You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-commits@incubator.apache.org by cl...@apache.org on 2005/02/17 23:57:32 UTC
svn commit: r154214 [10/10] - in incubator/graffito/trunk/applications: ./
browser/ browser/src/ browser/src/java/ browser/src/java/org/
browser/src/java/org/apache/ browser/src/java/org/apache/portals/
browser/src/java/org/apache/portals/graffito/
browser/src/java/org/apache/portals/graffito/portlets/
browser/src/java/org/apache/portals/graffito/portlets/resources/
browser/src/java/org/apache/portals/graffito/portlets/util/
browser/src/java/org/apache/portals/graffito/servlets/
browser/src/java/org/apache/portals/graffito/util/ browser/src/webapp/
browser/src/webapp/WEB-INF/ browser/src/webapp/WEB-INF/tabs/
browser/src/webapp/WEB-INF/velocity/ browser/src/webapp/WEB-INF/view/
browser/src/webapp/WEB-INF/view/document/
browser/src/webapp/WEB-INF/view/folder/
browser/src/webapp/WEB-INF/view/security/ browser/src/webapp/kupu/
browser/src/webapp/kupu/kupudrawers/
browser/src/webapp/kupu/kupudrawers/logos/
browser/src/webapp/kupu/kupuimages/ browser/src/webapp/kupu/kupupopups/
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupumulti.html
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupumulti.html?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupumulti.html (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupumulti.html Thu Feb 17 15:57:09 2005
@@ -0,0 +1,365 @@
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Test Editor</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link href="kupustyles.css" rel="stylesheet" type="text/css"/>
+ <link href="kupudrawerstyles.css" rel="stylesheet" type="text/css"/>
+ <script type="text/javascript" src="sarissa.js"> </script>
+ <script type="text/javascript" src="kupuhelpers.js"> </script>
+ <script type="text/javascript" src="kupueditor.js"> </script>
+ <script type="text/javascript" src="kupubasetools.js"> </script>
+ <script type="text/javascript" src="kupuloggers.js"> </script>
+ <script type="text/javascript" src="kupucontentfilters.js"> </script>
+ <script type="text/javascript" src="kupumultieditor.js"> </script>
+ <script type="text/javascript" src="kupuinit_multi.js"> </script>
+ <script type="text/javascript" src="kupustart_multi.js"> </script>
+ <script type="text/javascript" src="kupusourceedit.js"> </script>
+ <script type="text/javascript" src="kupudrawers.js"> </script>
+ </head>
+ <body onload="kupu = startKupu()">
+ <h1>Kupu Editor Test Page</h1>
+ <form action="http://debris.demon.nl/printpost" method="POST">
+ <div style="display: none;">
+ <xml id="kupuconfig">
+ <kupuconfig>
+ <dst>fulldoc.html</dst>
+ <use_css>1</use_css>
+ <reload_after_save>0</reload_after_save>
+ <strict_output>1</strict_output>
+ <content_type>application/xhtml+xml</content_type>
+ <compatible_singletons>1</compatible_singletons>
+ <table_classes>
+ <class>plain</class>
+ <class>listing</class>
+ <class>grid</class>
+ <class>data</class>
+ </table_classes>
+ <image_xsl_uri>kupudrawers/drawer.xsl</image_xsl_uri>
+ <link_xsl_uri>kupudrawers/drawer.xsl</link_xsl_uri>
+ <image_libraries_uri>kupudrawers/imagelibrary.xml</image_libraries_uri>
+ <link_libraries_uri>kupudrawers/linklibrary.xml</link_libraries_uri>
+ <search_images_uri> </search_images_uri>
+ <search_links_uri> </search_links_uri>
+ </kupuconfig>
+ </xml>
+ </div>
+ <div class="kupu-fulleditor">
+ <div class="kupu-tb" id="toolbar">
+ <span id="kupu-tb-buttons">
+ <span class="kupu-tb-buttongroup" style="float: right" id="kupu-logo">
+ <button type="button" class="kupu-logo" title="Kupu 1.2rc1" accesskey="k" onclick="window.open('http://kupu.oscom.org');"> </button>
+ </span>
+ <select id="kupu-tb-styles">
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="P" i18n:translate="paragraph-normal">
+ Normal
+ </option>
+ <option value="H1"><span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="heading">Heading</span> 1
+ </option>
+ <option value="H2"><span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="heading">Heading</span> 2
+ </option>
+ <option value="H3"><span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="heading">Heading</span> 3
+ </option>
+ <option value="H4"><span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="heading">Heading</span> 4
+ </option>
+ <option value="H5"><span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="heading">Heading</span> 5
+ </option>
+ <option value="H6"><span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="heading">Heading</span> 6
+ </option>
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="PRE" i18n:translate="paragraph-formatted">
+ Formatted
+ </option>
+ </select>
+ <span class="kupu-tb-buttongroup">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-save" id="kupu-save-button" title="Save" i18n:attributes="title" accesskey="s" onclick="kupu.prepareForm(this.form, 'kupu'); this.form.submit()"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup" id="kupu-bg-basicmarkup">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-bold" id="kupu-bold-button" title="bold: alt-b" i18n:attributes="title" accesskey="b"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-italic" id="kupu-italic-button" title="italic: alt-i" i18n:attributes="title" accesskey="i"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-underline" id="kupu-underline-button" title="underline: alt-u" i18n:attributes="title" accesskey="u"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup" id="kupu-bg-subsuper">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-subscript" id="kupu-subscript-button" title="subscript: alt--" i18n:attributes="title" accesskey="-"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-superscript" id="kupu-superscript-button" title="superscript: alt-+" i18n:attributes="title" accesskey="+"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-forecolor" id="kupu-forecolor-button" title="text color: alt-f" i18n:attributes="title" accesskey="f"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-hilitecolor" id="kupu-hilitecolor-button" title="background color: alt-h" i18n:attributes="title" accesskey="h"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup" id="kupu-bg-justify">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-justifyleft" id="kupu-justifyleft-button" title="left justify: alt-l" i18n:attributes="title" accesskey="l"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-justifycenter" id="kupu-justifycenter-button" title="center justify: alt-c" i18n:attributes="title" accesskey="c"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-justifyright" id="kupu-justifyright-button" title="right justify: alt-r" i18n:attributes="title" accesskey="r"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup" id="kupu-bg-list">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-insertorderedlist" title="numbered list: alt-#" id="kupu-list-ol-addbutton" i18n:attributes="title" accesskey="#"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-insertunorderedlist" title="unordered list: alt-*" id="kupu-list-ul-addbutton" i18n:attributes="title" accesskey="*"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup" id="kupu-bg-definitionlist">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-insertdefinitionlist" title="definition list: alt-=" id="kupu-list-dl-addbutton" i18n:attributes="title" accesskey="="> </button>
+ </span>
+ <span class="kupu-tb-buttongroup" id="kupu-bg-indent">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-outdent" id="kupu-outdent-button" title="outdent: alt-<" i18n:attributes="title" accesskey="<"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-indent" id="kupu-indent-button" title="indent: alt->" i18n:attributes="title" accesskey=">"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-image" id="kupu-imagelibdrawer-button" title="image" i18n:attributes="title"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-inthyperlink" id="kupu-linklibdrawer-button" title="internal link" i18n:attributes="title"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-exthyperlink" id="kupu-linkdrawer-button" title="external link" i18n:attributes="title"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-table" id="kupu-tabledrawer-button" title="table" i18n:attributes="title"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup" id="kupu-bg-remove">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-removeimage invisible" id="kupu-removeimage-button" title="Remove image" i18n:attributes="title"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-removelink invisible" id="kupu-removelink-button" title="Remove link" i18n:attributes="title"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup" id="kupu-bg-undo">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-undo" id="kupu-undo-button" title="undo: alt-z" i18n:attributes="title" accesskey="z"> </button>
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-redo" id="kupu-redo-button" title="redo: alt-y" i18n:attributes="title" accesskey="y"> </button>
+ </span>
+ <span class="kupu-tb-buttongroup" id="kupu-source">
+ <button xmlns:i18n="http://xml.zope.org/namespaces/i18n" type="button" class="kupu-source" id="kupu-source-button" title="edit HTML code" i18n:attributes="title"> </button>
+ </span>
+ </span>
+ <select id="kupu-ulstyles">
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="disc" i18n:translate="list-disc">●</option>
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="square" i18n:translate="list-square">■</option>
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="circle" i18n:translate="list-circle">○</option>
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="none" i18n:translate="list-nobullet">no bullet</option>
+ </select>
+ <select id="kupu-olstyles">
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="decimal" i18n:translate="list-decimal">1</option>
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="upper-roman" i18n:translate="list-upperroman">I</option>
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="lower-roman" i18n:translate="list-lowerroman">i</option>
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="upper-alpha" i18n:translate="list-upperalpha">A</option>
+ <option xmlns:i18n="http://xml.zope.org/namespaces/i18n" value="lower-alpha" i18n:translate="list-loweralpha">a</option>
+ </select>
+ <div style="display:block;">
+ <div id="kupu-librarydrawer" class="kupu-drawer">
+ </div>
+ </div>
+ <div id="kupu-linkdrawer" class="kupu-drawer">
+ <h1 xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="">External Link</h1>
+ <div id="kupu-linkdrawer-addlink" class="kupu-panels">
+ <table>
+ <tr>
+ <td>
+ <div class="kupu-toolbox-label"><span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="items-matching-keyword">
+ Link the highlighted text to this URL
+ </span>:
+ </div>
+ <input id="kupu-linkdrawer-input" class="kupu-toolbox-st" type="text"/>
+ </td>
+ <td class="kupu-preview-button">
+ <button type="button" onclick="drawertool.current_drawer.preview()">Preview</button>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center">
+ <iframe frameborder="1" scrolling="auto" width="440" height="198" id="kupu-linkdrawer-preview" src="kupublank.html">
+ </iframe>
+ </td>
+ </tr>
+ </table>
+ <div class="kupu-dialogbuttons">
+ <button type="button" onclick="drawertool.current_drawer.save()">Ok</button>
+ <button type="button" onclick="drawertool.closeDrawer()">Cancel</button>
+ </div>
+ </div>
+ </div>
+ <div id="kupu-tabledrawer" class="kupu-drawer">
+ <h1>Table</h1>
+ <div class="kupu-panels">
+ <table width="99%">
+ <tr class="kupu-panelsrow">
+ <td class="kupu-panel">
+ <table width="100%">
+ <tbody>
+ <tr>
+ <td class="kupu-toolbox-label">Table Class</td>
+ <td width="50%">
+ <select id="kupu-tabledrawer-classchooser" onchange="drawertool.current_drawer.tool.setTableClass(this.options[this.selectedIndex].value)">
+ <option value="plain">Plain</option>
+ <option value="listing">Listing</option>
+ <option value="grid">Grid</option>
+ <option value="data">Data</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="">
+ <div id="kupu-tabledrawer-addtable">
+ <table width="100%">
+ <tr>
+ <td class="kupu-toolbox-label" width="50%">Rows</td>
+ <td>
+ <input type="text" id="kupu-tabledrawer-newrows"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="kupu-toolbox-label">Columns</td>
+ <td>
+ <input type="text" id="kupu-tabledrawer-newcols"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="kupu-toolbox-label">Headings</td>
+ <td class="kupu-toolbox-label">
+ <input name="kupu-tabledrawer-makeheader" id="kupu-tabledrawer-makeheader" type="checkbox"/>
+ <label for="kupu-tabledrawer-makeheader">Create</label>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" style="text-align: center">
+ <button type="button" onclick="drawertool.current_drawer.createTable()">Add Table</button>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" style="text-align: center">
+ <button type="button" onclick="drawertool.current_drawer.tool.fixAllTables()">Fix All Tables</button>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div id="kupu-tabledrawer-edittable">
+ <table width="100%">
+ <tr>
+ <td width="50%">Current column alignment</td>
+ <td>
+ <select id="kupu-tabledrawer-alignchooser" onchange="drawertool.current_drawer.tool.setColumnAlign(this.options[this.selectedIndex].value)">
+ <option value="left">Left</option>
+ <option value="center">Center</option>
+ <option value="right">Right</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>Column</td>
+ <td>
+ <button type="button" id="kupu-tabledrawer-addcolumn-button" onclick="drawertool.current_drawer.tool.addTableColumn()">Add</button>
+ <button type="button" id="kupu-tabledrawer-delcolumn-button" onclick="drawertool.current_drawer.tool.delTableColumn()">Remove</button>
+ </td>
+ </tr>
+ <tr>
+ <td>Row</td>
+ <td>
+ <button type="button" id="kupu-tabledrawer-addrow-button" onclick="drawertool.current_drawer.tool.addTableRow()">Add</button>
+ <button type="button" id="kupu-tabledrawer-delrow-button" onclick="drawertool.current_drawer.tool.delTableRow()">Remove</button>
+ </td>
+ </tr>
+ <tr>
+ <td>Fix Table</td>
+ <td>
+ <button type="button" id="kupu-tabledrawer-addrow-button" onclick="drawertool.current_drawer.tool.fixTable()">Fix</button>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <div class="kupu-dialogbuttons">
+ <button type="button" onclick="drawertool.closeDrawer()">Close</button>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div xmlns="" class="kupu-toolboxes">
+ <div class="kupu-toolbox" id="kupu-toolbox-links">
+ <h1 xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="links">Links</h1>
+ <div id="kupu-toolbox-addlink">
+ <div class="kupu-toolbox-label">
+ <span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="items-matching-keyword">
+ Link the highlighted text to this URL:
+ </span>
+ </div>
+ <input id="kupu-link-input" class="wide" type="text"/>
+ <div class="kupu-toolbox-buttons">
+ <button type="button" id="kupu-link-button" class="kupu-toolbox-action">Make Link</button>
+ </div>
+ </div>
+ </div>
+ <div class="kupu-toolbox" id="kupu-toolbox-images">
+ <h1 xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="images">Images</h1>
+ <div class="kupu-toolbox-label">
+ <span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="">
+ Insert image at the following URL:
+ </span>
+ </div>
+ <input id="kupu-image-input" value="kupuimages/kupu_icon.gif" class="wide" type="text"/>
+ <span xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="">
+ Image float:
+ </span>
+ <select class="wide" id="kupu-image-float-select">
+ <option value="none">No float</option>
+ <option value="left">Left</option>
+ <option value="right">Right</option>
+ </select>
+ <div class="kupu-toolbox-buttons">
+ <button type="button" id="kupu-image-addbutton" class="kupu-toolbox-action">Insert Image</button>
+ </div>
+ </div>
+ <div class="kupu-toolbox" id="kupu-toolbox-tables">
+ <h1 xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="table-inspector">Tables</h1>
+ <div class="kupu-toolbox-label">Table Class:
+ <select class="wide" id="kupu-table-classchooser"> </select>
+ </div>
+ <div id="kupu-toolbox-addtable">
+ <div class="kupu-toolbox-label">Rows:</div>
+ <input class="wide" type="text" id="kupu-table-newrows"/>
+ <div class="kupu-toolbox-label">Columns:</div>
+ <input class="wide" type="text" id="kupu-table-newcols"/>
+ <div class="kupu-toolbox-label">
+ Headings:
+ <input name="kupu-table-makeheader" id="kupu-table-makeheader" type="checkbox"/>
+ <label for="kupu-table-makeheader">Create</label>
+ </div>
+ <div class="kupu-toolbox-buttons">
+ <button type="button" id="kupu-table-fixall-button">Fix Table</button>
+ <button type="button" id="kupu-table-addtable-button">Add Table</button>
+ </div>
+ </div>
+ <div id="kupu-toolbox-edittable">
+ <div class="kupu-toolbox-label">Col Align:
+ <select class="wide" id="kupu-table-alignchooser"><option value="left">Left</option><option value="center">Center</option><option value="right">Right</option></select>
+ </div>
+ <div class="kupu-toolbox-buttons">
+ <br/>
+ <button type="button" id="kupu-table-addcolumn-button">Add Column</button>
+ <button type="button" id="kupu-table-delcolumn-button">Remove Column</button>
+ <br/>
+ <button type="button" id="kupu-table-addrow-button">Add Row</button>
+ <button type="button" id="kupu-table-delrow-button">Remove Row</button>
+ <button type="button" id="kupu-table-fix-button">Fix</button>
+ </div>
+ </div>
+ </div>
+ <div class="kupu-toolbox" id="kupu-toolbox-debug">
+ <h1 xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:translate="debug-log">Debug Log</h1>
+ <div id="kupu-toolbox-debuglog" class="kupu-toolbox-label">
+ </div>
+ </div>
+ </div>
+ <table id="kupu-colorchooser" cellpadding="0" cellspacing="0" style="position: fixed; border-style: solid; border-color: black; border-width: 1px;">
+ </table>
+ <div class="kupu-editorframe">
+ <iframe id="kupu_1" frameborder="0" src="fulldoc.html" fieldid="kupu_1" style="height: 200px;" scrolling="auto">
+ </iframe>
+ <textarea class="kupu-editor-textarea" id="kupu-editor-textarea-kupu_1" style="width: 99%; height: 200px;">
+ </textarea>
+ <iframe id="kupu_2" frameborder="0" src="fulldoc.html" fieldid="kupu_2" style="height: 200px;" scrolling="auto">
+ </iframe>
+ <textarea class="kupu-editor-textarea" id="kupu-editor-textarea-kupu_2" style="width: 99%; height: 200px;">
+ </textarea>
+ <iframe id="kupu_3" frameborder="0" src="fulldoc.html" fieldid="kupu_3" style="height: 200px;" scrolling="auto">
+ </iframe>
+ <textarea class="kupu-editor-textarea" id="kupu-editor-textarea-kupu_3" style="width: 99%; height: 200px;">
+ </textarea>
+ </div>
+ </div>
+ </form>
+ </body>
+</html>
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupumultieditor.js
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupumultieditor.js?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupumultieditor.js (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupumultieditor.js Thu Feb 17 15:57:09 2005
@@ -0,0 +1,190 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2004 Kupu Contributors. All rights reserved.
+ *
+ * This software is distributed under the terms of the Kupu
+ * License. See LICENSE.txt for license text. For a list of Kupu
+ * Contributors see CREDITS.txt.
+ *
+ *****************************************************************************/
+
+// $Id: kupumultieditor.js 3450 2004-03-28 11:07:30Z guido $
+
+function KupuMultiEditor(documents, config, logger) {
+ /* multiple kupus in one form */
+ this.documents = documents; // array of documents
+ this.config = config;
+ this.log = logger;
+ this.tools = {};
+
+ this._designModeAttempts = 0;
+ this._initialized = false;
+
+ this._previous_range = null;
+
+ // here's where the current active document will be stored
+ this._current_document = documents[0];
+
+ this.initialize = function() {
+ this._initializeEventHandlers();
+ this.getDocument().getWindow().focus();
+ if (this.getBrowserName() == 'IE') {
+ for (var i=0; i < this.documents.length; i++) {
+ var body = this.documents[i].getDocument().getElementsByTagName('body')[0];
+ body.setAttribute('contentEditable', 'true');
+ };
+ // provide an 'afterInit' method on KupuEditor.prototype
+ // for additional bootstrapping (after editor init)
+ this._initialized = true;
+ if (this.afterInit) {
+ this.afterInit();
+ };
+ this._saveSelection();
+ this.logMessage('Editor initialized');
+ } else {
+ this._setDesignModeWhenReady();
+ };
+ };
+
+ this.updateStateHandler = function(event) {
+ /* check whether the event is interesting enough to trigger the
+ updateState machinery and act accordingly */
+ var interesting_codes = new Array(8, 13, 37, 38, 39, 40, 46);
+ if (event.type == 'click' || event.type == 'dblclick' ||
+ event.type == 'select' ||
+ (event.type == 'keyup' &&
+ interesting_codes.contains(event.keyCode))) {
+ var target = event.target ? event.target : event.srcElement;
+ // find the document targeted
+ while (target.nodeType != 9) {
+ target = target.parentNode;
+ };
+ var document = null;
+ for (var i=0; i < this.documents.length; i++) {
+ document = this.documents[i];
+ if (document.getDocument() == target) {
+ break;
+ };
+ };
+ if (!document) {
+ alert('No document found!');
+ return;
+ };
+ this._current_document = document;
+ this.updateState(event);
+ };
+ // unfortunately it's not possible to do this on blur, since that's
+ // too late. also (some versions of?) IE 5.5 doesn't support the
+ // onbeforedeactivate event, which would be ideal here...
+ if (this.getBrowserName() == 'IE') {
+ this._saveSelection();
+ };
+ };
+
+ this.saveDocument = function() {
+ throw('Not supported, use prepareForm to attach the editor to a form');
+ };
+
+ this.getDocument = function() {
+ /* return the current active document */
+ return this._current_document;
+ };
+
+ this._initializeEventHandlers = function() {
+ /* attache the event handlers to the iframe */
+ for (var i=0; i < this.documents.length; i++) {
+ var doc = this.documents[i].getDocument();
+ this._addEventHandler(doc, "click", this.updateStateHandler, this);
+ this._addEventHandler(doc, "keyup", this.updateStateHandler, this);
+ if (this.getBrowserName() == "IE") {
+ this._addEventHandler(doc, "dblclick", this.updateStateHandler, this);
+ this._addEventHandler(doc, "select", this.updateStateHandler, this);
+ };
+ };
+ };
+
+ this._setDesignModeWhenReady = function() {
+ this._designModeSetAttempts++;
+ if (this._designModeSetAttempts > 25) {
+ alert('Couldn\'t set design mode. Kupu will not work on this browser.');
+ return;
+ };
+ var should_retry = false;
+ for (var i=0; i < this.documents.length; i++) {
+ var document = this.documents[i];
+ if (!document._designModeSet) {
+ try {
+ this._setDesignMode(document);
+ document._designModeSet = true;
+ } catch(e) {
+ should_retry = true;
+ };
+ };
+ };
+ if (should_retry) {
+ timer_instance.registerFunction(this, this._setDesignModeWhenReady, 100);
+ } else {
+ // provide an 'afterInit' method on KupuEditor.prototype
+ // for additional bootstrapping (after editor init)
+ if (this.afterInit) {
+ this.afterInit();
+ };
+ this._initialized = true;
+ };
+ };
+
+ this._setDesignMode = function(doc) {
+ doc.getDocument().designMode = "On";
+ doc.execCommand("undo");
+ };
+
+ // XXX perhaps we can partially move this to a helper method to approve
+ // code reuse?
+ this.prepareForm = function(form, idprefix) {
+ /* add some fields to the form and place the contents of the iframes
+ */
+ var sourcetool = this.getTool('sourceedittool');
+ if (sourcetool) {sourcetool.cancelSourceMode();};
+
+ // make sure people can't edit or save during saving
+ if (!this._initialized) {
+ return;
+ }
+ this._initialized = false;
+
+ // set the window status so people can see we're actually saving
+ window.status= "Please wait while saving document...";
+
+ // set a default id
+ if (!idprefix) {
+ idprefix = 'kupu';
+ };
+
+ // pass the content through the filters
+ this.logMessage("Starting HTML cleanup");
+ var contents = new Array();
+ for (var i=0; i < this.documents.length; i++) {
+ var transform = this._filterContent(this.documents[i].getDocument().documentElement);
+ contents.push(this._serializeOutputToString(transform));
+ };
+
+ this.logMessage("Cleanup done, sending document to server");
+
+ // now create the form input, since IE 5.5 doesn't support the
+ // ownerDocument property we use window.document as a fallback (which
+ // will almost by definition be correct).
+ var document = form.ownerDocument ? form.ownerDocument : window.document;
+ for (var i=0; i < contents.length; i++) {
+ var ta = document.createElement('textarea');
+ ta.style.visibility = 'hidden';
+ var text = document.createTextNode(contents[i]);
+ ta.appendChild(text);
+ ta.setAttribute('name', idprefix + '_' + i);
+
+ // and add it to the form
+ form.appendChild(ta);
+ };
+ };
+};
+
+KupuMultiEditor.prototype = new KupuEditor;
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupupopups/image.html
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupupopups/image.html?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupupopups/image.html (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupupopups/image.html Thu Feb 17 15:57:09 2005
@@ -0,0 +1,31 @@
+<html>
+<head>
+<title>Kupu image box</title>
+<script type="text/javascript">
+
+function saveImage() {
+ var f = document.getElementById('imageform');
+ imagetool.createImage(f.url.value);
+ window.close();
+};
+
+</script>
+<link type="text/css" rel="stylesheet" href="kupustyles.css" />
+</head>
+
+<body>
+<center>
+<form action="." method="POST" id="imageform">
+<h3>Image url:</h3>
+<table>
+<tr>
+<td>Url:</td>
+<td><input type="text" name="url" value="http://" /></td>
+</tr>
+</table>
+<input type="button" onclick="window.close()" value="Cancel" />
+<input type="button" onclick="saveImage()" value="Save image" />
+</form>
+</center>
+</body>
+</html>
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupupopups/link.html
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupupopups/link.html?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupupopups/link.html (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupupopups/link.html Thu Feb 17 15:57:09 2005
@@ -0,0 +1,58 @@
+<html>
+<head>
+<title>Kupu link box</title>
+<script type="text/javascript">
+
+function changeType(element) {
+ if (element.value == "anchor") {
+ element.form.url.setAttribute("disabled", "disabled");
+ element.form.target.setAttribute("disabled", "disabled");
+ } else {
+ element.form.url.removeAttribute("disabled");
+ element.form.target.removeAttribute("disabled");
+ };
+};
+
+function saveLink() {
+ var f = document.getElementById('linkform');
+ var typeel = document.getElementById('anchorradio');
+ var linktype = (typeel.checked || typeel.getAttribute('checked')) ? 'anchor' : 'link';
+ linktool.createLink(f.url.value, linktype, f.name.value, f.target.value);
+ window.close();
+};
+
+</script>
+<link type="text/css" rel="stylesheet" href="kupustyles.css" />
+</head>
+
+<body>
+<center>
+<form action="." method="POST" id="linkform">
+<h3>Link details:</h3>
+<table>
+<tr>
+<td>Type:</td>
+<td>
+<input type="radio" name="linktype" value="link" onclick="changeType(this)" checked="checked" />Link
+<input type="radio" name="linktype" id="anchorradio" value="anchor" onclick="changeType(this)" />Anchor
+</td>
+</tr>
+<tr>
+<td>Url:</td>
+<td><input type="text" name="url" value="http://" /></td>
+</tr>
+<tr>
+<td>Target:</td>
+<td><input type="text" name="target" value="_self" /></td>
+</tr>
+<tr>
+<td>Name:</td>
+<td><input type="text" name="name" /></td>
+</tr>
+</table>
+<input type="button" onclick="window.close()" value="Cancel" />
+<input type="button" onclick="saveLink()" value="Save link" />
+</form>
+</center>
+</body>
+</html>
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupusaveonpart.js
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupusaveonpart.js?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupusaveonpart.js (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupusaveonpart.js Thu Feb 17 15:57:09 2005
@@ -0,0 +1,20 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2004 Kupu Contributors. All rights reserved.
+ *
+ * This software is distributed under the terms of the Kupu
+ * License. See LICENSE.txt for license text. For a list of Kupu
+ * Contributors see CREDITS.txt.
+ *
+ *****************************************************************************/
+
+// $Id: kupusaveonpart.js 6741 2004-09-27 09:52:44Z duncan $
+
+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?')) {
+ kupu.config.reload_src = 0;
+ kupu.saveDocument(false, true);
+ };
+};
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupusourceedit.js
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupusourceedit.js?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupusourceedit.js (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupusourceedit.js Thu Feb 17 15:57:09 2005
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2004 Kupu Contributors. All rights reserved.
+ *
+ * This software is distributed under the terms of the Kupu
+ * License. See LICENSE.txt for license text. For a list of Kupu
+ * Contributors see CREDITS.txt.
+ *
+ *****************************************************************************/
+
+// $Id$
+
+
+function SourceEditTool(sourcebuttonid, sourceareaid) {
+ /* Source edit tool to edit document's html source */
+ this.sourceButton = document.getElementById(sourcebuttonid);
+ this.sourcemode = false;
+ this._currently_editing = null;
+
+ this.getSourceArea = function() {
+ return document.getElementById(sourceareaid);
+ }
+
+ this.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();
+ }
+ 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();
+ };
+
+ kupu._initialized = true;
+ this._currently_editing = null;
+ };
+ this.sourcemode = !this.sourcemode;
+ };
+};
+
+SourceEditTool.prototype = new KupuTool;
+
+function MultiSourceEditTool(sourcebuttonid, textareaprefix) {
+ /* Source edit tool to edit document's html source */
+ this.sourceButton = document.getElementById(sourcebuttonid);
+ this.textareaprefix = textareaprefix;
+
+ this.getSourceArea = function() {
+ var docobj = this._currently_editing||kupu.getDocument();
+ var sourceareaid = this.textareaprefix + docobj.getEditable().id;
+ return document.getElementById(sourceareaid);
+ }
+
+ this._currently_editing = null;
+
+};
+
+MultiSourceEditTool.prototype = new SourceEditTool;
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart.js
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart.js?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart.js (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart.js Thu Feb 17 15:57:09 2005
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2004 Kupu Contributors. All rights reserved.
+ *
+ * This software is distributed under the terms of the Kupu
+ * License. See LICENSE.txt for license text. For a list of Kupu
+ * Contributors see CREDITS.txt.
+ *
+ *****************************************************************************/
+
+// $Id$
+
+function startKupu() {
+ // initialize the editor, initKupu groks 1 arg, a reference to the iframe
+ var frame = document.getElementById('kupu-editor');
+ var kupu = initKupu(frame);
+
+ // this makes the editor's content_changed attribute set according to changes
+ // in a textarea or input (registering onchange, see saveOnPart() for more
+ // details)
+ kupu.registerContentChanger(document.getElementById('kupu-editor-textarea'));
+
+ // let's register saveOnPart(), to ask the user if he wants to save when
+ // leaving after editing
+ if (kupu.getBrowserName() == 'IE') {
+ // IE supports onbeforeunload, so let's use that
+ addEventHandler(window, 'beforeunload', saveOnPart);
+ } else {
+ // some versions of Mozilla support onbeforeunload (starting with 1.7)
+ // so let's try to register and if it fails fall back on onunload
+ var re = /rv:([0-9\.]+)/
+ var match = re.exec(navigator.userAgent)
+ if (match[1] && parseFloat(match[1]) > 1.6) {
+ addEventHandler(window, 'beforeunload', saveOnPart);
+ } else {
+ addEventHandler(window, 'unload', saveOnPart);
+ };
+ };
+
+ // and now we can initialize...
+ kupu.initialize();
+
+ return kupu;
+};
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart_form.js
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart_form.js?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart_form.js (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart_form.js Thu Feb 17 15:57:09 2005
@@ -0,0 +1,19 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2004 Kupu Contributors. All rights reserved.
+ *
+ * This software is distributed under the terms of the Kupu
+ * License. See LICENSE.txt for license text. For a list of Kupu
+ * Contributors see CREDITS.txt.
+ *
+ *****************************************************************************/
+
+// $Id$
+
+function startKupu() {
+ var frame = document.getElementById('kupu-editor-textarea');
+ var kupu = initKupu(frame);
+ kupu.initialize();
+
+ return kupu;
+};
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart_multi.js
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart_multi.js?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart_multi.js (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustart_multi.js Thu Feb 17 15:57:09 2005
@@ -0,0 +1,19 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2004 Kupu Contributors. All rights reserved.
+ *
+ * This software is distributed under the terms of the Kupu
+ * License. See LICENSE.txt for license text. For a list of Kupu
+ * Contributors see CREDITS.txt.
+ *
+ *****************************************************************************/
+
+// $Id$
+
+function startKupu() {
+ var iframeids = new Array('kupu_1', 'kupu_2', 'kupu_3');
+ var kupu = initKupu(iframeids);
+ kupu.initialize();
+
+ return kupu;
+};
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustyles.css
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustyles.css?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustyles.css (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/kupustyles.css Thu Feb 17 15:57:09 2005
@@ -0,0 +1,266 @@
+/*****************************************************************************
+ *
+ * Kupu common styles
+ *
+ * Copyright (c) 2003-2004 Kupu Contributors. See CREDITS.txt
+ *
+ * Instead of customizing this file, it is recommended to add your own
+ * CSS file. Feel free to use whole or parts of this for your own
+ * designs, but give credit where credit is due.
+ *
+ *****************************************************************************/
+
+/* $Id: kupustyles.css 8344 2005-01-17 16:58:34Z duncan $ */
+
+.kupu-fulleditor, .kupu-toolboxes {
+ font-family: Verdana, "Lucida Grande", Helvetica, Arial, sans-serif;
+}
+
+div.kupu-fulleditor .kupu-fulleditor-zoomed {
+ border: solid 3px ButtonHighlight;
+ margin: 0.2em;
+ height: 100%;
+}
+
+div.kupu-fulleditor .kupu-editorframe {
+ margin-right: 20em;
+}
+
+div.kupu-fulleditor-zoomed {
+ z-index: 1;
+ margin: 0; border: none;
+ position: fixed;
+ top: 0; left: 0;
+}
+
+* html div.kupu-fulleditor-zoomed {
+ position: absolute; /* IE */
+}
+
+div.kupu-fulleditor-zoomed .kupu-editor-iframe {
+ border: none;
+ border-top: solid black 1px;
+ margin: 0;
+}
+
+div.kupu-smalleditor .kupu-editorframe {
+ margin-right: 0.2em;
+}
+
+/*
+div.kupu-sourcemode #kupu-editor {
+ display: none;
+}
+
+div.kupu-sourcemode textarea.kupu-editor-textarea {
+ display: block;
+}*/
+
+div.kupu-sourcemode span.kupu-tb-buttongroup,
+div.kupu-sourcemode select { display: none; }
+div.kupu-sourcemode span#kupu-logo,
+div.kupu-sourcemode span#kupu-source { display: inline; }
+
+div.kupu-smalleditor {
+ font-family: Verdana, "Lucida Grande", Helvetica, Arial, sans-serif;
+ border: solid 3px ButtonHighlight;
+ margin: 0.2em;
+ height: 100%;
+}
+
+.kupu-tb {
+ padding: 3px;
+ margin-bottom: 0.4em;
+ background-color: ButtonFace;
+ border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
+}
+
+#kupu-tb-buttons button {
+ color: ButtonText;
+ border: 1px solid ButtonFace;
+ margin-top: 0;
+ margin-left: 0;
+ height: 26px;
+ width: 26px;
+ background-repeat: no-repeat;
+}
+
+#kupu-tb-buttons button:hover {
+ cursor: default;
+ border: 1px solid;
+ border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
+}
+
+#kupu-tb-buttons button:active {
+ border: 1px solid;
+ border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
+}
+
+.kupu-tb-buttongroup {
+ margin-left: 2px;
+ margin-right: 2px;
+}
+
+
+.kupu-bold {background-image: url("kupuimages/bold.png");}
+.kupu-bold-pressed {background-image: url("kupuimages/bold.png"); background-color: white;}
+.kupu-forecolor {background-image: url("kupuimages/text-color.png");}
+.kupu-hilitecolor {background-image: url("kupuimages/background-color.png");}
+
+.kupu-inthyperlink {background-image: url("kupuimages/inthyperlink.png");}
+.kupu-inthyperlink-pressed {background-image: url("kupuimages/inthyperlink.png"); background-color: white}
+.kupu-exthyperlink {background-image: url("kupuimages/exthyperlink.png");}
+.kupu-exthyperlink-pressed {background-image: url("kupuimages/exthyperlink.png"); background-color: white}
+
+.kupu-image {background-image: url("kupuimages/image.png");}
+.kupu-indent {background-image: url("kupuimages/indent.png");}
+.kupu-inserthorizontalrule {background-image: url("kupuimages/hr.png");}
+.kupu-insertorderedlist {background-image: url("kupuimages/ordered-list.png");}
+.kupu-insertunorderedlist {background-image: url("kupuimages/unordered-list.png");}
+.kupu-insertdefinitionlist {background-image: url("kupuimages/definitionlist.png");}
+.kupu-italic {background-image: url("kupuimages/italic.png");}
+.kupu-italic-pressed {background-image: url("kupuimages/italic.png"); background-color: white}
+.kupu-justifycenter {background-image: url("kupuimages/justify-center.png");}
+.kupu-justifyleft {background-image: url("kupuimages/justify-left.png");}
+.kupu-justifyright {background-image: url("kupuimages/justify-right.png");}
+.kupu-logo {background-image: url("kupuimages/kupu_icon.gif");}
+.kupu-outdent {background-image: url("kupuimages/outdent.png");}
+.kupu-redo {background-image: url("kupuimages/redo.png");}
+.kupu-save {background-image: url("kupuimages/save.png");}
+.kupu-save-and-exit {background-image: url("kupuimages/exit.gif");}
+.kupu-space {background-image: url("kupuimages/space.gif");}
+.kupu-source {background-image: url("kupuimages/view-source.png");}
+.kupu-subscript {background-image: url("kupuimages/subscript.png");}
+.kupu-subscript-pressed {background-image: url("kupuimages/subscript.png"); background-color: white}
+.kupu-superscript {background-image: url("kupuimages/superscript.png");}
+.kupu-superscript-pressed {background-image: url("kupuimages/superscript.png"); background-color: white}
+.kupu-table {background-image: url("kupuimages/table.png");}
+.kupu-underline {background-image: url("kupuimages/underline.png");}
+.kupu-underline-pressed {background-image: url("kupuimages/underline.png"); background-color: white}
+.kupu-undo {background-image: url("kupuimages/undo.png");}
+.kupu-removelink {background-image: url("kupuimages/remove.png");}
+.kupu-removeimage {background-image: url("kupuimages/remove.png");}
+.kupu-zoom {background-image: url("kupuimages/zoom-in.gif");}
+.kupu-zoom-pressed {background-image: url("kupuimages/zoom-out.gif");}
+
+#kupu-tb-buttons button.invisible {
+ display: none;
+ /*visibility: hidden;*/
+}
+
+#kupu-tb-buttons button.visible {
+ display: inline;
+}
+
+div.kupu-editorframe {
+ margin-left: 0.3em;
+ margin-bottom: 0.3em;
+ border: solid 2px ButtonFace;
+}
+
+#kupu-editor {
+ height: 450px;
+ width: 99%;
+}
+
+textarea.kupu-editor-textarea {
+ height: 450px;
+ width: 99%;
+ display: none;
+}
+
+div.kupu-toolboxes {
+ float: right;
+ border: solid 2px ButtonFace;
+ width: 19.4em;
+ margin-right: 0.3em;
+ margin-bottom: 0.3em;
+ font-size: 0.8em;
+}
+
+div.kupu-toolbox, div.kupu-toolbox-active {
+ margin-bottom: 1em;
+}
+
+div.kupu-toolbox h1, div.kupu-toolbox-active h1 {
+ text-align: center;
+ width: 100%;
+ background-color: ButtonFace;
+ margin-top: 0;
+ font-size: 1.1em;
+}
+
+div.kupu-toolbox-label, span.kupu-toolbox-searchterm,
+input.wide, select.wide, textarea.wide, button.kupu-toolbox-action,
+div.kupu-toolbox-results {
+ margin-left: 0.2em;
+ margin-right: 0.2em;
+}
+
+.wide {
+ width: 95%;
+}
+
+div.kupu-toolbox-label {
+ margin-bottom: 0.4em;
+}
+
+.kupu-toolbox-buttons {
+ text-align: center;
+}
+
+.kupu-toolbox-buttons button {
+ width: 45%;
+}
+
+div.kupu-toolbox-results {
+ border: solid 2px ButtonFace;
+ margin-top: 0.8em;
+ text-decoration: underline;
+ padding: 0.2em;
+ display: none;
+}
+
+div.kupu-toolbox table#kupu-toolbox-addtable input,
+div.kupu-toolbox-active table#kupu-toolbox-edittable input {
+ width: 20px;
+}
+
+div.kupu-toolbox-active {
+ background-color: ButtonFace;
+}
+
+div.kupu-toolbox button {
+ font-size: 0.9em;
+ border: 1px solid;
+ border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
+}
+
+div.kupu-toolbox button:active {
+ border: 1px solid;
+ border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
+}
+
+#kupu-toolbox-editlink, #kupu-toolbox-edittable,
+#kupu-ulstyles, #kupu-olstyles {
+ display: none;
+}
+
+
+div#kupu-colorchooser {
+ position: absolute;
+ visibility: hidden;
+ border: solid black 1px;
+ background-color: white;
+ padding: 0.2em;
+ font-size: small;
+}
+
+.kupu-toolboxes input, .kupu-toolboxes select, .kupu-toolboxes textarea {
+ font-size: x-small;
+ font-family: Verdana, "Lucida Grande", Helvetica, Arial, sans-serif;
+}
+
+div#kupu-fgcolorchooser div:hover {
+ /* border: outset 1px; */
+}
Added: incubator/graffito/trunk/applications/browser/src/webapp/kupu/sarissa.js
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/kupu/sarissa.js?view=auto&rev=154214
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/kupu/sarissa.js (added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/kupu/sarissa.js Thu Feb 17 15:57:09 2005
@@ -0,0 +1,734 @@
+/*****************************************************************************
+ *
+ * Sarissa XML library version 0.9.3
+ * Copyright (c) 2003 Manos Batsis, mailto: mbatsis@netsmart.gr
+ * This software is distributed under the Kupu License. See
+ * LICENSE.txt for license text. See the Sarissa homepage at
+ * http://sarissa.sourceforge.net for more information.
+ *
+ *****************************************************************************/
+
+// $Id: sarissa.js 6908 2004-10-11 19:50:17Z paul $
+
+
+/**
+ * <p>
+ * Sarissa is a utility class. Provides factory methods for DOMDocument and XMLHTTP objects between other goodies.
+ * </p>
+ *
+ * @constructor
+ */
+function Sarissa(){}
+Sarissa.IS_ENABLED_TRANSFORM_NODE = false;
+Sarissa.IS_ENABLED_XMLHTTP = false;
+Sarissa.IS_ENABLED_XSLTPROC = false;
+Sarissa.IS_ENABLED_SELECT_NODES = false;
+// some basic browser detection TODO: change this
+var _SARISSA_IS_IE = (navigator.userAgent.toLowerCase().indexOf("msie") > -1)?true:false;
+var _SARISSA_IS_MOZ = (document.implementation && document.implementation.createDocument)?true:false;
+var _sarissa_iNsCounter = 0;
+var _SARISSA_IEPREFIX4XSLPARAM = "";
+if (_SARISSA_IS_MOZ){
+ if(XSLTProcessor && XSLTProcessor.prototype){
+ Sarissa.IS_ENABLED_TRANSFORM_NODE = true;
+ if(XSLTProcessor.prototype.reset){
+ Sarissa.IS_ENABLED_XSLTPROC = true;
+ };
+ };
+ if(XMLHttpRequest && XMLHttpRequest.prototype){
+ Sarissa.IS_ENABLED_XMLHTTP = true;
+ };
+ if(document.implementation.hasFeature && document.implementation.hasFeature("XPath", "3.0")){
+ Sarissa.IS_ENABLED_SELECT_NODES = true;
+ };
+ /**
+ * <p>Factory method to obtain a new DOM Document object</p>
+ * @argument sUri the namespace of the root node (if any)
+ * @argument sUri the local name of the root node (if any)
+ * @returns a new DOM Document
+ */
+ Sarissa.getDomDocument = function(sUri, sName){
+ var oDoc = document.implementation.createDocument(sUri, sName, null);
+ oDoc.addEventListener("load", _sarissa_XMLDocument_onload, false);
+ return oDoc;
+ };
+ /**
+ * <p>Factory method to obtain a new XMLHTTP Request object</p>
+ * @returns a new XMLHTTP Request object
+ */
+ Sarissa.getXmlHttpRequest = function() {
+ return new XMLHttpRequest();
+ };
+ /**
+ * <p>Attached by an event handler to the load event. Internal use.</p>
+ * @private
+ */
+ function _sarissa_XMLDocument_onload(){
+ _sarissa_loadHandler(this);
+ };
+ /**
+ * <p>Ensures the document was loaded correctly, otherwise sets the
+ * parseError to -1 to indicate something went wrong. Internal use</p>
+ * @private
+ */
+ function _sarissa_loadHandler(oDoc){
+ if (!oDoc.documentElement || oDoc.documentElement.tagName == "parsererror")
+ oDoc.parseError = -1;
+ _sarissa_setReadyState(oDoc, 4);
+ };
+ /**
+ * <p>Sets the readyState property of the given DOM Document object.
+ * Internal use.</p>
+ * @private
+ * @argument oDoc the DOM Document object to fire the
+ * readystatechange event
+ * @argument iReadyState the number to change the readystate property to
+ */
+ function _sarissa_setReadyState(oDoc, iReadyState){
+ oDoc.readyState = iReadyState;
+ if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function")
+ oDoc.onreadystatechange();
+ };
+ /**
+ * <p>Deletes all child Nodes of the Document. Internal use</p>
+ * @private
+ */
+ XMLDocument.prototype._sarissa_clearDOM = function(){
+ while(this.hasChildNodes())
+ this.removeChild(this.firstChild);
+ };
+ /**
+ * <p>Replaces the childNodes of the Document object with the childNodes of
+ * the object given as the parameter</p>
+ * @private
+ * @argument oDoc the Document to copy the childNodes from
+ */
+ XMLDocument.prototype._sarissa_copyDOM = function(oDoc){
+ this._sarissa_clearDOM();
+ if(oDoc.nodeType == Node.DOCUMENT_NODE || oDoc.nodeType == Node.DOCUMENT_FRAGMENT_NODE)
+ {
+ var oNodes = oDoc.childNodes;
+ for(var i=0;i<oNodes.length;i++)
+ this.appendChild(this.importNode(oNodes[i], true));
+ }
+ else if(oDoc.nodeType == Node.ELEMENT_NODE)
+ this.appendChild(this.importNode(oDoc, true));
+ };
+ // used to normalise text nodes (for IE's innerText emulation)
+ // i'd appreciate any ideas, regexp is not my strong point
+ var _SARISSA_WSMULT = new RegExp("^\\s*|\\s*$", "g");
+ var _SARISSA_WSENDS = new RegExp("\\s\\s+", "g");
+ /**
+ * <p>Used to "normalize" text (trim white space mostly). Internal use</p>
+ * @private
+ */
+ function _sarissa_normalizeText(sIn){
+ return sIn.replace(_SARISSA_WSENDS, " ").replace(_SARISSA_WSMULT, " ");
+ };
+ /**
+ * <p>Parses the String given as parameter to build the document content
+ * for the object, exactly like IE's loadXML()</p>
+ * @argument strXML The XML String to load as the Document's childNodes
+ * @returns the old Document structure serialized as an XML String
+ */
+ XMLDocument.prototype.loadXML = function(strXML){
+ _sarissa_setReadyState(this, 1);
+ var sOldXML = this.xml;
+ var oDoc = (new DOMParser()).parseFromString(strXML, "text/xml");
+ _sarissa_setReadyState(this, 2);
+ this._sarissa_copyDOM(oDoc);
+ _sarissa_setReadyState(this, 3);
+ _sarissa_loadHandler(this);
+ return sOldXML;
+ };
+ /**
+ * <p>Emulates IE's xml property, giving read-only access to the XML tree
+ * in it's serialized form (in other words, an XML string)</p>
+ * @uses Mozilla's XMLSerializer class.
+ */
+ XMLDocument.prototype.__defineGetter__("xml", function (){
+ return (new XMLSerializer()).serializeToString(this);
+ });
+ /**
+ * <p>Emulates IE's xml property, giving read-only access to the XML tree
+ * in it's serialized form (in other words, an XML string)</p>
+ * @uses Mozilla's XMLSerializer class.
+ */
+ Node.prototype.__defineGetter__("xml", function (){
+ return (new XMLSerializer()).serializeToString(this);
+ });
+ /**
+ * <p>Ensures and informs the xml property is read only</p>
+ * @throws an "Invalid assignment on read-only property" error.
+ */
+ XMLDocument.prototype.__defineSetter__("xml", function (){
+ throw "Invalid assignment on read-only property 'xml'. Hint: Use the 'loadXML(String xml)' method instead. (original exception: "+e+")";
+ });
+ /**
+ * <p>Emulates IE's innerText (read/write). Note that this removes all
+ * childNodes of an HTML Element and just replaces it with a textNode</p>
+ */
+ HTMLElement.prototype.innerText;
+ HTMLElement.prototype.__defineSetter__("innerText", function (sText){
+ var s = "" + sText;
+ this.innerHTML = s.replace(/\&/g, "&").replace(/</g, "<").replace(/>/g, ">");
+ });
+ HTMLElement.prototype.__defineGetter__("innerText", function (){
+ var s = this.innerHTML;
+ return s ? _sarissa_normalizeText( s.replace(/<[^>]+>/g, "")) : "";
+ });
+ /**
+ * <p>Emulate IE's onreadystatechange attribute</p>
+ */
+ Document.prototype.onreadystatechange = null;
+ /**
+ * <p>Emulate IE's parseError attribute</p>
+ */
+ Document.prototype.parseError = 0;
+ /**
+ * <p>Emulates IE's readyState property, which always gives an integer from 0 to 4:</p>
+ * <ul><li>1 == LOADING,</li>
+ * <li>2 == LOADED,</li>
+ * <li>3 == INTERACTIVE,</li>
+ * <li>4 == COMPLETED</li></ul>
+ */
+ XMLDocument.prototype.readyState = 0;
+ // NOTE: setting async to false will only work with documents
+ // called over HTTP (meaning a server), not the local file system,
+ // unless you are using Moz 1.4+.
+ // BTW the try>catch block is for 1.4; I haven't found a way to check if
+ // the property is implemented without
+ // causing an error and I dont want to use user agent stuff for that...
+ var _SARISSA_SYNC_NON_IMPLEMENTED = false;
+ try{
+ /**
+ * <p>Emulates IE's async property for Moz versions prior to 1.4.
+ * It controls whether loading of remote XML files works
+ * synchronously or asynchronously.</p>
+ */
+ XMLDocument.prototype.async = true;
+ _SARISSA_SYNC_NON_IMPLEMENTED = true;
+ }catch(e){/* trap */}
+ /**
+ * <p>Keeps a handle to the original load() method. Internal use and only
+ * if Mozilla version is lower than 1.4</p>
+ * @private
+ */
+ XMLDocument.prototype._sarissa_load = XMLDocument.prototype.load;
+ /**
+ * <p>Overrides the original load method to provide synchronous loading for
+ * Mozilla versions prior to 1.4, using an XMLHttpRequest object (if
+ * async is set to false)</p>
+ * @returns the DOM Object as it was before the load() call (may be empty)
+ */
+ XMLDocument.prototype.load = function(sURI){
+ var oDoc = document.implementation.createDocument("", "", null);
+ oDoc._sarissa_copyDOM(this);
+ this.parseError = 0;
+ _sarissa_setReadyState(this, 1);
+ try{
+ if(this.async == false && _SARISSA_SYNC_NON_IMPLEMENTED){
+ var tmp = new XMLHttpRequest();
+ tmp.open("GET", sURI, false);
+ tmp.send(null);
+ _sarissa_setReadyState(this, 2);
+ this._sarissa_copyDOM(tmp.responseXML);
+ _sarissa_setReadyState(this, 3);
+ }
+ else
+ this._sarissa_load(sURI);
+ }catch (objException) {
+ this.parseError = -1;
+ }finally{
+ if(this.async == false)
+ _sarissa_loadHandler(this);
+ };
+ return oDoc;
+ };
+ /**
+ * <p>Extends the Element class to emulate IE's transformNodeToObject.
+ * <b>Note </b>: The transformation result <i>must </i> be well formed,
+ * otherwise an error will be thrown</p>
+ * @uses Mozilla's XSLTProcessor
+ * @deprecated
+ * @argument xslDoc The stylesheet to use (a DOM Document instance)
+ * @argument oResult The Document to store the transformation result
+ */
+ Element.prototype.transformNodeToObject = function(xslDoc, oResult){
+ var oDoc = document.implementation.createDocument("", "", null);
+ oDoc._sarissa_copyDOM(this);
+ oDoc.transformNodeToObject(xslDoc, oResult);
+ };
+ /**
+ * <p>Extends the Document class to emulate IE's transformNodeToObject</p>
+ * @uses Mozilla's XSLTProcessor
+ * @deprecated
+ * @argument xslDoc The stylesheet to use (a DOM Document instance)
+ * @argument oResult The Document to store the transformation result
+ * @throws Errors that try to be informative
+ */
+ Document.prototype.transformNodeToObject = function(xslDoc, oResult){
+ var xsltProcessor = null;
+ try{
+ xsltProcessor = new XSLTProcessor();
+ if(xsltProcessor.reset){
+ /* new nsIXSLTProcessor is available */
+ xsltProcessor.importStylesheet(xslDoc);
+ var newFragment = xsltProcessor.transformToFragment(this, oResult);
+ oResult._sarissa_copyDOM(newFragment);
+ }else{
+ /* only nsIXSLTProcessorObsolete is available */
+ xsltProcessor.transformDocument(this, xslDoc, oResult, null);
+ };
+ }catch(e){
+ if(xslDoc && oResult)
+ throw "Failed to transform document. (original exception: "+e+")";
+ else if(!xslDoc)
+ throw "No Stylesheet Document was provided. (original exception: "+e+")";
+ else if(!oResult)
+ throw "No Result Document was provided. (original exception: "+e+")";
+ else if(xsltProcessor == null)
+ throw "Could not instantiate an XSLTProcessor object. (original exception: "+e+")";
+ else
+ throw e;
+ };
+ };
+ /**
+ * <p>Extends the Element class to emulate IE's transformNode. </p>
+ * <p><b>Note </b>: The result of your transformation must be well formed,
+ * otherwise you will get an error</p>
+ * @uses Mozilla's XSLTProcessor
+ * @deprecated
+ * @argument xslDoc The stylesheet to use (a DOM Document instance)
+ * @returns the result of the transformation serialized to an XML String
+ */
+ Element.prototype.transformNode = function(xslDoc){
+ var oDoc = document.implementation.createDocument("", "", null);
+ oDoc._sarissa_copyDOM(this);
+ return oDoc.transformNode(xslDoc);
+ };
+ /**
+ * <p>Extends the Document class to emulate IE's transformNode.</p>
+ * <p><b>Note </b>: The result of your transformation must be well formed,
+ * otherwise you will get an error</p>
+ * @uses Mozilla's XSLTProcessor
+ * @deprecated
+ * @argument xslDoc The stylesheet to use (a DOM Document instance)
+ * @returns the result of the transformation serialized to an XML String
+ */
+ Document.prototype.transformNode = function(xslDoc){
+ var out = document.implementation.createDocument("", "", null);
+ this.transformNodeToObject(xslDoc, out);
+ var str = null;
+ try{
+ var serializer = new XMLSerializer();
+ str = serializer.serializeToString(out);
+ }catch(e){
+ throw "Failed to serialize result document. (original exception: "+e+")";
+ };
+ return str;
+ };
+ /**
+ * <p>SarissaNodeList behaves as a NodeList but is only used as a result to <code>selectNodes</code>,
+ * so it also has some properties IEs proprietery object features.</p>
+ * @private
+ * @constructor
+ * @argument i the (initial) list size
+ */
+ function SarissaNodeList(i){
+ this.length = i;
+ };
+ /** <p>Set an Array as the prototype object</p> */
+ SarissaNodeList.prototype = new Array(0);
+ /** <p>Inherit the Array constructor </p> */
+ SarissaNodeList.prototype.constructor = Array;
+ /**
+ * <p>Returns the node at the specified index or null if the given index
+ * is greater than the list size or less than zero </p>
+ * <p><b>Note</b> that in ECMAScript you can also use the square-bracket
+ * array notation instead of calling <code>item</code>
+ * @argument i the index of the member to return
+ * @returns the member corresponding to the given index
+ */
+ SarissaNodeList.prototype.item = function(i) {
+ return (i < 0 || i >= this.length)?null:this[i];
+ };
+ /**
+ * <p>Emulate IE's expr property
+ * (Here the SarissaNodeList object is given as the result of selectNodes).</p>
+ * @returns the XPath expression passed to selectNodes that resulted in
+ * this SarissaNodeList
+ */
+ SarissaNodeList.prototype.expr = "";
+ /** dummy, used to accept IE's stuff without throwing errors */
+ XMLDocument.prototype.setProperty = function(x,y){};
+ /**
+ * <p>Programmatically control namespace URI/prefix mappings for XPath
+ * queries.</p>
+ * <p>This method comes especially handy when used to apply XPath queries
+ * on XML documents with a default namespace, as there is no other way
+ * of mapping that to a prefix.</p>
+ * <p>Using no namespace prefix in DOM Level 3 XPath queries, implies you
+ * are looking for elements in the null namespace. If you need to look
+ * for nodes in the default namespace, you need to map a prefix to it
+ * first like:</p>
+ * <pre>Sarissa.setXpathNamespaces(oDoc, "xmlns:myprefix=&aposhttp://mynsURI&apos");</pre>
+ * <p><b>Note 1 </b>: Use this method only if the source document features
+ * a default namespace (without a prefix). You will need to map that
+ * namespace to a prefix for queries to work.</p>
+ * <p><b>Note 2 </b>: This method calls IE's setProperty method to set the
+ * appropriate namespace-prefix mappings, so you dont have to do that.</p>
+ * @param oDoc The target XMLDocument to set the namespace mappings for.
+ * @param sNsSet A whilespace-seperated list of namespace declarations as
+ * those would appear in an XML document. E.g.:
+ * <code>"xmlns:xhtml='http://www.w3.org/1999/xhtml'
+ * xmlns:'http://www.w3.org/1999/XSL/Transform'"</code>
+ * @throws An error if the format of the given namespace declarations is bad.
+ */
+ Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
+ //oDoc._sarissa_setXpathNamespaces(sNsSet);
+ oDoc._sarissa_useCustomResolver = true;
+ var namespaces = sNsSet.indexOf(" ")>-1?sNsSet.split(" "):new Array(sNsSet);
+ oDoc._sarissa_xpathNamespaces = new Array(namespaces.length);
+ for(var i=0;i < namespaces.length;i++){
+ var ns = namespaces[i];
+ var colonPos = ns.indexOf(":");
+ var assignPos = ns.indexOf("=");
+ if(colonPos == 5 && assignPos > colonPos+2){
+ var prefix = ns.substring(colonPos+1, assignPos);
+ var uri = ns.substring(assignPos+2, ns.length-1);
+ oDoc._sarissa_xpathNamespaces[prefix] = uri;
+ }else{
+ throw "Bad format on namespace declaration(s) given";
+ };
+ };
+ };
+ /**
+ * @private Flag to control whether a custom namespace resolver should
+ * be used, set to true by Sarissa.setXpathNamespaces
+ */
+ XMLDocument.prototype._sarissa_useCustomResolver = false;
+ XMLDocument.prototype._sarissa_xpathNamespaces = new Array();
+ /**
+ * <p>Extends the XMLDocument to emulate IE's selectNodes.</p>
+ * @argument sExpr the XPath expression to use
+ * @argument contextNode this is for internal use only by the same
+ * method when called on Elements
+ * @returns the result of the XPath search as a SarissaNodeList
+ * @throws An error if no namespace URI is found for the given prefix.
+ */
+ XMLDocument.prototype.selectNodes = function(sExpr, contextNode){
+ var nsDoc = this;
+ var nsresolver = this._sarissa_useCustomResolver
+ ? function(prefix){
+ var s = nsDoc._sarissa_xpathNamespaces[prefix];
+ if(s)return s;
+ else throw "No namespace URI found for prefix: '" + prefix+"'";
+ }
+ : this.createNSResolver(this.documentElement);
+ var oResult = this.evaluate(sExpr,
+ (contextNode?contextNode:this),
+ nsresolver,
+ XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+ var nodeList = new SarissaNodeList(oResult.snapshotLength);
+ nodeList.expr = sExpr;
+ for(var i=0;i<nodeList.length;i++)
+ nodeList[i] = oResult.snapshotItem(i);
+ return nodeList;
+ };
+ /**
+ * <p>Extends the Element to emulate IE's selectNodes</p>
+ * @argument sExpr the XPath expression to use
+ * @returns the result of the XPath search as an (Sarissa)NodeList
+ * @throws An
+ * error if invoked on an HTML Element as this is only be
+ * available to XML Elements.
+ */
+ Element.prototype.selectNodes = function(sExpr){
+ var doc = this.ownerDocument;
+ if(doc.selectNodes)
+ return doc.selectNodes(sExpr, this);
+ else
+ throw "Method selectNodes is only supported by XML Elements";
+ };
+ /**
+ * <p>Extends the XMLDocument to emulate IE's selectSingleNodes.</p>
+ * @argument sExpr the XPath expression to use
+ * @argument contextNode this is for internal use only by the same
+ * method when called on Elements
+ * @returns the result of the XPath search as an (Sarissa)NodeList
+ */
+ XMLDocument.prototype.selectSingleNode = function(sExpr, contextNode){
+ var ctx = contextNode?contextNode:null;
+ sExpr += "[1]";
+ var nodeList = this.selectNodes(sExpr, ctx);
+ if(nodeList.length > 0)
+ return nodeList.item(0);
+ else
+ return null;
+ };
+ /**
+ * <p>Extends the Element to emulate IE's selectNodes.</p>
+ * @argument sExpr the XPath expression to use
+ * @returns the result of the XPath search as an (Sarissa)NodeList
+ * @throws An error if invoked on an HTML Element as this is only be
+ * available to XML Elements.
+ */
+ Element.prototype.selectSingleNode = function(sExpr){
+ var doc = this.ownerDocument;
+ if(doc.selectSingleNode)
+ return doc.selectSingleNode(sExpr, this);
+ else
+ throw "Method selectNodes is only supported by XML Elements";
+ };
+ /**
+ * <p>Returns a human readable description of the parsing error. Usefull
+ * for debugging. Tip: append the returned error string in a <pre>
+ * element if you want to render it.</p>
+ * <p>Many thanks to Christian Stocker for the reminder and code.</p>
+ * @argument oDoc The target DOM document
+ * @returns The parsing error description of the target Document in
+ * human readable form (preformated text)
+ */
+ Sarissa.getParseErrorText = function (oDoc){
+ if (oDoc.documentElement.tagName == "parsererror"){
+ var parseErrorText = oDoc.documentElement.firstChild.data;
+ parseErrorText += "\n" + oDoc.documentElement.firstChild.nextSibling.firstChild.data;
+ return parseErrorText;
+ };
+ };
+
+}else if (_SARISSA_IS_IE){
+ // Add NodeType constants; missing in IE4, 5 and 6
+ if(!window.Node){
+ var Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5, ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12};
+ };
+ // implement importNode for IE
+ if(!document.importNode){
+ /**
+ * Implements importNode for IE using innerHTML. Main purpose it to
+ * be able to append Nodes from XMLDocuments to the current page in
+ * IE.
+ *
+ * @param oNode
+ * the Node to import
+ * @param bChildren
+ * whether to include the children of oNode
+ * @returns the imported node for further use
+ */
+ document.importNode = function(oNode, bChildren){
+ var importNode = document.createElement("div");
+ if(bChildren)
+ importNode.innerHTML = oNode.xml;
+ else
+ importNode.innerHTML = oNode.cloneNode(false).xml;
+ return importNode.firstChild;
+ };
+ }//if(!document.importNode)
+
+ // for XSLT parameter names, prefix needed by IE
+ _SARISSA_IEPREFIX4XSLPARAM = "xsl:";
+ // used to store the most recent ProgID available out of the above
+ var _SARISSA_DOM_PROGID = "";
+ var _SARISSA_XMLHTTP_PROGID = "";
+ /**
+ * Called when the Sarissa_xx.js file is parsed, to pick most recent
+ * ProgIDs for IE, then gets destroyed.
+ * @param idList an array of MSXML PROGIDs from which the most recent will be picked for a given object
+ * @param enabledList an array of arrays where each array has two items; the index of the PROGID for which a certain feature is enabled
+ */
+ function pickRecentProgID(idList, enabledList){
+ // found progID flag
+ var bFound = false;
+ for(var i=0; i < idList.length && !bFound; i++){
+ try{
+ var oDoc = new ActiveXObject(idList[i]);
+ o2Store = idList[i];
+ bFound = true;
+ for(var j=0;j<enabledList.length;j++)
+ if(i <= enabledList[j][1])
+ Sarissa["IS_ENABLED_"+enabledList[j][0]] = true;
+ }catch (objException){
+ // trap; try next progID
+ };
+ };
+ if (!bFound)
+ throw "Could not retreive a valid progID of Class: " + idList[idList.length-1]+". (original exception: "+e+")";
+ idList = null;
+ return o2Store;
+ };
+ // store proper progIDs
+ _SARISSA_DOM_PROGID = pickRecentProgID(["Msxml2.DOMDocument.5.0", "Msxml2.DOMDocument.4.0", "Msxml2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"], [["SELECT_NODES", 2],["TRANSFORM_NODE", 2]]);
+ _SARISSA_XMLHTTP_PROGID = pickRecentProgID(["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"], [["XMLHTTP", 4]]);
+ _SARISSA_THREADEDDOM_PROGID = pickRecentProgID(["Msxml2.FreeThreadedDOMDocument.5.0", "MSXML2.FreeThreadedDOMDocument.4.0", "MSXML2.FreeThreadedDOMDocument.3.0"]);
+ _SARISSA_XSLTEMPLATE_PROGID = pickRecentProgID(["Msxml2.XSLTemplate.5.0", "Msxml2.XSLTemplate.4.0", "MSXML2.XSLTemplate.3.0"], [["XSLTPROC", 2]]);
+ // we dont need this anymore
+ pickRecentProgID = null;
+ //============================================
+ // Factory methods (IE)
+ //============================================
+ // see mozilla version
+ Sarissa.getDomDocument = function(sUri, sName){
+ var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
+ // if a root tag name was provided, we need to load it in the DOM
+ // object
+ if (sName){
+ // if needed, create an artifical namespace prefix the way Moz
+ // does
+ if (sUri){
+ oDoc.loadXML("<a" + _sarissa_iNsCounter + ":" + sName + " xmlns:a" + _sarissa_iNsCounter + "=\"" + sUri + "\" />");
+ // don't use the same prefix again
+ ++_sarissa_iNsCounter;
+ }
+ else
+ oDoc.loadXML("<" + sName + "/>");
+ };
+ return oDoc;
+ };
+ // see mozilla version
+ Sarissa.getXmlHttpRequest = function() {
+ return new ActiveXObject(_SARISSA_XMLHTTP_PROGID);
+ };
+ // see mozilla version
+ Sarissa.getParseErrorText = function (oDoc) {
+ var parseErrorText = "XML Parsing Error: " + oDoc.parseError.reason +" \n";
+ parseErrorText += "Location: " + oDoc.parseError.url + "\n";
+ parseErrorText += "Line Number " + oDoc.parseError.line ;
+ parseErrorText += ", Column " + oDoc.parseError.linepos + ":\n";
+ parseErrorText += oDoc.parseError.srcText + "\n";
+ for(var i = 0; i < oDoc.parseError.linepos;i++)
+ parseErrorText += "-";
+ parseErrorText += "^\n";
+ return parseErrorText;
+ };
+ // see mozilla version
+ Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
+ oDoc.setProperty("SelectionLanguage", "XPath");
+ oDoc.setProperty("SelectionNamespaces", sNsSet);
+ };
+ /**
+ * Basic implementation of Mozilla's XSLTProcessor for IE.
+ * Reuses the same XSLT stylesheet for multiple transforms
+ * @constructor
+ */
+ function XSLTProcessor(){
+ this.template = new ActiveXObject(_SARISSA_XSLTEMPLATE_PROGID);
+ this.processor = null;
+ };
+ /**
+ * Impoprts the given XSLT DOM and compiles it to a reusable transform
+ * @argument xslDoc The XSLT DOMDocument to import
+ */
+ XSLTProcessor.prototype.importStylesheet = function(xslDoc){
+ // convert stylesheet to free threaded
+ var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID);
+ converted.loadXML(xslDoc.xml);
+ this.template.stylesheet = converted;
+ this.processor = this.template.createProcessor();
+ // (re)set default param values
+ this.paramsSet = new Array();
+ };
+ /**
+ * Transform the given XML DOM
+ * @argument sourceDoc The XML DOMDocument to transform
+ * @return The transformation result as a DOM Document
+ */
+ XSLTProcessor.prototype.transformToDocument = function(sourceDoc) {
+ this.processor.input = sourceDoc;
+ var outDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
+ this.processor.output = outDoc;
+ this.processor.transform();
+ return outDoc;
+ };
+ /**
+ * Set global XSLT parameter of the imported stylesheet
+ * @argument nsURI The parameter namespace URI
+ * @argument name The parameter base name
+ * @argument value The new parameter value
+ */
+ XSLTProcessor.prototype.setParameter = function(nsURI, name, value){
+ // nsURI is optional and cannot be null
+ if(nsURI)
+ this.processor.addParameter(name, value, nsURI);
+ else
+ this.processor.addParameter(name, value);
+
+ // update updated params for getParameter
+ if(!this.paramsSet[""+nsURI])
+ this.paramsSet[""+nsURI] = new Array();
+
+ this.paramsSet[""+nsURI][name] = value;
+ };
+
+ /**
+ * Gets a parameter if previously set by setParameter. Returns null
+ * otherwise
+ * @argument name The parameter base name
+ * @argument value The new parameter value
+ * @return The parameter value if reviously set by setParameter, null otherwise
+ */
+ XSLTProcessor.prototype.getParameter = function(nsURI, name){
+ if(this.paramsSet[""+nsURI] && this.paramsSet[""+nsURI][name])
+ return this.paramsSet[""+nsURI][name];
+ else
+ return null;
+ };
+}
+
+/**
+ * <p>
+ * Factory method, used to set xslt parameters.
+ * </p>
+ * <p>
+ * <b>Note </b> that this method can only work for the main stylesheet and
+ * not any included/imported files.
+ * </p>
+ * @deprecated
+ * @argument oXslDoc the target XSLT DOM Document
+ * @argument sParamName the name of the XSLT parameter
+ * @argument sParamValue the value of the XSLT parameter
+ * @returns whether the parameter was set succefully
+ */
+Sarissa.setXslParameter = function(oXslDoc, sParamQName, sParamValue){
+ try{
+ var params = oXslDoc.getElementsByTagName(_SARISSA_IEPREFIX4XSLPARAM+"param");
+ var iLength = params.length;
+ var bFound = false;
+ var param;
+
+ if(sParamValue){
+ for(var i=0; i < iLength && !bFound;i++){
+ // match a param name attribute with the name given as
+ // argument
+ if(params[i].getAttribute("name") == sParamQName){
+ param = params[i];
+ // clean up the parameter
+ while(param.firstChild)
+ param.removeChild(param.firstChild);
+ if(!sParamValue || sParamValue == null){
+ // do nothing; we've cleaned up the parameter anyway
+ }else if(typeof sParamValue == "string"){
+ param.setAttribute("select", sParamValue);
+ bFound = true;
+ }else if(sParamValue.nodeName){
+ param.removeAttribute("select");
+ param.appendChild(sParamValue.cloneNode(true));
+ bFound = true;
+ }else if (sParamValue.item(0) && sParamValue.item(0).nodeType){
+ for(var j=0;j < sParamValue.length;j++)
+ if(sParamValue.item(j).nodeType) // check if this is a Node
+ param.appendChild(sParamValue.item(j).cloneNode(true));
+ bFound = true;
+ }else
+ throw "Failed to set xsl:param "+sParamQName+" (original exception: "+e+")";
+ };
+ };
+ };
+ return bFound;
+ }catch(e){
+ throw e;
+ return false;
+ };
+};
+// EOF
+