WordPress/wp-admin/js/editor-expand.min.js

1 line
5.2 KiB
JavaScript
Raw Normal View History

window.wp=window.wp||{},jQuery(document).ready(function(a){function b(a){var b,c,d,e,f,g=jQuery.ui.keyCode,h=a.keyCode,i=document.createRange(),j=t[0].selectionStart,k=t[0].selectionEnd,l=u[0].firstChild,n=m.height(),p=10;if(!j||!k||j===k){try{i.setStart(l,j),i.setEnd(l,k+1)}catch(q){}b=i.getBoundingClientRect(),b.height&&(c=b.top-p,d=c+b.height+p,e=o.outerHeight()+r.outerHeight()+s.outerHeight(),f=n-v.outerHeight(),e>c&&(h===g.UP||h===g.LEFT||h===g.BACKSPACE)?window.scrollTo(window.pageXOffset,c+window.pageYOffset-e):d>f&&window.scrollTo(window.pageXOffset,d+window.pageYOffset-f))}}function c(){if(!l||l.isHidden()){var a,b=t.height();u.width(t.width()),u.text(t.val()+"&nbsp;"),a=u.height(),300>a&&(a=300),a!==b&&(t.height(a),d())}}function d(a){if(!w||!w.settings.visible){var b,c,d,e,f,g,h,n,p,x=v.outerHeight(),y=m.scrollTop(),B=m.height(),C=m.width(),D=C>600?o.height():0,E="scroll"!==a,F=l&&!l.isHidden(),G=200;F?(b=i,c=j):(b=s,c=t),d=r.outerHeight(),e=b.parent().offset().top,f=b.outerHeight(),g=c.offset().top,h=c.outerHeight(),n=c.outerWidth(),p=F?k.outerHeight():0,(!z||E)&&y>=e-d-D&&e-d-D+h-G>=y?(z=!0,b.css({position:"fixed",top:D+d,width:c.parent().width()-(b.outerWidth()-b.width()),borderTop:"1px solid #e5e5e5"}),r.css({position:"fixed",top:D,width:n+2})):(z||E)&&(e-d-D>=y?(z=!1,b.css({position:"absolute",top:0,borderTop:"none",width:c.parent().width()-(b.outerWidth()-b.width())}),r.css({position:"absolute",top:0,width:q.width()})):y>=e-d-D+h-G&&(z=!1,b.css({position:"absolute",top:h-G}),r.css({position:"absolute",top:h-G+1,width:q.width()}))),(!A||E)&&g+h+x+p+1>=y+B?(A=!0,v.css({position:"fixed",bottom:0,width:n+2,borderTop:"1px solid #dedede"})):(A||E)&&y+B>g+h+x+p-1&&(A=!1,v.css({position:"relative",bottom:"auto",width:"100%",borderTop:"none"})),E&&(q.css({paddingTop:r.outerHeight()}),F?j.css({paddingTop:i.outerHeight()}):(t.css({marginTop:s.outerHeight()}),u.width(t.width())))}}function e(){c(),d()}function f(a){for(var b=1;6>b;b++)setTimeout(a,500*b)}function g(){window.pageYOffset&&window.pageYOffset>130&&window.scrollTo(window.pageXOffset,0),p.addClass("wp-editor-expand"),m.on("scroll.editor-expand resize.editor-expand",function(a){d(a.type)}),n.on("wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand",d),t.on("focus.editor-expand input.editor-expand propertychange.editor-expand",c),t.on("keyup.editor-expand",b),x(),w&&w.pubsub.subscribe("hidden",e),l&&(l.settings.wp_autoresize_on=!0,l.execCommand("wpAutoResizeOn"),l.isHidden()||l.execCommand("wpAutoResize")),(!l||l.isHidden())&&c(),d()}function h(){var f=window.getUserSetting("ed_size");window.pageYOffset&&window.pageYOffset>130&&window.scrollTo(window.pageXOffset,0),p.removeClass("wp-editor-expand"),m.off("scroll.editor-expand resize.editor-expand"),n.off("wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand",d),t.off("focus.editor-expand input.editor-expand propertychange.editor-expand",c),t.off("keyup.editor-expand",b),y(),w&&w.pubsub.unsubscribe("hidden",e),a.each([i,s,r,v,q,j,t],function(a,b){b&&b.attr("style","")}),l&&(l.settings.wp_autoresize_on=!1,l.execCommand("wpAutoResizeOff"),l.isHidden()||(t.hide(),f&&l.theme.resizeTo(null,f))),f&&t.height(f)}var i,j,k,l,m=a(window),n=a(document),o=a("#wpadminbar"),p=a("#postdivrich"),q=a("#wp-content-wrap"),r=a("#wp-content-editor-tools"),s=a("#ed_toolbar"),t=a("#content"),u=a('<div id="content-textarea-clone"></div>'),v=a("#post-status-info"),w=window.wp.editor&&window.wp.editor.fullscreen,x=function(){},y=function(){},z=!1,A=!1;u.insertAfter(t),u.css({"font-family":t.css("font-family"),"font-size":t.css("font-size"),"line-height":t.css("line-height"),padding:t.css("padding"),"padding-top":37,"white-space":"pre-wrap","word-wrap":"break-word"}),n.on("tinymce-editor-init.editor-expand",function(a,b){function e(){var a,c,d=b.selection.getNode();return c=b.plugins.wpview&&(a=b.plugins.wpview.getView(d))?a.getBoundingClientRect():d.getBoundingClientRect(),c.height?c:!1}function g(a){var c,d,f,g,h=tinymce.util.VK,j=a.keyC