mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-30 15:31:04 +01:00
68a3e1af2c
Built from https://develop.svn.wordpress.org/trunk@29524 git-svn-id: http://core.svn.wordpress.org/trunk@29300 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
6.2 KiB
JavaScript
1 line
6.2 KiB
JavaScript
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()-22),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+20<K+N&&(I=!0,z.css({position:"fixed",top:"auto",bottom:"20px"})):J>K&&(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('<div id="content-textarea-clone"></div>'),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-f<k.height||(f>c&&(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}}); |