Koha/koha-tmpl/opac-tmpl/lib/emoji-picker/js/emoji-picker.js
Tomas Cohen Arazi e11fd3060f Bug 15794: Add an emoji picker to tag entry in OPAC
This patch introduces an emoji picker int othe OPAC's tag entry form.
It relies on the emoji-picker library [1]

To test:
- Apply the patches
- Restart all services (just in case some caching is taking place):
  $ restart_all
- Log into the OPAC
- Do a search, pick a record
- On the detail page for the record, click on 'Add tags'
=> SUCCESS: An input form is displayed, with an emoji picker on the
    right.
=> SUCCESS: Choosing an emoji populates the input with it
- Set 'TagsModeration' and retry
=> SUCCESS: Proposed tags are displayed correctly on the staff interface
    for tag moderation
- Sign off :-D

Sponsored-by: Hotchkiss School

[1] https://github.com/OneSignal/emoji-picker

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2018-02-16 18:12:55 -03:00

139 lines
3.8 KiB
JavaScript

// 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