mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-02 16:59:35 +01:00
c3b2243a98
Built from https://develop.svn.wordpress.org/trunk@29886 git-svn-id: http://core.svn.wordpress.org/trunk@29642 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
8.1 KiB
JavaScript
1 line
8.1 KiB
JavaScript
window.wp=window.wp||{},jQuery(document).ready(function(a){function b(){var a=m.width();R={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},R.menuBarHeight<3&&(R.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=R.adminBarHeight+R.toolsHeight+R.textTopHeight,f=R.windowHeight-R.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"===Q)){var a,b=w.height();x.width(w.width()-22),x.text(w.val()+" "),a=x.height(),P>a&&(a=P),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=P,Q=D.offset().top,S=1,T=r.width();(F||!R.windowHeight)&&b(),G||"resize"!==a||d(),G?(c=t,e=u,j=R.visualTopHeight):(c=v,e=w,j=R.textTopHeight),i=c.parent().offset().top,l=e.offset().top,o=e.outerHeight(),h=G?P+j:P+20,h=o>h+5,h?((!H||F)&&q>=i-R.toolsHeight-R.adminBarHeight&&q<=i-R.toolsHeight-R.adminBarHeight+o-M?(H=!0,s.css({position:"fixed",top:R.adminBarHeight,width:T}),G&&z.length&&z.css({position:"fixed",top:R.adminBarHeight+R.toolsHeight,width:T-2*S-(G?0:c.outerWidth()-c.width())}),c.css({position:"fixed",top:R.adminBarHeight+R.toolsHeight+R.menuBarHeight,width:T-2*S-(G?0:c.outerWidth()-c.width())})):(H||F)&&(q<=i-R.toolsHeight-R.adminBarHeight?(H=!1,s.css({position:"absolute",top:0,width:T}),G&&z.length&&z.css({position:"absolute",top:0,width:T-2*S}),c.css({position:"absolute",top:R.menuBarHeight,width:T-2*S-(G?0:c.outerWidth()-c.width())})):q>=i-R.toolsHeight-R.adminBarHeight+o-M&&(H=!1,s.css({position:"absolute",top:o-M,width:T}),G&&z.length&&z.css({position:"absolute",top:o-M,width:T-2*S}),c.css({position:"absolute",top:o-M+R.menuBarHeight,width:T-2*S-(G?0:c.outerWidth()-c.width())}))),(!I||F)&&q+R.windowHeight<=l+o+R.bottomHeight+R.statusBarHeight+S?(I=!0,A.css({position:"fixed",bottom:R.bottomHeight,width:T-2*S}),y.css({position:"fixed",bottom:0,width:T})):(I||F)&&q+R.windowHeight>l+o+R.bottomHeight+R.statusBarHeight-S&&(I=!1,A.add(y).attr("style",""))):F&&(s.css({position:"absolute",top:0,width:T}),G&&z.length&&z.css({position:"absolute",top:0,width:T-2*S}),c.css({position:"absolute",top:R.menuBarHeight,width:T-2*S-(G?0:c.outerWidth()-c.width())}),A.add(y).attr("style","")),C.width()<300&&R.windowWidth>600&&n.height()>B.height()+Q+120&&R.windowHeight<o?(R.sideSortablesHeight+N+O>R.windowHeight||J||K?Q>=q+N?(B.attr("style",""),J=K=!1):q>L?J?(J=!1,f=B.offset().top-R.adminBarHeight,g=p.offset().top,g<f+R.sideSortablesHeight+O&&(f=g-R.sideSortablesHeight-12),B.css({position:"absolute",top:f,bottom:""})):!K&&R.sideSortablesHeight+B.offset().top+O<q+R.windowHeight&&(K=!0,B.css({position:"fixed",top:"auto",bottom:O})):L>q&&(K?(K=!1,f=B.offset().top-O,g=p.offset().top,g<f+R.sideSortablesHeight+O&&(f=g-R.sideSortablesHeight-12),B.css({position:"absolute",top:f,bottom:""})):!J&&B.offset().top>=q+N&&(J=!0,B.css({position:"fixed",top:N,bottom:""}))):(q>=Q-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:R.toolsHeight}),G?u.css({paddingTop:R.visualTopHeight+R.menuBarHeight}):(w.css({marginTop:R.textTopHeight}),x.width(T-20-2*S)))}}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-columnchange.editor-expand editor-classchange.editor-expand",e).on("postbox-toggled.editor-expand",function(){!J&&!K&&window.pageYOffset>N&&(K=!0,window.scrollBy(0,-1),e(),window.scrollBy(0,1)),e()}).on("wp-window-resized.editor-expand",function(){k&&!k.isHidden()?k.execCommand("wpAutoResize"):d()}),w.on("focus.editor-expand input.editor-expand propertychange.editor-expand",d),w.on("keyup.editor-expand",c),F(),E&&E.pubsub.subscribe("hidden",f),k&&(k.settings.wp_autoresize_on=!0,k.execCommand("wpAutoResizeOn"),k.isHidden()||k.execCommand("wpAutoResize")),(!k||k.isHidden())&&d(),e()}function j(){var b=window.getUserSetting("ed_size");window.pageYOffset&&window.pageYOffset>M&&window.scrollTo(window.pageXOffset,0),q.removeClass("wp-editor-expand"),m.off(".editor-expand"),n.off(".editor-expand"),w.off(".editor-expand"),G(),E&&E.pubsub.unsubscribe("hidden",f),a.each([t,v,s,z,y,A,r,u,w,B],function(a,b){b&&b.attr("style","")}),H=I=J=K=!1,k&&(k.settings.wp_autoresize_on=!1,k.execCommand("wpAutoResizeOff"),k.isHidden()||(w.hide(),b&&k.theme.resizeTo(null,b))),b&&w.height(b)}var k,l,m=a(window),n=a(document),o=a("#wpadminbar"),p=a("#wpfooter"),q=a("#postdivrich"),r=a("#wp-content-wrap"),s=a("#wp-content-editor-tools"),t=a(),u=a(),v=a("#ed_toolbar"),w=a("#content"),x=a('<div id="content-textarea-clone"></div>'),y=a("#post-status-info"),z=a(),A=a(),B=a("#side-sortables"),C=a("#postbox-container-1"),D=a("#post-body"),E=window.wp.editor&&window.wp.editor.fullscreen,F=function(){},G=function(){},H=!1,I=!1,J=!1,K=!1,L=0,M=130,N=56,O=20,P=300,Q=window.getUserSetting("editor"),R={windowHeight:0,windowWidth:0,adminBarHeight:0,toolsHeight:0,menuBarHeight:0,visualTopHeight:0,textTopHeight:0,bottomHeight:0,statusBarHeight:0,sideSortablesHeight:0};x.insertAfter(w),x.css({"font-family":w.css("font-family"),"font-size":w.css("font-size"),"line-height":w.css("line-height"),"white-space":"pre-wrap","word-wrap":"break-word"}),n.on("tinymce-editor-init.editor-expand",function(b,c){function f(){var a,b,d=c.selection.getNode();return b=c.plugins.wpview&&(a=c.plugins.wpview.getView(d))?a.getBoundingClientRect():d.getBoundingClientRect(),b.height?b:!1}function h(a){var b,d,e,g,h=tinymce.util.VK,i=a.keyCode,j=f(),k=10;j&&(47>=i&&i!==h.SPACEBAR&&i!==h.ENTER&&i!==h.DELETE&&i!==h.BACKSPACE&&i!==h.UP&&i!==h.LEFT&&i!==h.DOWN&&i!==h.UP||i>=91&&93>=i||i>=112&&123>=i||144===i||145===i||(b=j.top+c.iframeElement.getBoundingClientRect().top,d=b+j.height,b-=k,d+=k,e=R.adminBarHeight+R.toolsHeight+R.menuBarHeight+R.visualTopHeight,g=R.windowHeight-R.bottomHeight-R.statusBarHeight,g-e<j.height||(e>b&&(i===h.UP||i===h.LEFT||i===h.BACKSPACE)?window.scrollTo(window.pageXOffset,b+window.pageYOffset-e):d>g&&window.scrollTo(window.pageXOffset,d+window.pageYOffset-g))))}function i(){m.on("scroll.mce-float-panels",l),setTimeout(function(){c.execCommand("wpAutoResize"),e()},300)}function j(){m.off("scroll.mce-float-panels"),setTimeout(function(){var a=r.offset().top;window.pageYOffset>a&&window.scrollTo(window.pageXOffset,a-R.adminBarHeight),d(),e()},100),e()}var l=_.debounce(function(){!a(".mce-floatpanel:hover").length&&tinymce.ui.FloatPanel.hideAll(),a(".mce-tooltip").hide()},1e3,!0);"content"===c.id&&(k=c,c.settings.autoresize_min_height=P,t=r.find(".mce-toolbar-grp"),u=r.find(".mce-edit-area"),A=r.find(".mce-statusbar"),z=r.find(".mce-menubar"),F=function(){c.on("keyup",h),c.on("show",i),c.on("hide",j),c.on("setcontent wp-autoresize wp-toolbar-toggle",e),m.off("scroll.mce-float-panels").on("scroll.mce-float-panels",l)},G=function(){c.off("keyup",h),c.off("show",i),c.off("hide",j),c.off("setcontent wp-autoresize wp-toolbar-toggle",e),m.off("scroll.mce-float-panels")},q.hasClass("wp-editor-expand")&&(F(),g(e)))}),q.hasClass("wp-editor-expand")&&(i(),r.hasClass("html-active")&&g(function(){e(),d()})),a("#adv-settings .editor-expand").show(),a("#editor-expand-toggle").on("change.editor-expand",function(){a(this).prop("checked")?(i(),window.setUserSetting("editor_expand","on")):(j(),window.setUserSetting("editor_expand","off"))}),window.editorExpand={on:i,off:j}}); |