|
|
@ -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 () { |
|
|
|
EmojiTooltip.prototype.createTooltip = function () { |
|
|
@ -219,20 +204,12 @@ EmojiTooltip.prototype.createTooltip = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
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.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.tooltip); |
|
|
|
this.tabsEl = $('.composer_emoji_tooltip_tabs', this.tooltipEl); |
|
|
|
this.contentWrapEl = $('.composer_emoji_tooltip_content_wrap', this.tooltip); |
|
|
|
this.contentEl = $('.composer_emoji_tooltip_content', this.tooltipEl); |
|
|
|
this.contentEl = $('.composer_emoji_tooltip_content', this.tooltip); |
|
|
|
this.footerEl = $('.composer_emoji_tooltip_footer', this.tooltipEl); |
|
|
|
this.footerEl = $('.composer_emoji_tooltip_footer', this.tooltip); |
|
|
|
this.settingsEl = $('.composer_emoji_tooltip_settings', this.tooltipEl); |
|
|
|
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 |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
angular.forEach(['recent', 'smile', 'flower', 'bell', 'car', 'grid', 'stickers'], function (tabName, tabIndex) { |
|
|
|
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>') |
|
|
|
var tab = $('<a class="composer_emoji_tooltip_tab composer_emoji_tooltip_tab_' + tabName + '"></a>') |
|
|
@ -254,9 +231,7 @@ EmojiTooltip.prototype.createTooltip = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (!Config.Mobile) { |
|
|
|
this.scroller = new Scroller(this.contentEl, {classPrefix: 'composer_emoji_tooltip'}); |
|
|
|
this.contentWrapEl.nanoScroller({preventPageScrolling: true, tabIndex: -1}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.contentEl.on('mousedown', function (e) { |
|
|
|
this.contentEl.on('mousedown', function (e) { |
|
|
|
e = e.originalEvent || e; |
|
|
|
e = e.originalEvent || e; |
|
|
@ -323,13 +298,7 @@ EmojiTooltip.prototype.updateTabContents = function () { |
|
|
|
|
|
|
|
|
|
|
|
var renderContent = function () { |
|
|
|
var renderContent = function () { |
|
|
|
self.contentEl.html(html.join('')); |
|
|
|
self.contentEl.html(html.join('')); |
|
|
|
|
|
|
|
self.scroller.reinit(); |
|
|
|
if (!Config.Mobile) { |
|
|
|
|
|
|
|
self.contentWrapEl.nanoScroller({scroll: 'top'}); |
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
|
|
self.contentWrapEl.nanoScroller(); |
|
|
|
|
|
|
|
}, 100); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.tab == 6) { // Stickers
|
|
|
|
if (this.tab == 6) { // Stickers
|
|
|
@ -488,12 +457,9 @@ function MessageComposer (textarea, options) { |
|
|
|
this.setUpInput(); |
|
|
|
this.setUpInput(); |
|
|
|
|
|
|
|
|
|
|
|
this.autoCompleteWrapEl = $('<div class="composer_dropdown_wrap"></div>').appendTo(document.body); |
|
|
|
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"></ul>').appendTo(this.autoCompleteWrapEl); |
|
|
|
this.autoCompleteEl = $('<ul class="composer_dropdown dropdown-menu nano-content"></ul>').appendTo(this.autoCompleteScrollerEl); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Config.Mobile) { |
|
|
|
this.scroller = new Scroller(this.autoCompleteEl, {maxHeight: 180}); |
|
|
|
this.autoCompleteScrollerEl.nanoScroller({preventPageScrolling: true, tabIndex: -1}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
this.autoCompleteEl.on('mousedown', function (e) { |
|
|
|
this.autoCompleteEl.on('mousedown', function (e) { |
|
|
@ -614,18 +580,14 @@ MessageComposer.prototype.onKeyEvent = function (e) { |
|
|
|
currentSelected.removeClass('composer_autocomplete_option_active'); |
|
|
|
currentSelected.removeClass('composer_autocomplete_option_active'); |
|
|
|
if (nextWrap) { |
|
|
|
if (nextWrap) { |
|
|
|
$(nextWrap).find('a').addClass('composer_autocomplete_option_active'); |
|
|
|
$(nextWrap).find('a').addClass('composer_autocomplete_option_active'); |
|
|
|
if (!Config.Mobile) { |
|
|
|
this.scroller.scrollToNode(nextWrap); |
|
|
|
scrollToNode(this.autoCompleteEl[0], nextWrap, this.autoCompleteScrollerEl); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return cancelEvent(e); |
|
|
|
return cancelEvent(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var childNodes = this.autoCompleteEl[0].childNodes; |
|
|
|
var childNodes = this.autoCompleteEl[0].childNodes; |
|
|
|
var nextWrap = childNodes[next ? 0 : childNodes.length - 1]; |
|
|
|
var nextWrap = childNodes[next ? 0 : childNodes.length - 1]; |
|
|
|
if (!Config.Mobile) { |
|
|
|
this.scroller.scrollToNode(nextWrap); |
|
|
|
scrollToNode(this.autoCompleteEl[0], nextWrap, this.autoCompleteScrollerEl); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$(nextWrap).find('a').addClass('composer_autocomplete_option_active'); |
|
|
|
$(nextWrap).find('a').addClass('composer_autocomplete_option_active'); |
|
|
|
|
|
|
|
|
|
|
|
return cancelEvent(e); |
|
|
|
return cancelEvent(e); |
|
|
@ -714,7 +676,7 @@ MessageComposer.prototype.restoreSelection = function () { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.checkAutocomplete = function () { |
|
|
|
MessageComposer.prototype.checkAutocomplete = function (forceFull) { |
|
|
|
if (Config.Mobile) { |
|
|
|
if (Config.Mobile) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -730,7 +692,9 @@ MessageComposer.prototype.checkAutocomplete = function () { |
|
|
|
var value = textarea.value; |
|
|
|
var value = textarea.value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!forceFull) { |
|
|
|
value = value.substr(0, pos); |
|
|
|
value = value.substr(0, pos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var matches = value.match(this.autoCompleteRegEx); |
|
|
|
var matches = value.match(this.autoCompleteRegEx); |
|
|
|
if (matches) { |
|
|
|
if (matches) { |
|
|
@ -1096,15 +1060,7 @@ MessageComposer.prototype.focus = function () { |
|
|
|
MessageComposer.prototype.renderSuggestions = function (html) { |
|
|
|
MessageComposer.prototype.renderSuggestions = function (html) { |
|
|
|
this.autoCompleteEl.html(html.join('')); |
|
|
|
this.autoCompleteEl.html(html.join('')); |
|
|
|
this.autoCompleteWrapEl.show(); |
|
|
|
this.autoCompleteWrapEl.show(); |
|
|
|
|
|
|
|
this.scroller.reinit(); |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (!Config.Mobile) { |
|
|
|
|
|
|
|
self.autoCompleteScrollerEl.nanoScroller({scroll: 'top'}); |
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
|
|
self.autoCompleteScrollerEl.nanoScroller(); |
|
|
|
|
|
|
|
}, 100); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.updatePosition(); |
|
|
|
this.updatePosition(); |
|
|
|
this.autocompleteShown = true; |
|
|
|
this.autocompleteShown = true; |
|
|
|
} |
|
|
|
} |
|
|
@ -1161,7 +1117,7 @@ MessageComposer.prototype.showCommandsSuggestions = function (commands) { |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) { |
|
|
|
for (i = 0; i < count; i++) { |
|
|
|
command = commands[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); |
|
|
|
this.renderSuggestions(html); |
|
|
@ -1182,14 +1138,13 @@ MessageComposer.prototype.showCommandsSuggestions = function (commands) { |
|
|
|
MessageComposer.prototype.updatePosition = function () { |
|
|
|
MessageComposer.prototype.updatePosition = function () { |
|
|
|
var offset = (this.richTextareaEl || this.textareaEl).offset(); |
|
|
|
var offset = (this.richTextareaEl || this.textareaEl).offset(); |
|
|
|
var width = (this.richTextareaEl || this.textareaEl).outerWidth(); |
|
|
|
var width = (this.richTextareaEl || this.textareaEl).outerWidth(); |
|
|
|
var contentHeight = this.autoCompleteEl[0].firstChild.clientHeight * this.autoCompleteEl[0].childNodes.length; |
|
|
|
var height = this.scroller.updateHeight(); |
|
|
|
var height = Math.min(180, contentHeight); |
|
|
|
|
|
|
|
this.autoCompleteWrapEl.css({ |
|
|
|
this.autoCompleteWrapEl.css({ |
|
|
|
top: offset.top - height, |
|
|
|
top: offset.top - height, |
|
|
|
left: offset.left, |
|
|
|
left: offset.left, |
|
|
|
width: width - 2, |
|
|
|
width: width - 2 |
|
|
|
height: height |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
this.scroller.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.hideSuggestions = function () { |
|
|
|
MessageComposer.prototype.hideSuggestions = function () { |
|
|
@ -1202,3 +1157,83 @@ MessageComposer.prototype.resetTyping = function () { |
|
|
|
this.lastLength = 0; |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|