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

1 line
7.5 KiB
JavaScript
Raw Normal View History

window.wp=window.wp||{},jQuery(document).ready(function(a){function b(){var a=m.width();Q={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},Q.menuBarHeight<3&&(Q.menuBarHeight=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=Q.adminBarHeight+Q.toolsHeight+Q.textTopHeight,f=Q.windowHeight-Q.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()||!k&&"tinymce"===P)){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,e,f,g,h,i,j,l,o,q=m.scrollTop(),F="scroll"!==a,G=k&&!k.isHidden(),M=O,P=D.offset().top,R=1,S=r.width();(F||!Q.windowHeight)&&b(),G||"resize"!==a||d(),G?(c=t,e=u,j=Q.visualTopHeight):(c=v,e=w,j=Q.textTopHeight),i=c.parent().offset().top,l=e.offset().top,o=e.outerHeight(),h=G?O+j:O+20,h=o>h+5,h?((!H||F)&&q>=i-Q.toolsHeight-Q.adminBarHeight&&q<=i-Q.toolsHeight-Q.adminBarHeight+o-M?(H=!0,s.css({position:"fixed",top:Q.adminBarHeight,width:S}),G&&z.length&&z.css({position:"fixed",top:Q.adminBarHeight+Q.toolsHeight,width:S-2*R-(G?0:c.outerWidth()-c.width())}),c.css({position:"fixed",top:Q.adminBarHeight+Q.toolsHeight+Q.menuBarHeight,width:S-2*R-(G?0:c.outerWidth()-c.width())})):(H||F)&&(q<=i-Q.toolsHeight-Q.adminBarHeight?(H=!1,s.css({position:"absolute",top:0,width:S}),G&&z.length&&z.css({position:"absolute",top:0,width:S-2*R}),c.css({position:"absolute",top:Q.menuBarHeight,width:S-2*R-(G?0:c.outerWidth()-c.width())})):q>=i-Q.toolsHeight-Q.adminBarHeight+o-M&&(H=!1,s.css({position:"absolute",top:o-M,width:S}),G&&z.length&&z.css({position:"absolute",top:o-M,width:S-2*R}),c.css({position:"absolute",top:o-M+Q.menuBarHeight,width:S-2*R-(G?0:c.outerWidth()-c.width())}))),(!I||F)&&q+Q.windowHeight<=l+o+Q.bottomHeight+Q.statusBarHeight+R?(I=!0,A.css({position:"fixed",bottom:Q.bottomHeight,width:S-2*R}),y.css({position:"fixed",bottom:0,width:S})):(I||F)&&q+Q.windowHeight>l+o+Q.bottomHeight+Q.statusBarHeight-R&&(I=!1,A.add(y).attr("style",""))):F&&(s.css({position:"absolute",top:0,width:S}),G&&z.length&&z.css({position:"absolute",top:0,width:S-2*R}),c.css({position:"absolute",top:Q.menuBarHeight,width:S-2*R-(G?0:c.outerWidth()-c.width())}),A.add(y).attr("style","")),C.width()<300&&Q.windowWidth>600&&n.height()>B.height()+P+120&&Q.windowHeight<o?(Q.sideSortablesHeight>Q.windowHeight||J||K?P>=q+N?(B.attr("style",""),J=K=!1):q>L?J?(J=!1,f=B.offset().top-Q.adminBarHeight,g=p.offset().top,g<f+Q.sideSortablesHeight+20&&(f=g-Q.sideSortablesHeight-20),B.css({position:"absolute",top:f,bottom:""})):!K&&Q.sideSortablesHeight+B.offset().top+20<q+Q.windowHeight&&(K=!0,B.css({position:"fixed",top:"auto",bottom:"20px"})):L>q&&(K?(K=!1,f=B.offset().top-20,g=p.offset().top,g<f+Q.sideSortablesHeight+20&&(f=g-Q.sideSortablesHeight-20),B.css({position:"absolute",top:f,bottom:""})):!J&&B.offset().top>=q+N&&(J=!0,B.css({position:"fixed",top:N,bottom:""}))):(q>=P-N?B.css({position:"fixed",top:N}):B.attr("style",""),J=K=!1),L=q):(B.attr("style",""),J=K=!1),F&&(r.css({paddingTop:Q.toolsHeight}),G?u.css({paddingTop:Q.visualTopHeight+Q.menuBarHeight}):(w.css({marginTop:Q.textTopHeight}),x.width(S-20-2*R)))}}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-exp