mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-18 16:45:31 +01:00
da0b98a8f0
- Improve TinyMCE resizing when a floated block is at the end of the content. - Improve setting the padding/margin under the toolbar on loading. - Add custom event on TinyMCE resizing and use it to adjust the pinning (if needed). Part props avryl, see #28328. Built from https://develop.svn.wordpress.org/trunk@29279 git-svn-id: http://core.svn.wordpress.org/trunk@29061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
4.2 KiB
JavaScript
1 line
4.2 KiB
JavaScript
window.wp=window.wp||{},jQuery(document).ready(function(a){function b(){if(!h||h.isHidden()){var a,b=o.height();p.width(o.width()),p.text(o.val()+" "),a=p.height(),300>a&&(a=300),a!==b&&(o.height(a),c())}}function c(a){if(!s||!s.settings.visible){var b,c,d,j,v,w,x,y,z,A=q.outerHeight(),B=i.scrollTop(),C=i.height(),D=i.width(),E=D>600?k.height():0,F="scroll"!==a,G=h&&!h.isHidden();G?(b=e,c=f):(b=n,c=o),d=m.outerHeight(),j=b.parent().offset().top,v=b.outerHeight(),w=c.offset().top,x=c.outerHeight(),y=c.outerWidth(),z=G?g.outerHeight():0,(!t||F)&&B>=j-d-E&&j-d-E+x-r>=B?(t=!0,b.css({position:"fixed",top:E+d,width:c.parent().width()-(b.outerWidth()-b.width()),borderTop:"1px solid #e5e5e5"}),m.css({position:"fixed",top:E,width:y+2})):(t||F)&&(j-d-E>=B?(t=!1,b.css({position:"absolute",top:0,borderTop:"none",width:c.parent().width()-(b.outerWidth()-b.width())}),m.css({position:"absolute",top:0,width:l.width()})):B>=j-d-E+x-r&&(t=!1,b.css({position:"absolute",top:x-r}),m.css({position:"absolute",top:x-r+1,width:l.width()}))),(!u||F)&&w+x+A+z+1>=B+C?(u=!0,q.css({position:"fixed",bottom:0,width:y+2,borderTop:"1px solid #dedede"})):(u||F)&&B+C>w+x+A+z-1&&(u=!1,q.css({position:"relative",bottom:"auto",width:"100%",borderTop:"none"})),F&&(l.css({paddingTop:m.outerHeight()}),G?f.css({paddingTop:e.outerHeight()}):(o.css({marginTop:n.outerHeight()}),p.width(o.width())))}}function d(a){for(var b=1;6>b;b++)setTimeout(a,500*b)}var e,f,g,h,i=a(window),j=a(document),k=a("#wpadminbar"),l=a("#wp-content-wrap"),m=a("#wp-content-editor-tools"),n=a("#ed_toolbar"),o=a("#content"),p=a('<div id="content-textarea-clone"></div>'),q=a("#post-status-info"),r=200,s=window.wp.editor&&window.wp.editor.fullscreen,t=!1,u=!1;p.insertAfter(o),l.addClass("wp-editor-expand"),a("#content-resize-handle").hide(),p.css({"font-family":o.css("font-family"),"font-size":o.css("font-size"),"line-height":o.css("line-height"),padding:o.css("padding"),"padding-top":37,"white-space":"pre-wrap","word-wrap":"break-word"}),o.on("focus input propertychange",function(){b()}),o.on("keyup",function(a){var b,c,d,e,f,g=jQuery.ui.keyCode,h=a.keyCode,j=document.createRange(),l=o[0].selectionStart,r=o[0].selectionEnd,s=p[0].firstChild,t=i.height(),u=10;if(!l||!r||l===r){try{j.setStart(s,l),j.setEnd(s,r+1)}catch(v){}b=j.getBoundingClientRect(),b.height&&(c=b.top-u,d=c+b.height+u,e=k.outerHeight()+m.outerHeight()+n.outerHeight(),f=t-q.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))}}),j.on("tinymce-editor-init.editor-expand",function(a,j){function n(){var a,b,c,d=j.selection,e=d.getNode(),f=d.getRng();if(!(tinymce.Env.ie&&tinymce.Env.ie<9)&&(j.plugins.wpview&&(a=j.plugins.wpview.getView(e))?c=a.getBoundingClientRect():d.isCollapsed()?(b=f.cloneRange(),b.startContainer.length>1?(b.startContainer.length>b.endOffset?b.setEnd(b.startContainer,b.endOffset+1):b.setStart(b.startContainer,b.endOffset-1),d.setRng(b),c=d.getRng().getBoundingClientRect(),d.setRng(f)):c=e.getBoundingClientRect()):c=f.getBoundingClientRect(),c.height))return c}"content"===j.id&&(h=j,j.settings.autoresize_min_height=300,e=l.find(".mce-toolbar-grp"),f=l.find(".mce-edit-area"),g=l.find(".mce-statusbar").filter(":visible"),j.on("show",function(){setTimeout(function(){j.execCommand("wpAutoResize"),c()},300)}),j.on("keyup",function(a){var b,c,d,f,g=tinymce.util.VK,h=a.keyCode,l=n(),o=i.height(),p=10;l&&(b=l.top+j.getContentAreaContainer().getElementsByTagName("iframe")[0].getBoundingClientRect().top,c=b+l.height,b-=p,c+=p,d=k.outerHeight()+m.outerHeight()+e.outerHeight(),f=o-q.outerHeight(),d>b&&(h===g.UP||h===g.LEFT||h===g.BACKSPACE)?window.scrollTo(window.pageXOffset,b+window.pageYOffset-d):c>f&&window.scrollTo(window.pageXOffset,c+window.pageYOffset-f))}),j.on("hide",function(){b(),c()}),j.on("setcontent wp-autoresize wp-toolbar-toggle",function(){c()}),d(c))}),i.on("scroll.editor-expand resize.editor-expand",function(a){c(a.type)}),s&&s.pubsub.subscribe("hidden",function(){b(),c()}),j.on("wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand",c),l.hasClass("html-active")&&d(function(){c(),b()})}); |