Ticket #12921: 12921.1.patch
| File 12921.1.patch, 3.7 KB (added by koopersmith, 3 years ago) |
|---|
-
wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js
9 9 mceTout : 0, 10 10 11 11 init : function(ed, url) { 12 var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'), last = 0,moreHTML, nextpageHTML;12 var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'), moreHTML, nextpageHTML; 13 13 moreHTML = '<img src="' + url + '/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+ed.getLang('wordpress.wp_more_alt')+'" />'; 14 14 nextpageHTML = '<img src="' + url + '/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+ed.getLang('wordpress.wp_page_alt')+'" />'; 15 15 … … 162 162 // Word count if script is loaded 163 163 if ( 'undefined' != typeof wpWordCount ) { 164 164 ed.onKeyUp.add(function(ed, e) { 165 if ( e.keyCode == last ) return; 166 if ( 13 == e.keyCode || 8 == last || 46 == last ) wpWordCount.wc( ed.getContent({format : 'raw'}) ); 167 last = e.keyCode; 165 wpWordCount.keyup( e, function(){ return ed.getContent({format : 'raw'}); }); 168 166 }); 167 ed.onPaste.add(function(ed, e) { 168 wpWordCount.update(); 169 }); 169 170 }; 170 171 171 172 ed.onSaveContent.add(function(ed, o) { -
wp-admin/js/word-count.dev.js
3 3 wpWordCount = { 4 4 5 5 init : function() { 6 var t = this, last = 0, co = $('#content');6 var t = this, co = $('#content'), fn = function() { return co.val(); }; 7 7 8 8 $('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '<span id="word-count">0</span>' ) ); 9 t.block = 0; 10 t.wc(co.val()); 9 t.block = false; 10 t.pending = false; 11 t.last = 0; 12 13 t.wc( fn ); 14 11 15 co.keyup( function(e) { 12 if ( e.keyCode == last ) return true; 13 if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val()); 14 last = e.keyCode; 15 return true; 16 t.keyup( e, fn ); 17 }).bind('paste select', function(){ 18 t.update(); 16 19 }); 17 20 }, 21 22 keyup : function( e, fn ) { 23 if ( ! (e instanceof $.Event) ) e = $.event.fix(e); 24 25 var t = this, key = e.which; 26 27 if ( key == t.last ) return; 28 29 if ( t.block && 32 == key && 8 != t.last && 46 != t.last ) t.increment(); 30 if ( 32 == key || 13 == key || 8 == t.last || 46 == t.last ) t.wc( fn ); 31 32 t.last = key; 33 }, 34 35 update : function() { 36 this.last = 8; 37 }, 38 39 increment : function() { 40 var w = $('#word-count'); 41 w.html( (w.html() * 1 + 1).toString() ); 42 }, 43 44 wc : function(fn) { 45 var t = this; 18 46 19 wc : function(tx) { 20 var t = this, w = $('#word-count'), tc = 0; 47 if ( t.block ) { 48 t.pending = fn; 49 return; 50 } 51 t.block = true; 52 t.pending = false; 53 54 var w = $('#word-count'), tc = 0, tx = fn(); 21 55 22 if ( t.block ) return;23 t.block = 1;24 25 56 setTimeout( function() { 57 var time = new Date().getMilliseconds(); 58 26 59 if ( tx ) { 60 tx = tx + " "; 27 61 tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( / | /gi, ' ' ); 28 62 tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' ); 29 63 tx.replace( /\S\s+/g, function(){tc++;} ); 30 64 } 31 65 w.html(tc.toString()); 66 67 time = ( new Date().getMilliseconds() - time ) * 100; 68 time = ( time > 2000 ) ? time : 2000; 32 69 33 setTimeout( function() { t.block = 0; }, 2000 ); 70 setTimeout( function() { 71 t.block = false; 72 if( t.pending ) t.wc(t.pending); 73 }, time ); 34 74 }, 1 ); 35 75 } 36 76 }
