Make emoji picker close automatically if input parent element is destroyed

This commit is contained in:
Pierre 2018-04-20 16:52:17 +02:00
parent b05a26d734
commit 3cee773de0
2 changed files with 35 additions and 1 deletions

View File

@ -289,6 +289,20 @@
addClass(this, 'wdt-emoji-picker-open'); addClass(this, 'wdt-emoji-picker-open');
//this.innerHTML = wdtEmojiBundle.emoji.replace_colons(':sunglasses:'); //COMUNIC - EDIT //this.innerHTML = wdtEmojiBundle.emoji.replace_colons(':sunglasses:'); //COMUNIC - EDIT
//COMUNIC EDIT
//Make the picker close automatically if the parent element is removed
var interval = setInterval(function(){
if(!parent.isConnected){
wdtEmojiBundle.close();
clearInterval(interval);
}
}, 2500);
//END COMUNIC EDIT
}; };
/** /**

View File

@ -446,3 +446,23 @@ window.location.changed = function(e){};
} }
}, 900); }, 900);
})(); })();
/**
* jQuery special event that detects the deletion
* of a DOM element
*
* @source StackOverFlow answer from mtkopone
*/
(function($){
$.event.special.destroyed = {
remove: function(o){
if(o.handler)
o.handler();
}
}
})(jQuery);