mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 13:33:18 +00:00
139 lines
3.8 KiB
JavaScript
Vendored
139 lines
3.8 KiB
JavaScript
Vendored
// Generated by CoffeeScript 1.12.5
|
|
(function() {
|
|
this.EmojiPicker = (function() {
|
|
function EmojiPicker(options) {
|
|
var ref, ref1;
|
|
if (options == null) {
|
|
options = {};
|
|
}
|
|
$.emojiarea.iconSize = (ref = options.iconSize) != null ? ref : 25;
|
|
$.emojiarea.assetsPath = (ref1 = options.assetsPath) != null ? ref1 : '';
|
|
this.generateEmojiIconSets(options);
|
|
if (!options.emojiable_selector) {
|
|
options.emojiable_selector = '[data-emojiable=true]';
|
|
}
|
|
this.options = options;
|
|
}
|
|
|
|
EmojiPicker.prototype.discover = function() {
|
|
var isiOS;
|
|
isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
|
if (isiOS) {
|
|
return;
|
|
}
|
|
return $(this.options.emojiable_selector).emojiarea($.extend({
|
|
emojiPopup: this,
|
|
norealTime: true
|
|
}, this.options));
|
|
};
|
|
|
|
EmojiPicker.prototype.generateEmojiIconSets = function(options) {
|
|
var column, dataItem, hex, i, icons, j, name, reverseIcons, row, totalColumns;
|
|
icons = {};
|
|
reverseIcons = {};
|
|
i = void 0;
|
|
j = void 0;
|
|
hex = void 0;
|
|
name = void 0;
|
|
dataItem = void 0;
|
|
row = void 0;
|
|
column = void 0;
|
|
totalColumns = void 0;
|
|
j = 0;
|
|
while (j < Config.EmojiCategories.length) {
|
|
totalColumns = Config.EmojiCategorySpritesheetDimens[j][1];
|
|
i = 0;
|
|
while (i < Config.EmojiCategories[j].length) {
|
|
dataItem = Config.Emoji[Config.EmojiCategories[j][i]];
|
|
name = dataItem[1][0];
|
|
row = Math.floor(i / totalColumns);
|
|
column = i % totalColumns;
|
|
icons[':' + name + ':'] = [j, row, column, ':' + name + ':'];
|
|
reverseIcons[name] = dataItem[0];
|
|
i++;
|
|
}
|
|
j++;
|
|
}
|
|
$.emojiarea.icons = icons;
|
|
return $.emojiarea.reverseIcons = reverseIcons;
|
|
};
|
|
|
|
EmojiPicker.prototype.colonToUnicode = function(input) {
|
|
if (!input) {
|
|
return '';
|
|
}
|
|
if (!Config.rx_colons) {
|
|
Config.init_unified();
|
|
}
|
|
return input.replace(Config.rx_colons, function(m) {
|
|
var val;
|
|
val = Config.mapcolon[m];
|
|
if (val) {
|
|
return val;
|
|
} else {
|
|
return '';
|
|
}
|
|
});
|
|
};
|
|
|
|
EmojiPicker.prototype.appendUnicodeAsImageToElement = function(element, input) {
|
|
var k, len, split_on_unicode, text, val;
|
|
if (!input) {
|
|
return '';
|
|
}
|
|
if (!Config.rx_codes) {
|
|
Config.init_unified();
|
|
}
|
|
split_on_unicode = input.split(Config.rx_codes);
|
|
for (k = 0, len = split_on_unicode.length; k < len; k++) {
|
|
text = split_on_unicode[k];
|
|
val = '';
|
|
if (Config.rx_codes.test(text)) {
|
|
val = Config.reversemap[text];
|
|
if (val) {
|
|
val = ':' + val + ':';
|
|
val = $.emojiarea.createIcon($.emojiarea.icons[val]);
|
|
}
|
|
} else {
|
|
val = document.createTextNode(text);
|
|
}
|
|
element.append(val);
|
|
}
|
|
return input.replace(Config.rx_codes, function(m) {
|
|
var $img;
|
|
val = Config.reversemap[m];
|
|
if (val) {
|
|
val = ':' + val + ':';
|
|
$img = $.emojiarea.createIcon($.emojiarea.icons[val]);
|
|
return $img;
|
|
} else {
|
|
return '';
|
|
}
|
|
});
|
|
};
|
|
|
|
EmojiPicker.prototype.colonToImage = function(input) {
|
|
if (!input) {
|
|
return '';
|
|
}
|
|
if (!Config.rx_colons) {
|
|
Config.init_unified();
|
|
}
|
|
return input.replace(Config.rx_colons, function(m) {
|
|
var $img;
|
|
if (m) {
|
|
$img = $.emojiarea.createIcon($.emojiarea.icons[m]);
|
|
return $img;
|
|
} else {
|
|
return '';
|
|
}
|
|
});
|
|
};
|
|
|
|
return EmojiPicker;
|
|
|
|
})();
|
|
|
|
}).call(this);
|
|
|
|
//# sourceMappingURL=emoji-picker.js.map
|