/**
* Emojies picker
*
* @author Pierre HUBERT
*/
ComunicWeb.components.emoji.picker = {
//Source code of the emojies picker
pickerSrc: '
";',
/**
* Initialize Emojie picker
*/
init: function(){
//Check if the picker has to be included in the page
var targetPicker = byId("emojiPicker");
if(!targetPicker){
targetPicker = createElem2({
appendTo: byId("wrapper"),
type: "div",
id: "emojiPicker",
innerHTML: this.pickerSrc
});
wdtEmojiBundle.defaults.emojiSheets.twitter = ComunicWeb.__config.assetsURL + "3rdparty/wdt-emoji/sheets/sheet_twitter_64_indexed_128.png";
wdtEmojiBundle.init('.wdt-emoji-bundle-enabled');
wdtEmojiBundle.changeType("twitter");
}
},
/**
* Add a picker for an element
*
* @param {HTMLElement} elem Target element
* @param {HTMLElement} trigger Alternative element to trigger picker
*/
addPicker: function(elem, trigger){
//Make sure the system is ready
this.init();
//Check if the default features of the framework can be used
if(!trigger){
wdtEmojiBundle.addPicker(elem);
return;
}
trigger.addEventListener('click', wdtEmojiBundle.openPicker);
var parent = elem.parentNode;
parent.className += ' wdt-emoji-picker-parent';
if (elem.className.includes('wdt-emoji-open-on-colon')) {
parent.addEventListener('keyup', wdtEmojiBundle.onKeyup)
}
elem.className += ' wdt-emoji-bundle-enabled wdt-emoji-picker-ready';
}
}