You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by he...@apache.org on 2006/11/13 23:55:14 UTC
svn commit: r474551 [33/49] - in
/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo:
./ src/ src/alg/ src/animation/ src/cal/ src/charting/ src/charting/svg/
src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/cs...
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,666 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+/* TODO:
+ * - font selector
+ * - test, bug fix, more features :)
+*/
+dojo.provide("dojo.widget.Editor2");
+
+dojo.require("dojo.io.*");
+dojo.require("dojo.html.*");
+dojo.require("dojo.html.layout");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.RichText");
+dojo.require("dojo.widget.Editor2Toolbar");
+
+// Object: Manager of current focused Editor2 Instance and available editor2 commands
+dojo.widget.Editor2Manager = {
+ _currentInstance: null,
+ _loadedCommands: {},
+
+ // Object: state a command may be in
+ commandState: {Disabled: 0, Latched: 1, Enabled: 2},
+
+ getCurrentInstance: function(){
+ // summary: Return the current focused Editor2 instance
+ return this._currentInstance;
+ },
+ setCurrentInstance: function(/*Widget*/inst){
+ // summary: Set current focused Editor2 instance
+ this._currentInstance = inst;
+ },
+ registerCommand: function(/*String*/name, /*Object*/cmd){
+ // summary: Register an Editor2 command
+ // name: name of the command (case insensitive)
+ // cmd: an object which implements interface dojo.widget.Editor2Command
+ name = name.toLowerCase();
+ if(this._loadedCommands[name]){
+ delete this._loadedCommands[name];
+ }
+ this._loadedCommands[name] = cmd;
+ },
+ getCommand: function(/*String*/name){
+ // summary: Return Editor2 command with the given name
+ // name: name of the command (case insensitive)
+ name = name.toLowerCase();
+ var oCommand = this._loadedCommands[name];
+ if(oCommand){
+ return oCommand;
+ }
+
+ switch(name){
+ case 'htmltoggle':
+ //Editor2 natively provide the htmltoggle functionalitity
+ //and it is treated as a builtin command
+ oCommand = new dojo.widget.Editor2BrowserCommand(name);
+ break;
+ case 'formatblock':
+ oCommand = new dojo.widget.Editor2FormatBlockCommand(name);
+ break;
+ case 'anchor':
+ oCommand = new dojo.widget.Editor2Command(name);
+ break;
+
+ //dialog command
+ case 'createlink':
+ oCommand = new dojo.widget.Editor2DialogCommand(name,
+ {contentFile: "dojo.widget.Editor2Plugin.CreateLinkDialog",
+ contentClass: "Editor2CreateLinkDialog",
+ title: "Insert/Edit Link", width: "300px", height: "200px"});
+ break;
+ case 'insertimage':
+ oCommand = new dojo.widget.Editor2DialogCommand(name,
+ {contentFile: "dojo.widget.Editor2Plugin.InsertImageDialog",
+ contentClass: "Editor2InsertImageDialog",
+ title: "Insert/Edit Image", width: "400px", height: "270px"});
+ break;
+ // By default we assume that it is a builtin simple command.
+ default:
+ var curtInst = this.getCurrentInstance();
+ if((curtInst && curtInst.queryCommandAvailable(name)) ||
+ (!curtInst && dojo.widget.Editor2.prototype.queryCommandAvailable(name))){
+ oCommand = new dojo.widget.Editor2BrowserCommand(name);
+ }else{
+ dojo.debug("dojo.widget.Editor2Manager.getCommand: Unknown command "+name);
+ return;
+ }
+ }
+ this._loadedCommands[name] = oCommand;
+ return oCommand;
+ },
+ destroy: function(){
+ // summary: Cleaning up. This is called automatically on page unload.
+ this._currentInstance = null;
+ for(var cmd in this._loadedCommands){
+ this._loadedCommands[cmd].destory();
+ }
+ }
+};
+
+dojo.addOnUnload(dojo.widget.Editor2Manager, "destroy");
+
+// summary:
+// dojo.widget.Editor2Command is the base class for all command in Editor2
+dojo.lang.declare("dojo.widget.Editor2Command",null,{
+ initializer: function(name){
+ // summary: Constructor of this class
+ this._name = name;
+ },
+ //this function should be re-implemented in subclass
+ execute: function(para){
+ // summary: Execute the command. should be implemented in subclass
+ dojo.unimplemented("dojo.widget.Editor2Command.execute");
+ },
+ //default implemetation always returns Enabled
+ getState: function(){
+ // summary:
+ // Return the state of the command. The default behavior is
+ // to always return Enabled
+ return dojo.widget.Editor2Manager.commandState.Enabled;
+ },
+ destory: function(){
+ // summary: Destructor
+ }
+ }
+);
+
+// summary:
+// dojo.widget.Editor2BrowserCommand is the base class for all the browser built
+// in commands
+dojo.lang.declare("dojo.widget.Editor2BrowserCommand", dojo.widget.Editor2Command, {
+ execute: function(para){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ if(curInst){
+ curInst.execCommand(this._name, para);
+ }
+ },
+ getState: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ if(curInst){
+ try{
+ if(curInst.queryCommandEnabled(this._name)){
+ if(curInst.queryCommandState(this._name)){
+ return dojo.widget.Editor2Manager.commandState.Latched;
+ }else{
+ return dojo.widget.Editor2Manager.commandState.Enabled;
+ }
+ }else{
+ return dojo.widget.Editor2Manager.commandState.Disabled;
+ }
+ }catch (e) {
+ //dojo.debug("exception when getting state for command "+this._name+": "+e);
+ return dojo.widget.Editor2Manager.commandState.Enabled;
+ }
+ }
+ return dojo.widget.Editor2Manager.commandState.Disabled;
+ },
+ getValue: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ if(curInst){
+ try{
+ return curInst.queryCommandValue(this._name);
+ }catch(e){}
+ }
+ }
+ }
+);
+
+dojo.lang.declare("dojo.widget.Editor2FormatBlockCommand", dojo.widget.Editor2BrowserCommand, {
+ /* In none-ActiveX mode under IE, <p> and no <p> text can not be distinguished
+ getCurrentValue: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ if(!curInst){ return ''; }
+
+ var h = dojo.render.html;
+
+ // safari f's us for selection primitives
+ if(h.safari){ return ''; }
+
+ var selectedNode = (h.ie) ? curInst.document.selection.createRange().parentElement() : curInst.window.getSelection().anchorNode;
+ // make sure we actuall have an element
+ while((selectedNode)&&(selectedNode.nodeType != 1)){
+ selectedNode = selectedNode.parentNode;
+ }
+ if(!selectedNode){ return ''; }
+
+ var formats = ["p", "pre", "h1", "h2", "h3", "h4", "h5", "h6", "address"];
+ // gotta run some specialized updates for the various
+ // formatting options
+ var type = formats[dojo.lang.find(formats, selectedNode.nodeName.toLowerCase())];
+ while((selectedNode!=curInst.editNode)&&(!type)){
+ selectedNode = selectedNode.parentNode;
+ if(!selectedNode){ break; }
+ type = formats[dojo.lang.find(formats, selectedNode.nodeName.toLowerCase())];
+ }
+ if(!type){
+ type = "";
+ }
+ return type;
+ }*/
+ }
+);
+
+dojo.require("dojo.widget.FloatingPane");
+// summary:
+// dojo.widget.Editor2Dialog provides a Dialog which can be modal or normal for the Editor2.
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2Dialog",
+ [dojo.widget.HtmlWidget, dojo.widget.FloatingPaneBase, dojo.widget.ModalDialogBase],
+ {
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorDialog.html"),
+ // Boolean: Whether this is a modal dialog. True by default.
+ modal: true,
+// refreshOnShow: true, //for debug for now
+
+ // String: Wwidth of the dialog. None by default
+ width: false,
+ // String: Height of the dialog. None by default
+ height: false,
+
+ // String: startup state of the dialog
+ windowState: "minimized",
+
+ displayCloseAction: true,
+
+ contentFile: "",
+ contentClass: "",
+
+ fillInTemplate: function(args, frag){
+ this.fillInFloatingPaneTemplate(args, frag);
+ dojo.widget.Editor2Dialog.superclass.fillInTemplate.call(this, args, frag);
+ },
+ postCreate: function(){
+ if(this.contentFile){
+ dojo.require(this.contentFile);
+ }
+ if(this.modal){
+ dojo.widget.ModalDialogBase.prototype.postCreate.call(this);
+ }else{
+ with(this.domNode.style) {
+ zIndex = 999;
+ display = "none";
+ }
+ }
+ dojo.widget.FloatingPaneBase.prototype.postCreate.apply(this, arguments);
+ dojo.widget.Editor2Dialog.superclass.postCreate.call(this);
+ if(this.width && this.height){
+ with(this.domNode.style){
+ width = this.width;
+ height = this.height;
+ }
+ }
+ },
+ createContent: function(){
+ if(!this.contentWidget && this.contentClass){
+ this.contentWidget = dojo.widget.createWidget(this.contentClass);
+ this.addChild(this.contentWidget);
+ }
+ },
+ show: function(){
+ if(!this.contentWidget){
+ //buggy IE: if the dialog is hidden, the button widgets
+ //in the dialog can not be shown, so show it temporary (as the
+ //dialog may decide not to show it in loadContent() later)
+ dojo.widget.Editor2Dialog.superclass.show.apply(this, arguments);
+ this.createContent();
+ dojo.widget.Editor2Dialog.superclass.hide.call(this);
+ }
+
+ if(!this.contentWidget || !this.contentWidget.loadContent()){
+ return;
+ }
+ this.showFloatingPane();
+ dojo.widget.Editor2Dialog.superclass.show.apply(this, arguments);
+ if(this.modal){
+ this.showModalDialog();
+ }
+ this.placeModalDialog();
+ if(this.modal){
+ //place the background div under this modal pane
+ this.shared.bg.style.zIndex = this.domNode.style.zIndex-1;
+ }
+ },
+ onShow: function(){
+ dojo.widget.Editor2Dialog.superclass.onShow.call(this);
+ this.onFloatingPaneShow();
+ },
+ closeWindow: function(){
+ this.hide();
+ dojo.widget.Editor2Dialog.superclass.closeWindow.apply(this, arguments);
+ },
+ hide: function(){
+ if(this.modal){
+ this.hideModalDialog();
+ }
+ dojo.widget.Editor2Dialog.superclass.hide.call(this);
+ }
+ }
+);
+
+// summary:
+// dojo.widget.Editor2DialogContent is the actual content of a Editor2Dialog.
+// This class should be subclassed to provide the content.
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2DialogContent",
+ dojo.widget.HtmlWidget,
+{
+ widgetsInTemplate: true,
+
+ loadContent:function(){
+ // summary: Load the content. Called by Editor2Dialog when first shown
+ return true;
+ },
+ cancel: function(){
+ // summary: Default handler when cancel button is clicked.
+ this.parent.hide();
+ }
+});
+
+// summary:
+// dojo.widget.Editor2DialogCommand provides an easy way to popup a dialog when
+// the command is executed.
+dojo.lang.declare("dojo.widget.Editor2DialogCommand", dojo.widget.Editor2BrowserCommand,
+ function(name, dialogParas){
+ this.dialogParas = dialogParas;
+ },
+{
+ execute: function(){
+ if(!this.dialog){
+ if(!this.dialogParas.contentFile || !this.dialogParas.contentClass){
+ alert("contentFile and contentClass should be set for dojo.widget.Editor2DialogCommand.dialogParas!");
+ return;
+ }
+ this.dialog = dojo.widget.createWidget("Editor2Dialog", this.dialogParas);
+
+ dojo.body().appendChild(this.dialog.domNode);
+
+ dojo.event.connect(this, "destroy", this.dialog, "destroy");
+ }
+ this.dialog.show();
+ }
+});
+
+// summary:
+// dojo.widget.Editor2 is the WYSIWYG editor in dojo with toolbar. It supports a plugin
+// framework which can be used to extend the functionalities of the editor, such as
+// adding a context menu, table operation etc.
+// description:
+// Plugins are available using dojo's require syntax. Please find available built-in plugins
+// under src/widget/Editor2Plugin.
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2",
+ dojo.widget.RichText,
+ {
+// // String: url to which save action should send content to
+// saveUrl: "",
+// // String: HTTP method for save (post or get)
+// saveMethod: "post",
+// saveArgName: "editorContent",
+// closeOnSave: false,
+
+ // Boolean: Whether to share toolbar with other instances of Editor2
+ shareToolbar: false,
+ // Boolean: Whether the toolbar should scroll to keep it in the view
+ toolbarAlwaysVisible: false,
+
+// htmlEditing: false,
+
+ toolbarWidget: null,
+ scrollInterval: null,
+
+ // Object: dojo.uri.Uri object to specify the template file for the toolbar
+ toolbarTemplatePath: dojo.uri.dojoUri("src/widget/templates/EditorToolbarOneline.html"),
+ // Object: dojo.uri.Uri object to specify the css file for the toolbar
+ toolbarTemplateCssPath: null,
+// toolbarTemplatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbarFCKStyle.html"),
+// toolbarTemplateCssPath: dojo.uri.dojoUri("src/widget/templates/Editor2/FCKDefault/EditorToolbarFCKStyle.css"),
+
+ _inSourceMode: false,
+ _htmlEditNode: null,
+
+ editorOnLoad: function(){
+ // summary:
+ // Create toolbar and other initialization routines. This is called after
+ // the finish of the loading of document in the editing element
+// dojo.profile.start("dojo.widget.Editor2::editorOnLoad");
+
+ dojo.event.topic.publish("dojo.widget.Editor2::preLoadingToolbar", this);
+ if(this.toolbarAlwaysVisible){
+ dojo.require("dojo.widget.Editor2Plugin.AlwaysShowToolbar");
+ }
+
+ var toolbars = dojo.widget.byType("Editor2Toolbar");
+ if((!toolbars.length)||(!this.shareToolbar)){
+ if(this.toolbarWidget){
+ this.toolbarWidget.show();
+ //re-add the toolbar to the new domNode (caused by open() on another element)
+ dojo.html.insertBefore(this.toolbarWidget.domNode, this.domNode.firstChild);
+ }else{
+ var tbOpts = {};
+ tbOpts.templatePath = this.toolbarTemplatePath;
+ if(this.toolbarTemplateCssPath){
+ tbOpts.templateCssPath = this.toolbarTemplateCssPath;
+ }
+ this.toolbarWidget = dojo.widget.createWidget("Editor2Toolbar", tbOpts, this.domNode.firstChild, "before");
+
+ dojo.event.connect(this, "close", this.toolbarWidget, "hide");
+
+ this.toolbarLoaded();
+ }
+ }else{
+ // FIXME: selecting in one shared toolbar doesn't clobber
+ // selection in the others. This is problematic.
+ this.toolbarWidget = toolbars[0];
+ }
+
+ dojo.event.topic.registerPublisher("Editor2.clobberFocus", this, "clobberFocus");
+ dojo.event.topic.subscribe("Editor2.clobberFocus", this, "setBlur");
+
+ dojo.event.topic.publish("dojo.widget.Editor2::onLoad", this);
+// dojo.profile.end("dojo.widget.Editor2::editorOnLoad");
+ },
+
+ //event for plugins to use
+ toolbarLoaded: function(){
+ // summary:
+ // Fired when the toolbar for this editor is created.
+ // This event is for plugins to use
+ },
+
+ //TODO: provide a query mechanism about loaded plugins?
+ registerLoadedPlugin: function(/*Object*/obj){
+ // summary: Register a plugin which is loaded for this instance
+ if(!this.loadedPlugins){
+ this.loadedPlugins = [];
+ }
+ this.loadedPlugins.push(obj);
+ },
+ unregisterLoadedPlugin: function(/*Object*/obj){
+ // summery: Delete a loaded plugin for this instance
+ for(var i in this.loadedPlugins){
+ if(this.loadedPlugins[i] === obj){
+ delete this.loadedPlugins[i];
+ return;
+ }
+ }
+ dojo.debug("dojo.widget.Editor2.unregisterLoadedPlugin: unknow plugin object: "+obj);
+ },
+
+ //overload the original ones to provide extra commands
+ execCommand: function(/*String*/command, argument){
+ switch(command.toLowerCase()){
+ case 'htmltoggle':
+ this.toggleHtmlEditing();
+ break;
+ default:
+ dojo.widget.Editor2.superclass.execCommand.apply(this, arguments);
+ }
+ },
+ queryCommandEnabled: function(/*String*/command, argument){
+ switch(command.toLowerCase()){
+ case 'htmltoggle':
+ return true;
+ default:
+ if(this._inSourceMode){ return false;}
+ return dojo.widget.Editor2.superclass.queryCommandEnabled.apply(this, arguments);
+ }
+ },
+ queryCommandState: function(/*String*/command, argument){
+ switch(command.toLowerCase()){
+ case 'htmltoggle':
+ return this._inSourceMode;
+ default:
+ return dojo.widget.Editor2.superclass.queryCommandState.apply(this, arguments);
+ }
+ },
+
+ onClick: function(/*Event*/e){
+ dojo.widget.Editor2.superclass.onClick.call(this, e);
+ //if Popup is used, call dojo.widget.PopupManager.onClick
+ //manually when click in the editing area to close all
+ //open popups (dropdowns)
+ if(dojo.widget.PopupManager){
+ if(!e){ //IE
+ e = this.window.event;
+ }
+ dojo.widget.PopupManager.onClick(e);
+ }
+ },
+
+ clobberFocus: function(){
+ // summary: stub to signal other instances to clobber focus
+ },
+ toggleHtmlEditing: function(){
+ // summary: toggle between WYSIWYG mode and HTML source mode
+ if(this===dojo.widget.Editor2Manager.getCurrentInstance()){
+ if(!this._inSourceMode){
+ this._inSourceMode = true;
+
+ if(!this._htmlEditNode){
+ this._htmlEditNode = dojo.doc().createElement("textarea");
+ dojo.html.insertAfter(this._htmlEditNode, this.editorObject);
+ }
+ this._htmlEditNode.style.display = "";
+ this._htmlEditNode.style.width = "100%";
+ this._htmlEditNode.style.height = dojo.html.getBorderBox(this.editNode).height+"px";
+ this._htmlEditNode.value = this.editNode.innerHTML;
+
+ //activeX object (IE) doesn't like to be hidden, so move it outside of screen instead
+ with(this.editorObject.style){
+ position = "absolute";
+ left = "-2000px";
+ top = "-2000px";
+ }
+ }else{
+ this._inSourceMode = false;
+
+ //In IE activeX mode, if _htmlEditNode is focused,
+ //when toggling, an error would occur, so unfocus it
+ this._htmlEditNode.blur();
+
+ with(this.editorObject.style){
+ position = "";
+ left = "";
+ top = "";
+ }
+
+ dojo.lang.setTimeout(this, "replaceEditorContent", 1, this._htmlEditNode.value);
+ this._htmlEditNode.style.display = "none";
+ this.focus();
+ }
+ this.updateToolbar(true);
+ }
+ },
+
+ setFocus: function(){
+ // summary: focus is set on this instance
+// dojo.debug("setFocus: start "+this.widgetId);
+ if(dojo.widget.Editor2Manager.getCurrentInstance() === this){ return; }
+
+ this.clobberFocus();
+// dojo.debug("setFocus:", this);
+ dojo.widget.Editor2Manager.setCurrentInstance(this);
+ },
+
+ setBlur: function(){
+ // summary: focus on this instance is lost
+// dojo.debug("setBlur:", this);
+ //dojo.event.disconnect(this.toolbarWidget, "exec", this, "execCommand");
+ },
+
+ saveSelection: function(){
+ // summary: save the current selection for restoring it
+ this._bookmark = null;
+ this._bookmark = dojo.withGlobal(this.window, dojo.html.selection.getBookmark);
+ },
+ restoreSelection: function(){
+ // summary: restore the last saved selection
+ if(this._bookmark){
+ this.focus(); //require for none-activeX IE
+ dojo.withGlobal(this.window, "moveToBookmark", dojo.html.selection, [this._bookmark]);
+ this._bookmark = null;
+ }else{
+ dojo.debug("restoreSelection: no saved selection is found!");
+ }
+ },
+
+ _updateToolbarLastRan: null,
+ _updateToolbarTimer: null,
+ _updateToolbarFrequency: 500,
+
+ updateToolbar: function(/*Boolean*/force){
+ // summary: update the associated toolbar of this Editor2
+ if((!this.isLoaded)||(!this.toolbarWidget)){ return; }
+
+ // keeps the toolbar from updating too frequently
+ // TODO: generalize this functionality?
+ var diff = new Date() - this._updateToolbarLastRan;
+ if( (!force)&&(this._updateToolbarLastRan)&&
+ ((diff < this._updateToolbarFrequency)) ){
+
+ clearTimeout(this._updateToolbarTimer);
+ var _this = this;
+ this._updateToolbarTimer = setTimeout(function() {
+ _this.updateToolbar();
+ }, this._updateToolbarFrequency/2);
+ return;
+
+ }else{
+ this._updateToolbarLastRan = new Date();
+ }
+ // end frequency checker
+
+ //IE has the habit of generating events even when this editor is blurred, prevent this
+ if(dojo.widget.Editor2Manager.getCurrentInstance() !== this){ return; }
+
+ this.toolbarWidget.update();
+ },
+
+ destroy: function(/*Boolean*/finalize){
+ this._htmlEditNode = null;
+ dojo.event.disconnect(this, "close", this.toolbarWidget, "hide");
+ if(!finalize){
+ this.toolbarWidget.destroy();
+ }
+ dojo.widget.Editor2.superclass.destroy.call(this);
+ },
+
+ onDisplayChanged: function(/*Object*/e){
+ dojo.widget.Editor2.superclass.onDisplayChanged.call(this,e);
+ this.updateToolbar();
+ },
+
+ onLoad: function(){
+ try{
+ dojo.widget.Editor2.superclass.onLoad.call(this);
+ }catch(e){ // FIXME: debug why this is throwing errors in IE!
+ dojo.debug(e);
+ }
+ this.editorOnLoad();
+ },
+
+ onFocus: function(){
+ dojo.widget.Editor2.superclass.onFocus.call(this);
+ this.setFocus();
+ },
+
+ //overload to support source editing mode
+ getEditorContent: function(){
+ if(this._inSourceMode){
+ this.replaceEditorContent(this._htmlEditNode.value);
+ }
+ return dojo.widget.Editor2.superclass.getEditorContent.call(this);
+ }
+ /*,
+ // FIXME: probably not needed any more with new design, but need to verify
+ _save: function(e){
+ // FIXME: how should this behave when there's a larger form in play?
+ if(!this.isClosed){
+ dojo.debug("save attempt");
+ if(this.saveUrl.length){
+ var content = {};
+ content[this.saveArgName] = this.getEditorContent();
+ dojo.io.bind({
+ method: this.saveMethod,
+ url: this.saveUrl,
+ content: content
+ });
+ }else{
+ dojo.debug("please set a saveUrl for the editor");
+ }
+ if(this.closeOnSave){
+ this.close(e.getName().toLowerCase() == "save");
+ }
+ }
+ }*/
+ },
+ "html"
+);
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/AlwaysShowToolbar.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/AlwaysShowToolbar.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/AlwaysShowToolbar.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/AlwaysShowToolbar.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,132 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Editor2Plugin.AlwaysShowToolbar");
+
+//dojo.widget.Editor2Manager.registerPerInstancePlugin("dojo.widget.Editor2Plugin.AlwaysShowToolbar");
+
+dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function(editor){
+ if(editor.toolbarAlwaysVisible){
+ var p = new dojo.widget.Editor2Plugin.AlwaysShowToolbar(editor);
+ }
+});
+dojo.declare("dojo.widget.Editor2Plugin.AlwaysShowToolbar", null,
+ function(editor){
+ this.editor = editor;
+ this.editor.registerLoadedPlugin(this);
+ this.setup();
+ },
+ {
+ _scrollSetUp: false,
+ _fixEnabled: false,
+ _scrollThreshold: false,
+ _handleScroll: true,
+
+ setup: function(){
+ var tdn = this.editor.toolbarWidget;
+ if(!tdn.tbBgIframe){
+ tdn.tbBgIframe = new dojo.html.BackgroundIframe(tdn.domNode);
+ tdn.tbBgIframe.onResized();
+ }
+ this.scrollInterval = setInterval(dojo.lang.hitch(this, "globalOnScrollHandler"), 100);
+
+ dojo.event.connect("before", this.editor.toolbarWidget, "destroy", this, "destroy");
+ },
+
+ globalOnScrollHandler: function(){
+ var isIE = dojo.render.html.ie;
+ if(!this._handleScroll){ return; }
+ var dh = dojo.html;
+ var tdn = this.editor.toolbarWidget.domNode;
+ var db = dojo.body();
+
+ if(!this._scrollSetUp){
+ this._scrollSetUp = true;
+ var editorWidth = dh.getMarginBox(this.editor.domNode).width;
+ this._scrollThreshold = dh.abs(tdn, true).y;
+ // dojo.debug("threshold:", this._scrollThreshold);
+ if((isIE)&&(db)&&(dh.getStyle(db, "background-image")=="none")){
+ with(db.style){
+ backgroundImage = "url(" + dojo.uri.dojoUri("src/widget/templates/images/blank.gif") + ")";
+ backgroundAttachment = "fixed";
+ }
+ }
+ }
+
+ var scrollPos = (window["pageYOffset"]) ? window["pageYOffset"] : (document["documentElement"]||document["body"]).scrollTop;
+
+ // FIXME: need to have top and bottom thresholds so toolbar doesn't keep scrolling past the bottom
+ if(scrollPos > this._scrollThreshold){
+ // dojo.debug(scrollPos);
+ if(!this._fixEnabled){
+ var tdnbox = dojo.html.getMarginBox(tdn);
+ this.editor.editorObject.style.marginTop = tdnbox.height+"px";
+
+ if(isIE){
+ // FIXME: should we just use setBehvior() here instead?
+ tdn.style.left = dojo.html.abs(tdn, dojo.html.boxSizing.MARGIN_BOX).x;
+ dojo.body().appendChild(tdn);
+
+ dojo.html.addClass(tdn, "IEFixedToolbar");
+ }else{
+ with(tdn.style){
+ position = "fixed";
+ top = "0px";
+ }
+ }
+
+ tdn.style.width = tdnbox.width + "px";
+ tdn.style.zIndex = 1000;
+ this._fixEnabled = true;
+ }
+ // if we're showing the floating toolbar, make sure that if
+ // we've scrolled past the bottom of the editor that we hide
+ // the toolbar for this instance of the editor.
+
+ // TODO: when we get multiple editor toolbar support working
+ // correctly, ensure that we check this against the scroll
+ // position of the bottom-most editor instance.
+ if(!dojo.render.html.safari){
+ // safari reports a bunch of things incorrectly here
+ var eHeight = (this.height) ? parseInt(this.editor.height) : this.editor._lastHeight;
+ if(scrollPos > (this._scrollThreshold+eHeight)){
+ tdn.style.display = "none";
+ }else{
+ tdn.style.display = "";
+ }
+ }
+ }else if(this._fixEnabled){
+ (this.editor.object || this.editor.iframe).style.marginTop = null;
+ with(tdn.style){
+ position = "";
+ top = "";
+ zIndex = "";
+ display = "";
+ }
+ if(isIE){
+ tdn.style.left = "";
+ dojo.html.removeClass(tdn, "IEFixedToolbar");
+ dojo.html.insertBefore(tdn, this.editor.object||this.editor.iframe);
+ }
+ tdn.style.width = "";
+ this._fixEnabled = false;
+ }
+ },
+
+ destroy: function(){
+ this._handleScroll = false;
+ clearInterval(this.scrollInterval);
+ this.editor.unregisterLoadedPlugin(this);
+
+ if(dojo.render.html.ie){
+ dojo.html.removeClass(this.editor.toolbarWidget.domNode, "IEFixedToolbar");
+ }
+ }
+});
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/AlwaysShowToolbar.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ContextMenu.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ContextMenu.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ContextMenu.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ContextMenu.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,246 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Editor2Plugin.ContextMenu");
+
+//ContextMenu plugin should be dojo.required-ed before all other plugins which
+//support contextmenu, otherwise the menu for that plugin won't be shown
+
+dojo.require("dojo.widget.Menu2");
+
+dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function(editor){
+ var p = new dojo.widget.Editor2Plugin.ContextMenu(editor);
+});
+dojo.widget.Editor2Plugin.ContextMenuManager = {
+ menuGroups: ['Generic', 'Link', 'Anchor', 'Image', 'List', 'Table'],
+ _registeredGroups: {},
+ registerGroup: function(name, handler){
+ if(this._registeredGroups[name]){
+ alert("dojo.widget.Editor2Plugin.ContextMenuManager.registerGroup: menu group "+name+"is already registered. Ignored.");
+ return;
+ }
+ this._registeredGroups[name] = handler;
+ },
+ removeGroup: function(name){
+ delete this._registeredGroups[name];
+ },
+ getGroup: function(name, contextmenuplugin){
+ if(this._registeredGroups[name]){
+ var item = this._registeredGroups[name](name, contextmenuplugin);
+ if(item){
+ return item;
+ }
+ }
+ switch(name){
+ case 'Generic':
+ case 'Link':
+ case 'Image':
+ return new dojo.widget.Editor2Plugin[name+"ContextMenu"](contextmenuplugin);
+ //TODO
+ case 'Anchor':
+ case 'List':
+ }
+ }
+};
+
+dojo.declare("dojo.widget.Editor2Plugin.ContextMenu", null,
+ function(editor){
+ this.groups = [];
+ this.separators = [];
+ this.editor = editor;
+ this.editor.registerLoadedPlugin(this);
+ this.contextMenu = dojo.widget.createWidget("PopupMenu2", {});
+ dojo.body().appendChild(this.contextMenu.domNode);
+ this.contextMenu.bindDomNode(this.editor.document.body);
+
+ dojo.event.connect(this.contextMenu, "aboutToShow", this, "aboutToShow");
+ dojo.event.connect(this.editor, "destroy", this, "destroy");
+
+ this.setup();
+ },
+ {
+ setup: function(){
+ var gs = dojo.widget.Editor2Plugin.ContextMenuManager.menuGroups;
+ for(var i in gs){
+ var g = dojo.widget.Editor2Plugin.ContextMenuManager.getGroup(gs[i], this);
+ if(g){
+ this.groups.push(g);
+ }
+ }
+ },
+ aboutToShow: function(){
+ var first = true;
+ for(var i in this.groups){
+ if(i>0 && this.separators.length != this.groups.length-1){
+ this.separators.push(dojo.widget.createWidget("MenuSeparator2", {}));
+ this.contextMenu.addChild(this.separators[this.separators.length-1]);
+ }
+ if(this.groups[i].refresh()){
+ if(i>0){
+ if(first){
+ this.separators[i-1].hide();
+ }else{
+ this.separators[i-1].show();
+ }
+ }
+ if(first){ first = false; }
+ }else{
+ if(i>0){
+ this.separators[i-1].hide();
+ }
+ }
+ }
+ },
+ destroy: function(){
+ this.editor.unregisterLoadedPlugin(this);
+ delete this.groups;
+ delete this.separators;
+ this.contextMenu.destroy();
+ delete this.contextMenu;
+ }
+});
+
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2ContextMenuItem",
+ dojo.widget.MenuItem2, {
+ command: null,
+ postCreate: function(){
+ if(!this.command){
+ this.command = this.caption;
+ }
+
+ dojo.widget.Editor2ContextMenuItem.superclass.postCreate.apply(this, arguments);
+ },
+ setup: function(){
+ this.cmd = dojo.widget.Editor2Manager.getCommand(this.command);
+ if(!this.cmd){
+ alert("command " + this.command + " is not recognized!");
+ }
+ },
+ onClick: function(){
+ if(!this.cmd){
+ this.setup();
+ }
+ if(this.cmd){
+ this.cmd.execute();
+ }
+ },
+ refresh: function(){
+ if(!this.cmd){
+ this.setup();
+ }
+ if(this.cmd){
+ if(this.cmd.getState() == dojo.widget.Editor2Manager.commandState.Disabled){
+ this.disable();
+ return false;
+ }else{
+ this.enable();
+ return true;
+ }
+ }
+ },
+ //improve performance by skipping animation
+ hide: function(){
+ this.domNode.style.display = "none";
+ },
+ show: function(){
+ this.domNode.style.display = "";
+ }
+});
+dojo.declare("dojo.widget.Editor2Plugin.SimpleContextMenu", null,
+ function(contextmenuplugin){
+ this.contextMenu = contextmenuplugin.contextMenu;
+ this.items = [];
+
+ dojo.event.connect(contextmenuplugin, "destroy", this, "destroy");
+ },
+ {
+ refresh: function(){
+ if(!this.items.length){
+ this.createItems();
+ for(var i in this.items){
+ this.contextMenu.addChild(this.items[i]);
+ }
+ }
+
+ return this.checkVisibility();
+ },
+ destroy: function(){
+ this.contextmenu = null;
+ delete this.items;
+ delete this.contextMenu;
+ },
+ //implement this to fill in the menu items
+ createItems: function(){ },
+
+ //overload this to show/hide items
+ checkVisibility: function(){
+ var show = false;
+ for(var i in this.items){
+ show = show || this.items[i].refresh();
+ }
+ var action = show ? "show" : "hide";
+ for(var i in this.items){
+ this.items[i][action]();
+ }
+ return show;
+ }
+});
+dojo.declare("dojo.widget.Editor2Plugin.GenericContextMenu",
+ dojo.widget.Editor2Plugin.SimpleContextMenu,
+{
+ createItems: function(){
+ this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Cut", iconClass: "dojoE2TBIcon dojoE2TBIcon_Cut"}));
+ this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Copy", iconClass: "dojoE2TBIcon dojoE2TBIcon_Copy"}));
+ this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Paste", iconClass: "dojoE2TBIcon dojoE2TBIcon_Paste"}));
+ }
+});
+dojo.declare("dojo.widget.Editor2Plugin.LinkContextMenu",
+ dojo.widget.Editor2Plugin.SimpleContextMenu,
+{
+ createItems: function(){
+ this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Modify Link", command: 'createlink', iconClass: "dojoE2TBIcon dojoE2TBIcon_Link"}));
+ this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Remove Link", command: 'unlink', iconClass: "dojoE2TBIcon dojoE2TBIcon_UnLink"}));
+ },
+ checkVisibility: function(){
+ var show = this.items[1].refresh();
+ if(show){
+ this.items[0].refresh();
+ for(var i in this.items){
+ this.items[i].show();
+ }
+ }else{
+ for(var i in this.items){
+ this.items[i].hide();
+ }
+ }
+
+ return show;
+ }
+});
+dojo.declare("dojo.widget.Editor2Plugin.ImageContextMenu",
+ dojo.widget.Editor2Plugin.SimpleContextMenu,
+{
+ createItems: function(){
+ this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Edit Image", command: 'insertimage', iconClass: "dojoE2TBIcon dojoE2TBIcon_Image"}));
+ },
+ checkVisibility: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ var img = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection);
+
+ if(img && img.tagName.toLowerCase() == 'img'){
+ this.items[0].show();
+ return true;
+ }else{
+ this.items[0].hide();
+ return false;
+ }
+ }
+});
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ContextMenu.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/CreateLinkDialog.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/CreateLinkDialog.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/CreateLinkDialog.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/CreateLinkDialog.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,78 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Editor2Plugin.CreateLinkDialog");
+
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2CreateLinkDialog",
+ dojo.widget.Editor2DialogContent,
+{
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/createlink.html"),
+
+ editableAttributes: ['href', 'target', 'class'],
+ loadContent: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+
+ curInst.saveSelection(); //save selection (none-activeX IE)
+
+ this.linkNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['a']);
+ var linkAttributes = {};
+ this.extraAttribText = "";
+ if(this.linkNode){
+ var attrs = this.linkNode.attributes;
+ for(var i=0; i<attrs.length; i++) {
+ if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){
+ linkAttributes[attrs[i].name] = attrs[i].value;
+ }else{
+ //IE lists all attributes, even default ones, filter them
+ if(attrs[i].specified == undefined || attrs[i].specified){
+ this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" ';
+ }
+ }
+ }
+ }else{
+ var html = dojo.withGlobal(curInst.window, "getSelectedText", dojo.html.selection);
+ if(html == null || html.length == 0){
+ alert("Please select some text to create a link.");
+ return false;//do not show the dialog
+ }
+ }
+
+ for(var i=0; i<this.editableAttributes.length; ++i){
+ name = this.editableAttributes[i];
+ this["link_"+name].value = (linkAttributes[name] == undefined) ? "" : linkAttributes[name] ;
+ }
+ return true;
+ },
+ ok: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ curInst.restoreSelection(); //restore previous selection, required for none-activeX IE
+
+ if(!this.linkNode){
+ var html = dojo.withGlobal(curInst.window, "getSelectedHtml", dojo.html.selection);
+ }else{
+ var html = this.linkNode.innerHTML;
+ dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.linkNode]);
+ }
+
+ var attstr='';
+ for(var i=0; i<this.editableAttributes.length; ++i){
+ name = this.editableAttributes[i];
+ var value = this["link_"+name].value;
+ if(value.length > 0){
+ attstr += name + '="'+value+'" ';
+ }
+ }
+
+ curInst.execCommand('inserthtml', '<a '+attstr+this.extraAttribText+'>'+html+'</a>');
+
+ this.cancel();
+ }
+});
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/CreateLinkDialog.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplace.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplace.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplace.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplace.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,74 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Editor2Plugin.FindReplace");
+
+dojo.require("dojo.widget.Editor2");
+
+//TODO replace, better GUI
+
+dojo.declare("dojo.widget.Editor2Plugin.FindCommand", dojo.widget.Editor2DialogCommand,{
+ SearchOption: {
+ CaseSensitive: 4,
+ SearchBackwards: 64,
+ WholeWord: 2,
+ WrapSearch: 128
+ },
+ find: function(text, option){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ if(curInst){
+ curInst.focus();
+ if(window.find){ //moz
+ curInst.window.find(text,
+ option & this.SearchOption.CaseSensitive ? true : false,
+ option & this.SearchOption.SearchBackwards ? true : false,
+ option & this.SearchOption.WrapSearch ? true : false,
+ option & this.SearchOption.WholeWord ? true : false
+ );
+ }else if(dojo.body().createTextRange){ //IE
+ var range = curInst.document.body.createTextRange();
+ var found = range.findText(text, (option&this.SearchOption.SearchBackwards)?1:-1, option );
+ if(found){
+ range.scrollIntoView() ;
+ range.select() ;
+ }else{
+ alert("Can not find "+text+" in the document");
+ }
+ }else{
+ alert("No idea how to search in this browser. Please submit patch if you know.");
+ }
+ }
+ }
+});
+
+dojo.widget.Editor2Manager.registerCommand("Find", new dojo.widget.Editor2Plugin.FindCommand('find',
+ {contentFile: "dojo.widget.Editor2Plugin.FindReplaceDialog",
+ contentClass: "Editor2FindDialog",
+ title: "Find", width: "350px", height: "150px", modal: false}));
+dojo.widget.Editor2Manager.registerCommand("Replace", new dojo.widget.Editor2DialogCommand('replace',
+ {contentFile: "dojo.widget.Editor2Plugin.FindReplaceDialog",
+ contentClass: "Editor2ReplaceDialog",
+ href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/replace.html"),
+ title: "Replace", width: "350px", height: "200px", modal: false}));
+
+dojo.widget.Editor2Plugin.FindReplace = function(name){
+ var name = name.toLowerCase();
+
+ var item;
+ if(name == 'replace'){
+ item = new dojo.widget.Editor2ToolbarButton('Replace');
+ }else if(name == 'find') {
+ item = new dojo.widget.Editor2ToolbarButton('Find');
+ }
+
+ return item;
+}
+
+dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.FindReplace);
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplace.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplaceDialog.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplaceDialog.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplaceDialog.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplaceDialog.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,49 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Editor2Plugin.FindReplaceDialog");
+
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2FindDialog",
+ dojo.widget.Editor2DialogContent,
+{
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/find.html"),
+
+ find: function(){
+ var findcmd = dojo.widget.Editor2Manager.getCommand('find');
+ var option = 0;
+
+ if(this["find_option_casesens"].checked){
+ option |= findcmd.SearchOption.CaseSensitive;
+ }
+ if(this["find_option_backwards"].checked){
+ option |= findcmd.SearchOption.SearchBackwards;
+ }
+
+ if(this["find_option_wholeword"].checked){
+ option |= findcmd.SearchOption.WholeWord;
+ }
+ findcmd.find(this["find_text"].value, option);
+ }
+});
+
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2ReplaceDialog",
+ dojo.widget.Editor2DialogContent,
+{
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/replace.html"),
+
+ replace: function(){
+ alert("not implemented yet");
+ },
+ replaceAll: function(){
+ alert("not implemented yet");
+ }
+});
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/FindReplaceDialog.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertImageDialog.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertImageDialog.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertImageDialog.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertImageDialog.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,64 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Editor2Plugin.InsertImageDialog");
+
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2InsertImageDialog",
+ dojo.widget.Editor2DialogContent,
+{
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/insertimage.html"),
+
+ editableAttributes: ['src', 'alt', 'width', 'height', 'hspace', 'vspace', 'border', 'align'],
+ loadContent: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ this.imageNode = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection);
+ if(!this.imageNode){
+ this.imageNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['img']);
+ }
+ var imageAttributes = {};
+ this.extraAttribText = "";
+ if(this.imageNode){
+ var attrs = this.imageNode.attributes;
+ for(var i=0; i<attrs.length; i++) {
+ if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){
+ imageAttributes[attrs[i].name] = attrs[i].value;
+ }else{
+ this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" ';
+ }
+ }
+ }
+ for(var i=0; i<this.editableAttributes.length; ++i){
+ name = this.editableAttributes[i];
+ this["image_"+name].value = (imageAttributes[name] == undefined) ? "" : imageAttributes[name] ;
+ }
+ return true;
+ },
+ ok: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ var insertcmd = dojo.widget.Editor2Manager.getCommand('inserthtml');
+ var option = 0;
+
+ var attstr='';
+ for(var i=0; i<this.editableAttributes.length; ++i){
+ name = this.editableAttributes[i];
+ var value = this["image_"+name].value;
+ if(value.length > 0){
+ attstr += name + '="'+value+'" ';
+ }
+ }
+ if(this.imageNode){
+ dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.imageNode]);
+ }
+ insertcmd.execute('<img '+attstr+this.extraAttribText+'/>');
+
+ this.cancel();
+ }
+});
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertImageDialog.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertTableDialog.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertTableDialog.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertTableDialog.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertTableDialog.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,147 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Editor2Plugin.InsertTableDialog");
+
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2InsertTableDialog",
+ dojo.widget.Editor2DialogContent,
+{
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/inserttable.html"),
+
+ editableAttributes: ['summery', 'height', 'cellspacing', 'cellpadding', 'border', 'align'],
+
+ loadContent: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ this.tableNode = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection);
+ if(!this.tableNode || this.tableNode.tagName.toLowerCase() != 'table'){
+ this.tableNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['table']);
+ }
+
+ var tableAttributes = {};
+ this.extraAttribText = "";
+ if(this.tableNode){
+ this["table_rows"].value = this.tableNode.rows.length;
+ this["table_rows"].disabled = true;
+ this["table_cols"].value = this.tableNode.rows[0].cells.length;
+ this["table_cols"].disabled = true;
+
+ if (this.tableNode.caption){
+ this["table_caption"].value = this.tableNode.caption.innerHTML;
+ }else{
+ this["table_caption"].value = "";
+ }
+
+ var width = this.tableNode.style.width || this.tableNode.width;
+ if(width){
+ this["table_width"].value = parseInt(width);
+ if (width.indexOf('%') > -1){
+ this["table_widthtype"].value = "percent";
+ }else{
+ this["table_widthtype"].value = "pixels";
+ }
+ }else{
+ this["table_width"].value = "100";
+ }
+
+ var height = this.tableNode.style.height || this.tableNode.height;
+ if(height){
+ this["table_height"].value = parseInt(width);
+ }else{
+ this["table_height"].value = "";
+ }
+
+ var attrs = this.tableNode.attributes;
+ for(var i=0; i<attrs.length; i++) {
+ if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){
+ tableAttributes[attrs[i].name] = attrs[i].value;
+ }else{
+ this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" ';
+ }
+ }
+ }else{
+ this["table_rows"].value = 3;
+ this["table_rows"].disabled = false;
+ this["table_cols"].value = 2;
+ this["table_cols"].disabled = false;
+ this["table_width"].value = 100;
+ this["table_widthtype"].value = "percent";
+ this["table_height"].value = "";
+ }
+
+ for(var i=0; i<this.editableAttributes.length; ++i){
+ name = this.editableAttributes[i];
+ this["table_"+name].value = (tableAttributes[name] == undefined) ? "" : tableAttributes[name];
+ if(name == 'height' && tableAttributes[name] != undefined){
+ this["table_"+name].value = tableAttributes[name];
+ }
+ }
+ return true;
+ },
+ ok: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ var args = {};
+
+ args['rows'] = this["table_rows"].value;
+ args['cols'] = this["table_cols"].value;
+ args['caption'] = this["table_caption"].value;
+ args["tableattrs"] = "";
+ if(this["table_widthtype"].value == "percent"){
+ args["tableattrs"] += 'width="'+this["table_width"].value +'%" ';
+ }else{
+ args["tableattrs"] += 'width="'+this["table_width"].value +'px" ';
+ }
+ for(var i=0; i<this.editableAttributes.length; ++i){
+ var name = this.editableAttributes[i];
+ var value = this["table_"+name].value;
+ if(value.length > 0){
+ args["tableattrs"] += name + '="'+value+'" ';
+ }
+ }
+
+ if(!args["tableattrs"]){
+ args["tableattrs"] = "";
+ }
+
+ //show the border in IE by applying a custom class
+ if(dojo.render.html.ie && !this["table_border"].value){
+ args["tableattrs"] += 'class="dojoShowIETableBorders" ';
+ }
+
+ var html = "<table "+args["tableattrs"]+">";
+ if(args['caption']){
+ html += "<caption>"+args["caption"]+"</caption>";
+ }
+ var outertbody = "<tbody>";
+ if(this.tableNode){
+ //retain the content
+ var tbody = this.tableNode.getElementsByTagName("tbody")[0];
+ outertbody = tbody.outerHTML;
+ if(!outertbody){
+ var cnode = tbody.cloneNode(true);
+ var tmpnode = tbody.ownerDocument.createElement("div");
+ tmpnode.appendChild(cnode);
+ outertbody = tmpnode.innerHTML;
+ }
+ //TODO: save current selection and restore it later
+ dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.tableNode]);
+ }else{
+ var cols = "<tr>";
+ for (var i = 0; i < +args.cols; i++) { cols += "<td></td>"; }
+ cols += "</tr>";
+ for (var i = 0; i < args.rows; i++) { outertbody += cols; }
+ outertbody += "</tbody>";
+ }
+ html += outertbody+"</table>";
+ curInst.execCommand("inserthtml", html);
+
+ this.cancel();
+ }
+});
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/InsertTableDialog.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/SimpleSignalCommands.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/SimpleSignalCommands.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/SimpleSignalCommands.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/SimpleSignalCommands.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,72 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+/*
+ * This plugin adds save() and insertImage() to Editor2 widget, and two commands for each
+ * of them. When the corresponding button is clicked in the toolbar, the added function in the
+ * Editor2 widget is called. This mimics the original Editor2 behavior. If you want to have other
+ * signals on the Editor2 widget, add them to dojo.widget.Editor2Plugin.SimpleSignalCommands.signals
+ * NOTE: Please consider writing your own Editor2 plugin rather than using this backward compatible
+ * plugin
+ * ATTENTION: This plugin overwrites the new built-in insertImage dialog. (If this is not desired, set
+ * dojo.widget.Editor2Plugin.SimpleSignalCommands.signals to not contain insertImage)
+ */
+
+//uncomment this line to add save only (do not overwrite the new built-in insertImage dialog
+//this line should present before require dojo.widget.Editor2Plugin.SimpleSignalCommands
+//dojo.widget.Editor2Plugin['SimpleSignalCommands'] = {signals: ['save']};
+
+dojo.provide("dojo.widget.Editor2Plugin.SimpleSignalCommands");
+
+dojo.require("dojo.widget.Editor2");
+
+dojo.declare("dojo.widget.Editor2Plugin.SimpleSignalCommand", dojo.widget.Editor2Command,
+ function(name){
+ if(dojo.widget.Editor2.prototype[name] == undefined){
+ dojo.widget.Editor2.prototype[name] = function(){ dojo.debug("Editor2::"+name); };
+ }
+ },
+{
+ execute: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+
+ if(curInst){
+ curInst[this._name]();
+ }
+ }
+});
+
+if(dojo.widget.Editor2Plugin['SimpleSignalCommands']){
+ dojo.widget.Editor2Plugin['_SimpleSignalCommands']=dojo.widget.Editor2Plugin['SimpleSignalCommands'];
+}
+
+dojo.widget.Editor2Plugin.SimpleSignalCommands = {
+ signals: ['save', 'insertImage'],
+ Handler: function(name){
+ if(name.toLowerCase() == 'save'){
+ return new dojo.widget.Editor2ToolbarButton('Save');
+ }else if(name.toLowerCase() == 'insertimage'){
+ return new dojo.widget.Editor2ToolbarButton('InsertImage');
+ }
+ },
+ registerAllSignalCommands: function(){
+ for(var i=0;i<this.signals.length;i++){
+ dojo.widget.Editor2Manager.registerCommand(this.signals[i],
+ new dojo.widget.Editor2Plugin.SimpleSignalCommand(this.signals[i]));
+ }
+ }
+};
+
+if(dojo.widget.Editor2Plugin['_SimpleSignalCommands']){
+ dojo.lang.mixin(dojo.widget.Editor2Plugin.SimpleSignalCommands, dojo.widget.Editor2Plugin['_SimpleSignalCommands']);
+}
+
+dojo.widget.Editor2Plugin.SimpleSignalCommands.registerAllSignalCommands();
+dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.SimpleSignalCommands.Handler);
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/SimpleSignalCommands.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/TableOperation.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/TableOperation.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/TableOperation.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/TableOperation.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,147 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Editor2Plugin.TableOperation");
+
+dojo.require("dojo.widget.Editor2");
+
+//subscribe to dojo.widget.RichText::init, not onLoad because after onLoad
+//the stylesheets for the editing areas are already applied and the prefilters
+//are executed, so we have to insert our own trick before that point
+dojo.event.topic.subscribe("dojo.widget.RichText::init", function(editor){
+ editor.__TableOperationShowBorder = false;
+
+ if(dojo.render.html.ie){
+ //add/remove a class to a table with border=0 to show the border when loading/saving
+ editor.contentDomPreFilters.push(dojo.widget.Editor2Plugin.TableOperation.showIETableBorder);
+ editor.contentDomPostFilters.push(dojo.widget.Editor2Plugin.TableOperation.removeIEFakeClass);
+ //include the css file to show table border when border=0
+// editor.__TableOperationShowBorder = true;
+// editor.addStyleSheet(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_ie.css"));
+// editor.editingAreaStyleSheets.push(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_ie.css"));
+ }
+ dojo.event.connect(editor, "editorOnLoad", function(){
+ dojo.widget.Editor2Plugin.TableOperation.toggleTableBorderCommand.execute(editor);
+ });
+});
+
+dojo.widget.Editor2Plugin.TableOperation = {
+ getToolbarItem: function(name){
+ var name = name.toLowerCase();
+
+ var item;
+ switch(name){
+ case 'inserttable':
+ case 'toggletableborder':
+ item = new dojo.widget.Editor2ToolbarButton(name);
+ }
+
+ return item;
+ },
+ getContextMenuGroup: function(name, contextmenuplugin){
+ return new dojo.widget.Editor2Plugin.TableContextMenu(contextmenuplugin);
+ },
+ deleteTableCommand: {
+ execute: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ var table = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['table']);
+ if(table){
+ dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [table]);
+ curInst.execCommand("inserthtml", " "); //Moz does not like an empty string, so a space here instead
+ }
+ },
+ getState: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ var table = dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table']);
+ return table ? dojo.widget.Editor2Manager.commandState.Enabled : dojo.widget.Editor2Manager.commandState.Disabled;
+ },
+ destory: function(){}
+ },
+ toggleTableBorderCommand: {
+ execute: function(instance){
+ var curInst = instance || dojo.widget.Editor2Manager.getCurrentInstance();
+ if(curInst.__TableOperationShowBorder){
+ curInst.__TableOperationShowBorder = false;
+ if(dojo.render.html.moz){
+ curInst.removeStyleSheet(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_gecko.css"));
+ }else if(dojo.render.html.ie){
+ curInst.removeStyleSheet(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_ie.css"));
+ }
+ }else{
+ curInst.__TableOperationShowBorder = true;
+ if(dojo.render.html.moz){
+ curInst.addStyleSheet(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_gecko.css"));
+ }else if(dojo.render.html.ie){
+ curInst.addStyleSheet(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_ie.css"));
+ }
+ }
+ },
+ getState: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ return curInst.__TableOperationShowBorder ? dojo.widget.Editor2Manager.commandState.Latched : dojo.widget.Editor2Manager.commandState.Enabled;
+ },
+ destory: function(){}
+ },
+ showIETableBorder: function(dom){
+ var tables = dom.getElementsByTagName('table');
+ dojo.lang.forEach(tables, function(t){
+ dojo.html.addClass(t, "dojoShowIETableBorders");
+ });
+ return dom;
+ },
+ removeIEFakeClass: function(dom){
+ var tables = dom.getElementsByTagName('table');
+ dojo.lang.forEach(tables, function(t){
+ dojo.html.removeClass(t, "dojoShowIETableBorders");
+ });
+ return dom;
+ }
+}
+
+//register commands: toggletableborder, inserttable, deletetable
+dojo.widget.Editor2Manager.registerCommand("toggletableborder", dojo.widget.Editor2Plugin.TableOperation.toggleTableBorderCommand);
+
+dojo.widget.Editor2Manager.registerCommand("inserttable", new dojo.widget.Editor2DialogCommand('inserttable',
+ {contentFile: "dojo.widget.Editor2Plugin.InsertTableDialog",
+ contentClass: "Editor2InsertTableDialog",
+ title: "Insert/Edit Table", width: "450px", height: "250px"}));
+
+dojo.widget.Editor2Manager.registerCommand("deletetable", dojo.widget.Editor2Plugin.TableOperation.deleteTableCommand);
+
+//register toggletableborder and inserttable as toolbar item
+dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.TableOperation.getToolbarItem);
+
+//add context menu support if dojo.widget.Editor2Plugin.ContextMenu is included before this plugin
+if(dojo.widget.Editor2Plugin.ContextMenuManager){
+ dojo.widget.Editor2Plugin.ContextMenuManager.registerGroup('Table', dojo.widget.Editor2Plugin.TableOperation.getContextMenuGroup);
+
+ dojo.declare("dojo.widget.Editor2Plugin.TableContextMenu",
+ dojo.widget.Editor2Plugin.SimpleContextMenu,
+ {
+ createItems: function(){
+ this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Delete Table", command: 'deletetable'}));
+ this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Table Property", command: 'inserttable', iconClass: "TB_Button_Icon TB_Button_Table"}));
+ },
+ checkVisibility: function(){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ var table = dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table']);
+
+ if(dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table'])){
+ this.items[0].show();
+ this.items[1].show();
+ return true;
+ }else{
+ this.items[0].hide();
+ this.items[1].hide();
+ return false;
+ }
+ }
+ });
+}
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/TableOperation.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ToolbarDndSupport.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ToolbarDndSupport.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ToolbarDndSupport.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ToolbarDndSupport.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,68 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+/*TODO:
+ * Add a command to toggle DnD support for a toolbar
+ * Save/restore order of toolbar/item
+ */
+dojo.provide("dojo.widget.Editor2Plugin.ToolbarDndSupport");
+dojo.require("dojo.dnd.*");
+
+dojo.event.topic.subscribe("dojo.widget.Editor2::preLoadingToolbar", function(editor){
+ dojo.dnd.dragManager.nestedTargets = true;
+ var p = new dojo.widget.Editor2Plugin.ToolbarDndSupport(editor);
+});
+
+dojo.declare("dojo.widget.Editor2Plugin.ToolbarDndSupport", null,{
+ lookForClass: "dojoEditorToolbarDnd TB_ToolbarSet TB_Toolbar",
+ initializer: function(editor){
+ this.editor = editor;
+ dojo.event.connect(this.editor, "toolbarLoaded", this, "setup");
+ this.editor.registerLoadedPlugin(this);
+ },
+
+ setup: function(){
+ dojo.event.disconnect(this.editor, "toolbarLoaded", this, "setup");
+ var tbw = this.editor.toolbarWidget;
+ dojo.event.connect("before", tbw, "destroy", this, "destroy");
+
+ var nodes = dojo.html.getElementsByClass(this.lookForClass, tbw.domNode, null, dojo.html.classMatchType.ContainsAny);
+ if(!nodes){
+ dojo.debug("dojo.widget.Editor2Plugin.ToolbarDndSupport: No dom node with class in "+this.lookForClass);
+ return;
+ }
+ for(var i=0; i<nodes.length; i++){
+ var node = nodes[i];
+ var droptarget = node.getAttribute("dojoETDropTarget");
+ if(droptarget){
+ (new dojo.dnd.HtmlDropTarget(node, [droptarget+tbw.widgetId])).vertical = true;
+ }
+ var dragsource = node.getAttribute("dojoETDragSource");
+ if(dragsource){
+ new dojo.dnd.HtmlDragSource(node, dragsource+tbw.widgetId);
+ }
+ }
+ },
+
+ destroy: function(){
+ this.editor.unregisterLoadedPlugin(this);
+ }
+});
+
+//let's have a command to enable DnD
+/*dojo.declare("dojo.widget.Editor2Plugin.ToolbarDndCommand", dojo.widget.Editor2Command,{
+ execute: function(text, option){
+ var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
+ if(curInst){
+ }
+ },
+ getState: function(){
+ }
+});*/
\ No newline at end of file
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/ToolbarDndSupport.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/__package__.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/__package__.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/__package__.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/__package__.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,15 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.kwCompoundRequire({
+ common: [ "dojo.widget.Editor2",
+ "dojo.widget.Editor2Toolbar"]
+});
+dojo.provide("dojo.widget.Editor2Plugin.*");
Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Plugin/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Toolbar.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Toolbar.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Toolbar.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/widget/Editor2Toolbar.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,600 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Editor2Toolbar");
+
+dojo.require("dojo.lang.*");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html.layout");
+dojo.require("dojo.html.display");
+dojo.require("dojo.widget.RichText");
+dojo.require("dojo.widget.PopupContainer");
+dojo.require("dojo.widget.ColorPalette");
+
+// Object: Manager available editor2 toolbar items
+dojo.widget.Editor2ToolbarItemManager = {
+ _registeredItemHandlers: [],
+ registerHandler: function(/*Object*/obj, /*String*/func){
+ // summary: register a toolbar item handler
+ // obj: object which has the function to call
+ // func: the function in the object
+ if(arguments.length == 2){
+ this._registeredItemHandlers.push(function(){return obj[func].apply(obj, arguments);});
+ }else{
+ /* obj: Function
+ func: null
+ pId: f */
+// for(i in this._registeredItemHandlers){
+// if(func === this._registeredItemHandlers[i]){
+// dojo.debug("Editor2ToolbarItemManager handler "+func+" is already registered, ignored");
+// return;
+// }
+// }
+ this._registeredItemHandlers.push(obj);
+ }
+ },
+ removeHandler: function(func){
+ // summary: remove a registered handler
+ for(var i in this._registeredItemHandlers){
+ if(func === this._registeredItemHandlers[i]){
+ delete this._registeredItemHandlers[i];
+ return;
+ }
+ }
+ dojo.debug("Editor2ToolbarItemManager handler "+func+" is not registered, can not remove.");
+ },
+ destroy: function(){
+ for(var i in this._registeredItemHandlers){
+ delete this._registeredItemHandlers[i];
+ }
+ },
+ getToolbarItem: function(/*String*/name){
+ // summary: return a toobar item with the given name
+ var item;
+ name = name.toLowerCase();
+ for(var i in this._registeredItemHandlers){
+ item = this._registeredItemHandlers[i](name);
+ if(item){
+ break;
+ }
+ }
+
+ if(!item){
+ switch(name){
+ //button for builtin functions
+ case 'bold':
+ case 'copy':
+ case 'cut':
+ case 'delete':
+ case 'indent':
+ case 'inserthorizontalrule':
+ case 'insertorderedlist':
+ case 'insertunorderedlist':
+ case 'italic':
+ case 'justifycenter':
+ case 'justifyfull':
+ case 'justifyleft':
+ case 'justifyright':
+ case 'outdent':
+ case 'paste':
+ case 'redo':
+ case 'removeformat':
+ case 'selectall':
+ case 'strikethrough':
+ case 'subscript':
+ case 'superscript':
+ case 'underline':
+ case 'undo':
+ case 'unlink':
+ case 'createlink':
+ case 'insertimage':
+ //extra simple buttons
+ case 'htmltoggle':
+ item = new dojo.widget.Editor2ToolbarButton(name);
+ break;
+ case 'forecolor':
+ case 'hilitecolor':
+ item = new dojo.widget.Editor2ToolbarColorPaletteButton(name);
+ break;
+ case 'plainformatblock':
+ item = new dojo.widget.Editor2ToolbarFormatBlockPlainSelect("formatblock");
+ break;
+ case 'formatblock':
+ item = new dojo.widget.Editor2ToolbarFormatBlockSelect("formatblock");
+ break;
+ case 'fontsize':
+ item = new dojo.widget.Editor2ToolbarFontSizeSelect("fontsize");
+ break;
+ case 'fontname':
+ item = new dojo.widget.Editor2ToolbarFontNameSelect("fontname");
+ break;
+ case 'inserttable':
+ case 'insertcell':
+ case 'insertcol':
+ case 'insertrow':
+ case 'deletecells':
+ case 'deletecols':
+ case 'deleterows':
+ case 'mergecells':
+ case 'splitcell':
+ dojo.debug(name + " is implemented in dojo.widget.Editor2Plugin.TableOperation, please require it first.");
+ break;
+ //TODO:
+ case 'inserthtml':
+ case 'blockdirltr':
+ case 'blockdirrtl':
+ case 'dirltr':
+ case 'dirrtl':
+ case 'inlinedirltr':
+ case 'inlinedirrtl':
+ dojo.debug("Not yet implemented toolbar item: "+name);
+ break;
+ default:
+ dojo.debug("dojo.widget.Editor2ToolbarItemManager.getToolbarItem: Unknown toolbar item: "+name);
+ }
+ }
+ return item;
+ }
+};
+
+dojo.addOnUnload(dojo.widget.Editor2ToolbarItemManager, "destroy");
+// summary:
+// dojo.widget.Editor2ToolbarButton is the base class for all toolbar item in Editor2Toolbar
+dojo.declare("dojo.widget.Editor2ToolbarButton", null,{
+ initializer: function(name){
+ // summary: constructor
+ this._name = name;
+ this._command = dojo.widget.Editor2Manager.getCommand(name);
+ },
+ create: function(/*DomNode*/node, /*dojo.widget.Editor2Toolbar*/toolbar, /*Boolean*/nohover){
+ // summary: create the item
+ // node: the dom node which is the root of this toolbar item
+ // toolbar: the Editor2Toolbar widget this toolbar item belonging to
+ // nohover: whether this item in charge of highlight this item
+ this._domNode = node;
+ //make this unselectable: different browsers
+ //use different properties for this, so use
+ //js do it automatically
+ this.disableSelection(this._domNode);
+ this._parentToolbar = toolbar;
+ dojo.event.connect(this._domNode, 'onclick', this, 'onClick');
+ if(!nohover){
+ dojo.event.connect(this._domNode, 'onmouseover', this, 'onMouseOver');
+ dojo.event.connect(this._domNode, 'onmouseout', this, 'onMouseOut');
+ }
+ },
+ disableSelection: function(/*DomNode*/rootnode){
+ // summary: disable selection on the passed node and all its children
+ dojo.html.disableSelection(rootnode);
+ var nodes = rootnode.all || rootnode.getElementsByTagName("*");
+ for(var x=0; x<nodes.length; x++){
+ dojo.html.disableSelection(nodes[x]);
+ }
+ },
+ onMouseOver: function(){
+ if(this._command.getState() != dojo.widget.Editor2Manager.commandState.Disabled){
+ this.highlightToolbarItem();
+ }
+ },
+ onMouseOut: function(){
+ this.unhighlightToolbarItem();
+ },
+ destroy: function(){
+ // summary: destructor
+ this._domNode = null;
+ delete this._command;
+ this._parentToolbar = null;
+ },
+ onClick: function(e){
+ if(this._domNode && !this._domNode.disabled && this._command){
+ e.preventDefault();
+ e.stopPropagation();
+ this._command.execute();
+ }
+ },
+ refreshState: function(){
+ // summary: update the state of the toolbar item
+ if(this._domNode && this._command){
+ var em = dojo.widget.Editor2Manager;
+ var state = this._command.getState();
+ if(state != this._lastState){
+ switch(state){
+ case em.commandState.Latched:
+ this.latchToolbarItem();
+ break;
+ case em.commandState.Enabled:
+ this.enableToolbarItem();
+ break;
+ case em.commandState.Disabled:
+ default:
+ this.disableToolbarItem();
+ }
+ this._lastState = state;
+ }
+ return state;
+ }
+ },
+
+ latchToolbarItem: function(){
+ this._domNode.disabled = false;
+ this.removeToolbarItemStyle(this._domNode);
+ dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarLatchedItemStyle);
+ },
+
+ enableToolbarItem: function(){
+ this._domNode.disabled = false;
+ this.removeToolbarItemStyle(this._domNode);
+ dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarEnabledItemStyle);
+ },
+
+ disableToolbarItem: function(){
+ this._domNode.disabled = true;
+ this.removeToolbarItemStyle(this._domNode);
+ dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarDisabledItemStyle);
+ },
+
+ highlightToolbarItem: function(){
+ dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarHighlightedItemStyle);
+ },
+
+ unhighlightToolbarItem: function(){
+ dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarHighlightedItemStyle);
+ },
+
+ removeToolbarItemStyle: function(){
+ dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarEnabledItemStyle);
+ dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarLatchedItemStyle);
+ dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarDisabledItemStyle);
+ this.unhighlightToolbarItem();
+ }
+});
+
+// summary: dojo.widget.Editor2ToolbarDropDownButton extends the basic button with a dropdown list
+dojo.declare("dojo.widget.Editor2ToolbarDropDownButton", dojo.widget.Editor2ToolbarButton,{
+ onClick: function(){
+ if(this._domNode){
+ if(!this._dropdown){
+ this._dropdown = dojo.widget.createWidget("PopupContainer", {});
+ this._domNode.appendChild(this._dropdown.domNode);
+ }
+ if(this._dropdown.isShowingNow){
+ this._dropdown.close();
+ }else{
+ this.onDropDownShown();
+ this._dropdown.open(this._domNode, null, this._domNode);
+ }
+ }
+ },
+ destroy: function(){
+ this.onDropDownDestroy();
+ if(this._dropdown){
+ this._dropdown.destroy();
+ }
+ dojo.widget.Editor2ToolbarDropDownButton.superclass.destroy.call(this);
+ },
+ onDropDownShown: function(){},
+ onDropDownDestroy: function(){}
+});
+
+// summary: dojo.widget.Editor2ToolbarColorPaletteButton provides a dropdown color palette picker
+dojo.declare("dojo.widget.Editor2ToolbarColorPaletteButton", dojo.widget.Editor2ToolbarDropDownButton,{
+ onDropDownShown: function(){
+ if(!this._colorpalette){
+ this._colorpalette = dojo.widget.createWidget("ColorPalette", {});
+ this._dropdown.addChild(this._colorpalette);
+
+ this.disableSelection(this._dropdown.domNode);
+ this.disableSelection(this._colorpalette.domNode);
+ //do we need a destory to delete this._colorpalette manually?
+ //I assume as it is added to this._dropdown via addChild, it
+ //should be deleted when this._dropdown is destroyed
+
+ dojo.event.connect(this._colorpalette, "onColorSelect", this, 'setColor');
+ dojo.event.connect(this._dropdown, "open", this, 'latchToolbarItem');
+ dojo.event.connect(this._dropdown, "close", this, 'enableToolbarItem');
+ }
+ },
+ setColor: function(color){
+ this._dropdown.close();
+ this._command.execute(color);
+ }
+});
+
+// summary: dojo.widget.Editor2ToolbarFormatBlockPlainSelect provides a simple select for setting block format
+dojo.declare("dojo.widget.Editor2ToolbarFormatBlockPlainSelect", dojo.widget.Editor2ToolbarButton,{
+ create: function(node, toolbar){
+ //TODO: check node is a select
+ this._domNode = node;
+ this.disableSelection(this._domNode);
+ this._parentToolbar = toolbar;
+ dojo.event.connect(this._domNode, 'onchange', this, 'onChange');
+ },
+
+ destroy: function(){
+ this._domNode = null;
+ this._command = null;
+ this._parentToolbar = null;
+ },
+
+ onChange: function(){
+ if(this._domNode){
+ var sv = this._domNode.value.toLowerCase();
+ this._command.execute(sv);
+ }
+ },
+
+ refreshState: function(){
+ if(this._domNode && this._command){
+ dojo.widget.Editor2ToolbarFormatBlockPlainSelect.superclass.refreshState.call(this);
+ var format = this._command.getValue();
+ if(!format){ format = ""; }
+ dojo.lang.forEach(this._domNode.options, function(item){
+ if(item.value.toLowerCase() == format.toLowerCase()){
+ item.selected = true;
+ }
+ });
+ }
+ }
+});
+
+// summary: dojo.widget.Editor2ToolbarComboItem provides an external loaded dropdown list
+dojo.declare("dojo.widget.Editor2ToolbarComboItem", dojo.widget.Editor2ToolbarDropDownButton,{
+ href: null,
+ create: function(node, toolbar){
+ dojo.widget.Editor2ToolbarComboItem.superclass.create.call(this, node, toolbar);
+ //do not use lazy initilization, as we need the local names in refreshState()
+ if(!this._contentPane){
+ dojo.require("dojo.widget.ContentPane");
+ this._contentPane = dojo.widget.createWidget("ContentPane", {preload: 'true'});
+ this._contentPane.addOnLoad(this, "setup");
+ this._contentPane.setUrl(this.href);
+ }
+ },
+
+ onMouseOver: function(e){
+ dojo.html.addClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectStyle);
+ },
+ onMouseOut:function(e){
+ dojo.html.removeClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectStyle);
+ },
+
+ onDropDownShown: function(){
+ if(!this._dropdown.__addedContentPage){
+ this._dropdown.addChild(this._contentPane);
+ this._dropdown.__addedContentPage = true;
+ }
+ },
+
+ setup: function(){
+ // summary: overload this to connect event
+ },
+
+ onChange: function(e){
+ var name = e.currentTarget.getAttribute("dropDownItemName");
+ this._command.execute(name);
+ this._dropdown.close();
+ },
+
+ onMouseOverItem: function(e){
+ dojo.html.addClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectItemStyle);
+ },
+
+ onMouseOutItem: function(e){
+ dojo.html.removeClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectItemStyle);
+ },
+
+ refreshState: function(){
+ // summary: overload this to update GUI item
+ }
+});
+
+// summary: dojo.widget.Editor2ToolbarFormatBlockSelect is an improved format block setting item
+dojo.declare("dojo.widget.Editor2ToolbarFormatBlockSelect", dojo.widget.Editor2ToolbarComboItem,{
+ href: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FormatBlock.html"),
+
+ setup: function(){
+ dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.setup.call(this);
+
+ var nodes = this._contentPane.domNode.all || this._contentPane.domNode.getElementsByTagName("*");
+ this._blockNames = {};
+ this._blockDisplayNames = {};
+ for(var x=0; x<nodes.length; x++){
+ var node = nodes[x];
+ dojo.html.disableSelection(node);
+ var name=node.getAttribute("dropDownItemName")
+ if(name){
+ this._blockNames[name] = node;
+ var childrennodes = node.getElementsByTagName(name);
+ this._blockDisplayNames[name] = childrennodes[childrennodes.length-1].innerHTML;
+ }
+ }
+ for(var name in this._blockNames){
+ dojo.event.connect(this._blockNames[name], "onclick", this, "onChange");
+ dojo.event.connect(this._blockNames[name], "onmouseover", this, "onMouseOverItem");
+ dojo.event.connect(this._blockNames[name], "onmouseout", this, "onMouseOutItem");
+ }
+ },
+
+ onDropDownDestroy: function(){
+ if(this._blockNames){
+ for(var name in this._blockNames){
+ delete this._blockNames[name];
+ delete this._blockDisplayNames[name];
+ }
+ }
+ },
+
+ refreshState: function(){
+ if(this._command){
+ //dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.refreshState.call(this);
+ var format = this._command.getValue();
+ if(format == this._lastSelectedFormat && this._blockDisplayNames){
+ return;
+ }
+ this._lastSelectedFormat = format;
+ var label = this._domNode.getElementsByTagName("label")[0];
+ var isSet = false;
+ if(this._blockDisplayNames){
+ for(var name in this._blockDisplayNames){
+ if(name == format){
+ label.innerHTML = this._blockDisplayNames[name];
+ isSet = true;
+ break;
+ }
+ }
+ if(!isSet){
+ label.innerHTML = " ";
+ }
+ }
+ }
+ }
+});
+
+// summary: dojo.widget.Editor2ToolbarFontSizeSelect provides a dropdown list for setting fontsize
+dojo.declare("dojo.widget.Editor2ToolbarFontSizeSelect", dojo.widget.Editor2ToolbarComboItem,{
+ href: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FontSize.html"),
+
+ setup: function(){
+ dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.setup.call(this);
+
+ var nodes = this._contentPane.domNode.all || this._contentPane.domNode.getElementsByTagName("*");
+ this._fontsizes = {};
+ this._fontSizeDisplayNames = {};
+ for(var x=0; x<nodes.length; x++){
+ var node = nodes[x];
+ dojo.html.disableSelection(node);
+ var name=node.getAttribute("dropDownItemName")
+ if(name){
+ this._fontsizes[name] = node;
+ this._fontSizeDisplayNames[name] = node.getElementsByTagName('font')[0].innerHTML;
+ }
+ }
+ for(var name in this._fontsizes){
+ dojo.event.connect(this._fontsizes[name], "onclick", this, "onChange");
+ dojo.event.connect(this._fontsizes[name], "onmouseover", this, "onMouseOverItem");
+ dojo.event.connect(this._fontsizes[name], "onmouseout", this, "onMouseOutItem");
+ }
+ },
+
+ onDropDownDestroy: function(){
+ if(this._fontsizes){
+ for(var name in this._fontsizes){
+ delete this._fontsizes[name];
+ delete this._fontSizeDisplayNames[name];
+ }
+ }
+ },
+
+ refreshState: function(){
+ if(this._command){
+ //dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.refreshState.call(this);
+ var size = this._command.getValue();
+ if(size == this._lastSelectedSize && this._fontSizeDisplayNames){
+ return;
+ }
+ this._lastSelectedSize = size;
+ var label = this._domNode.getElementsByTagName("label")[0];
+ var isSet = false;
+ if(this._fontSizeDisplayNames){
+ for(var name in this._fontSizeDisplayNames){
+ if(name == size){
+ label.innerHTML = this._fontSizeDisplayNames[name];
+ isSet = true;
+ break;
+ }
+ }
+ if(!isSet){
+ label.innerHTML = " ";
+ }
+ }
+ }
+ }
+});
+
+// summary: dojo.widget.Editor2ToolbarFontNameSelect provides a dropdown list for setting fontname
+dojo.declare("dojo.widget.Editor2ToolbarFontNameSelect", dojo.widget.Editor2ToolbarFontSizeSelect,{
+ href: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FontName.html")
+});
+
+// summary:
+// dojo.widget.Editor2Toolbar is the main widget for the toolbar associated with an Editor2
+dojo.widget.defineWidget(
+ "dojo.widget.Editor2Toolbar",
+ dojo.widget.HtmlWidget,
+ {
+ templatePath: dojo.uri.dojoUri("src/widget/templates/EditorToolbar.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/EditorToolbar.css"),
+
+ // DOM Nodes
+// saveButton: null,
+
+ // String: class name for latched toolbar button items
+ ToolbarLatchedItemStyle: "ToolbarButtonLatched",
+ // String: class name for enabled toolbar button items
+ ToolbarEnabledItemStyle: "ToolbarButtonEnabled",
+ // String: class name for disabled toolbar button items
+ ToolbarDisabledItemStyle: "ToolbarButtonDisabled",
+ // String: class name for highlighted toolbar button items
+ ToolbarHighlightedItemStyle: "ToolbarButtonHighlighted",
+ // String: class name for highlighted toolbar select items
+ ToolbarHighlightedSelectStyle: "ToolbarSelectHighlighted",
+ // String: class name for highlighted toolbar select dropdown items
+ ToolbarHighlightedSelectItemStyle: "ToolbarSelectHighlightedItem",
+
+// itemNodeType: 'span', //all the items (with attribute dojoETItemName set) defined in the toolbar should be a of this type
+
+ postCreate: function(){
+ var nodes = dojo.html.getElementsByClass("dojoEditorToolbarItem", this.domNode/*, this.itemNodeType*/);
+
+ this.items = {};
+ for(var x=0; x<nodes.length; x++){
+ var node = nodes[x];
+ var itemname = node.getAttribute("dojoETItemName");
+ if(itemname){
+ var item = dojo.widget.Editor2ToolbarItemManager.getToolbarItem(itemname);
+ if(item){
+ item.create(node, this);
+ this.items[itemname.toLowerCase()] = item;
+ }else{
+ //hide unsupported toolbar items
+ node.style.display = "none";
+ }
+ }
+ }
+ },
+
+ update: function(){
+ // summary: update all the toolbar items
+ for(var cmd in this.items){
+ this.items[cmd].refreshState();
+ }
+ },
+
+ destroy: function(){
+ for(var it in this.items){
+ this.items[it].destroy();
+ delete this.items[it];
+ }
+ dojo.widget.Editor2Toolbar.superclass.destroy.call(this);
+ }//,
+
+ // stub for observers
+// exec: function(what, arg){ /* dojo.debug(what, new Date()); */ }
+ },
+ "html",
+ function(){
+ dojo.event.connect(this, "fillInTemplate", dojo.lang.hitch(this, function(){
+ if(dojo.render.html.ie){
+ this.domNode.style.zoom = 1.0;
+ }
+ }));
+ }
+);