|
|
|
@ -196,21 +196,6 @@ EmojiTooltip.prototype.onMouseLeave = function (triggerUnshow) {
@@ -196,21 +196,6 @@ EmojiTooltip.prototype.onMouseLeave = function (triggerUnshow) {
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
EmojiTooltip.prototype.getScrollWidth = function() { |
|
|
|
|
var outer = $('<div>').css({ |
|
|
|
|
position: 'absolute', |
|
|
|
|
width: 100, |
|
|
|
|
height: 100, |
|
|
|
|
overflow: 'scroll', |
|
|
|
|
top: -9999 |
|
|
|
|
}).appendTo($(document.body)); |
|
|
|
|
|
|
|
|
|
var scrollbarWidth = outer[0].offsetWidth - outer[0].clientWidth; |
|
|
|
|
outer.remove(); |
|
|
|
|
|
|
|
|
|
return scrollbarWidth; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EmojiTooltip.prototype.createTooltip = function () { |
|
|
|
@ -219,20 +204,12 @@ EmojiTooltip.prototype.createTooltip = function () {
@@ -219,20 +204,12 @@ EmojiTooltip.prototype.createTooltip = function () {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
this.tooltipEl = $('<div class="composer_emoji_tooltip noselect"><div class="composer_emoji_tooltip_tabs"></div><div class="composer_emoji_tooltip_content_wrap nano mobile_scrollable_wrap"><div class="composer_emoji_tooltip_content nano-content clearfix"></div></div><div class="composer_emoji_tooltip_footer"><a class="composer_emoji_tooltip_settings"></a></div><div class="composer_emoji_tooltip_tail"><i class="icon icon-tooltip-tail"></i></div></div>').appendTo(document.body); |
|
|
|
|
|
|
|
|
|
this.tabsEl = $('.composer_emoji_tooltip_tabs', this.tooltip); |
|
|
|
|
this.contentWrapEl = $('.composer_emoji_tooltip_content_wrap', this.tooltip); |
|
|
|
|
this.contentEl = $('.composer_emoji_tooltip_content', this.tooltip); |
|
|
|
|
this.footerEl = $('.composer_emoji_tooltip_footer', this.tooltip); |
|
|
|
|
this.settingsEl = $('.composer_emoji_tooltip_settings', this.tooltip); |
|
|
|
|
|
|
|
|
|
var scrollWidth = this.getScrollWidth(); |
|
|
|
|
if (scrollWidth > 0) { |
|
|
|
|
this.tooltipEl.css({ |
|
|
|
|
width: parseInt(this.tooltipEl.css('width')) + scrollWidth |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.tooltipEl = $('<div class="composer_emoji_tooltip noselect"><div class="composer_emoji_tooltip_tabs"></div><div class="composer_emoji_tooltip_content clearfix"></div><div class="composer_emoji_tooltip_footer"><a class="composer_emoji_tooltip_settings"></a></div><div class="composer_emoji_tooltip_tail"><i class="icon icon-tooltip-tail"></i></div></div>').appendTo(document.body); |
|
|
|
|
|
|
|
|
|
this.tabsEl = $('.composer_emoji_tooltip_tabs', this.tooltipEl); |
|
|
|
|
this.contentEl = $('.composer_emoji_tooltip_content', this.tooltipEl); |
|
|
|
|
this.footerEl = $('.composer_emoji_tooltip_footer', this.tooltipEl); |
|
|
|
|
this.settingsEl = $('.composer_emoji_tooltip_settings', this.tooltipEl); |
|
|
|
|
|
|
|
|
|
angular.forEach(['recent', 'smile', 'flower', 'bell', 'car', 'grid', 'stickers'], function (tabName, tabIndex) { |
|
|
|
|
var tab = $('<a class="composer_emoji_tooltip_tab composer_emoji_tooltip_tab_' + tabName + '"></a>') |
|
|
|
@ -254,9 +231,7 @@ EmojiTooltip.prototype.createTooltip = function () {
@@ -254,9 +231,7 @@ EmojiTooltip.prototype.createTooltip = function () {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (!Config.Mobile) { |
|
|
|
|
this.contentWrapEl.nanoScroller({preventPageScrolling: true, tabIndex: -1}); |
|
|
|
|
} |
|
|
|
|
this.scroller = new Scroller(this.contentEl, {classPrefix: 'composer_emoji_tooltip'}); |
|
|
|
|
|
|
|
|
|
this.contentEl.on('mousedown', function (e) { |
|
|
|
|
e = e.originalEvent || e; |
|
|
|
@ -323,13 +298,7 @@ EmojiTooltip.prototype.updateTabContents = function () {
@@ -323,13 +298,7 @@ EmojiTooltip.prototype.updateTabContents = function () {
|
|
|
|
|
|
|
|
|
|
var renderContent = function () { |
|
|
|
|
self.contentEl.html(html.join('')); |
|
|
|
|
|
|
|
|
|
if (!Config.Mobile) { |
|
|
|
|
self.contentWrapEl.nanoScroller({scroll: 'top'}); |
|
|
|
|
setTimeout(function () { |
|
|
|
|
self.contentWrapEl.nanoScroller(); |
|
|
|
|
}, 100); |
|
|
|
|
} |
|
|
|
|
self.scroller.reinit(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.tab == 6) { // Stickers
|
|
|
|
@ -488,12 +457,9 @@ function MessageComposer (textarea, options) {
@@ -488,12 +457,9 @@ function MessageComposer (textarea, options) {
|
|
|
|
|
this.setUpInput(); |
|
|
|
|
|
|
|
|
|
this.autoCompleteWrapEl = $('<div class="composer_dropdown_wrap"></div>').appendTo(document.body); |
|
|
|
|
this.autoCompleteScrollerEl = $('<div class="composer_dropdown_scroller nano"></div>').appendTo(this.autoCompleteWrapEl); |
|
|
|
|
this.autoCompleteEl = $('<ul class="composer_dropdown dropdown-menu nano-content"></ul>').appendTo(this.autoCompleteScrollerEl); |
|
|
|
|
this.autoCompleteEl = $('<ul class="composer_dropdown dropdown-menu"></ul>').appendTo(this.autoCompleteWrapEl); |
|
|
|
|
|
|
|
|
|
if (!Config.Mobile) { |
|
|
|
|
this.autoCompleteScrollerEl.nanoScroller({preventPageScrolling: true, tabIndex: -1}); |
|
|
|
|
} |
|
|
|
|
this.scroller = new Scroller(this.autoCompleteEl, {maxHeight: 180}); |
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
this.autoCompleteEl.on('mousedown', function (e) { |
|
|
|
@ -614,18 +580,14 @@ MessageComposer.prototype.onKeyEvent = function (e) {
@@ -614,18 +580,14 @@ MessageComposer.prototype.onKeyEvent = function (e) {
|
|
|
|
|
currentSelected.removeClass('composer_autocomplete_option_active'); |
|
|
|
|
if (nextWrap) { |
|
|
|
|
$(nextWrap).find('a').addClass('composer_autocomplete_option_active'); |
|
|
|
|
if (!Config.Mobile) { |
|
|
|
|
scrollToNode(this.autoCompleteEl[0], nextWrap, this.autoCompleteScrollerEl); |
|
|
|
|
} |
|
|
|
|
this.scroller.scrollToNode(nextWrap); |
|
|
|
|
return cancelEvent(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var childNodes = this.autoCompleteEl[0].childNodes; |
|
|
|
|
var nextWrap = childNodes[next ? 0 : childNodes.length - 1]; |
|
|
|
|
if (!Config.Mobile) { |
|
|
|
|
scrollToNode(this.autoCompleteEl[0], nextWrap, this.autoCompleteScrollerEl); |
|
|
|
|
} |
|
|
|
|
this.scroller.scrollToNode(nextWrap); |
|
|
|
|
$(nextWrap).find('a').addClass('composer_autocomplete_option_active'); |
|
|
|
|
|
|
|
|
|
return cancelEvent(e); |
|
|
|
@ -714,7 +676,7 @@ MessageComposer.prototype.restoreSelection = function () {
@@ -714,7 +676,7 @@ MessageComposer.prototype.restoreSelection = function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.checkAutocomplete = function () { |
|
|
|
|
MessageComposer.prototype.checkAutocomplete = function (forceFull) { |
|
|
|
|
if (Config.Mobile) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -730,7 +692,9 @@ MessageComposer.prototype.checkAutocomplete = function () {
@@ -730,7 +692,9 @@ MessageComposer.prototype.checkAutocomplete = function () {
|
|
|
|
|
var value = textarea.value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
value = value.substr(0, pos); |
|
|
|
|
if (!forceFull) { |
|
|
|
|
value = value.substr(0, pos); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var matches = value.match(this.autoCompleteRegEx); |
|
|
|
|
if (matches) { |
|
|
|
@ -1096,15 +1060,7 @@ MessageComposer.prototype.focus = function () {
@@ -1096,15 +1060,7 @@ MessageComposer.prototype.focus = function () {
|
|
|
|
|
MessageComposer.prototype.renderSuggestions = function (html) { |
|
|
|
|
this.autoCompleteEl.html(html.join('')); |
|
|
|
|
this.autoCompleteWrapEl.show(); |
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
if (!Config.Mobile) { |
|
|
|
|
self.autoCompleteScrollerEl.nanoScroller({scroll: 'top'}); |
|
|
|
|
setTimeout(function () { |
|
|
|
|
self.autoCompleteScrollerEl.nanoScroller(); |
|
|
|
|
}, 100); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.scroller.reinit(); |
|
|
|
|
this.updatePosition(); |
|
|
|
|
this.autocompleteShown = true; |
|
|
|
|
} |
|
|
|
@ -1161,7 +1117,7 @@ MessageComposer.prototype.showCommandsSuggestions = function (commands) {
@@ -1161,7 +1117,7 @@ MessageComposer.prototype.showCommandsSuggestions = function (commands) {
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) { |
|
|
|
|
command = commands[i]; |
|
|
|
|
html.push('<li><a class="composer_command_option" data-command="' + encodeEntities(command.value) + '"><span class="composer_user_photo" data-user-id="' + command.botID + '"></span><span class="composer_command_value">' + encodeEntities(command.value) + '</span><span class="composer_command_desc">' + encodeEntities(command.description) + '</span></a></li>'); |
|
|
|
|
html.push('<li><a class="composer_command_option" data-command="' + encodeEntities(command.value) + '"><span class="composer_user_photo" data-user-id="' + command.botID + '"></span><span class="composer_command_value">' + encodeEntities(command.value) + '</span><span class="composer_command_desc">' + command.rDescription + '</span></a></li>'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.renderSuggestions(html); |
|
|
|
@ -1182,14 +1138,13 @@ MessageComposer.prototype.showCommandsSuggestions = function (commands) {
@@ -1182,14 +1138,13 @@ MessageComposer.prototype.showCommandsSuggestions = function (commands) {
|
|
|
|
|
MessageComposer.prototype.updatePosition = function () { |
|
|
|
|
var offset = (this.richTextareaEl || this.textareaEl).offset(); |
|
|
|
|
var width = (this.richTextareaEl || this.textareaEl).outerWidth(); |
|
|
|
|
var contentHeight = this.autoCompleteEl[0].firstChild.clientHeight * this.autoCompleteEl[0].childNodes.length; |
|
|
|
|
var height = Math.min(180, contentHeight); |
|
|
|
|
var height = this.scroller.updateHeight(); |
|
|
|
|
this.autoCompleteWrapEl.css({ |
|
|
|
|
top: offset.top - height, |
|
|
|
|
left: offset.left, |
|
|
|
|
width: width - 2, |
|
|
|
|
height: height |
|
|
|
|
width: width - 2 |
|
|
|
|
}); |
|
|
|
|
this.scroller.update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.hideSuggestions = function () { |
|
|
|
@ -1202,3 +1157,83 @@ MessageComposer.prototype.resetTyping = function () {
@@ -1202,3 +1157,83 @@ MessageComposer.prototype.resetTyping = function () {
|
|
|
|
|
this.lastLength = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Scroller(content, options) { |
|
|
|
|
options = options || {}; |
|
|
|
|
var classPrefix = options.classPrefix || 'scroller'; |
|
|
|
|
|
|
|
|
|
this.content = $(content); |
|
|
|
|
this.content.wrap('<div class="' + classPrefix + '_scrollable_container"><div class="' + classPrefix + '_scrollable_wrap"><div class="' + classPrefix + '_scrollable"></div></div></div>'); |
|
|
|
|
|
|
|
|
|
this.scrollable = $(this.content[0].parentNode); |
|
|
|
|
this.scroller = $(this.scrollable[0].parentNode); |
|
|
|
|
this.wrap = $(this.scroller[0].parentNode); |
|
|
|
|
|
|
|
|
|
this.useNano = options.nano !== undefined ? options.nano : !Config.Mobile; |
|
|
|
|
this.maxHeight = options.maxHeight; |
|
|
|
|
|
|
|
|
|
if (this.useNano) { |
|
|
|
|
this.scrollable.addClass('nano-content'); |
|
|
|
|
this.scroller.addClass('nano'); |
|
|
|
|
this.scroller.nanoScroller({preventPageScrolling: true, tabIndex: -1}); |
|
|
|
|
} else { |
|
|
|
|
if (this.maxHeight) { |
|
|
|
|
this.wrap.css({maxHeight: this.maxHeight}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.updateHeight(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Scroller.prototype.update = function () { |
|
|
|
|
if (this.useNano) { |
|
|
|
|
$(this.scroller).nanoScroller(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Scroller.prototype.reinit = function () { |
|
|
|
|
this.scrollTo(0); |
|
|
|
|
if (this.useNano) { |
|
|
|
|
setTimeout((function () { |
|
|
|
|
this.updateHeight(); |
|
|
|
|
}).bind(this), 100) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Scroller.prototype.updateHeight = function () { |
|
|
|
|
var height; |
|
|
|
|
if (this.maxHeight) { |
|
|
|
|
var contentHeight = this.content[0].offsetHeight; |
|
|
|
|
height = Math.min(this.maxHeight, contentHeight); |
|
|
|
|
this.wrap.css({height: height}); |
|
|
|
|
} else { |
|
|
|
|
height = this.scroller[0].offsetHeight; |
|
|
|
|
} |
|
|
|
|
$(this.scroller).nanoScroller(); |
|
|
|
|
return height; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Scroller.prototype.scrollTo = function (scrollTop) { |
|
|
|
|
this.scrollable[0].scrollTop = scrollTop; |
|
|
|
|
if (this.useNano) { |
|
|
|
|
$(this.scroller).nanoScroller({flash: true}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Scroller.prototype.scrollToNode = function (node) { |
|
|
|
|
node = node[0] || node; |
|
|
|
|
var elTop = node.offsetTop - 15, |
|
|
|
|
elHeight = node.offsetHeight + 30, |
|
|
|
|
scrollTop = this.scrollable[0].scrollTop, |
|
|
|
|
viewportHeight = this.scrollable[0].clientHeight; |
|
|
|
|
|
|
|
|
|
if (scrollTop > elTop) { // we are below the node to scroll
|
|
|
|
|
this.scrollTo(elTop); |
|
|
|
|
} |
|
|
|
|
else if (scrollTop < elTop + elHeight - viewportHeight) { // we are over the node to scroll
|
|
|
|
|
this.scrollTo(elTop + elHeight - viewportHeight); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|