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

1 line
7.3 KiB
JavaScript
Raw Normal View History

window.wp=window.wp||{},jQuery(document).ready(function(a){function b(){var a=m.width();P={windowHeight:m.height(),windowWidth:a,adminBarHeight:a>600?o.outerHeight():0,toolsHeight:s.outerHeight()||0,menuBarHeight:z.outerHeight()||0,visualTopHeight:t.outerHeight()||0,textTopHeight:v.outerHeight()||0,bottomHeight:y.outerHeight()||0,statusBarHeight:A.outerHeight()||0,sideSortablesHeight:B.height()||0}}function c(a){var b,c,d,e,f,g=jQuery.ui.keyCode,h=a.keyCode,i=document.createRange(),j=w[0].selectionStart,k=w[0].selectionEnd,l=x[0].firstChild,m=10;if(!j||!k||j===k){try{i.setStart(l,j),i.setEnd(l,k+1)}catch(n){}b=i.getBoundingClientRect(),b.height&&(c=b.top-m,d=c+b.height+m,e=P.adminBarHeight+P.toolsHeight+P.textTopHeight,f=P.windowHeight-P.bottomHeight,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 d(){if(!k||k.isHidden()){var a,b=w.height();x.width(w.width()-22),x.text(w.val()+"&nbsp;"),a=x.height(),O>a&&(a=O),a!==b&&(w.height(a),e())}}function e(a){if(!E||!E.settings.visible){var c,d,e,f,g,h,i,j,l,o=m.scrollTop(),q="scroll"!==a,F=k&&!k.isHidden(),G=O,M=D.offset().top,Q=1,R=r.width();(q||!P.windowHeight)&&b(),F?(c=t,d=u,i=P.visualTopHeight):(c=v,d=w,i=P.textTopHeight),h=c.parent().offset().top,j=d.offset().top,l=d.outerHeight(),g=F?O+i:O+20,g=l>g+5,g?((!H||q)&&o>=h-P.toolsHeight-P.adminBarHeight&&o<=h-P.toolsHeight-P.adminBarHeight+l-G?(H=!0,s.css({position:"fixed",top:P.adminBarHeight,width:R}),F&&z.length&&z.css({position:"fixed",top:P.adminBarHeight+P.toolsHeight,width:R-2*Q-(F?0:c.outerWidth()-c.width())}),c.css({position:"fixed",top:P.adminBarHeight+P.toolsHeight+P.menuBarHeight,width:R-2*Q-(F?0:c.outerWidth()-c.width())})):(H||q)&&(o<=h-P.toolsHeight-P.adminBarHeight?(H=!1,s.css({position:"absolute",top:0,width:R}),F&&z.length&&z.css({position:"absolute",top:0,width:R-2*Q}),c.css({position:"absolute",top:P.menuBarHeight,width:R-2*Q-(F?0:c.outerWidth()-c.width())})):o>=h-P.toolsHeight-P.adminBarHeight+l-G&&(H=!1,s.css({position:"absolute",top:l-G,width:R}),F&&z.length&&z.css({position:"absolute",top:l-G,width:R-2*Q}),c.css({position:"absolute",top:l-G+P.menuBarHeight,width:R-2*Q-(F?0:c.outerWidth()-c.width())}))),(!I||q)&&o+P.windowHeight<=j+l+P.bottomHeight+P.statusBarHeight+Q?(I=!0,A.css({position:"fixed",bottom:P.bottomHeight,width:R-2*Q}),y.css({position:"fixed",bottom:0,width:R})):(I||q)&&o+P.windowHeight>j+l+P.bottomHeight+P.statusBarHeight-Q&&(I=!1,A.add(y).attr("style",""))):q&&(s.css({position:"absolute",top:0,width:R}),F&&z.length&&z.css({position:"absolute",top:0,width:R-2*Q}),c.css({position:"absolute",top:P.menuBarHeight,width:R-2*Q-(F?0:c.outerWidth()-c.width())}),A.add(y).attr("style","")),C.width()<300&&P.windowWidth>600&&n.height()>B.height()+M+120&&P.windowHeight<l?(P.sideSortablesHeight>P.windowHeight||J||K?M>=o+N?(B.attr("style",""),J=K=!1):o>L?J?(J=!1,e=B.offset().top-P.adminBarHeight,f=p.offset().top,f<e+P.sideSortablesHeight+20&&(e=f-P.sideSortablesHeight-20),B.css({position:"absolute",top:e,bottom:""})):!K&&P.sideSortablesHeight+B.offset().top+20<o+P.windowHeight&&(K=!0,B.css({position:"fixed",top:"auto",bottom:"20px"})):L>o&&(K?(K=!1,e=B.offset().top-20,f=p.offset().top,f<e+P.sideSortablesHeight+20&&(e=f-P.sideSortablesHeight-20),B.css({position:"absolute",top:e,bottom:""})):!J&&B.offset().top>=o+N&&(J=!0,B.css({position:"fixed",top:N,bottom:""}))):(o>=M-N?B.css({position:"fixed",top:N}):B.attr("style",""),J=K=!1),L=o):(B.attr("style",""),J=K=!1),q&&(r.css({paddingTop:P.toolsHeight}),F?u.css({paddingTop:P.visualTopHeight+P.menuBarHeight}):(w.css({marginTop:P.textTopHeight}),x.width(R-20-2*Q)))}}function f(){d(),e()}function g(a){for(var b=1;6>b;b++)setTimeout(a,500*b)}function h(){clearTimeout(l),l=setTimeout(e,100)}function i(){window.pageYOffset&&window.pageYOffset>M&&window.scrollTo(window.pageXOffset,0),q.addClass("wp-editor-expand"),m.on("scroll.editor-expand resize.editor-expand",function(a){e(a.type),h()}),n.on("wp-collapse-menu.editor-expand postboxes-co