Moved emojiarea recent tab to ConfigStorage
This commit is contained in:
parent
cce8193ebc
commit
0dbe741a16
57
app/vendor/jquery.emojiarea/jquery.emojiarea.js
vendored
57
app/vendor/jquery.emojiarea/jquery.emojiarea.js
vendored
@ -172,15 +172,10 @@
|
|||||||
This function was added by Igor Zhukov to save recent used emojis.
|
This function was added by Igor Zhukov to save recent used emojis.
|
||||||
*/
|
*/
|
||||||
util.emojiInserted = function (emojiKey, menu) {
|
util.emojiInserted = function (emojiKey, menu) {
|
||||||
try {
|
ConfigStorage.get('emojis_recent', function (curEmojis) {
|
||||||
var curEmojisStr = localStorage.getItem('emojis_recent');
|
curEmojis = curEmojis || [];
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var curEmojis = curEmojisStr && curEmojisStr.split(',') || [],
|
|
||||||
pos = curEmojis.indexOf(emojiKey);
|
|
||||||
|
|
||||||
|
var pos = curEmojis.indexOf(emojiKey);
|
||||||
if (!pos) {
|
if (!pos) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -192,11 +187,12 @@
|
|||||||
curEmojis = curEmojis.slice(42);
|
curEmojis = curEmojis.slice(42);
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorage.setItem('emojis_recent', curEmojis.join(','));
|
ConfigStorage.set({emojis_recent: curEmojis});
|
||||||
|
|
||||||
if (menu) {
|
if (menu) {
|
||||||
menu.updateRecentTab(curEmojis);
|
menu.updateRecentTab(curEmojis);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
/*! MODIFICATION END */
|
/*! MODIFICATION END */
|
||||||
|
|
||||||
@ -246,7 +242,7 @@
|
|||||||
var column = emoji[2];
|
var column = emoji[2];
|
||||||
var name = emoji[3];
|
var name = emoji[3];
|
||||||
var filename = $.emojiarea.spritesheetPath;
|
var filename = $.emojiarea.spritesheetPath;
|
||||||
var iconSize = menu && Config.Navigator.mobile ? 26 : $.emojiarea.iconSize
|
var iconSize = menu && Config.Mobile ? 26 : $.emojiarea.iconSize
|
||||||
var xoffset = -(iconSize * column);
|
var xoffset = -(iconSize * column);
|
||||||
var yoffset = -(iconSize * row);
|
var yoffset = -(iconSize * row);
|
||||||
var scaledWidth = ($.emojiarea.spritesheetDimens[category][1] * iconSize);
|
var scaledWidth = ($.emojiarea.spritesheetDimens[category][1] * iconSize);
|
||||||
@ -562,8 +558,10 @@
|
|||||||
|
|
||||||
/* MODIFICATION: Following line was modified by Andre Staltz, in order to select a default category. */
|
/* MODIFICATION: Following line was modified by Andre Staltz, in order to select a default category. */
|
||||||
this.selectCategory(0);
|
this.selectCategory(0);
|
||||||
/* MODIFICATION: Following line was added by Igor Zhukov, in order to update emoji tab visibility */
|
/* MODIFICATION: Following 3 lines was added by Igor Zhukov, in order to update emoji tab visibility */
|
||||||
this.updateRecentTab();
|
ConfigStorage.get('emojis_recent', function (curEmojis) {
|
||||||
|
self.updateRecentTab(curEmojis);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! MODIFICATION START
|
/*! MODIFICATION START
|
||||||
@ -601,10 +599,19 @@
|
|||||||
var html = [];
|
var html = [];
|
||||||
var options = $.emojiarea.icons;
|
var options = $.emojiarea.icons;
|
||||||
var path = $.emojiarea.path;
|
var path = $.emojiarea.path;
|
||||||
|
var self = this;
|
||||||
if (path.length && path.charAt(path.length - 1) !== '/') {
|
if (path.length && path.charAt(path.length - 1) !== '/') {
|
||||||
path += '/';
|
path += '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! MODIFICATION: Following function was added by Igor Zhukov, in order to add scrollbars to EmojiMenu */
|
||||||
|
var updateItems = function () {
|
||||||
|
self.$items.html(html.join(''));
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
self.$itemsWrap.nanoScroller();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
if (category > 0) {
|
if (category > 0) {
|
||||||
for (var key in options) {
|
for (var key in options) {
|
||||||
@ -613,41 +620,25 @@
|
|||||||
html.push('<a href="javascript:void(0)" title="' + util.htmlEntities(key) + '">' + EmojiArea.createIcon(options[key], true) + '<span class="label">' + util.htmlEntities(key) + '</span></a>');
|
html.push('<a href="javascript:void(0)" title="' + util.htmlEntities(key) + '">' + EmojiArea.createIcon(options[key], true) + '<span class="label">' + util.htmlEntities(key) + '</span></a>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateItems();
|
||||||
} else {
|
} else {
|
||||||
try {
|
ConfigStorage.get('emojis_recent', function (curEmojis) {
|
||||||
var curEmojis = (localStorage.getItem('emojis_recent') || '').split(','),
|
var key, i;
|
||||||
key, i;
|
|
||||||
for (i = 0; i < curEmojis.length; i++) {
|
for (i = 0; i < curEmojis.length; i++) {
|
||||||
key = curEmojis[i]
|
key = curEmojis[i]
|
||||||
if (options[key]) {
|
if (options[key]) {
|
||||||
html.push('<a href="javascript:void(0)" title="' + util.htmlEntities(key) + '">' + EmojiArea.createIcon(options[key], true) + '<span class="label">' + util.htmlEntities(key) + '</span></a>');
|
html.push('<a href="javascript:void(0)" title="' + util.htmlEntities(key) + '">' + EmojiArea.createIcon(options[key], true) + '<span class="label">' + util.htmlEntities(key) + '</span></a>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
updateItems();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$items.html(html.join(''));
|
|
||||||
|
|
||||||
/*! MODIFICATION: Following 4 lines were added by Igor Zhukov, in order to add scrollbars to EmojiMenu */
|
|
||||||
var self = this;
|
|
||||||
setTimeout(function () {
|
|
||||||
self.$itemsWrap.nanoScroller();
|
|
||||||
}, 100);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! MODIFICATION START
|
/*! MODIFICATION START
|
||||||
This function was added by Igor Zhukov to update recent emojis tab state.
|
This function was added by Igor Zhukov to update recent emojis tab state.
|
||||||
*/
|
*/
|
||||||
EmojiMenu.prototype.updateRecentTab = function(curEmojis) {
|
EmojiMenu.prototype.updateRecentTab = function(curEmojis) {
|
||||||
if (curEmojis === undefined) {
|
|
||||||
try {
|
|
||||||
var curEmojisStr = localStorage.getItem('emojis_recent');
|
|
||||||
curEmojis = curEmojisStr && curEmojisStr.split(',') || [];
|
|
||||||
} catch (e) {
|
|
||||||
curEmojis = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.hasRecent != (curEmojis.length > 1)) {
|
if (this.hasRecent != (curEmojis.length > 1)) {
|
||||||
var tabEl = this.$categoryTabs.find('.emoji-menu-tab').eq(0);
|
var tabEl = this.$categoryTabs.find('.emoji-menu-tab').eq(0);
|
||||||
if (this.hasRecent) {
|
if (this.hasRecent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user