/[drupal]/contributions/modules/wymeditor/wymeditor/plugins/resizable/jquery.wymeditor.resizable.js
ViewVC logotype

Diff of /contributions/modules/wymeditor/wymeditor/plugins/resizable/jquery.wymeditor.resizable.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.4.1, Sun Sep 21 13:57:42 2008 UTC revision 1.1.4.2, Mon Sep 22 20:19:16 2008 UTC
# Line 0  Line 1 
1    /*
2     * WYMeditor : what you see is What You Mean web-based editor
3     * Copyright (c) 2008 Jean-Francois Hovinne, http://www.wymeditor.org/
4     * Dual licensed under the MIT (MIT-license.txt)
5     * and GPL (GPL-license.txt) licenses.
6     *
7     * For further information visit:
8     *        http://www.wymeditor.org/
9     *
10     * File Name:
11     *        jquery.wymeditor.resizable.js
12     *        resize plugin for WYMeditor
13     *
14     * File Authors:
15     *        Peter Eschler (peschler _at_ gmail.com)
16     *
17     * Version:
18     *        0.3
19     *
20     * Changelog:
21     *
22     * 0.3
23     *     - Added 'iframeOriginalSize' and removed 'ui.instance' calls (jfh).
24     *
25     * 0.2
26     *     - Added full support for all jQueryUI resizable plugin options.
27     *     - Refactored and documented code.
28     * 0.1
29     *     - Initial release.
30     */
31    
32    /**
33     * The resizable plugin makes the wymeditor box vertically resizable.
34     * It it based on the ui.resizable.js plugin of the jQuery UI library.
35     *
36     * The WYMeditor resizable plugin supports all parameters of the jQueryUI
37     * resizable plugin. The parameters are passed like this:
38     *
39     *         wym.resizable({ handles: "s,e",
40     *                         maxHeight: 600 });
41     *
42     * @param options options for the plugin
43     */
44    WYMeditor.editor.prototype.resizable = function(options) {
45    
46        var wym = this;
47        var iframe = jQuery(wym._box).find('iframe');
48        var iframeOriginalSize = {};
49    
50        // Define some default options
51        var default_options = {
52            start: function(e, ui) {
53                iframeOriginalSize = {
54                    width: jQuery(iframe).width(),
55                    height: jQuery(iframe).height()
56                }
57            },
58    
59            // resize is called by the jQuery resizable plugin whenever the
60            // client area was resized.
61            resize: function(e, ui) {
62                var diff = ui.size.height - ui.originalSize.height;
63                jQuery(iframe).height( iframeOriginalSize.height + diff );
64    
65                // If the plugin has horizontal resizing disabled we need to
66                // adjust the "width" attribute of the area css, because the
67                // resizing will set a fixed width (which breaks liquid layout
68                // of the wymeditor area).
69                if( !ui.options.handles['w'] && !ui.options.handles['e'] ) {
70                    ui.size.width = "inherit";
71                }
72            },
73            handles: "s,e,se",
74            minHeight: 250,
75            maxHeight: 600
76        };
77    
78        // Merge given options with default options. Given options override
79        // default ones.
80        var final_options = jQuery.extend(default_options, options);
81    
82        // Get the jQuery path from the editor, stripping away the jQuery file.
83        // see http://www.oreilly.com/catalog/regex/chapter/ch04.html
84        // The match result array contains the path and the filename.
85        var jQueryPath = wym.computeJqueryPath().match(/^(.*)\/(.*)$/)[1];
86    
87        // Make an array of the external JavaScript files required by the plugin.
88        var jQueryPlugins = [jQueryPath + '/jquery.ui.js',
89                             jQueryPath + '/jquery.ui.resizable.js'];
90    
91        // First get the jQuery UI base file
92        $.getScript(jQueryPlugins[0]);
93    
94        // Get the jQuery UI resizeable plugin and then init the wymeditor resize
95        // plugin. It is import to do the initialisation after loading the
96        // necessary jQuery UI files has finished, otherwise the "resizable" method
97        // would not be available.
98        $.getScript(jQueryPlugins[1], function() {
99            jQuery(wym._box).resizable(final_options);
100        });
101    
102    };

Legend:
Removed from v.1.1.4.1  
changed lines
  Added in v.1.1.4.2

  ViewVC Help
Powered by ViewVC 1.1.2