Fix chat textarea grow bug
- the chat input would make the bottom area jump when something get’s typed - in Firefox the chat placeholder was not visible when the chat input was empty
This commit is contained in:
parent
31b4138ab5
commit
c5af2f995a
6 changed files with 1933 additions and 210 deletions
|
@ -342,10 +342,10 @@
|
|||
float: left;
|
||||
width: auto;
|
||||
height: auto;
|
||||
min-height: 1.4em !important;
|
||||
max-height: 6em;
|
||||
min-height: 1.4em !important;
|
||||
font-family: inherit;
|
||||
line-height: inherit;
|
||||
line-height: 1.4em;
|
||||
font-size: inherit;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
|
@ -353,6 +353,7 @@
|
|||
border: none !important;
|
||||
background: none;
|
||||
box-shadow: none !important;
|
||||
box-sizing: content-box;
|
||||
outline: none;
|
||||
resize: none;
|
||||
-webkit-flex: 1;
|
||||
|
|
|
@ -1,3 +1,152 @@
|
|||
/*!
|
||||
* ----------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <jevin9@gmail.com> wrote this file. As long as you retain this notice you
|
||||
* can do whatever you want with this stuff. If we meet some day, and you think
|
||||
* this stuff is worth it, you can buy me a beer in return. Jevin O. Sewaruth
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* Autogrow Textarea Plugin Version v3.0
|
||||
* http://www.technoreply.com/autogrow-textarea-plugin-3-0
|
||||
*
|
||||
* THIS PLUGIN IS DELIVERD ON A PAY WHAT YOU WHANT BASIS. IF THE PLUGIN WAS USEFUL TO YOU, PLEASE CONSIDER BUYING THE PLUGIN HERE :
|
||||
* https://sites.fastspring.com/technoreply/instant/autogrowtextareaplugin
|
||||
*
|
||||
* Date: October 15, 2012
|
||||
*
|
||||
* Zammad modification: remove overflow:hidden when maximum height is reached
|
||||
*
|
||||
*/
|
||||
|
||||
jQuery.fn.autoGrow = function(options) {
|
||||
return this.each(function() {
|
||||
var settings = jQuery.extend({
|
||||
extraLine: true,
|
||||
}, options);
|
||||
|
||||
var createMirror = function(textarea) {
|
||||
jQuery(textarea).after('<div class="autogrow-textarea-mirror"></div>');
|
||||
return jQuery(textarea).next('.autogrow-textarea-mirror')[0];
|
||||
}
|
||||
|
||||
var sendContentToMirror = function (textarea) {
|
||||
mirror.innerHTML = String(textarea.value)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/ /g, ' ')
|
||||
.replace(/\n/g, '<br />') +
|
||||
(settings.extraLine? '.<br/>.' : '')
|
||||
;
|
||||
|
||||
if (jQuery(textarea).height() != jQuery(mirror).height()) {
|
||||
jQuery(textarea).height(jQuery(mirror).height());
|
||||
|
||||
var maxHeight = parseInt(jQuery(textarea).css('max-height'), 10);
|
||||
var overflow = jQuery(mirror).height() > maxHeight ? '' : 'hidden'
|
||||
jQuery(textarea).css('overflow', overflow);
|
||||
}
|
||||
}
|
||||
|
||||
var growTextarea = function () {
|
||||
sendContentToMirror(this);
|
||||
}
|
||||
|
||||
// Create a mirror
|
||||
var mirror = createMirror(this);
|
||||
|
||||
// Style the mirror
|
||||
mirror.style.display = 'none';
|
||||
mirror.style.wordWrap = 'break-word';
|
||||
mirror.style.whiteSpace = 'normal';
|
||||
mirror.style.padding = jQuery(this).css('paddingTop') + ' ' +
|
||||
jQuery(this).css('paddingRight') + ' ' +
|
||||
jQuery(this).css('paddingBottom') + ' ' +
|
||||
jQuery(this).css('paddingLeft');
|
||||
|
||||
mirror.style.width = jQuery(this).css('width');
|
||||
mirror.style.fontFamily = jQuery(this).css('font-family');
|
||||
mirror.style.fontSize = jQuery(this).css('font-size');
|
||||
mirror.style.lineHeight = jQuery(this).css('line-height');
|
||||
mirror.style.letterSpacing = jQuery(this).css('letter-spacing');
|
||||
mirror.style.boxSizing = jQuery(this).css('boxSizing');
|
||||
|
||||
// Style the textarea
|
||||
this.style.overflow = "hidden";
|
||||
this.style.minHeight = this.rows+"em";
|
||||
|
||||
// Bind the textarea's event
|
||||
this.onkeyup = growTextarea;
|
||||
this.onfocus = growTextarea;
|
||||
|
||||
// Fire the event for text already present
|
||||
sendContentToMirror(this);
|
||||
|
||||
});
|
||||
};
|
||||
if (!window.zammadChatTemplates) {
|
||||
window.zammadChatTemplates = {};
|
||||
}
|
||||
window.zammadChatTemplates["agent"] = function (__obj) {
|
||||
if (!__obj) __obj = {};
|
||||
var __out = [], __capture = function(callback) {
|
||||
var out = __out, result;
|
||||
__out = [];
|
||||
callback.call(this);
|
||||
result = __out.join('');
|
||||
__out = out;
|
||||
return __safe(result);
|
||||
}, __sanitize = function(value) {
|
||||
if (value && value.ecoSafe) {
|
||||
return value;
|
||||
} else if (typeof value !== 'undefined' && value != null) {
|
||||
return __escape(value);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
|
||||
__safe = __obj.safe = function(value) {
|
||||
if (value && value.ecoSafe) {
|
||||
return value;
|
||||
} else {
|
||||
if (!(typeof value !== 'undefined' && value != null)) value = '';
|
||||
var result = new String(value);
|
||||
result.ecoSafe = true;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
if (!__escape) {
|
||||
__escape = __obj.escape = function(value) {
|
||||
return ('' + value)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
};
|
||||
}
|
||||
(function() {
|
||||
(function() {
|
||||
if (this.agent.avatar) {
|
||||
__out.push('\n<img class="zammad-chat-agent-avatar" src="');
|
||||
__out.push(__sanitize(this.agent.avatar));
|
||||
__out.push('">\n');
|
||||
}
|
||||
|
||||
__out.push('\n<span class="zammad-chat-agent-sentence">\n <span class="zammad-chat-agent-name">');
|
||||
|
||||
__out.push(__sanitize(this.agent.name));
|
||||
|
||||
__out.push('</span>\n</span>');
|
||||
|
||||
}).call(this);
|
||||
|
||||
}).call(__obj);
|
||||
__obj.safe = __objSafe, __obj.escape = __escape;
|
||||
return __out.join('');
|
||||
};
|
||||
|
||||
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
||||
slice = [].slice,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
|
@ -1275,152 +1424,6 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
|
|||
return window.ZammadChat = ZammadChat;
|
||||
})(window.jQuery, window);
|
||||
|
||||
/*!
|
||||
* ----------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <jevin9@gmail.com> wrote this file. As long as you retain this notice you
|
||||
* can do whatever you want with this stuff. If we meet some day, and you think
|
||||
* this stuff is worth it, you can buy me a beer in return. Jevin O. Sewaruth
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* Autogrow Textarea Plugin Version v3.0
|
||||
* http://www.technoreply.com/autogrow-textarea-plugin-3-0
|
||||
*
|
||||
* THIS PLUGIN IS DELIVERD ON A PAY WHAT YOU WHANT BASIS. IF THE PLUGIN WAS USEFUL TO YOU, PLEASE CONSIDER BUYING THE PLUGIN HERE :
|
||||
* https://sites.fastspring.com/technoreply/instant/autogrowtextareaplugin
|
||||
*
|
||||
* Date: October 15, 2012
|
||||
*
|
||||
* Zammad modification: remove overflow:hidden when maximum height is reached
|
||||
*
|
||||
*/
|
||||
|
||||
jQuery.fn.autoGrow = function(options) {
|
||||
return this.each(function() {
|
||||
var settings = jQuery.extend({
|
||||
extraLine: true,
|
||||
}, options);
|
||||
|
||||
var createMirror = function(textarea) {
|
||||
jQuery(textarea).after('<div class="autogrow-textarea-mirror"></div>');
|
||||
return jQuery(textarea).next('.autogrow-textarea-mirror')[0];
|
||||
}
|
||||
|
||||
var sendContentToMirror = function (textarea) {
|
||||
mirror.innerHTML = String(textarea.value)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/ /g, ' ')
|
||||
.replace(/\n/g, '<br />') +
|
||||
(settings.extraLine? '.<br/>.' : '')
|
||||
;
|
||||
|
||||
if (jQuery(textarea).height() != jQuery(mirror).height()) {
|
||||
jQuery(textarea).height(jQuery(mirror).height());
|
||||
|
||||
var maxHeight = parseInt(jQuery(textarea).css('max-height'), 10);
|
||||
var overflow = jQuery(mirror).height() > maxHeight ? '' : 'hidden'
|
||||
jQuery(textarea).css('overflow', overflow);
|
||||
}
|
||||
}
|
||||
|
||||
var growTextarea = function () {
|
||||
sendContentToMirror(this);
|
||||
}
|
||||
|
||||
// Create a mirror
|
||||
var mirror = createMirror(this);
|
||||
|
||||
// Style the mirror
|
||||
mirror.style.display = 'none';
|
||||
mirror.style.wordWrap = 'break-word';
|
||||
mirror.style.whiteSpace = 'normal';
|
||||
mirror.style.padding = jQuery(this).css('paddingTop') + ' ' +
|
||||
jQuery(this).css('paddingRight') + ' ' +
|
||||
jQuery(this).css('paddingBottom') + ' ' +
|
||||
jQuery(this).css('paddingLeft');
|
||||
|
||||
mirror.style.width = jQuery(this).css('width');
|
||||
mirror.style.fontFamily = jQuery(this).css('font-family');
|
||||
mirror.style.fontSize = jQuery(this).css('font-size');
|
||||
mirror.style.lineHeight = jQuery(this).css('line-height');
|
||||
|
||||
// Style the textarea
|
||||
this.style.overflow = "hidden";
|
||||
this.style.minHeight = this.rows+"em";
|
||||
|
||||
// Bind the textarea's event
|
||||
this.onkeyup = growTextarea;
|
||||
|
||||
// Fire the event for text already present
|
||||
sendContentToMirror(this);
|
||||
|
||||
});
|
||||
};
|
||||
if (!window.zammadChatTemplates) {
|
||||
window.zammadChatTemplates = {};
|
||||
}
|
||||
window.zammadChatTemplates["agent"] = function (__obj) {
|
||||
if (!__obj) __obj = {};
|
||||
var __out = [], __capture = function(callback) {
|
||||
var out = __out, result;
|
||||
__out = [];
|
||||
callback.call(this);
|
||||
result = __out.join('');
|
||||
__out = out;
|
||||
return __safe(result);
|
||||
}, __sanitize = function(value) {
|
||||
if (value && value.ecoSafe) {
|
||||
return value;
|
||||
} else if (typeof value !== 'undefined' && value != null) {
|
||||
return __escape(value);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
|
||||
__safe = __obj.safe = function(value) {
|
||||
if (value && value.ecoSafe) {
|
||||
return value;
|
||||
} else {
|
||||
if (!(typeof value !== 'undefined' && value != null)) value = '';
|
||||
var result = new String(value);
|
||||
result.ecoSafe = true;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
if (!__escape) {
|
||||
__escape = __obj.escape = function(value) {
|
||||
return ('' + value)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
};
|
||||
}
|
||||
(function() {
|
||||
(function() {
|
||||
if (this.agent.avatar) {
|
||||
__out.push('\n<img class="zammad-chat-agent-avatar" src="');
|
||||
__out.push(__sanitize(this.agent.avatar));
|
||||
__out.push('">\n');
|
||||
}
|
||||
|
||||
__out.push('\n<span class="zammad-chat-agent-sentence">\n <span class="zammad-chat-agent-name">');
|
||||
|
||||
__out.push(__sanitize(this.agent.name));
|
||||
|
||||
__out.push('</span>\n</span>');
|
||||
|
||||
}).call(this);
|
||||
|
||||
}).call(__obj);
|
||||
__obj.safe = __objSafe, __obj.escape = __escape;
|
||||
return __out.join('');
|
||||
};
|
||||
|
||||
if (!window.zammadChatTemplates) {
|
||||
window.zammadChatTemplates = {};
|
||||
}
|
||||
|
|
4
public/assets/chat/chat.min.js
vendored
4
public/assets/chat/chat.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -351,15 +351,16 @@
|
|||
float: left;
|
||||
width: auto;
|
||||
height: auto;
|
||||
min-height: 1.4em !important;
|
||||
max-height: 6em;
|
||||
min-height: 1.4em !important;
|
||||
font-family: inherit;
|
||||
line-height: inherit;
|
||||
line-height: 1.4em;
|
||||
font-size: inherit;
|
||||
appearance: none;
|
||||
border: none !important;
|
||||
background: none;
|
||||
box-shadow: none !important;
|
||||
box-sizing: content-box;
|
||||
outline: none;
|
||||
resize: none;
|
||||
flex: 1;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,9 @@
|
|||
*
|
||||
* Date: October 15, 2012
|
||||
*
|
||||
* Zammad modification: remove overflow:hidden when maximum height is reached
|
||||
* Zammad modification:
|
||||
* - remove overflow:hidden when maximum height is reached
|
||||
* - mirror box-sizing
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -44,8 +46,7 @@ jQuery.fn.autoGrow = function(options) {
|
|||
if (jQuery(textarea).height() != jQuery(mirror).height()) {
|
||||
jQuery(textarea).height(jQuery(mirror).height());
|
||||
|
||||
var maxHeight = parseInt(jQuery(textarea).css('max-height'), 10);
|
||||
var overflow = jQuery(mirror).height() > maxHeight ? '' : 'hidden'
|
||||
var overflow = jQuery(mirror).height() > maxHeight ? '' : 'hidden';
|
||||
jQuery(textarea).css('overflow', overflow);
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +57,9 @@ jQuery.fn.autoGrow = function(options) {
|
|||
|
||||
// Create a mirror
|
||||
var mirror = createMirror(this);
|
||||
|
||||
// Store max-height
|
||||
var maxHeight = parseInt(jQuery(this).css('max-height'), 10);
|
||||
|
||||
// Style the mirror
|
||||
mirror.style.display = 'none';
|
||||
|
@ -70,6 +74,8 @@ jQuery.fn.autoGrow = function(options) {
|
|||
mirror.style.fontFamily = jQuery(this).css('font-family');
|
||||
mirror.style.fontSize = jQuery(this).css('font-size');
|
||||
mirror.style.lineHeight = jQuery(this).css('line-height');
|
||||
mirror.style.letterSpacing = jQuery(this).css('letter-spacing');
|
||||
mirror.style.boxSizing = jQuery(this).css('boxSizing');
|
||||
|
||||
// Style the textarea
|
||||
this.style.overflow = "hidden";
|
||||
|
@ -77,6 +83,7 @@ jQuery.fn.autoGrow = function(options) {
|
|||
|
||||
// Bind the textarea's event
|
||||
this.onkeyup = growTextarea;
|
||||
this.onfocus = growTextarea;
|
||||
|
||||
// Fire the event for text already present
|
||||
sendContentToMirror(this);
|
||||
|
|
Loading…
Reference in a new issue