diff options
author | friendica <info@friendica.com> | 2012-03-20 20:47:31 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-03-20 20:47:31 -0700 |
commit | f55779fd831029f764c885bf1fd026a7e94f08eb (patch) | |
tree | 8a441c0bc5f519f7cf303e5065cba750141b05a8 /library/tinymce/jscripts/tiny_mce/plugins/autoresize/editor_plugin_src.js | |
parent | 810e69ef0a88a959ce9f5358377cdc1c7d4bd53a (diff) | |
download | volse-hubzilla-f55779fd831029f764c885bf1fd026a7e94f08eb.tar.gz volse-hubzilla-f55779fd831029f764c885bf1fd026a7e94f08eb.tar.bz2 volse-hubzilla-f55779fd831029f764c885bf1fd026a7e94f08eb.zip |
update tinymce to 3.5b2 to fix issues with FF 11 and pasting into code blocks
Diffstat (limited to 'library/tinymce/jscripts/tiny_mce/plugins/autoresize/editor_plugin_src.js')
-rw-r--r--[-rwxr-xr-x] | library/tinymce/jscripts/tiny_mce/plugins/autoresize/editor_plugin_src.js | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/library/tinymce/jscripts/tiny_mce/plugins/autoresize/editor_plugin_src.js b/library/tinymce/jscripts/tiny_mce/plugins/autoresize/editor_plugin_src.js index c260b7a24..7673bcff8 100755..100644 --- a/library/tinymce/jscripts/tiny_mce/plugins/autoresize/editor_plugin_src.js +++ b/library/tinymce/jscripts/tiny_mce/plugins/autoresize/editor_plugin_src.js @@ -11,7 +11,7 @@ (function() { /** * Auto Resize - * + * * This plugin automatically resizes the content area to fit its content height. * It will retain a minimum height, which is the height of the content area when * it's initialized. @@ -26,7 +26,7 @@ * @param {string} url Absolute URL to where the plugin is located. */ init : function(ed, url) { - var t = this; + var t = this, oldSize = 0; if (ed.getParam('fullscreen_is_enabled')) return; @@ -35,29 +35,51 @@ * This method gets executed each time the editor needs to resize. */ function resize() { - var d = ed.getDoc(), b = d.body, de = d.documentElement, DOM = tinymce.DOM, resizeHeight = t.autoresize_min_height, myHeight; + var deltaSize, d = ed.getDoc(), body = d.body, de = d.documentElement, DOM = tinymce.DOM, resizeHeight = t.autoresize_min_height, myHeight; // Get height differently depending on the browser used - myHeight = tinymce.isIE ? b.scrollHeight : de.offsetHeight; + myHeight = tinymce.isIE ? body.scrollHeight : (tinymce.isWebKit && body.clientHeight == 0 ? 0 : body.offsetHeight); // Don't make it smaller than the minimum height if (myHeight > t.autoresize_min_height) resizeHeight = myHeight; - // Resize content element - DOM.setStyle(DOM.get(ed.id + '_ifr'), 'height', resizeHeight + 'px'); + // If a maximum height has been defined don't exceed this height + if (t.autoresize_max_height && myHeight > t.autoresize_max_height) { + resizeHeight = t.autoresize_max_height; + body.style.overflowY = "auto"; + de.style.overflowY = "auto"; // Old IE + } else { + body.style.overflowY = "hidden"; + de.style.overflowY = "hidden"; // Old IE + body.scrollTop = 0; + } - // if we're throbbing, we'll re-throb to match the new size - if (t.throbbing) { - ed.setProgressState(false); - ed.setProgressState(true); + // Resize content element + if (resizeHeight !== oldSize) { + deltaSize = resizeHeight - oldSize; + DOM.setStyle(DOM.get(ed.id + '_ifr'), 'height', resizeHeight + 'px'); + oldSize = resizeHeight; + + // WebKit doesn't decrease the size of the body element until the iframe gets resized + // So we need to continue to resize the iframe down until the size gets fixed + if (tinymce.isWebKit && deltaSize < 0) + resize(); } }; t.editor = ed; // Define minimum height - t.autoresize_min_height = ed.getElement().offsetHeight; + t.autoresize_min_height = parseInt(ed.getParam('autoresize_min_height', ed.getElement().offsetHeight)); + + // Define maximum height + t.autoresize_max_height = parseInt(ed.getParam('autoresize_max_height', 0)); + + // Add padding at the bottom for better UX + ed.onInit.add(function(ed){ + ed.dom.setStyle(ed.getBody(), 'paddingBottom', ed.getParam('autoresize_bottom_margin', 50) + 'px'); + }); // Add appropriate listeners for resizing content area ed.onChange.add(resize); @@ -67,30 +89,8 @@ ed.onPostRender.add(resize); if (ed.getParam('autoresize_on_init', true)) { - // Things to do when the editor is ready - ed.onInit.add(function(ed, l) { - // Show throbber until content area is resized properly - ed.setProgressState(true); - t.throbbing = true; - - // Hide scrollbars - ed.getBody().style.overflowY = "hidden"; - }); - - ed.onLoadContent.add(function(ed, l) { - resize(); - - // Because the content area resizes when its content CSS loads, - // and we can't easily add a listener to its onload event, - // we'll just trigger a resize after a short loading period - setTimeout(function() { - resize(); - - // Disable throbber - ed.setProgressState(false); - t.throbbing = false; - }, 1250); - }); + ed.onLoad.add(resize); + ed.onLoadContent.add(resize); } // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); @@ -116,4 +116,4 @@ // Register plugin tinymce.PluginManager.add('autoresize', tinymce.plugins.AutoResizePlugin); -})();
\ No newline at end of file +})(); |