diff --git a/wp-admin/js/editor-expand.js b/wp-admin/js/editor-expand.js index 700954df29..b2caebfea5 100644 --- a/wp-admin/js/editor-expand.js +++ b/wp-admin/js/editor-expand.js @@ -226,13 +226,13 @@ jQuery( document ).ready( function($) { adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0, resize = type !== 'scroll', visual = ( mceEditor && ! mceEditor.isHidden() ), - buffer = autoresizeMinHeight + adminBarHeight, + buffer = autoresizeMinHeight, postBodyTop = $postBody.offset().top, borderWidth = 1, contentWrapWidth = $contentWrap.width(), sideSortablesHeight = $sideSortables.height(), - $top, $editor, sidebarTop, footerTop, - toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight; + $top, $editor, sidebarTop, footerTop, canPin, + toolsHeight, topPos, topHeight, editorPos, editorHeight, statusBarHeight; if ( visual ) { $top = $visualTop; @@ -247,37 +247,14 @@ jQuery( document ).ready( function($) { topHeight = $top.outerHeight(); editorPos = $editor.offset().top; editorHeight = $editor.outerHeight(); - editorWidth = $editor.outerWidth(); statusBarHeight = visual ? $statusBar.outerHeight() : 0; + // Should we pin? + canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding + canPin = editorHeight > ( canPin + 5 ); - // Maybe pin the top. - if ( ( ! fixedTop || resize ) && - // Handle scrolling down. - ( windowPos >= ( topPos - toolsHeight - adminBarHeight ) && - // Handle scrolling up. - windowPos <= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) ) { - - fixedTop = true; - - $top.css( { - position: 'fixed', - top: adminBarHeight + toolsHeight, - width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ), - borderTop: '1px solid #e5e5e5' - } ); - - $tools.css( { - position: 'fixed', - top: adminBarHeight, - width: contentWrapWidth - } ); - // Maybe unpin the top. - } else if ( fixedTop || resize ) { - // Handle scrolling up. - if ( windowPos <= ( topPos - toolsHeight - adminBarHeight ) ) { - fixedTop = false; - + if ( ! canPin ) { + if ( resize ) { $top.css( { position: 'absolute', top: 0, @@ -290,53 +267,102 @@ jQuery( document ).ready( function($) { top: 0, width: contentWrapWidth } ); - // Handle scrolling down. - } else if ( windowPos >= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) { - fixedTop = false; + + $bottom.css( { + position: 'relative', + bottom: 'auto', + width: '100%', + borderTop: 'none' + } ); + } + } else { + // Maybe pin the top. + if ( ( ! fixedTop || resize ) && + // Handle scrolling down. + ( windowPos >= ( topPos - toolsHeight - adminBarHeight ) && + // Handle scrolling up. + windowPos <= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) ) { + + fixedTop = true; $top.css( { - position: 'absolute', - top: editorHeight - buffer, - width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) + position: 'fixed', + top: adminBarHeight + toolsHeight, + width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ), + borderTop: '1px solid #e5e5e5' } ); $tools.css( { - position: 'absolute', - top: editorHeight - buffer + borderWidth, // border + position: 'fixed', + top: adminBarHeight, width: contentWrapWidth } ); + // Maybe unpin the top. + } else if ( fixedTop || resize ) { + // Handle scrolling up. + if ( windowPos <= ( topPos - toolsHeight - adminBarHeight ) ) { + fixedTop = false; + + $top.css( { + position: 'absolute', + top: 0, + borderTop: 'none', + width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) + } ); + + $tools.css( { + position: 'absolute', + top: 0, + width: contentWrapWidth + } ); + // Handle scrolling down. + } else if ( windowPos >= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) { + fixedTop = false; + + $top.css( { + position: 'absolute', + top: editorHeight - buffer, + width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) + } ); + + $tools.css( { + position: 'absolute', + top: editorHeight - buffer + borderWidth, // border + width: contentWrapWidth + } ); + } } - } - // Maybe adjust the bottom bar. - if ( ( ! fixedBottom || resize ) && - // +[n] for the border around the .wp-editor-container. - ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { + // Maybe adjust the bottom bar. + if ( ( ! fixedBottom || resize ) && + // +[n] for the border around the .wp-editor-container. + ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { - fixedBottom = true; + fixedBottom = true; - $bottom.css( { - position: 'fixed', - bottom: 0, - width: editorWidth + ( borderWidth * 2 ), - borderTop: '1px solid #dedede' - } ); - } else if ( ( fixedBottom || resize ) && - ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { - fixedBottom = false; + $bottom.css( { + position: 'fixed', + bottom: 0, + width: contentWrapWidth, + borderTop: '1px solid #dedede' + } ); + } else if ( ( fixedBottom || resize ) && + ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { + fixedBottom = false; - $bottom.css( { - position: 'relative', - bottom: 'auto', - width: '100%', - borderTop: 'none' - } ); + $bottom.css( { + position: 'relative', + bottom: 'auto', + width: '100%', + borderTop: 'none' + } ); + } } // Sidebar pinning if ( $postboxContainer.width() < 300 && windowWidth > 600 && // sidebar position is changed with @media from CSS, make sure it is on the side $document.height() > ( $sideSortables.height() + postBodyTop + 120 ) && // the sidebar is not the tallest element - windowHeight < editorHeight * 0.7 ) { // the editor is taller than the viewport + windowHeight < editorHeight ) { // the editor is taller than the viewport if ( sideSortablesHeight > windowHeight || fixedSideTop || fixedSideBottom ) { // Reset when scrolling to the top @@ -454,7 +480,7 @@ jQuery( document ).ready( function($) { function afterScroll() { clearTimeout( scrollTimer ); - scrollTimer = setTimeout( adjust, 200 ); + scrollTimer = setTimeout( adjust, 100 ); } function on() { @@ -473,7 +499,17 @@ jQuery( document ).ready( function($) { } ); // Adjust when collapsing the menu, changing the columns, changing the body class. - $document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ); + $document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ) + .on( 'postbox-toggled.editor-expand', function() { + if ( ! fixedSideTop && ! fixedSideBottom && window.pageYOffset > 20 ) { + fixedSideBottom = true; + window.scrollBy( 0, -1 ); + adjust(); + window.scrollBy( 0, 1 ); + } + + adjust(); + }); $textEditor.on( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize ); $textEditor.on( 'keyup.editor-expand', textEditorKeyup ); @@ -509,14 +545,9 @@ jQuery( document ).ready( function($) { $wrap.removeClass( 'wp-editor-expand' ); - // Adjust when the window is scrolled or resized. - $window.off( 'scroll.editor-expand resize.editor-expand' ); - - // Adjust when collapsing the menu, changing the columns, changing the body class. - $document.off( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ); - - $textEditor.off( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize ); - $textEditor.off( 'keyup.editor-expand', textEditorKeyup ); + $window.off( '.editor-expand' ); + $document.off( '.editor-expand' ); + $textEditor.off( '.editor-expand' ); mceUnbind(); // Adjust when entering/exiting fullscreen mode. diff --git a/wp-admin/js/editor-expand.min.js b/wp-admin/js/editor-expand.min.js index 634a4f69f7..b116a9fdce 100644 --- a/wp-admin/js/editor-expand.min.js +++ b/wp-admin/js/editor-expand.min.js @@ -1 +1 @@ -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=w[0].selectionStart,k=w[0].selectionEnd,l=x[0].firstChild,m=o.height(),n=10;if(!j||!k||j===k){try{i.setStart(l,j),i.setEnd(l,k+1)}catch(p){}b=i.getBoundingClientRect(),b.height&&(c=b.top-n,d=c+b.height+n,e=q.outerHeight()+u.outerHeight()+v.outerHeight(),f=m-y.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(!m||m.isHidden()){var a,b=w.height();x.width(w.width()),x.text(w.val()+" "),a=x.height(),M>a&&(a=M),a!==b&&(w.height(a),d())}}function d(a){if(!C||!C.settings.visible){var b,c,d,e,f,g,h,i,n,s,D,E=y.outerHeight(),K=o.scrollTop(),N=o.height(),O=o.width(),P=O>600?q.height():0,Q="scroll"!==a,R=m&&!m.isHidden(),S=M+P,T=B.offset().top,U=1,V=t.width(),W=z.height();R?(b=j,c=k):(b=v,c=w),f=u.outerHeight(),g=b.parent().offset().top,h=b.outerHeight(),i=c.offset().top,n=c.outerHeight(),s=c.outerWidth(),D=R?l.outerHeight():0,(!F||Q)&&K>=g-f-P&&g-f-P+n-S>=K?(F=!0,b.css({position:"fixed",top:P+f,width:V-2*U-(R?0:b.outerWidth()-b.width()),borderTop:"1px solid #e5e5e5"}),u.css({position:"fixed",top:P,width:V})):(F||Q)&&(g-f-P>=K?(F=!1,b.css({position:"absolute",top:0,borderTop:"none",width:V-2*U-(R?0:b.outerWidth()-b.width())}),u.css({position:"absolute",top:0,width:V})):K>=g-f-P+n-S&&(F=!1,b.css({position:"absolute",top:n-S,width:V-2*U-(R?0:b.outerWidth()-b.width())}),u.css({position:"absolute",top:n-S+U,width:V}))),(!G||Q)&&i+n+E+D+U>=K+N?(G=!0,y.css({position:"fixed",bottom:0,width:s+2*U,borderTop:"1px solid #dedede"})):(G||Q)&&K+N>i+n+E+D-U&&(G=!1,y.css({position:"relative",bottom:"auto",width:"100%",borderTop:"none"})),A.width()<300&&O>600&&p.height()>z.height()+T+120&&.7*n>N?(W>N||H||I?T>=K+L?(z.attr("style",""),H=I=!1):K>J?H?(H=!1,d=z.offset().top-P,e=r.offset().top,d+W+20>e&&(d=e-W-20),z.css({position:"absolute",top:d,bottom:""})):!I&&W+z.offset().top+20K&&(I?(I=!1,d=z.offset().top-20,e=r.offset().top,d+W+20>e&&(d=e-W-20),z.css({position:"absolute",top:d,bottom:""})):!H&&z.offset().top>=K+L&&(H=!0,z.css({position:"fixed",top:L,bottom:""}))):(K>=T-L?z.css({position:"fixed",top:L}):z.attr("style",""),H=I=!1),J=K):(z.attr("style",""),H=I=!1),Q&&(t.css({paddingTop:u.outerHeight()}),R?k.css({paddingTop:j.outerHeight()}):w.css({marginTop:v.outerHeight()}),x.width(V-20-2*U))}}function e(){c(),d()}function f(a){for(var b=1;6>b;b++)setTimeout(a,500*b)}function g(){clearTimeout(n),n=setTimeout(d,200)}function h(){window.pageYOffset&&window.pageYOffset>K&&window.scrollTo(window.pageXOffset,0),s.addClass("wp-editor-expand"),o.on("scroll.editor-expand resize.editor-expand",function(a){d(a.type),g()}),p.on("wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand",d),w.on("focus.editor-expand input.editor-expand propertychange.editor-expand",c),w.on("keyup.editor-expand",b),D(),C&&C.pubsub.subscribe("hidden",e),m&&(m.settings.wp_autoresize_on=!0,m.execCommand("wpAutoResizeOn"),m.isHidden()||m.execCommand("wpAutoResize")),(!m||m.isHidden())&&c(),d()}function i(){var f=window.getUserSetting("ed_size");window.pageYOffset&&window.pageYOffset>K&&window.scrollTo(window.pageXOffset,0),s.removeClass("wp-editor-expand"),o.off("scroll.editor-expand resize.editor-expand"),p.off("wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand",d),w.off("focus.editor-expand input.editor-expand propertychange.editor-expand",c),w.off("keyup.editor-expand",b),E(),C&&C.pubsub.unsubscribe("hidden",e),a.each([j,v,u,y,t,k,w,z],function(a,b){b&&b.attr("style","")}),F=G=H=I=!1,m&&(m.settings.wp_autoresize_on=!1,m.execCommand("wpAutoResizeOff"),m.isHidden()||(w.hide(),f&&m.theme.resizeTo(null,f))),f&&w.height(f)}var j,k,l,m,n,o=a(window),p=a(document),q=a("#wpadminbar"),r=a("#wpfooter"),s=a("#postdivrich"),t=a("#wp-content-wrap"),u=a("#wp-content-editor-tools"),v=a("#ed_toolbar"),w=a("#content"),x=a('
'),y=a("#post-status-info"),z=a("#side-sortables"),A=a("#postbox-container-1"),B=a("#post-body"),C=window.wp.editor&&window.wp.editor.fullscreen,D=function(){},E=function(){},F=!1,G=!1,H=!1,I=!1,J=0,K=130,L=56,M=300;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"}),p.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,i=a.keyCode,k=e(),l=o.height(),m=10;k&&(c=k.top+b.getContentAreaContainer().firstChild.getBoundingClientRect().top,d=c+k.height,c-=m,d+=m,f=q.outerHeight()+u.outerHeight()+j.outerHeight(),g=l-y.outerHeight(),g-fc&&(i===h.UP||i===h.LEFT||i===h.BACKSPACE)?window.scrollTo(window.pageXOffset,c+window.pageYOffset-f):d>g&&window.scrollTo(window.pageXOffset,d+window.pageYOffset-g)))}function h(){setTimeout(function(){b.execCommand("wpAutoResize"),d()},300)}function i(){c(),d()}"content"===b.id&&(m=b,b.settings.autoresize_min_height=M,j=t.find(".mce-toolbar-grp"),k=t.find(".mce-edit-area"),l=t.find(".mce-statusbar").filter(":visible"),D=function(){b.on("keyup",g),b.on("show",h),b.on("hide",i),b.on("setcontent wp-autoresize wp-toolbar-toggle",d)},E=function(){b.off("keyup",g),b.off("show",h),b.off("hide",i),b.off("setcontent wp-autoresize wp-toolbar-toggle",d)},s.hasClass("wp-editor-expand")&&(D(),f(d)))}),s.hasClass("wp-editor-expand")&&(h(),t.hasClass("html-active")&&f(function(){d(),c()})),a("#adv-settings .editor-expand").show(),a("#editor-expand-toggle").on("change.editor-expand",function(){a(this).prop("checked")?(h(),window.setUserSetting("editor_expand","on")):(i(),window.setUserSetting("editor_expand","off"))}),window.editorExpand={on:h,off:i}}); \ No newline at end of file +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=w[0].selectionStart,k=w[0].selectionEnd,l=x[0].firstChild,m=o.height(),n=10;if(!j||!k||j===k){try{i.setStart(l,j),i.setEnd(l,k+1)}catch(p){}b=i.getBoundingClientRect(),b.height&&(c=b.top-n,d=c+b.height+n,e=q.outerHeight()+u.outerHeight()+v.outerHeight(),f=m-y.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(!m||m.isHidden()){var a,b=w.height();x.width(w.width()),x.text(w.val()+" "),a=x.height(),M>a&&(a=M),a!==b&&(w.height(a),d())}}function d(a){if(!C||!C.settings.visible){var b,c,d,e,f,g,h,i,n,s,D,E=y.outerHeight(),K=o.scrollTop(),N=o.height(),O=o.width(),P=O>600?q.height():0,Q="scroll"!==a,R=m&&!m.isHidden(),S=M,T=B.offset().top,U=1,V=t.width(),W=z.height();R?(b=j,c=k):(b=v,c=w),g=u.outerHeight(),h=b.parent().offset().top,i=b.outerHeight(),n=c.offset().top,s=c.outerHeight(),D=R?l.outerHeight():0,f=R?M+i:M+20,f=s>f+5,f?((!F||Q)&&K>=h-g-P&&h-g-P+s-S>=K?(F=!0,b.css({position:"fixed",top:P+g,width:V-2*U-(R?0:b.outerWidth()-b.width()),borderTop:"1px solid #e5e5e5"}),u.css({position:"fixed",top:P,width:V})):(F||Q)&&(h-g-P>=K?(F=!1,b.css({position:"absolute",top:0,borderTop:"none",width:V-2*U-(R?0:b.outerWidth()-b.width())}),u.css({position:"absolute",top:0,width:V})):K>=h-g-P+s-S&&(F=!1,b.css({position:"absolute",top:s-S,width:V-2*U-(R?0:b.outerWidth()-b.width())}),u.css({position:"absolute",top:s-S+U,width:V}))),(!G||Q)&&n+s+E+D+U>=K+N?(G=!0,y.css({position:"fixed",bottom:0,width:V,borderTop:"1px solid #dedede"})):(G||Q)&&K+N>n+s+E+D-U&&(G=!1,y.css({position:"relative",bottom:"auto",width:"100%",borderTop:"none"}))):Q&&(b.css({position:"absolute",top:0,borderTop:"none",width:V-2*U-(R?0:b.outerWidth()-b.width())}),u.css({position:"absolute",top:0,width:V}),y.css({position:"relative",bottom:"auto",width:"100%",borderTop:"none"})),A.width()<300&&O>600&&p.height()>z.height()+T+120&&s>N?(W>N||H||I?T>=K+L?(z.attr("style",""),H=I=!1):K>J?H?(H=!1,d=z.offset().top-P,e=r.offset().top,d+W+20>e&&(d=e-W-20),z.css({position:"absolute",top:d,bottom:""})):!I&&W+z.offset().top+20K&&(I?(I=!1,d=z.offset().top-20,e=r.offset().top,d+W+20>e&&(d=e-W-20),z.css({position:"absolute",top:d,bottom:""})):!H&&z.offset().top>=K+L&&(H=!0,z.css({position:"fixed",top:L,bottom:""}))):(K>=T-L?z.css({position:"fixed",top:L}):z.attr("style",""),H=I=!1),J=K):(z.attr("style",""),H=I=!1),Q&&(t.css({paddingTop:u.outerHeight()}),R?k.css({paddingTop:j.outerHeight()}):w.css({marginTop:v.outerHeight()}),x.width(V-20-2*U))}}function e(){c(),d()}function f(a){for(var b=1;6>b;b++)setTimeout(a,500*b)}function g(){clearTimeout(n),n=setTimeout(d,100)}function h(){window.pageYOffset&&window.pageYOffset>K&&window.scrollTo(window.pageXOffset,0),s.addClass("wp-editor-expand"),o.on("scroll.editor-expand resize.editor-expand",function(a){d(a.type),g()}),p.on("wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand",d).on("postbox-toggled.editor-expand",function(){!H&&!I&&window.pageYOffset>20&&(I=!0,window.scrollBy(0,-1),d(),window.scrollBy(0,1)),d()}),w.on("focus.editor-expand input.editor-expand propertychange.editor-expand",c),w.on("keyup.editor-expand",b),D(),C&&C.pubsub.subscribe("hidden",e),m&&(m.settings.wp_autoresize_on=!0,m.execCommand("wpAutoResizeOn"),m.isHidden()||m.execCommand("wpAutoResize")),(!m||m.isHidden())&&c(),d()}function i(){var b=window.getUserSetting("ed_size");window.pageYOffset&&window.pageYOffset>K&&window.scrollTo(window.pageXOffset,0),s.removeClass("wp-editor-expand"),o.off(".editor-expand"),p.off(".editor-expand"),w.off(".editor-expand"),E(),C&&C.pubsub.unsubscribe("hidden",e),a.each([j,v,u,y,t,k,w,z],function(a,b){b&&b.attr("style","")}),F=G=H=I=!1,m&&(m.settings.wp_autoresize_on=!1,m.execCommand("wpAutoResizeOff"),m.isHidden()||(w.hide(),b&&m.theme.resizeTo(null,b))),b&&w.height(b)}var j,k,l,m,n,o=a(window),p=a(document),q=a("#wpadminbar"),r=a("#wpfooter"),s=a("#postdivrich"),t=a("#wp-content-wrap"),u=a("#wp-content-editor-tools"),v=a("#ed_toolbar"),w=a("#content"),x=a('
'),y=a("#post-status-info"),z=a("#side-sortables"),A=a("#postbox-container-1"),B=a("#post-body"),C=window.wp.editor&&window.wp.editor.fullscreen,D=function(){},E=function(){},F=!1,G=!1,H=!1,I=!1,J=0,K=130,L=56,M=300;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"}),p.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,i=a.keyCode,k=e(),l=o.height(),m=10;k&&(c=k.top+b.getContentAreaContainer().firstChild.getBoundingClientRect().top,d=c+k.height,c-=m,d+=m,f=q.outerHeight()+u.outerHeight()+j.outerHeight(),g=l-y.outerHeight(),g-fc&&(i===h.UP||i===h.LEFT||i===h.BACKSPACE)?window.scrollTo(window.pageXOffset,c+window.pageYOffset-f):d>g&&window.scrollTo(window.pageXOffset,d+window.pageYOffset-g)))}function h(){setTimeout(function(){b.execCommand("wpAutoResize"),d()},300)}function i(){c(),d()}"content"===b.id&&(m=b,b.settings.autoresize_min_height=M,j=t.find(".mce-toolbar-grp"),k=t.find(".mce-edit-area"),l=t.find(".mce-statusbar").filter(":visible"),D=function(){b.on("keyup",g),b.on("show",h),b.on("hide",i),b.on("setcontent wp-autoresize wp-toolbar-toggle",d)},E=function(){b.off("keyup",g),b.off("show",h),b.off("hide",i),b.off("setcontent wp-autoresize wp-toolbar-toggle",d)},s.hasClass("wp-editor-expand")&&(D(),f(d)))}),s.hasClass("wp-editor-expand")&&(h(),t.hasClass("html-active")&&f(function(){d(),c()})),a("#adv-settings .editor-expand").show(),a("#editor-expand-toggle").on("change.editor-expand",function(){a(this).prop("checked")?(h(),window.setUserSetting("editor_expand","on")):(i(),window.setUserSetting("editor_expand","off"))}),window.editorExpand={on:h,off:i}}); \ No newline at end of file diff --git a/wp-admin/js/postbox.js b/wp-admin/js/postbox.js index 6c2e6945cd..5fc24e846c 100644 --- a/wp-admin/js/postbox.js +++ b/wp-admin/js/postbox.js @@ -3,6 +3,8 @@ var postboxes; (function($) { + var $document = $( document ); + postboxes = { add_postbox_toggles : function(page, args) { var self = this; @@ -26,6 +28,8 @@ var postboxes; else if ( p.hasClass('closed') && $.isFunction(postboxes.pbhide) ) self.pbhide(id); } + + $document.trigger( 'postbox-toggled', p ); }); $('.postbox .hndle a').click( function(e) { @@ -39,19 +43,21 @@ var postboxes; }); $('.hide-postbox-tog').bind('click.postboxes', function() { - var box = $(this).val(); + var boxId = $(this).val(), + $postbox = $( '#' + boxId ); if ( $(this).prop('checked') ) { - $('#' + box).show(); + $postbox.show(); if ( $.isFunction( postboxes.pbshow ) ) self.pbshow( box ); } else { - $('#' + box).hide(); + $postbox.hide(); if ( $.isFunction( postboxes.pbhide ) ) self.pbhide( box ); } self.save_state(page); self._mark_area(); + $document.trigger( 'postbox-toggled', $postbox ); }); $('.columns-prefs input[type="radio"]').bind('click.postboxes', function(){ diff --git a/wp-admin/js/postbox.min.js b/wp-admin/js/postbox.min.js index 43cfa5aa1d..6108394b82 100644 --- a/wp-admin/js/postbox.min.js +++ b/wp-admin/js/postbox.min.js @@ -1 +1 @@ -var postboxes;!function(a){postboxes={add_postbox_toggles:function(b,c){var d=this;d.init(b,c),a(".postbox .hndle, .postbox .handlediv").bind("click.postboxes",function(){var c=a(this).parent(".postbox"),e=c.attr("id");"dashboard_browser_nag"!=e&&(c.toggleClass("closed"),"press-this"!=b&&d.save_state(b),e&&(!c.hasClass("closed")&&a.isFunction(postboxes.pbshow)?d.pbshow(e):c.hasClass("closed")&&a.isFunction(postboxes.pbhide)&&d.pbhide(e)))}),a(".postbox .hndle a").click(function(a){a.stopPropagation()}),a(".postbox a.dismiss").bind("click.postboxes",function(){var b=a(this).parents(".postbox").attr("id")+"-hide";return a("#"+b).prop("checked",!1).triggerHandler("click"),!1}),a(".hide-postbox-tog").bind("click.postboxes",function(){var c=a(this).val();a(this).prop("checked")?(a("#"+c).show(),a.isFunction(postboxes.pbshow)&&d.pbshow(c)):(a("#"+c).hide(),a.isFunction(postboxes.pbhide)&&d.pbhide(c)),d.save_state(b),d._mark_area()}),a('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var c=parseInt(a(this).val(),10);c&&(d._pb_edit(c),d.save_order(b))})},init:function(b,c){var d=a(document.body).hasClass("mobile");a.extend(this,c||{}),a("#wpbody-content").css("overflow","hidden"),a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",delay:d?200:0,distance:2,tolerance:"pointer",forcePlaceholderSize:!0,helper:"clone",opacity:.65,stop:function(){return a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id?void a(this).sortable("cancel"):void postboxes.save_order(b)},receive:function(b,c){"dashboard_browser_nag"==c.item[0].id&&a(c.sender).sortable("cancel"),postboxes._mark_area()}}),d&&(a(document.body).bind("orientationchange.postboxes",function(){postboxes._pb_change()}),this._pb_change()),this._mark_area()},save_state:function(b){var c=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),d=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:c,hidden:d,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:b})},save_order:function(b){var c,d=a(".columns-prefs input:checked").val()||0;c={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:b},a(".meta-box-sortables").each(function(){c["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")}),a.post(ajaxurl,c)},_mark_area:function(){var b=a("div.postbox:visible").length,c=a("#post-body #side-sortables");a("#dashboard-widgets .meta-box-sortables:visible").each(function(){var c=a(this);1==b||c.children(".postbox:visible").length?c.removeClass("empty-container"):c.addClass("empty-container")}),c.length&&(c.children(".postbox:visible").length?c.removeClass("empty-container"):"280px"==a("#postbox-container-1").css("width")&&c.addClass("empty-container"))},_pb_edit:function(b){var c=a(".metabox-holder").get(0);c&&(c.className=c.className.replace(/columns-\d+/,"columns-"+b)),a(document).trigger("postboxes-columnchange")},_pb_change:function(){var b=a('label.columns-prefs-1 input[type="radio"]');switch(window.orientation){case 90:case-90:b.length&&b.is(":checked")||this._pb_edit(2);break;case 0:case 180:a("#poststuff").length?this._pb_edit(1):b.length&&b.is(":checked")||this._pb_edit(2)}},pbshow:!1,pbhide:!1}}(jQuery); \ No newline at end of file +var postboxes;!function(a){var b=a(document);postboxes={add_postbox_toggles:function(c,d){var e=this;e.init(c,d),a(".postbox .hndle, .postbox .handlediv").bind("click.postboxes",function(){var d=a(this).parent(".postbox"),f=d.attr("id");"dashboard_browser_nag"!=f&&(d.toggleClass("closed"),"press-this"!=c&&e.save_state(c),f&&(!d.hasClass("closed")&&a.isFunction(postboxes.pbshow)?e.pbshow(f):d.hasClass("closed")&&a.isFunction(postboxes.pbhide)&&e.pbhide(f)),b.trigger("postbox-toggled",d))}),a(".postbox .hndle a").click(function(a){a.stopPropagation()}),a(".postbox a.dismiss").bind("click.postboxes",function(){var b=a(this).parents(".postbox").attr("id")+"-hide";return a("#"+b).prop("checked",!1).triggerHandler("click"),!1}),a(".hide-postbox-tog").bind("click.postboxes",function(){var d=a(this).val(),f=a("#"+d);a(this).prop("checked")?(f.show(),a.isFunction(postboxes.pbshow)&&e.pbshow(box)):(f.hide(),a.isFunction(postboxes.pbhide)&&e.pbhide(box)),e.save_state(c),e._mark_area(),b.trigger("postbox-toggled",f)}),a('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var b=parseInt(a(this).val(),10);b&&(e._pb_edit(b),e.save_order(c))})},init:function(b,c){var d=a(document.body).hasClass("mobile");a.extend(this,c||{}),a("#wpbody-content").css("overflow","hidden"),a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",delay:d?200:0,distance:2,tolerance:"pointer",forcePlaceholderSize:!0,helper:"clone",opacity:.65,stop:function(){return a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id?void a(this).sortable("cancel"):void postboxes.save_order(b)},receive:function(b,c){"dashboard_browser_nag"==c.item[0].id&&a(c.sender).sortable("cancel"),postboxes._mark_area()}}),d&&(a(document.body).bind("orientationchange.postboxes",function(){postboxes._pb_change()}),this._pb_change()),this._mark_area()},save_state:function(b){var c=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),d=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:c,hidden:d,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:b})},save_order:function(b){var c,d=a(".columns-prefs input:checked").val()||0;c={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:b},a(".meta-box-sortables").each(function(){c["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")}),a.post(ajaxurl,c)},_mark_area:function(){var b=a("div.postbox:visible").length,c=a("#post-body #side-sortables");a("#dashboard-widgets .meta-box-sortables:visible").each(function(){var c=a(this);1==b||c.children(".postbox:visible").length?c.removeClass("empty-container"):c.addClass("empty-container")}),c.length&&(c.children(".postbox:visible").length?c.removeClass("empty-container"):"280px"==a("#postbox-container-1").css("width")&&c.addClass("empty-container"))},_pb_edit:function(b){var c=a(".metabox-holder").get(0);c&&(c.className=c.className.replace(/columns-\d+/,"columns-"+b)),a(document).trigger("postboxes-columnchange")},_pb_change:function(){var b=a('label.columns-prefs-1 input[type="radio"]');switch(window.orientation){case 90:case-90:b.length&&b.is(":checked")||this._pb_edit(2);break;case 0:case 180:a("#poststuff").length?this._pb_edit(1):b.length&&b.is(":checked")||this._pb_edit(2)}},pbshow:!1,pbhide:!1}}(jQuery); \ No newline at end of file