From mihxil at codespeak.net Sat Apr 1 10:44:10 2006 From: mihxil at codespeak.net (mihxil@codespeak.net) Date: Sat Apr 1 10:44:11 2006 Subject: [kupu-checkins] r25203 - kupu/trunk/kupu/mmbase Message-ID: <20060401084410.3B610100C3@code0.codespeak.net> Author: mihxil Date: Sat Apr 1 10:44:09 2006 New Revision: 25203 Modified: kupu/trunk/kupu/mmbase/mmbase.js kupu/trunk/kupu/mmbase/mmbasedrawers.js kupu/trunk/kupu/mmbase/receive.jspx Log: Modified: kupu/trunk/kupu/mmbase/mmbase.js ============================================================================== --- kupu/trunk/kupu/mmbase/mmbase.js (original) +++ kupu/trunk/kupu/mmbase/mmbase.js Sat Apr 1 10:44:09 2006 @@ -156,7 +156,7 @@ function saveNode(button, editor) { // hmm, i think editor == kupu kupu.logMessage(_("Saving body (kupu)") + " " + currentNode); - editor.saveDocument(undefined, false); // kupu-part of save + editor.saveDocument(undefined, true); // kupu-part of save var content = ""; kupu.logMessage(_("Saving fields (form)") + " " + currentNode); Modified: kupu/trunk/kupu/mmbase/mmbasedrawers.js ============================================================================== --- kupu/trunk/kupu/mmbase/mmbasedrawers.js (original) +++ kupu/trunk/kupu/mmbase/mmbasedrawers.js Sat Apr 1 10:44:09 2006 @@ -37,7 +37,8 @@ // XXX requiring the user to know what link type to enter is a // little too much I think. (philiKON) var type = null; - var name = getFromSelector('link_name').value; + var elm = getFromSelector('link_name'); + var name = elm ? elm.value : ''; var target = null; if (getFromSelector('link_target') && getFromSelector('link_target').value != '') target = getFromSelector('link_target').value; Modified: kupu/trunk/kupu/mmbase/receive.jspx ============================================================================== --- kupu/trunk/kupu/mmbase/receive.jspx (original) +++ kupu/trunk/kupu/mmbase/receive.jspx Sat Apr 1 10:44:09 2006 @@ -10,10 +10,10 @@ KUPU-receiver - + - + false @@ -27,7 +27,6 @@ line = r.readLine(); } node.setStringValue("body", received.toString()); - node.commit(); log.debug("Saved " + received.toString()); From fschulze at codespeak.net Mon Apr 3 13:23:12 2006 From: fschulze at codespeak.net (fschulze@codespeak.net) Date: Mon Apr 3 13:23:15 2006 Subject: [kupu-checkins] r25247 - in kupu/trunk/kupu: Extensions common/kupudrawers plone plone/kupu_plone_layer plone/kupu_plone_layer/plonekupuimages Message-ID: <20060403112312.B8640100F4@code0.codespeak.net> Author: fschulze Date: Mon Apr 3 13:23:02 2006 New Revision: 25247 Added: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/image.gif - copied unchanged from r25115, kupu/branch/kupu-1.3/plone/kupu_plone_layer/plonekupuimages/image.gif Modified: kupu/trunk/kupu/Extensions/Install.py kupu/trunk/kupu/common/kupudrawers/drawer.xsl kupu/trunk/kupu/plone/__init__.py kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/anchor.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/bgcolor.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/bold.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/center.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/definitionlist.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/hr.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/hyperlink.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/indent.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/italic.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/left_just.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/list.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/numbered_list.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/outdent.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/redo.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/right_just.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/strikethrough.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/subscript.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/superscript.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/table.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/textcolor.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/tools.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/underline.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/undo.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/unformat.gif kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/view-source.gif kupu/trunk/kupu/plone/plonelibrarytool.py kupu/trunk/kupu/plone/wire.kupu Log: Merged changes from plone branch (this is the same as r25115 in the kupu-1.3 branch). Modified: kupu/trunk/kupu/Extensions/Install.py ============================================================================== --- kupu/trunk/kupu/Extensions/Install.py (original) +++ kupu/trunk/kupu/Extensions/Install.py Mon Apr 3 13:23:02 2006 @@ -41,6 +41,7 @@ # register the plone skin layers register_layer(self, 'plone/kupu_plone_layer', 'kupu_plone', out) register_layer(self, 'plone/kupu_references', 'kupu_references', out) + register_layer(self, 'tests', 'kupu_tests', out) # register as editor portal_props = getToolByName(self, 'portal_properties') Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl ============================================================================== --- kupu/trunk/kupu/common/kupudrawers/drawer.xsl (original) +++ kupu/trunk/kupu/common/kupudrawers/drawer.xsl Mon Apr 3 13:23:02 2006 @@ -414,7 +414,7 @@ - Modified: kupu/trunk/kupu/plone/__init__.py ============================================================================== --- kupu/trunk/kupu/plone/__init__.py (original) +++ kupu/trunk/kupu/plone/__init__.py Mon Apr 3 13:23:02 2006 @@ -24,6 +24,7 @@ kupu_package_dir = package_home(kupu_globals) registerDirectory('plone/kupu_plone_layer', kupu_package_dir) registerDirectory('plone/kupu_references', kupu_package_dir) +registerDirectory('tests', kupu_package_dir) def initialize(context): try: Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml Mon Apr 3 13:23:02 2006 @@ -11,16 +11,17 @@ /* $Id: kupuplone.css 7217 2004-11-11 13:20:56Z duncan $ */ /* - - - - - - - -*/ -/* */ +/* + * + * */ + +.kupu a { + color: &dtml-linkColor; !important; + background-color: transparent; + text-decoration: none !important; + border-bottom: 1px #cccccc solid !important; +} + div.kupu-toolboxes {display: none} @@ -138,64 +139,68 @@ .kupu-bold, -.kupu-bold-pressed {background-image: url("kupuimages/bold.gif");} +.kupu-bold-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/bold.gif");} -.kupu-forecolor {background-image: url("plonekupuimages/text-color.gif");} -.kupu-inthyperlink {background-image: url("plonekupuimages/anchor.gif");} +.kupu-forecolor {background-image: url("&dtml-portal_url;/plonekupuimages/text-color.gif");} +.kupu-inthyperlink {background-image: url("&dtml-portal_url;/plonekupuimages/hyperlink.gif");} .kupu-inthyperlink-pressed { border-color: &dtml-buttonshadow; &dtml-buttonhighlight; &dtml-buttonhighlight; &dtml-buttonshadow;; } -.kupu-exthyperlink {background-image: url("plonekupuimages/hyperlink.gif");} +.kupu-exthyperlink {background-image: url("&dtml-portal_url;/link_icon.gif");} .kupu-exthyperlink-pressed { border-color: &dtml-buttonshadow; &dtml-buttonhighlight; &dtml-buttonhighlight; &dtml-buttonshadow;; } -.kupu-image {background-image: url("kupuimages/image.png");} +.kupu-image {background-image: url("&dtml-portal_url;/plonekupuimages/image.gif");} -.kupu-indent {background-image: url("kupuimages/indent.gif");} -.kupu-inserthorizontalrule {background-image: url("plonekupuimages/hr.gif");} +.kupu-indent {background-image: url("&dtml-portal_url;/plonekupuimages/indent.gif");} +.kupu-inserthorizontalrule {background-image: url("&dtml-portal_url;/plonekupuimages/hr.gif");} .kupu-insertorderedlist, -.kupu-insertorderedlist-pressed {background-image: url("plonekupuimages/numbered_list.gif");} +.kupu-insertorderedlist-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/numbered_list.gif");} .kupu-insertunorderedlist, -.kupu-insertunorderedlist-pressed {background-image: url("plonekupuimages/list.gif");} +.kupu-insertunorderedlist-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/list.gif");} -.kupu-insertdefinitionlist {background-image: url("plonekupuimages/definitionlist.gif");} +.kupu-insertdefinitionlist {background-image: url("&dtml-portal_url;/plonekupuimages/definitionlist.gif");} .kupu-italic, -.kupu-italic-pressed {background-image: url("kupuimages/italic.gif");} +.kupu-italic-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/italic.gif");} .kupu-justifycenter, -.kupu-justifycenter-pressed {background-image: url("plonekupuimages/center.gif");} +.kupu-justifycenter-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/center.gif");} .kupu-justifyleft, -.kupu-justifyleft-pressed {background-image: url("plonekupuimages/left_just.gif");} +.kupu-justifyleft-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/left_just.gif");} .kupu-justifyright, -.kupu-justifyright-pressed {background-image: url("plonekupuimages/right_just.gif");} +.kupu-justifyright-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/right_just.gif");} -button.kupu-logo {background-image: url("kupuimages/kupu_icon.gif");} -.kupu-outdent {background-image: url("plonekupuimages/outdent.gif");} -.kupu-redo {background-image: url("plonekupuimages/redo.gif");} -.kupu-save {background-image: url("kupuimages/save.png");} -.kupu-save-and-exit {background-image: url("kupuimages/exit.gif");} -.kupu-space {background-image: url("plonekupuimages/space.gif");} -.kupu-source {background-image: url("plonekupuimages/view-source.gif");} +button.kupu-logo {background-image: url("&dtml-portal_url;/kupuimages/kupu_icon.gif");} +.kupu-outdent {background-image: url("&dtml-portal_url;/plonekupuimages/outdent.gif");} +.kupu-redo {background-image: url("&dtml-portal_url;/plonekupuimages/redo.gif");} +.kupu-save {background-image: url("&dtml-portal_url;/plonekupuimages/save.png");} +.kupu-save-and-exit {background-image: url("&dtml-portal_url;/kupuimages/exit.gif");} +.kupu-space {background-image: url("&dtml-portal_url;/plonekupuimages/space.gif");} +.kupu-source {background-image: url("&dtml-portal_url;/plonekupuimages/view-source.gif");} .kupu-subscript, -.kupu-subscript-pressed {background-image: url("plonekupuimages/subscript.gif");} +.kupu-subscript-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/subscript.gif");} .kupu-superscript, -.kupu-superscript-pressed {background-image: url("plonekupuimages/superscript.gif");} +.kupu-superscript-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/superscript.gif");} -.kupu-table {background-image: url("plonekupuimages/table.gif");} +.kupu-table {background-image: url("&dtml-portal_url;/plonekupuimages/table.gif");} .kupu-underline, -.kupu-underline-pressed {background-image: url("kupuimages/underline.gif");} +.kupu-underline-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/underline.gif");} -.kupu-undo {background-image: url("plonekupuimages/undo.gif");} -.kupu-removelink {background-image: url("plonekupuimages/delete_icon.gif");} -.kupu-removeimage {background-image: url("plonekupuimages/delete_icon.gif");} +.kupu-undo {background-image: url("&dtml-portal_url;/plonekupuimages/undo.gif");} +.kupu-removelink {background-image: url("&dtml-portal_url;/plonekupuimages/delete_icon.gif");} +.kupu-removeimage {background-image: url("&dtml-portal_url;/plonekupuimages/delete_icon.gif");} .kupu-spellchecker { display:none; } +.kupu-zoom {background-image: url("&dtml-portal_url;/plonekupuimages/fullscreenexpand_icon.gif");} +.kupu-zoom-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/fullscreencollapse_icon.gif");} + + div.kupu-drawer { border: solid 1px &dtml-contentViewBorderColor;; background-color: &dtml-contentViewBackgroundColor;; @@ -269,5 +274,10 @@ .even .kupu-preview-row { background-color: &dtml-evenRowBackgroundColor;; } + +#kupu-logo-button { + display: none; +} + /* */ Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/anchor.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/bgcolor.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/bold.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/center.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/definitionlist.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/hr.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/hyperlink.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/indent.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/italic.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/left_just.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/list.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/numbered_list.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/outdent.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/redo.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/right_just.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/strikethrough.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/subscript.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/superscript.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/table.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/textcolor.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/tools.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/underline.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/undo.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/unformat.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/view-source.gif ============================================================================== Binary files. No diff available. Modified: kupu/trunk/kupu/plone/plonelibrarytool.py ============================================================================== --- kupu/trunk/kupu/plone/plonelibrarytool.py (original) +++ kupu/trunk/kupu/plone/plonelibrarytool.py Mon Apr 3 13:23:02 2006 @@ -75,9 +75,12 @@ _style_whitelist = ['text-align', 'list-style-type', 'float'] _default_paragraph_styles = ( - "Heading|h2|Heading", - "Subheading|h3|Subheading", - "Formatted|pre", + "Heading|h2", + "Subheading|h3", + "Literal|pre", + "Discreet|p|discreet", + "Pull-quote|blockquote|pullquote", + "Call-out|p|callout" ) class PloneKupuLibraryTool(UniqueObject, SimpleItem, KupuLibraryTool, Modified: kupu/trunk/kupu/plone/wire.kupu ============================================================================== --- kupu/trunk/kupu/plone/wire.kupu (original) +++ kupu/trunk/kupu/plone/wire.kupu Mon Apr 3 13:23:02 2006 @@ -44,4 +44,25 @@ + + + + + + + + + + + + + + + + + + + + + From fschulze at codespeak.net Mon Apr 3 14:22:31 2006 From: fschulze at codespeak.net (fschulze@codespeak.net) Date: Mon Apr 3 14:22:33 2006 Subject: [kupu-checkins] r25249 - in kupu/branch/plone-2.1: default plone plone/kupu_plone_layer Message-ID: <20060403122231.1686E100E8@code0.codespeak.net> Author: fschulze Date: Mon Apr 3 14:22:25 2006 New Revision: 25249 Modified: kupu/branch/plone-2.1/default/drawers.kupu kupu/branch/plone-2.1/default/sourceedit.kupu kupu/branch/plone-2.1/default/spellchecker.kupu kupu/branch/plone-2.1/default/toolbar.kupu kupu/branch/plone-2.1/plone/body.kupu kupu/branch/plone-2.1/plone/kupu_plone_layer/kupu_wysiwyg_support.html kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuplone.css.dtml kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuploneinit.js kupu/branch/plone-2.1/plone/toolbar.kupu kupu/branch/plone-2.1/plone/wysiwyg_support.kupu Log: Cleaning up behind limi. Make all his changes in the proper places. Modified: kupu/branch/plone-2.1/default/drawers.kupu ============================================================================== --- kupu/branch/plone-2.1/default/drawers.kupu (original) +++ kupu/branch/plone-2.1/default/drawers.kupu Mon Apr 3 14:22:25 2006 @@ -20,13 +20,13 @@ + title="Insert image" i18n:attributes="title">  + title="Insert internal link" i18n:attributes="title">  + title="Insert external link" i18n:attributes="title">  + title="Insert table" i18n:attributes="title">  Modified: kupu/branch/plone-2.1/default/sourceedit.kupu ============================================================================== --- kupu/branch/plone-2.1/default/sourceedit.kupu (original) +++ kupu/branch/plone-2.1/default/sourceedit.kupu Mon Apr 3 14:22:25 2006 @@ -23,7 +23,7 @@ Modified: kupu/branch/plone-2.1/default/spellchecker.kupu ============================================================================== --- kupu/branch/plone-2.1/default/spellchecker.kupu (original) +++ kupu/branch/plone-2.1/default/spellchecker.kupu Mon Apr 3 14:22:25 2006 @@ -17,7 +17,7 @@ Modified: kupu/branch/plone-2.1/default/toolbar.kupu ============================================================================== --- kupu/branch/plone-2.1/default/toolbar.kupu (original) +++ kupu/branch/plone-2.1/default/toolbar.kupu Mon Apr 3 14:22:25 2006 @@ -46,7 +46,7 @@ + title="Zoom: Access key (Alt or Ctrl) + X" accesskey="x">  @@ -89,20 +89,20 @@ - - - - - @@ -110,13 +110,13 @@ @@ -125,10 +125,10 @@ @@ -137,7 +137,7 @@ @@ -145,10 +145,10 @@ @@ -156,10 +156,10 @@ Modified: kupu/branch/plone-2.1/plone/body.kupu ============================================================================== --- kupu/branch/plone-2.1/plone/body.kupu (original) +++ kupu/branch/plone-2.1/plone/body.kupu Mon Apr 3 14:22:25 2006 @@ -74,7 +74,7 @@ i18n:translate="suppress-kupu" tal:attributes="href string:${request/URL0}?kupu.suppress=${fieldName};" title="reload current page without kupu"> - Edit with visual editor + Edit without visual editor Modified: kupu/branch/plone-2.1/plone/kupu_plone_layer/kupu_wysiwyg_support.html ============================================================================== --- kupu/branch/plone-2.1/plone/kupu_plone_layer/kupu_wysiwyg_support.html (original) +++ kupu/branch/plone-2.1/plone/kupu_plone_layer/kupu_wysiwyg_support.html Mon Apr 3 14:22:25 2006 @@ -8,20 +8,20 @@ - + - + - + - - + + @@ -120,9 +120,6 @@ - @@ -131,7 +128,6 @@ - @@ -359,11 +355,11 @@ - Modified: kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuplone.css.dtml ============================================================================== --- kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuplone.css.dtml (original) +++ kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuplone.css.dtml Mon Apr 3 14:22:25 2006 @@ -198,7 +198,7 @@ .kupu-table {background-image: url("&dtml-portal_url;/plonekupuimages/table.gif");} .kupu-underline, -.kupu-underline-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/underline.gif"); display: none;} +.kupu-underline-pressed {background-image: url("&dtml-portal_url;/plonekupuimages/underline.gif");} .kupu-undo {background-image: url("&dtml-portal_url;/plonekupuimages/undo.gif");} .kupu-removelink {background-image: url("&dtml-portal_url;/plonekupuimages/delete_icon.gif");} @@ -247,8 +247,4 @@ background-color: white; } -#kupu-logo-button { - display: none; -} - /* */ Modified: kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuploneinit.js ============================================================================== --- kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuploneinit.js (original) +++ kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuploneinit.js Mon Apr 3 14:22:25 2006 @@ -66,6 +66,7 @@ 'kupu-italic-pressed'); kupu.registerTool('italicsbutton', italicsbutton); + /* disabled var underlinechecker = ParentWithStyleChecker(new Array('u')); var underlinebutton = new KupuStateButton(prefix+'button.kupu-underline', execCommand('underline'), @@ -73,6 +74,7 @@ 'kupu-underline', 'kupu-underline-pressed'); kupu.registerTool('underlinebutton', underlinebutton); + */ var subscriptchecker = ParentWithStyleChecker(new Array('sub')); var subscriptbutton = new KupuStateButton(prefix+'button.kupu-subscript', @@ -150,16 +152,24 @@ var linktool = NoContextMenu(new LinkTool()); kupu.registerTool('linktool', linktool); + /* disabled var zoom = new KupuZoomTool(prefix+'button.kupu-zoom', prefix+'select.kupu-tb-styles', prefix+'button.kupu-logo'); kupu.registerTool('zoomtool', zoom); + */ // XXX - Needs prefix here for multi area support, but also // added to the template - var spellchecker = new KupuSpellChecker('kupu-spellchecker-button', - 'kupu_library_tool/spellcheck'); - kupu.registerTool('spellchecker', spellchecker); + if (typeof KupuSpellChecker != 'undefined') { + var spellchecker = new KupuSpellChecker('kupu-spellchecker-button', + 'kupu_library_tool/spellcheck'); + kupu.registerTool('spellchecker', spellchecker); + } else { + // hide the button when not available + var spellchecker_tool = document.getElementById('kupu-spellchecker'); + spellchecker_tool.style.display = 'none'; + } // Use the generic beforeUnload handler if we have it: var beforeunloadTool = window.onbeforeunload && window.onbeforeunload.tool; Modified: kupu/branch/plone-2.1/plone/toolbar.kupu ============================================================================== --- kupu/branch/plone-2.1/plone/toolbar.kupu (original) +++ kupu/branch/plone-2.1/plone/toolbar.kupu Mon Apr 3 14:22:25 2006 @@ -9,11 +9,6 @@ $Id$ - @@ -35,4 +30,14 @@ + + + + + + + + Modified: kupu/branch/plone-2.1/plone/wysiwyg_support.kupu ============================================================================== --- kupu/branch/plone-2.1/plone/wysiwyg_support.kupu (original) +++ kupu/branch/plone-2.1/plone/wysiwyg_support.kupu Mon Apr 3 14:22:25 2006 @@ -74,7 +74,7 @@ Convert to HTML and edit with Kupu + tal:attributes="href string:${request/URL0}?kupu.convert=${fieldName};">Convert to HTML and edit with the visual editor From fschulze at codespeak.net Mon Apr 3 14:32:44 2006 From: fschulze at codespeak.net (fschulze@codespeak.net) Date: Mon Apr 3 14:32:45 2006 Subject: [kupu-checkins] r25250 - in kupu/trunk/kupu/common: . kupudrawers Message-ID: <20060403123244.5A31D100E8@code0.codespeak.net> Author: fschulze Date: Mon Apr 3 14:32:42 2006 New Revision: 25250 Modified: kupu/trunk/kupu/common/kupudrawers.js kupu/trunk/kupu/common/kupudrawers/drawer.xsl Log: Added optional image size selector. Use the following syntax in collections: [url to the image of this size] Modified: kupu/trunk/kupu/common/kupudrawers.js ============================================================================== --- kupu/trunk/kupu/common/kupudrawers.js (original) +++ kupu/trunk/kupu/common/kupudrawers.js Mon Apr 3 14:32:42 2006 @@ -1286,7 +1286,13 @@ return; }; - var uri = selnode.selectSingleNode('uri/text()').nodeValue; + var sizeselector = document.getElementsByName('image-size-selector'); + if (sizeselector && sizeselector.length > 0) { + sizeselector = sizeselector[0]; + var uri = sizeselector.options[sizeselector.selectedIndex].value; + } else { + var uri = selnode.selectSingleNode('uri/text()').nodeValue; + } uri = uri.strip(); // needs kupuhelpers.js var alt = getFromSelector('image_alt'); alt = alt?alt.value:undefined; Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl ============================================================================== --- kupu/trunk/kupu/common/kupudrawers/drawer.xsl (original) +++ kupu/trunk/kupu/common/kupudrawers/drawer.xsl Mon Apr 3 14:32:42 2006 @@ -332,6 +332,12 @@ + + +
display:none; @@ -343,6 +349,11 @@
+ + + From fschulze at codespeak.net Tue Apr 4 15:03:19 2006 From: fschulze at codespeak.net (fschulze@codespeak.net) Date: Tue Apr 4 15:03:21 2006 Subject: [kupu-checkins] r25289 - kupu/branch/plone-2.1/plone/kupu_plone_layer Message-ID: <20060404130319.AFE0710128@code0.codespeak.net> Author: fschulze Date: Tue Apr 4 15:03:17 2006 New Revision: 25289 Modified: kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuInfoForBrains.py kupu/branch/plone-2.1/plone/kupu_plone_layer/kupucollection.xml.pt Log: Enabled image size selector for standard collections. Modified: kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuInfoForBrains.py ============================================================================== --- kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuInfoForBrains.py (original) +++ kupu/branch/plone-2.1/plone/kupu_plone_layer/kupuInfoForBrains.py Tue Apr 4 15:03:17 2006 @@ -32,6 +32,30 @@ base = context.absolute_url() security = AccessControl.getSecurityManager() +image_sizes_cache = {} + +def get_image_sizes(obj, portal_type, url): + if not image_sizes_cache.has_key(portal_type): + image_sizes_cache[portal_type] = {} + if getattr(obj, 'getObject', None) is not None: + obj = obj.getObject() + if getattr(obj, 'getField', None) is None: + return + image_field = obj.getWrappedField('image') + if image_field is None: + return + if getattr(image_field, 'getAvailableSizes', None) is None: + return + image_sizes_cache[portal_type] = image_field.getAvailableSizes(obj) + image_sizes = image_sizes_cache[portal_type] + results = [] + sizes = [((v[0], v[1]), k) for k,v in image_sizes.items()] + sizes.sort() + for size, key in sizes: + results.append({'label':"%s (%s, %s)" % (key.capitalize(), size[0], size[1]), + 'uri':"%s/image_%s" % (url, key)}) + return results + def info_object(obj, allowCollection=True): '''Get information from a content object''' @@ -58,6 +82,8 @@ width = height = size = None preview = obj.getTypeInfo().getActionById(preview_action, None) + sizes = get_image_sizes(obj, portal_type, url) + try: size = context.getObjSize(obj) except: @@ -74,7 +100,7 @@ return {'id': id, 'url': url, 'portal_type': portal_type, 'collection': collection, 'icon': icon, 'size': size, - 'width': width, 'height': height, + 'width': width, 'height': height, 'sizes': sizes, 'preview': preview, 'title': title, 'description': description, } except Unauthorized: @@ -108,6 +134,8 @@ width = height = size = None preview = types_tool.getTypeInfo(brain.portal_type).getActionById(preview_action, None) + sizes = get_image_sizes(brain, portal_type, url) + # It would be nice to do everything from the brain, but # unfortunately we need to get the object for the preview size. # XXX Figure out some way to get the image size client side @@ -126,7 +154,7 @@ return {'id': id, 'url': url, 'portal_type': portal_type, 'collection': collection, 'icon': icon, 'size': size, - 'width': width, 'height': height, + 'width': width, 'height': height, 'sizes': sizes, 'preview': preview, 'title': title, 'description': description, } Modified: kupu/branch/plone-2.1/plone/kupu_plone_layer/kupucollection.xml.pt ============================================================================== --- kupu/branch/plone-2.1/plone/kupu_plone_layer/kupucollection.xml.pt (original) +++ kupu/branch/plone-2.1/plone/kupu_plone_layer/kupucollection.xml.pt Tue Apr 4 15:03:17 2006 @@ -65,6 +65,14 @@ tal:content="info/title">title description + + + + + + From fschulze at codespeak.net Tue Apr 4 15:06:05 2006 From: fschulze at codespeak.net (fschulze@codespeak.net) Date: Tue Apr 4 15:06:07 2006 Subject: [kupu-checkins] r25290 - kupu/branch/plone-2.1/doc Message-ID: <20060404130605.E0B2C10128@code0.codespeak.net> Author: fschulze Date: Tue Apr 4 15:06:04 2006 New Revision: 25290 Modified: kupu/branch/plone-2.1/doc/CHANGES.txt Log: Updated. Modified: kupu/branch/plone-2.1/doc/CHANGES.txt ============================================================================== --- kupu/branch/plone-2.1/doc/CHANGES.txt (original) +++ kupu/branch/plone-2.1/doc/CHANGES.txt Tue Apr 4 15:06:04 2006 @@ -2,6 +2,20 @@ Kupu changes ============ +- 1.3.6 + + - Plone + + * Enabled selection of image sizes in standard libraries. + + - General + + * Added optional list of server provided image sizes. + +- 1.3.5 + + ?? no entries + - 1.3.4 - Silva From fschulze at codespeak.net Wed Apr 5 14:18:42 2006 From: fschulze at codespeak.net (fschulze@codespeak.net) Date: Wed Apr 5 14:18:43 2006 Subject: [kupu-checkins] r25376 - in kupu/trunk/kupu/plone: . kupu_plone_layer Message-ID: <20060405121842.57EB5101D9@code0.codespeak.net> Author: fschulze Date: Wed Apr 5 14:18:40 2006 New Revision: 25376 Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupucollection.xml.pt kupu/trunk/kupu/plone/plonedrawers.py Log: Enabled image sizes selector. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupucollection.xml.pt ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/kupucollection.xml.pt (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/kupucollection.xml.pt Wed Apr 5 14:18:40 2006 @@ -58,6 +58,14 @@ tal:content="info/title">title description + + + + + + Source Modified: kupu/trunk/kupu/plone/plonedrawers.py ============================================================================== --- kupu/trunk/kupu/plone/plonedrawers.py (original) +++ kupu/trunk/kupu/plone/plonedrawers.py Wed Apr 5 14:18:40 2006 @@ -15,6 +15,7 @@ """ import re +from thread import get_ident from Products.CMFCore.utils import getToolByName from AccessControl import Unauthorized, ClassSecurityInfo, getSecurityManager from Globals import InitializeClass @@ -32,6 +33,10 @@ UIDURL = re.compile(".*\\bresolveuid/([^/?#]+)") +# mapping (thread-id, portal-physicalPath, portal_type) -> +# imagefield-getAvailableSizes (as tuple sorted by dimension) (width, height, key) +IMAGE_SIZES_CACHE = {} + class ResourceType: '''Resource types are wrapped into a class so we can easily access attributes which may, or may not be present. @@ -153,8 +158,8 @@ self.linkbyuid = tool.getLinkbyuid() self.coll_types = tool.getResourceType('collection').portal_types self.anchor_types = tool.getResourceType('containsanchors').portal_types - portal_base = self.url_tool.getPortalPath() - self.prefix_length = len(portal_base)+1 + self.portal_base = self.url_tool.getPortalPath() + self.prefix_length = len(self.portal_base)+1 self.resource_type = tool.getResourceType(resource_type) instance = tool.REQUEST.get('instance', '') @@ -210,6 +215,35 @@ if callable(height): height = height() return size, width, height + def get_image_sizes(self, obj, portal_type, url): + cache_key = (get_ident(), self.portal_base, portal_type) + if not IMAGE_SIZES_CACHE.has_key(cache_key): + IMAGE_SIZES_CACHE[cache_key] = {} + # if getId is not callable, we assume that we have a brain and + # need to get the object + if not callable(obj.getId): + if getattr(obj, 'getObject', None) is None: + return + obj = obj.getObject() + if getattr(obj, 'getField', None) is None: + return + image_field = obj.getWrappedField('image') + if image_field is None: + return + if getattr(image_field, 'getAvailableSizes', None) is None: + return + image_sizes = image_field.getAvailableSizes(obj) + sizes = [((v[0], v[1]), k) for k,v in image_sizes.items()] + sizes.sort() + IMAGE_SIZES_CACHE[cache_key] = sizes + else: + sizes = IMAGE_SIZES_CACHE[cache_key] + results = [] + for size, key in sizes: + results.append({'label':"%s (%s, %s)" % (key.capitalize(), size[0], size[1]), + 'uri':"%s/image_%s" % (url, key)}) + return results + def getState(self, review_state): if review_state: className = 'state-'+review_state @@ -245,6 +279,8 @@ url = obj.absolute_url() preview = self.tool.getPreviewUrl(portal_type, url) + sizes = self.get_image_sizes(obj, portal_type, url) + if collection and self.resource_type.allow_browse: src = obj.absolute_url() if not src.endswith('/'): src += '/' @@ -279,6 +315,7 @@ 'width': width, 'height': height, 'preview': preview, + 'sizes': sizes, 'title': title, 'description': description, 'linkable': linkable, @@ -299,6 +336,8 @@ collection = portal_type in self.coll_types preview = self.tool.getPreviewUrl(portal_type, url) + sizes = self.get_image_sizes(brain, portal_type, url) + # Path for the uid catalog doesn't have the leading '/' path = brain.getPath() UID = None @@ -346,6 +385,7 @@ 'width': width, 'height': height, 'preview': preview, + 'sizes': sizes, 'title': title, 'description': description, 'linkable': linkable, From guido at codespeak.net Thu Apr 6 12:26:27 2006 From: guido at codespeak.net (guido@codespeak.net) Date: Thu Apr 6 12:26:28 2006 Subject: [kupu-checkins] r25436 - kupu/trunk/kupu/common Message-ID: <20060406102627.07B7310223@code0.codespeak.net> Author: guido Date: Thu Apr 6 12:26:26 2006 New Revision: 25436 Modified: kupu/trunk/kupu/common/kupusourceedit.js Log: Ported change in the way objects are defined from 1.3 branch. Modified: kupu/trunk/kupu/common/kupusourceedit.js ============================================================================== --- kupu/trunk/kupu/common/kupusourceedit.js (original) +++ kupu/trunk/kupu/common/kupusourceedit.js Thu Apr 6 12:26:26 2006 @@ -17,104 +17,112 @@ this.sourcemode = false; this._currently_editing = null; + // method defined inline to support closure + // XXX would be nice to have this defined on the prototype too, because + // of subclassing issues? this.getSourceArea = function() { return getFromSelector(sourceareaid); - } + }; +}; - this.cancelSourceMode = function() { - if (this._currently_editing) { - this.switchSourceEdit(null, true); - } +SourceEditTool.prototype = new KupuTool; + +SourceEditTool.prototype.cancelSourceMode = function() { + if (this._currently_editing) { + this.switchSourceEdit(null, true); } - this.updateState = this.cancelSourceMode; +}; - this.initialize = function(editor) { - /* attach the event handlers */ - this.editor = editor; - this._fixTabIndex(this.sourceButton); - addEventHandler(this.sourceButton, "click", this.switchSourceEdit, this); - this.editor.logMessage(_('Source edit tool initialized')); - }; - - this.switchSourceEdit = function(event, nograb) { - var kupu = this.editor; - var docobj = this._currently_editing||kupu.getDocument(); - var editorframe = docobj.getEditable(); - var sourcearea = this.getSourceArea(); - var kupudoc = docobj.getDocument(); - var sourceClass = 'kupu-sourcemode'; - - if (!this.sourcemode) { - if (window.drawertool) { - window.drawertool.closeDrawer(); - } - if (/on/i.test(kupudoc.designMode)) { - kupudoc.designMode = 'Off'; - }; - kupu._initialized = false; - - var data=''; - if(kupu.config.filtersourceedit) { - window.status = _('Cleaning up HTML...'); - var transform = kupu._filterContent(kupu.getInnerDocument().documentElement); - data = kupu.getXMLBody(transform); - data = kupu._fixupSingletons(data).replace(/<\/?body[^>]*>/g, ""); - window.status = ''; - } else { - data = kupu.getHTMLBody(); - } - data = data.replace( - /\s*(<(p|div|h.|ul|ol|dl|menu|dir|pre|blockquote|address|center|table|thead|tbody|tfoot|tr|th|td))\b/g, '\n$1').strip(); - sourcearea.value = data; - kupu.setClass(sourceClass); - editorframe.style.display = 'none'; - sourcearea.style.display = 'block'; - if (!nograb) { - sourcearea.focus(); - }; - this._currently_editing = docobj; - } else { - kupu.setHTMLBody(sourcearea.value); - kupu.clearClass(sourceClass); - sourcearea.style.display = 'none'; - editorframe.style.display = 'block'; - if (/off/i.test(kupudoc.designMode)) { - kupudoc.designMode = 'On'; - }; - if (!nograb) { - docobj.getWindow().focus(); - var selection = this.editor.getSelection(); - selection.collapse(); - }; +SourceEditTool.prototype.updateState = + SourceEditTool.prototype.cancelSourceMode; - kupu._initialized = true; - this._currently_editing = null; +SourceEditTool.prototype.initialize = function(editor) { + /* attach the event handlers */ + this.editor = editor; + this._fixTabIndex(this.sourceButton); + addEventHandler(this.sourceButton, "click", this.switchSourceEdit, this); + this.editor.logMessage(_('Source edit tool initialized')); +}; + +SourceEditTool.prototype.switchSourceEdit = function(event, nograb) { + var kupu = this.editor; + var docobj = this._currently_editing||kupu.getDocument(); + var editorframe = docobj.getEditable(); + var sourcearea = this.getSourceArea(); + var kupudoc = docobj.getDocument(); + var sourceClass = 'kupu-sourcemode'; + + if (!this.sourcemode) { + if (window.drawertool) { + window.drawertool.closeDrawer(); + } + if (/on/i.test(kupudoc.designMode)) { + kupudoc.designMode = 'Off'; + }; + kupu._initialized = false; + + var data=''; + if(kupu.config.filtersourceedit) { + window.status = _('Cleaning up HTML...'); + var transform = kupu._filterContent( + kupu.getInnerDocument().documentElement); + data = kupu.getXMLBody(transform); + data = kupu._fixupSingletons(data).replace(/<\/?body[^>]*>/g, ""); + window.status = ''; + } else { + data = kupu.getHTMLBody(); + } + data = data.replace( + /\s*(<(p|div|h.|ul|ol|dl|menu|dir|pre|blockquote|address|center|table|thead|tbody|tfoot|tr|th|td))\b/g, '\n$1').strip(); + sourcearea.value = data; + kupu.setClass(sourceClass); + editorframe.style.display = 'none'; + sourcearea.style.display = 'block'; + if (!nograb) { + sourcearea.focus(); + }; + this._currently_editing = docobj; + } else { + kupu.setHTMLBody(sourcearea.value); + kupu.clearClass(sourceClass); + sourcearea.style.display = 'none'; + editorframe.style.display = 'block'; + if (/off/i.test(kupudoc.designMode)) { + kupudoc.designMode = 'On'; }; - this.sourcemode = !this.sourcemode; + if (!nograb) { + docobj.getWindow().focus(); + var selection = this.editor.getSelection(); + selection.collapse(); + }; + + kupu._initialized = true; + this._currently_editing = null; + this.editor.updateState(); }; - this.enable = function() { - KupuButtonEnable(this.sourceButton); - } - this.disable = function() { - KupuButtonDisable(this.sourceButton); - } + this.sourcemode = !this.sourcemode; }; -SourceEditTool.prototype = new KupuTool; +SourceEditTool.prototype.enable = function() { + KupuButtonEnable(this.sourceButton); +}; + +SourceEditTool.prototype.disable = function() { + KupuButtonDisable(this.sourceButton); +}; function MultiSourceEditTool(sourcebuttonid, textareaprefix) { /* Source edit tool to edit document's html source */ this.sourceButton = getFromSelector(sourcebuttonid); this.textareaprefix = textareaprefix; - this.getSourceArea = function() { - var docobj = this._currently_editing||kupu.getDocument(); - var sourceareaid = this.textareaprefix + docobj.getEditable().id; - return getFromSelector(sourceareaid); - } - this._currently_editing = null; - }; MultiSourceEditTool.prototype = new SourceEditTool; + +MultiSourceEditTool.prototype.getSourceArea = function() { + var docobj = this._currently_editing||kupu.getDocument(); + var sourceareaid = this.textareaprefix + docobj.getEditable().id; + return getFromSelector(sourceareaid); +}; From guido at codespeak.net Thu Apr 6 12:26:52 2006 From: guido at codespeak.net (guido@codespeak.net) Date: Thu Apr 6 12:26:54 2006 Subject: [kupu-checkins] r25437 - kupu/trunk/kupu/common Message-ID: <20060406102652.049F810223@code0.codespeak.net> Author: guido Date: Thu Apr 6 12:26:51 2006 New Revision: 25437 Modified: kupu/trunk/kupu/common/kupuhelpers.js Log: Made apostrophes get escaped too, using '. Modified: kupu/trunk/kupu/common/kupuhelpers.js ============================================================================== --- kupu/trunk/kupu/common/kupuhelpers.js (original) +++ kupu/trunk/kupu/common/kupuhelpers.js Thu Apr 6 12:26:51 2006 @@ -1324,6 +1324,7 @@ String.prototype.entitize = function() { var ret = this.replace(/&/g, '&'); ret = ret.replace(/"/g, '"'); + ret = ret.replace(/'/g, '''); ret = ret.replace(//g, '>'); return ret; @@ -1332,6 +1333,7 @@ String.prototype.deentitize = function() { var ret = this.replace(/>/g, '>'); ret = ret.replace(/</g, '<'); + ret = ret.replace(/'/g, "'"); ret = ret.replace(/"/g, '"'); ret = ret.replace(/&/g, '&'); return ret; From guido at codespeak.net Thu Apr 6 12:27:13 2006 From: guido at codespeak.net (guido@codespeak.net) Date: Thu Apr 6 12:27:14 2006 Subject: [kupu-checkins] r25438 - kupu/trunk/kupu/common Message-ID: <20060406102713.4246F10224@code0.codespeak.net> Author: guido Date: Thu Apr 6 12:27:12 2006 New Revision: 25438 Modified: kupu/trunk/kupu/common/kupusaveonpart.js Log: Chaged message displayed when leaving the page. Modified: kupu/trunk/kupu/common/kupusaveonpart.js ============================================================================== --- kupu/trunk/kupu/common/kupusaveonpart.js (original) +++ kupu/trunk/kupu/common/kupusaveonpart.js Thu Apr 6 12:27:12 2006 @@ -12,8 +12,9 @@ function saveOnPart() { /* ask the user if (s)he wants to save the document before leaving */ - if (kupu.content_changed && - confirm(_('You have unsaved changes. Do you want to save before leaving the page?'))) { + if (kupu.content_changed && confirm( + _('You are leaving the editor. Do you want to save your changes?') + )) { kupu.config.reload_src = 0; kupu.saveDocument(false, true); }; From guido at codespeak.net Thu Apr 6 12:28:04 2006 From: guido at codespeak.net (guido@codespeak.net) Date: Thu Apr 6 12:28:05 2006 Subject: [kupu-checkins] r25439 - kupu/trunk/kupu/common Message-ID: <20060406102804.35EAE10223@code0.codespeak.net> Author: guido Date: Thu Apr 6 12:28:03 2006 New Revision: 25439 Modified: kupu/trunk/kupu/common/kuputoolcollapser.js Log: Made opened classname get set when toolboxes are displayed with an initial opened state. Modified: kupu/trunk/kupu/common/kuputoolcollapser.js ============================================================================== --- kupu/trunk/kupu/common/kuputoolcollapser.js (original) +++ kupu/trunk/kupu/common/kuputoolcollapser.js Thu Apr 6 12:28:03 2006 @@ -57,6 +57,9 @@ if (initial_state[child.id] === undefined || initial_state[child.id] == '0') { body.style.display = 'none'; + } else { + heading.className = 'kupu-toolbox-heading-opened'; + heading.setAttribute('title', _('click to fold')); }; // add a reference to the openhandler on the toolbox div // so any toolbox code can use that to open the toolbox if From guido at codespeak.net Thu Apr 6 12:28:45 2006 From: guido at codespeak.net (guido@codespeak.net) Date: Thu Apr 6 12:28:45 2006 Subject: [kupu-checkins] r25440 - kupu/trunk/kupu Message-ID: <20060406102845.93E0C10232@code0.codespeak.net> Author: guido Date: Thu Apr 6 12:28:45 2006 New Revision: 25440 Modified: kupu/trunk/kupu/__init__.py Log: Changing Zope 2 imports to comply with recent Zope changes ('import Zope' is deprecated in favour of 'import Zope2', both will be tried now in __init__.py). Modified: kupu/trunk/kupu/__init__.py ============================================================================== --- kupu/trunk/kupu/__init__.py (original) +++ kupu/trunk/kupu/__init__.py Thu Apr 6 12:28:45 2006 @@ -20,10 +20,17 @@ # test for Zope2 try: - import Zope + import Zope2 as Zope have_zope2 = 1 except ImportError: have_zope2 = 0 + +if not have_zope2: + try: + import Zope + have_zope2 = 1 + except ImportError: + have_zope2 = 0 # test for CMF try: From guido at codespeak.net Thu Apr 6 12:29:04 2006 From: guido at codespeak.net (guido@codespeak.net) Date: Thu Apr 6 12:29:05 2006 Subject: [kupu-checkins] r25441 - kupu/trunk/kupu/default Message-ID: <20060406102904.81FC41023C@code0.codespeak.net> Author: guido Date: Thu Apr 6 12:28:58 2006 New Revision: 25441 Modified: kupu/trunk/kupu/default/sourceedit.kupu Log: Added access key for source edit. Modified: kupu/trunk/kupu/default/sourceedit.kupu ============================================================================== --- kupu/trunk/kupu/default/sourceedit.kupu (original) +++ kupu/trunk/kupu/default/sourceedit.kupu Thu Apr 6 12:28:58 2006 @@ -25,6 +25,7 @@ id="kupu-source-button" title="change between Kupu and HTML views" i18n:attributes="title toggle_source_view;" + accesskey="h" >  From guido at codespeak.net Thu Apr 6 12:29:21 2006 From: guido at codespeak.net (guido@codespeak.net) Date: Thu Apr 6 12:29:22 2006 Subject: [kupu-checkins] r25442 - kupu/trunk/kupu/silva Message-ID: <20060406102921.3B6F11023F@code0.codespeak.net> Author: guido Date: Thu Apr 6 12:29:19 2006 New Revision: 25442 Modified: kupu/trunk/kupu/silva/body.kupu kupu/trunk/kupu/silva/contextmenu.kupu kupu/trunk/kupu/silva/drawers.kupu kupu/trunk/kupu/silva/head.kupu kupu/trunk/kupu/silva/kupusilvainit.js kupu/trunk/kupu/silva/kupusilvatools.js kupu/trunk/kupu/silva/saveonpart.kupu kupu/trunk/kupu/silva/toolbar.kupu kupu/trunk/kupu/silva/toolboxes.kupu kupu/trunk/kupu/silva/wire.kupu kupu/trunk/kupu/silva/xmlconfig.kupu Log: Ported Silva-specific fixes from the 1.3 branch to the trunk. Modified: kupu/trunk/kupu/silva/body.kupu ============================================================================== --- kupu/trunk/kupu/silva/body.kupu (original) +++ kupu/trunk/kupu/silva/body.kupu Thu Apr 6 12:29:19 2006 @@ -5,8 +5,6 @@ xmlns="http://www.w3.org/1999/xhtml" xmlns:kupu="http://kupu.oscom.org/namespaces/dist" xmlns:metal="http://xml.zope.org/namespaces/metal" - xmlns:i18n="http://xml.zope.org/namespaces/i18n" - i18n:domain="kupu" > Modified: kupu/trunk/kupu/silva/contextmenu.kupu ============================================================================== --- kupu/trunk/kupu/silva/contextmenu.kupu (original) +++ kupu/trunk/kupu/silva/contextmenu.kupu Thu Apr 6 12:29:19 2006 @@ -5,8 +5,6 @@ xmlns="http://www.w3.org/1999/xhtml" xmlns:kupu="http://kupu.oscom.org/namespaces/dist" xmlns:tal="http://xml.zope.org/namespaces/tal" - xmlns:i18n="http://xml.zope.org/namespaces/i18n" - i18n:domain="kupu" > Modified: kupu/trunk/kupu/silva/drawers.kupu ============================================================================== --- kupu/trunk/kupu/silva/drawers.kupu (original) +++ kupu/trunk/kupu/silva/drawers.kupu Thu Apr 6 12:29:19 2006 @@ -6,7 +6,6 @@ xmlns:kupu="http://kupu.oscom.org/namespaces/dist" xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns:tal="http://xml.zope.org/namespaces/tal" - i18n:domain="kupu" > Modified: kupu/trunk/kupu/silva/head.kupu ============================================================================== --- kupu/trunk/kupu/silva/head.kupu (original) +++ kupu/trunk/kupu/silva/head.kupu Thu Apr 6 12:29:19 2006 @@ -5,8 +5,6 @@ xmlns="http://www.w3.org/1999/xhtml" xmlns:kupu="http://kupu.oscom.org/namespaces/dist" xmlns:tal="http://xml.zope.org/namespaces/tal" - xmlns:i18n="http://xml.zope.org/namespaces/i18n" - i18n:domain="kupu" > @@ -30,8 +28,10 @@ tal:attributes="src string:${root_url}/kupu/kupusourceedit.js"> + Modified: kupu/trunk/kupu/silva/kupusilvainit.js ============================================================================== --- kupu/trunk/kupu/silva/kupusilvainit.js (original) +++ kupu/trunk/kupu/silva/kupusilvainit.js Thu Apr 6 12:29:19 2006 @@ -195,8 +195,8 @@ var imagetool = new SilvaImageTool( 'kupu-toolbox-image-edit', 'kupu-toolbox-image-src', 'kupu-toolbox-image-target', 'kupu-toolbox-image-target-input', - 'kupu-toolbox-image-link-radio-hires', - 'kupu-toolbox-image-link-radio-link', 'kupu-toolbox-image-link', + 'kupu-toolbox-image-link-checkbox-hires', + 'kupu-toolbox-image-link', 'kupu-toolbox-image-align', 'kupu-toolbox-image-alt', 'kupu-toolbox-images', 'kupu-toolbox', 'kupu-toolbox-active'); @@ -227,9 +227,11 @@ 'kupu-editor-textarea'); kupu.registerTool('sourceedittool', sourceedittool); +/* var spellchecker = new KupuSpellChecker('kupu-spellchecker-button', 'kupu_spellcheck'); kupu.registerTool('spellchecker', spellchecker); +*/ var cleanupexpressions = new CleanupExpressionsTool( 'kupucleanupexpressionselect', 'kupucleanupexpressionbutton'); Modified: kupu/trunk/kupu/silva/kupusilvatools.js ============================================================================== --- kupu/trunk/kupu/silva/kupusilvatools.js (original) +++ kupu/trunk/kupu/silva/kupusilvatools.js Thu Apr 6 12:29:19 2006 @@ -15,11 +15,11 @@ // be moved to somewhere in Silva or something?) EDITABLE_METADATA = { 'http://infrae.com/namespaces/metadata/silva-news': - [['subjects', 'checkbox', 1, 'Subjects'], - ['target_audiences', 'checkbox', 1, 'Target audiences'], - ['start_datetime', 'datetime', 1, 'Start date/time'], - ['end_datetime', 'datetime', 0, 'End date/time'], - ['location', 'text', 0, 'Location'] + [['subjects', 'checkbox', 1, 'subjects'], + ['target_audiences', 'checkbox', 1, 'target audiences'], + ['start_datetime', 'datetime', 1, 'start date/time'], + ['end_datetime', 'datetime', 0, 'end date/time'], + ['location', 'text', 0, 'location'] ] } @@ -184,7 +184,7 @@ }; function SilvaImageTool(editelid, urlinputid, targetselectid, targetinputid, - hireslinkradioid, linklinkradioid, linkinputid, + hireslinkcheckboxid, linkinputid, alignselectid, titleinputid, toolboxid, plainclass, activeclass) { /* Silva specific image tool */ @@ -192,8 +192,7 @@ this.urlinput = getFromSelector(urlinputid); this.targetselect = getFromSelector(targetselectid); this.targetinput = getFromSelector(targetinputid); - this.hireslinkradio = getFromSelector(hireslinkradioid); - this.linklinkradio = getFromSelector(linklinkradioid); + this.hireslinkcheckbox = getFromSelector(hireslinkcheckboxid); this.linkinput = getFromSelector(linkinputid); this.alignselect = getFromSelector(alignselectid); this.titleinput = getFromSelector(titleinputid); @@ -205,13 +204,12 @@ SilvaImageTool.prototype = new ImageTool; SilvaImageTool.prototype.initialize = function(editor) { - this.editor = editor; + this.editor = editor; addEventHandler(this.targetselect, 'change', this.setTarget, this); addEventHandler(this.targetselect, 'change', this.selectTargetHandler, this); addEventHandler(this.targetinput, 'change', this.setTarget, this); addEventHandler(this.urlinput, 'change', this.setSrc, this); - addEventHandler(this.hireslinkradio, 'click', this.setHires, this); - addEventHandler(this.linklinkradio, 'click', this.setNoHires, this); + addEventHandler(this.hireslinkcheckbox, 'change', this.setHires, this); addEventHandler(this.linkinput, 'keypress', this.setLink, this); addEventHandler(this.linkinput, 'change', this.setLink, this); addEventHandler(this.alignselect, 'change', this.setAlign, this); @@ -271,11 +269,12 @@ var hires = image.getAttribute('link_to_hires') == '1'; if (!hires) { var link = image.getAttribute('link'); - this.linklinkradio.checked = 'selected'; + this.hireslinkcheckbox.checked = false; this.linkinput.value = link == null ? '' : link; } else { - this.hireslinkradio.checked = 'checked'; + this.hireslinkcheckbox.checked = 'checked'; this.linkinput.value = ''; + this.linkinput.disabled = 'disabled'; }; if (this.toolboxel) { if (this.toolboxel.open_handler) { @@ -358,22 +357,16 @@ this.editor.logMessage('No image selected!', 1); return; }; - image.setAttribute('link_to_hires', '1'); - image.removeAttribute('link'); - this.linkinput.value = ''; -}; - -SilvaImageTool.prototype.setNoHires = function() { - var selNode = this.editor.getSelectedNode(); - var image = this.editor.getNearestParentOfType(selNode, 'img'); - if (!image) { - this.editor.logMessage('Not inside an image!', 1); - return; + if (this.hireslinkcheckbox.checked) { + image.setAttribute('link_to_hires', '1'); + image.removeAttribute('link'); + this.linkinput.value = ''; + this.linkinput.disabled = 'disabled'; + } else { + image.setAttribute('link_to_hires', '0'); + image.setAttribute('link', this.linkinput.value); + this.linkinput.disabled = false; }; - var link = this.linkinput.value; - image.setAttribute('link_to_hires', '0'); - image.setAttribute('link', link); - this.linklinkradio.setAttribute('selected', 'selected'); }; SilvaImageTool.prototype.setLink = function() { @@ -1232,178 +1225,178 @@ this.toolboxel = getFromSelector(toolboxid); this.plainclass = plainclass; this.activeclass = activeclass; +}; - this.initialize = function(editor) { - /* attach the event handlers */ - this.editor = editor; - addEventHandler(this.input, 'blur', this.updateIndex, this); - addEventHandler(this.addbutton, 'click', this.addIndex, this); - addEventHandler(this.updatebutton, 'click', this.updateIndex, this); - addEventHandler(this.deletebutton, 'click', this.deleteIndex, this); - if (this.editor.getBrowserName() == 'IE') { - // need to catch some additional events for IE - addEventHandler(editor.getInnerDocument(), 'keyup', this.handleKeyPressOnIndex, this); - addEventHandler(editor.getInnerDocument(), 'keydown', this.handleKeyPressOnIndex, this); - }; - addEventHandler(editor.getInnerDocument(), 'keypress', this.handleKeyPressOnIndex, this); - this.updatebutton.style.display = 'none'; - this.deletebutton.style.display = 'none'; +SilvaIndexTool.prototype = new KupuTool; + +SilvaIndexTool.prototype.initialize = function(editor) { + /* attach the event handlers */ + this.editor = editor; + addEventHandler(this.input, 'blur', this.updateIndex, this); + addEventHandler(this.addbutton, 'click', this.addIndex, this); + addEventHandler(this.updatebutton, 'click', this.updateIndex, this); + addEventHandler(this.deletebutton, 'click', this.deleteIndex, this); + if (this.editor.getBrowserName() == 'IE') { + // need to catch some additional events for IE + addEventHandler(editor.getInnerDocument(), 'keyup', this.handleKeyPressOnIndex, this); + addEventHandler(editor.getInnerDocument(), 'keydown', this.handleKeyPressOnIndex, this); }; + addEventHandler(editor.getInnerDocument(), 'keypress', this.handleKeyPressOnIndex, this); + this.updatebutton.style.display = 'none'; + this.deletebutton.style.display = 'none'; +}; - this.addIndex = function(event) { - /* create an index */ - var name = this.input.value; - var currnode = this.editor.getSelectedNode(); - var indexel = this.editor.getNearestParentOfType(currnode, 'A'); - - if (indexel && indexel.getAttribute('href')) { - this.editor.logMessage('Can not add index items in anchors'); - return; - }; - - if (!indexel) { - var doc = this.editor.getDocument(); - if (!name) { - var selection = this.editor.getSelection(); - var cloned = selection.cloneContents(); - var iterator = new NodeIterator(cloned); - var name = ''; - var currnode = null; - while (currnode = iterator.next()) { - if (currnode.nodeValue) { - name += currnode.nodeValue; - }; - }; - if (name) { - this.input.value = name; - }; - }; - var docel = doc.getDocument(); - indexel = docel.createElement('a'); - var text = docel.createTextNode('[' + name + ']'); - indexel.appendChild(text); - indexel = this.editor.insertNodeAtSelection(indexel, true); - indexel.className = 'index'; - }; - - indexel.setAttribute('name', name); - var sel = this.editor.getSelection(); - sel.collapse(true); - this.editor.logMessage('Index added'); +SilvaIndexTool.prototype.addIndex = function(event) { + /* create an index */ + var name = this.input.value; + var currnode = this.editor.getSelectedNode(); + var indexel = this.editor.getNearestParentOfType(currnode, 'A'); + + if (indexel && indexel.getAttribute('href')) { + this.editor.logMessage('Can not add index items in anchors'); + return; + }; + + if (!indexel) { + var doc = this.editor.getDocument(); + if (!name) { + var selection = this.editor.getSelection(); + var cloned = selection.cloneContents(); + var iterator = new NodeIterator(cloned); + var name = ''; + var currnode = null; + while (currnode = iterator.next()) { + if (currnode.nodeValue) { + name += currnode.nodeValue; + }; + }; + if (name) { + this.input.value = name; + }; + }; + var docel = doc.getDocument(); + indexel = docel.createElement('a'); + var text = docel.createTextNode('[' + name + ']'); + indexel.appendChild(text); + indexel = this.editor.insertNodeAtSelection(indexel, true); + indexel.className = 'index'; }; + + indexel.setAttribute('name', name); + var sel = this.editor.getSelection(); + sel.collapse(true); + this.editor.logMessage('Index added'); +}; - this.updateIndex = function(event) { - /* update an existing index */ - var currnode = this.editor.getSelectedNode(); - var indexel = this.editor.getNearestParentOfType(currnode, 'A'); - if (!indexel) { - return; - }; +SilvaIndexTool.prototype.updateIndex = function(event) { + /* update an existing index */ + var currnode = this.editor.getSelectedNode(); + var indexel = this.editor.getNearestParentOfType(currnode, 'A'); + if (!indexel) { + return; + }; - if (indexel && indexel.getAttribute('href')) { - this.editor.logMessage('Can not add an index element inside a link!'); - return; - }; + if (indexel && indexel.getAttribute('href')) { + this.editor.logMessage('Can not add an index element inside a link!'); + return; + }; - var name = this.input.value; - indexel.setAttribute('name', name); - while (indexel.hasChildNodes()) { - indexel.removeChild(indexel.firstChild); - }; - var text = this.editor.getInnerDocument().createTextNode('[' + name + ']') - indexel.appendChild(text); - this.editor.logMessage('Index modified'); + var name = this.input.value; + indexel.setAttribute('name', name); + while (indexel.hasChildNodes()) { + indexel.removeChild(indexel.firstChild); }; + var text = this.editor.getInnerDocument().createTextNode('[' + name + ']') + indexel.appendChild(text); + this.editor.logMessage('Index modified'); +}; - this.deleteIndex = function() { - var selNode = this.editor.getSelectedNode(); - var a = this.editor.getNearestParentOfType(selNode, 'a'); - if (!a || a.getAttribute('href')) { - this.editor.logMessage('Not inside an index element!'); - return; - }; - a.parentNode.removeChild(a); - this.editor.logMessage('Index element removed'); +SilvaIndexTool.prototype.deleteIndex = function() { + var selNode = this.editor.getSelectedNode(); + var a = this.editor.getNearestParentOfType(selNode, 'a'); + if (!a || a.getAttribute('href')) { + this.editor.logMessage('Not inside an index element!'); + return; }; + a.parentNode.removeChild(a); + this.editor.logMessage('Index element removed'); +}; - this.handleKeyPressOnIndex = function(event) { - var selNode = this.editor.getSelectedNode(); - var a = this.editor.getNearestParentOfType(selNode, 'a'); - if (!a || a.getAttribute('href')) { - return; +SilvaIndexTool.prototype.handleKeyPressOnIndex = function(event) { + var selNode = this.editor.getSelectedNode(); + var a = this.editor.getNearestParentOfType(selNode, 'a'); + if (!a || a.getAttribute('href')) { + return; + }; + var keyCode = event.keyCode; + if (keyCode == 8 || keyCode == 46) { + a.parentNode.removeChild(a); + } else if (keyCode == 9 || keyCode == 39) { + var next = a.nextSibling; + while (next && next.nodeName.toLowerCase() == 'br') { + next = next.nextSibling; }; - var keyCode = event.keyCode; - if (keyCode == 8 || keyCode == 46) { - a.parentNode.removeChild(a); - } else if (keyCode == 9 || keyCode == 39) { - var next = a.nextSibling; - while (next && next.nodeName.toLowerCase() == 'br') { - next = next.nextSibling; - }; - if (!next) { - var doc = this.editor.getInnerDocument(); - next = doc.createTextNode('\xa0'); - a.parentNode.appendChild(next); - }; - var selection = this.editor.getSelection(); - // XXX I fear I'm working around bugs here... because of a bug in - // selection.moveStart() I can't use the same codepath in IE as in Moz - if (this.editor.getBrowserName() == 'IE') { - selection.selectNodeContents(a); - // XXX are we depending on a bug here? shouldn't we move the - // selection one place to get out of the anchor? it works, - // but seems wrong... - selection.collapse(true); - } else { - selection.selectNodeContents(next); - selection.collapse(); - var selection = this.editor.getSelection(); - }; - this.editor.updateState(); + if (!next) { + var doc = this.editor.getInnerDocument(); + next = doc.createTextNode('\xa0'); + a.parentNode.appendChild(next); }; - if (event.preventDefault) { - event.preventDefault(); + var selection = this.editor.getSelection(); + // XXX I fear I'm working around bugs here... because of a bug in + // selection.moveStart() I can't use the same codepath in IE as in Moz + if (this.editor.getBrowserName() == 'IE') { + selection.selectNodeContents(a); + // XXX are we depending on a bug here? shouldn't we move the + // selection one place to get out of the anchor? it works, + // but seems wrong... + selection.collapse(true); } else { - event.returnValue = false; + selection.selectNodeContents(next); + selection.collapse(); + var selection = this.editor.getSelection(); }; - return false; + this.editor.updateState(); + }; + if (event.preventDefault) { + event.preventDefault(); + } else { + event.returnValue = false; }; + return false; +}; - this.updateState = function(selNode) { - var indexel = this.editor.getNearestParentOfType(selNode, 'A'); - if (indexel && !indexel.getAttribute('href')) { - if (this.toolboxel) { - if (this.toolboxel.open_handler) { - this.toolboxel.open_handler(); - }; - this.toolboxel.className = this.activeclass; - }; - this.input.value = indexel.getAttribute('name'); - this.addbutton.style.display = 'none'; - this.updatebutton.style.display = 'inline'; - this.deletebutton.style.display = 'inline'; - } else { - if (this.toolboxel) { - this.toolboxel.className = this.plainclass; +SilvaIndexTool.prototype.updateState = function(selNode) { + var indexel = this.editor.getNearestParentOfType(selNode, 'A'); + if (indexel && !indexel.getAttribute('href')) { + if (this.toolboxel) { + if (this.toolboxel.open_handler) { + this.toolboxel.open_handler(); }; - this.input.value = ''; - this.updatebutton.style.display = 'none'; - this.deletebutton.style.display = 'none'; - this.addbutton.style.display = 'inline'; + this.toolboxel.className = this.activeclass; }; - }; - - this.createContextMenuElements = function(selNode, event) { - var indexel = this.editor.getNearestParentOfType(selNode, 'A'); - if (indexel && !indexel.getAttribute('href')) { - return new Array(new ContextMenuElement('Delete index', this.deleteIndex, this)); - } else { - return new Array(); + this.input.value = indexel.getAttribute('name'); + this.addbutton.style.display = 'none'; + this.updatebutton.style.display = 'inline'; + this.deletebutton.style.display = 'inline'; + } else { + if (this.toolboxel) { + this.toolboxel.className = this.plainclass; }; + this.input.value = ''; + this.updatebutton.style.display = 'none'; + this.deletebutton.style.display = 'none'; + this.addbutton.style.display = 'inline'; }; }; -SilvaIndexTool.prototype = new KupuTool; +SilvaIndexTool.prototype.createContextMenuElements = function(selNode, event) { + var indexel = this.editor.getNearestParentOfType(selNode, 'A'); + if (indexel && !indexel.getAttribute('href')) { + return new Array(new ContextMenuElement('Delete index', this.deleteIndex, this)); + } else { + return new Array(); + }; +}; function SilvaTocTool(depthselectid, addbuttonid, delbuttonid, toolboxid, plainclass, activeclass) { this.depthselect = getFromSelector(depthselectid); @@ -1413,176 +1406,176 @@ this.plainclass = plainclass; this.activeclass = activeclass; this._inside_toc = false; +}; - this.initialize = function(editor) { - this.editor = editor; - addEventHandler(this.addbutton, 'click', this.addOrUpdateToc, this); - addEventHandler(this.depthselect, 'change', this.updateToc, this); - addEventHandler(this.delbutton, 'click', this.deleteToc, this); - addEventHandler(editor.getInnerDocument(), 'keypress', this.handleKeyPressOnToc, this); - if (this.editor.getBrowserName() == 'IE') { - addEventHandler(editor.getInnerDocument(), 'keydown', this.handleKeyPressOnToc, this); - addEventHandler(editor.getInnerDocument(), 'keyup', this.handleKeyPressOnToc, this); - }; - }; +SilvaTocTool.prototype = new KupuTool; - this.handleKeyPressOnToc = function(event) { - if (!this._inside_toc) { - return; - }; - var keyCode = event.keyCode; - if (keyCode == 8 || keyCode == 46) { - var selNode = this.editor.getSelectedNode(); - var toc = this.getNearestToc(selNode); - toc.parentNode.removeChild(toc); - }; - if (keyCode == 13 || keyCode == 9 || keyCode == 39) { - var selNode = this.editor.getSelectedNode(); - var toc = this.getNearestToc(selNode); - var doc = this.editor.getInnerDocument(); - var selection = this.editor.getSelection(); - if (toc.nextSibling) { - var sibling = toc.nextSibling; - selection.selectNodeContents(toc.nextSibling); - selection.collapse(); - } else { - var parent = toc.parentNode; - var p = doc.createElement('p'); - parent.appendChild(p); - var text = doc.createTextNode('\xa0'); - p.appendChild(text); - selection.selectNodeContents(p); - }; - this._inside_toc = false; - }; - if (event.preventDefault) { - event.preventDefault(); - } else { - event.returnValue = false; - }; +SilvaTocTool.prototype.initialize = function(editor) { + this.editor = editor; + addEventHandler(this.addbutton, 'click', this.addOrUpdateToc, this); + addEventHandler(this.depthselect, 'change', this.updateToc, this); + addEventHandler(this.delbutton, 'click', this.deleteToc, this); + addEventHandler(editor.getInnerDocument(), 'keypress', this.handleKeyPressOnToc, this); + if (this.editor.getBrowserName() == 'IE') { + addEventHandler(editor.getInnerDocument(), 'keydown', this.handleKeyPressOnToc, this); + addEventHandler(editor.getInnerDocument(), 'keyup', this.handleKeyPressOnToc, this); }; +}; - this.updateState = function(selNode, event) { +SilvaTocTool.prototype.handleKeyPressOnToc = function(event) { + if (!this._inside_toc) { + return; + }; + var keyCode = event.keyCode; + if (keyCode == 8 || keyCode == 46) { + var selNode = this.editor.getSelectedNode(); var toc = this.getNearestToc(selNode); - if (toc) { - var depth = toc.getAttribute('toc_depth'); - selectSelectItem(this.depthselect, depth); - this.addbutton.style.display = 'none'; - this.delbutton.style.display = 'inline'; - this._inside_toc = true; - if (this.toolbox) { - if (this.toolbox.open_handler) { - this.toolbox.open_handler(); - }; - this.toolbox.className = this.activeclass; - }; - } else { - this.depthselect.selectedIndex = 0; - this.delbutton.style.display = 'none'; - this.addbutton.style.display = 'inline'; - this._inside_toc = false; - if (this.toolbox) { - this.toolbox.className = this.plainclass; - }; - }; + toc.parentNode.removeChild(toc); }; - - this.addOrUpdateToc = function(event, depth) { + if (keyCode == 13 || keyCode == 9 || keyCode == 39) { var selNode = this.editor.getSelectedNode(); - var depth = depth ? depth : this.depthselect.options[this.depthselect.selectedIndex].value; var toc = this.getNearestToc(selNode); var doc = this.editor.getInnerDocument(); - var toctext = this.getTocText(depth); - if (toc) { - // there's already a toc, just update the depth - toc.setAttribute('toc_depth', depth); - while (toc.hasChildNodes()) { - toc.removeChild(toc.firstChild); - }; - toc.appendChild(doc.createTextNode(toctext)); + var selection = this.editor.getSelection(); + if (toc.nextSibling) { + var sibling = toc.nextSibling; + selection.selectNodeContents(toc.nextSibling); + selection.collapse(); } else { - // create a new toc - var div = doc.createElement('div'); - div.setAttribute('toc_depth', depth); - div.setAttribute('is_toc', 1); - div.className = 'toc'; - var text = doc.createTextNode(toctext); - div.appendChild(text); - this.editor.insertNodeAtSelection(div); + var parent = toc.parentNode; + var p = doc.createElement('p'); + parent.appendChild(p); + var text = doc.createTextNode('\xa0'); + p.appendChild(text); + selection.selectNodeContents(p); }; + this._inside_toc = false; }; - - this.createDefaultToc = function() { - // XXX nasty workaround, entering null as the event... - this.addOrUpdateToc(null, '-1'); + if (event.preventDefault) { + event.preventDefault(); + } else { + event.returnValue = false; }; +}; - this.updateToc = function() { - var selNode = this.editor.getSelectedNode(); - var toc = this.getNearestToc(selNode); - if (toc) { - var depth = this.depthselect.options[this.depthselect.selectedIndex].value; - var toctext = this.getTocText(depth); - toc.setAttribute('toc_depth', depth); - while (toc.hasChildNodes()) { - toc.removeChild(toc.firstChild); +SilvaTocTool.prototype.updateState = function(selNode, event) { + var toc = this.getNearestToc(selNode); + if (toc) { + var depth = toc.getAttribute('toc_depth'); + selectSelectItem(this.depthselect, depth); + this.addbutton.style.display = 'none'; + this.delbutton.style.display = 'inline'; + this._inside_toc = true; + if (this.toolbox) { + if (this.toolbox.open_handler) { + this.toolbox.open_handler(); }; - doc = this.editor.getInnerDocument(); - toc.appendChild(doc.createTextNode(toctext)); + this.toolbox.className = this.activeclass; + }; + } else { + this.depthselect.selectedIndex = 0; + this.delbutton.style.display = 'none'; + this.addbutton.style.display = 'inline'; + this._inside_toc = false; + if (this.toolbox) { + this.toolbox.className = this.plainclass; }; }; +}; - this.deleteToc = function() { - var selNode = this.editor.getSelectedNode(); - var toc = this.getNearestToc(selNode); - if (!toc) { - this.editor.logMessage('Not inside a toc!', 1); - return; +SilvaTocTool.prototype.addOrUpdateToc = function(event, depth) { + var selNode = this.editor.getSelectedNode(); + var depth = depth ? depth : this.depthselect.options[this.depthselect.selectedIndex].value; + var toc = this.getNearestToc(selNode); + var doc = this.editor.getInnerDocument(); + var toctext = this.getTocText(depth); + if (toc) { + // there's already a toc, just update the depth + toc.setAttribute('toc_depth', depth); + while (toc.hasChildNodes()) { + toc.removeChild(toc.firstChild); }; - toc.parentNode.removeChild(toc); + toc.appendChild(doc.createTextNode(toctext)); + } else { + // create a new toc + var div = doc.createElement('div'); + div.setAttribute('toc_depth', depth); + div.setAttribute('is_toc', 1); + div.className = 'toc'; + var text = doc.createTextNode(toctext); + div.appendChild(text); + this.editor.insertNodeAtSelection(div); }; - - this.getNearestToc = function(selNode) { - var currnode = selNode; - while (currnode) { - if (currnode.nodeName.toLowerCase() == 'div' && - currnode.getAttribute('is_toc')) { - return currnode; - }; - currnode = currnode.parentNode; - }; - return false; - }; - - this.createContextMenuElements = function(selNode, event) { - /* create the 'Delete TOC' menu elements */ - var ret = new Array(); - if (this.getNearestToc(selNode)) { - ret.push(new ContextMenuElement('Delete TOC', this.deleteToc, this)); - } else { - ret.push(new ContextMenuElement('Create TOC', this.createDefaultToc, this)); +}; + +SilvaTocTool.prototype.createDefaultToc = function() { + // XXX nasty workaround, entering null as the event... + this.addOrUpdateToc(null, '-1'); +}; + +SilvaTocTool.prototype.updateToc = function() { + var selNode = this.editor.getSelectedNode(); + var toc = this.getNearestToc(selNode); + if (toc) { + var depth = this.depthselect.options[this.depthselect.selectedIndex].value; + var toctext = this.getTocText(depth); + toc.setAttribute('toc_depth', depth); + while (toc.hasChildNodes()) { + toc.removeChild(toc.firstChild); }; - return ret; + doc = this.editor.getInnerDocument(); + toc.appendChild(doc.createTextNode(toctext)); }; +}; - this.getTocText = function(depth) { - var toctext = 'Table of Contents '; - switch (depth) { - case '-1': - toctext += '(unlimited levels)'; - break; - case '1': - toctext += '(1 level)'; - break; - default: - toctext += '(' + depth + ' levels)'; - break; +SilvaTocTool.prototype.deleteToc = function() { + var selNode = this.editor.getSelectedNode(); + var toc = this.getNearestToc(selNode); + if (!toc) { + this.editor.logMessage('Not inside a toc!', 1); + return; + }; + toc.parentNode.removeChild(toc); +}; + +SilvaTocTool.prototype.getNearestToc = function(selNode) { + var currnode = selNode; + while (currnode) { + if (currnode.nodeName.toLowerCase() == 'div' && + currnode.getAttribute('is_toc')) { + return currnode; }; - return toctext; + currnode = currnode.parentNode; }; + return false; }; -SilvaTocTool.prototype = new KupuTool; +SilvaTocTool.prototype.createContextMenuElements = function(selNode, event) { + /* create the 'Delete TOC' menu elements */ + var ret = new Array(); + if (this.getNearestToc(selNode)) { + ret.push(new ContextMenuElement('Delete TOC', this.deleteToc, this)); + } else { + ret.push(new ContextMenuElement('Create TOC', this.createDefaultToc, this)); + }; + return ret; +}; + +SilvaTocTool.prototype.getTocText = function(depth) { + var toctext = 'Table of Contents '; + switch (depth) { + case '-1': + toctext += '(unlimited levels)'; + break; + case '1': + toctext += '(1 level)'; + break; + default: + toctext += '(' + depth + ' levels)'; + break; + }; + return toctext; +}; function SilvaAbbrTool(abbrradioid, acronymradioid, radiocontainerid, titleinputid, addbuttonid, updatebuttonid, delbuttonid, @@ -1598,117 +1591,117 @@ this.toolbox = getFromSelector(toolboxid); this.plainclass = plainclass; this.activeclass = activeclass; +}; + +SilvaAbbrTool.prototype = new KupuTool; + +SilvaAbbrTool.prototype.initialize = function(editor) { + this.editor = editor; + addEventHandler(this.addbutton, 'click', this.addElement, this); + addEventHandler(this.updatebutton, 'click', this.updateElement, this); + addEventHandler(this.delbutton, 'click', this.deleteElement, this); - this.initialize = function(editor) { - this.editor = editor; - addEventHandler(this.addbutton, 'click', this.addElement, this); - addEventHandler(this.updatebutton, 'click', this.updateElement, this); - addEventHandler(this.delbutton, 'click', this.deleteElement, this); - - this.updatebutton.style.display = 'none'; - this.delbutton.style.display = 'none'; - }; + this.updatebutton.style.display = 'none'; + this.delbutton.style.display = 'none'; +}; - this.updateState = function(selNode, event) { - var element = this.getNearestAbbrAcronym(selNode); - if (element) { - this.addbutton.style.display = 'none'; - this.updatebutton.style.display = 'inline'; - this.delbutton.style.display = 'inline'; - this.titleinput.value = element.getAttribute('title'); - this.radiocontainer.style.display = 'none'; - if (this.toolbox) { - if (this.toolbox.open_handler) { - this.toolbox.open_handler(); - }; - this.toolbox.className = this.activeclass; +SilvaAbbrTool.prototype.updateState = function(selNode, event) { + var element = this.getNearestAbbrAcronym(selNode); + if (element) { + this.addbutton.style.display = 'none'; + this.updatebutton.style.display = 'inline'; + this.delbutton.style.display = 'inline'; + this.titleinput.value = element.getAttribute('title'); + this.radiocontainer.style.display = 'none'; + if (this.toolbox) { + if (this.toolbox.open_handler) { + this.toolbox.open_handler(); }; + this.toolbox.className = this.activeclass; + }; + } else { + this.addbutton.style.display = 'inline'; + this.updatebutton.style.display = 'none'; + this.delbutton.style.display = 'none'; + this.titleinput.value = ''; + if (this.editor.getBrowserName() == 'IE' || this.radiocontainer.nodeName.toLowerCase() != 'tr') { + this.radiocontainer.style.display = 'block'; } else { - this.addbutton.style.display = 'inline'; - this.updatebutton.style.display = 'none'; - this.delbutton.style.display = 'none'; - this.titleinput.value = ''; - if (this.editor.getBrowserName() == 'IE' || this.radiocontainer.nodeName.toLowerCase() != 'tr') { - this.radiocontainer.style.display = 'block'; - } else { - this.radiocontainer.style.display = 'table-row'; - }; - if (this.toolbox) { - this.toolbox.className = this.plainclass; - }; + this.radiocontainer.style.display = 'table-row'; + }; + if (this.toolbox) { + this.toolbox.className = this.plainclass; }; }; +}; - this.getNearestAbbrAcronym = function(selNode) { - var current = selNode; - while (current && current.nodeType != 9) { - if (current.nodeType == 1) { - var nodeName = current.nodeName.toLowerCase(); - if (nodeName == 'abbr' || nodeName == 'acronym') { - return current; - }; +SilvaAbbrTool.prototype.getNearestAbbrAcronym = function(selNode) { + var current = selNode; + while (current && current.nodeType != 9) { + if (current.nodeType == 1) { + var nodeName = current.nodeName.toLowerCase(); + if (nodeName == 'abbr' || nodeName == 'acronym') { + return current; }; - current = current.parentNode; }; + current = current.parentNode; }; +}; - this.addElement = function() { - var type = this.abbrradio.checked ? 'abbr' : 'acronym'; - var doc = this.editor.getInnerDocument(); - var selNode = this.editor.getSelectedNode(); - if (this.getNearestAbbrAcronym(selNode)) { - this.editor.logMessage('Can not nest abbr and acronym elements'); - return; - }; - var element = doc.createElement(type); - element.setAttribute('title', this.titleinput.value); - - var selection = this.editor.getSelection(); - var docfrag = selection.cloneContents(); - var placecursoratend = false; - if (docfrag.hasChildNodes()) { - for (var i=0; i < docfrag.childNodes.length; i++) { - element.appendChild(docfrag.childNodes[i]); - }; - placecursoratend = true; - } else { - var text = doc.createTextNode('\xa0'); - element.appendChild(text); - }; - this.editor.insertNodeAtSelection(element, 1); - var selection = this.editor.getSelection(); - selection.collapse(placecursoratend); - this.editor.getDocument().getWindow().focus(); - var selNode = selection.getSelectedNode(); - this.editor.updateState(selNode); - this.editor.logMessage('Element ' + type + ' added'); +SilvaAbbrTool.prototype.addElement = function() { + var type = this.abbrradio.checked ? 'abbr' : 'acronym'; + var doc = this.editor.getInnerDocument(); + var selNode = this.editor.getSelectedNode(); + if (this.getNearestAbbrAcronym(selNode)) { + this.editor.logMessage('Can not nest abbr and acronym elements'); + return; }; + var element = doc.createElement(type); + element.setAttribute('title', this.titleinput.value); - this.updateElement = function() { - var selNode = this.editor.getSelectedNode(); - var element = this.getNearestAbbrAcronym(selNode); - if (!element) { - this.editor.logMessage('Not inside an abbr or acronym element!', 1); - return; + var selection = this.editor.getSelection(); + var docfrag = selection.cloneContents(); + var placecursoratend = false; + if (docfrag.hasChildNodes()) { + for (var i=0; i < docfrag.childNodes.length; i++) { + element.appendChild(docfrag.childNodes[i]); }; - var title = this.titleinput.value; - element.setAttribute('title', title); - this.editor.logMessage('Updated ' + element.nodeName.toLowerCase() + ' element'); + placecursoratend = true; + } else { + var text = doc.createTextNode('\xa0'); + element.appendChild(text); }; + this.editor.insertNodeAtSelection(element, 1); + var selection = this.editor.getSelection(); + selection.collapse(placecursoratend); + this.editor.getDocument().getWindow().focus(); + var selNode = selection.getSelectedNode(); + this.editor.updateState(selNode); + this.editor.logMessage('Element ' + type + ' added'); +}; - this.deleteElement = function() { - var selNode = this.editor.getSelectedNode(); - var element = this.getNearestAbbrAcronym(selNode); - if (!element) { - this.editor.logMessage('Not inside an abbr or acronym element!', 1); - return; - }; - element.parentNode.removeChild(element); - this.editor.logMessage('Deleted ' + element.nodeName.toLowerCase() + ' deleted'); +SilvaAbbrTool.prototype.updateElement = function() { + var selNode = this.editor.getSelectedNode(); + var element = this.getNearestAbbrAcronym(selNode); + if (!element) { + this.editor.logMessage('Not inside an abbr or acronym element!', 1); + return; }; + var title = this.titleinput.value; + element.setAttribute('title', title); + this.editor.logMessage('Updated ' + element.nodeName.toLowerCase() + ' element'); }; -SilvaAbbrTool.prototype = new KupuTool; +SilvaAbbrTool.prototype.deleteElement = function() { + var selNode = this.editor.getSelectedNode(); + var element = this.getNearestAbbrAcronym(selNode); + if (!element) { + this.editor.logMessage('Not inside an abbr or acronym element!', 1); + return; + }; + element.parentNode.removeChild(element); + this.editor.logMessage('Deleted ' + element.nodeName.toLowerCase() + ' deleted'); +}; function SilvaCitationTool(authorinputid, sourceinputid, addbuttonid, updatebuttonid, delbuttonid, toolboxid, plainclass, activeclass) { @@ -1722,173 +1715,173 @@ this.plainclass = plainclass; this.activeclass = activeclass; this._inside_citation = false; +}; + +SilvaCitationTool.prototype = new KupuTool; + +SilvaCitationTool.prototype.initialize = function(editor) { + this.editor = editor; + addEventHandler(this.addbutton, 'click', this.addCitation, this); + addEventHandler(this.updatebutton, 'click', this.updateCitation, this); + addEventHandler(this.delbutton, 'click', this.deleteCitation, this); + if (editor.getBrowserName() == 'IE') { + addEventHandler(editor.getInnerDocument(), 'keyup', this.cancelEnterPress, this); + addEventHandler(editor.getInnerDocument(), 'keydown', this.handleKeyPressOnCitation, this); + } else { + addEventHandler(editor.getInnerDocument(), 'keypress', this.handleKeyPressOnCitation, this); + }; - this.initialize = function(editor) { - this.editor = editor; - addEventHandler(this.addbutton, 'click', this.addCitation, this); - addEventHandler(this.updatebutton, 'click', this.updateCitation, this); - addEventHandler(this.delbutton, 'click', this.deleteCitation, this); - if (editor.getBrowserName() == 'IE') { - addEventHandler(editor.getInnerDocument(), 'keyup', this.cancelEnterPress, this); - addEventHandler(editor.getInnerDocument(), 'keydown', this.handleKeyPressOnCitation, this); - } else { - addEventHandler(editor.getInnerDocument(), 'keypress', this.handleKeyPressOnCitation, this); - }; - - this.updatebutton.style.display = 'none'; - this.delbutton.style.display = 'none'; + this.updatebutton.style.display = 'none'; + this.delbutton.style.display = 'none'; +}; + +SilvaCitationTool.prototype.cancelEnterPress = function(event) { + if (!this._inside_citation || (event.keyCode != 13 && event.keyCode != 9)) { + return; + }; + if (event.preventDefault) { + event.preventDefault(); + } else { + event.returnValue = false; }; +}; - this.cancelEnterPress = function(event) { - if (!this._inside_citation || (event.keyCode != 13 && event.keyCode != 9)) { - return; +SilvaCitationTool.prototype.handleKeyPressOnCitation = function(event) { + if (!this._inside_citation) { + return; + }; + var keyCode = event.keyCode; + var citation = this.getNearestCitation(this.editor.getSelectedNode()); + var doc = this.editor.getInnerDocument(); + var selection = this.editor.getSelection(); + if (keyCode == 13 && this.editor.getBrowserName() == 'IE') { + var br = doc.createElement('br'); + var currnode = selection.getSelectedNode(); + selection.replaceWithNode(br); + selection.selectNodeContents(br); + selection.collapse(true); + event.returnValue = false; + } else if (keyCode == 9) { + var next = citation.nextSibling; + if (!next) { + next = doc.createElement('p'); + next.appendChild(doc.createTextNode('\xa0')); + citation.parentNode.appendChild(next); }; + selection.selectNodeContents(next); + selection.collapse(); if (event.preventDefault) { event.preventDefault(); - } else { - event.returnValue = false; }; + event.returnValue = false; + this._inside_citation = false; }; +}; - this.handleKeyPressOnCitation = function(event) { - if (!this._inside_citation) { - return; - }; - var keyCode = event.keyCode; - var citation = this.getNearestCitation(this.editor.getSelectedNode()); - var doc = this.editor.getInnerDocument(); - var selection = this.editor.getSelection(); - if (keyCode == 13 && this.editor.getBrowserName() == 'IE') { - var br = doc.createElement('br'); - var currnode = selection.getSelectedNode(); - selection.replaceWithNode(br); - selection.selectNodeContents(br); - selection.collapse(true); - event.returnValue = false; - } else if (keyCode == 9) { - var next = citation.nextSibling; - if (!next) { - next = doc.createElement('p'); - next.appendChild(doc.createTextNode('\xa0')); - citation.parentNode.appendChild(next); +SilvaCitationTool.prototype.updateState = function(selNode, event) { + var citation = this.getNearestCitation(selNode); + if (citation) { + this.addbutton.style.display = 'none'; + this.updatebutton.style.display = 'inline'; + this.delbutton.style.display = 'inline'; + this.authorinput.value = citation.getAttribute('author'); + this.sourceinput.value = citation.getAttribute('source'); + this._inside_citation = true; + if (this.toolbox) { + if (this.toolbox.open_handler) { + this.toolbox.open_handler(); }; - selection.selectNodeContents(next); - selection.collapse(); - if (event.preventDefault) { - event.preventDefault(); - }; - event.returnValue = false; - this._inside_citation = false; + this.toolbox.className = this.activeclass; }; - }; - - this.updateState = function(selNode, event) { - var citation = this.getNearestCitation(selNode); - if (citation) { - this.addbutton.style.display = 'none'; - this.updatebutton.style.display = 'inline'; - this.delbutton.style.display = 'inline'; - this.authorinput.value = citation.getAttribute('author'); - this.sourceinput.value = citation.getAttribute('source'); - this._inside_citation = true; - if (this.toolbox) { - if (this.toolbox.open_handler) { - this.toolbox.open_handler(); - }; - this.toolbox.className = this.activeclass; - }; - } else { - this.addbutton.style.display = 'inline'; - this.updatebutton.style.display = 'none'; - this.delbutton.style.display = 'none'; - this.authorinput.value = ''; - this.sourceinput.value = ''; - this._inside_citation = false; - if (this.toolbox) { - this.toolbox.className = this.plainclass; - }; + } else { + this.addbutton.style.display = 'inline'; + this.updatebutton.style.display = 'none'; + this.delbutton.style.display = 'none'; + this.authorinput.value = ''; + this.sourceinput.value = ''; + this._inside_citation = false; + if (this.toolbox) { + this.toolbox.className = this.plainclass; }; }; +}; - this.addCitation = function() { - var selNode = this.editor.getSelectedNode(); - var citation = this.getNearestCitation(selNode); - if (citation) { - this.editor.logMessage('Nested citations are not allowed!'); - return; - }; - var author = this.authorinput.value; - var source = this.sourceinput.value; - var doc = this.editor.getInnerDocument(); - var div = doc.createElement('div'); - div.className = 'citation'; - div.setAttribute('author', author); - div.setAttribute('source', source); - div.setAttribute('is_citation', '1'); - var selection = this.editor.getSelection(); - var docfrag = selection.cloneContents(); - var placecursoratend = false; - if (docfrag.hasChildNodes()) { - for (var i=0; i < docfrag.childNodes.length; i++) { - div.appendChild(docfrag.childNodes[i]); - }; - placecursoratend = true; - } else { - var text = doc.createTextNode('\xa0'); - div.appendChild(text); - }; - this.editor.insertNodeAtSelection(div, 1); - var selection = this.editor.getSelection(); - selection.collapse(placecursoratend); - this.editor.getDocument().getWindow().focus(); - var selNode = selection.getSelectedNode(); - this.editor.updateState(selNode); +SilvaCitationTool.prototype.addCitation = function() { + var selNode = this.editor.getSelectedNode(); + var citation = this.getNearestCitation(selNode); + if (citation) { + this.editor.logMessage('Nested citations are not allowed!'); + return; }; - - this.updateCitation = function() { - var selNode = this.editor.getSelectedNode(); - var citation = this.getNearestCitation(selNode); - if (!citation) { - this.editor.logMessage('Not inside a citation element!'); - return; + var author = this.authorinput.value; + var source = this.sourceinput.value; + var doc = this.editor.getInnerDocument(); + var div = doc.createElement('div'); + div.className = 'citation'; + div.setAttribute('author', author); + div.setAttribute('source', source); + div.setAttribute('is_citation', '1'); + var selection = this.editor.getSelection(); + var docfrag = selection.cloneContents(); + var placecursoratend = false; + if (docfrag.hasChildNodes()) { + for (var i=0; i < docfrag.childNodes.length; i++) { + div.appendChild(docfrag.childNodes[i]); }; - citation.setAttribute('author', this.authorinput.value); - citation.setAttribute('source', this.sourceinput.value); + placecursoratend = true; + } else { + var text = doc.createTextNode('\xa0'); + div.appendChild(text); }; + this.editor.insertNodeAtSelection(div, 1); + var selection = this.editor.getSelection(); + selection.collapse(placecursoratend); + this.editor.getDocument().getWindow().focus(); + var selNode = selection.getSelectedNode(); + this.editor.updateState(selNode); +}; - this.deleteCitation = function() { - var selNode = this.editor.getSelectedNode(); - var citation = this.getNearestCitation(selNode); - if (!citation) { - this.editor.logMessage('Not inside citation element!'); - return; - }; - citation.parentNode.removeChild(citation); +SilvaCitationTool.prototype.updateCitation = function() { + var selNode = this.editor.getSelectedNode(); + var citation = this.getNearestCitation(selNode); + if (!citation) { + this.editor.logMessage('Not inside a citation element!'); + return; }; + citation.setAttribute('author', this.authorinput.value); + citation.setAttribute('source', this.sourceinput.value); +}; - this.getNearestCitation = function(selNode) { - var currnode = selNode; - while (currnode) { - if (currnode.nodeName.toLowerCase() == 'div' && - currnode.getAttribute('is_citation')) { - return currnode; - }; - currnode = currnode.parentNode; - }; - return false; +SilvaCitationTool.prototype.deleteCitation = function() { + var selNode = this.editor.getSelectedNode(); + var citation = this.getNearestCitation(selNode); + if (!citation) { + this.editor.logMessage('Not inside citation element!'); + return; }; - - this.createContextMenuElements = function(selNode, event) { - /* create the 'Delete citation' menu elements */ - var ret = new Array(); - if (this.getNearestCitation(selNode)) { - ret.push(new ContextMenuElement('Delete cite', this.deleteCitation, this)); + citation.parentNode.removeChild(citation); +}; + +SilvaCitationTool.prototype.getNearestCitation = function(selNode) { + var currnode = selNode; + while (currnode) { + if (currnode.nodeName.toLowerCase() == 'div' && + currnode.getAttribute('is_citation')) { + return currnode; }; - return ret; + currnode = currnode.parentNode; }; + return false; }; -SilvaCitationTool.prototype = new KupuTool; +SilvaCitationTool.prototype.createContextMenuElements = function(selNode, event) { + /* create the 'Delete citation' menu elements */ + var ret = new Array(); + if (this.getNearestCitation(selNode)) { + ret.push(new ContextMenuElement('Delete cite', this.deleteCitation, this)); + }; + return ret; +}; function SilvaExternalSourceTool(idselectid, formcontainerid, addbuttonid, cancelbuttonid, updatebuttonid, delbuttonid, toolboxid, plainclass, activeclass) { @@ -1921,482 +1914,524 @@ urlparts_to_use.push(part); }; this._baseurl = urlparts_to_use.join('/'); +}; - this.initialize = function(editor) { - this.editor = editor; - addEventHandler(this.addbutton, 'click', this.startExternalSourceAddEdit, this); - addEventHandler(this.cancelbutton, 'click', this.resetTool, this); - addEventHandler(this.updatebutton, 'click', this.startExternalSourceAddEdit, this); - addEventHandler(this.delbutton, 'click', this.delExternalSource, this); - addEventHandler(editor.getInnerDocument(), 'keypress', this.handleKeyPressOnExternalSource, this); - if (this.editor.getBrowserName() == 'IE') { - addEventHandler(editor.getInnerDocument(), 'keydown', this.handleKeyPressOnExternalSource, this); - addEventHandler(editor.getInnerDocument(), 'keyup', this.handleKeyPressOnExternalSource, this); - }; - - // search for a special serialized identifier of the current document - // which is used to send to the ExternalSource element when sending - // requests so the ExternalSources know their context - this.docref = null; - var metas = this.editor.getInnerDocument().getElementsByTagName('meta'); - for (var i=0; i < metas.length; i++) { - var meta = metas[i]; - if (meta.getAttribute('name') == 'docref') { - this.docref = meta.getAttribute('content'); - }; +SilvaExternalSourceTool.prototype = new KupuTool; + +SilvaExternalSourceTool.prototype.initialize = function(editor) { + this.editor = editor; + addEventHandler(this.addbutton, 'click', this.startExternalSourceAddEdit, this); + addEventHandler(this.cancelbutton, 'click', this.resetTool, this); + addEventHandler(this.updatebutton, 'click', this.startExternalSourceAddEdit, this); + addEventHandler(this.delbutton, 'click', this.delExternalSource, this); + addEventHandler(editor.getInnerDocument(), 'keypress', this.handleKeyPressOnExternalSource, this); + if (this.editor.getBrowserName() == 'IE') { + addEventHandler(editor.getInnerDocument(), 'keydown', this.handleKeyPressOnExternalSource, this); + addEventHandler(editor.getInnerDocument(), 'keyup', this.handleKeyPressOnExternalSource, this); + }; + + // search for a special serialized identifier of the current document + // which is used to send to the ExternalSource element when sending + // requests so the ExternalSources know their context + this.docref = null; + var metas = this.editor.getInnerDocument().getElementsByTagName('meta'); + for (var i=0; i < metas.length; i++) { + var meta = metas[i]; + if (meta.getAttribute('name') == 'docref') { + this.docref = meta.getAttribute('content'); }; - - this.updatebutton.style.display = 'none'; - this.delbutton.style.display = 'none'; - this.cancelbutton.style.display = 'none'; }; + + this.updatebutton.style.display = 'none'; + this.delbutton.style.display = 'none'; + this.cancelbutton.style.display = 'none'; +}; - this.updateState = function(selNode) { - var extsource = this.getNearestExternalSource(selNode); - if (extsource) { - this._insideExternalSource = true; - selectSelectItem(this.idselect, extsource.getAttribute('source_id')); - this.addbutton.style.display = 'none'; - this.cancelbutton.style.display = 'none'; - this.updatebutton.style.display = 'inline'; - this.delbutton.style.display = 'inline'; - this.startExternalSourceUpdate(extsource); - if (this.toolbox) { - this.toolbox.className = this.activeclass; - }; - } else { - this._insideExternalSource = false; - this.resetTool(); - if (this.toolbox) { - this.toolbox.className = this.plainclass; - }; +SilvaExternalSourceTool.prototype.updateState = function(selNode) { + var extsource = this.getNearestExternalSource(selNode); + var heading = this.toolbox.getElementsByTagName('h1')[0]; + if (extsource) { + this._insideExternalSource = true; + selectSelectItem(this.idselect, extsource.getAttribute('source_id')); + this.addbutton.style.display = 'none'; + this.cancelbutton.style.display = 'none'; + this.updatebutton.style.display = 'inline'; + this.delbutton.style.display = 'inline'; + this.startExternalSourceUpdate(extsource); + if (this.toolbox) { + this.toolbox.className = this.activeclass; + }; + heading.replaceChild( + document.createTextNode('external source \xab' + + extsource.getAttribute('source_id') + '\xbb'), + heading.firstChild + ); + } else { + this._insideExternalSource = false; + this.resetTool(); + if (this.toolbox) { + this.toolbox.className = this.plainclass; }; + heading.replaceChild( + document.createTextNode('external source'), + heading.firstChild + ); }; +}; - this.handleKeyPressOnExternalSource = function(event) { - if (!this._insideExternalSource) { - return; - }; - var keyCode = event.keyCode; - var selNode = this.editor.getSelectedNode(); - var div = this.getNearestExternalSource(selNode); - var doc = this.editor.getInnerDocument(); - if (keyCode == 13 || keyCode == 9 || keyCode == 39) { - if (div.nextSibling) { - var selection = this.editor.getSelection(); - selection.selectNodeContents(div.nextSibling); - selection.collapse(); - } else { - var p = doc.createElement('p'); - var nbsp = doc.createTextNode('\xa0'); - p.appendChild(nbsp); - div.parentNode.appendChild(p); - var selection = this.editor.getSelection(); - selection.selectNodeContents(p); - selection.collapse(); - }; - this._insideExternalSource = false; - } else if (keyCode == 8) { - var selectnode = div.nextSibling; - if (!selectnode) { - selectnode = doc.createElement('p'); - selectnode.appendChild(doc.createTextNode('\xa0')); - doc.appendChild(selectnode); - }; +SilvaExternalSourceTool.prototype.handleKeyPressOnExternalSource = function(event) { + if (!this._insideExternalSource) { + return; + }; + var keyCode = event.keyCode; + var selNode = this.editor.getSelectedNode(); + var div = this.getNearestExternalSource(selNode); + var doc = this.editor.getInnerDocument(); + if (keyCode == 13 || keyCode == 9 || keyCode == 39) { + if (div.nextSibling) { var selection = this.editor.getSelection(); - selection.selectNodeContents(selectnode); - div.parentNode.removeChild(div); + selection.selectNodeContents(div.nextSibling); selection.collapse(); - }; - if (event.preventDefault) { - event.preventDefault(); } else { - event.returnValue = false; + var p = doc.createElement('p'); + var nbsp = doc.createTextNode('\xa0'); + p.appendChild(nbsp); + div.parentNode.appendChild(p); + var selection = this.editor.getSelection(); + selection.selectNodeContents(p); + selection.collapse(); }; - }; - - this.getUrlAndContinue = function(id, handler) { - if (id == this._id) { - // return cached - handler.call(this, this._url); - return; - }; - var request = new XMLHttpRequest(); - request.open('GET', - this._baseurl + '/edit/get_extsource_url?id=' + id, true); - var callback = new ContextFixer(function() { - if (request.readyState == 4) { - var url = request.responseText; - this._id = id; - this._url = url; - handler.call(this, url); - }; - }, this); - request.onreadystatechange = callback.execute; - request.send(''); - }; - - this.startExternalSourceAddEdit = function() { - // get the appropriate form and display it - if (!this._editing) { - var id = this.idselect.options[this.idselect.selectedIndex].value; - this.getUrlAndContinue(id, this._continueStartExternalSourceEdit); - } else { - // validate the data and take further actions - var formdata = this._gatherFormData(); - var doc = window.document; - var request = new XMLHttpRequest(); - request.open('POST', this._url + '/validate_form_to_request', true); - var callback = new ContextFixer(this._addExternalSourceIfValidated, request, this); - request.onreadystatechange = callback.execute; - request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - request.send(formdata); + this._insideExternalSource = false; + } else if (keyCode == 8) { + var selectnode = div.nextSibling; + if (!selectnode) { + selectnode = doc.createElement('p'); + selectnode.appendChild(doc.createTextNode('\xa0')); + doc.appendChild(selectnode); }; + var selection = this.editor.getSelection(); + selection.selectNodeContents(selectnode); + div.parentNode.removeChild(div); + selection.collapse(); }; - - this._continueStartExternalSourceEdit = function(url) { - url = url + '/get_rendered_form_for_editor?docref=' + this.docref; - var request = new XMLHttpRequest(); - request.open('GET', url, true); - var callback = new ContextFixer(this._addFormToTool, request, this); - request.onreadystatechange = callback.execute; - request.send(null); - while (this.formcontainer.hasChildNodes()) { - this.formcontainer.removeChild(this.formcontainer.firstChild); - }; - var text = document.createTextNode('Loading...'); - this.formcontainer.appendChild(text); - this.updatebutton.style.display = 'none'; - this.cancelbutton.style.display = 'inline'; - this.addbutton.style.display = 'inline'; - this._editing = true; + if (event.preventDefault) { + event.preventDefault(); + } else { + event.returnValue = false; }; +}; - this.startExternalSourceUpdate = function(extsource) { - var id = extsource.getAttribute('source_id'); - this.getUrlAndContinue(id, this._continueStartExternalSourceUpdate); +SilvaExternalSourceTool.prototype.getUrlAndContinue = function(id, handler) { + if (id == this._id) { + // return cached + handler.call(this, this._url); + return; }; + var request = new XMLHttpRequest(); + var url = this._baseurl + '/edit/get_extsource_url?id=' + id; + request.open('GET', url, true); + var callback = new ContextFixer(function() { + if (request.readyState == 4) { + if (request.status.toString() == '200') { + var returl = request.responseText; + this._id = id; + this._url = returl; + handler.call(this, returl); + } else { + alert('problem: url ' + url + + ' could not be loaded (status ' + + request.status + ')'); + }; + }; + }, this); + request.onreadystatechange = callback.execute; + request.send(''); +}; - this._continueStartExternalSourceUpdate = function(url) { - url = url + '/get_rendered_form_for_editor'; - var formdata = this._gatherFormDataFromElement(); - formdata += '&docref=' + this.docref; +SilvaExternalSourceTool.prototype.startExternalSourceAddEdit = function() { + // get the appropriate form and display it + if (!this._editing) { + var id = this.idselect.options[this.idselect.selectedIndex].value; + this.getUrlAndContinue(id, this._continueStartExternalSourceEdit); + } else { + // validate the data and take further actions + var formdata = this._gatherFormData(); + var doc = window.document; var request = new XMLHttpRequest(); - request.open('POST', url, true); - request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - var callback = new ContextFixer(this._addFormToTool, request, this); + request.open('POST', this._url + '/validate_form_to_request', true); + var callback = new ContextFixer(this._addExternalSourceIfValidated, request, this); request.onreadystatechange = callback.execute; + request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); request.send(formdata); - this._editing = true; - while (this.formcontainer.hasChildNodes()) { - this.formcontainer.removeChild(this.formcontainer.firstChild); - }; - var text = document.createTextNode('Loading...'); - this.formcontainer.appendChild(text); }; +}; - this._addFormToTool = function(object) { - if (this.readyState == 4) { - if (this.status != '200') { - // element not found, return without doing anythink - object.resetTool(); - return; - }; - while (object.formcontainer.hasChildNodes()) { - object.formcontainer.removeChild(object.formcontainer.firstChild); - }; - // XXX Somehow appending the XML to the form using DOM doesn't - // work correctly, it looks like the elements aren't HTMLElements - // but XML elements, don't know how to fix now so I'll use string - // insertion for now, needless to say it should be changed to DOM - // manipulation asap... - // XXX why is this.responseXML.documentElement.xml sometimes 'undefined'? - object.formcontainer.innerHTML = this.responseText; - object.idselect.style.display = 'none'; - // the formcontainer will contain a table with a form - var form = null; - var iterator = new NodeIterator(object.formcontainer); - while (form == null) { - var next = iterator.next(); - if (next.nodeName.toLowerCase() == 'form') { - form = next; - }; - }; - object._form = form; - }; +SilvaExternalSourceTool.prototype._continueStartExternalSourceEdit = function(url) { + url = url + '/get_rendered_form_for_editor?docref=' + this.docref; + var request = new XMLHttpRequest(); + request.open('GET', url, true); + var callback = new ContextFixer(this._addFormToTool, request, this); + request.onreadystatechange = callback.execute; + request.send(null); + while (this.formcontainer.hasChildNodes()) { + this.formcontainer.removeChild(this.formcontainer.firstChild); }; + var text = document.createTextNode('Loading...'); + this.formcontainer.appendChild(text); + this.updatebutton.style.display = 'none'; + this.cancelbutton.style.display = 'inline'; + this.addbutton.style.display = 'inline'; + this._editing = true; +}; - this._addExternalSourceIfValidated = function(object) { - if (this.readyState == 4) { - if (this.status == '200') { - // success, add the external source element to the document - var selNode = object.editor.getSelectedNode(); - var currsource = object.getNearestExternalSource(selNode); - var doc = object.editor.getInnerDocument(); - - var extsource = doc.createElement('div'); - extsource.setAttribute('source_id', object._id); - var header = doc.createElement('h4'); - extsource.appendChild(header); - extsource.className = 'externalsource'; - var metatype = 'Silva Code Source'; // a default just in case - for (var i=0; i < this.responseXML.documentElement.childNodes.length; i++) { - var child = this.responseXML.documentElement.childNodes[i]; - if (child.nodeName.toLowerCase() == 'parameter') { - var key = child.getAttribute('key'); - var value = ''; - for (var j=0; j < child.childNodes.length; j++) { - value += child.childNodes[j].nodeValue; - }; - if (key == 'metatype') { - metatype = value; - continue; - }; - extsource.setAttribute(key, value); - var textel = doc.createTextNode('Key: ' + key + ', value: ' + value.toString()); - extsource.appendChild(textel); - extsource.appendChild(doc.createElement('br')); +SilvaExternalSourceTool.prototype.startExternalSourceUpdate = function(extsource) { + var id = extsource.getAttribute('source_id'); + this.getUrlAndContinue(id, this._continueStartExternalSourceUpdate); +}; + +SilvaExternalSourceTool.prototype._continueStartExternalSourceUpdate = function(url) { + url = url + '/get_rendered_form_for_editor'; + var formdata = this._gatherFormDataFromElement(); + formdata += '&docref=' + this.docref; + var request = new XMLHttpRequest(); + request.open('POST', url, true); + request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + var callback = new ContextFixer(this._addFormToTool, request, this); + request.onreadystatechange = callback.execute; + request.send(formdata); + this._editing = true; + while (this.formcontainer.hasChildNodes()) { + this.formcontainer.removeChild(this.formcontainer.firstChild); + }; + var text = document.createTextNode('Loading...'); + this.formcontainer.appendChild(text); +}; + +SilvaExternalSourceTool.prototype._addFormToTool = function(object) { + if (this.readyState == 4) { + if (this.status != '200') { + if (this.status == '500') { + alert('error on the server. body returned:\n' + + this.responseText); + }; + // element not found, return without doing anythink + object.resetTool(); + return; + }; + while (object.formcontainer.hasChildNodes()) { + object.formcontainer.removeChild(object.formcontainer.firstChild); + }; + // XXX Somehow appending the XML to the form using DOM doesn't + // work correctly, it looks like the elements aren't HTMLElements + // but XML elements, don't know how to fix now so I'll use string + // insertion for now, needless to say it should be changed to DOM + // manipulation asap... + // XXX why is this.responseXML.documentElement.xml sometimes 'undefined'? + object.formcontainer.innerHTML = this.responseText; + object.idselect.style.display = 'none'; + // the formcontainer will contain a table with a form + var form = null; + var iterator = new NodeIterator(object.formcontainer); + while (form == null) { + var next = iterator.next(); + if (next.nodeName.toLowerCase() == 'form') { + form = next; + }; + }; + object._form = form; + }; +}; + +SilvaExternalSourceTool.prototype._addExternalSourceIfValidated = + function(object) { + if (this.readyState == 4) { + if (this.status == '200') { + // success, add the external source element to the document + var selNode = object.editor.getSelectedNode(); + var currsource = object.getNearestExternalSource(selNode); + var doc = object.editor.getInnerDocument(); + + var extsource = doc.createElement('div'); + extsource.setAttribute('source_id', object._id); + var header = doc.createElement('h4'); + extsource.appendChild(header); + extsource.className = 'externalsource'; + var metatype = 'Silva Code Source'; // a default just in case + for (var i=0; i < + this.responseXML.documentElement.childNodes.length; i++) { + var child = this.responseXML.documentElement.childNodes[i]; + if (child.nodeName.toLowerCase() == 'parameter') { + var key = child.getAttribute('key'); + var value = ''; + for (var j=0; j < child.childNodes.length; j++) { + value += child.childNodes[j].nodeValue; }; + if (key == 'metatype') { + metatype = value; + continue; + }; + // for presentation only change some stuff + var displayvalue = value.toString(); + var attrkey = key; + if (child.getAttribute('type') == 'list') { + displayvalue = eval(value).join(', '); + attrkey = key + '__type__list'; + }; + extsource.setAttribute(attrkey, value); + key = key.replace(/_/g, ' '); + var textel = doc.createTextNode(key + ': ' + displayvalue); + extsource.appendChild(textel); + extsource.appendChild(doc.createElement('br')); }; - var htext = doc.createTextNode(metatype + ' \xab' + object._id + '\xbb'); - header.insertBefore(htext, header.firstChild); - extsource.appendChild(doc.createElement('br')); - if (!currsource) { - object.editor.insertNodeAtSelection(extsource); - } else { - currsource.parentNode.replaceChild(extsource, currsource); - var selection = object.editor.getSelection(); - selection.selectNodeContents(extsource); - selection.collapse(true); - }; - object.resetTool(); - object.editor.updateState(); - } else if (this.status == '400') { - // failure, provide some feedback and return to the form - alert('Form could not be validated, error message: ' + this.responseText); + }; + var htext = doc.createTextNode(metatype + ' \xab' + object._id + '\xbb'); + header.insertBefore(htext, header.firstChild); + extsource.appendChild(doc.createElement('br')); + if (!currsource) { + object.editor.insertNodeAtSelection(extsource); } else { - alert('POST failed with unhandled status ' + this.status); - throw('Error handling POST, server returned ' + this.status + ' HTTP status code'); + currsource.parentNode.replaceChild(extsource, currsource); + var selection = object.editor.getSelection(); + selection.selectNodeContents(extsource); + selection.collapse(true); }; + object.resetTool(); + object.editor.updateState(); + } else if (this.status == '400') { + // failure, provide some feedback and return to the form + alert('Form could not be validated, error message: ' + this.responseText); + } else { + alert('POST failed with unhandled status ' + this.status); + throw('Error handling POST, server returned ' + this.status + ' HTTP status code'); }; }; +}; - this.delExternalSource = function() { - var selNode = this.editor.getSelectedNode(); - var source = this.getNearestExternalSource(selNode); - if (!source) { - this.editor.logMessage('Not inside external source!', 1); - return; - }; - var nextsibling = source.nextSibling; - source.parentNode.removeChild(source); - if (nextsibling) { - var selection = this.editor.getSelection(); - selection.selectNodeContents(nextsibling); - selection.collapse(); - }; +SilvaExternalSourceTool.prototype.delExternalSource = function() { + var selNode = this.editor.getSelectedNode(); + var source = this.getNearestExternalSource(selNode); + if (!source) { + this.editor.logMessage('Not inside external source!', 1); + return; }; + var nextsibling = source.nextSibling; + source.parentNode.removeChild(source); + if (nextsibling) { + var selection = this.editor.getSelection(); + selection.selectNodeContents(nextsibling); + selection.collapse(); + }; +}; - this.resetTool = function() { - while (this.formcontainer.hasChildNodes()) { - this.formcontainer.removeChild(this.formcontainer.firstChild); - }; - this.idselect.style.display = 'inline'; - this.addbutton.style.display = 'inline'; - this.cancelbutton.style.display = 'none'; - this.updatebutton.style.display = 'none'; - this.delbutton.style.display = 'none'; - //this.editor.updateState(); - this._editing = false; +SilvaExternalSourceTool.prototype.resetTool = function() { + while (this.formcontainer.hasChildNodes()) { + this.formcontainer.removeChild(this.formcontainer.firstChild); }; + this.idselect.style.display = 'inline'; + this.addbutton.style.display = 'inline'; + this.cancelbutton.style.display = 'none'; + this.updatebutton.style.display = 'none'; + this.delbutton.style.display = 'none'; + //this.editor.updateState(); + this._editing = false; +}; - this._gatherFormData = function() { - /* walks through the form and creates a POST body */ - // XXX we may want to turn this into a helper function, since it's - // quite useful outside of this object I reckon - var form = this._form; - if (!form) { - this.editor.logMessage('Not currently editing'); - return; - }; - // first place all data into a dict, convert to a string later on - var data = {}; - for (var i=0; i < form.elements.length; i++) { - var child = form.elements[i]; - var elname = child.nodeName.toLowerCase(); - if (elname == 'input') { - var name = child.getAttribute('name'); - var type = child.getAttribute('type'); - if (!type || type == 'text' || type == 'hidden' || type == 'password') { - data[name] = child.value; - } else if (type == 'checkbox' || type == 'radio') { - if (child.checked) { - if (data[name]) { - if (typeof data[name] == typeof('')) { - var value = new Array(data[name]); - value.push(child.value); - data[name] = value; - } else { - data[name].push(child.value); - }; +SilvaExternalSourceTool.prototype._gatherFormData = function() { + /* walks through the form and creates a POST body */ + // XXX we may want to turn this into a helper function, since it's + // quite useful outside of this object I reckon + var form = this._form; + if (!form) { + this.editor.logMessage('Not currently editing'); + return; + }; + // first place all data into a dict, convert to a string later on + var data = {}; + for (var i=0; i < form.elements.length; i++) { + var child = form.elements[i]; + var elname = child.nodeName.toLowerCase(); + if (elname == 'input') { + var name = child.getAttribute('name'); + var type = child.getAttribute('type'); + if (!type || type == 'text' || type == 'hidden' || type == 'password') { + data[name] = child.value; + } else if (type == 'checkbox' || type == 'radio') { + if (child.checked) { + if (data[name]) { + if (typeof data[name] == typeof('')) { + var value = new Array(data[name]); + value.push(child.value); + data[name] = value; } else { - data[name] = child.value; + data[name].push(child.value); }; + } else { + data[name] = child.value; }; }; - } else if (elname == 'textarea') { - data[child.getAttribute('name')] = child.value; - } else if (elname == 'select') { - var name = child.getAttribute('name'); - var multiple = child.getAttribute('multiple'); - if (!multiple) { - data[name] = child.options[child.selectedIndex].value; - } else { - var value = new Array(); - for (var i=0; i < child.options.length; i++) { - if (child.options[i].checked) { - value.push(options[i].value); - }; - if (value.length > 1) { - data[name] = value; - } else if (value.length) { - data[name] = value[0]; - }; + }; + } else if (elname == 'textarea') { + data[child.getAttribute('name')] = child.value; + } else if (elname == 'select') { + var name = child.getAttribute('name'); + var multiple = child.getAttribute('multiple'); + if (!multiple) { + data[name] = child.options[child.selectedIndex].value; + } else { + var value = new Array(); + for (var j=0; j < child.options.length; j++) { + if (child.options[j].selected) { + value.push(child.options[j].value); }; }; + if (value.length > 1) { + data[name] = value; + } else if (value.length) { + data[name] = value[0]; + }; }; }; - - // now we should turn it into a query string - var ret = new Array(); - for (var key in data) { - var value = data[key]; + }; + + // now we should turn it into a query string + var ret = new Array(); + for (var key in data) { + var value = data[key]; + if (!(value instanceof Array)) { + value = [value]; + }; + for (var i=0; i < value.length; i++) { // XXX does IE5 support encodeURIComponent? - ret.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); + ret.push(encodeURIComponent(key) + '=' + + encodeURIComponent(value[i])); }; - - return ret.join("&"); }; - this._gatherFormDataFromElement = function() { - var selNode = this.editor.getSelectedNode(); - var source = this.getNearestExternalSource(selNode); - if (!source) { - return ''; - }; - var ret = new Array(); - for (var i=0; i < source.attributes.length; i++) { - var attr = source.attributes[i]; - var name = attr.nodeName; - var value = attr.nodeValue; - if (name != 'class' && name != 'source_id' && name != 'id') { - ret.push(encodeURIComponent(name) + '=' + encodeURIComponent(value)); - }; + return ret.join("&"); +}; + +SilvaExternalSourceTool.prototype._gatherFormDataFromElement = function() { + var selNode = this.editor.getSelectedNode(); + var source = this.getNearestExternalSource(selNode); + if (!source) { + return ''; + }; + var ret = new Array(); + for (var i=0; i < source.attributes.length; i++) { + var attr = source.attributes[i]; + var name = attr.nodeName; + var value = attr.nodeValue; + if (name != 'class' && name != 'source_id' && name != 'id') { + ret.push(encodeURIComponent(name) + '=' + encodeURIComponent(value)); }; - return ret.join('&'); }; + return ret.join('&'); +}; - this.getNearestExternalSource = function(selNode) { - - var currnode = selNode; - while (currnode) { - if (currnode.nodeName.toLowerCase() == 'div' && currnode.className == 'externalsource') { - return currnode; - }; - currnode = currnode.parentNode; +SilvaExternalSourceTool.prototype.getNearestExternalSource = function(selNode) { + + var currnode = selNode; + while (currnode) { + if (currnode.nodeName.toLowerCase() == 'div' && currnode.className == 'externalsource') { + return currnode; }; + currnode = currnode.parentNode; }; }; -SilvaExternalSourceTool.prototype = new KupuTool; - function SilvaKupuUI(textstyleselectid) { this.tsselect = getFromSelector(textstyleselectid); +}; - this.updateState = function(selNode) { - /* set the text-style pulldown */ +SilvaKupuUI.prototype = new KupuUI; - // first get the nearest style - var styles = {}; // use an object here so we can use the 'in' operator later on - for (var i=0; i < this.tsselect.options.length; i++) { - // XXX we should cache this - styles[this.tsselect.options[i].value] = i; - } - - // search the list of nodes like in the original one, break if we encounter a match, - // this method does some more than the original one since it can handle commands in - // the form of '