/forum/site_media/js/wym/wymeditor/plugins/resizable/readme.txt

http://djforum.googlecode.com/ · Plain Text · 124 lines · 92 code · 32 blank · 0 comment · 0 complexity · 779875a11fe8526a6d246829afda4f1c MD5 · raw file

  1. resizable plugin for WYMeditor
  2. ##############################
  3. The ``resizable`` plugin for WYMeditor_ enables vertical resizing of the
  4. editor area. The plugin is based on the jQuery UI library.
  5. Requirements
  6. ============
  7. The following packages are required for using the WYMeditor ``resizable``
  8. plugin:
  9. * jQuery (tested with jQuery ``jquery-1.2.4a.js`` from ``jquery.ui`` package)
  10. * WYMeditor SVN trunk (Revision: 482)
  11. * jQuery-UI (tested with ``jquery.ui-1.5b2``)
  12. It should be possible to use this plugin with ``WYMeditor-0.4`` but I have not
  13. tried.
  14. Download
  15. ========
  16. You can download the WYMeditor ``resizable`` plugin here:
  17. * wymeditor-resizable-plugin-0.2.tgz_
  18. * wymeditor-resizable-plugin-0.1.tgz_
  19. See the Changelog_ for more infos about the releases.
  20. .. _wymeditor-resizable-plugin-0.2.tgz: http://pyjax.net/download/wymeditor-resizable-plugin-0.2.tgz
  21. .. _wymeditor-resizable-plugin-0.1.tgz: http://pyjax.net/download/wymeditor-resizable-plugin-0.1.tgz
  22. Installation
  23. ============
  24. Just extract the downloaded archive into your WYMeditor's ``plugin``
  25. directory.
  26. Usage
  27. =====
  28. For general instructions on WYMeditor plugins please refer to the `WYMeditor
  29. plugin page`_.
  30. To use the ``resizable`` plugin simply include the plugin's JavaScript file in
  31. your code. You **do not** need to include the jQuery UI files - this is done
  32. automatically by the plugin (see `Internals`_)::
  33. <script type="text/javascript"
  34. src="/js/wymeditor/plugins/resizable/jquery.wymeditor.resizable.js">
  35. </script>
  36. Make sure to adjust the ``src`` attribute to your needs, then initialize the
  37. plugin in WYMeditor's ``postInit`` function::
  38. wymeditor({postInit: function(wym) {
  39. wym.hovertools(); // other plugins...
  40. wym.resizable({handles: "s,e",
  41. maxHeight: 600});
  42. }
  43. })
  44. The ``resizable`` plugin takes exactly one parameter, which is an object literal
  45. containing the options of the plugin. The WYMeditor ``resizable`` plugin
  46. supports all options of the jQuery UI ``resizable`` plugin. These are the
  47. default values used by the plugin::
  48. handles: "s,e,se",
  49. minHeight: 250,
  50. maxHeight: 600
  51. See the `jQuery UI resizable plugin docs`_ for a list of all options.
  52. That's it! You are now able to resize the WYMeditor vertically, horizontally or
  53. both, depending on your options.
  54. .. _jQuery UI resizable plugin docs: http://docs.jquery.com/UI/Resizables
  55. Internals
  56. =========
  57. The plugin takes care of loading the necessary jQuery UI files (``base`` and
  58. ``resizable``) from the same path the jQuery library was loaded. Here's how
  59. it's done::
  60. // Get the jQuery path from the editor, stripping away the jQuery file.
  61. // see http://www.oreilly.com/catalog/regex/chapter/ch04.html
  62. // The match result array contains the path and the filename.
  63. var jQueryPath = wym.computeJqueryPath().match(/^(.*)\/(.*)$/)[1];
  64. // Make an array of the external JavaScript files required by the plugin.
  65. var jQueryPlugins = [jQueryPath + '/ui.base.js',
  66. jQueryPath + '/ui.resizable.js'];
  67. // First get the jQuery UI base file
  68. $.getScript(jQueryPlugins[0]);
  69. // Get the jQuery UI resizeable plugin and then init the wymeditor resizable
  70. // plugin. It is import to do the initialisation after loading the
  71. // necessary jQuery UI files has finished, otherwise the "resizable" method
  72. // would not be available.
  73. $.getScript(jQueryPlugins[1], function() {
  74. jQuery(wym._box).resizable(final_options);
  75. });
  76. An alternative approach would be to use an AJAX queue when getting the script
  77. files to ensure that all jQuery files are loaded before the initialisation code
  78. of the plugin is executed. There is an `jQuery AJAX queue plugin`_ which does
  79. that.
  80. .. _jQuery AJAX queue plugin: http://plugins.jquery.com/project/ajaxqueue
  81. Changelog
  82. =========
  83. 0.2
  84. ---
  85. - Added full support for all jQuery UI resizable plugin options.
  86. - Refactored and documented code.
  87. - Now contains a packed version (775 bytes).
  88. 0.1
  89. ---
  90. - Initial release.
  91. .. _WYMeditor: http://www.wymeditor.org/
  92. .. _WYMeditor plugin page: http://trac.wymeditor.org/trac/wiki/0.4/Plugins