mirror of
https://github.com/WordPress/WordPress.git
synced 2024-08-18 11:42:57 +02:00
Built from https://develop.svn.wordpress.org/trunk@29352 git-svn-id: http://core.svn.wordpress.org/trunk@29128 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
5.3 KiB
JavaScript
1 line
5.3 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=v[0].selectionStart,k=v[0].selectionEnd,l=w[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()+t.outerHeight()+u.outerHeight(),f=m-x.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=v.height();w.width(v.width()),w.text(v.val()+" "),a=w.height(),300>a&&(a=300),a!==b&&(v.height(a),d())}}function d(a){if(!y||!y.settings.visible){var b,c,d,e,f,g,h,i,n,p=x.outerHeight(),r=o.scrollTop(),z=o.height(),A=o.width(),D=A>600?q.height():0,E="scroll"!==a,F=m&&!m.isHidden(),G=200;F?(b=j,c=k):(b=u,c=v),d=t.outerHeight(),e=b.parent().offset().top,f=b.outerHeight(),g=c.offset().top,h=c.outerHeight(),i=c.outerWidth(),n=F?l.outerHeight():0,(!B||E)&&r>=e-d-D&&e-d-D+h-G>=r?(B=!0,b.css({position:"fixed",top:D+d,width:c.parent().width()-(b.outerWidth()-b.width()),borderTop:"1px solid #e5e5e5"}),t.css({position:"fixed",top:D,width:i+2})):(B||E)&&(e-d-D>=r?(B=!1,b.css({position:"absolute",top:0,borderTop:"none",width:c.parent().width()-(b.outerWidth()-b.width())}),t.css({position:"absolute",top:0,width:s.width()})):r>=e-d-D+h-G&&(B=!1,b.css({position:"absolute",top:h-G}),t.css({position:"absolute",top:h-G+1,width:s.width()}))),(!C||E)&&g+h+p+n+1>=r+z?(C=!0,x.css({position:"fixed",bottom:0,width:i+2,borderTop:"1px solid #dedede"})):(C||E)&&r+z>g+h+p+n-1&&(C=!1,x.css({position:"relative",bottom:"auto",width:"100%",borderTop:"none"})),E&&(s.css({paddingTop:t.outerHeight()}),F?k.css({paddingTop:j.outerHeight()}):(v.css({marginTop:u.outerHeight()}),w.width(v.width())))}}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>130&&window.scrollTo(window.pageXOffset,0),r.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),v.on("focus.editor-expand input.editor-expand propertychange.editor-expand",c),v.on("keyup.editor-expand",b),z(),y&&y.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>130&&window.scrollTo(window.pageXOffset,0),r.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),v.off("focus.editor-expand input.editor-expand propertychange.editor-expand",c),v.off("keyup.editor-expand",b),A(),y&&y.pubsub.unsubscribe("hidden",e),a.each([j,u,t,x,s,k,v],function(a,b){b&&b.attr("style","")}),m&&(m.settings.wp_autoresize_on=!1,m.execCommand("wpAutoResizeOff"),m.isHidden()||(v.hide(),f&&m.theme.resizeTo(null,f))),f&&v.height(f)}var j,k,l,m,n,o=a(window),p=a(document),q=a("#wpadminbar"),r=a("#postdivrich"),s=a("#wp-content-wrap"),t=a("#wp-content-editor-tools"),u=a("#ed_toolbar"),v=a("#content"),w=a('<div id="content-textarea-clone"></div>'),x=a("#post-status-info"),y=window.wp.editor&&window.wp.editor.fullscreen,z=function(){},A=function(){},B=!1,C=!1;w.insertAfter(v),w.css({"font-family":v.css("font-family"),"font-size":v.css("font-size"),"line-height":v.css("line-height"),padding:v.css("padding"),"padding-top":37,"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()+t.outerHeight()+j.outerHeight(),g=l-x.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=300,j=s.find(".mce-toolbar-grp"),k=s.find(".mce-edit-area"),l=s.find(".mce-statusbar").filter(":visible"),z=function(){b.on("keyup",g),b.on("show",h),b.on("hide",i),b.on("setcontent wp-autoresize wp-toolbar-toggle",d)},A=function(){b.off("keyup",g),b.off("show",h),b.off("hide",i),b.off("setcontent wp-autoresize wp-toolbar-toggle",d)},r.hasClass("wp-editor-expand")&&(z(),f(d)))}),r.hasClass("wp-editor-expand")&&(h(),s.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}}); |