Merge branch 'pr/698'
This commit is contained in:
commit
1ce4c0c3d4
@ -1165,13 +1165,17 @@ a.mobile_modal_action .tg_checkbox_label {
|
|||||||
|
|
||||||
|
|
||||||
.composer_emoji_tooltip {
|
.composer_emoji_tooltip {
|
||||||
margin-left: 10px;
|
margin-left: 6px;
|
||||||
margin-top: -175px;
|
margin-top: -170px;
|
||||||
width: 262px;
|
width: 262px;
|
||||||
|
z-index: 10000;
|
||||||
}
|
}
|
||||||
.composer_emoji_tooltip .composer_emoji_tooltip_content {
|
.composer_emoji_tooltip .composer_emoji_tooltip_content_wrap {
|
||||||
height: 106px;
|
height: 106px;
|
||||||
}
|
}
|
||||||
|
.composer_emoji_tooltip_tabs {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
.composer_emoji_tooltip .composer_emoji_tooltip_content .composer_emoji_btn {
|
.composer_emoji_tooltip .composer_emoji_tooltip_content .composer_emoji_btn {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
@ -952,10 +952,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
}
|
}
|
||||||
if (pos > -1) {
|
if (pos > -1) {
|
||||||
history = $scope.peerHistories[pos];
|
history = $scope.peerHistories[pos];
|
||||||
// if (pos) {
|
|
||||||
// $scope.peerHistories.splice(pos, 1);
|
|
||||||
// $scope.peerHistories.unshift(history);
|
|
||||||
// }
|
|
||||||
return history;
|
return history;
|
||||||
}
|
}
|
||||||
history = {peerID: peerID, messages: []};
|
history = {peerID: peerID, messages: []};
|
||||||
@ -1389,7 +1385,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
}
|
}
|
||||||
// console.log('append', addedMessage);
|
// console.log('append', addedMessage);
|
||||||
// console.trace();
|
// console.trace();
|
||||||
history.messages.push(AppMessagesManager.wrapForHistory(addedMessage.messageID));
|
var historyMessage = AppMessagesManager.wrapForHistory(addedMessage.messageID);
|
||||||
|
history.messages.push(historyMessage);
|
||||||
if (AppMessagesManager.regroupWrappedHistory(history.messages, -3)) {
|
if (AppMessagesManager.regroupWrappedHistory(history.messages, -3)) {
|
||||||
$scope.$broadcast('messages_regroup');
|
$scope.$broadcast('messages_regroup');
|
||||||
}
|
}
|
||||||
@ -1402,8 +1399,16 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
$scope.$broadcast('messages_unread_after');
|
$scope.$broadcast('messages_unread_after');
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('append check', $rootScope.idle.isIDLE, addedMessage.peerID, $scope.curDialog.peerID);
|
// console.log('append check', $rootScope.idle.isIDLE, addedMessage.peerID, $scope.curDialog.peerID, historyMessage, history.messages[history.messages.length - 2]);
|
||||||
if (!$rootScope.idle.isIDLE) {
|
if ($rootScope.idle.isIDLE) {
|
||||||
|
if (historyMessage.unread &&
|
||||||
|
!historyMessage.out &&
|
||||||
|
!(history.messages[history.messages.length - 2] || {}).unread) {
|
||||||
|
|
||||||
|
$scope.historyUnreadAfter = historyMessage.id;
|
||||||
|
$scope.$broadcast('messages_unread_after');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
AppMessagesManager.readHistory($scope.curDialog.inputPeer);
|
AppMessagesManager.readHistory($scope.curDialog.inputPeer);
|
||||||
});
|
});
|
||||||
|
@ -1119,7 +1119,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
return sendOnEnter;
|
return sendOnEnter;
|
||||||
},
|
},
|
||||||
onMessageSubmit: onMessageSubmit,
|
onMessageSubmit: onMessageSubmit,
|
||||||
onFilesPaste: onFilesPaste
|
onFilePaste: onFilePaste
|
||||||
});
|
});
|
||||||
|
|
||||||
var richTextarea = composer.richTextareaEl[0];
|
var richTextarea = composer.richTextareaEl[0];
|
||||||
@ -1204,7 +1204,9 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
composer.setValue($scope.draftMessage.text || '');
|
composer.setValue($scope.draftMessage.text || '');
|
||||||
updateHeight();
|
updateHeight();
|
||||||
}
|
}
|
||||||
|
if (!Config.Navigator.touch) {
|
||||||
composer.focus();
|
composer.focus();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var sendAwaiting = false;
|
var sendAwaiting = false;
|
||||||
@ -1214,7 +1216,9 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
});
|
});
|
||||||
$scope.$on('ui_message_send', function () {
|
$scope.$on('ui_message_send', function () {
|
||||||
sendAwaiting = false;
|
sendAwaiting = false;
|
||||||
|
if (!Config.Navigator.touch) {
|
||||||
focusField();
|
focusField();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function focusField () {
|
function focusField () {
|
||||||
@ -1223,9 +1227,9 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFilesPaste (blobs) {
|
function onFilePaste (blob) {
|
||||||
ErrorService.confirm({type: 'FILE_CLIPBOARD_PASTE'}).then(function () {
|
ErrorService.confirm({type: 'FILE_CLIPBOARD_PASTE'}).then(function () {
|
||||||
$scope.draftMessage.files = blobs;
|
$scope.draftMessage.files = [blob];
|
||||||
$scope.draftMessage.isMedia = true;
|
$scope.draftMessage.isMedia = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -2344,6 +2348,8 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
var updatePeerPhoto = function () {
|
var updatePeerPhoto = function () {
|
||||||
|
var curJump = ++jump;
|
||||||
|
|
||||||
peerPhoto = peer.photo && angular.copy(peer.photo.photo_small);
|
peerPhoto = peer.photo && angular.copy(peer.photo.photo_small);
|
||||||
|
|
||||||
var hasPhoto = peerPhoto !== undefined;
|
var hasPhoto = peerPhoto !== undefined;
|
||||||
@ -2362,7 +2368,6 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
|
|
||||||
|
|
||||||
if (hasPhoto) {
|
if (hasPhoto) {
|
||||||
var curJump = ++jump;
|
|
||||||
|
|
||||||
MtpApiFileManager.downloadSmallFile(peer.photo.photo_small).then(function (blob) {
|
MtpApiFileManager.downloadSmallFile(peer.photo.photo_small).then(function (blob) {
|
||||||
if (curJump != jump) {
|
if (curJump != jump) {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -53,6 +53,7 @@
|
|||||||
if (Array.isArray(shortcut)) {
|
if (Array.isArray(shortcut)) {
|
||||||
shortcut = shortcut[0];
|
shortcut = shortcut[0];
|
||||||
}
|
}
|
||||||
|
if (shortcut && typeof shortcut === 'string') {
|
||||||
if (shortcut.charAt(0) == ':') {
|
if (shortcut.charAt(0) == ':') {
|
||||||
shortcut = shortcut.substr(1, shortcut.length - 2);
|
shortcut = shortcut.substr(1, shortcut.length - 2);
|
||||||
}
|
}
|
||||||
@ -60,6 +61,7 @@
|
|||||||
result.push({code: code, rate: 1});
|
result.push({code: code, rate: 1});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
callback(result);
|
callback(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -139,6 +141,7 @@ function EmojiTooltip (btnEl, options) {
|
|||||||
this.onStickerSelected = options.onStickerSelected;
|
this.onStickerSelected = options.onStickerSelected;
|
||||||
this.getStickers = options.getStickers;
|
this.getStickers = options.getStickers;
|
||||||
|
|
||||||
|
if (!Config.Navigator.touch) {
|
||||||
$(this.btnEl).on('mouseenter mouseleave', function (e) {
|
$(this.btnEl).on('mouseenter mouseleave', function (e) {
|
||||||
self.isOverBtn = e.type == 'mouseenter';
|
self.isOverBtn = e.type == 'mouseenter';
|
||||||
self.createTooltip();
|
self.createTooltip();
|
||||||
@ -149,16 +152,19 @@ function EmojiTooltip (btnEl, options) {
|
|||||||
self.onMouseLeave(true);
|
self.onMouseLeave(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
$(this.btnEl).on('mousedown', function (e) {
|
$(this.btnEl).on('mousedown', function (e) {
|
||||||
if (!self.shown) {
|
if (!self.shown) {
|
||||||
clearTimeout(self.showTimeout);
|
clearTimeout(self.showTimeout);
|
||||||
delete self.showTimeout;
|
delete self.showTimeout;
|
||||||
|
self.createTooltip();
|
||||||
self.show();
|
self.show();
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(self.hideTimeout);
|
clearTimeout(self.hideTimeout);
|
||||||
delete self.hideTimeout;
|
delete self.hideTimeout;
|
||||||
self.hide();
|
self.hide();
|
||||||
}
|
}
|
||||||
|
return cancelEvent(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,20 +208,23 @@ EmojiTooltip.prototype.createTooltip = function () {
|
|||||||
this.settingsEl = $('.composer_emoji_tooltip_settings', this.tooltip);
|
this.settingsEl = $('.composer_emoji_tooltip_settings', this.tooltip);
|
||||||
|
|
||||||
angular.forEach(['recent', 'smile', 'flower', 'bell', 'car', 'grid', 'stickers'], function (tabName, tabIndex) {
|
angular.forEach(['recent', 'smile', 'flower', 'bell', 'car', 'grid', 'stickers'], function (tabName, tabIndex) {
|
||||||
$('<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>')
|
||||||
.on('mousedown', function (e) {
|
.on('mousedown', function (e) {
|
||||||
self.selectTab(tabIndex);
|
self.selectTab(tabIndex);
|
||||||
return cancelEvent(e);
|
return cancelEvent(e);
|
||||||
})
|
})
|
||||||
.on('mouseenter mouseleave', function (e) {
|
.appendTo(self.tabsEl);
|
||||||
|
|
||||||
|
if (!Config.Navigator.touch) {
|
||||||
|
tab.on('mouseenter mouseleave', function (e) {
|
||||||
clearTimeout(self.selectTabTimeout);
|
clearTimeout(self.selectTabTimeout);
|
||||||
if (e.type == 'mouseenter') {
|
if (e.type == 'mouseenter') {
|
||||||
self.selectTabTimeout = setTimeout(function () {
|
self.selectTabTimeout = setTimeout(function () {
|
||||||
self.selectTab(tabIndex);
|
self.selectTab(tabIndex);
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.appendTo(self.tabsEl);
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Config.Mobile) {
|
if (!Config.Mobile) {
|
||||||
@ -238,10 +247,14 @@ EmojiTooltip.prototype.createTooltip = function () {
|
|||||||
if (self.onStickerSelected) {
|
if (self.onStickerSelected) {
|
||||||
self.onStickerSelected(sticker);
|
self.onStickerSelected(sticker);
|
||||||
}
|
}
|
||||||
|
if (Config.Mobile) {
|
||||||
|
self.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cancelEvent(e);
|
return cancelEvent(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!Config.Navigator.touch) {
|
||||||
this.tooltipEl.on('mouseenter mouseleave', function (e) {
|
this.tooltipEl.on('mouseenter mouseleave', function (e) {
|
||||||
if (e.type == 'mouseenter') {
|
if (e.type == 'mouseenter') {
|
||||||
self.onMouseEnter();
|
self.onMouseEnter();
|
||||||
@ -249,9 +262,12 @@ EmojiTooltip.prototype.createTooltip = function () {
|
|||||||
self.onMouseLeave();
|
self.onMouseLeave();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.selectTab(0);
|
this.selectTab(0);
|
||||||
|
|
||||||
|
$(window).on('resize', this.updatePosition.bind(this));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,6 +454,7 @@ function MessageComposer (textarea, options) {
|
|||||||
this.onTyping = options.onTyping;
|
this.onTyping = options.onTyping;
|
||||||
this.onMessageSubmit = options.onMessageSubmit;
|
this.onMessageSubmit = options.onMessageSubmit;
|
||||||
this.getSendOnEnter = options.getSendOnEnter;
|
this.getSendOnEnter = options.getSendOnEnter;
|
||||||
|
this.onFilePaste = options.onFilePaste;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageComposer.prototype.setUpInput = function () {
|
MessageComposer.prototype.setUpInput = function () {
|
||||||
@ -472,19 +489,7 @@ MessageComposer.prototype.onKeyEvent = function (e) {
|
|||||||
if (e.type == 'keyup') {
|
if (e.type == 'keyup') {
|
||||||
this.checkAutocomplete();
|
this.checkAutocomplete();
|
||||||
|
|
||||||
if (this.onTyping) {
|
var length = false;
|
||||||
var now = tsNow();
|
|
||||||
if (now - this.lastTyping > 5000) {
|
|
||||||
var length = (this.richTextareaEl ? this.richTextareaEl[0].textContent : this.textareaEl[0].value).length;
|
|
||||||
|
|
||||||
if (length != this.lastLength) {
|
|
||||||
this.lastTyping = now;
|
|
||||||
this.lastLength = length;
|
|
||||||
this.onTyping();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.richTextareaEl) {
|
if (this.richTextareaEl) {
|
||||||
clearTimeout(this.updateValueTO);
|
clearTimeout(this.updateValueTO);
|
||||||
var now = tsNow();
|
var now = tsNow();
|
||||||
@ -495,12 +500,33 @@ MessageComposer.prototype.onKeyEvent = function (e) {
|
|||||||
this.onChange();
|
this.onChange();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
length = this.richTextareaEl[0].textContent.length;
|
||||||
|
if (this.wasEmpty != !length) {
|
||||||
|
this.wasEmpty = !this.wasEmpty;
|
||||||
|
this.onChange();
|
||||||
|
} else {
|
||||||
this.updateValueTO = setTimeout(this.onChange.bind(this), 1000);
|
this.updateValueTO = setTimeout(this.onChange.bind(this), 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.onTyping) {
|
||||||
|
var now = tsNow();
|
||||||
|
if (now - this.lastTyping > 5000) {
|
||||||
|
if (length === false) {
|
||||||
|
length = (this.richTextareaEl ? this.richTextareaEl[0].textContent : this.textareaEl[0].value).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length != this.lastLength) {
|
||||||
|
this.lastTyping = now;
|
||||||
|
this.lastLength = length;
|
||||||
|
this.onTyping();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (e.type == 'keydown') {
|
if (e.type == 'keydown') {
|
||||||
|
var checkSubmit = !this.autocompleteShown;
|
||||||
if (this.autocompleteShown) {
|
if (this.autocompleteShown) {
|
||||||
if (e.keyCode == 38 || e.keyCode == 40) { // UP / DOWN
|
if (e.keyCode == 38 || e.keyCode == 40) { // UP / DOWN
|
||||||
var next = e.keyCode == 40;
|
var next = e.keyCode == 40;
|
||||||
@ -524,18 +550,19 @@ MessageComposer.prototype.onKeyEvent = function (e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e.keyCode == 13) { // ENTER
|
if (e.keyCode == 13) { // ENTER
|
||||||
var currentSelected = $(this.autoCompleteEl).find('.composer_emoji_option_active') ||
|
var currentSelected = $(this.autoCompleteEl).find('.composer_emoji_option_active')/* ||
|
||||||
$(this.autoCompleteEl).childNodes[0].find('a');
|
$(this.autoCompleteEl).childNodes[0].find('a')*/;
|
||||||
var code = currentSelected.attr('data-code');
|
var code = currentSelected.attr('data-code');
|
||||||
if (code) {
|
if (code) {
|
||||||
this.onEmojiSelected(code, true);
|
this.onEmojiSelected(code, true);
|
||||||
EmojiHelper.pushPopularEmoji(code);
|
EmojiHelper.pushPopularEmoji(code);
|
||||||
}
|
|
||||||
return cancelEvent(e);
|
return cancelEvent(e);
|
||||||
}
|
}
|
||||||
|
checkSubmit = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (e.keyCode == 13) {
|
if (checkSubmit && e.keyCode == 13) {
|
||||||
var submit = false;
|
var submit = false;
|
||||||
var sendOnEnter = true;
|
var sendOnEnter = true;
|
||||||
if (this.getSendOnEnter && !this.getSendOnEnter()) {
|
if (this.getSendOnEnter && !this.getSendOnEnter()) {
|
||||||
@ -594,6 +621,9 @@ MessageComposer.prototype.restoreSelection = function () {
|
|||||||
|
|
||||||
|
|
||||||
MessageComposer.prototype.checkAutocomplete = function () {
|
MessageComposer.prototype.checkAutocomplete = function () {
|
||||||
|
if (Config.Mobile) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var pos, value;
|
var pos, value;
|
||||||
if (this.richTextareaEl) {
|
if (this.richTextareaEl) {
|
||||||
var textarea = this.richTextareaEl[0];
|
var textarea = this.richTextareaEl[0];
|
||||||
@ -671,7 +701,11 @@ MessageComposer.prototype.onRichPaste = function (e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = (e.originalEvent || e).clipboardData.getData('text/plain');
|
try {
|
||||||
|
var text = cData.getData('text/plain');
|
||||||
|
} catch (e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
setZeroTimeout(this.onChange.bind(this), 0);
|
setZeroTimeout(this.onChange.bind(this), 0);
|
||||||
if (text.length) {
|
if (text.length) {
|
||||||
document.execCommand('insertText', false, text);
|
document.execCommand('insertText', false, text);
|
||||||
@ -690,7 +724,7 @@ MessageComposer.prototype.onRichPasteNode = function (e) {
|
|||||||
var blob = dataUrlToBlob(src);
|
var blob = dataUrlToBlob(src);
|
||||||
this.onFilePaste(blob);
|
this.onFilePaste(blob);
|
||||||
setZeroTimeout(function () {
|
setZeroTimeout(function () {
|
||||||
element.parentNode.removeChild(element);
|
element.parentNode.replaceChild(document.createTextNode(' '), element);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else if (src && !src.match(/img\/blank\.gif/)) {
|
else if (src && !src.match(/img\/blank\.gif/)) {
|
||||||
@ -808,6 +842,8 @@ MessageComposer.prototype.setValue = function (text) {
|
|||||||
if (this.richTextareaEl) {
|
if (this.richTextareaEl) {
|
||||||
this.richTextareaEl.html(this.getRichHtml(text));
|
this.richTextareaEl.html(this.getRichHtml(text));
|
||||||
this.lastLength = text.length;
|
this.lastLength = text.length;
|
||||||
|
this.wasEmpty = !text.length;
|
||||||
|
this.onKeyEvent({type: 'keyup'});
|
||||||
} else {
|
} else {
|
||||||
this.textareaEl.val(text);
|
this.textareaEl.val(text);
|
||||||
}
|
}
|
||||||
|
@ -1967,6 +1967,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curMessage.fwd_from_id &&
|
||||||
|
curMessage.media &&
|
||||||
|
curMessage.media.document &&
|
||||||
|
curMessage.media.document.sticker &&
|
||||||
|
(curMessage.from_id != (prevMessage || {}).from_id || !(prevMessage || {}).fwd_from_id)) {
|
||||||
|
delete curMessage.fwd_from_id;
|
||||||
|
curMessage._ = 'message';
|
||||||
|
}
|
||||||
|
|
||||||
if (prevMessage &&
|
if (prevMessage &&
|
||||||
curMessage.from_id == prevMessage.from_id &&
|
curMessage.from_id == prevMessage.from_id &&
|
||||||
!prevMessage.fwd_from_id == !curMessage.fwd_from_id &&
|
!prevMessage.fwd_from_id == !curMessage.fwd_from_id &&
|
||||||
@ -3495,15 +3504,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
|
|
||||||
.service('RichTextProcessor', function ($sce, $sanitize) {
|
.service('RichTextProcessor', function ($sce, $sanitize) {
|
||||||
|
|
||||||
var emojiUtf = [],
|
var emojiMap = {},
|
||||||
emojiMap = {},
|
|
||||||
emojiData = Config.Emoji,
|
emojiData = Config.Emoji,
|
||||||
emojiIconSize = 18,
|
emojiIconSize = 18,
|
||||||
emojiSupported = navigator.userAgent.search(/OS X|iPhone|iPad|iOS|Android/i) != -1,
|
emojiSupported = navigator.userAgent.search(/OS X|iPhone|iPad|iOS|Android/i) != -1,
|
||||||
emojiCode;
|
emojiCode;
|
||||||
|
|
||||||
|
var emojiRegex = '\\u0023\\u20E3|\\u00a9|\\u00ae|\\u203c|\\u2049|\\u2139|[\\u2194-\\u2199]|\\u21a9|\\u21aa|\\u231a|\\u231b|\\u23e9|[\\u23ea-\\u23ec]|\\u23f0|\\u24c2|\\u25aa|\\u25ab|\\u25b6|\\u2611|\\u2614|\\u26fd|\\u2705|\\u2709|[\\u2795-\\u2797]|\\u27a1|\\u27b0|\\u27bf|\\u2934|\\u2935|[\\u2b05-\\u2b07]|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u3030|\\u303d|\\u3297|\\u3299|[\\uE000-\\uF8FF\\u270A-\\u2764\\u2122\\u25C0\\u25FB-\\u25FE\\u2615\\u263a\\u2648-\\u2653\\u2660-\\u2668\\u267B\\u267F\\u2693\\u261d\\u26A0-\\u26FA\\u2708\\u2702\\u2601\\u260E]|[\\u2600\\u26C4\\u26BE\\u23F3\\u2764]|\\uD83D[\\uDC00-\\uDFFF]|\\uD83C[\\uDDE8-\\uDDFA\uDDEC]\\uD83C[\\uDDEA-\\uDDFA\uDDE7]|[0-9]\\u20e3|\\uD83C[\\uDC00-\\uDFFF]';
|
||||||
|
|
||||||
for (emojiCode in emojiData) {
|
for (emojiCode in emojiData) {
|
||||||
emojiUtf.push(emojiData[emojiCode][0]);
|
|
||||||
emojiMap[emojiData[emojiCode][0]] = emojiCode;
|
emojiMap[emojiData[emojiCode][0]] = emojiCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3535,11 +3544,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
|
|
||||||
var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars;
|
var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars;
|
||||||
|
|
||||||
// Regular Expression for URL validation by Diego Perini
|
// Based on Regular Expression for URL validation by Diego Perini
|
||||||
var urlRegex = "((?:https?|ftp)://|mailto:)?" +
|
var urlRegex = "((?:https?|ftp)://|mailto:)?" +
|
||||||
// user:pass authentication
|
// user:pass authentication
|
||||||
"(?:\\S+(?::\\S*)?@)?" +
|
"(?:\\S+(?::\\S*)?@)?" +
|
||||||
"(?:" +
|
"(?:" +
|
||||||
|
// sindresorhus/ip-regex
|
||||||
"(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}" +
|
"(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}" +
|
||||||
"|" +
|
"|" +
|
||||||
// host name
|
// host name
|
||||||
@ -3547,14 +3557,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
// domain name
|
// domain name
|
||||||
"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
|
"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
|
||||||
// TLD identifier
|
// TLD identifier
|
||||||
"(?:\\.(?:[a-z\\u00a1-\\uffff]{2,24}))" +
|
"(?:\\.(xn--[0-9a-z]{2,16}|[a-z\\u00a1-\\uffff]{2,24}))" +
|
||||||
")" +
|
")" +
|
||||||
// port number
|
// port number
|
||||||
"(?::\\d{2,5})?" +
|
"(?::\\d{2,5})?" +
|
||||||
// resource path
|
// resource path
|
||||||
"(?:/[^\\s\\.\"\']*)?";
|
"(?:/(?:\\S*[^\\s.;,(\\[\\]{}<>\"'])?)?";
|
||||||
|
|
||||||
var regExp = new RegExp('(^|\\s)((?:https?://)?telegram\\.me/|@)([a-zA-Z\\d_]{5,32})|(' + urlRegex + ')|(\\n)|(' + emojiUtf.join('|') + ')|(^|\\s)(#[' + regexAlphaNumericChars + ']{2,20})', 'i');
|
var regExp = new RegExp('(^|\\s)((?:https?://)?telegram\\.me/|@)([a-zA-Z\\d_]{5,32})|(' + urlRegex + ')|(\\n)|(' + emojiRegex + ')|(^|\\s)(#[' + regexAlphaNumericChars + ']{2,20})', 'i');
|
||||||
|
|
||||||
var emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
var emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
var youtubeRegex = /^(?:https?:\/\/)?(?:www\.)?youtu(?:|\.be|be\.com|\.b)(?:\/v\/|\/watch\\?v=|e\/|(?:\/\??#)?\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/;
|
var youtubeRegex = /^(?:https?:\/\/)?(?:www\.)?youtu(?:|\.be|be\.com|\.b)(?:\/v\/|\/watch\\?v=|e\/|(?:\/\??#)?\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/;
|
||||||
@ -3593,8 +3603,6 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
text = text.replace(/\ufe0f/g, '', text);
|
|
||||||
|
|
||||||
var match,
|
var match,
|
||||||
raw = text,
|
raw = text,
|
||||||
html = [],
|
html = [],
|
||||||
@ -3603,6 +3611,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
emojiTitle,
|
emojiTitle,
|
||||||
emojiCoords;
|
emojiCoords;
|
||||||
|
|
||||||
|
// var start = tsNow();
|
||||||
|
|
||||||
while ((match = raw.match(regExp))) {
|
while ((match = raw.match(regExp))) {
|
||||||
html.push(encodeEntities(raw.substr(0, match.index)));
|
html.push(encodeEntities(raw.substr(0, match.index)));
|
||||||
|
|
||||||
@ -3634,33 +3644,61 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
'</a>'
|
'</a>'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
var url = (match[5] ? '' : 'http://') + match[4];
|
var url = false,
|
||||||
|
protocol = match[5],
|
||||||
|
tld = match[6],
|
||||||
|
excluded = '';
|
||||||
|
|
||||||
|
if (tld) {
|
||||||
|
if (!protocol && (tld.substr(0, 4) === 'xn--' || Config.TLD.indexOf(tld.toLowerCase()) !== -1)) {
|
||||||
|
protocol = 'http://';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (protocol) {
|
||||||
|
var balanced = checkBrackets(match[4]);
|
||||||
|
|
||||||
|
if (balanced.length !== match[4].length) {
|
||||||
|
excluded = match[4].substring(balanced.length);
|
||||||
|
match[4] = balanced;
|
||||||
|
}
|
||||||
|
|
||||||
|
url = (match[5] ? '' : protocol) + match[4];
|
||||||
|
}
|
||||||
|
} else { // IP address
|
||||||
|
url = (match[5] ? '' : 'http://') + match[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url) {
|
||||||
html.push(
|
html.push(
|
||||||
'<a href="',
|
'<a href="',
|
||||||
encodeEntities(url),
|
encodeEntities(url),
|
||||||
'" target="_blank">',
|
'" target="_blank">',
|
||||||
encodeEntities(match[4]),
|
encodeEntities(match[4]),
|
||||||
'</a>'
|
'</a>',
|
||||||
|
excluded
|
||||||
);
|
);
|
||||||
|
|
||||||
if (options.extractUrlEmbed &&
|
if (options.extractUrlEmbed &&
|
||||||
!options.extractedUrlEmbed) {
|
!options.extractedUrlEmbed) {
|
||||||
options.extractedUrlEmbed = findExternalEmbed(url);
|
options.extractedUrlEmbed = findExternalEmbed(url);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
html.push(encodeEntities(match[0]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
html.push(encodeEntities(match[0]));
|
html.push(encodeEntities(match[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (match[6]) { // New line
|
else if (match[7]) { // New line
|
||||||
if (!options.noLinebreaks) {
|
if (!options.noLinebreaks) {
|
||||||
html.push('<br/>');
|
html.push('<br/>');
|
||||||
} else {
|
} else {
|
||||||
html.push(' ');
|
html.push(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (match[7]) {
|
else if (match[8]) {
|
||||||
if ((emojiCode = emojiMap[match[7]]) &&
|
if ((emojiCode = emojiMap[match[8]]) &&
|
||||||
(emojiCoords = getEmojiSpritesheetCoords(emojiCode))) {
|
(emojiCoords = getEmojiSpritesheetCoords(emojiCode))) {
|
||||||
|
|
||||||
emojiTitle = encodeEntities(emojiData[emojiCode][1][0]);
|
emojiTitle = encodeEntities(emojiData[emojiCode][1][0]);
|
||||||
@ -3677,21 +3715,21 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
':', emojiTitle, ':</span>'
|
':', emojiTitle, ':</span>'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
html.push(encodeEntities(match[7]));
|
html.push(encodeEntities(match[8]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (match[9]) {
|
else if (match[10]) {
|
||||||
if (!options.noLinks) {
|
if (!options.noLinks) {
|
||||||
html.push(
|
html.push(
|
||||||
'<a href="#/im?q=',
|
'<a href="#/im?q=',
|
||||||
encodeURIComponent(match[9]),
|
encodeURIComponent(match[10]),
|
||||||
'">',
|
'">',
|
||||||
encodeEntities(match[9]),
|
encodeEntities(match[10]),
|
||||||
'</a>'
|
'</a>'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
html.push(
|
html.push(
|
||||||
encodeEntities(match[9])
|
encodeEntities(match[10])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3700,11 +3738,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
|
|
||||||
html.push(encodeEntities(raw));
|
html.push(encodeEntities(raw));
|
||||||
|
|
||||||
|
// var timeDiff = tsNow() - start;
|
||||||
|
// if (timeDiff > 1) {
|
||||||
|
// console.log(dT(), 'wrap text', text.length, timeDiff);
|
||||||
|
// }
|
||||||
|
|
||||||
text = $sanitize(html.join(''));
|
text = $sanitize(html.join(''));
|
||||||
|
|
||||||
// console.log(3, text, html);
|
// console.log(3, text, html);
|
||||||
|
|
||||||
if (emojiFound) {
|
if (emojiFound) {
|
||||||
|
text = text.replace(/\ufe0f|️/g, '', text);
|
||||||
text = text.replace(/<span class="emoji emoji-(\d)-(\d+)-(\d+)"(.+?)<\/span>/g,
|
text = text.replace(/<span class="emoji emoji-(\d)-(\d+)-(\d+)"(.+?)<\/span>/g,
|
||||||
'<span class="emoji emoji-spritesheet-$1" style="background-position: -$2px -$3px;" $4</span>');
|
'<span class="emoji emoji-spritesheet-$1" style="background-position: -$2px -$3px;" $4</span>');
|
||||||
}
|
}
|
||||||
@ -3712,6 +3756,20 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
return $sce.trustAs('html', text);
|
return $sce.trustAs('html', text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkBrackets(url) {
|
||||||
|
var urlLength = url.length,
|
||||||
|
urlOpenBrackets = url.split('(').length - 1,
|
||||||
|
urlCloseBrackets = url.split(')').length - 1;
|
||||||
|
|
||||||
|
while (urlCloseBrackets > urlOpenBrackets &&
|
||||||
|
url.charAt(urlLength - 1) === ')') {
|
||||||
|
url = url.substr(0, urlLength - 1);
|
||||||
|
urlCloseBrackets--;
|
||||||
|
urlLength--;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
function findExternalEmbed(url) {
|
function findExternalEmbed(url) {
|
||||||
var embedUrlMatches,
|
var embedUrlMatches,
|
||||||
result;
|
result;
|
||||||
@ -3773,8 +3831,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
while ((match = raw.match(regExp))) {
|
while ((match = raw.match(regExp))) {
|
||||||
text.push(raw.substr(0, match.index));
|
text.push(raw.substr(0, match.index));
|
||||||
|
|
||||||
if (match[6]) {
|
if (match[7]) {
|
||||||
if ((emojiCode = emojiMap[match[6]]) &&
|
if ((emojiCode = emojiMap[match[7]]) &&
|
||||||
(emojiTitle = emojiData[emojiCode][1][0])) {
|
(emojiTitle = emojiData[emojiCode][1][0])) {
|
||||||
text.push(':' + emojiTitle + ':');
|
text.push(':' + emojiTitle + ':');
|
||||||
} else {
|
} else {
|
||||||
@ -3887,6 +3945,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
var langNotificationsPluralize = _.pluralize('page_title_pluralize_notifications');
|
var langNotificationsPluralize = _.pluralize('page_title_pluralize_notifications');
|
||||||
|
|
||||||
var titleBackup = document.title,
|
var titleBackup = document.title,
|
||||||
|
titleChanged = false,
|
||||||
titlePromise;
|
titlePromise;
|
||||||
var prevFavicon;
|
var prevFavicon;
|
||||||
|
|
||||||
@ -3897,6 +3956,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
if (!Config.Navigator.mobile) {
|
if (!Config.Navigator.mobile) {
|
||||||
$interval.cancel(titlePromise);
|
$interval.cancel(titlePromise);
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
|
titleChanged = false;
|
||||||
document.title = titleBackup;
|
document.title = titleBackup;
|
||||||
setFavicon();
|
setFavicon();
|
||||||
} else {
|
} else {
|
||||||
@ -3905,9 +3965,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
titlePromise = $interval(function () {
|
titlePromise = $interval(function () {
|
||||||
var time = tsNow();
|
var time = tsNow();
|
||||||
if (!notificationsCount || time % 2000 > 1000) {
|
if (!notificationsCount || time % 2000 > 1000) {
|
||||||
|
if (titleChanged) {
|
||||||
|
titleChanged = false;
|
||||||
document.title = titleBackup;
|
document.title = titleBackup;
|
||||||
setFavicon();
|
setFavicon();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
titleChanged = true;
|
||||||
document.title = langNotificationsPluralize(notificationsCount);
|
document.title = langNotificationsPluralize(notificationsCount);
|
||||||
setFavicon('favicon_unread.ico');
|
setFavicon('favicon_unread.ico');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user