WordPress.org

Make WordPress Core

Ticket #12921: 12921.2.patch

File 12921.2.patch, 24.0 KB (added by koopersmith, 5 years ago)
  • wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js

     
    1 (function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.WordPress",{mceTout:0,init:function(c,d){var e=this,h=c.getParam("wordpress_adv_toolbar","toolbar2"),g=0,f,b;f='<img src="'+d+'/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+c.getLang("wordpress.wp_more_alt")+'" />';b='<img src="'+d+'/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+c.getLang("wordpress.wp_page_alt")+'" />';if(getUserSetting("hidetb","0")=="1"){c.settings.wordpress_adv_hidden=0}c.onPostRender.add(function(){var i=c.controlManager.get(h);if(c.getParam("wordpress_adv_hidden",1)&&i){a.hide(i.id);e._resizeIframe(c,h,28)}});c.addCommand("WP_More",function(){c.execCommand("mceInsertContent",0,f)});c.addCommand("WP_Page",function(){c.execCommand("mceInsertContent",0,b)});c.addCommand("WP_Help",function(){c.windowManager.open({url:tinymce.baseURL+"/wp-mce-help.php",width:450,height:420,inline:1})});c.addCommand("WP_Adv",function(){var i=c.controlManager,j=i.get(h).id;if("undefined"==j){return}if(a.isHidden(j)){i.setActive("wp_adv",1);a.show(j);e._resizeIframe(c,h,-28);c.settings.wordpress_adv_hidden=0;setUserSetting("hidetb","1")}else{i.setActive("wp_adv",0);a.hide(j);e._resizeIframe(c,h,28);c.settings.wordpress_adv_hidden=1;setUserSetting("hidetb","0")}});c.addButton("wp_more",{title:"wordpress.wp_more_desc",image:d+"/img/more.gif",cmd:"WP_More"});c.addButton("wp_page",{title:"wordpress.wp_page_desc",image:d+"/img/page.gif",cmd:"WP_Page"});c.addButton("wp_help",{title:"wordpress.wp_help_desc",image:d+"/img/help.gif",cmd:"WP_Help"});c.addButton("wp_adv",{title:"wordpress.wp_adv_desc",image:d+"/img/toolbars.gif",cmd:"WP_Adv"});c.addButton("add_media",{title:"wordpress.add_media",image:d+"/img/media.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_media").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_image",{title:"wordpress.add_image",image:d+"/img/image.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_image").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_video",{title:"wordpress.add_video",image:d+"/img/video.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_video").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_audio",{title:"wordpress.add_audio",image:d+"/img/audio.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_audio").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.onBeforeExecCommand.add(function(i,l,k,m){var j=tinymce.DOM;if("mceFullScreen"!=l){return}if("mce_fullscreen"!=i.id&&j.get("add_audio")&&j.get("add_video")&&j.get("add_image")&&j.get("add_media")){i.settings.theme_advanced_buttons1+=",|,add_image,add_video,add_audio,add_media"}});c.addCommand("JustifyLeft",function(){var i=c.selection.getNode();if(i.nodeName!="IMG"){c.editorCommands.mceJustify("JustifyLeft","left")}else{c.plugins.wordpress.do_align(i,"alignleft")}});c.addCommand("JustifyRight",function(){var i=c.selection.getNode();if(i.nodeName!="IMG"){c.editorCommands.mceJustify("JustifyRight","right")}else{c.plugins.wordpress.do_align(i,"alignright")}});c.addCommand("JustifyCenter",function(){var k=c.selection.getNode(),j=c.dom.getParent(k,"p"),i=c.dom.getParent(k,"dl");if(k.nodeName=="IMG"&&(j||i)){c.plugins.wordpress.do_align(k,"aligncenter")}else{c.editorCommands.mceJustify("JustifyCenter","center")}});if("undefined"!=typeof wpWordCount){c.onKeyUp.add(function(i,j){if(j.keyCode==g){return}if(13==j.keyCode||8==g||46==g){wpWordCount.wc(i.getContent({format:"raw"}))}g=j.keyCode})}c.onSaveContent.add(function(i,j){if(typeof(switchEditors)=="object"){if(i.isHidden()){j.content=j.element.value}else{j.content=switchEditors.pre_wpautop(j.content)}}});e._handleMoreBreak(c,d);c.addShortcut("alt+shift+c",c.getLang("justifycenter_desc"),"JustifyCenter");c.addShortcut("alt+shift+r",c.getLang("justifyright_desc"),"JustifyRight");c.addShortcut("alt+shift+l",c.getLang("justifyleft_desc"),"JustifyLeft");c.addShortcut("alt+shift+j",c.getLang("justifyfull_desc"),"JustifyFull");c.addShortcut("alt+shift+q",c.getLang("blockquote_desc"),"mceBlockQuote");c.addShortcut("alt+shift+u",c.getLang("bullist_desc"),"InsertUnorderedList");c.addShortcut("alt+shift+o",c.getLang("numlist_desc"),"InsertOrderedList");c.addShortcut("alt+shift+d",c.getLang("striketrough_desc"),"Strikethrough");c.addShortcut("alt+shift+n",c.getLang("spellchecker.desc"),"mceSpellCheck");c.addShortcut("alt+shift+a",c.getLang("link_desc"),"mceLink");c.addShortcut("alt+shift+s",c.getLang("unlink_desc"),"unlink");c.addShortcut("alt+shift+m",c.getLang("image_desc"),"mceImage");c.addShortcut("alt+shift+g",c.getLang("fullscreen.desc"),"mceFullScreen");c.addShortcut("alt+shift+z",c.getLang("wp_adv_desc"),"WP_Adv");c.addShortcut("alt+shift+h",c.getLang("help_desc"),"WP_Help");c.addShortcut("alt+shift+t",c.getLang("wp_more_desc"),"WP_More");c.addShortcut("alt+shift+p",c.getLang("wp_page_desc"),"WP_Page");c.addShortcut("ctrl+s",c.getLang("save_desc"),function(){if("function"==typeof autosave){autosave()}});if(tinymce.isWebKit){c.addShortcut("alt+shift+b",c.getLang("bold_desc"),"Bold");c.addShortcut("alt+shift+i",c.getLang("italic_desc"),"Italic")}c.onInit.add(function(i){tinymce.dom.Event.add(i.getWin(),"scroll",function(j){i.plugins.wordpress._hideButtons()});tinymce.dom.Event.add(i.getBody(),"dragstart",function(j){i.plugins.wordpress._hideButtons()})});c.onBeforeExecCommand.add(function(i,k,j,l){i.plugins.wordpress._hideButtons()});c.onSaveContent.add(function(i,j){i.plugins.wordpress._hideButtons()});c.onMouseDown.add(function(i,j){if(j.target.nodeName!="IMG"){i.plugins.wordpress._hideButtons()}})},getInfo:function(){return{longname:"WordPress Plugin",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"3.0"}},_setEmbed:function(b){return b.replace(/\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g,function(d,c){return'<img width="300" height="200" src="'+tinymce.baseURL+'/plugins/wordpress/img/trans.gif" class="wp-oembed mceItemNoResize" alt="'+c+'" title="'+c+'" />'})},_getEmbed:function(b){return b.replace(/<img[^>]+>/g,function(c){if(c.indexOf('class="wp-oembed')!=-1){var d=c.match(/alt="([^\"]+)"/);if(d[1]){c="[embed]"+d[1]+"[/embed]"}}return c})},_showButtons:function(f,d){var g=tinyMCE.activeEditor,i,h,b,j=tinymce.DOM,e,c;b=g.dom.getViewPort(g.getWin());i=j.getPos(g.getContentAreaContainer());h=g.dom.getPos(f);e=Math.max(h.x-b.x,0)+i.x;c=Math.max(h.y-b.y,0)+i.y;j.setStyles(d,{top:c+5+"px",left:e+5+"px",display:"block"});if(this.mceTout){clearTimeout(this.mceTout)}this.mceTout=setTimeout(function(){g.plugins.wordpress._hideButtons()},5000)},_hideButtons:function(){if(!this.mceTout){return}if(document.getElementById("wp_editbtns")){tinymce.DOM.hide("wp_editbtns")}if(document.getElementById("wp_gallerybtns")){tinymce.DOM.hide("wp_gallerybtns")}clearTimeout(this.mceTout);this.mceTout=0},do_align:function(j,d){var h,f,g,b,i,e=tinyMCE.activeEditor;if(/^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(j.className)){return}h=e.dom.getParent(j,"p");f=e.dom.getParent(j,"dl");g=e.dom.getParent(j,"div");if(f&&g){b=e.dom.hasClass(f,d)?"alignnone":d;f.className=f.className.replace(/align[^ '"]+\s?/g,"");e.dom.addClass(f,b);i=(b=="aligncenter")?e.dom.addClass(g,"mceIEcenter"):e.dom.removeClass(g,"mceIEcenter")}else{if(h){b=e.dom.hasClass(j,d)?"alignnone":d;j.className=j.className.replace(/align[^ '"]+\s?/g,"");e.dom.addClass(j,b);if(b=="aligncenter"){e.dom.setStyle(h,"textAlign","center")}else{if(h.style&&h.style.textAlign=="center"){e.dom.setStyle(h,"textAlign","")}}}}e.execCommand("mceRepaint")},_resizeIframe:function(c,e,b){var d=c.getContentAreaContainer().firstChild;a.setStyle(d,"height",d.clientHeight+b);c.theme.deltaHeight+=b},_handleMoreBreak:function(c,d){var e,b;e='<img src="'+d+'/img/trans.gif" alt="$1" class="mceWPmore mceItemNoResize" title="'+c.getLang("wordpress.wp_more_alt")+'" />';b='<img src="'+d+'/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+c.getLang("wordpress.wp_page_alt")+'" />';c.onInit.add(function(){c.dom.loadCSS(d+"/css/content.css")});c.onPostRender.add(function(){if(c.theme.onResolveName){c.theme.onResolveName.add(function(f,g){if(g.node.nodeName=="IMG"){if(c.dom.hasClass(g.node,"mceWPmore")){g.name="wpmore"}if(c.dom.hasClass(g.node,"mceWPnextpage")){g.name="wppage"}}})}});c.onBeforeSetContent.add(function(f,g){g.content=g.content.replace(/<!--more(.*?)-->/g,e);g.content=g.content.replace(/<!--nextpage-->/g,b)});c.onPostProcess.add(function(f,g){if(g.get){g.content=g.content.replace(/<img[^>]+>/g,function(i){if(i.indexOf('class="mceWPmore')!==-1){var h,j=(h=i.match(/alt="(.*?)"/))?h[1]:"";i="<!--more"+j+"-->"}if(i.indexOf('class="mceWPnextpage')!==-1){i="<!--nextpage-->"}return i})}});c.onNodeChange.add(function(g,f,h){f.setActive("wp_page",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPnextpage"));f.setActive("wp_more",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPmore"))})}});tinymce.PluginManager.add("wordpress",tinymce.plugins.WordPress)})(); 
    2  No newline at end of file 
     1(function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.WordPress",{mceTout:0,init:function(c,d){var e=this,g=c.getParam("wordpress_adv_toolbar","toolbar2"),f,b;f='<img src="'+d+'/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+c.getLang("wordpress.wp_more_alt")+'" />';b='<img src="'+d+'/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+c.getLang("wordpress.wp_page_alt")+'" />';if(getUserSetting("hidetb","0")=="1"){c.settings.wordpress_adv_hidden=0}c.onPostRender.add(function(){var h=c.controlManager.get(g);if(c.getParam("wordpress_adv_hidden",1)&&h){a.hide(h.id);e._resizeIframe(c,g,28)}});c.addCommand("WP_More",function(){c.execCommand("mceInsertContent",0,f)});c.addCommand("WP_Page",function(){c.execCommand("mceInsertContent",0,b)});c.addCommand("WP_Help",function(){c.windowManager.open({url:tinymce.baseURL+"/wp-mce-help.php",width:450,height:420,inline:1})});c.addCommand("WP_Adv",function(){var h=c.controlManager,i=h.get(g).id;if("undefined"==i){return}if(a.isHidden(i)){h.setActive("wp_adv",1);a.show(i);e._resizeIframe(c,g,-28);c.settings.wordpress_adv_hidden=0;setUserSetting("hidetb","1")}else{h.setActive("wp_adv",0);a.hide(i);e._resizeIframe(c,g,28);c.settings.wordpress_adv_hidden=1;setUserSetting("hidetb","0")}});c.addButton("wp_more",{title:"wordpress.wp_more_desc",image:d+"/img/more.gif",cmd:"WP_More"});c.addButton("wp_page",{title:"wordpress.wp_page_desc",image:d+"/img/page.gif",cmd:"WP_Page"});c.addButton("wp_help",{title:"wordpress.wp_help_desc",image:d+"/img/help.gif",cmd:"WP_Help"});c.addButton("wp_adv",{title:"wordpress.wp_adv_desc",image:d+"/img/toolbars.gif",cmd:"WP_Adv"});c.addButton("add_media",{title:"wordpress.add_media",image:d+"/img/media.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_media").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_image",{title:"wordpress.add_image",image:d+"/img/image.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_image").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_video",{title:"wordpress.add_video",image:d+"/img/video.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_video").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_audio",{title:"wordpress.add_audio",image:d+"/img/audio.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_audio").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.onBeforeExecCommand.add(function(h,k,j,l){var i=tinymce.DOM;if("mceFullScreen"!=k){return}if("mce_fullscreen"!=h.id&&i.get("add_audio")&&i.get("add_video")&&i.get("add_image")&&i.get("add_media")){h.settings.theme_advanced_buttons1+=",|,add_image,add_video,add_audio,add_media"}});c.addCommand("JustifyLeft",function(){var h=c.selection.getNode();if(h.nodeName!="IMG"){c.editorCommands.mceJustify("JustifyLeft","left")}else{c.plugins.wordpress.do_align(h,"alignleft")}});c.addCommand("JustifyRight",function(){var h=c.selection.getNode();if(h.nodeName!="IMG"){c.editorCommands.mceJustify("JustifyRight","right")}else{c.plugins.wordpress.do_align(h,"alignright")}});c.addCommand("JustifyCenter",function(){var j=c.selection.getNode(),i=c.dom.getParent(j,"p"),h=c.dom.getParent(j,"dl");if(j.nodeName=="IMG"&&(i||h)){c.plugins.wordpress.do_align(j,"aligncenter")}else{c.editorCommands.mceJustify("JustifyCenter","center")}});if("undefined"!=typeof wpWordCount){c.onKeyUp.add(function(h,i){wpWordCount.keyup(i,function(){return h.getContent({format:"raw"})})});c.onPaste.add(function(h,i){wpWordCount.update()})}c.onSaveContent.add(function(h,i){if(typeof(switchEditors)=="object"){if(h.isHidden()){i.content=i.element.value}else{i.content=switchEditors.pre_wpautop(i.content)}}});e._handleMoreBreak(c,d);c.addShortcut("alt+shift+c",c.getLang("justifycenter_desc"),"JustifyCenter");c.addShortcut("alt+shift+r",c.getLang("justifyright_desc"),"JustifyRight");c.addShortcut("alt+shift+l",c.getLang("justifyleft_desc"),"JustifyLeft");c.addShortcut("alt+shift+j",c.getLang("justifyfull_desc"),"JustifyFull");c.addShortcut("alt+shift+q",c.getLang("blockquote_desc"),"mceBlockQuote");c.addShortcut("alt+shift+u",c.getLang("bullist_desc"),"InsertUnorderedList");c.addShortcut("alt+shift+o",c.getLang("numlist_desc"),"InsertOrderedList");c.addShortcut("alt+shift+d",c.getLang("striketrough_desc"),"Strikethrough");c.addShortcut("alt+shift+n",c.getLang("spellchecker.desc"),"mceSpellCheck");c.addShortcut("alt+shift+a",c.getLang("link_desc"),"mceLink");c.addShortcut("alt+shift+s",c.getLang("unlink_desc"),"unlink");c.addShortcut("alt+shift+m",c.getLang("image_desc"),"mceImage");c.addShortcut("alt+shift+g",c.getLang("fullscreen.desc"),"mceFullScreen");c.addShortcut("alt+shift+z",c.getLang("wp_adv_desc"),"WP_Adv");c.addShortcut("alt+shift+h",c.getLang("help_desc"),"WP_Help");c.addShortcut("alt+shift+t",c.getLang("wp_more_desc"),"WP_More");c.addShortcut("alt+shift+p",c.getLang("wp_page_desc"),"WP_Page");c.addShortcut("ctrl+s",c.getLang("save_desc"),function(){if("function"==typeof autosave){autosave()}});if(tinymce.isWebKit){c.addShortcut("alt+shift+b",c.getLang("bold_desc"),"Bold");c.addShortcut("alt+shift+i",c.getLang("italic_desc"),"Italic")}c.onInit.add(function(h){tinymce.dom.Event.add(h.getWin(),"scroll",function(i){h.plugins.wordpress._hideButtons()});tinymce.dom.Event.add(h.getBody(),"dragstart",function(i){h.plugins.wordpress._hideButtons()})});c.onBeforeExecCommand.add(function(h,j,i,k){h.plugins.wordpress._hideButtons()});c.onSaveContent.add(function(h,i){h.plugins.wordpress._hideButtons()});c.onMouseDown.add(function(h,i){if(i.target.nodeName!="IMG"){h.plugins.wordpress._hideButtons()}})},getInfo:function(){return{longname:"WordPress Plugin",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"3.0"}},_setEmbed:function(b){return b.replace(/\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g,function(d,c){return'<img width="300" height="200" src="'+tinymce.baseURL+'/plugins/wordpress/img/trans.gif" class="wp-oembed mceItemNoResize" alt="'+c+'" title="'+c+'" />'})},_getEmbed:function(b){return b.replace(/<img[^>]+>/g,function(c){if(c.indexOf('class="wp-oembed')!=-1){var d=c.match(/alt="([^\"]+)"/);if(d[1]){c="[embed]"+d[1]+"[/embed]"}}return c})},_showButtons:function(f,d){var g=tinyMCE.activeEditor,i,h,b,j=tinymce.DOM,e,c;b=g.dom.getViewPort(g.getWin());i=j.getPos(g.getContentAreaContainer());h=g.dom.getPos(f);e=Math.max(h.x-b.x,0)+i.x;c=Math.max(h.y-b.y,0)+i.y;j.setStyles(d,{top:c+5+"px",left:e+5+"px",display:"block"});if(this.mceTout){clearTimeout(this.mceTout)}this.mceTout=setTimeout(function(){g.plugins.wordpress._hideButtons()},5000)},_hideButtons:function(){if(!this.mceTout){return}if(document.getElementById("wp_editbtns")){tinymce.DOM.hide("wp_editbtns")}if(document.getElementById("wp_gallerybtns")){tinymce.DOM.hide("wp_gallerybtns")}clearTimeout(this.mceTout);this.mceTout=0},do_align:function(j,d){var h,f,g,b,i,e=tinyMCE.activeEditor;if(/^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(j.className)){return}h=e.dom.getParent(j,"p");f=e.dom.getParent(j,"dl");g=e.dom.getParent(j,"div");if(f&&g){b=e.dom.hasClass(f,d)?"alignnone":d;f.className=f.className.replace(/align[^ '"]+\s?/g,"");e.dom.addClass(f,b);i=(b=="aligncenter")?e.dom.addClass(g,"mceIEcenter"):e.dom.removeClass(g,"mceIEcenter")}else{if(h){b=e.dom.hasClass(j,d)?"alignnone":d;j.className=j.className.replace(/align[^ '"]+\s?/g,"");e.dom.addClass(j,b);if(b=="aligncenter"){e.dom.setStyle(h,"textAlign","center")}else{if(h.style&&h.style.textAlign=="center"){e.dom.setStyle(h,"textAlign","")}}}}e.execCommand("mceRepaint")},_resizeIframe:function(c,e,b){var d=c.getContentAreaContainer().firstChild;a.setStyle(d,"height",d.clientHeight+b);c.theme.deltaHeight+=b},_handleMoreBreak:function(c,d){var e,b;e='<img src="'+d+'/img/trans.gif" alt="$1" class="mceWPmore mceItemNoResize" title="'+c.getLang("wordpress.wp_more_alt")+'" />';b='<img src="'+d+'/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+c.getLang("wordpress.wp_page_alt")+'" />';c.onInit.add(function(){c.dom.loadCSS(d+"/css/content.css")});c.onPostRender.add(function(){if(c.theme.onResolveName){c.theme.onResolveName.add(function(f,g){if(g.node.nodeName=="IMG"){if(c.dom.hasClass(g.node,"mceWPmore")){g.name="wpmore"}if(c.dom.hasClass(g.node,"mceWPnextpage")){g.name="wppage"}}})}});c.onBeforeSetContent.add(function(f,g){g.content=g.content.replace(/<!--more(.*?)-->/g,e);g.content=g.content.replace(/<!--nextpage-->/g,b)});c.onPostProcess.add(function(f,g){if(g.get){g.content=g.content.replace(/<img[^>]+>/g,function(i){if(i.indexOf('class="mceWPmore')!==-1){var h,j=(h=i.match(/alt="(.*?)"/))?h[1]:"";i="<!--more"+j+"-->"}if(i.indexOf('class="mceWPnextpage')!==-1){i="<!--nextpage-->"}return i})}});c.onNodeChange.add(function(g,f,h){f.setActive("wp_page",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPnextpage"));f.setActive("wp_more",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPmore"))})}});tinymce.PluginManager.add("wordpress",tinymce.plugins.WordPress)})(); 
     2 No newline at end of file 
  • wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js

     
    99                mceTout : 0, 
    1010 
    1111                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; 
    1313                        moreHTML = '<img src="' + url + '/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+ed.getLang('wordpress.wp_more_alt')+'" />'; 
    1414                        nextpageHTML = '<img src="' + url + '/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+ed.getLang('wordpress.wp_page_alt')+'" />'; 
    1515 
     
    162162                        // Word count if script is loaded 
    163163                        if ( 'undefined' != typeof wpWordCount ) { 
    164164                                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'}); }); 
    168166                                }); 
     167                                ed.onPaste.add(function(ed, e) { 
     168                                        wpWordCount.update(); 
     169                                }); 
    169170                        }; 
    170171 
    171172                        ed.onSaveContent.add(function(ed, o) { 
  • wp-admin/js/word-count.dev.js

     
    33        wpWordCount = { 
    44 
    55                init : function() { 
    6                         var t = this, last = 0, co = $('#content'); 
     6                        var t = this, co = $('#content'), fn = function() { return co.val(); }; 
    77 
    88                        $('#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                         
    1115                        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(); 
    1619                        }); 
    1720                }, 
     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; 
    1846 
    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(); 
    2155 
    22                         if ( t.block ) return; 
    23                         t.block = 1; 
    24  
    2556                        setTimeout( function() { 
     57                                var time = new Date().getMilliseconds(); 
     58                         
    2659                                if ( tx ) { 
     60                                        tx = tx + " "; 
    2761                                        tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( /&nbsp;|&#160;/gi, ' ' ); 
    2862                                        tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' ); 
    2963                                        tx.replace( /\S\s+/g, function(){tc++;} ); 
    3064                                } 
    3165                                w.html(tc.toString()); 
     66                                 
     67                                time = ( new Date().getMilliseconds() - time ) * 100; 
     68                                time = ( time > 2000 ) ? time : 2000; 
    3269 
    33                                 setTimeout( function() { t.block = 0; }, 2000 ); 
     70                                setTimeout( function() { 
     71                                        t.block = false; 
     72                                        if( t.pending ) t.wc(t.pending); 
     73                                }, time ); 
    3474                        }, 1 ); 
    3575                } 
    3676        } 
  • wp-admin/js/word-count.js

     
    1 (function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'<span id="word-count">0</span>'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/<.[^<>]*?>/g," ").replace(/&nbsp;|&#160;/gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery)); 
    2  No newline at end of file 
     1(function(a){wpWordCount={init:function(){var b=this,d=a("#content"),c=function(){return d.val()};a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'<span id="word-count">0</span>'));b.block=false;b.pending=false;b.last=0;b.wc(c);d.keyup(function(f){b.keyup(f,c)}).bind("paste select",function(){b.update()})},keyup:function(f,d){if(!(f instanceof a.Event)){f=a.event.fix(f)}var c=this,b=f.which;if(b==c.last){return}if(c.block&&32==b&&8!=c.last&&46!=c.last){c.increment()}if(32==b||13==b||8==c.last||46==c.last){c.wc(d)}c.last=b},update:function(){this.last=8},increment:function(){var b=a("#word-count");b.html((b.html()*1+1).toString())},wc:function(f){var e=this;if(e.block){e.pending=f;return}e.block=true;e.pending=false;var d=a("#word-count"),b=0,c=f();setTimeout(function(){var g=new Date().getMilliseconds();if(c){c=c+" ";c=c.replace(/<.[^<>]*?>/g," ").replace(/&nbsp;|&#160;/gi," ");c=c.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");c.replace(/\S\s+/g,function(){b++})}d.html(b.toString());g=(new Date().getMilliseconds()-g)*100;g=(g>2000)?g:2000;setTimeout(function(){e.block=false;if(e.pending){e.wc(e.pending)}},g)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery)); 
     2 No newline at end of file