diff options
| author | hukl <contact@smyck.org> | 2009-09-09 12:07:57 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-09-09 12:07:57 +0200 |
| commit | a6292dd0fecd4482fe863ed849d126b5281b1a8a (patch) | |
| tree | 7c4c32e1a3448c5d1995a236ed01c731018da13d /public/javascripts/tiny_mce/plugins/autoresize | |
| parent | 83fe1b1abd7d7bb85679be3f1341e5c88db0ae83 (diff) | |
huge tiny_mce update - now using the tiny_mce jquery build which allows tiny_mce to be initialized via jquery - great!
Diffstat (limited to 'public/javascripts/tiny_mce/plugins/autoresize')
| -rw-r--r-- | public/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js | 1 | ||||
| -rw-r--r-- | public/javascripts/tiny_mce/plugins/autoresize/editor_plugin_src.js | 114 |
2 files changed, 115 insertions, 0 deletions
diff --git a/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js b/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js new file mode 100644 index 0000000..220b84a --- /dev/null +++ b/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js | |||
| @@ -0,0 +1 @@ | |||
| (function(){tinymce.create("tinymce.plugins.AutoResizePlugin",{init:function(a,c){var d=this;if(a.getParam("fullscreen_is_enabled")){return}function b(){var h=a.getDoc(),e=h.body,j=h.documentElement,g=tinymce.DOM,i=d.autoresize_min_height,f;f=tinymce.isIE?e.scrollHeight:j.offsetHeight;if(f>d.autoresize_min_height){i=f}g.setStyle(g.get(a.id+"_ifr"),"height",i+"px");if(d.throbbing){a.setProgressState(false);a.setProgressState(true)}}d.editor=a;d.autoresize_min_height=a.getElement().offsetHeight;a.onInit.add(function(f,e){f.setProgressState(true);d.throbbing=true;f.getBody().style.overflowY="hidden"});a.onChange.add(b);a.onSetContent.add(b);a.onPaste.add(b);a.onKeyUp.add(b);a.onPostRender.add(b);a.onLoadContent.add(function(f,e){b();setTimeout(function(){b();f.setProgressState(false);d.throbbing=false},1250)});a.addCommand("mceAutoResize",b)},getInfo:function(){return{longname:"Auto Resize",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autoresize",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("autoresize",tinymce.plugins.AutoResizePlugin)})(); \ No newline at end of file | |||
diff --git a/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin_src.js b/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin_src.js new file mode 100644 index 0000000..89a9b89 --- /dev/null +++ b/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin_src.js | |||
| @@ -0,0 +1,114 @@ | |||
| 1 | /** | ||
| 2 | * $Id: editor_plugin_src.js 539 2008-01-14 19:08:58Z spocke $ | ||
| 3 | * | ||
| 4 | * @author Moxiecode | ||
| 5 | * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. | ||
| 6 | */ | ||
| 7 | |||
| 8 | (function() { | ||
| 9 | /** | ||
| 10 | * Auto Resize | ||
| 11 | * | ||
| 12 | * This plugin automatically resizes the content area to fit its content height. | ||
| 13 | * It will retain a minimum height, which is the height of the content area when | ||
| 14 | * it's initialized. | ||
| 15 | */ | ||
| 16 | tinymce.create('tinymce.plugins.AutoResizePlugin', { | ||
| 17 | /** | ||
| 18 | * Initializes the plugin, this will be executed after the plugin has been created. | ||
| 19 | * This call is done before the editor instance has finished it's initialization so use the onInit event | ||
| 20 | * of the editor instance to intercept that event. | ||
| 21 | * | ||
| 22 | * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. | ||
| 23 | * @param {string} url Absolute URL to where the plugin is located. | ||
| 24 | */ | ||
| 25 | init : function(ed, url) { | ||
| 26 | var t = this; | ||
| 27 | |||
| 28 | if (ed.getParam('fullscreen_is_enabled')) | ||
| 29 | return; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * This method gets executed each time the editor needs to resize. | ||
| 33 | */ | ||
| 34 | function resize() { | ||
| 35 | var d = ed.getDoc(), b = d.body, de = d.documentElement, DOM = tinymce.DOM, resizeHeight = t.autoresize_min_height, myHeight; | ||
| 36 | |||
| 37 | // Get height differently depending on the browser used | ||
| 38 | myHeight = tinymce.isIE ? b.scrollHeight : de.offsetHeight; | ||
| 39 | |||
| 40 | // Don't make it smaller than the minimum height | ||
| 41 | if (myHeight > t.autoresize_min_height) | ||
| 42 | resizeHeight = myHeight; | ||
| 43 | |||
| 44 | // Resize content element | ||
| 45 | DOM.setStyle(DOM.get(ed.id + '_ifr'), 'height', resizeHeight + 'px'); | ||
| 46 | |||
| 47 | // if we're throbbing, we'll re-throb to match the new size | ||
| 48 | if (t.throbbing) { | ||
| 49 | ed.setProgressState(false); | ||
| 50 | ed.setProgressState(true); | ||
| 51 | } | ||
| 52 | }; | ||
| 53 | |||
| 54 | t.editor = ed; | ||
| 55 | |||
| 56 | // Define minimum height | ||
| 57 | t.autoresize_min_height = ed.getElement().offsetHeight; | ||
| 58 | |||
| 59 | // Things to do when the editor is ready | ||
| 60 | ed.onInit.add(function(ed, l) { | ||
| 61 | // Show throbber until content area is resized properly | ||
| 62 | ed.setProgressState(true); | ||
| 63 | t.throbbing = true; | ||
| 64 | |||
| 65 | // Hide scrollbars | ||
| 66 | ed.getBody().style.overflowY = "hidden"; | ||
| 67 | }); | ||
| 68 | |||
| 69 | // Add appropriate listeners for resizing content area | ||
| 70 | ed.onChange.add(resize); | ||
| 71 | ed.onSetContent.add(resize); | ||
| 72 | ed.onPaste.add(resize); | ||
| 73 | ed.onKeyUp.add(resize); | ||
| 74 | ed.onPostRender.add(resize); | ||
| 75 | |||
| 76 | ed.onLoadContent.add(function(ed, l) { | ||
| 77 | resize(); | ||
| 78 | |||
| 79 | // Because the content area resizes when its content CSS loads, | ||
| 80 | // and we can't easily add a listener to its onload event, | ||
| 81 | // we'll just trigger a resize after a short loading period | ||
| 82 | setTimeout(function() { | ||
| 83 | resize(); | ||
| 84 | |||
| 85 | // Disable throbber | ||
| 86 | ed.setProgressState(false); | ||
| 87 | t.throbbing = false; | ||
| 88 | }, 1250); | ||
| 89 | }); | ||
| 90 | |||
| 91 | // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); | ||
| 92 | ed.addCommand('mceAutoResize', resize); | ||
| 93 | }, | ||
| 94 | |||
| 95 | /** | ||
| 96 | * Returns information about the plugin as a name/value array. | ||
| 97 | * The current keys are longname, author, authorurl, infourl and version. | ||
| 98 | * | ||
| 99 | * @return {Object} Name/value array containing information about the plugin. | ||
| 100 | */ | ||
| 101 | getInfo : function() { | ||
| 102 | return { | ||
| 103 | longname : 'Auto Resize', | ||
| 104 | author : 'Moxiecode Systems AB', | ||
| 105 | authorurl : 'http://tinymce.moxiecode.com', | ||
| 106 | infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autoresize', | ||
| 107 | version : tinymce.majorVersion + "." + tinymce.minorVersion | ||
| 108 | }; | ||
| 109 | } | ||
| 110 | }); | ||
| 111 | |||
| 112 | // Register plugin | ||
| 113 | tinymce.PluginManager.add('autoresize', tinymce.plugins.AutoResizePlugin); | ||
| 114 | })(); \ No newline at end of file | ||
