Changeset 31750
- Timestamp:
- 03/12/2015 12:51:06 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Gruntfile.js
r31629 r31750 303 303 '!wp-includes/js/json2.js', 304 304 '!wp-includes/js/tw-sack.js', 305 '!wp-includes/js/twemoji.js', 305 306 '!**/*.min.js' 306 307 ], -
trunk/src/wp-admin/js/inline-edit-post.js
r31744 r31750 273 273 $(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove(); 274 274 $('#edit-'+id).before(r).remove(); 275 wp.emoji.parse( $( inlineEditPost.what + id ).get( 0 ) );276 275 $(inlineEditPost.what+id).hide().fadeIn(); 277 276 } else { -
trunk/src/wp-admin/js/inline-edit-tax.js
r31744 r31750 118 118 $( '#parent' ).find( 'option[value=' + option_value + ']' ).text( row.find( '.row-title' ).text() ); 119 119 120 wp.emoji.parse( row.get( 0 ) );121 122 120 row.hide().fadeIn(); 123 121 } else { -
trunk/src/wp-admin/js/post.js
r31744 r31750 742 742 } 743 743 744 wp.emoji.parse( box.get( 0 ) );745 746 744 b.html(revert_b); 747 745 real_slug.val(new_slug); -
trunk/src/wp-admin/js/tags.js
r31744 r31750 50 50 $( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm 51 51 52 wp.emoji.parse( $( '.tags' ).get( 0 ) );53 54 52 $('.tags .no-items').remove(); 55 53 -
trunk/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js
r31744 r31750 22 22 } ); 23 23 24 editor.on( 'input setcontent', function( ) {24 editor.on( 'input setcontent', function( event ) { 25 25 var selection, node, bookmark, imgs; 26 26 27 if ( typing ) {27 if ( typing && event.type === 'input' ) { 28 28 return; 29 29 } -
trunk/src/wp-includes/js/wp-emoji.js
r31744 r31750 1 /* global _wpemojiSettings, twemoji */2 1 window.wp = window.wp || {}; 3 2 4 (function() { 5 var emoji; 6 7 wp.emoji = emoji = { 8 /** 9 * The CDN URL for where emoji files are hosted. 10 * 11 * @since 4.2.0 12 * 13 * @var string 14 */ 15 baseUrl: '//s0.wp.com/wp-content/mu-plugins/emoji/twemoji/72x72', 16 17 /** 18 * The extension of the hosted emoji files. 19 * 20 * @since 4.2.0 21 * 22 * @var string 23 */ 24 ext: '.png', 25 3 ( function( window, wp, twemoji, settings ) { 4 var emoji = { 26 5 /** 27 6 * Flag to determine if we should parse all emoji characters into Twemoji images. … … 29 8 * @since 4.2.0 30 9 * 31 * @var bool10 * @var Boolean 32 11 */ 33 12 parseAllEmoji: false, … … 38 17 * @since 4.2.0 39 18 * 40 * @var bool19 * @var Boolean 41 20 */ 42 21 parseEmoji: false, … … 47 26 * @since 4.2.0 48 27 * 49 * @var bool28 * @var Boolean 50 29 */ 51 30 parseFlags: false, … … 57 36 */ 58 37 init: function() { 59 if ( typeof _wpemojiSettings !== 'undefined' ) {60 emoji.baseUrl = _wpemojiSettings.baseUrl || emoji.baseUrl;61 emoji.ext = _wpemojiSettings.ext || emoji.ext;62 }63 64 38 emoji.parseAllEmoji = ! emoji.browserSupportsEmoji(); 65 39 emoji.parseFlags = ! emoji.browserSupportsFlagEmoji(); 66 40 emoji.parseEmoji = emoji.parseAllEmoji || emoji.parseFlags; 67 41 68 if ( ! emoji.parseEmoji ) { 69 return; 42 if ( window.addEventListener ) { 43 window.addEventListener( 'load', emoji.load, false ); 44 } else if ( window.attachEvent ) { 45 window.attachEvent( 'onload', emoji.load ); 70 46 } 71 47 }, … … 77 53 */ 78 54 load: function() { 55 if ( MutationObserver ) { 56 new MutationObserver( function( mutationRecords ) { 57 var i = mutationRecords.length, 58 ii, 59 node; 60 61 while ( i-- ) { 62 ii = mutationRecords[ i ].addedNodes.length; 63 64 while ( ii-- ) { 65 node = mutationRecords[ i ].addedNodes[ ii ]; 66 67 if ( node.nodeType === 3 ) { 68 node = node.parentNode; 69 } 70 71 if ( node.nodeType === 1 ) { 72 emoji.parse( node ); 73 } 74 } 75 } 76 } ) 77 78 .observe( document.body, { 79 childList: true, 80 subtree: true 81 } ); 82 } 83 79 84 emoji.parse( document.body ); 80 85 }, … … 85 90 * @since 4.2.0 86 91 * 87 * @return { bool} True if the browser can render emoji, false if it cannot.92 * @return {Boolean} True if the browser can render emoji, false if it cannot. 88 93 */ 89 94 browserSupportsEmoji: function() { 90 var context, smile; 95 var canvas = document.createElement( 'canvas' ), 96 context = canvas.getContext && canvas.getContext( '2d' ); 91 97 92 if ( ! document.createElement( 'canvas' ).getContext ) {93 return ;98 if ( ! context.fillText ) { 99 return false; 94 100 } 95 96 context = document.createElement( 'canvas' ).getContext( '2d' );97 if ( typeof context.fillText != 'function' ) {98 return;99 }100 101 smile = String.fromCharCode( 55357 ) + String.fromCharCode( 56835 );102 101 103 102 /* … … 108 107 context.textBaseline = 'top'; 109 108 context.font = '600 32px Arial'; 110 context.fillText( smile, 0, 0 );109 context.fillText( String.fromCharCode( 55357, 56835 ), 0, 0 ); 111 110 112 111 return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0; … … 118 117 * 119 118 * @since 4.2.0 120 * @return {bool} True if the browser renders flag characters as a flag glyph, false if it does not. 119 * 120 * @return {Boolean} True if the browser renders flag characters as a flag glyph, false if it does not. 121 121 */ 122 122 browserSupportsFlagEmoji: function() { 123 var context, flag, canvas; 123 var canvas = document.createElement( 'canvas' ), 124 context = canvas.getContext && canvas.getContext( '2d' ); 124 125 125 canvas = document.createElement( 'canvas' ); 126 127 if ( ! canvas.getContext ) { 128 return; 126 if ( ! context.fillText ) { 127 return false; 129 128 } 130 131 context = canvas.getContext( '2d' );132 133 if ( typeof context.fillText != 'function' ) {134 return;135 }136 137 flag = String.fromCharCode(55356) + String.fromCharCode(56812); // [G]138 flag += String.fromCharCode(55356) + String.fromCharCode(56807); // [B]139 129 140 130 context.textBaseline = 'top'; 141 131 context.font = '32px Arial'; 142 context.fillText( flag, 0, 0 );132 context.fillText( String.fromCharCode( 55356, 56812, 55356, 56807 ), 0, 0 ); 143 133 144 134 /* … … 152 142 */ 153 143 return canvas.toDataURL().length > 3000; 154 155 144 }, 156 145 157 146 /** 158 * Given a DOM node, parse any emoji characters into Twemoji images.147 * Given an element or string, parse any emoji characters into Twemoji images. 159 148 * 160 149 * @since 4.2.0 161 150 * 162 * @param { Element} element The DOM nodeto parse.151 * @param {HTMLElement|String} object The element or string to parse. 163 152 */ 164 parse: function( element ) {153 parse: function( object ) { 165 154 if ( ! emoji.parseEmoji ) { 166 return ;155 return object; 167 156 } 168 157 169 return twemoji.parse( element, {170 base: emoji.baseUrl,171 ext: emoji.ext,158 return twemoji.parse( object, { 159 base: settings.baseUrl, 160 ext: settings.ext, 172 161 callback: function( icon, options ) { 173 162 // Ignore some standard characters that TinyMCE recommends in its character map. … … 194 183 }; 195 184 196 if ( window.addEventListener ) { 197 window.addEventListener( 'load', emoji.load, false ); 198 } else if ( window.attachEvent ) { 199 window.attachEvent( 'onload', emoji.load ); 200 } 185 emoji.init(); 201 186 202 emoji.init();203 } )();187 wp.emoji = emoji; 188 } )( window, window.wp, window.twemoji, window._wpemojiSettings ); -
trunk/src/wp-includes/script-loader.php
r31749 r31750 448 448 449 449 if ( is_admin() ) { 450 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' , 'emoji'), false, 1 );450 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 ); 451 451 did_action( 'init' ) && $scripts->localize( 'admin-tags', 'tagsl10n', array( 452 452 'noPerm' => __('You do not have permission to do that.'), … … 471 471 ) ); 472 472 473 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box' , 'emoji'), false, 1 );473 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box' ), false, 1 ); 474 474 did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array( 475 475 'ok' => __('OK'), … … 523 523 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone' ), false, 1 ); 524 524 525 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' , 'emoji'), false, 1 );525 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), false, 1 ); 526 526 did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( 527 527 'error' => __('Error while saving the changes.'), … … 531 531 ) ); 532 532 533 $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' , 'emoji'), false, 1 );533 $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), false, 1 ); 534 534 did_action( 'init' ) && $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( 535 535 'error' => __('Error while saving the changes.')
Note: See TracChangeset
for help on using the changeset viewer.