Ticket #31242: 31242.2.patch
File 31242.2.patch, 11.3 KB (added by , 10 years ago) |
---|
-
Gruntfile.js
295 295 'wp-includes/js/tinymce/plugins/wp*/plugin.js', 296 296 // Third party scripts 297 297 '!wp-admin/js/farbtastic.js', 298 '!wp-includes/js/backbone *.js',298 '!wp-includes/js/backbone.js', 299 299 '!wp-includes/js/swfobject.js', 300 '!wp-includes/js/underscore *.js',300 '!wp-includes/js/underscore.js', 301 301 '!wp-includes/js/colorpicker.js', 302 302 '!wp-includes/js/hoverIntent.js', 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 ], 307 308 // Remove once other JSHint errors are resolved -
src/wp-admin/js/inline-edit-post.js
272 272 if ( -1 !== r.indexOf( '<tr' ) ) { 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 { 278 277 r = r.replace( /<.[^<>]*?>/g, '' ); -
src/wp-admin/js/inline-edit-tax.js
117 117 // Update the value in the Parent dropdown. 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 { 124 122 $('#edit-'+id+' .inline-edit-save .error').html(r).show(); -
src/wp-admin/js/post.js
741 741 }); 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); 748 746 $('#view-post-btn').show(); -
src/wp-admin/js/tags.js
49 49 else 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 56 54 if ( form.find('select#parent') ) { -
src/wp-content/themes/twentyfifteen/style.css
1 1 /* 2 Theme Name: Twenty Fifteen 2 Theme Name: Twenty Fifteen 😋 3 3 Theme URI: https://wordpress.org/themes/twentyfifteen 4 4 Author: the WordPress team 5 5 Author URI: https://wordpress.org/ -
src/wp-includes/js/wp-emoji.js
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. 28 7 * 29 8 * @since 4.2.0 30 9 * 31 * @var bool10 * @var Boolean 32 11 */ 33 12 parseAllEmoji: false, 34 13 … … 37 16 * 38 17 * @since 4.2.0 39 18 * 40 * @var bool19 * @var Boolean 41 20 */ 42 21 parseEmoji: false, 43 22 … … 46 25 * 47 26 * @since 4.2.0 48 27 * 49 * @var bool28 * @var Boolean 50 29 */ 51 30 parseFlags: false, 52 31 … … 56 35 * @since 4.2.0 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 }, 72 48 … … 76 52 * @since 4.2.0 77 53 */ 78 54 load: function() { 55 new MutationObserver( callback ) 56 57 .observe( document.body, { 58 childList: true, 59 subtree: true 60 } ); 61 62 function callback( mutationRecords ) { 63 var i = mutationRecords.length, 64 ii, 65 node; 66 67 while ( i-- ) { 68 ii = mutationRecords[ i ].addedNodes.length; 69 70 while ( ii-- ) { 71 node = mutationRecords[ i ].addedNodes[ ii ]; 72 73 if ( node.nodeType === 3 ) { 74 node = node.parentNode; 75 } 76 77 if ( node.nodeType === 1 ) { 78 emoji.parse( node ); 79 } 80 } 81 } 82 } 83 79 84 emoji.parse( document.body ); 80 85 }, 81 86 … … 84 89 * 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 101 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 103 102 /* 104 103 * Chrome OS X added native emoji rendering in M41. Unfortunately, 105 104 * it doesn't work when the font is bolder than 500 weight. So, we … … 107 106 */ 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; 113 112 }, … … 117 116 * made of two characters, so some browsers (notably, Firefox OS X) don't support them. 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; 129 } 130 131 context = canvas.getContext( '2d' ); 132 133 if ( typeof context.fillText != 'function' ) { 134 return; 126 if ( ! context.fillText ) { 127 return false; 135 128 } 136 129 137 flag = String.fromCharCode(55356) + String.fromCharCode(56812); // [G]138 flag += String.fromCharCode(55356) + String.fromCharCode(56807); // [B]139 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 /* 145 135 * This works because the image will be one of three things: … … 151 141 * to a larger image (4-5KB data URL). 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. 174 163 switch ( icon ) { … … 193 182 } 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 }201 202 185 emoji.init(); 203 })(); 186 187 wp.emoji = emoji; 188 } )( window, window.wp, window.twemoji, window._wpemojiSettings ); -
src/wp-includes/script-loader.php
447 447 $scripts->enqueue( 'emoji' ); 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.'), 453 453 'broken' => __('An unidentified error has occurred.') … … 470 470 'tagDelimiter' => _x( ',', 'tag delimiter' ), 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'), 476 476 'cancel' => __('Cancel'), … … 522 522 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.'), 528 528 'ntdeltitle' => __('Remove From Bulk Edit'), … … 530 530 'comma' => trim( _x( ',', 'tag delimiter' ) ), 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.') 536 536 ) );