WordPress/wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js
Andrew Ozz b9886e92e3 Editor scrolling:
- Add a Screen Option to turn it on/off, and on()/off() methods from JS. Store the user preference.
- Fix delayed calls to resize() in the TinyMCE autoresize plugin.
See #28328.
Built from https://develop.svn.wordpress.org/trunk@29336


git-svn-id: http://core.svn.wordpress.org/trunk@29116 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-01 02:43:17 +00:00

1 line
2.1 KiB
JavaScript

tinymce.PluginManager.add("wpautoresize",function(a){function b(){return a.plugins.fullscreen&&a.plugins.fullscreen.isFullscreen()}function c(d){var e,f,j,k,l,m,n,o,p=tinymce.DOM;if(i&&(f=a.getDoc())){if(d=d||{},j=f.body,k=f.documentElement,l=g.autoresize_min_height,!j||d&&"setcontent"===d.type&&d.initial||b())return void(j&&k&&(j.style.overflowY="auto",k.style.overflowY="auto"));n=a.dom.getStyle(j,"margin-top",!0),o=a.dom.getStyle(j,"margin-bottom",!0),m=j.offsetHeight+parseInt(n,10)+parseInt(o,10),m&&m<k.offsetHeight&&(m=k.offsetHeight),(isNaN(m)||0>=m)&&(m=tinymce.Env.ie?j.scrollHeight:tinymce.Env.webkit&&0===j.clientHeight?0:j.offsetHeight),m>g.autoresize_min_height&&(l=m),g.autoresize_max_height&&m>g.autoresize_max_height?(l=g.autoresize_max_height,j.style.overflowY="auto",k.style.overflowY="auto"):(j.style.overflowY="hidden",k.style.overflowY="hidden",j.scrollTop=0),l!==h&&(e=l-h,p.setStyle(p.get(a.id+"_ifr"),"height",l+"px"),h=l,tinymce.isWebKit&&0>e&&c(d),a.fire("wp-autoresize",{height:l}))}}function d(a,b,e){setTimeout(function(){c(),a--?d(a,b,e):e&&e()},b)}function e(){a.dom.hasClass(a.getBody(),"wp-autoresize")||(i=!0,a.dom.addClass(a.getBody(),"wp-autoresize"),a.on("nodechange setcontent keyup FullscreenStateChanged",c),c())}function f(){var b;g.wp_autoresize_on||(i=!1,b=a.getDoc(),a.dom.removeClass(a.getBody(),"wp-autoresize"),a.off("nodechange setcontent keyup FullscreenStateChanged",c),b.body.style.overflowY="auto",b.documentElement.style.overflowY="auto",h=0)}var g=a.settings,h=0,i=!1;a.settings.inline||(g.autoresize_min_height=parseInt(a.getParam("autoresize_min_height",a.getElement().offsetHeight),10),g.autoresize_max_height=parseInt(a.getParam("autoresize_max_height",0),10),g.wp_autoresize_on&&(i=!0,a.on("init",function(){a.dom.addClass(a.getBody(),"wp-autoresize")}),a.on("nodechange keyup FullscreenStateChanged",c),a.on("setcontent",function(){d(3,100)}),a.getParam("autoresize_on_init",!0)&&a.on("init",function(){d(10,200,function(){d(5,1e3)})})),a.on("show",function(){h=0}),a.addCommand("wpAutoResize",c),a.addCommand("wpAutoResizeOn",e),a.addCommand("wpAutoResizeOff",f))});