[kupu-checkins] r35478 - in kupu/trunk/kupu: common doc

duncan at codespeak.net duncan at codespeak.net
Fri Dec 8 14:24:16 CET 2006


Author: duncan
Date: Fri Dec  8 14:24:14 2006
New Revision: 35478

Modified:
   kupu/trunk/kupu/common/kupubasetools.js
   kupu/trunk/kupu/common/kupusourceedit.js
   kupu/trunk/kupu/doc/CHANGES.txt
   kupu/trunk/kupu/doc/PLONE2.txt
Log:
Missed a few files on last checkin

Modified: kupu/trunk/kupu/common/kupubasetools.js
==============================================================================
--- kupu/trunk/kupu/common/kupubasetools.js	(original)
+++ kupu/trunk/kupu/common/kupubasetools.js	Fri Dec  8 14:24:14 2006
@@ -115,13 +115,17 @@
 // Helper function for enabling/disabling tools
 function KupuButtonDisable(button) {
     button = button || this.button;
-    button.disabled = "disabled";
-    button.className += ' disabled';
+    if (button) {
+        button.disabled = "disabled";
+        button.className += ' disabled';
+    }
 }
 function KupuButtonEnable(button) {
     button = button || this.button;
-    button.disabled = "";
-    button.className = button.className.replace(/ *\bdisabled\b/g, '');
+    if (button) {
+        button.disabled = "";
+        button.className = button.className.replace(/ *\bdisabled\b/g, '');
+    }
 }
 
 
@@ -143,6 +147,7 @@
 
 KupuButton.prototype.initialize = function(editor) {
     this.editor = editor;
+    if (!this.button) return;
     this._fixTabIndex(this.button);
     addEventHandler(this.button, 'click', this.execCommand, this);
 };
@@ -182,6 +187,7 @@
         
             if the state of the button should be changed, we set the class
         */
+        if (!this.button) return;
         var currclass = this.button.className;
         var newclass = null;
         if (this.checkfunc(selNode, this, this.editor, event)) {
@@ -265,8 +271,10 @@
         this.editor = editor;
         this.cleanStyles();
         this.enableOptions(false);
-        this._fixTabIndex(this.tsselect);
-        this._selectevent = addEventHandler(this.tsselect, 'change', this.setTextStyleHandler, this);
+        if (this.tsselect) {
+            this._fixTabIndex(this.tsselect);
+            this._selectevent = addEventHandler(this.tsselect, 'change', this.setTextStyleHandler, this);
+        }
     };
 
     this.getStyles = function() {
@@ -337,6 +345,7 @@
     };
 
     this.cleanStyles = function() {
+        if (!this.tsselect) return;
         var options = this.tsselect.options;
         var parastyles = this.styles;
         var tablestyles = this.tablestyles;
@@ -395,6 +404,7 @@
 
     // Remove otherstyle and switch to appropriate style set.
     this.enableOptions = function(inTable) {
+        if (!this.tsselect) return;
         var select = this.tsselect;
         var options = select.options;
         if (this.otherstyle) {
@@ -509,6 +519,7 @@
         // this method does some more than the original one since it can handle commands in
         // the form of '<style>|<classname>' next to the plain
         // '<style>' commands
+        if (!this.tsselect) return;
         var index = undefined;
         var mixed = false;
         var styletag, classname;
@@ -808,10 +819,10 @@
         return ret;
     };
     this.disable = function() {
-        this.tsselect.disabled = "disabled";
+        if (this.tsselect) this.tsselect.disabled = "disabled";
     }
     this.enable = function() {
-        this.tsselect.disabled = "";
+        if (this.tsselect) this.tsselect.disabled = "";
     }
 }
 
@@ -1179,6 +1190,7 @@
         /* attach the event handlers */
         this.tool = tool;
         this.editor = editor;
+        if (!this.button) return;
         addEventHandler(this.input, "blur", this.updateLink, this);
         addEventHandler(this.button, "click", this.addLink, this);
     };
@@ -2157,17 +2169,24 @@
     this.initialize = function(editor) {
         /* attach event handlers */
         this.editor = editor;
-        this._fixTabIndex(this.addulbutton);
-        this._fixTabIndex(this.addolbutton);
-        this._fixTabIndex(this.ulselect);
-        this._fixTabIndex(this.olselect);
-
-        addEventHandler(this.addulbutton, "click", this.addUnorderedList, this);
-        addEventHandler(this.addolbutton, "click", this.addOrderedList, this);
-        addEventHandler(this.ulselect, "change", this.setUnorderedListStyle, this);
-        addEventHandler(this.olselect, "change", this.setOrderedListStyle, this);
-        this.ulselect.style.display = "none";
-        this.olselect.style.display = "none";
+        if (this.addulbutton) {
+            this._fixTabIndex(this.addulbutton);
+            addEventHandler(this.addulbutton, "click", this.addUnorderedList, this);
+        }
+        if (this.addolbutton) {
+            this._fixTabIndex(this.addolbutton);
+            addEventHandler(this.addolbutton, "click", this.addOrderedList, this);
+        }
+        if (this.ulselect) {
+            this._fixTabIndex(this.ulselect);
+            addEventHandler(this.ulselect, "change", this.setUnorderedListStyle, this);
+            this.ulselect.style.display = "none";
+        }
+        if (this.olselect) {
+            this._fixTabIndex(this.olselect);
+            addEventHandler(this.olselect, "change", this.setOrderedListStyle, this);
+            this.olselect.style.display = "none";
+        }
 
         this.editor.logMessage(_('List style tool initialized'));
     };
