|
|
@ -674,38 +674,19 @@ EmojiPanel.prototype.update = function () { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function MessageComposer (textarea, options) { |
|
|
|
function MessageComposer (textarea, options) { |
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
|
|
|
|
this.textareaEl = $(textarea); |
|
|
|
this.textareaEl = $(textarea); |
|
|
|
|
|
|
|
|
|
|
|
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.autoCompleteEl = $('<ul class="composer_dropdown dropdown-menu"></ul>').appendTo(this.autoCompleteWrapEl); |
|
|
|
var autoCompleteEl = $('<div></div>').appendTo(this.autoCompleteWrapEl); |
|
|
|
|
|
|
|
|
|
|
|
this.scroller = new Scroller(this.autoCompleteEl, {maxHeight: 180}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
options.dropdownDirective(div, function (scope, autoCompleteEl) { |
|
|
|
this.autoCompleteEl.on('mousedown', function (e) { |
|
|
|
self.autoCompleteEl = autoCompleteEl; |
|
|
|
e = e.originalEvent || e; |
|
|
|
self.autoCompleteScope = scope; |
|
|
|
var target = $(e.target), mention, code, command; |
|
|
|
self.setUpAutoComplete(); |
|
|
|
if (target[0].tagName != 'A') { |
|
|
|
|
|
|
|
target = $(target[0].parentNode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (code = target.attr('data-code')) { |
|
|
|
|
|
|
|
if (self.onEmojiSelected) { |
|
|
|
|
|
|
|
self.onEmojiSelected(code, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
EmojiHelper.pushPopularEmoji(code); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (mention = target.attr('data-mention')) { |
|
|
|
|
|
|
|
self.onMentionSelected(mention); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (command = target.attr('data-command')) { |
|
|
|
|
|
|
|
if (self.onCommandSelected) { |
|
|
|
|
|
|
|
self.onCommandSelected(command); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.hideSuggestions(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return cancelEvent(e); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.isActive = false; |
|
|
|
this.isActive = false; |
|
|
@ -714,10 +695,9 @@ function MessageComposer (textarea, options) { |
|
|
|
this.onMessageSubmit = options.onMessageSubmit; |
|
|
|
this.onMessageSubmit = options.onMessageSubmit; |
|
|
|
this.getSendOnEnter = options.getSendOnEnter; |
|
|
|
this.getSendOnEnter = options.getSendOnEnter; |
|
|
|
this.onFilePaste = options.onFilePaste; |
|
|
|
this.onFilePaste = options.onFilePaste; |
|
|
|
|
|
|
|
this.onCommandSend = options.onCommandSend; |
|
|
|
this.mentions = options.mentions; |
|
|
|
this.mentions = options.mentions; |
|
|
|
this.commands = options.commands; |
|
|
|
this.commands = options.commands; |
|
|
|
this.getPeerImage = options.getPeerImage; |
|
|
|
|
|
|
|
this.onCommandSend = options.onCommandSend; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.autoCompleteRegEx = /(\s|^)(:|@|\/)([A-Za-z0-9\-\+\*@_]*)$/; |
|
|
|
MessageComposer.autoCompleteRegEx = /(\s|^)(:|@|\/)([A-Za-z0-9\-\+\*@_]*)$/; |
|
|
@ -738,6 +718,35 @@ MessageComposer.prototype.setUpInput = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.setUpAutoComplete = function () { |
|
|
|
|
|
|
|
this.scroller = new Scroller(this.autoCompleteEl, {maxHeight: 180}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
this.autoCompleteEl.on('mousedown', function (e) { |
|
|
|
|
|
|
|
e = e.originalEvent || e; |
|
|
|
|
|
|
|
var target = $(e.target), mention, code, command; |
|
|
|
|
|
|
|
if (target[0].tagName != 'A') { |
|
|
|
|
|
|
|
target = $(target[0].parentNode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (code = target.attr('data-code')) { |
|
|
|
|
|
|
|
if (self.onEmojiSelected) { |
|
|
|
|
|
|
|
self.onEmojiSelected(code, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
EmojiHelper.pushPopularEmoji(code); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (mention = target.attr('data-mention')) { |
|
|
|
|
|
|
|
self.onMentionSelected(mention); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (command = target.attr('data-command')) { |
|
|
|
|
|
|
|
if (self.onCommandSelected) { |
|
|
|
|
|
|
|
self.onCommandSelected(command); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.hideSuggestions(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return cancelEvent(e); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.setUpRich = function () { |
|
|
|
MessageComposer.prototype.setUpRich = function () { |
|
|
|
this.textareaEl.hide(); |
|
|
|
this.textareaEl.hide(); |
|
|
|
this.richTextareaEl = $('<div class="composer_rich_textarea" contenteditable="true" dir="auto"></div>'); |
|
|
|
this.richTextareaEl = $('<div class="composer_rich_textarea" contenteditable="true" dir="auto"></div>'); |
|
|
@ -1353,8 +1362,7 @@ MessageComposer.prototype.blur = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.renderSuggestions = function (html) { |
|
|
|
MessageComposer.prototype.renderSuggestions = function () { |
|
|
|
this.autoCompleteEl.html(html.join('')); |
|
|
|
|
|
|
|
this.autoCompleteWrapEl.show(); |
|
|
|
this.autoCompleteWrapEl.show(); |
|
|
|
this.scroller.reinit(); |
|
|
|
this.scroller.reinit(); |
|
|
|
this.updatePosition(); |
|
|
|
this.updatePosition(); |
|
|
@ -1362,72 +1370,35 @@ MessageComposer.prototype.renderSuggestions = function (html) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.showEmojiSuggestions = function (codes) { |
|
|
|
MessageComposer.prototype.showEmojiSuggestions = function (codes) { |
|
|
|
var html = []; |
|
|
|
var self = this; |
|
|
|
var iconSize = Config.Mobile ? 26 : 20; |
|
|
|
this.autoCompleteScope.$apply(function () { |
|
|
|
|
|
|
|
self.autoCompleteScope.type = 'emoji'; |
|
|
|
var emoticonCode, emoticonData, spritesheet, pos, categoryIndex; |
|
|
|
self.autoCompleteScope.emojiCodes = codes; |
|
|
|
var count = Math.min(5, codes.length); |
|
|
|
}); |
|
|
|
var i, x, y; |
|
|
|
onContentLoaded(function () { |
|
|
|
|
|
|
|
self.renderSuggestions(); |
|
|
|
for (i = 0; i < count; i++) { |
|
|
|
}); |
|
|
|
emoticonCode = codes[i]; |
|
|
|
|
|
|
|
if (emoticonCode.code) { |
|
|
|
|
|
|
|
emoticonCode = emoticonCode.code; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (emoticonData = Config.Emoji[emoticonCode]) { |
|
|
|
|
|
|
|
spritesheet = EmojiHelper.spritesheetPositions[emoticonCode]; |
|
|
|
|
|
|
|
categoryIndex = spritesheet[0]; |
|
|
|
|
|
|
|
pos = spritesheet[1]; |
|
|
|
|
|
|
|
x = iconSize * spritesheet[3]; |
|
|
|
|
|
|
|
y = iconSize * spritesheet[2]; |
|
|
|
|
|
|
|
html.push('<li><a class="composer_emoji_option" data-code="' + encodeEntities(emoticonCode) + '"><i class="emoji emoji-w', iconSize, ' emoji-spritesheet-' + categoryIndex + '" style="background-position: -' + x + 'px -' + y + 'px;"></i><span class="composer_emoji_shortcut">:' + encodeEntities(emoticonData[1][0]) + ':</span></a></li>'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.renderSuggestions(html); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.showMentionSuggestions = function (users) { |
|
|
|
MessageComposer.prototype.showMentionSuggestions = function (users) { |
|
|
|
var html = []; |
|
|
|
|
|
|
|
var user; |
|
|
|
|
|
|
|
var count = users.length; |
|
|
|
|
|
|
|
var i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) { |
|
|
|
|
|
|
|
user = users[i]; |
|
|
|
|
|
|
|
html.push('<li><a class="composer_mention_option" data-mention="' + user.username + '"><span class="composer_user_photo" data-user-id="' + user.id + '"></span><span class="composer_user_name">' + user.rFullName + '</span><span class="composer_user_mention">@' + user.username + '</span></a></li>'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.renderSuggestions(html); |
|
|
|
|
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
this.autoCompleteEl.find('.composer_user_photo').each(function (k, element) { |
|
|
|
this.autoCompleteScope.$apply(function () { |
|
|
|
self.getPeerImage($(element), element.getAttribute('data-user-id')); |
|
|
|
self.autoCompleteScope.type = 'mentions'; |
|
|
|
|
|
|
|
self.autoCompleteScope.mentionUsers = users; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
onContentLoaded(function () { |
|
|
|
|
|
|
|
self.renderSuggestions(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MessageComposer.prototype.showCommandsSuggestions = function (commands) { |
|
|
|
MessageComposer.prototype.showCommandsSuggestions = function (commands) { |
|
|
|
var html = []; |
|
|
|
|
|
|
|
var command; |
|
|
|
|
|
|
|
var count = Math.min(200, commands.length); |
|
|
|
|
|
|
|
var i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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">' + command.rDescription + '</span></a></li>'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.renderSuggestions(html); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
var usedImages = {}; |
|
|
|
this.autoCompleteScope.$apply(function () { |
|
|
|
this.autoCompleteEl.find('.composer_user_photo').each(function (k, element) { |
|
|
|
self.autoCompleteScope.type = 'commands'; |
|
|
|
var noReplace = true; |
|
|
|
self.autoCompleteScope.commands = commands; |
|
|
|
var botID = element.getAttribute('data-user-id'); |
|
|
|
}); |
|
|
|
if (!usedImages[botID]) { |
|
|
|
onContentLoaded(function () { |
|
|
|
usedImages[botID] = true; |
|
|
|
self.renderSuggestions(); |
|
|
|
noReplace = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.getPeerImage($(element), botID, noReplace); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|