mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-20 01:25:30 +01:00
46e2a65cf1
Replace exisiting smilies with equivalent emoji, or with shiny new smiley images where no emoji existed. Props batmoo, joen and mkaz for the original plugin upon which this is based. Props pento, iseulde, kraftbj and peterwilsoncc for making the internet's dreams come true. See #31242 Built from https://develop.svn.wordpress.org/trunk@31733 git-svn-id: http://core.svn.wordpress.org/trunk@31714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
1.7 KiB
JavaScript
1 line
1.7 KiB
JavaScript
var WPEmoji;!function(){WPEmoji={base_url:"//s0.wp.com/wp-content/mu-plugins/emoji/twemoji/72x72",ext:".png",parseAllEmoji:!1,parseEmoji:!1,parseFlags:!1,init:function(){"undefined"!=typeof EmojiSettings&&(this.base_url=EmojiSettings.base_url||this.base_url,this.ext=EmojiSettings.ext||this.ext),WPEmoji.parseAllEmoji=!WPEmoji.browserSupportsEmoji(),WPEmoji.parseFlags=!WPEmoji.browserSupportsFlagEmoji(),WPEmoji.parseEmoji=WPEmoji.parseAllEmoji||WPEmoji.parseFlags,!WPEmoji.parseEmoji},load:function(){WPEmoji.parse(document.body)},browserSupportsEmoji:function(){var a,b;if(document.createElement("canvas").getContext&&(a=document.createElement("canvas").getContext("2d"),"function"==typeof a.fillText))return b=String.fromCharCode(55357)+String.fromCharCode(56835),a.textBaseline="top",a.font="600 32px Arial",a.fillText(b,0,0),0!==a.getImageData(16,16,1,1).data[0]},browserSupportsFlagEmoji:function(){var a,b,c;return c=document.createElement("canvas"),c.getContext&&(a=c.getContext("2d"),"function"==typeof a.fillText)?(b=String.fromCharCode(55356)+String.fromCharCode(56812),b+=String.fromCharCode(55356)+String.fromCharCode(56807),a.textBaseline="top",a.font="32px Arial",a.fillText(b,0,0),c.toDataURL().length>3e3):void 0},parse:function(a){return WPEmoji.parseEmoji?twemoji.parse(a,{base:this.base_url,ext:this.ext,callback:function(a,b){switch(a){case"a9":case"ae":case"2122":case"2194":case"2660":case"2663":case"2665":case"2666":return!1}return!WPEmoji.parseFlags||WPEmoji.parseAllEmoji||a.match(/^1f1(e[6-9a-f]|f[1-9a-f])-1f1(e[6-9a-f]|f[1-9a-f])$/)?"".concat(b.base,"/",a,b.ext):!1}}):void 0}},window.addEventListener?window.addEventListener("load",WPEmoji.load,!1):window.attachEvent&&window.attachEvent("onload",WPEmoji.load),WPEmoji.init()}(); |