Implemented issue #443 - Using text modules also in chat.

This commit is contained in:
Martin Edenhofer 2017-07-24 09:48:18 +02:00
parent 0986e89335
commit 3babd8495e
6 changed files with 35 additions and 10 deletions

View file

@ -462,6 +462,11 @@ class ChatWindow extends App.Controller
) )
) )
# show text module UI
new App.WidgetTextModule(
el: @input
)
focus: => focus: =>
@input.focus() @input.focus()
@ -473,7 +478,7 @@ class ChatWindow extends App.Controller
if event.data and event.data.callback if event.data and event.data.callback
event.data.callback() event.data.callback()
@$('.js-customerChatInput').ce({ @input.ce({
mode: 'richtext' mode: 'richtext'
multiline: true multiline: true
maxlength: 40000 maxlength: 40000
@ -522,7 +527,7 @@ class ChatWindow extends App.Controller
switch event.keyCode switch event.keyCode
when TABKEY when TABKEY
allChatInputs = $('.js-customerChatInput').not('[disabled="disabled"]') allChatInputs = @input.not('[disabled="disabled"]')
chatCount = allChatInputs.size() chatCount = allChatInputs.size()
index = allChatInputs.index(@input) index = allChatInputs.index(@input)
@ -542,7 +547,7 @@ class ChatWindow extends App.Controller
allChatInputs.eq(chatCount-1).focus() allChatInputs.eq(chatCount-1).focus()
when ENTERKEY when ENTERKEY
if !event.shiftKey if !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey
event.preventDefault() event.preventDefault()
@sendMessage() @sendMessage()

View file

@ -111,6 +111,15 @@
document.execCommand('Outdent') document.execCommand('Outdent')
return return
} }
// behavior to enter new line on alt+enter
// on alt + enter not realy newline is fired, to make
// it compat. to other systems, do it here
if (!e.shiftKey && e.altKey && !e.ctrlKey && !e.metaKey) {
e.preventDefault()
_this.paste('<br><br>')
return
}
} }
// on zammad magicKey + i/b/u/s // on zammad magicKey + i/b/u/s

View file

@ -54,6 +54,7 @@
// enter // enter
if (e.keyCode === 13) { if (e.keyCode === 13) {
e.preventDefault() e.preventDefault()
e.stopPropagation()
var id = _this.$widget.find('.dropdown-menu li.is-active').data('id') var id = _this.$widget.find('.dropdown-menu li.is-active').data('id')
// as fallback use hovered element // as fallback use hovered element
@ -92,6 +93,9 @@
var menu = _this.$widget.find('.dropdown-menu') var menu = _this.$widget.find('.dropdown-menu')
if (!active.get(0)) {
return
}
if (active.position().top < 0) { if (active.position().top < 0) {
// scroll up // scroll up
menu.scrollTop( menu.scrollTop() + active.position().top ) menu.scrollTop( menu.scrollTop() + active.position().top )
@ -187,7 +191,7 @@
// set height of widget // set height of widget
Plugin.prototype.movePosition = function() { Plugin.prototype.movePosition = function() {
if (!this._position) return if (!this._position) return
var height = this.$element.height() + 2 var height = this.$element.outerHeight() + 2
var widgetHeight = this.$widget.find('ul').height() //+ 60 // + height var widgetHeight = this.$widget.find('ul').height() //+ 60 // + height
var top = -( widgetHeight + height ) + this._position.top var top = -( widgetHeight + height ) + this._position.top
var left = this._position.left - 6 var left = this._position.left - 6

View file

@ -26,6 +26,8 @@
<div class="chat-body js-body"></div> <div class="chat-body js-body"></div>
</div> </div>
<div class="chat-controls"> <div class="chat-controls">
<div class="chat-input form-control form-control--small form-control--multiline js-customerChatInput" contenteditable="true"></div> <div class="chat-input">
<div class="form-control form-control--small form-control--multiline js-customerChatInput" contenteditable="true"></div>
</div>
<div class="btn btn--primary btn--slim btn--small js-send"><%- @T('Send') %></div> <div class="btn btn--primary btn--slim btn--small js-send"><%- @T('Send') %></div>
</div> </div>

View file

@ -8199,8 +8199,13 @@ output {
.chat-input { .chat-input {
margin-right: 10px; margin-right: 10px;
max-height: 50vh; flex-grow: 1;
position: relative;
.form-control {
overflow: auto; overflow: auto;
max-height: 50vh;
}
} }
.browser { .browser {