Changeset 32361
- Timestamp:
- 05/06/2015 01:34:41 AM (10 years ago)
- Location:
- branches/4.2/src/wp-includes/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.2/src/wp-includes/js/wp-emoji-loader.js
r31876 r32361 1 1 ( function( window, document, settings ) { 2 var src ;2 var src, ready; 3 3 4 4 /** … … 63 63 }; 64 64 65 settings.DOMReady = false; 66 settings.readyCallback = function() { 67 settings.DOMReady = true; 68 }; 69 65 70 if ( ! settings.supports.simple || ! settings.supports.flag ) { 71 ready = function() { 72 settings.readyCallback(); 73 }; 74 75 if ( document.addEventListener ) { 76 document.addEventListener( 'DOMContentLoaded', ready, false ); 77 window.addEventListener( 'load', ready, false ); 78 } else { 79 window.attachEvent( 'onload', ready ); 80 document.attachEvent( 'onreadystatechange', function() { 81 if ( 'complete' === document.readyState ) { 82 settings.readyCallback(); 83 } 84 } ); 85 } 86 66 87 src = settings.source || {}; 67 88 -
branches/4.2/src/wp-includes/js/wp-emoji.js
r32360 r32361 3 3 function wpEmoji() { 4 4 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, 5 6 /**7 * Flag to determine if the browser and the OS support emoji.8 *9 * @since 4.2.010 *11 * @var Boolean12 */13 supportsEmoji = false,14 15 /**16 * Flag to determine if the browser and the OS support flag (two character) emoji.17 *18 * @since 4.2.019 *20 * @var Boolean21 */22 supportsFlagEmoji = false,23 5 24 6 /** … … 31 13 replaceEmoji = false, 32 14 33 isIE8 = window.navigator.userAgent.indexOf( 'IE 8' ) !== -1,34 35 15 // Private 36 16 twemoji, timer, 17 loaded = false, 37 18 count = 0; 38 19 … … 43 24 */ 44 25 function load() { 26 if ( loaded ) { 27 return; 28 } 29 45 30 if ( typeof window.twemoji === 'undefined' ) { 46 31 // Break if waiting for longer than 30 sec. … … 58 43 59 44 twemoji = window.twemoji; 45 loaded = true; 60 46 61 47 if ( MutationObserver ) { … … 108 94 */ 109 95 function parse( object, args ) { 110 if ( ! replaceEmoji ) {96 if ( ! replaceEmoji || ! twemoji ) { 111 97 return object; 112 98 } … … 133 119 } 134 120 135 if ( ! s upportsFlagEmoji && supportsEmoji&&121 if ( ! settings.supports.flag && settings.supports.simple && 136 122 ! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) ) { 137 123 … … 144 130 } 145 131 146 // Load when the readyState changes to 'interactive', not 'complete'.147 function onLoad() {148 if ( ( ! isIE8 && 'interactive' === document.readyState ) || ( isIE8 && 'complete' === document.readyState ) ) {149 load();150 }151 }152 153 132 /** 154 133 * Initialize our emoji support, and set up listeners. 155 134 */ 156 135 if ( settings ) { 157 supportsEmoji = window._wpemojiSettings.supports.simple; 158 supportsFlagEmoji = window._wpemojiSettings.supports.flag; 159 replaceEmoji = ! supportsEmoji || ! supportsFlagEmoji; 136 replaceEmoji = ! settings.supports.simple || ! settings.supports.flag; 160 137 161 if ( ( ! isIE8 && 'loading' === document.readyState ) || ( isIE8 && 'complete' !== document.readyState ) ) { 162 if ( document.addEventListener ) { 163 document.addEventListener( 'readystatechange', onLoad, false ); 164 } else if ( document.attachEvent ) { 165 document.attachEvent( 'onreadystatechange', onLoad ); 166 } 138 if ( settings.DOMReady ) { 139 load(); 167 140 } else { 168 load();141 settings.readyCallback = load; 169 142 } 170 143 }
Note: See TracChangeset
for help on using the changeset viewer.