X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..e0bf0ae6a149125bedfeaf344114a97d5864e74d:/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js?ds=sidebyside diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js index faff8415..afacc227 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js @@ -1,298 +1 @@ -/** - * WordPress plugin. - */ - -(function() { - var DOM = tinymce.DOM; - - // Load plugin specific language pack - tinymce.PluginManager.requireLangPack('wordpress'); - - tinymce.create('tinymce.plugins.WordPress', { - init : function(ed, url) { - var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'); - var moreHTML = ''; - var nextpageHTML = ''; - - if ( tinymce.util.Cookie.get('kitchenSink') == '1' ) - ed.settings.wordpress_adv_hidden = 0; - - // Hides the specified toolbar and resizes the iframe - ed.onPostRender.add(function() { - if ( ed.getParam('wordpress_adv_hidden', 1) ) { - DOM.hide(ed.controlManager.get(tbId).id); - t._resizeIframe(ed, tbId, 28); - } - }); - - // Register commands - ed.addCommand('WP_More', function() { - ed.execCommand('mceInsertContent', 0, moreHTML); - }); - - ed.addCommand('WP_Page', function() { - ed.execCommand('mceInsertContent', 0, nextpageHTML); - }); - - ed.addCommand('WP_Help', function() { - ed.windowManager.open({ - url : tinymce.baseURL + '/wp-mce-help.php', - width : 450, - height : 420, - inline : 1 - }); - }); - - ed.addCommand('WP_Adv', function() { - var id = ed.controlManager.get(tbId).id, cm = ed.controlManager, cook = tinymce.util.Cookie, date; - - date = new Date(); - date.setTime(date.getTime()+(10*365*24*60*60*1000)); - - if (DOM.isHidden(id)) { - cm.setActive('wp_adv', 1); - DOM.show(id); - t._resizeIframe(ed, tbId, -28); - ed.settings.wordpress_adv_hidden = 0; - cook.set('kitchenSink', '1', date); - } else { - cm.setActive('wp_adv', 0); - DOM.hide(id); - t._resizeIframe(ed, tbId, 28); - ed.settings.wordpress_adv_hidden = 1; - cook.set('kitchenSink', '0', date); - } - }); - - // Register buttons - ed.addButton('wp_more', { - title : 'wordpress.wp_more_desc', - image : url + '/img/more.gif', - cmd : 'WP_More' - }); - - ed.addButton('wp_page', { - title : 'wordpress.wp_page_desc', - image : url + '/img/page.gif', - cmd : 'WP_Page' - }); - - ed.addButton('wp_help', { - title : 'wordpress.wp_help_desc', - image : url + '/img/help.gif', - cmd : 'WP_Help' - }); - - ed.addButton('wp_adv', { - title : 'wordpress.wp_adv_desc', - image : url + '/img/toolbars.gif', - cmd : 'WP_Adv' - }); - - // Add Media buttons - ed.addButton('add_media', { - title : 'wordpress.add_media', - image : url + '/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' ); - } - }); - - ed.addButton('add_image', { - title : 'wordpress.add_image', - image : url + '/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' ); - } - }); - - ed.addButton('add_video', { - title : 'wordpress.add_video', - image : url + '/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' ); - } - }); - - ed.addButton('add_audio', { - title : 'wordpress.add_audio', - image : url + '/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' ); - } - }); - - // Add Media buttons to fullscreen - ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) { - if ( 'mceFullScreen' != cmd ) return; - if ( 'mce_fullscreen' != ed.id ) - ed.settings.theme_advanced_buttons1 += ',|,add_image,add_video,add_audio,add_media'; - }); - - // Add class "alignleft", "alignright" and "aligncenter" when selecting align for images. - ed.addCommand('JustifyLeft', function() { - var n = ed.selection.getNode(); - - if ( n.nodeName != 'IMG' ) - ed.editorCommands.mceJustify('JustifyLeft', 'left'); - else ed.plugins.wordpress.do_align(n, 'alignleft'); - }); - - ed.addCommand('JustifyRight', function() { - var n = ed.selection.getNode(); - - if ( n.nodeName != 'IMG' ) - ed.editorCommands.mceJustify('JustifyRight', 'right'); - else ed.plugins.wordpress.do_align(n, 'alignright'); - }); - - ed.addCommand('JustifyCenter', function() { - var n = ed.selection.getNode(), P = ed.dom.getParent(n, 'p'), DL = ed.dom.getParent(n, 'dl'); - - if ( n.nodeName == 'IMG' && ( P || DL ) ) - ed.plugins.wordpress.do_align(n, 'aligncenter'); - else ed.editorCommands.mceJustify('JustifyCenter', 'center'); - }); - - // Word count if script is loaded - if ( 'undefined' != typeof wpWordCount ) { - var last = 0; - ed.onKeyUp.add(function(ed, e) { - if ( e.keyCode == last ) return; - if ( 13 == e.keyCode || 8 == last || 46 == last ) wpWordCount.wc( ed.getContent({format : 'raw'}) ); - last = e.keyCode; - }); - }; - - // Add listeners to handle more break - t._handleMoreBreak(ed, url); - - // Add custom shortcuts - ed.addShortcut('alt+shift+c', ed.getLang('justifycenter_desc'), 'JustifyCenter'); - ed.addShortcut('alt+shift+r', ed.getLang('justifyright_desc'), 'JustifyRight'); - ed.addShortcut('alt+shift+l', ed.getLang('justifyleft_desc'), 'JustifyLeft'); - ed.addShortcut('alt+shift+j', ed.getLang('justifyfull_desc'), 'JustifyFull'); - ed.addShortcut('alt+shift+q', ed.getLang('blockquote_desc'), 'mceBlockQuote'); - ed.addShortcut('alt+shift+u', ed.getLang('bullist_desc'), 'InsertUnorderedList'); - ed.addShortcut('alt+shift+o', ed.getLang('numlist_desc'), 'InsertOrderedList'); - ed.addShortcut('alt+shift+d', ed.getLang('striketrough_desc'), 'Strikethrough'); - ed.addShortcut('alt+shift+n', ed.getLang('spellchecker.desc'), 'mceSpellCheck'); - ed.addShortcut('alt+shift+a', ed.getLang('link_desc'), 'mceLink'); - ed.addShortcut('alt+shift+s', ed.getLang('unlink_desc'), 'unlink'); - ed.addShortcut('alt+shift+m', ed.getLang('image_desc'), 'mceImage'); - ed.addShortcut('alt+shift+g', ed.getLang('fullscreen.desc'), 'mceFullScreen'); - ed.addShortcut('alt+shift+z', ed.getLang('wp_adv_desc'), 'WP_Adv'); - ed.addShortcut('alt+shift+h', ed.getLang('help_desc'), 'WP_Help'); - ed.addShortcut('alt+shift+t', ed.getLang('wp_more_desc'), 'WP_More'); - ed.addShortcut('alt+shift+p', ed.getLang('wp_page_desc'), 'WP_Page'); - - if ( tinymce.isWebKit ) { - ed.addShortcut('alt+shift+b', ed.getLang('bold_desc'), 'Bold'); - ed.addShortcut('alt+shift+i', ed.getLang('italic_desc'), 'Italic'); - } - }, - - getInfo : function() { - return { - longname : 'WordPress Plugin', - author : 'WordPress', // add Moxiecode? - authorurl : 'http://wordpress.org', - infourl : 'http://wordpress.org', - version : '3.0' - }; - }, - - // Internal functions - do_align : function(n, a) { - var P, DL, DIV, cls, c, ed = tinyMCE.activeEditor; - - P = ed.dom.getParent(n, 'p'); - DL = ed.dom.getParent(n, 'dl'); - DIV = ed.dom.getParent(n, 'div'); - - if ( DL && DIV ) { - cls = ed.dom.hasClass(DL, a) ? 'alignnone' : a; - DL.className = DL.className.replace(/align[^ '"]+\s?/g, ''); - ed.dom.addClass(DL, cls); - c = (cls == 'aligncenter') ? ed.dom.addClass(DIV, 'mceIEcenter') : ed.dom.removeClass(DIV, 'mceIEcenter'); - } else if ( P ) { - cls = ed.dom.hasClass(n, a) ? 'alignnone' : a; - n.className = n.className.replace(/align[^ '"]+\s?/g, ''); - ed.dom.addClass(n, cls); - if ( cls == 'aligncenter' ) - ed.dom.setStyle(P, 'textAlign', 'center'); - else if (P.style && P.style.textAlign == 'center') - ed.dom.setStyle(P, 'textAlign', ''); - } - - ed.execCommand('mceRepaint'); - }, - - // Resizes the iframe by a relative height value - _resizeIframe : function(ed, tb_id, dy) { - var ifr = ed.getContentAreaContainer().firstChild; - - DOM.setStyle(ifr, 'height', ifr.clientHeight + dy); // Resize iframe - ed.theme.deltaHeight += dy; // For resize cookie - }, - - _handleMoreBreak : function(ed, url) { - var moreHTML = '$1'; - var nextpageHTML = ''; - - // Load plugin specific CSS into editor - ed.onInit.add(function() { - ed.dom.loadCSS(url + '/css/content.css'); - }); - - // Display morebreak instead if img in element path - ed.onPostRender.add(function() { - if (ed.theme.onResolveName) { - ed.theme.onResolveName.add(function(th, o) { - if (o.node.nodeName == 'IMG') { - if ( ed.dom.hasClass(o.node, 'mceWPmore') ) - o.name = 'wpmore'; - if ( ed.dom.hasClass(o.node, 'mceWPnextpage') ) - o.name = 'wppage'; - } - - }); - } - }); - - // Replace morebreak with images - ed.onBeforeSetContent.add(function(ed, o) { - o.content = o.content.replace(//g, moreHTML); - o.content = o.content.replace(//g, nextpageHTML); - }); - - // Replace images with morebreak - ed.onPostProcess.add(function(ed, o) { - if (o.get) - o.content = o.content.replace(/]+>/g, function(im) { - if (im.indexOf('class="mceWPmore') !== -1) { - var m, moretext = (m = im.match(/alt="(.*?)"/)) ? m[1] : ''; - im = ''; - } - if (im.indexOf('class="mceWPnextpage') !== -1) - im = ''; - - return im; - }); - }); - - // Set active buttons if user selected pagebreak or more break - ed.onNodeChange.add(function(ed, cm, n) { - cm.setActive('wp_page', n.nodeName === 'IMG' && ed.dom.hasClass(n, 'mceWPnextpage')); - cm.setActive('wp_more', n.nodeName === 'IMG' && ed.dom.hasClass(n, 'mceWPmore')); - }); - } - }); - - // Register plugin - tinymce.PluginManager.add('wordpress', tinymce.plugins.WordPress); -})(); +!function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.WordPress",{init:function(b,c){var d,e,f,g,h,i=this,j=b.getParam("wordpress_adv_toolbar","toolbar2"),k=0;d='',e='',"1"==getUserSetting("hidetb","0")&&(b.settings.wordpress_adv_hidden=0),b.onPostRender.add(function(){var c=b.controlManager.get(j);b.getParam("wordpress_adv_hidden",1)&&c&&(a.hide(c.id),i._resizeIframe(b,j,28))}),b.addCommand("WP_More",function(){b.execCommand("mceInsertContent",0,d)}),b.addCommand("WP_Page",function(){b.execCommand("mceInsertContent",0,e)}),b.addCommand("WP_Help",function(){b.windowManager.open({url:tinymce.baseURL+"/wp-mce-help.php",width:450,height:420,inline:1})}),b.addCommand("WP_Adv",function(){var c=b.controlManager,d=c.get(j).id;"undefined"!=d&&(a.isHidden(d)?(c.setActive("wp_adv",1),a.show(d),i._resizeIframe(b,j,-28),b.settings.wordpress_adv_hidden=0,setUserSetting("hidetb","1")):(c.setActive("wp_adv",0),a.hide(d),i._resizeIframe(b,j,28),b.settings.wordpress_adv_hidden=1,setUserSetting("hidetb","0")))}),b.addCommand("WP_Medialib",function(){"undefined"!=typeof wp&&wp.media&&wp.media.editor&&wp.media.editor.open(b.id)}),b.addButton("wp_more",{title:"wordpress.wp_more_desc",cmd:"WP_More"}),b.addButton("wp_page",{title:"wordpress.wp_page_desc",image:c+"/img/page.gif",cmd:"WP_Page"}),b.addButton("wp_help",{title:"wordpress.wp_help_desc",cmd:"WP_Help"}),b.addButton("wp_adv",{title:"wordpress.wp_adv_desc",cmd:"WP_Adv"}),b.addButton("add_media",{title:"wordpress.add_media",image:c+"/img/image.gif",cmd:"WP_Medialib"}),b.onBeforeExecCommand.add(function(a,b,c,d,e){var f,g,i,j,k,l,m=tinymce.DOM;"mceFullScreen"==b&&"mce_fullscreen"!=a.id&&m.select("a.thickbox").length&&(a.settings.theme_advanced_buttons1+=",|,add_media"),("JustifyLeft"==b||"JustifyRight"==b||"JustifyCenter"==b)&&(f=a.selection.getNode(),"IMG"==f.nodeName&&(l=b.substr(7).toLowerCase(),k="align"+l,g=a.dom.getParent(f,"dl.wp-caption"),i=a.dom.getParent(f,"div.mceTemp"),g&&i?(j=a.dom.hasClass(g,k)?"alignnone":k,g.className=g.className.replace(/align[^ '"]+\s?/g,""),a.dom.addClass(g,j),"aligncenter"==j?a.dom.addClass(i,"mceIEcenter"):a.dom.removeClass(i,"mceIEcenter"),e.terminate=!0,a.execCommand("mceRepaint")):a.dom.hasClass(f,k)?a.dom.addClass(f,"alignnone"):a.dom.removeClass(f,"alignnone"))),!tinymce.isWebKit||"InsertUnorderedList"!=b&&"InsertOrderedList"!=b||(h||(h=a.dom.create("style",{type:"text/css"},"#tinymce,#tinymce span,#tinymce li,#tinymce li>span,#tinymce p,#tinymce p>span{font:medium sans-serif;color:#000;line-height:normal;}")),a.getDoc().head.appendChild(h))}),b.onExecCommand.add(function(a,b){tinymce.isWebKit&&h&&("InsertUnorderedList"==b||"InsertOrderedList"==b)&&a.dom.remove(h)}),b.onInit.add(function(a){var b=a.getParam("body_class",""),c=a.getBody();b=b?b.split(" "):[],"rtl"==a.getParam("directionality","")&&b.push("rtl"),tinymce.isIE9?b.push("ie9"):tinymce.isIE8?b.push("ie8"):tinymce.isIE7&&b.push("ie7"),"wp_mce_fullscreen"!=a.id&&"mce_fullscreen"!=a.id?b.push("wp-editor"):"mce_fullscreen"==a.id&&b.push("mce-fullscreen"),tinymce.each(b,function(b){b&&a.dom.addClass(c,b)}),a.onNodeChange.add(function(a,b,c){var d;"IMG"==c.nodeName?d=a.dom.getParent(c,"dl.wp-caption"):"DIV"==c.nodeName&&a.dom.hasClass(c,"mceTemp")&&(d=c.firstChild,a.dom.hasClass(d,"wp-caption")||(d=!1)),d&&(a.dom.hasClass(d,"alignleft")?b.setActive("justifyleft",1):a.dom.hasClass(d,"alignright")?b.setActive("justifyright",1):a.dom.hasClass(d,"aligncenter")&&b.setActive("justifycenter",1))}),a.onBeforeSetContent.add(function(a,b){b.content&&(b.content=b.content.replace(/

\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi,"<$1$2>"),b.content=b.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi,""))})}),"undefined"!=typeof jQuery&&b.onKeyUp.add(function(a,b){var c=b.keyCode||b.charCode;c!=k&&((13==c||8==k||46==k)&&jQuery(document).triggerHandler("wpcountwords",[a.getContent({format:"raw"})]),k=c)}),b.onSaveContent.addToTop(function(a,b){b.content=b.content.replace(/

(
|\u00a0|\uFEFF)?<\/p>/g,"

 

")}),tinymce.isIOS5&&b.onKeyDown.add(function(){document.activeElement==document.body&&b.getWin().focus()}),b.onSaveContent.add(function(a,b){a.isHidden()?b.content=b.element.value:a.getParam("wpautop",!0)&&"object"==typeof switchEditors&&(b.content=switchEditors.pre_wpautop(b.content))}),i._handleMoreBreak(b,c),g="alt+shift",b.addShortcut(g+"+c","justifycenter_desc","JustifyCenter"),b.addShortcut(g+"+r","justifyright_desc","JustifyRight"),b.addShortcut(g+"+l","justifyleft_desc","JustifyLeft"),b.addShortcut(g+"+j","justifyfull_desc","JustifyFull"),b.addShortcut(g+"+q","blockquote_desc","mceBlockQuote"),b.addShortcut(g+"+u","bullist_desc","InsertUnorderedList"),b.addShortcut(g+"+o","numlist_desc","InsertOrderedList"),b.addShortcut(g+"+n","spellchecker.desc","mceSpellCheck"),b.addShortcut(g+"+a","link_desc","WP_Link"),b.addShortcut(g+"+s","unlink_desc","unlink"),b.addShortcut(g+"+m","image_desc","WP_Medialib"),b.addShortcut(g+"+z","wordpress.wp_adv_desc","WP_Adv"),b.addShortcut(g+"+t","wordpress.wp_more_desc","WP_More"),b.addShortcut(g+"+d","striketrough_desc","Strikethrough"),b.addShortcut(g+"+h","help_desc","WP_Help"),b.addShortcut(g+"+p","wordpress.wp_page_desc","WP_Page"),b.addShortcut("ctrl+s","save_desc",function(){"function"==typeof autosave&&autosave()}),/\bwpfullscreen\b/.test(b.settings.plugins)?b.addShortcut(g+"+w","wordpress.wp_fullscreen_desc","wpFullScreen"):/\bfullscreen\b/.test(b.settings.plugins)&&b.addShortcut(g+"+g","fullscreen.desc","mceFullScreen"),b.onInit.add(function(a){tinymce.dom.Event.add(a.getWin(),"scroll",function(){a.plugins.wordpress._hideButtons()}),tinymce.dom.Event.add(a.getBody(),"dragstart",function(){a.plugins.wordpress._hideButtons()})}),b.onBeforeExecCommand.add(function(a){a.plugins.wordpress._hideButtons()}),b.onSaveContent.add(function(a){a.plugins.wordpress._hideButtons()}),b.onMouseDown.add(function(a,b){"IMG"!=b.target.nodeName&&a.plugins.wordpress._hideButtons()}),b.onKeyDown.add(function(a,b){(b.which==tinymce.VK.DELETE||b.which==tinymce.VK.BACKSPACE)&&a.plugins.wordpress._hideButtons()}),f=function(a){var c;if("mceModalBlocker"==a.target.id||"ui-widget-overlay"==a.target.className)for(c in b.windowManager.windows)b.windowManager.close(null,c)},tinymce.dom.Event.remove(document.body,"click",f),tinymce.dom.Event.add(document.body,"click",f)},getInfo:function(){return{longname:"WordPress Plugin",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"3.0"}},_setEmbed:function(a){return a.replace(/\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g,function(a,b){return''+b+''})},_getEmbed:function(a){return a.replace(/]+>/g,function(a){if(-1!=a.indexOf('class="wp-oembed')){var b=a.match(/alt="([^\"]+)"/);b[1]&&(a="[embed]"+b[1]+"[/embed]")}return a})},_showButtons:function(a,b){var c,d,e,f,g,h=tinyMCE.activeEditor,i=tinymce.DOM;e=h.dom.getViewPort(h.getWin()),c=i.getPos(h.getContentAreaContainer()),d=h.dom.getPos(a),f=Math.max(d.x-e.x,0)+c.x,g=Math.max(d.y-e.y,0)+c.y,i.setStyles(b,{top:g+5+"px",left:f+5+"px",display:"block"})},_hideButtons:function(){var a=tinymce.DOM;a.hide(a.select("#wp_editbtns, #wp_gallerybtns"))},_resizeIframe:function(b,c,d){var e=b.getContentAreaContainer().firstChild;a.setStyle(e,"height",e.clientHeight+d),b.theme.deltaHeight+=d},_handleMoreBreak:function(a,b){var c,d;c='$1',d='',a.onPostRender.add(function(){a.theme.onResolveName&&a.theme.onResolveName.add(function(b,c){"IMG"==c.node.nodeName&&(a.dom.hasClass(c.node,"mce-wp-more")&&(c.name="wpmore"),a.dom.hasClass(c.node,"mce-wp-nextpage")&&(c.name="wppage"))})}),a.onBeforeSetContent.add(function(a,b){b.content&&(b.content=b.content.replace(//g,c),b.content=b.content.replace(//g,d))}),a.onPostProcess.add(function(a,b){b.get&&(b.content=b.content.replace(/]+>/g,function(a){if(-1!==a.indexOf('class="mce-wp-more')){var b,c=(b=a.match(/alt="(.*?)"/))?b[1]:"";a=""}return-1!==a.indexOf('class="mce-wp-nextpage')&&(a=""),a}))}),a.onNodeChange.add(function(a,b,c){b.setActive("wp_page","IMG"===c.nodeName&&a.dom.hasClass(c,"mce-wp-nextpage")),b.setActive("wp_more","IMG"===c.nodeName&&a.dom.hasClass(c,"mce-wp-more"))})}}),tinymce.PluginManager.add("wordpress",tinymce.plugins.WordPress)}(); \ No newline at end of file