mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-26 11:08:06 +01:00
9c09d0ea2c
Built from https://develop.svn.wordpress.org/trunk@31727 git-svn-id: http://core.svn.wordpress.org/trunk@31708 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
tinymce.ui.FloatPanel.zIndex=100100,tinymce.PluginManager.add("wordpress",function(a){function b(b){var c,e,f,h=0;e="hide"===b,a.theme.panel&&(f=a.theme.panel.find(".toolbar:not(.menubar)")),!f||f.length<2||"hide"===b&&!f[1].visible()||(!b&&f[1].visible()&&(b="hide"),tinymce.each(f,function(a,c){c>0&&("hide"===b?(a.hide(),h+=30):(a.show(),h-=30))}),h&&!e&&(tinymce.Env.iOS||(c=a.getContentAreaContainer().firstChild,g.setStyle(c,"height",c.clientHeight+h)),"hide"===b?(setUserSetting("hidetb","0"),d&&d.active(!1)):(setUserSetting("hidetb","1"),d&&d.active(!0))),a.fire("wp-toolbar-toggle"))}function c(){}var d,e,f,g=tinymce.DOM,h=0;return"undefined"!=typeof window.jQuery&&window.jQuery(document).triggerHandler("tinymce-editor-setup",[a]),a.addButton("wp_adv",{tooltip:"Toolbar Toggle",cmd:"WP_Adv",onPostRender:function(){d=this,d.active("1"===getUserSetting("hidetb")?!0:!1)}}),a.on("PostRender",function(){a.getParam("wordpress_adv_hidden",!0)&&"0"===getUserSetting("hidetb","0")&&b("hide")}),a.addCommand("WP_Adv",function(){b()}),a.on("focus",function(){window.wpActiveEditor=a.id}),a.on("BeforeSetContent",function(b){var c;b.content&&(-1!==b.content.indexOf("<!--more")&&(c=a.editorManager.i18n.translate("Read more..."),b.content=b.content.replace(/<!--more(.*?)-->/g,function(a,b){return'<img src="'+tinymce.Env.transparentSrc+'" data-wp-more="more" data-wp-more-text="'+b+'" class="wp-more-tag mce-wp-more" title="'+c+'" data-mce-resize="false" data-mce-placeholder="1" />'})),-1!==b.content.indexOf("<!--nextpage-->")&&(c=a.editorManager.i18n.translate("Page break"),b.content=b.content.replace(/<!--nextpage-->/g,'<img src="'+tinymce.Env.transparentSrc+'" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" title="'+c+'" data-mce-resize="false" data-mce-placeholder="1" />')))}),a.on("PostProcess",function(a){a.get&&(a.content=a.content.replace(/<img[^>]+>/g,function(a){var b,c="";return-1!==a.indexOf('data-wp-more="more"')?((b=a.match(/data-wp-more-text="([^"]+)"/))&&(c=b[1]),a="<!--more"+c+"-->"):-1!==a.indexOf('data-wp-more="nextpage"')&&(a="<!--nextpage-->"),a}))}),a.on("ResolveName",function(b){var c;"IMG"===b.target.nodeName&&(c=a.dom.getAttrib(b.target,"data-wp-more"))&&(b.name=c)}),a.addCommand("WP_More",function(b){var c,d,e,f="wp-more-tag",g=a.dom,h=a.selection.getNode();return b=b||"more",f+=" mce-wp-"+b,e="more"===b?"Read more...":"Next page",e=a.editorManager.i18n.translate(e),d='<img src="'+tinymce.Env.transparentSrc+'" title="'+e+'" class="'+f+'" data-wp-more="'+b+'" data-mce-resize="false" data-mce-placeholder="1" />',"BODY"===h.nodeName||"P"===h.nodeName&&"BODY"===h.parentNode.nodeName?void a.insertContent(d):(c=g.getParent(h,function(a){return a.parentNode&&"BODY"===a.parentNode.nodeName?!0:!1},a.getBody()),void(c&&("P"===c.nodeName?c.appendChild(g.create("p",null,d).firstChild):g.insertAfter(g.create("p",null,d),c),a.nodeChanged())))}),a.addCommand("WP_Code",function(){a.formatter.toggle("code")}),a.addCommand("WP_Page",function(){a.execCommand("WP_More","nextpage")}),a.addCommand("WP_Help",function(){a.windowManager.open({url:tinymce.baseURL+"/wp-mce-help.php",title:"Keyboard Shortcuts",width:450,height:420,classes:"wp-help",buttons:{text:"Close",onclick:"close"}})}),a.addCommand("WP_Medialib",function(){"undefined"!=typeof wp&&wp.media&&wp.media.editor&&wp.media.editor.open(a.id)}),a.addButton("wp_more",{tooltip:"Insert Read More tag",onclick:function(){a.execCommand("WP_More","more")}}),a.addButton("wp_page",{tooltip:"Page break",onclick:function(){a.execCommand("WP_More","nextpage")}}),a.addButton("wp_help",{tooltip:"Keyboard Shortcuts",cmd:"WP_Help"}),a.addButton("wp_code",{tooltip:"Code",cmd:"WP_Code",stateSelector:"code"}),"undefined"!=typeof wp&&wp.media&&wp.media.editor&&a.addMenuItem("add_media",{text:"Add Media",icon:"wp-media-library",context:"insert",cmd:"WP_Medialib"}),a.addMenuItem("wp_more",{text:"Insert Read More tag",icon:"wp_more",context:"insert",onclick:function(){a.execCommand("WP_More","more")}}),a.addMenuItem("wp_page",{text:"Page break",icon:"wp_page",context:"insert",onclick:function(){a.execCommand("WP_More","nextpage")}}),a.on("BeforeExecCommand",function(b){!tinymce.Env.webkit||"InsertUnorderedList"!==b.command&&"InsertOrderedList"!==b.command||(f||(f=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(f))}),a.on("ExecCommand",function(b){tinymce.Env.webkit&&f&&("InsertUnorderedList"===b.command||"InsertOrderedList"===b.command)&&a.dom.remove(f)}),a.on("init",function(){var b=tinymce.Env,c=["mceContentBody"],d=a.getDoc(),e=a.dom;tinymce.Env.iOS&&e.addClass(d.documentElement,"ios"),"rtl"===a.getParam("directionality")&&(c.push("rtl"),e.setAttrib(d.documentElement,"dir","rtl")),b.ie?9===parseInt(b.ie,10)?c.push("ie9"):8===parseInt(b.ie,10)?c.push("ie8"):b.ie<8&&c.push("ie7"):b.webkit&&c.push("webkit"),c.push("wp-editor"),tinymce.each(c,function(a){a&&e.addClass(d.body,a)}),a.on("BeforeSetContent",function(a){a.content&&(a.content=a.content.replace(/<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi,"<$1$2>"),a.content=a.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi,"</$1>"))}),"undefined"!=typeof window.jQuery&&window.jQuery(document).triggerHandler("tinymce-editor-init",[a]),window.tinyMCEPreInit&&window.tinyMCEPreInit.dragDropUpload&&e.bind(d,"dragstart dragend dragover drop",function(a){"undefined"!=typeof window.jQuery&&window.jQuery(document).trigger(new window.jQuery.Event(a))}),a.getParam("wp_paste_filters",!0)&&(tinymce.Env.webkit||a.on("PastePreProcess",function(a){a.content=a.content.replace(/(<[^>]+) style="[^"]*"([^>]*>)/gi,"$1$2"),a.content=a.content.replace(/(<[^>]+) data-mce-style=([^>]+>)/gi,"$1 style=$2")}),a.on("PastePostProcess",function(a){tinymce.each(e.select("p",a.node),function(a){e.isEmpty(a)&&e.remove(a)})}))}),"undefined"!=typeof window.jQuery&&a.on("keyup",function(b){var c=b.keyCode||b.charCode;c!==h&&((13===c||8===h||46===h)&&window.jQuery(document).triggerHandler("wpcountwords",[a.getContent({format:"raw"})]),h=c)}),a.on("SaveContent",function(b){return!a.inline&&a.isHidden()?void(b.content=b.element.value):(b.content=b.content.replace(/<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g,"<p> </p>"),void(a.getParam("wpautop",!0)&&"undefined"!=typeof window.switchEditors&&(b.content=window.switchEditors.pre_wpautop(b.content))))}),a.on("BeforeSetContent",function(a){a.content&&(a.content=a.content.replace(/<p>(?: |\u00a0|\uFEFF| )+<\/p>/gi,"<p></p>"))}),a.on("preInit",function(){a.schema.addValidElements("@[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],i,b"),tinymce.Env.iOS&&(a.settings.height=300)}),e="alt+shift",a.addShortcut(e+"+c","","JustifyCenter"),a.addShortcut(e+"+r","","JustifyRight"),a.addShortcut(e+"+l","","JustifyLeft"),a.addShortcut(e+"+j","","JustifyFull"),a.addShortcut(e+"+q","","mceBlockQuote"),a.addShortcut(e+"+u","","InsertUnorderedList"),a.addShortcut(e+"+o","","InsertOrderedList"),a.addShortcut(e+"+n","","mceSpellCheck"),a.addShortcut(e+"+s","","unlink"),a.addShortcut(e+"+m","","WP_Medialib"),a.addShortcut(e+"+z","","WP_Adv"),a.addShortcut(e+"+t","","WP_More"),a.addShortcut(e+"+d","","Strikethrough"),a.addShortcut(e+"+h","","WP_Help"),a.addShortcut(e+"+p","","WP_Page"),a.addShortcut(e+"+x","","WP_Code"),a.addShortcut("ctrl+s","",function(){"undefined"!=typeof wp&&wp.autosave&&wp.autosave.server.triggerSave()}),function(){function b(b){function i(){k.hide()}function j(){var b,c,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y=this.getEl(),z=5,A=8,B=0;if(d)return h=window.pageYOffset||document.documentElement.scrollTop,i=tinymce.$("#wpadminbar")[0],j=tinymce.$(".mce-toolbar-grp",a.getContainer())[0],k=d.getBoundingClientRect(),l=(k.left+k.right)/2,m=(k.top+k.bottom)/2,n=k.top,o=v-k.bottom,p=window.innerWidth,q=y.offsetWidth,r=q/2,s=document.getElementById(a.id+"_ifr"),t=e.getPos(s),u=s.offsetWidth,v=s.offsetHeight,w=y.offsetHeight,x=w+A+z,n>=x?(g=" mce-arrow-down",b=k.top+t.y-w-A):o>=x?(g=" mce-arrow-up",b=k.bottom+t.y):(b=z,g=m>=x?" mce-arrow-down":" mce-arrow-up"),f=j?e.getPos(j).y+j.clientHeight:t.y,h&&(i&&0===i.getBoundingClientRect().top&&(B=i.clientHeight),h+B>f&&(f=h+B)),b&&f&&f+z>b&&(b=f+z,g=""),c=l-r,c+=t.x,k.left<0||k.right>u?c=t.x+(u-q)/2:q>=p?(g+=" mce-arrow-full",c=0):0>c&&k.left+q>p||c+q>p&&k.right-q<0?c=(p-q)/2:c<t.x?(g+=" mce-arrow-left",c=k.left+t.x):c+q>u+t.x&&(g+=" mce-arrow-right",c=k.right-q+t.x),y.className=y.className.replace(/ ?mce-arrow-[\w]+/g,""),y.className+=g,e.setStyles(y,{left:c,top:b}),this}var k,l,m=[];return f(b,function(b){function c(){var c=a.selection;"bullist"===d&&c.selectorChanged("ul > li",function(a,c){for(var d,e=c.parents.length;e--&&(d=c.parents[e].nodeName,"OL"!==d&&"UL"!=d););b.active(a&&"UL"===d)}),"numlist"===d&&c.selectorChanged("ol > li",function(a,c){for(var d,e=c.parents.length;e--&&(d=c.parents[e].nodeName,"OL"!==d&&"UL"!==d););b.active(a&&"OL"===d)}),b.settings.stateSelector&&c.selectorChanged(b.settings.stateSelector,function(a){b.active(a)},!0),b.settings.disabledStateSelector&&c.selectorChanged(b.settings.disabledStateSelector,function(a){b.disabled(a)})}var d;"|"===b?l=null:g.has(b)?(b={type:b},h.toolbar_items_size&&(b.size=h.toolbar_items_size),m.push(b),l=null):(l||(l={type:"buttongroup",items:[]},m.push(l)),a.buttons[b]&&(d=b,b=a.buttons[d],"function"==typeof b&&(b=b()),b.type=b.type||"button",h.toolbar_items_size&&(b.size=h.toolbar_items_size),b=g.create(b),l.items.push(b),a.initialized?c():a.on("init",c)))}),k=g.create({type:"panel",layout:"stack",classes:"toolbar-grp inline-toolbar-grp",ariaRoot:!0,ariaRemember:!0,items:[{type:"toolbar",layout:"flow",items:m}]}),k.on("show",function(){c=this,this.reposition()}),k.on("hide",function(){c=!1}),k.on("keydown",function(b){27===b.keyCode&&(this.hide(),a.focus())}),k.on("remove",function(){e.unbind(window,"resize scroll",i),a.dom.unbind(a.getWin(),"resize scroll",i),a.off("blur hide",i)}),a.once("init",function(){e.bind(window,"resize scroll",i),a.dom.bind(a.getWin(),"resize scroll",i),a.on("blur hide",i)}),k.reposition=j,k.hide().renderTo(document.body),k}var c,d,e=tinymce.DOM,f=tinymce.each,g=tinymce.ui.Factory,h=a.settings;a.shortcuts.add("alt+119","",function(){var a;c&&(a=c.find("toolbar")[0],a&&a.focus(!0))}),a.on("nodechange",function(b){var e=a.selection.isCollapsed(),f={element:b.element,parents:b.parents,collapsed:e};a.fire("wptoolbar",f),d=f.selection||f.element,c&&c.hide(),f.toolbar&&f.toolbar.show()}),a.wp=a.wp||{},a.wp._createToolbar=b}(),{_showButtons:c,_hideButtons:c,_setEmbed:c,_getEmbed:c}}); |