Browse Source

Merge branch 'pr/698'

master
Igor Zhukov 10 years ago
parent
commit
1ce4c0c3d4
  1. 10
      app/css/mobile.css
  2. 19
      app/js/controllers.js
  3. 17
      app/js/directives.js
  4. 13
      app/js/lib/config.js
  5. 126
      app/js/message_composer.js
  6. 132
      app/js/services.js
  7. 4
      webogram.sublime-project

10
app/css/mobile.css

@ -1165,13 +1165,17 @@ a.mobile_modal_action .tg_checkbox_label { @@ -1165,13 +1165,17 @@ a.mobile_modal_action .tg_checkbox_label {
.composer_emoji_tooltip {
margin-left: 10px;
margin-top: -175px;
margin-left: 6px;
margin-top: -170px;
width: 262px;
z-index: 10000;
}
.composer_emoji_tooltip .composer_emoji_tooltip_content {
.composer_emoji_tooltip .composer_emoji_tooltip_content_wrap {
height: 106px;
}
.composer_emoji_tooltip_tabs {
margin-bottom: 3px;
}
.composer_emoji_tooltip .composer_emoji_tooltip_content .composer_emoji_btn {
padding: 5px;
}

19
app/js/controllers.js

@ -952,10 +952,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -952,10 +952,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
if (pos > -1) {
history = $scope.peerHistories[pos];
// if (pos) {
// $scope.peerHistories.splice(pos, 1);
// $scope.peerHistories.unshift(history);
// }
return history;
}
history = {peerID: peerID, messages: []};
@ -1389,7 +1385,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1389,7 +1385,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
// console.log('append', addedMessage);
// 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)) {
$scope.$broadcast('messages_regroup');
}
@ -1402,8 +1399,16 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1402,8 +1399,16 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$broadcast('messages_unread_after');
}
// console.log('append check', $rootScope.idle.isIDLE, addedMessage.peerID, $scope.curDialog.peerID);
if (!$rootScope.idle.isIDLE) {
// console.log('append check', $rootScope.idle.isIDLE, addedMessage.peerID, $scope.curDialog.peerID, historyMessage, history.messages[history.messages.length - 2]);
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 () {
AppMessagesManager.readHistory($scope.curDialog.inputPeer);
});

17
app/js/directives.js

@ -1119,7 +1119,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1119,7 +1119,7 @@ angular.module('myApp.directives', ['myApp.filters'])
return sendOnEnter;
},
onMessageSubmit: onMessageSubmit,
onFilesPaste: onFilesPaste
onFilePaste: onFilePaste
});
var richTextarea = composer.richTextareaEl[0];
@ -1204,7 +1204,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1204,7 +1204,9 @@ angular.module('myApp.directives', ['myApp.filters'])
composer.setValue($scope.draftMessage.text || '');
updateHeight();
}
composer.focus();
if (!Config.Navigator.touch) {
composer.focus();
}
});
var sendAwaiting = false;
@ -1214,7 +1216,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1214,7 +1216,9 @@ angular.module('myApp.directives', ['myApp.filters'])
});
$scope.$on('ui_message_send', function () {
sendAwaiting = false;
focusField();
if (!Config.Navigator.touch) {
focusField();
}
});
function focusField () {
@ -1223,9 +1227,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1223,9 +1227,9 @@ angular.module('myApp.directives', ['myApp.filters'])
});
}
function onFilesPaste (blobs) {
function onFilePaste (blob) {
ErrorService.confirm({type: 'FILE_CLIPBOARD_PASTE'}).then(function () {
$scope.draftMessage.files = blobs;
$scope.draftMessage.files = [blob];
$scope.draftMessage.isMedia = true;
});
};
@ -2344,6 +2348,8 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -2344,6 +2348,8 @@ angular.module('myApp.directives', ['myApp.filters'])
}
var updatePeerPhoto = function () {
var curJump = ++jump;
peerPhoto = peer.photo && angular.copy(peer.photo.photo_small);
var hasPhoto = peerPhoto !== undefined;
@ -2362,7 +2368,6 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -2362,7 +2368,6 @@ angular.module('myApp.directives', ['myApp.filters'])
if (hasPhoto) {
var curJump = ++jump;
MtpApiFileManager.downloadSmallFile(peer.photo.photo_small).then(function (blob) {
if (curJump != jump) {

13
app/js/lib/config.js

File diff suppressed because one or more lines are too long

126
app/js/message_composer.js

@ -53,11 +53,13 @@ @@ -53,11 +53,13 @@
if (Array.isArray(shortcut)) {
shortcut = shortcut[0];
}
if (shortcut.charAt(0) == ':') {
shortcut = shortcut.substr(1, shortcut.length - 2);
}
if (code = shortcuts[shortcut]) {
result.push({code: code, rate: 1});
if (shortcut && typeof shortcut === 'string') {
if (shortcut.charAt(0) == ':') {
shortcut = shortcut.substr(1, shortcut.length - 2);
}
if (code = shortcuts[shortcut]) {
result.push({code: code, rate: 1});
}
}
}
callback(result);
@ -139,26 +141,30 @@ function EmojiTooltip (btnEl, options) { @@ -139,26 +141,30 @@ function EmojiTooltip (btnEl, options) {
this.onStickerSelected = options.onStickerSelected;
this.getStickers = options.getStickers;
$(this.btnEl).on('mouseenter mouseleave', function (e) {
self.isOverBtn = e.type == 'mouseenter';
self.createTooltip();
if (!Config.Navigator.touch) {
$(this.btnEl).on('mouseenter mouseleave', function (e) {
self.isOverBtn = e.type == 'mouseenter';
self.createTooltip();
if (self.isOverBtn) {
self.onMouseEnter(true);
} else {
self.onMouseLeave(true);
}
});
if (self.isOverBtn) {
self.onMouseEnter(true);
} else {
self.onMouseLeave(true);
}
});
}
$(this.btnEl).on('mousedown', function (e) {
if (!self.shown) {
clearTimeout(self.showTimeout);
delete self.showTimeout;
self.createTooltip();
self.show();
} else {
clearTimeout(self.hideTimeout);
delete self.hideTimeout;
self.hide();
}
return cancelEvent(e);
});
}
@ -202,20 +208,23 @@ EmojiTooltip.prototype.createTooltip = function () { @@ -202,20 +208,23 @@ EmojiTooltip.prototype.createTooltip = function () {
this.settingsEl = $('.composer_emoji_tooltip_settings', this.tooltip);
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) {
self.selectTab(tabIndex);
return cancelEvent(e);
})
.on('mouseenter mouseleave', function (e) {
.appendTo(self.tabsEl);
if (!Config.Navigator.touch) {
tab.on('mouseenter mouseleave', function (e) {
clearTimeout(self.selectTabTimeout);
if (e.type == 'mouseenter') {
self.selectTabTimeout = setTimeout(function () {
self.selectTab(tabIndex);
}, 300);
}
})
.appendTo(self.tabsEl);
});
}
});
if (!Config.Mobile) {
@ -238,20 +247,27 @@ EmojiTooltip.prototype.createTooltip = function () { @@ -238,20 +247,27 @@ EmojiTooltip.prototype.createTooltip = function () {
if (self.onStickerSelected) {
self.onStickerSelected(sticker);
}
if (Config.Mobile) {
self.hide();
}
}
return cancelEvent(e);
});
this.tooltipEl.on('mouseenter mouseleave', function (e) {
if (e.type == 'mouseenter') {
self.onMouseEnter();
} else {
self.onMouseLeave();
}
});
if (!Config.Navigator.touch) {
this.tooltipEl.on('mouseenter mouseleave', function (e) {
if (e.type == 'mouseenter') {
self.onMouseEnter();
} else {
self.onMouseLeave();
}
});
}
this.selectTab(0);
$(window).on('resize', this.updatePosition.bind(this));
return true;
}
@ -438,6 +454,7 @@ function MessageComposer (textarea, options) { @@ -438,6 +454,7 @@ function MessageComposer (textarea, options) {
this.onTyping = options.onTyping;
this.onMessageSubmit = options.onMessageSubmit;
this.getSendOnEnter = options.getSendOnEnter;
this.onFilePaste = options.onFilePaste;
}
MessageComposer.prototype.setUpInput = function () {
@ -472,19 +489,7 @@ MessageComposer.prototype.onKeyEvent = function (e) { @@ -472,19 +489,7 @@ MessageComposer.prototype.onKeyEvent = function (e) {
if (e.type == 'keyup') {
this.checkAutocomplete();
if (this.onTyping) {
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();
}
}
}
var length = false;
if (this.richTextareaEl) {
clearTimeout(this.updateValueTO);
var now = tsNow();
@ -495,12 +500,33 @@ MessageComposer.prototype.onKeyEvent = function (e) { @@ -495,12 +500,33 @@ MessageComposer.prototype.onKeyEvent = function (e) {
this.onChange();
}
else {
this.updateValueTO = setTimeout(this.onChange.bind(this), 1000);
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);
}
}
}
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') {
var checkSubmit = !this.autocompleteShown;
if (this.autocompleteShown) {
if (e.keyCode == 38 || e.keyCode == 40) { // UP / DOWN
var next = e.keyCode == 40;
@ -524,18 +550,19 @@ MessageComposer.prototype.onKeyEvent = function (e) { @@ -524,18 +550,19 @@ MessageComposer.prototype.onKeyEvent = function (e) {
}
if (e.keyCode == 13) { // ENTER
var currentSelected = $(this.autoCompleteEl).find('.composer_emoji_option_active') ||
$(this.autoCompleteEl).childNodes[0].find('a');
var currentSelected = $(this.autoCompleteEl).find('.composer_emoji_option_active')/* ||
$(this.autoCompleteEl).childNodes[0].find('a')*/;
var code = currentSelected.attr('data-code');
if (code) {
this.onEmojiSelected(code, true);
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 sendOnEnter = true;
if (this.getSendOnEnter && !this.getSendOnEnter()) {
@ -594,6 +621,9 @@ MessageComposer.prototype.restoreSelection = function () { @@ -594,6 +621,9 @@ MessageComposer.prototype.restoreSelection = function () {
MessageComposer.prototype.checkAutocomplete = function () {
if (Config.Mobile) {
return false;
}
var pos, value;
if (this.richTextareaEl) {
var textarea = this.richTextareaEl[0];
@ -671,7 +701,11 @@ MessageComposer.prototype.onRichPaste = function (e) { @@ -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);
if (text.length) {
document.execCommand('insertText', false, text);
@ -690,7 +724,7 @@ MessageComposer.prototype.onRichPasteNode = function (e) { @@ -690,7 +724,7 @@ MessageComposer.prototype.onRichPasteNode = function (e) {
var blob = dataUrlToBlob(src);
this.onFilePaste(blob);
setZeroTimeout(function () {
element.parentNode.removeChild(element);
element.parentNode.replaceChild(document.createTextNode('   '), element);
})
}
else if (src && !src.match(/img\/blank\.gif/)) {
@ -808,6 +842,8 @@ MessageComposer.prototype.setValue = function (text) { @@ -808,6 +842,8 @@ MessageComposer.prototype.setValue = function (text) {
if (this.richTextareaEl) {
this.richTextareaEl.html(this.getRichHtml(text));
this.lastLength = text.length;
this.wasEmpty = !text.length;
this.onKeyEvent({type: 'keyup'});
} else {
this.textareaEl.val(text);
}

132
app/js/services.js

@ -1967,6 +1967,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -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 &&
curMessage.from_id == prevMessage.from_id &&
!prevMessage.fwd_from_id == !curMessage.fwd_from_id &&
@ -3495,15 +3504,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3495,15 +3504,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
.service('RichTextProcessor', function ($sce, $sanitize) {
var emojiUtf = [],
emojiMap = {},
var emojiMap = {},
emojiData = Config.Emoji,
emojiIconSize = 18,
emojiSupported = navigator.userAgent.search(/OS X|iPhone|iPad|iOS|Android/i) != -1,
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) {
emojiUtf.push(emojiData[emojiCode][0]);
emojiMap[emojiData[emojiCode][0]] = emojiCode;
}
@ -3535,11 +3544,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3535,11 +3544,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
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:)?" +
// user:pass authentication
"(?:\\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}" +
"|" +
// host name
@ -3547,14 +3557,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3547,14 +3557,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
// domain name
"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
// TLD identifier
"(?:\\.(?:[a-z\\u00a1-\\uffff]{2,24}))" +
"(?:\\.(xn--[0-9a-z]{2,16}|[a-z\\u00a1-\\uffff]{2,24}))" +
")" +
// port number
"(?::\\d{2,5})?" +
// 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 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']) @@ -3593,8 +3603,6 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
options = options || {};
text = text.replace(/\ufe0f/g, '', text);
var match,
raw = text,
html = [],
@ -3603,6 +3611,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3603,6 +3611,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
emojiTitle,
emojiCoords;
// var start = tsNow();
while ((match = raw.match(regExp))) {
html.push(encodeEntities(raw.substr(0, match.index)));
@ -3634,33 +3644,61 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3634,33 +3644,61 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
'</a>'
);
} else {
var url = (match[5] ? '' : 'http://') + match[4];
html.push(
'<a href="',
encodeEntities(url),
'" target="_blank">',
encodeEntities(match[4]),
'</a>'
);
if (options.extractUrlEmbed &&
!options.extractedUrlEmbed) {
options.extractedUrlEmbed = findExternalEmbed(url);
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(
'<a href="',
encodeEntities(url),
'" target="_blank">',
encodeEntities(match[4]),
'</a>',
excluded
);
if (options.extractUrlEmbed &&
!options.extractedUrlEmbed) {
options.extractedUrlEmbed = findExternalEmbed(url);
}
} else {
html.push(encodeEntities(match[0]));
}
}
} else {
html.push(encodeEntities(match[0]));
}
}
else if (match[6]) { // New line
else if (match[7]) { // New line
if (!options.noLinebreaks) {
html.push('<br/>');
} else {
html.push(' ');
}
}
else if (match[7]) {
if ((emojiCode = emojiMap[match[7]]) &&
else if (match[8]) {
if ((emojiCode = emojiMap[match[8]]) &&
(emojiCoords = getEmojiSpritesheetCoords(emojiCode))) {
emojiTitle = encodeEntities(emojiData[emojiCode][1][0]);
@ -3677,21 +3715,21 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3677,21 +3715,21 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
':', emojiTitle, ':</span>'
);
} else {
html.push(encodeEntities(match[7]));
html.push(encodeEntities(match[8]));
}
}
else if (match[9]) {
else if (match[10]) {
if (!options.noLinks) {
html.push(
'<a href="#/im?q=',
encodeURIComponent(match[9]),
encodeURIComponent(match[10]),
'">',
encodeEntities(match[9]),
encodeEntities(match[10]),
'</a>'
);
} else {
html.push(
encodeEntities(match[9])
encodeEntities(match[10])
);
}
}
@ -3700,11 +3738,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3700,11 +3738,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
html.push(encodeEntities(raw));
// var timeDiff = tsNow() - start;
// if (timeDiff > 1) {
// console.log(dT(), 'wrap text', text.length, timeDiff);
// }
text = $sanitize(html.join(''));
// console.log(3, text, html);
if (emojiFound) {
text = text.replace(/\ufe0f|&#65039;/g, '', text);
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>');
}
@ -3712,7 +3756,21 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3712,7 +3756,21 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return $sce.trustAs('html', text);
}
function findExternalEmbed (url) {
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) {
var embedUrlMatches,
result;
@ -3773,8 +3831,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3773,8 +3831,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
while ((match = raw.match(regExp))) {
text.push(raw.substr(0, match.index));
if (match[6]) {
if ((emojiCode = emojiMap[match[6]]) &&
if (match[7]) {
if ((emojiCode = emojiMap[match[7]]) &&
(emojiTitle = emojiData[emojiCode][1][0])) {
text.push(':' + emojiTitle + ':');
} else {
@ -3887,6 +3945,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3887,6 +3945,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var langNotificationsPluralize = _.pluralize('page_title_pluralize_notifications');
var titleBackup = document.title,
titleChanged = false,
titlePromise;
var prevFavicon;
@ -3897,6 +3956,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3897,6 +3956,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if (!Config.Navigator.mobile) {
$interval.cancel(titlePromise);
if (!newVal) {
titleChanged = false;
document.title = titleBackup;
setFavicon();
} else {
@ -3905,9 +3965,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3905,9 +3965,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
titlePromise = $interval(function () {
var time = tsNow();
if (!notificationsCount || time % 2000 > 1000) {
document.title = titleBackup;
setFavicon();
if (titleChanged) {
titleChanged = false;
document.title = titleBackup;
setFavicon();
}
} else {
titleChanged = true;
document.title = langNotificationsPluralize(notificationsCount);
setFavicon('favicon_unread.ico');
}

4
webogram.sublime-project vendored

@ -4,8 +4,8 @@ @@ -4,8 +4,8 @@
{
"follow_symlinks": true,
"path": ".",
"folder_exclude_patterns": ["*dist", "node_modules", "releases"],
"file_exclude_patterns": ["*.zip", "templates.js"]
"folder_exclude_patterns": ["*dist", "node_modules", "releases"],
"file_exclude_patterns": ["*.zip", "templates.js"]
}
]
}

Loading…
Cancel
Save