You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/03/29 00:53:15 UTC
svn commit: r928511 [6/7] -
/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_form.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_form.js?rev=928511&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_form.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_form.js Sun Mar 28 22:53:14 2010
@@ -0,0 +1,295 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2005 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: kupuinit_form.js 39345 2007-02-23 18:29:27Z yuppie $
+
+
+//----------------------------------------------------------------------------
+// Sample initialization function
+//
+// This is a copy of initKupu for the form support
+//
+// We only want to disable the save button, but unfortunately that currently
+// still means this method should be overridden completely
+//----------------------------------------------------------------------------
+
+function initKupu(iframe) {
+ /* Although this is meant to be a sample implementation, it can
+ be used out-of-the box to run the sample pagetemplate or for simple
+ implementations that just don't use some elements. When you want
+ to do some customization, this should probably be overridden. For
+ larger customization actions you will have to subclass or roll your
+ own UI object.
+ */
+
+ // first we create a logger
+ var l = new PlainLogger('kupu-toolbox-debuglog', 5);
+
+ // now some config values
+ var conf = loadDictFromXML(document, 'kupuconfig');
+
+ // the we create the document, hand it over the id of the iframe
+ var doc = new KupuDocument(iframe);
+
+ // now we can create the controller
+ var kupu = new KupuEditor(doc, conf, l);
+
+ var contextmenu = new ContextMenu();
+ kupu.setContextMenu(contextmenu);
+
+ // now we can create a UI object which we can use from the UI
+ var ui = new KupuUI('kupu-tb-styles');
+
+ // the ui must be registered to the editor like a tool so it can be notified
+ // of state changes
+ kupu.registerTool('ui', ui); // XXX Should this be a different method?
+
+ // function that returns a function to execute a button command
+ var execCommand = function(cmd) {
+ return function(button, editor) {
+ editor.execCommand(cmd);
+ };
+ };
+
+ var boldchecker = parentWithStyleChecker(['b', 'strong'],
+ 'fontWeight', 'bold', 'bold');
+ var boldbutton = new KupuStateButton('kupu-bold-button',
+ execCommand('bold'),
+ boldchecker,
+ 'kupu-bold',
+ 'kupu-bold-pressed');
+ kupu.registerTool('boldbutton', boldbutton);
+
+ var italicschecker = parentWithStyleChecker(['i', 'em'],
+ 'fontStyle', 'italic', 'italic');
+ var italicsbutton = new KupuStateButton('kupu-italic-button',
+ execCommand('italic'),
+ italicschecker,
+ 'kupu-italic',
+ 'kupu-italic-pressed');
+ kupu.registerTool('italicsbutton', italicsbutton);
+
+ var underlinechecker = parentWithStyleChecker(['u'],
+ 'textDecoration', 'underline', 'underline');
+ var underlinebutton = new KupuStateButton('kupu-underline-button',
+ execCommand('underline'),
+ underlinechecker,
+ 'kupu-underline',
+ 'kupu-underline-pressed');
+ kupu.registerTool('underlinebutton', underlinebutton);
+
+ var subscriptchecker = parentWithStyleChecker(['sub'],
+ null, null, 'subscript');
+ var subscriptbutton = new KupuStateButton('kupu-subscript-button',
+ execCommand('subscript'),
+ subscriptchecker,
+ 'kupu-subscript',
+ 'kupu-subscript-pressed');
+ kupu.registerTool('subscriptbutton', subscriptbutton);
+
+ var superscriptchecker = parentWithStyleChecker(['super', 'sup'],
+ null, null, 'superscript');
+ var superscriptbutton = new KupuStateButton('kupu-superscript-button',
+ execCommand('superscript'),
+ superscriptchecker,
+ 'kupu-superscript',
+ 'kupu-superscript-pressed');
+ kupu.registerTool('superscriptbutton', superscriptbutton);
+
+ var justifyleftbutton = new KupuButton('kupu-justifyleft-button',
+ execCommand('justifyleft'));
+ kupu.registerTool('justifyleftbutton', justifyleftbutton);
+
+ var justifycenterbutton = new KupuButton('kupu-justifycenter-button',
+ execCommand('justifycenter'));
+ kupu.registerTool('justifycenterbutton', justifycenterbutton);
+
+ var justifyrightbutton = new KupuButton('kupu-justifyright-button',
+ execCommand('justifyright'));
+ kupu.registerTool('justifyrightbutton', justifyrightbutton);
+
+ var outdentbutton = new KupuButton('kupu-outdent-button', execCommand('outdent'));
+ kupu.registerTool('outdentbutton', outdentbutton);
+
+ var indentbutton = new KupuButton('kupu-indent-button', execCommand('indent'));
+ kupu.registerTool('indentbutton', indentbutton);
+
+ var undobutton = new KupuButton('kupu-undo-button', execCommand('undo'));
+ kupu.registerTool('undobutton', undobutton);
+
+ var redobutton = new KupuButton('kupu-redo-button', execCommand('redo'));
+ kupu.registerTool('redobutton', redobutton);
+
+ var removeimagebutton = new KupuRemoveElementButton('kupu-removeimage-button',
+ 'img',
+ 'kupu-removeimage');
+ kupu.registerTool('removeimagebutton', removeimagebutton);
+
+ var removelinkbutton = new KupuRemoveElementButton('kupu-removelink-button',
+ 'a',
+ 'kupu-removelink');
+ kupu.registerTool('removelinkbutton', removelinkbutton);
+
+ // add some tools
+ var colorchoosertool = new ColorchooserTool('kupu-forecolor-button',
+ 'kupu-hilitecolor-button',
+ 'kupu-colorchooser');
+ kupu.registerTool('colorchooser', colorchoosertool);
+
+ var listtool = new ListTool('kupu-list-ul-addbutton',
+ 'kupu-list-ol-addbutton',
+ 'kupu-ulstyles',
+ 'kupu-olstyles');
+ kupu.registerTool('listtool', listtool);
+
+ var definitionlisttool = new DefinitionListTool('kupu-list-dl-addbutton');
+ kupu.registerTool('definitionlisttool', definitionlisttool);
+
+ var proptool = new PropertyTool('kupu-properties-title', 'kupu-properties-description');
+ kupu.registerTool('proptool', proptool);
+
+ var linktool = new LinkTool();
+ kupu.registerTool('linktool', linktool);
+ var linktoolbox = new LinkToolBox("kupu-link-input", "kupu-link-button", 'kupu-toolbox-links', 'kupu-toolbox', 'kupu-toolbox-active');
+ linktool.registerToolBox('linktoolbox', linktoolbox);
+
+ var imagetool = new ImageTool();
+ kupu.registerTool('imagetool', imagetool);
+ var imagetoolbox = new ImageToolBox('kupu-image-input', 'kupu-image-addbutton',
+ 'kupu-image-float-select', 'kupu-toolbox-images',
+ 'kupu-toolbox', 'kupu-toolbox-active');
+ imagetool.registerToolBox('imagetoolbox', imagetoolbox);
+
+ var tabletool = new TableTool();
+ kupu.registerTool('tabletool', tabletool);
+ var tabletoolbox = new TableToolBox('kupu-toolbox-addtable',
+ 'kupu-toolbox-edittable', 'kupu-table-newrows', 'kupu-table-newcols',
+ 'kupu-table-makeheader', 'kupu-table-classchooser',
+ 'kupu-table-alignchooser', 'kupu-table-addtable-button',
+ 'kupu-table-addrow-button', 'kupu-table-delrow-button',
+ 'kupu-table-addcolumn-button', 'kupu-table-delcolumn-button',
+ 'kupu-table-fix-button', 'kupu-table-del-button',
+ 'kupu-table-fixall-button', 'kupu-toolbox-tables',
+ 'kupu-toolbox', 'kupu-toolbox-active');
+ tabletool.registerToolBox('tabletoolbox', tabletoolbox);
+
+ var anchortool = new AnchorTool();
+ kupu.registerTool('anchortool', anchortool);
+
+ var showpathtool = new ShowPathTool();
+ kupu.registerTool('showpathtool', showpathtool);
+
+ var sourceedittool = new SourceEditTool('kupu-source-button',
+ 'kupu-editor-textarea');
+ kupu.registerTool('sourceedittool', sourceedittool);
+
+ var spellchecker = new KupuSpellChecker('kupu-spellchecker-button',
+ 'spellcheck.cgi');
+ kupu.registerTool('spellchecker', spellchecker);
+
+ var zoom = new KupuZoomTool('kupu-zoom-button',
+ 'kupu-tb-styles',
+ 'kupu-logo-button');
+ kupu.registerTool('zoomtool', zoom);
+
+ var cleanupexpressions = new CleanupExpressionsTool(
+ 'kupucleanupexpressionselect', 'kupucleanupexpressionbutton');
+ kupu.registerTool('cleanupexpressions', cleanupexpressions);
+
+ // Drawers...
+
+ // Function that returns function to open a drawer
+ var opendrawer = function(drawerid) {
+ return function(button, editor) {
+ drawertool.openDrawer(drawerid);
+ };
+ };
+
+ var imagelibdrawerbutton = new KupuButton('kupu-imagelibdrawer-button',
+ opendrawer('imagelibdrawer'));
+ kupu.registerTool('imagelibdrawerbutton', imagelibdrawerbutton);
+
+ var linklibdrawerbutton = new KupuButton('kupu-linklibdrawer-button',
+ opendrawer('linklibdrawer'));
+ kupu.registerTool('linklibdrawerbutton', linklibdrawerbutton);
+
+ var linkdrawerbutton = new KupuButton('kupu-linkdrawer-button',
+ opendrawer('linkdrawer'));
+ kupu.registerTool('linkdrawerbutton', linkdrawerbutton);
+
+ var anchorbutton = new KupuButton('kupu-anchors',
+ opendrawer('anchordrawer'));
+ kupu.registerTool('anchorbutton', anchorbutton);
+
+ var tabledrawerbutton = new KupuButton('kupu-tabledrawer-button',
+ opendrawer('tabledrawer'));
+ kupu.registerTool('tabledrawerbutton', tabledrawerbutton);
+
+ // create some drawers, drawers are some sort of popups that appear when a
+ // toolbar button is clicked
+ var drawertool = new DrawerTool();
+ kupu.registerTool('drawertool', drawertool);
+
+ try {
+ var linklibdrawer = new LinkLibraryDrawer(linktool,
+ conf.link_xsl_uri,
+ conf.link_libraries_uri,
+ conf.search_links_uri);
+ drawertool.registerDrawer('linklibdrawer', linklibdrawer);
+
+ var imagelibdrawer = new ImageLibraryDrawer(imagetool,
+ conf.image_xsl_uri,
+ conf.image_libraries_uri,
+ conf.search_images_uri);
+ drawertool.registerDrawer('imagelibdrawer', imagelibdrawer);
+ } catch(e) {
+ var msg = _('There was a problem initializing the drawers. Most ' +
+ 'likely the XSLT or XML files aren\'t available. If this ' +
+ 'is not the Kupu demo version, check your files or the ' +
+ 'service that provide them (error: ${error}).',
+ {'error': (e.message || e.toString())});
+ alert(msg);
+ };
+
+ var linkdrawer = new LinkDrawer('kupu-linkdrawer', linktool);
+ drawertool.registerDrawer('linkdrawer', linkdrawer);
+
+ var anchordrawer = new AnchorDrawer('kupu-anchordrawer', anchortool);
+ drawertool.registerDrawer('anchordrawer', anchordrawer);
+
+ var tabledrawer = new TableDrawer('kupu-tabledrawer', tabletool);
+ drawertool.registerDrawer('tabledrawer', tabledrawer);
+
+ // make the prepareForm method get called on form submit
+ // some bug in IE makes it crash on saving the form when a lib drawer
+ // was added to the page at some point, remove it on form submit
+ var savebutton = getFromSelector('kupu-save-button');
+ function prepareForm(event) {
+ var drawer = window.document.getElementById('kupu-librarydrawer');
+ if (drawer) {
+ drawer.parentNode.removeChild(drawer);
+ }
+ kupu.prepareForm(savebutton.form, 'kupu');
+ savebutton.form.submit();
+ };
+ addEventHandler(savebutton, 'click', prepareForm, kupu);
+
+ // register some cleanup filter
+ // remove tags that aren't in the XHTML DTD
+ var nonxhtmltagfilter = new NonXHTMLTagFilter();
+ kupu.registerFilter(nonxhtmltagfilter);
+
+ if (window.kuputoolcollapser) {
+ var collapser = new window.kuputoolcollapser.Collapser(
+ 'kupu-toolboxes');
+ collapser.initialize();
+ };
+
+ return kupu;
+}
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_genericelements.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_genericelements.js?rev=928511&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_genericelements.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_genericelements.js Sun Mar 28 22:53:14 2010
@@ -0,0 +1,276 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2005 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.
+ *
+ *****************************************************************************/
+/*extern CNFTableToolBox GenericElementsTool GenericElementsToolBox */
+// $Id: kupuinit_genericelements.js 39345 2007-02-23 18:29:27Z yuppie $
+
+
+//----------------------------------------------------------------------------
+// Sample initialization function
+//----------------------------------------------------------------------------
+
+function initKupu(iframe) {
+ /* Although this is meant to be a sample implementation, it can
+ be used out-of-the box to run the sample pagetemplate or for simple
+ implementations that just don't use some elements. When you want
+ to do some customization, this should probably be overridden. For
+ larger customization actions you will have to subclass or roll your
+ own UI object.
+ */
+
+ // first we create a logger
+ var l = new PlainLogger('kupu-toolbox-debuglog', 5);
+
+ // now some config values
+ var conf = loadDictFromXML(document, 'kupuconfig');
+
+ // the we create the document, hand it over the id of the iframe
+ var doc = new KupuDocument(iframe);
+
+ // now we can create the controller
+ var kupu = new KupuEditor(doc, conf, l);
+
+ var contextmenu = new ContextMenu();
+ kupu.setContextMenu(contextmenu);
+
+ // now we can create a UI object which we can use from the UI
+ var ui = new KupuUI('kupu-tb-styles');
+
+ // the ui must be registered to the editor like a tool so it can be notified
+ // of state changes
+ kupu.registerTool('ui', ui); // XXX Should this be a different method?
+
+ // add the buttons to the toolbar
+ var savebuttonfunc = function(button, editor) {editor.saveDocument();};
+ var savebutton = new KupuButton('kupu-save-button', savebuttonfunc);
+ kupu.registerTool('savebutton', savebutton);
+
+ // function that returns a function to execute a button command
+ var execCommand = function(cmd) {
+ return function(button, editor) {
+ editor.execCommand(cmd);
+ };
+ };
+
+ var boldchecker = parentWithStyleChecker(['b', 'strong'],
+ 'fontWeight', 'bold', 'bold');
+ var boldbutton = new KupuStateButton('kupu-bold-button',
+ execCommand('bold'),
+ boldchecker,
+ 'kupu-bold',
+ 'kupu-bold-pressed');
+ kupu.registerTool('boldbutton', boldbutton);
+
+ var italicschecker = parentWithStyleChecker(['i', 'em'],
+ 'fontStyle', 'italic', 'italic');
+ var italicsbutton = new KupuStateButton('kupu-italic-button',
+ execCommand('italic'),
+ italicschecker,
+ 'kupu-italic',
+ 'kupu-italic-pressed');
+ kupu.registerTool('italicsbutton', italicsbutton);
+
+ var underlinechecker = parentWithStyleChecker(['u'],
+ 'textDecoration', 'underline', 'underline');
+ var underlinebutton = new KupuStateButton('kupu-underline-button',
+ execCommand('underline'),
+ underlinechecker,
+ 'kupu-underline',
+ 'kupu-underline-pressed');
+ kupu.registerTool('underlinebutton', underlinebutton);
+
+ var subscriptchecker = parentWithStyleChecker(['sub'],
+ null, null, 'subscript');
+ var subscriptbutton = new KupuStateButton('kupu-subscript-button',
+ execCommand('subscript'),
+ subscriptchecker,
+ 'kupu-subscript',
+ 'kupu-subscript-pressed');
+ kupu.registerTool('subscriptbutton', subscriptbutton);
+
+ var superscriptchecker = parentWithStyleChecker(['super', 'sup'],
+ null, null, 'superscript');
+ var superscriptbutton = new KupuStateButton('kupu-superscript-button',
+ execCommand('superscript'),
+ superscriptchecker,
+ 'kupu-superscript',
+ 'kupu-superscript-pressed');
+ kupu.registerTool('superscriptbutton', superscriptbutton);
+
+ var justifyleftbutton = new KupuButton('kupu-justifyleft-button',
+ execCommand('justifyleft'));
+ kupu.registerTool('justifyleftbutton', justifyleftbutton);
+
+ var justifycenterbutton = new KupuButton('kupu-justifycenter-button',
+ execCommand('justifycenter'));
+ kupu.registerTool('justifycenterbutton', justifycenterbutton);
+
+ var justifyrightbutton = new KupuButton('kupu-justifyright-button',
+ execCommand('justifyright'));
+ kupu.registerTool('justifyrightbutton', justifyrightbutton);
+
+ var outdentbutton = new KupuButton('kupu-outdent-button', execCommand('outdent'));
+ kupu.registerTool('outdentbutton', outdentbutton);
+
+ var indentbutton = new KupuButton('kupu-indent-button', execCommand('indent'));
+ kupu.registerTool('indentbutton', indentbutton);
+
+ var undobutton = new KupuButton('kupu-undo-button', execCommand('undo'));
+ kupu.registerTool('undobutton', undobutton);
+
+ var redobutton = new KupuButton('kupu-redo-button', execCommand('redo'));
+ kupu.registerTool('redobutton', redobutton);
+
+ var removeimagebutton = new KupuRemoveElementButton('kupu-removeimage-button',
+ 'img',
+ 'kupu-removeimage');
+ kupu.registerTool('removeimagebutton', removeimagebutton);
+
+ var removelinkbutton = new KupuRemoveElementButton('kupu-removelink-button',
+ 'a',
+ 'kupu-removelink');
+ kupu.registerTool('removelinkbutton', removelinkbutton);
+
+ // add some tools
+ var colorchoosertool = new ColorchooserTool('kupu-forecolor-button',
+ 'kupu-hilitecolor-button',
+ 'kupu-colorchooser');
+ kupu.registerTool('colorchooser', colorchoosertool);
+
+ var listtool = new ListTool('kupu-list-ul-addbutton',
+ 'kupu-list-ol-addbutton',
+ 'kupu-ulstyles',
+ 'kupu-olstyles');
+ kupu.registerTool('listtool', listtool);
+
+ var definitionlisttool = new DefinitionListTool('kupu-list-dl-addbutton');
+ kupu.registerTool('definitionlisttool', definitionlisttool);
+
+ var proptool = new PropertyTool('kupu-properties-title', 'kupu-properties-description');
+ kupu.registerTool('proptool', proptool);
+
+ var linktool = new LinkTool();
+ kupu.registerTool('linktool', linktool);
+ var linktoolbox = new LinkToolBox("kupu-link-input", "kupu-link-button", 'kupu-toolbox-links', 'kupu-toolbox', 'kupu-toolbox-active');
+ linktool.registerToolBox('linktoolbox', linktoolbox);
+
+ var imagetool = new ImageTool();
+ kupu.registerTool('imagetool', imagetool);
+ var imagetoolbox = new ImageToolBox('kupu-image-input', 'kupu-image-addbutton',
+ 'kupu-image-float-select', 'kupu-toolbox-images',
+ 'kupu-toolbox', 'kupu-toolbox-active');
+ imagetool.registerToolBox('imagetoolbox', imagetoolbox);
+
+ var tabletool = new TableTool();
+ kupu.registerTool('tabletool', tabletool);
+ // custom TableToolBox for CNF, Codename Future
+ var tabletoolbox = new CNFTableToolBox('kupu-toolbox-addtable',
+ 'kupu-toolbox-edittable', 'kupu-table-newrows', 'kupu-table-newcols',
+ 'kupu-table-makeheader', 'kupu-table-classchooser',
+ 'kupu-table-alignchooser', 'kupu-table-addtable-button',
+ 'kupu-table-addrow-button', 'kupu-table-delrow-button',
+ 'kupu-table-setrowrepeat-button', 'kupu-table-delrowrepeat-button',
+ 'kupu-table-addcolumn-button', 'kupu-table-delcolumn-button',
+ 'kupu-table-fix-button',
+ 'kupu-table-fixall-button', 'kupu-toolbox-tables',
+ 'kupu-toolbox', 'kupu-toolbox-active');
+ tabletool.registerToolBox('tabletoolbox', tabletoolbox);
+
+ var anchortool = new AnchorTool();
+ kupu.registerTool('anchortool', anchortool);
+
+ var showpathtool = new ShowPathTool();
+ kupu.registerTool('showpathtool', showpathtool);
+
+ var sourceedittool = new SourceEditTool('kupu-source-button',
+ 'kupu-editor-textarea');
+ kupu.registerTool('sourceedittool', sourceedittool);
+
+ // Generic elements tool
+ var geneltool = new GenericElementsTool('genericelementsxml');
+ kupu.registerTool('genericelements', geneltool);
+
+ var geneltoolbox = new GenericElementsToolBox('genericelements-elid', 'genericelements-form',
+ 'genericelements-addbutton', 'genericelements-delbutton',
+ 'genericelements-copybutton', 'genericelements-pastebutton',
+ 'genericelements-cancelbutton', 'genericelements-toolbox',
+ 'kupu-toolbox', 'kupu-toolbox-active');
+ geneltool.registerToolBox('genericelementstoolbox', geneltoolbox);
+
+ // Drawers...
+
+ // Function that returns function to open a drawer
+ var opendrawer = function(drawerid) {
+ return function(button, editor) {
+ drawertool.openDrawer(drawerid);
+ };
+ };
+
+ var imagelibdrawerbutton = new KupuButton('kupu-imagelibdrawer-button',
+ opendrawer('imagelibdrawer'));
+ kupu.registerTool('imagelibdrawerbutton', imagelibdrawerbutton);
+
+ var linklibdrawerbutton = new KupuButton('kupu-linklibdrawer-button',
+ opendrawer('linklibdrawer'));
+ kupu.registerTool('linklibdrawerbutton', linklibdrawerbutton);
+
+ var linkdrawerbutton = new KupuButton('kupu-linkdrawer-button',
+ opendrawer('linkdrawer'));
+ kupu.registerTool('linkdrawerbutton', linkdrawerbutton);
+
+ var anchorbutton = new KupuButton('kupu-anchors',
+ opendrawer('anchordrawer'));
+ kupu.registerTool('anchorbutton', anchorbutton);
+
+ var tabledrawerbutton = new KupuButton('kupu-tabledrawer-button',
+ opendrawer('tabledrawer'));
+ kupu.registerTool('tabledrawerbutton', tabledrawerbutton);
+
+ // create some drawers, drawers are some sort of popups that appear when a
+ // toolbar button is clicked
+ var drawertool = new DrawerTool();
+ kupu.registerTool('drawertool', drawertool);
+
+ try {
+ var linklibdrawer = new LinkLibraryDrawer(linktool,
+ conf.link_xsl_uri,
+ conf.link_libraries_uri,
+ conf.search_links_uri);
+ drawertool.registerDrawer('linklibdrawer', linklibdrawer);
+
+ var imagelibdrawer = new ImageLibraryDrawer(imagetool,
+ conf.image_xsl_uri,
+ conf.image_libraries_uri,
+ conf.search_images_uri);
+ drawertool.registerDrawer('imagelibdrawer', imagelibdrawer);
+ } catch(e) {
+ var msg = _('There was a problem initializing the drawers. Most ' +
+ 'likely the XSLT or XML files aren\'t available. If this ' +
+ 'is not the Kupu demo version, check your files or the ' +
+ 'service that provide them (error: ${error}).',
+ {'error': (e.message || e.toString())});
+ alert(msg);
+ };
+
+ var linkdrawer = new LinkDrawer('kupu-linkdrawer', linktool);
+ drawertool.registerDrawer('linkdrawer', linkdrawer);
+
+ var anchordrawer = new AnchorDrawer('kupu-anchordrawer', anchortool);
+ drawertool.registerDrawer('anchordrawer', anchordrawer);
+
+ var tabledrawer = new TableDrawer('kupu-tabledrawer', tabletool);
+ drawertool.registerDrawer('tabledrawer', tabledrawer);
+
+ // register some cleanup filter
+ // remove tags that aren't in the XHTML DTD
+ var nonxhtmltagfilter = new NonXHTMLTagFilter();
+ kupu.registerFilter(nonxhtmltagfilter);
+
+ return kupu;
+}
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_multi.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_multi.js?rev=928511&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_multi.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinit_multi.js Sun Mar 28 22:53:14 2010
@@ -0,0 +1,275 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2005 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.
+ *
+ *****************************************************************************/
+/*extern KupuMultiEditor MultiSourceEditTool */
+// $Id: kupuinit_multi.js 39345 2007-02-23 18:29:27Z yuppie $
+
+
+//----------------------------------------------------------------------------
+// Sample initialization function
+//----------------------------------------------------------------------------
+
+function initKupu(iframeids) {
+ /* Although this is meant to be a sample implementation, it can
+ be used out-of-the box to run the sample pagetemplate or for simple
+ implementations that just don't use some elements. When you want
+ to do some customization, this should probably be overridden. For
+ larger customization actions you will have to subclass or roll your
+ own UI object.
+ */
+
+ // first we create a logger
+ var l = new PlainLogger('kupu-toolbox-debuglog', 5);
+
+ // now some config values
+ var conf = loadDictFromXML(document, 'kupuconfig');
+
+ var documents = [];
+ for (var i=0; i < iframeids.length; i++) {
+ var iframe = getFromSelector(iframeids[i]);
+ documents.push(new KupuDocument(iframe));
+ };
+
+ // now we can create the controller
+ var kupu = new KupuMultiEditor(documents, conf, l);
+
+ /* doesn't work yet
+ var contextmenu = new ContextMenu();
+ kupu.setContextMenu(contextmenu);
+ */
+
+ // now we can create a UI object which we can use from the UI
+ var ui = new KupuUI('kupu-tb-styles');
+
+ // the ui must be registered to the editor like a tool so it can be notified
+ // of state changes
+ kupu.registerTool('ui', ui); // XXX Should this be a different method?
+
+ // function that returns a function to execute a button command
+ var execCommand = function(cmd) {
+ return function(button, editor) {
+ editor.execCommand(cmd);
+ };
+ };
+
+ var boldchecker = parentWithStyleChecker(['b', 'strong'],
+ 'fontWeight', 'bold', 'bold');
+ var boldbutton = new KupuStateButton('kupu-bold-button',
+ execCommand('bold'),
+ boldchecker,
+ 'kupu-bold',
+ 'kupu-bold-pressed');
+ kupu.registerTool('boldbutton', boldbutton);
+
+ var italicschecker = parentWithStyleChecker(['i', 'em'],
+ 'fontStyle', 'italic', 'italic');
+ var italicsbutton = new KupuStateButton('kupu-italic-button',
+ execCommand('italic'),
+ italicschecker,
+ 'kupu-italic',
+ 'kupu-italic-pressed');
+ kupu.registerTool('italicsbutton', italicsbutton);
+
+ var underlinechecker = parentWithStyleChecker(['u'],
+ 'textDecoration', 'underline', 'underline');
+ var underlinebutton = new KupuStateButton('kupu-underline-button',
+ execCommand('underline'),
+ underlinechecker,
+ 'kupu-underline',
+ 'kupu-underline-pressed');
+ kupu.registerTool('underlinebutton', underlinebutton);
+
+ var subscriptchecker = parentWithStyleChecker(['sub'],
+ null, null, 'subscript');
+ var subscriptbutton = new KupuStateButton('kupu-subscript-button',
+ execCommand('subscript'),
+ subscriptchecker,
+ 'kupu-subscript',
+ 'kupu-subscript-pressed');
+ kupu.registerTool('subscriptbutton', subscriptbutton);
+
+ var superscriptchecker = parentWithStyleChecker(['super', 'sup'],
+ null, null, 'superscript');
+ var superscriptbutton = new KupuStateButton('kupu-superscript-button',
+ execCommand('superscript'),
+ superscriptchecker,
+ 'kupu-superscript',
+ 'kupu-superscript-pressed');
+ kupu.registerTool('superscriptbutton', superscriptbutton);
+
+ var justifyleftbutton = new KupuButton('kupu-justifyleft-button',
+ execCommand('justifyleft'));
+ kupu.registerTool('justifyleftbutton', justifyleftbutton);
+
+ var justifycenterbutton = new KupuButton('kupu-justifycenter-button',
+ execCommand('justifycenter'));
+ kupu.registerTool('justifycenterbutton', justifycenterbutton);
+
+ var justifyrightbutton = new KupuButton('kupu-justifyright-button',
+ execCommand('justifyright'));
+ kupu.registerTool('justifyrightbutton', justifyrightbutton);
+
+ var outdentbutton = new KupuButton('kupu-outdent-button', execCommand('outdent'));
+ kupu.registerTool('outdentbutton', outdentbutton);
+
+ var indentbutton = new KupuButton('kupu-indent-button', execCommand('indent'));
+ kupu.registerTool('indentbutton', indentbutton);
+
+ var undobutton = new KupuButton('kupu-undo-button', execCommand('undo'));
+ kupu.registerTool('undobutton', undobutton);
+
+ var redobutton = new KupuButton('kupu-redo-button', execCommand('redo'));
+ kupu.registerTool('redobutton', redobutton);
+
+ var removeimagebutton = new KupuRemoveElementButton('kupu-removeimage-button',
+ 'img',
+ 'kupu-removeimage');
+ kupu.registerTool('removeimagebutton', removeimagebutton);
+
+ var removelinkbutton = new KupuRemoveElementButton('kupu-removelink-button',
+ 'a',
+ 'kupu-removelink');
+ kupu.registerTool('removelinkbutton', removelinkbutton);
+
+ // add some tools
+ var colorchoosertool = new ColorchooserTool('kupu-forecolor-button',
+ 'kupu-hilitecolor-button',
+ 'kupu-colorchooser');
+ kupu.registerTool('colorchooser', colorchoosertool);
+
+ var listtool = new ListTool('kupu-list-ul-addbutton',
+ 'kupu-list-ol-addbutton',
+ 'kupu-ulstyles',
+ 'kupu-olstyles');
+ kupu.registerTool('listtool', listtool);
+
+ var definitionlisttool = new DefinitionListTool('kupu-list-dl-addbutton');
+ kupu.registerTool('definitionlisttool', definitionlisttool);
+
+ /* dunno if we'll ever want to support this
+ var proptool = new PropertyTool('kupu-properties-title', 'kupu-properties-description');
+ kupu.registerTool('proptool', proptool);
+ */
+
+ var linktool = new LinkTool();
+ kupu.registerTool('linktool', linktool);
+ var linktoolbox = new LinkToolBox("kupu-link-input", "kupu-link-button", 'kupu-toolbox-links', 'kupu-toolbox', 'kupu-toolbox-active');
+ linktool.registerToolBox('linktoolbox', linktoolbox);
+
+ var imagetool = new ImageTool();
+ kupu.registerTool('imagetool', imagetool);
+ var imagetoolbox = new ImageToolBox('kupu-image-input', 'kupu-image-addbutton',
+ 'kupu-image-float-select', 'kupu-toolbox-images',
+ 'kupu-toolbox', 'kupu-toolbox-active');
+ imagetool.registerToolBox('imagetoolbox', imagetoolbox);
+
+ var tabletool = new TableTool();
+ kupu.registerTool('tabletool', tabletool);
+ var tabletoolbox = new TableToolBox('kupu-toolbox-addtable',
+ 'kupu-toolbox-edittable', 'kupu-table-newrows', 'kupu-table-newcols',
+ 'kupu-table-makeheader', 'kupu-table-classchooser',
+ 'kupu-table-alignchooser', 'kupu-table-addtable-button',
+ 'kupu-table-addrow-button', 'kupu-table-delrow-button',
+ 'kupu-table-addcolumn-button', 'kupu-table-delcolumn-button',
+ 'kupu-table-fix-button', 'kupu-table-del-button',
+ 'kupu-table-fixall-button', 'kupu-toolbox-tables',
+ 'kupu-toolbox', 'kupu-toolbox-active');
+ tabletool.registerToolBox('tabletoolbox', tabletoolbox);
+
+ var anchortool = new AnchorTool();
+ kupu.registerTool('anchortool', anchortool);
+
+ var showpathtool = new ShowPathTool();
+ kupu.registerTool('showpathtool', showpathtool);
+
+ var sourceedittool = new MultiSourceEditTool('kupu-source-button',
+ 'kupu-editor-textarea-');
+ kupu.registerTool('sourceedittool', sourceedittool);
+
+ var cleanupexpressions = new CleanupExpressionsTool(
+ 'kupucleanupexpressionselect', 'kupucleanupexpressionbutton');
+ kupu.registerTool('cleanupexpressions', cleanupexpressions);
+
+ // Drawers...
+
+ // Function that returns function to open a drawer
+ var opendrawer = function(drawerid) {
+ return function(button, editor) {
+ drawertool.openDrawer(drawerid);
+ };
+ };
+
+ var imagelibdrawerbutton = new KupuButton('kupu-imagelibdrawer-button',
+ opendrawer('imagelibdrawer'));
+ kupu.registerTool('imagelibdrawerbutton', imagelibdrawerbutton);
+
+ var linklibdrawerbutton = new KupuButton('kupu-linklibdrawer-button',
+ opendrawer('linklibdrawer'));
+ kupu.registerTool('linklibdrawerbutton', linklibdrawerbutton);
+
+ var linkdrawerbutton = new KupuButton('kupu-linkdrawer-button',
+ opendrawer('linkdrawer'));
+ kupu.registerTool('linkdrawerbutton', linkdrawerbutton);
+
+ var anchorbutton = new KupuButton('kupu-anchors',
+ opendrawer('anchordrawer'));
+ kupu.registerTool('anchorbutton', anchorbutton);
+
+ var tabledrawerbutton = new KupuButton('kupu-tabledrawer-button',
+ opendrawer('tabledrawer'));
+ kupu.registerTool('tabledrawerbutton', tabledrawerbutton);
+
+ // create some drawers, drawers are some sort of popups that appear when a
+ // toolbar button is clicked
+ var drawertool = new DrawerTool();
+ kupu.registerTool('drawertool', drawertool);
+
+ try {
+ var linklibdrawer = new LinkLibraryDrawer(linktool,
+ conf.link_xsl_uri,
+ conf.link_libraries_uri,
+ conf.search_links_uri);
+ drawertool.registerDrawer('linklibdrawer', linklibdrawer);
+
+ var imagelibdrawer = new ImageLibraryDrawer(imagetool,
+ conf.image_xsl_uri,
+ conf.image_libraries_uri,
+ conf.search_images_uri);
+ drawertool.registerDrawer('imagelibdrawer', imagelibdrawer);
+ } catch(e) {
+ var msg = _('There was a problem initializing the drawers. Most ' +
+ 'likely the XSLT or XML files aren\'t available. If this ' +
+ 'is not the Kupu demo version, check your files or the ' +
+ 'service that provide them (error: ${error}).',
+ {'error': (e.message || e.toString())});
+ alert(msg);
+ };
+
+ var linkdrawer = new LinkDrawer('kupu-linkdrawer', linktool);
+ drawertool.registerDrawer('linkdrawer', linkdrawer);
+
+ var anchordrawer = new AnchorDrawer('kupu-anchordrawer', anchortool);
+ drawertool.registerDrawer('anchordrawer', anchordrawer);
+
+ var tabledrawer = new TableDrawer('kupu-tabledrawer', tabletool);
+ drawertool.registerDrawer('tabledrawer', tabledrawer);
+
+ // register some cleanup filter
+ // remove tags that aren't in the XHTML DTD
+ var nonxhtmltagfilter = new NonXHTMLTagFilter();
+ kupu.registerFilter(nonxhtmltagfilter);
+
+ if (window.kuputoolcollapser) {
+ var collapser = new window.kuputoolcollapser.Collapser(
+ 'kupu-toolboxes');
+ collapser.initialize();
+ };
+
+ return kupu;
+}
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinspector.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinspector.js?rev=928511&r1=928510&r2=928511&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinspector.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuinspector.js Sun Mar 28 22:53:14 2010
@@ -7,8 +7,7 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-
-// $Id: kupuinspector.js 9879 2005-03-18 12:04:00Z yuppie $
+// $Id: kupuinspector.js 35854 2006-12-18 15:37:15Z duncan $
/* The Kupu Inspector tool
@@ -25,7 +24,7 @@
function Panel() {
/* the container (user interface element) of the elements */
- this.elements = new Array();
+ this.elements = [];
this.element = document.createElement('table');
this.element.style.width = '100%';
@@ -44,7 +43,7 @@ function Element(node, panel, visibility
/* an element in the panel (reflecting an element in the document) */
this.panel = panel;
this.node = node;
- this.nodes = new Array();
+ this.nodes = [];
this.default_visibility = visibility;
// create a header
@@ -117,7 +116,7 @@ function Element(node, panel, visibility
input.setAttribute('name', stylename);
input.style.width = "100%";
input.element = this.node;
- addEventHandler(input, 'change', function() {this.element.style[this.getAttribute('name')] = this.value}, input);
+ addEventHandler(input, 'change', function() {this.element.style[this.getAttribute('name')] = this.value;}, input);
inputcell.appendChild(input);
this.nodes.push(row);
};
@@ -151,32 +150,32 @@ function KupuInspector(inspectorelement)
this.element = getFromSelector(inspectorelement);
this._lastnode = null;
- this.default_attrs = new Array('id', 'className');
- this.special_attrs = {'a': new Array('href', 'name', 'target'),
- 'img': new Array('url', 'width', 'height'),
- 'ul': new Array('type'),
- 'ol': new Array('type'),
- 'table': new Array('border', 'cellPadding', 'cellSpacing'),
- 'td': new Array('align')
+ this.default_attrs = ['id', 'className'];
+ this.special_attrs = {'a': ['href', 'name', 'target'],
+ 'img': ['url', 'width', 'height'],
+ 'ul': ['type'],
+ 'ol': ['type'],
+ 'table': ['border', 'cellPadding', 'cellSpacing'],
+ 'td': ['align']
};
- this.styles = new Array('background', 'borderWidth', 'borderColor',
+ this.styles = ['background', 'borderWidth', 'borderColor',
'borderStyle', 'color', 'fontSize',
'fontFamily', 'float', 'height',
'lineHeight', 'margin', 'padding',
'textAlign', 'verticalAlign', 'whiteApace',
- 'width');
+ 'width'];
this.updateState = function(selNode, event) {
/* repopulate the inspector (if required) */
if (selNode != this._lastnode) {
// we need to repopulate
- this._lastnode = selNode
+ this._lastnode = selNode;
this._clear();
var panel = new Panel();
var currnode = selNode;
// walk up to the body, add the elements in an array so we can
// walk through it backwards later on
- var els = new Array();
+ var els = [];
while (currnode.nodeName.toLowerCase() != 'html') {
// only use element nodes
if (currnode.nodeType == 1) {
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuloggers.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuloggers.js?rev=928511&r1=928510&r2=928511&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuloggers.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuloggers.js Sun Mar 28 22:53:14 2010
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-
// $Id$
@@ -70,4 +69,4 @@ function DummyLogger() {
throw message;
}
};
-};
+}
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupumultieditor.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupumultieditor.js?rev=928511&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupumultieditor.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupumultieditor.js Sun Mar 28 22:53:14 2010
@@ -0,0 +1,189 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2005 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 = [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 = [];
+ 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: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupusaveonpart.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupusaveonpart.js?rev=928511&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupusaveonpart.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupusaveonpart.js Sun Mar 28 22:53:14 2010
@@ -0,0 +1,20 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2005 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 35854 2006-12-18 15:37:15Z duncan $
+
+function saveOnPart() {
+ /* ask the user if (s)he wants to save the document before leaving */
+ 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);
+ };
+}
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupusourceedit.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupusourceedit.js?rev=928511&r1=928510&r2=928511&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupusourceedit.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupusourceedit.js Sun Mar 28 22:53:14 2010
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-
// $Id$
@@ -30,7 +29,7 @@ SourceEditTool.prototype = new KupuTool;
SourceEditTool.prototype.cancelSourceMode = function() {
if (this._currently_editing) {
this.switchSourceEdit(null, true);
- };
+ }
};
SourceEditTool.prototype.updateState =
@@ -39,7 +38,7 @@ SourceEditTool.prototype.updateState =
SourceEditTool.prototype.initialize = function(editor) {
/* attach the event handlers */
this.editor = editor;
- this._fixTabIndex(this.sourceButton);
+ if (!this.sourceButton) return;
addEventHandler(this.sourceButton, "click", this.switchSourceEdit, this);
this.editor.logMessage(_('Source edit tool initialized'));
};
@@ -55,7 +54,7 @@ SourceEditTool.prototype.switchSourceEdi
if (!this.sourcemode) {
if (window.drawertool) {
window.drawertool.closeDrawer();
- };
+ }
if (/on/i.test(kupudoc.designMode)) {
kupudoc.designMode = 'Off';
};
@@ -64,15 +63,18 @@ SourceEditTool.prototype.switchSourceEdi
var data='';
if(kupu.config.filtersourceedit) {
window.status = _('Cleaning up HTML...');
- var transform = kupu._filterContent(
- kupu.getInnerDocument().documentElement);
+ var transform = kupu._filterContent(kupu.getInnerDocument().documentElement);
data = kupu.getXMLBody(transform);
data = kupu._fixupSingletons(data).replace(/<\/?body[^>]*>/g, "");
+ if (kupu._getBase && kupu.makeLinksRelative) {
+ var base = kupu._getBase(transform);
+ data = kupu.makeLinksRelative(data, base).replace(/<\/?body[^>]*>/g, "");
+ };
window.status = '';
} else {
data = kupu.getHTMLBody();
- };
- sourcearea.value = data;
+ }
+ sourcearea.value = data.strip();
kupu.setClass(sourceClass);
editorframe.style.display = 'none';
sourcearea.style.display = 'block';
@@ -102,11 +104,11 @@ SourceEditTool.prototype.switchSourceEdi
};
SourceEditTool.prototype.enable = function() {
- KupuButtonEnable(this.sourceButton);
+ kupuButtonEnable(this.sourceButton);
};
SourceEditTool.prototype.disable = function() {
- KupuButtonDisable(this.sourceButton);
+ kupuButtonDisable(this.sourceButton);
};
function MultiSourceEditTool(sourcebuttonid, textareaprefix) {
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuspellchecker.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuspellchecker.js?rev=928511&r1=928510&r2=928511&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuspellchecker.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuspellchecker.js Sun Mar 28 22:53:14 2010
@@ -13,7 +13,9 @@ KupuSpellChecker.prototype = new KupuToo
KupuSpellChecker.prototype.initialize = function(editor) {
this.editor = editor;
- addEventHandler(this.button, 'click', this.check, this);
+ if (this.button) {
+ addEventHandler(this.button, 'click', this.check, this);
+ }
};
KupuSpellChecker.prototype.check = function() {
@@ -26,7 +28,7 @@ KupuSpellChecker.prototype.check = funct
this,
request).execute;
var result = this.getCurrentContents();
- result = escape(result.strip().replace('\n', ' ').reduceWhitespace());
+ result = encodeURIComponent(result.reduceWhitespace().strip());
request.send('text=' + result);
};
@@ -53,7 +55,7 @@ KupuSpellChecker.prototype.getCurrentCon
var bits = [];
while (true) {
var node = iterator.next();
- if (!node) {
+ if (!node || node.nodeName.toLowerCase() == 'body') {
break;
};
while (this.skip_tags.contains(node.nodeName.toLowerCase())) {
@@ -86,7 +88,7 @@ KupuSpellChecker.prototype.displayUnreco
html = html.replace(/<meta[^>]*http-equiv="[Cc]ontent-[Tt]ype"[^>]*>/gm,
'');
win.document.write('<html>' + html + '</html>');
- win.deentitize = function(str) {return str.deentitize()};
+ win.deentitize = function(str) {return str.deentitize();};
win.document.close();
if (!win.document.getElementsByTagName('body').length) {
addEventHandler(win, 'load', this.continueDisplay, this, win, mapping);
@@ -113,7 +115,7 @@ KupuSpellChecker.prototype.continueDispl
KupuSpellChecker.prototype.displayHelperNodeLoop = function(iterator, node,
win, mapping) {
- if (!node) {
+ if (!node || node.nodeName.toLowerCase() == 'body') {
return;
};
var next = iterator.next();
@@ -195,6 +197,5 @@ KupuSpellChecker.prototype.xmlToMapping
};
result[word] = replacements;
};
- var attrs = [];
return result;
};
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart.js?rev=928511&r1=928510&r2=928511&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart.js Sun Mar 28 22:53:14 2010
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-
// $Id$
// myFaces : added parameter
@@ -49,9 +48,9 @@ function startKupu( iframeId ) {
} 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) {
+ var re = /rv:([0-9\.]+)/;
+ var match = re.exec(navigator.userAgent);
+ if (match && match[1] && parseFloat(match[1]) > 1.6) {
addEventHandler(window, 'beforeunload', saveOnPart);
} else {
addEventHandler(window, 'unload', saveOnPart);
@@ -63,4 +62,4 @@ function startKupu( iframeId ) {
kupu.initialize();
return kupu;
-};
+}
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart_form.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart_form.js?rev=928511&r1=928510&r2=928511&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart_form.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart_form.js Sun Mar 28 22:53:14 2010
@@ -7,7 +7,6 @@
* Contributors see CREDITS.txt.
*
*****************************************************************************/
-
// $Id$
function startKupu() {
@@ -54,4 +53,4 @@ function continueStartKupu(kupu) {
kupu.initialize();
return kupu;
-};
+}
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart_multi.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart_multi.js?rev=928511&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart_multi.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustart_multi.js Sun Mar 28 22:53:14 2010
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ *
+ * Copyright (c) 2003-2005 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, this version groks an array of iframeids
+ var iframeids = ['kupu_1', 'kupu_2', 'kupu_3'];
+ var kupu = initKupu(iframeids);
+
+ // if there's no global 'i18n_message_catalog' variable available, don't
+ // try to load any translations
+ if (!window.i18n_message_catalog) {
+ continueStartKupu(kupu);
+ return kupu;
+ };
+ // loading will be done asynchronously (to keep Mozilla from freezing)
+ // so we'll continue in a follow-up function (continueStartKupu() below)
+ var handler = function(request) {
+ if (this.readyState == 4) {
+ var status = this.status;
+ if (status != '200') {
+ alert(_('Error loading translation (status ${status} ' +
+ '), falling back to english'), {'status': status});
+ continueStartKupu(kupu);
+ return;
+ };
+ var dom = this.responseXML;
+ window.i18n_message_catalog.initialize(dom);
+ continueStartKupu(kupu);
+ };
+ };
+ var request = new XMLHttpRequest();
+ request.onreadystatechange = (new ContextFixer(handler, request)).execute;
+ request.open('GET', 'kupu.pox', true);
+ request.send('');
+
+ // we need to return a reference to the editor here for certain 'external'
+ // stuff, developers should note that it's not yet initialized though, we
+ // need to wait for i18n data before we can do that
+ return kupu;
+};
+
+function continueStartKupu(kupu) {
+ kupu.initialize();
+
+ return kupu;
+}
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustyles.css
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustyles.css?rev=928511&r1=928510&r2=928511&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustyles.css (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupustyles.css Sun Mar 28 22:53:14 2010
@@ -114,6 +114,7 @@ div.kupu-smalleditor {
.kupu-bold {background-image: url("kupuimages/bold.png");}
.kupu-bold-pressed {background-image: url("kupuimages/bold.png"); background-color: white;}
+.kupu-anchors {background-image: url("kupuimages/anchor.png");}
.kupu-forecolor {background-image: url("kupuimages/text-color.png");}
.kupu-hilitecolor {background-image: url("kupuimages/background-color.png");}
@@ -181,7 +182,7 @@ textarea.kupu-editor-textarea {
}
div.kupu-toolboxes {
- float: right;
+ float: right;
border: solid 2px ButtonFace;
width: 19.4em;
margin-right: 0.3em;
@@ -273,7 +274,7 @@ div.kupu-drawer {
overflow: auto;
}
-button.disabled {
+input.disabled, button.disabled {
opacity:0.5;
filter:alpha(opacity=50);
}
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kuputoolcollapser.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kuputoolcollapser.js?rev=928511&r1=928510&r2=928511&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kuputoolcollapser.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kuputoolcollapser.js Sun Mar 28 22:53:14 2010
@@ -14,13 +14,13 @@ this.kuputoolcollapser = new function()
var cookie = document.cookie;
var reg = /initial_state=([^;]+);?/;
var match = cookie.match(reg);
- if (match) {
+ if (match) { /*ignore 558 */
eval(unescape(match[0]));
};
};
for (var i=0; i < this.parent.childNodes.length; i++) {
var child = this.parent.childNodes[i];
- if (child.className == 'kupu-toolbox') {
+ if (child.className && child.className.match(/\bkupu-toolbox\b/)) {
var heading = child.getElementsByTagName('h1')[0];
if (!heading) {
throw('heading not found by collapser for toolbox ' +
@@ -54,7 +54,7 @@ this.kuputoolcollapser = new function()
};
};
addEventHandler(heading, 'click', handler, body, heading);
- if (initial_state[child.id] === undefined ||
+ if (initial_state[child.id] === undefined ||
initial_state[child.id] == '0') {
body.style.display = 'none';
} else {
@@ -67,7 +67,7 @@ this.kuputoolcollapser = new function()
child.open_handler = wrap_openhandler(body, heading);
};
};
- // TODO : Check this
+
addEventHandler(window, 'beforeunload', this.saveState, this);
};
@@ -78,7 +78,7 @@ this.kuputoolcollapser = new function()
currchild = currchild.nextSibling;
if (!currchild) {
throw('body not found by collapser for toolbox ' +
- child.id);
+ tool.id);
};
};
return currchild;
@@ -98,12 +98,12 @@ this.kuputoolcollapser = new function()
var body = this.getToolBody(child);
current_state[child.id] = body.style.display == 'none' ? '0' : '1';
};
-
+
var exp = new Date();
// 100 years before state is lost... should be enough ;)
exp.setTime(exp.getTime() + (100 * 365 * 24 * 60 * 60 * 1000));
- var cookie = 'initial_state=' +
- escape(this.serializeMapping(current_state)) +
+ var cookie = 'initial_state=' +
+ escape(this.serializeMapping(current_state)) +
';' +
'expires=' + exp.toGMTString() + ';' +
'path=/';
@@ -112,7 +112,7 @@ this.kuputoolcollapser = new function()
ToolCollapser.prototype.serializeMapping = function(mapping) {
/* serializes the config dict into a string that can be evalled
-
+
works only for dicts with string values
*/
if (typeof(mapping) == 'string') {
@@ -124,7 +124,7 @@ this.kuputoolcollapser = new function()
if (!first) {
ret += ', ';
};
- ret += "'" + key + "': " +
+ ret += "'" + key + "': " +
this.serializeMapping(mapping[key]);
first = false;
};
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuundo.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuundo.js?rev=928511&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuundo.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/inputHtml/resource/kupuundo.js Sun Mar 28 22:53:14 2010
@@ -0,0 +1,108 @@
+/* Improved undo support for Kupu
+
+ This uses the 'diff-match-patch' library from Neil Fraser to make patches
+ between edits, and saves those patches in an undo buffer.
+
+ The diff-match-patch lib is distributed under terms of the LGPL license,
+ for more information see doc/LICENSE_DIFFMATCHPATH.txt.
+
+ For more information about the library itself, see
+ http://code.google.com/p/google-diff-match-patch/
+*/
+
+function KupuUndoTool() {
+ if (arguments.length) {
+ this._init.apply(this, arguments);
+ };
+};
+
+KupuUndoTool.prototype = new KupuTool;
+
+KupuUndoTool.prototype._init =
+ function _init(undobuttonid, redobuttonid, maxbufsize) {
+ this.undobutton = document.getElementById(undobuttonid);
+ this.redobutton = document.getElementById(redobuttonid);
+ this._content = null;
+ this._buffer = [];
+ this._rev_buffer = [];
+ this._maximum_buffer_size = maxbufsize || 100;
+};
+
+KupuUndoTool.prototype.initialize = function initialize(editor) {
+ this.editor = editor;
+ addEventHandler(this.undobutton, 'click', this.undo, this);
+ addEventHandler(this.redobutton, 'click', this.redo, this);
+ this.dmp = new diff_match_patch();
+ this._content = this._get_content();
+};
+
+KupuUndoTool.prototype.updateState = function updateState(selNode, event) {
+ var new_content = this._get_content();
+ var patch = this.dmp.patch_make(new_content, this._content);
+ if (!patch.toString()) {
+ return;
+ };
+ var revpatch = this.dmp.patch_make(this._content, new_content);
+ this._buffer.push([patch, revpatch]);
+ this._rev_buffer = []; // discard redo information
+ this._content = new_content;
+ while (this._buffer.length > this._maximum_buffer_size) {
+ this._buffer.shift();
+ };
+};
+
+KupuUndoTool.prototype.undo = function undo() {
+ this.updateState();
+ var patchset = this._buffer.pop();
+ if (!patchset) {
+ return;
+ };
+ this._apply_patch(patchset[0]);
+ this._rev_buffer.push(patchset);
+};
+
+KupuUndoTool.prototype.redo = function redo() {
+ var patchset = this._rev_buffer.pop();
+ if (!patchset) {
+ return;
+ };
+ this._apply_patch(patchset[1]);
+ this._buffer.push(patchset);
+};
+
+KupuUndoTool.prototype._apply_patch = function _apply_patch(patch) {
+ var ret = this.dmp.patch_apply(patch, this._content);
+ var results = ret[1];
+ var failures = false;
+ for (var i=0; i < results.length; i++) {
+ if (!results[i]) {
+ failures = true;
+ break;
+ };
+ };
+ if (failures) {
+ throw('there were errors applying undo buffer patch! ' +
+ 'cancelling undo action...');
+ };
+ var new_content = ret[0];
+ this._set_content(new_content);
+ this._content = new_content;
+};
+
+KupuUndoTool.prototype._get_content = function _get_content() {
+ var body = this.editor.document.document.getElementsByTagName('body')[0];
+ return body.innerHTML;
+};
+
+KupuUndoTool.prototype._set_content = function _set_content(content) {
+ var body = this.editor.document.document.getElementsByTagName('body')[0];
+ body.innerHTML = content;
+};
+
+KupuUndoTool.prototype.debug = function debug(msg) {
+ var body = document.getElementsByTagName('body')[0];
+ var div = document.createElement('div');
+ div.appendChild(document.createTextNode(msg));
+ body.appendChild(div);
+ div.style.border = '1px solid red';
+};