@@ -2178,10 +2197,14 @@
         } else {
             var currstyle = this.type_to_style[currnode.getAttribute('type')];
         }
-        selectSelectItem(onselect, currstyle);
-        offselect.style.display = "none";
-        onselect.style.display = "inline";
-        offselect.selectedIndex = 0;
+        if (onselect) {
+            selectSelectItem(onselect, currstyle);
+            onselect.style.display = "inline";
+        }
+        if (offselect) {
+            offselect.style.display = "none";
+            offselect.selectedIndex = 0;
+        }
     };
 
     this.updateState = function(selNode) {
@@ -2198,19 +2221,19 @@
                 return;
             }
         }
-        with(this.ulselect) {
+        if (this.ulselect) with(this.ulselect) {
             selectedIndex = 0;
             style.display = "none";
         };
-        with(this.olselect) {
+        if (this.olselect) with(this.olselect) {
             selectedIndex = 0;
             style.display = "none";
         };
     };
 
     this.addList = function(command) {
-        this.ulselect.style.display = "inline";
-        this.olselect.style.display = "none";
+        if (this.ulselect) this.ulselect.style.display = "inline";
+        if (this.olselect) this.olselect.style.display = "none";
         this.editor.execCommand(command);
         this.editor.focusDocument();
     };
@@ -2226,6 +2249,7 @@
 
     this.setListStyle = function(tag, select) {
         /* set the type of an ul */
+        if (!select) return;
         var currnode = this.editor.getSelectedNode();
         var l = this.editor.getNearestParentOfType(currnode, tag);
         var style = select.options[select.selectedIndex].value;
@@ -2251,14 +2275,14 @@
     this.enable = function() {
         KupuButtonEnable(this.addulbutton);
         KupuButtonEnable(this.addolbutton);
-        this.ulselect.disabled = "";
-        this.olselect.disabled = "";
+        if (this.ulselect) this.ulselect.disabled = "";
+        if (this.olselect) this.olselect.disabled = "";
     }
     this.disable = function() {
         KupuButtonDisable(this.addulbutton);
         KupuButtonDisable(this.addolbutton);
-        this.ulselect.disabled = "disabled";
-        this.olselect.disabled = "disabled";
+        if (this.ulselect) this.ulselect.disabled = "disabled";
+        if (this.olselect) this.olselect.disabled = "disabled";
     }
 };
 
@@ -2343,6 +2367,7 @@
     this.initialize = function(editor) {
         /* initialize the tool */
         this.editor = editor;
+        if (!this.dlbutton) return;
         this._fixTabIndex(this.dlbutton);
         addEventHandler(this.dlbutton, 'click', this.createDefinitionList, this);
         addEventHandler(editor.getInnerDocument(), 'keyup', this._keyDownHandler, this);
@@ -2650,7 +2675,7 @@
         this.offclass = 'kupu-zoom';
         this.onclass = 'kupu-zoom-pressed';
         this.pressed = false;
-
+        if (!this.button) return;
         this.baseinitialize(editor);
         this.button.tabIndex = this.editor.document.editable.tabIndex;
         addEventHandler(window, "resize", this.onresize, this);

Modified: kupu/trunk/kupu/common/kupusourceedit.js
==============================================================================
--- kupu/trunk/kupu/common/kupusourceedit.js	(original)
+++ kupu/trunk/kupu/common/kupusourceedit.js	Fri Dec  8 14:24:14 2006
@@ -39,6 +39,7 @@
 SourceEditTool.prototype.initialize = function(editor) {
     /* attach the event handlers */
     this.editor = editor;
+    if (!this.sourceButton) return;
     this._fixTabIndex(this.sourceButton);
     addEventHandler(this.sourceButton, "click", this.switchSourceEdit, this);
     this.editor.logMessage(_('Source edit tool initialized'));

Modified: kupu/trunk/kupu/doc/CHANGES.txt
==============================================================================
--- kupu/trunk/kupu/doc/CHANGES.txt	(original)
+++ kupu/trunk/kupu/doc/CHANGES.txt	Fri Dec  8 14:24:14 2006
@@ -2,10 +2,16 @@
 Kupu changes
 ============
 
-- 1.4 unreleased
+- 1.4 Beta 3
 
   - Fixed a bug where createLink deleted the selected text.
 
+  - Paragraph styles may now be replaced as well as added to in a
+    widget definition.
+
+  - Toolbar buttons may be hidden globally, according to an 
+    expression, or from a widget definition.
+
 - 1.4 Beta 2
 
   - Paragraph styling now permitted inside a table again (contributed

Modified: kupu/trunk/kupu/doc/PLONE2.txt
==============================================================================
--- kupu/trunk/kupu/doc/PLONE2.txt	(original)
+++ kupu/trunk/kupu/doc/PLONE2.txt	Fri Dec  8 14:24:14 2006
@@ -399,6 +399,72 @@
         screen showing the proposed changes and may exclude any of them
         before confirming the search.
 
+toolbar tab
+===========
+
+This tab allows you to control which buttons and groups of buttons are
+displayed on the kupu toolbar. N.B. Be carefule, some combinations of
+buttons may render kupu hard to use.
+
+You may hide a button or group completely simply by unchecking the
+appropriate ``visible`` checkbox in this page. A button can only be
+visible if the group which contains it is also visible.
+
+You may enter an expression to control whether a button should be
+visible, e.g. to restrict buttons based on the user's roles.
+If there is an expression for a button the setting of the checkbox is
+ignored. The following values are available within the expression
+context:
+
+    field object_url folder_url portal_url object folder portal 
+    nothing request modules member
+
+The visibility of buttons may be further controlled within the widget
+definition for a field, but the this can only hide buttons, it cannot
+force a button to display if the settings on this tab have made it
+invisible. The widget allows for either a whitelist ``allow_buttons``
+attribute or a blacklist ``filter_buttons``. Either attribute should
+contain a list or tuple of button or group ids. The available ids are
+listed on the toolbar tab.
+
+If the widget has an attribute ``allow_buttons`` then only buttons and
+groups listed in this attribute will be visible; all other buttons are
+hidden. If there is no ``allow_buttons`` attribute (or its value is
+``None`` then all buttons are allowed unless excluded by
+``filter_buttons``.
+
+This example would hide all buttons except for bold, italic, left and
+right justify::
+
+        TextField('text',
+            allowable_content_types=('text/html',),
+            default_output_type='text/x-html-safe',
+            required=1,
+            widget=RichWidget
+            (label='Content',
+                allow_buttons=(
+                'bg-basicmarkup',
+                'bold-button', 'italic-button',
+                'bg-justify',
+                'justifyleft-button',
+                'justifyright-button',
+                ),
+            ),
+        ),
+
+This example would hide only the zoom button::
+
+        TextField('text',
+            allowable_content_types=('text/html',),
+            default_output_type='text/x-html-safe',
+            required=1,
+            widget=RichWidget
+            (label='Content',
+                filter_buttons=('zoom',
+                ),
+            ),
+        ),
+
 Custom styles
 -------------
 Kupu allows you to specify styles for paragraphs (P or DIV tags),
@@ -439,20 +505,27 @@
             widget=RichWidget
             (description='Please paste or type your article here',
                 label='Body Copy',
+                redefine_parastyles=False,
                 parastyles=(
-                 'div|pullQuote|Pull Quote',
-                 'div|Caption|Caption',
-                 'div|contactInformation|Contact Information',
-                 'div|notesToEditors|Notes to editors',
+                 'Pull Quote|div|pullQuote',
+                 'Caption|div|caption',
+                 'Contact Information|div|contactInformation',
+                 'Notes to editors|div|notesToEditors',
                 ),
             ),
         ),
 
 ``parastyles`` is a sequence of style definitions. Each definition
 should be a string as for the style definitions in the control panel
-containing the tag to be added, vertical bar, class to be assigned to
-the tag, vertical bar, description that appears in the style pulldown.
-The class may be omitted, so tag, vertical bar, description is also valid.
+containing the description that appears in the style pulldown, vertical
+bar, the tag to be added, vertical bar, class to be assigned to
+the tag.
+The class may be omitted, so description, vertical bar, tag is also valid.
+
+If the widget has an attribute ``redefine_parastyles`` which is true,
+then the styles defined for the field will replace the globally
+configured styles. If false or not set the field styles are added to
+the global styles.
 
 Images
 ------
@@ -471,6 +544,10 @@
 and the field you are editing must invoke the html-to-captioned output 
 transform.
 
+The field must have a default output type of text/x-html-safe or
+text/x-html-captioned otherwise image drawer will not include the
+caption option.
+
 If both of these conditions are filled, then the image drawer will
 include a checkbox for captioning an image. By default this is
 checked, turn it off to disable the caption on that image.
@@ -565,11 +642,6 @@
             widget=RichWidget
             (description='Please paste or type your article here',
                 label='Body Copy',
-                parastyles=(
-                 ('div|pullQuote','Pull Quote'),
-                 ('div|Caption','Caption'),
-                 ('div|contactInformation','Contact Information'),
-                 ('div|notesToEditors','Notes to editors'),
                 ),
             ),
         ),


More information about the kupu-checkins mailing list