Upgrade TinyMCE to v3.4.5
[citadel.git] / webcit / tiny_mce / plugins / autoresize / editor_plugin_src.js
index c260b7a24f542784832d3b7e09a81152451848af..7d113419d98a17ff03a0b8d2b1738110d5895996 100644 (file)
@@ -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;
                                var d = ed.getDoc(), b = 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 ? b.scrollHeight : d.body.offsetHeight;
 
                                // Don't make it smaller than the minimum height
                                if (myHeight > t.autoresize_min_height)
                                        resizeHeight = myHeight;
 
+                               // 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;
+                                       ed.getBody().style.overflowY = "auto";
+                               } else
+                                       ed.getBody().style.overflowY = "hidden";
+
                                // Resize content element
-                               DOM.setStyle(DOM.get(ed.id + '_ifr'), 'height', resizeHeight + 'px');
+                               if (resizeHeight !== oldSize) {
+                                       DOM.setStyle(DOM.get(ed.id + '_ifr'), 'height', resizeHeight + 'px');
+                                       oldSize = resizeHeight;
+                               }
 
                                // if we're throbbing, we'll re-throb to match the new size
                                if (t.throbbing) {
                        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);
 
        // Register plugin
        tinymce.PluginManager.add('autoresize', tinymce.plugins.AutoResizePlugin);
-})();
\ No newline at end of file
+})();