Changes between Version 11 and Version 12 of AddDojoEditor


Ignore:
Timestamp:
Oct 11, 2006, 1:07:16 PM (18 years ago)
Author:
Andy Dustman <farcepest@…>
Comment:

Alternate version using fieldset classes

Legend:

Unmodified
Added
Removed
Modified
  • AddDojoEditor

    v11 v12  
    6666 * some examples can be found in the [http://archive.dojotoolkit.org/ Dojo Nightly builds].
    6767
     68== Alternative version ==
     69
     70Another way to do this is to use the fieldset support in the Admin interface, and set the CSS class for the fieldset
     71to `wysiwyg`; see http://www.djangoproject.com/documentation/model_api/#classes for more details on how to do this.
     72Then use this version of `AddRichTextEditing.js`:
     73
     74{{{
     75document.write('<script type="text/javascript" src="/media/dojo/dojo.js"></script>');
     76document.write('<script type="text/javascript">dojo.require("dojo.widget.Editor2");</script>');
     77
     78var AddEditor = {
     79    init: function() {
     80        var fieldsets = document.getElementsByTagName('fieldset');
     81        for (var i = 0, fs; fs = fieldsets[i]; i++) {
     82            var classes = fs.className || fs.getAttribute("class");
     83            if ( (classes) && (classes.indexOf) && (classes.indexOf("wysiwyg") != -1) ) {
     84                var textareas = fs.getElementsByTagName('textarea');
     85                for (var j = 0, ta; ta = textareas[j]; j++) {
     86                    ta.setAttribute("dojoType", "Editor2");
     87                }
     88            }
     89        }
     90    },
     91}
     92
     93addEvent(window, 'load', AddEditor.init);
     94}}}
     95
     96This looks for all `fieldset`s with a `class` of `wysiwyg`, and then finds any contained `textarea`s and gives them
     97a `dojoType="Editor2"` attribute. The value of `help_text` is unimportant and shows up as normal.
Back to Top