You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2006/10/07 20:22:39 UTC
svn commit: r453979 [5/8] - in
/tapestry/tapestry4/trunk/tapestry-framework/src/js: dojo/ dojo/src/
dojo/src/collections/ dojo/src/data/ dojo/src/data/csv/ dojo/src/date/
dojo/src/debug/ dojo/src/event/ dojo/src/gfx/ dojo/src/html/ dojo/src/i18n/
dojo/...
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2.js Sat Oct 7 11:22:33 2006
@@ -22,38 +22,35 @@
dojo.require("dojo.widget.RichText");
dojo.require("dojo.widget.Editor2Toolbar");
-// dojo.require("dojo.widget.ColorPalette");
-// dojo.require("dojo.string.extras");
-
-//API to manage current focused Editor2 Instance
+// Object: Manager of current focused Editor2 Instance and available editor2 commands
dojo.widget.Editor2Manager = {
- //private variables
_currentInstance: null,
_loadedCommands: {},
- destroy: function(){
- this._currentInstance = null;
- for(var cmd in this._loadedCommands){
- this._loadedCommands[cmd].destory();
- }
- },
-
+ // Object: state a command may be in
commandState: {Disabled: 0, Latched: 1, Enabled: 2},
- //Public API
+
getCurrentInstance: function(){
+ // summary: Return the current focused Editor2 instance
return this._currentInstance;
},
- setCurrentInstance: function(inst){
+ setCurrentInstance: function(/*Widget*/inst){
+ // summary: Set current focused Editor2 instance
this._currentInstance = inst;
},
- registerCommand: function(name, cmd){
+ 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(name){
+ 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){
@@ -63,7 +60,7 @@
switch(name){
case 'htmltoggle':
//Editor2 natively provide the htmltoggle functionalitity
- //and it is treated as a builtin command
+ //and it is treated as a builtin command
oCommand = new dojo.widget.Editor2BrowserCommand(name);
break;
case 'formatblock':
@@ -75,14 +72,14 @@
//dialog command
case 'createlink':
- oCommand = new dojo.widget.Editor2DialogCommand(name,
- {contentFile: "dojo.widget.Editor2Plugin.CreateLinkDialog",
+ 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",
+ oCommand = new dojo.widget.Editor2DialogCommand(name,
+ {contentFile: "dojo.widget.Editor2Plugin.InsertImageDialog",
contentClass: "Editor2InsertImageDialog",
title: "Insert/Edit Image", width: "400px", height: "270px"});
break;
@@ -99,28 +96,46 @@
}
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");
-/* base class for all command in Editor2 */
+// 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){
- alert("Please implement your own execute() function for subclass of Editor2Command.");
+ // 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(){}
+ 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();
@@ -166,7 +181,7 @@
if(!curInst){ return ''; }
var h = dojo.render.html;
-
+
// safari f's us for selection primitives
if(h.safari){ return ''; }
@@ -195,25 +210,31 @@
);
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],
{
- modal: true,
templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorDialog.html"),
- executeScripts: true,
- refreshOnShow: true, //for debug for now
+ // 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){
+ fillInTemplate: function(args, frag){
this.fillInFloatingPaneTemplate(args, frag);
dojo.widget.Editor2Dialog.superclass.fillInTemplate.call(this, args, frag);
},
@@ -285,6 +306,9 @@
}
);
+// 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,
@@ -292,14 +316,19 @@
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();
}
});
-dojo.lang.declare("dojo.widget.Editor2DialogCommand", dojo.widget.Editor2BrowserCommand,
+// 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;
},
@@ -320,29 +349,48 @@
}
});
+// 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,
{
- saveUrl: "",
- saveMethod: "post",
- saveArgName: "editorContent",
- closeOnSave: false,
+// // 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,
- _inSourceMode: false,
- _htmlEditNode: null,
+
+// 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"),
- plugins: "",
+ _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);
@@ -382,16 +430,22 @@
},
//event for plugins to use
- toolbarLoaded: function(){},
+ 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];
@@ -401,39 +455,39 @@
dojo.debug("dojo.widget.Editor2.unregisterLoadedPlugin: unknow plugin object: "+obj);
},
- //overload the default one to provide extra commands
- execCommand: function(command, argument){
+ //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.call(this, command, argument);
+ dojo.widget.Editor2.superclass.execCommand.apply(this, arguments);
}
},
- queryCommandEnabled: function(command, argument){
+ queryCommandEnabled: function(/*String*/command, argument){
switch(command.toLowerCase()){
case 'htmltoggle':
return true;
default:
if(this._inSourceMode){ return false;}
- return dojo.widget.Editor2.superclass.queryCommandEnabled.call(this, command, argument);
+ return dojo.widget.Editor2.superclass.queryCommandEnabled.apply(this, arguments);
}
},
- queryCommandState: function(command, argument){
+ queryCommandState: function(/*String*/command, argument){
switch(command.toLowerCase()){
case 'htmltoggle':
return this._inSourceMode;
default:
- return dojo.widget.Editor2.superclass.queryCommandState.call(this, command, argument);
+ return dojo.widget.Editor2.superclass.queryCommandState.apply(this, arguments);
}
},
- onClick: function(e){
+ onClick: function(/*Object*/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)
+ //open popups (dropdowns)
if(dojo.widget.PopupManager){
if(!e){ //IE
e = this.window.event;
@@ -442,8 +496,11 @@
}
},
- clobberFocus: function(){},
+ 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;
@@ -485,16 +542,18 @@
},
setFocus: function(){
- dojo.debug("setFocus: start "+this.widgetId);
+ // 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.debug("setFocus:", this);
dojo.widget.Editor2Manager.setCurrentInstance(this);
},
setBlur: function(){
- dojo.debug("setBlur:", this);
+ // summary: focus on this instance is lost
+// dojo.debug("setBlur:", this);
//dojo.event.disconnect(this.toolbarWidget, "exec", this, "execCommand");
},
@@ -502,7 +561,8 @@
_updateToolbarTimer: null,
_updateToolbarFrequency: 500,
- updateToolbar: function(force){
+ 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
@@ -523,16 +583,13 @@
}
// end frequency checker
- //TODO
- //if((cmd == "inserthtml") || (cmd == "save")){ return; }
-
//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(finalize){
+ destroy: function(/*Boolean*/finalize){
this._htmlEditNode = null;
dojo.event.disconnect(this, "close", this.toolbarWidget, "hide");
if(!finalize){
@@ -541,7 +598,7 @@
dojo.widget.Editor2.superclass.destroy.call(this);
},
- onDisplayChanged: function(e){
+ onDisplayChanged: function(/*Object*/e){
dojo.widget.Editor2.superclass.onDisplayChanged.call(this,e);
this.updateToolbar();
},
@@ -566,9 +623,9 @@
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
+ }
/*,
-
+ // 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){
@@ -591,19 +648,4 @@
}*/
},
"html"
-);
-
-//ContextMenu plugin should come before all other plugins which support
-//contextmenu, otherwise the menu for that plugin won't be shown
-dojo.require("dojo.widget.Editor2Plugin.ContextMenu");
-
-// plugins are available using dojo's require syntax:
-// dojo.widget.Editor2Plugin.FindReplace
-//dojo.widget.Editor2Plugin.TableOperation
-//dojo.widget.Editor2Plugin.ToolbarDndSupport
-//dojo.widget.Editor2Plugin.ContextMenu
-//use this plugin to have the old save/insertImage stub called when the
-//corresponding button is clicked.
-//Attention: this plugin overwrites the new builtin insertImage dialog
-//see comments in the plugin file
-//dojo.widget.Editor2Plugin.SimpleSignalCommands
\ No newline at end of file
+);
\ No newline at end of file
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/ContextMenu.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/ContextMenu.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/ContextMenu.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/ContextMenu.js Sat Oct 7 11:22:33 2006
@@ -10,6 +10,9 @@
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){
@@ -190,7 +193,7 @@
return show;
}
});
-dojo.declare("dojo.widget.Editor2Plugin.GenericContextMenu",
+dojo.declare("dojo.widget.Editor2Plugin.GenericContextMenu",
dojo.widget.Editor2Plugin.SimpleContextMenu,
{
createItems: function(){
@@ -199,7 +202,7 @@
this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Paste", iconClass: "dojoE2TBIcon dojoE2TBIcon_Paste"}));
}
});
-dojo.declare("dojo.widget.Editor2Plugin.LinkContextMenu",
+dojo.declare("dojo.widget.Editor2Plugin.LinkContextMenu",
dojo.widget.Editor2Plugin.SimpleContextMenu,
{
createItems: function(){
@@ -222,7 +225,7 @@
return show;
}
});
-dojo.declare("dojo.widget.Editor2Plugin.ImageContextMenu",
+dojo.declare("dojo.widget.Editor2Plugin.ImageContextMenu",
dojo.widget.Editor2Plugin.SimpleContextMenu,
{
createItems: function(){
@@ -240,4 +243,4 @@
return false;
}
}
-});
+});
\ No newline at end of file
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/SimpleSignalCommands.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/SimpleSignalCommands.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/SimpleSignalCommands.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/SimpleSignalCommands.js Sat Oct 7 11:22:33 2006
@@ -9,11 +9,11 @@
*/
/*
- * This plugin adds save() and insertImage() to Editor2 widget, and add two commands for each
- * of them. When the corresponding button is clicked in the toolbar, the added function in the
+ * 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
+ * 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)
@@ -27,7 +27,7 @@
dojo.require("dojo.widget.Editor2");
-dojo.declare("dojo.widget.Editor2Plugin.SimpleSignalCommand", dojo.widget.Editor2Command,
+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); };
@@ -58,7 +58,7 @@
},
registerAllSignalCommands: function(){
for(var i=0;i<this.signals.length;i++){
- dojo.widget.Editor2Manager.registerCommand(this.signals[i],
+ dojo.widget.Editor2Manager.registerCommand(this.signals[i],
new dojo.widget.Editor2Plugin.SimpleSignalCommand(this.signals[i]));
}
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/TableOperation.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/TableOperation.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/TableOperation.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Plugin/TableOperation.js Sat Oct 7 11:22:33 2006
@@ -14,10 +14,10 @@
//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
+//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.moz && false){
//include the css file to show table border when border=0
editor.__TableOperationShowBorder = true;
@@ -32,20 +32,22 @@
// 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.widget.Editor2Plugin.TableOperation.toggleTableBorderCommand.execute(editor);
+ 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){
@@ -111,8 +113,8 @@
//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",
+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"}));
@@ -125,7 +127,7 @@
if(dojo.widget.Editor2Plugin.ContextMenuManager){
dojo.widget.Editor2Plugin.ContextMenuManager.registerGroup('Table', dojo.widget.Editor2Plugin.TableOperation.getContextMenuGroup);
- dojo.declare("dojo.widget.Editor2Plugin.TableContextMenu",
+ dojo.declare("dojo.widget.Editor2Plugin.TableContextMenu",
dojo.widget.Editor2Plugin.SimpleContextMenu,
{
createItems: function(){
@@ -135,7 +137,7 @@
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();
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Toolbar.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Toolbar.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Toolbar.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Editor2Toolbar.js Sat Oct 7 11:22:33 2006
@@ -19,10 +19,19 @@
dojo.require("dojo.widget.PopupContainer");
dojo.require("dojo.widget.ColorPalette");
+// Object: Manager available editor2 toolbar items
dojo.widget.Editor2ToolbarItemManager = {
_registeredItemHandlers: [],
- registerHandler: function(obj, func){
- if(arguments.length == 1){
+ 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");
@@ -30,11 +39,10 @@
// }
// }
this._registeredItemHandlers.push(obj);
- }else{
- this._registeredItemHandlers.push(function(){return obj[func].apply(obj, arguments);});
}
},
removeHandler: function(func){
+ // summary: remove a registered handler
for(var i in this._registeredItemHandlers){
if(func === this._registeredItemHandlers[i]){
delete this._registeredItemHandlers[i];
@@ -48,7 +56,8 @@
delete this._registeredItemHandlers[i];
}
},
- getToolbarItem: function(name){
+ getToolbarItem: function(/*String*/name){
+ // summary: return a toobar item with the given name
var item;
name = name.toLowerCase();
for(var i in this._registeredItemHandlers){
@@ -72,7 +81,7 @@
case 'italic':
case 'justifycenter':
case 'justifyfull':
- case 'justifyleft':
+ case 'justifyleft':
case 'justifyright':
case 'outdent':
case 'paste':
@@ -83,7 +92,7 @@
case 'subscript':
case 'superscript':
case 'underline':
- case 'undo':
+ case 'undo':
case 'unlink':
case 'createlink':
case 'insertimage':
@@ -91,7 +100,7 @@
case 'htmltoggle':
item = new dojo.widget.Editor2ToolbarButton(name);
break;
- case 'forecolor':
+ case 'forecolor':
case 'hilitecolor':
item = new dojo.widget.Editor2ToolbarColorPaletteButton(name);
break;
@@ -137,13 +146,19 @@
};
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(node, toolbar, isMenu){
+ 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
@@ -151,12 +166,13 @@
this.disableSelection(this._domNode);
this._parentToolbar = toolbar;
dojo.event.connect(this._domNode, 'onclick', this, 'onClick');
- if(!isMenu){
+ if(!nohover){
dojo.event.connect(this._domNode, 'onmouseover', this, 'onMouseOver');
dojo.event.connect(this._domNode, 'onmouseout', this, 'onMouseOut');
}
},
- disableSelection: function(rootnode){
+ 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++){
@@ -172,6 +188,7 @@
this.unhighlightToolbarItem();
},
destroy: function(){
+ // summary: destructor
this._domNode = null;
delete this._command;
this._parentToolbar = null;
@@ -184,6 +201,7 @@
}
},
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();
@@ -239,6 +257,7 @@
}
});
+// 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){
@@ -249,7 +268,7 @@
if(this._dropdown.isShowingNow){
this._dropdown.close();
}else{
- this.onDropDownShown();
+ this.onDropDownShown();
this._dropdown.open(this._domNode, null, this._domNode);
}
}
@@ -265,6 +284,7 @@
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){
@@ -288,6 +308,7 @@
}
});
+// 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
@@ -324,6 +345,7 @@
}
});
+// summary: dojo.widget.Editor2ToolbarComboItem provides an external loaded dropdown list
dojo.declare("dojo.widget.Editor2ToolbarComboItem", dojo.widget.Editor2ToolbarDropDownButton,{
href: null,
create: function(node, toolbar){
@@ -351,8 +373,9 @@
}
},
- //overload this to connect event
- setup: function(){},
+ setup: function(){
+ // summary: overload this to connect event
+ },
onChange: function(e){
var name = e.currentTarget.getAttribute("dropDownItemName");
@@ -368,10 +391,12 @@
dojo.html.removeClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectItemStyle);
},
- //overload this to update GUI item
- refreshState: function(){}
+ 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"),
@@ -433,6 +458,7 @@
}
});
+// 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"),
@@ -493,10 +519,13 @@
}
});
+// 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,
@@ -505,13 +534,19 @@
templateCssPath: dojo.uri.dojoUri("src/widget/templates/EditorToolbar.css"),
// DOM Nodes
- saveButton: null,
+// 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
@@ -537,6 +572,7 @@
},
update: function(){
+ // summary: update all the toolbar items
for(var cmd in this.items){
this.items[cmd].refreshState();
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FisheyeList.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FisheyeList.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FisheyeList.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FisheyeList.js Sat Oct 7 11:22:33 2006
@@ -24,64 +24,109 @@
dojo.require("dojo.html.util");
dojo.require("dojo.event.*");
+/*
+ * summary
+ * Menu similar to the fish eye menu on the Mac OS
+ * usage
+ * <div dojoType="FisheyeList"
+ * itemWidth="40" itemHeight="40"
+ * itemMaxWidth="150" itemMaxHeight="150"
+ * orientation="horizontal"
+ * effectUnits="2"
+ * itemPadding="10"
+ * attachEdge="center"
+ * labelEdge="bottom">
+ *
+ * <div dojoType="FisheyeListItem"
+ * id="item1"
+ * onclick="alert('click on' + this.caption + '(from widget id ' + this.widgetId + ')!');"
+ * caption="Item 1"
+ * iconsrc="images/fisheye_1.png">
+ * </div>
+ * ...
+ * </div>
+ */
dojo.widget.defineWidget(
"dojo.widget.FisheyeList",
dojo.widget.HtmlWidget,
-{
- templateString: '<div class="dojoHtmlFisheyeListBar"></div>',
- templateCssPath: dojo.uri.dojoUri("src/widget/templates/FisheyeList.css"),
+function(){
+ this.pos = {x: -1, y: -1}; // current cursor position, relative to the grid
- EDGE: {
+ this.EDGE = {
CENTER: 0,
LEFT: 1,
RIGHT: 2,
TOP: 3,
BOTTOM: 4
- },
-
- isContainer: true,
- snarfChildDomOutput: true,
-
- pos: {x: -1, y: -1}, // current cursor position, relative to the grid
+ };
// for conservative trigger mode, when triggered, timerScale is gradually increased from 0 to 1
- timerScale: 1.0,
+ this.timerScale = 1.0;
- /////////////////////////////////////////////////////////////////
- //
- // i spy OPTIONS!!!!
- //
+},
+{
+ templateString: '<div class="dojoHtmlFisheyeListBar"></div>',
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/FisheyeList.css"),
+ isContainer: true,
+ snarfChildDomOutput: true,
+
+ // Integer
+ // width of menu item (in pixels) in it's dormant state (when the mouse is far away)
itemWidth: 40,
+
+ // Integer
+ // height of menu item (in pixels) in it's dormant state (when the mouse is far away)
itemHeight: 40,
+ // Integer
+ // width of menu item (in pixels) in it's fully enlarged state (when the mouse is directly over it)
itemMaxWidth: 150,
+
+ // Integer
+ // height of menu item (in pixels) in it's fully enlarged state (when the mouse is directly over it)
itemMaxHeight: 150,
+
+ // String
+ // orientation of the menu, either "horizontal" or "vertical"
orientation: 'horizontal',
-
- conservativeTrigger: false, // don't active menu until mouse is over an image (macintosh style)
+ // Boolean
+ // if true, don't start enlarging menu items until mouse is over an image;
+ // if false, start enlarging menu items as the mouse moves near them.
+ conservativeTrigger: false,
+
+ // Number
+ // controls how much reaction the menu makes, relative to the distance of the mouse from the menu
effectUnits: 2,
+
+ // Integer
+ // padding (in pixels) betweeen each menu item
itemPadding: 10,
+ // String
+ // controls the border that the menu items don't expand past;
+ // for example, if set to "top", then the menu items will drop downwards as they expand.
+ // values
+ // "center", "left", "right", "top", "bottom".
attachEdge: 'center',
+
+ // String
+ // controls were the labels show up in relation to the menu item icons
+ // values
+ // "center", "left", "right", "top", "bottom".
labelEdge: 'bottom',
+ // Boolean
+ // for browsers that support svg, use the svg image (specified in FisheyeListIem.svgSrc)
+ // rather than the iconSrc image attribute
enableCrappySvgSupport: false,
-
- //
- //
- //
- /////////////////////////////////////////////////////////////////
-
- fillInTemplate: function(args, frag) {
- //dojo.debug(this.orientation);
-
+ fillInTemplate: function() {
dojo.html.disableSelection(this.domNode);
- this.isHorizontal = (this.orientation == 'horizontal') ? 1 : 0;
+ this.isHorizontal = (this.orientation == 'horizontal');
this.selectedNode = -1;
this.isOver = false;
@@ -93,9 +138,8 @@
//
// only some edges make sense...
//
-
- this.anchorEdge = this.toEdge(this.attachEdge, this.EDGE.CENTER);
- this.labelEdge = this.toEdge(this.labelEdge, this.EDGE.TOP);
+ this.anchorEdge = this._toEdge(this.attachEdge, this.EDGE.CENTER);
+ this.labelEdge = this._toEdge(this.labelEdge, this.EDGE.TOP);
if ( this.isHorizontal && (this.anchorEdge == this.EDGE.LEFT )){ this.anchorEdge = this.EDGE.CENTER; }
if ( this.isHorizontal && (this.anchorEdge == this.EDGE.RIGHT )){ this.anchorEdge = this.EDGE.CENTER; }
@@ -108,11 +152,9 @@
if (!this.isHorizontal && (this.labelEdge == this.EDGE.TOP )){ this.labelEdge = this.EDGE.LEFT; }
if (!this.isHorizontal && (this.labelEdge == this.EDGE.BOTTOM)){ this.labelEdge = this.EDGE.LEFT; }
-
//
// figure out the proximity size
//
-
this.proximityLeft = this.itemWidth * (this.effectUnits - 0.5);
this.proximityRight = this.itemWidth * (this.effectUnits - 0.5);
this.proximityTop = this.itemHeight * (this.effectUnits - 0.5);
@@ -138,22 +180,22 @@
}
},
- postCreate: function(args, frag) {
- this.initializePositioning();
+ postCreate: function() {
+ this._initializePositioning();
//
// in liberal trigger mode, activate menu whenever mouse is close
//
if( !this.conservativeTrigger ){
- dojo.event.connect(document.documentElement, "onmousemove", this, "mouseHandler");
+ dojo.event.connect(document.documentElement, "onmousemove", this, "_onMouseMove");
}
// Deactivate the menu if mouse is moved off screen (doesn't work for FF?)
- dojo.event.connect(document.documentElement, "onmouseout", this, "onBodyOut");
- dojo.event.connect(this, "addChild", this, "initializePositioning");
+ dojo.event.connect(document.documentElement, "onmouseout", this, "_onBodyOut");
+ dojo.event.connect(this, "addChild", this, "_initializePositioning");
},
- initializePositioning: function(){
+ _initializePositioning: function(){
this.itemCount = this.children.length;
this.barWidth = (this.isHorizontal ? this.itemCount : 1) * this.itemWidth;
@@ -165,7 +207,6 @@
//
// calculate effect ranges for each item
//
-
for (var i=0; i<this.children.length; i++){
this.children[i].posX = this.itemWidth * (this.isHorizontal ? i : 0);
@@ -193,15 +234,12 @@
//dojo.debug('effect range for '+i+' is '+range_lhs+'/'+range_rhs);
}
-
//
// create the bar
//
-
this.domNode.style.width = this.barWidth + 'px';
this.domNode.style.height = this.barHeight + 'px';
-
//
// position the items
//
@@ -233,76 +271,78 @@
//
// calc the grid
//
-
- this.calcHitGrid();
+ this._calcHitGrid();
},
- onBodyOut: function(e){
+ _onBodyOut: function(/*Event*/ e){
// clicking over an object inside of body causes this event to fire; ignore that case
if( dojo.html.overElement(dojo.body(), e) ){
return;
}
- this.setDormant(e);
+ this._setDormant(e);
},
- // when mouse moves out of menu's range
- setDormant: function(e){
+ _setDormant: function(/*Event*/ e){
+ // summary: called when mouse moves out of menu's range
+
if( !this.isOver ){ return; } // already dormant?
this.isOver = false;
if ( this.conservativeTrigger ) {
// user can't re-trigger the menu expansion
// until he mouses over a icon again
- dojo.event.disconnect(document.documentElement, "onmousemove", this, "mouseHandler");
+ dojo.event.disconnect(document.documentElement, "onmousemove", this, "_onMouseMove");
}
- this.onGridMouseMove(-1, -1);
+ this._onGridMouseMove(-1, -1);
},
- // when mouse is moved into menu's range
- setActive: function(e){
+ _setActive: function(/*Event*/ e){
+ // summary: called when mouse is moved into menu's range
+
if( this.isOver ){ return; } // already activated?
this.isOver = true;
if ( this.conservativeTrigger ) {
// switch event handlers so that we handle mouse events from anywhere near
// the menu
- dojo.event.connect(document.documentElement, "onmousemove", this, "mouseHandler");
+ dojo.event.connect(document.documentElement, "onmousemove", this, "_onMouseMove");
this.timerScale=0.0;
// call mouse handler to do some initial necessary calculations/positioning
- this.mouseHandler(e);
+ this._onMouseMove(e);
// slowly expand the icon size so it isn't jumpy
- this.expandSlowly();
+ this._expandSlowly();
}
},
- // when mouse is moved
- mouseHandler: function(e) {
+ _onMouseMove: function(/*Event*/ e) {
+ // summary: called when mouse is moved
if ((e.pageX >= this.hitX1) && (e.pageX <= this.hitX2) &&
(e.pageY >= this.hitY1) && (e.pageY <= this.hitY2)){
if( !this.isOver ){
- this.setActive(e);
+ this._setActive(e);
}
- this.onGridMouseMove(e.pageX-this.hitX1, e.pageY-this.hitY1);
+ this._onGridMouseMove(e.pageX-this.hitX1, e.pageY-this.hitY1);
}else{
if (this.isOver){
- this.setDormant(e);
+ this._setDormant(e);
}
}
},
onResized: function() {
- this.calcHitGrid();
+ this._calcHitGrid();
},
- onGridMouseMove: function(x, y){
+ _onGridMouseMove: function(x, y){
+ // summary: called when mouse is moved in the vicinity of the menu
this.pos = {x:x, y:y};
- this.paint();
+ this._paint();
},
- paint: function(){
+ _paint: function(){
var x=this.pos.x;
var y=this.pos.y;
@@ -311,7 +351,6 @@
//
// figure out our main index
//
-
var pos = this.isHorizontal ? x : y;
var prx = this.isHorizontal ? this.proximityLeft : this.proximityTop;
var siz = this.isHorizontal ? this.itemWidth : this.itemHeight;
@@ -324,11 +363,9 @@
if (max_off_cen > this.effectUnits){ max_off_cen = this.effectUnits; }
-
//
// figure out our off-axis weighting
//
-
var off_weight = 0;
if (this.anchorEdge == this.EDGE.BOTTOM){
@@ -348,7 +385,6 @@
off_weight = (cen2 < 0.5) ? 1 : (this.totalWidth - x) / (this.proximityRight + (this.itemWidth / 2));
}
if (this.anchorEdge == this.EDGE.CENTER){
-
if (this.isHorizontal){
off_weight = y / (this.totalHeight);
}else{
@@ -362,18 +398,13 @@
off_weight *= 2;
}
-
//
// set the sizes
//
-
for(var i=0; i<this.itemCount; i++){
-
- var weight = this.weightAt(cen, i);
-
+ var weight = this._weighAt(cen, i);
if (weight < 0){weight = 0;}
-
- this.setitemsize(i, weight * off_weight);
+ this._setItemSize(i, weight * off_weight);
}
//
@@ -395,40 +426,16 @@
offset = (cen - main_p) * ((this.isHorizontal ? this.itemWidth : this.itemHeight) - this.children[main_p].sizeMain);
}
- this.positionElementsFrom(main_p, offset);
+ this._positionElementsFrom(main_p, offset);
},
- weightAt: function(cen, i){
-
+ _weighAt: function(/*Integer*/ cen, /*Integer*/ i){
var dist = Math.abs(cen - i);
-
var limit = ((cen - i) > 0) ? this.children[i].effectRangeRght : this.children[i].effectRangeLeft;
-
- return (dist > limit) ? 0 : (1 - dist / limit);
- },
-
- positionFromNode: function(p, w){
-
- //
- // we need to grow all the nodes growing out from node 'i'
- //
-
- this.setitemsize(p, w);
-
- var wx = w;
- for(var i=p; i<this.itemCount; i++){
- wx = 0.8 * wx;
- this.setitemsize(i, wx);
- }
-
- var wx = w;
- for(var i=p; i>=0; i--){
- wx = 0.8 * wx;
- this.setitemsize(i, wx);
- }
+ return (dist > limit) ? 0 : (1 - dist / limit); // Integer
},
- setitemsize: function(p, scale){
+ _setItemSize: function(p, scale){
scale *= this.timerScale;
var w = Math.round(this.itemWidth + ((this.itemMaxWidth - this.itemWidth ) * scale));
var h = Math.round(this.itemHeight + ((this.itemMaxHeight - this.itemHeight) * scale));
@@ -442,24 +449,16 @@
this.children[p].sizeOff = h;
var y = 0;
-
if (this.anchorEdge == this.EDGE.TOP){
-
y = (this.children[p].cenY - (this.itemHeight / 2));
-
}else if (this.anchorEdge == this.EDGE.BOTTOM){
-
y = (this.children[p].cenY - (h - (this.itemHeight / 2)));
-
}else{
-
y = (this.children[p].cenY - (h / 2));
}
this.children[p].usualX = Math.round(this.children[p].cenX - (w / 2));
-
this.children[p].domNode.style.top = y + 'px';
-
this.children[p].domNode.style.left = this.children[p].usualX + 'px';
}else{
@@ -471,16 +470,11 @@
this.children[p].sizeMain = h;
var x = 0;
-
if (this.anchorEdge == this.EDGE.LEFT){
-
x = this.children[p].cenX - (this.itemWidth / 2);
-
}else if (this.anchorEdge == this.EDGE.RIGHT){
-
x = this.children[p].cenX - (w - (this.itemWidth / 2));
}else{
-
x = this.children[p].cenX - (w / 2);
}
@@ -498,7 +492,7 @@
}
},
- positionElementsFrom: function(p, offset){
+ _positionElementsFrom: function(p, offset){
var pos = 0;
@@ -509,17 +503,14 @@
pos = Math.round(this.children[p].usualY + offset);
this.children[p].domNode.style.top = pos + 'px';
}
- this.positionLabel(this.children[p]);
+ this._positionLabel(this.children[p]);
//
// position before
//
-
var bpos = pos;
-
for(var i=p-1; i>=0; i--){
-
bpos -= this.children[i].sizeMain;
if (this.isHorizontal){
@@ -527,17 +518,14 @@
}else{
this.children[i].domNode.style.top = bpos + 'px';
}
- this.positionLabel(this.children[i]);
+ this._positionLabel(this.children[i]);
}
//
// position after
//
-
var apos = pos;
-
for(var i=p+1; i<this.itemCount; i++){
-
apos += this.children[i-1].sizeMain;
if (this.isHorizontal){
@@ -545,12 +533,12 @@
}else{
this.children[i].domNode.style.top = apos + 'px';
}
- this.positionLabel(this.children[i]);
+ this._positionLabel(this.children[i]);
}
},
- positionLabel: function(itm){
+ _positionLabel: function(itm){
var x = 0;
var y = 0;
@@ -581,7 +569,7 @@
itm.lblNode.style.top = y + 'px';
},
- calcHitGrid: function(){
+ _calcHitGrid: function(){
var pos = dojo.html.getAbsolutePosition(this.domNode, true);
@@ -593,40 +581,54 @@
//dojo.debug(this.hitX1+','+this.hitY1+' // '+this.hitX2+','+this.hitY2);
},
- toEdge: function(inp, def){
+ _toEdge: function(inp, def){
return this.EDGE[inp.toUpperCase()] || def;
},
- // slowly expand the image to user specified max size
- expandSlowly: function(){
+ _expandSlowly: function(){
+ // summary: slowly expand the image to user specified max size
if( !this.isOver ){ return; }
this.timerScale += 0.2;
- this.paint();
+ this._paint();
if ( this.timerScale<1.0 ) {
- dojo.lang.setTimeout(this, "expandSlowly", 10);
+ dojo.lang.setTimeout(this, "_expandSlowly", 10);
}
},
destroy: function(){
// need to disconnect when we destroy
- dojo.event.disconnect(document.documentElement, "onmouseout", this, "onBodyOut");
- dojo.event.disconnect(document.documentElement, "onmousemove", this, "mouseHandler");
+ dojo.event.disconnect(document.documentElement, "onmouseout", this, "_onBodyOut");
+ dojo.event.disconnect(document.documentElement, "onmousemove", this, "_onMouseMove");
dojo.widget.FisheyeList.superclass.destroy.call(this);
}
});
+/*
+ * summary
+ * Menu item inside of a FisheyeList.
+ * See FisheyeList documentation for details on usage.
+ */
dojo.widget.defineWidget(
"dojo.widget.FisheyeListItem",
dojo.widget.HtmlWidget,
{
- // Constructor arguments
+ // String
+ // pathname to image file (jpg, gif, png, etc.) of icon for this menu item
iconSrc: "",
+
+ // String
+ // pathname to svg file of icon for this menu item
svgSrc: "",
+
+ // String
+ // label to print next to the icon, when it is moused-over
caption: "",
- // will be set to the id of the orginal div element
+
+ // String
+ // will be set to the id of the orginal div element
id: "",
- blankImgPath: dojo.uri.dojoUri("src/widget/templates/images/blank.gif"),
+ _blankImgPath: dojo.uri.dojoUri("src/widget/templates/images/blank.gif"),
templateString:
'<div class="dojoHtmlFisheyeListItem">' +
@@ -634,8 +636,6 @@
' <div class="dojoHtmlFisheyeListItemLabel" dojoAttachPoint="lblNode"></div>' +
'</div>',
- imgNode: null,
-
fillInTemplate: function() {
//
// set image
@@ -643,7 +643,7 @@
// this.parent.enableCrappySvgSupport is not available to this function
//
if (this.svgSrc != ""){
- this.svgNode = this.createSvgNode(this.svgSrc);
+ this.svgNode = this._createSvgNode(this.svgSrc);
this.domNode.appendChild(this.svgNode);
this.imgNode.style.display = 'none';
} else if((this.iconSrc.toLowerCase().substring(this.iconSrc.length-4)==".png")&&(dojo.render.html.ie)&&(!dojo.render.html.ie70)){
@@ -653,7 +653,7 @@
parent.setAttribute("id", this.id);
}
this.imgNode.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.iconSrc+"', sizingMethod='scale')";
- this.imgNode.src = this.blankImgPath.toString();
+ this.imgNode.src = this._blankImgPath.toString();
} else {
if (dojo.dom.hasParent(this.imgNode) && this.id != ""){
var parent = this.imgNode.parentNode;
@@ -671,8 +671,7 @@
dojo.html.disableSelection(this.domNode);
},
- createSvgNode: function(src){
-
+ _createSvgNode: function(src){
var elm = document.createElement('embed');
elm.src = src;
elm.type = 'image/svg+xml';
@@ -720,22 +719,25 @@
return elm;
},
- onMouseOver: function(e) {
+ onMouseOver: function(/*Event*/ e) {
+ // summary: callback when user moves mouse over this menu item
// in conservative mode, don't activate the menu until user mouses over an icon
if( !this.parent.isOver ){
- this.parent.setActive(e);
+ this.parent._setActive(e);
}
if ( this.caption != "" ) {
dojo.html.addClass(this.lblNode, "selected");
- this.parent.positionLabel(this);
+ this.parent._positionLabel(this);
}
},
- onMouseOut: function() {
+ onMouseOut: function(/*Event*/ e) {
+ // summary: callback when user moves mouse off of this menu item
dojo.html.removeClass(this.lblNode, "selected");
},
- onClick: function() {
+ onClick: function(/*Event*/ e) {
+ // summary: user overridable callback when user clicks this menu item
}
});
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FloatingPane.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FloatingPane.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FloatingPane.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FloatingPane.js Sat Oct 7 11:22:33 2006
@@ -10,10 +10,6 @@
dojo.provide("dojo.widget.FloatingPane");
-//
-// this widget provides a window-like floating pane
-//
-
dojo.require("dojo.widget.*");
dojo.require("dojo.widget.Manager");
dojo.require("dojo.html.*");
@@ -24,37 +20,75 @@
dojo.require("dojo.widget.html.layout");
dojo.require("dojo.widget.ContentPane");
dojo.require("dojo.dnd.HtmlDragMove");
-dojo.require("dojo.dnd.HtmlDragMoveSource");
-dojo.require("dojo.dnd.HtmlDragMoveObject");
+dojo.require("dojo.widget.Dialog"); // for ModalFloatingPane
dojo.require("dojo.widget.ResizeHandle");
+// summary
+// Base class for FloatingPane, ModalFloatingPane
dojo.declare(
"dojo.widget.FloatingPaneBase",
null,
{
- // Constructor arguments
+ // String
+ // text to display in floating pane's title bar (ex: "My Window")
title: '',
+
+ // String
+ // path of icon to display in floating pane's title bar
iconSrc: '',
+
+ // Boolean
+ // if true, display a shadow behind the floating pane
hasShadow: false,
+
+ // Boolean
+ // if true, and the floating pane is inside another container (ContentPane, another FloatingPane, etc.),
+ // then don't allow the floating pane to be dragged outside of it's container
constrainToContainer: false,
+
+ // String
+ // widget id of TaskBar widget;
+ // if specified, then an icon for this FloatingPane will be added to the specified TaskBar
taskBarId: "",
+
+ // Boolean
+ // if true, allow user to resize floating pane
resizable: true,
- titleBarDisplay: "fancy",
-
+
+ // Boolean
+ // if true, display title bar for this floating pane
+ titleBarDisplay: true,
+
+ // String
+ // control whether window is initially not displayed ("minimized"), displayed full screen ("maximized"),
+ // or just displayed normally ("normal")
+ // Values
+ // "normal", "maximized", "minimized"
windowState: "normal",
+
+ // Boolean
+ // display button to close window
displayCloseAction: false,
+
+ // Boolean
+ // display button to minimize window (ie, window disappears so only the taskbar item remains)
displayMinimizeAction: false,
+
+ // Boolean
+ // display button to maximize window (ie, to take up the full screen)
displayMaximizeAction: false,
- maxTaskBarConnectAttempts: 5,
- taskBarConnectAttempts: 0,
+ // Related to connecting to taskbar
+ // TODO: use topics rather than repeated connect attempts?
+ _max_taskBarConnectAttempts: 5,
+ _taskBarConnectAttempts: 0,
templatePath: dojo.uri.dojoUri("src/widget/templates/FloatingPane.html"),
templateCssPath: dojo.uri.dojoUri("src/widget/templates/FloatingPane.css"),
- drag: null,
-
fillInFloatingPaneTemplate: function(args, frag){
+ // summary: this should be called by fillInTemplate() of the widget that I'm mixed into
+
// Copy style info from input node to output node
var source = this.getFragNodeRef(frag);
dojo.html.copyStyle(this.domNode, source);
@@ -74,7 +108,7 @@
this.titleBarIcon.src = this.iconSrc.toString();// dojo.uri.Uri obj req. toString()
}
- if(this.titleBarDisplay!="none"){
+ if(this.titleBarDisplay){
this.titleBar.style.display="";
dojo.html.disableSelection(this.titleBar);
@@ -119,7 +153,7 @@
this.bgIframe = new dojo.html.BackgroundIframe(this.domNode);
if( this.taskBarId ){
- this.taskBarSetup();
+ this._taskBarSetup();
}
// counteract body.appendChild above
@@ -128,13 +162,14 @@
postCreate: function(){
if (dojo.hostenv.post_load_) {
- this.setInitialWindowState();
+ this._setInitialWindowState();
} else {
- dojo.addOnLoad(this, "setInitialWindowState");
+ dojo.addOnLoad(this, "_setInitialWindowState");
}
},
- maximizeWindow: function(evt) {
+ maximizeWindow: function(/*Event*/ evt) {
+ // summary: maximize the window
var mb = dojo.html.getMarginBox(this.domNode);
this.previous={
width: mb.width || this.width,
@@ -177,7 +212,8 @@
this.windowState="maximized";
},
- minimizeWindow: function(evt) {
+ minimizeWindow: function(/*Event*/ evt) {
+ // summary: hide the window so that only the icon in the taskbar is shown
this.hide();
for(var attr in this.parentPrevious){
this.domNode.parentNode.style[attr] = this.parentPrevious[attr];
@@ -186,7 +222,8 @@
this.windowState = "minimized";
},
- restoreWindow: function(evt) {
+ restoreWindow: function(/*Event*/ evt) {
+ // summary: set the winow to normal size (neither maximized nor minimized)
if (this.windowState=="minimized") {
this.show();
if(this.lastWindowState == "maximized"){
@@ -220,6 +257,7 @@
},
toggleDisplay: function(){
+ // summary: switch between hidden mode and displayed mode (either maximized or normal, depending on state before window was minimized)
if(this.windowState=="minimized"){
this.restoreWindow();
}else{
@@ -227,16 +265,21 @@
}
},
- closeWindow: function(evt) {
+ closeWindow: function(/*Event*/ evt) {
+ // summary: destroy this window
dojo.html.removeNode(this.domNode);
this.destroy();
},
- onMouseDown: function(evt) {
+ onMouseDown: function(/*Event*/ evt) {
+ // summary: callback when user clicks anywhere on the floating pane
this.bringToTop();
},
bringToTop: function() {
+ // summary
+ // all the floating panes are stacked in z-index order; bring this floating pane to the top of that stack,
+ // so that it's displayed in front of all the other floating panes
var floatingPanes= dojo.widget.manager.getWidgetsByType(this.widgetType);
var windows = [];
for (var x=0; x<floatingPanes.length; x++) {
@@ -257,7 +300,7 @@
}
},
- setInitialWindowState: function() {
+ _setInitialWindowState: function() {
if(this.isShowing()){
this.width=-1; // force resize
var mb = dojo.html.getMarginBox(this.domNode);
@@ -282,13 +325,13 @@
this.windowState="minimized";
},
- // add icon to task bar, connected to me
- taskBarSetup: function() {
+ _taskBarSetup: function() {
+ // summary: add icon to task bar, connected to me
var taskbar = dojo.widget.getWidgetById(this.taskBarId);
if (!taskbar){
- if (this.taskBarConnectAttempts < this.maxTaskBarConnectAttempts) {
- dojo.lang.setTimeout(this, this.taskBarSetup, 50);
- this.taskBarConnectAttempts++;
+ if (this._taskBarConnectAttempts < this._max_taskBarConnectAttempts) {
+ dojo.lang.setTimeout(this, this._taskBarSetup, 50);
+ this._taskBarConnectAttempts++;
} else {
dojo.debug("Unable to connect to the taskBar");
}
@@ -298,17 +341,20 @@
},
showFloatingPane: function(){
+ // summary:
+ // bring this floating pane to the top
this.bringToTop();
},
onFloatingPaneShow: function(){
+ // summary: callback for when someone calls FloatingPane.show
var mb = dojo.html.getMarginBox(this.domNode);
this.resizeTo(mb.width, mb.height);
},
- // This is called when the user adjusts the size of the floating pane
- resizeTo: function(w, h){
- dojo.html.setMarginBox(this.domNode, { width: w, height: h });
+ // summary: set the floating pane to the given size
+ resizeTo: function(/*Integer*/ width, /*Integer*/ height){
+ dojo.html.setMarginBox(this.domNode, { width: width, height: height });
dojo.widget.html.layout(this.domNode,
[
@@ -321,19 +367,24 @@
dojo.widget.html.layout(this.containerNode, this.children, "top-bottom");
this.bgIframe.onResized();
- if(this.shadow){ this.shadow.size(w, h); }
+ if(this.shadow){ this.shadow.size(width, height); }
this.onResized();
},
checkSize: function() {
- // checkSize() is called when the user has resized the browser window,
- // but that doesn't affect this widget (or this widget's children)
- // so it can be safely ignored...
+ // summary
+ // checkSize() is called when the user has resized the browser window,
+ // but that doesn't affect this widget (or this widget's children)
+ // so it can be safely ignored...
// TODO: unless we are maximized. then we should resize ourself.
}
}
);
+// summary
+// A non-modal floating window.
+// Attaches to a Taskbar which has an icon for each window.
+// Must specify size (like style="width: 500px; height: 500px;"),
dojo.widget.defineWidget(
"dojo.widget.FloatingPane",
[dojo.widget.ContentPane, dojo.widget.FloatingPaneBase],
@@ -356,7 +407,11 @@
}
});
-dojo.require("dojo.widget.Dialog");
+
+// summary
+// A modal floating window.
+// This widget is similar to the Dialog widget, but the window, unlike the Dialog, can be moved.
+// Must specify size (like style="width: 500px; height: 500px;"),
dojo.widget.defineWidget(
"dojo.widget.ModalFloatingPane",
[dojo.widget.FloatingPane, dojo.widget.ModalDialogBase],
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FormContainer.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FormContainer.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FormContainer.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/FormContainer.js Sat Oct 7 11:22:33 2006
@@ -16,10 +16,43 @@
dojo.widget.defineWidget("dojo.widget.FormContainer", dojo.widget.HtmlWidget,
{
isContainer: true,
+ templateString: "<form dojoAttachPoint='containerNode' dojoAttachEvent='onSubmit:onSubmit'></form>",
+ formElements: [],
+
+ postCreate: function(args,frag){
+ for (var key in args) {
+ if (key == "dojotype") continue;
+ var attr= document.createAttribute(key);
+ attr.nodeValue=args[key];
+ this.containerNode.setAttributeNode(attr);
+ }
+ },
+ _createFormElements: function() {
+ if(dojo.render.html.safari) {
+ // bug in safari (not registering form-elements)
+ var elems = ["INPUT", "SELECT", "TEXTAREA"];
+ for (var k=0; k < elems.length; k++) {
+ var list = this.containerNode.getElementsByTagName(elems[k]);
+ for (var j=0,len2=list.length; j<len2; j++) {
+ this.formElements.push(list[j]);
+ }
+ }
+ // fixed in safari nightly
+ } else {
+ this.formElements=this.containerNode.elements;
+ }
+ },
+ onSubmit: function(e) {
+ e.preventDefault();
+ },
+
+ submit: function() {
+ this.containerNode.submit();
+ },
_getFormElement: function(name) {
- for(var i=0, len=this.domNode.elements.length; i<len; i++) {
- var element = this.domNode.elements[i];
+ for(var i=0, len=this.formElements.length; i<len; i++) {
+ var element = this.formElements[i];
if (element.name == name) {
return element;
} // if
@@ -45,11 +78,11 @@
_setToContainers: function (obj, widget) {
for(var i=0, len=widget.children.length; i<len; ++i) {
if (widget.children[i].widgetType == "RepeaterContainer") {
- var rIndex=widget.children[i].index;
+ var rIndex=widget.children[i].pattern;
var rIndexPos=rIndex.indexOf("%{index}");
rIndex=rIndex.substr(0,rIndexPos-1);
var myObj = this._getObject(obj, rIndex);
- if (typeof(myObj) == "object" && myObj.length == 0) {
+ if (typeof(myObj) == "object" && typeof(myObj.length) == "undefined") {
myObj=[];
}
var rowCount = widget.children[i].getRowCount();
@@ -103,8 +136,9 @@
}
},
setValues: function(obj) {
- for(var i=0, len=this.domNode.elements.length; i<len; i++) {
- var element = this.domNode.elements[i];
+ this._createFormElements();
+ for(var i=0, len=this.formElements.length; i<len; i++) {
+ var element = this.formElements[i];
if (element.name == '') {continue};
var namePath = new Array();
namePath=element.name.split(".");
@@ -130,7 +164,7 @@
}
switch(type) {
case "checkbox":
- this.domNode.elements[i].checked=false;
+ this.formElements[i].checked=false;
if (typeof(myObj[name]) == 'undefined') continue;
for (var j=0,len2=myObj[name].length; j<len2; ++j) {
if(element.value == myObj[name][j]) {
@@ -139,14 +173,14 @@
}
break;
case "radio":
- this.domNode.elements[i].checked=false;
+ this.formElements[i].checked=false;
if (typeof(myObj[name]) == 'undefined') {continue};
- if (myObj[name] == this.domNode.elements[i].value) {
- this.domNode.elements[i].checked=true;
+ if (myObj[name] == this.formElements[i].value) {
+ this.formElements[i].checked=true;
}
break;
case "select-one":
- this.domNode.elements[i].selectedIndex="0";
+ this.formElements[i].selectedIndex="0";
for (var j=0,len2=element.options.length; j<len2; ++j) {
if (element.options[j].value == myObj[name]) {
element.options[j].selected=true;
@@ -160,21 +194,22 @@
if (typeof(myObj[name]) == 'string') {
value = myObj[name];
}
- this.domNode.elements[i].value=value;
+ this.formElements[i].value=value;
break;
default:
//dojo.debug("Not supported type ("+type+")");
break;
}
- }
+ }
this._setToContainers(obj,this);
},
getValues: function() {
+ this._createFormElements();
var obj = { };
- for(var i=0,len=this.domNode.elements.length; i<len; i++) {
+ for(var i=0,len=this.formElements.length; i<len; i++) {
// FIXME: would be better to give it an attachPoint:
- var elm = this.domNode.elements[i];
+ var elm = this.formElements[i];
var namePath = [];
if (elm.name == '') { continue;}
namePath=elm.name.split(".");
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/InlineEditBox.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/InlineEditBox.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/InlineEditBox.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/InlineEditBox.js Sat Oct 7 11:22:33 2006
@@ -103,7 +103,7 @@
// Hide the text and display the form instead.
beginEdit: function(e){
if(this.editing || !this.isEnabled){ return; }
- this.mouseout();
+ this.onMouseOut();
this.editing = true;
// setup the form's <input> or <textarea> field, as specified by mode
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/LayoutContainer.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/LayoutContainer.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/LayoutContainer.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/LayoutContainer.js Sat Oct 7 11:22:33 2006
@@ -8,21 +8,55 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-//
-// this widget provides Delphi-style panel layout semantics
-//
-
dojo.provide("dojo.widget.LayoutContainer");
dojo.require("dojo.widget.*");
dojo.require("dojo.widget.html.layout");
+// summary
+// Provides Delphi-style panel layout semantics.
+//
+// details
+// A LayoutContainer is a box with a specified size (like style="width: 500px; height: 500px;"),
+// that contains children widgets marked with "layoutAlign" of "left", "right", "bottom", "top", and "client".
+// It takes it's children marked as left/top/bottom/right, and lays them out along the edges of the box,
+// and then it takes the child marked "client" and puts it into the remaining space in the middle.
+//
+// Left/right positioning is similar to CSS's "float: left" and "float: right",
+// and top/bottom positioning would be similar to "float: top" and "float: bottom", if there were such
+// CSS.
+//
+// Note that there can only be one client element, but there can be multiple left, right, top,
+// or bottom elements.
+//
+// usage
+// <style>
+// html, body{ height: 100%; width: 100%; }
+// </style>
+// <div dojoType="LayoutContainer" style="width: 100%; height: 100%">
+// <div dojoType="ContentPane" layoutAlign="top">header text</div>
+// <div dojoType="ContentPane" layoutAlign="left" style="width: 200px;">table of contents</div>
+// <div dojoType="ContentPane" layoutAlign="client">client area</div>
+// </div>
dojo.widget.defineWidget(
"dojo.widget.LayoutContainer",
dojo.widget.HtmlWidget,
{
isContainer: true,
+ // String
+ // - If the value is "top-bottom", then LayoutContainer will first position the "top" and "bottom" aligned elements,
+ // to and then put the left and right aligned elements in the remaining space, between the top and the bottom elements.
+ // It aligns the client element at the very end, in the remaining space.
+ //
+ // - If the value is "left-right", then it first positions the "left" and "right" elements, and then puts the
+ // "top" and "bottom" elements in the remaining space, between the left and the right elements.
+ // It aligns the client element at the very end, in the remaining space.
+ //
+ // - If the value is "none", then it will lay out each child in the natural order the children occur in.
+ // Basically each child is laid out into the "remaining space", where "remaining space" is initially
+ // the content area of this widget, but is reduced to a smaller rectangle each time a child is added.
+ //
layoutChildPriority: 'top-bottom',
postCreate: function(){
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/LinkPane.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/LinkPane.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/LinkPane.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/LinkPane.js Sat Oct 7 11:22:33 2006
@@ -8,17 +8,18 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-//
-// a div that loads from a URL. (Similar to an iframe, but
-// it's in the same environment as the main window)
-//
-
dojo.provide("dojo.widget.LinkPane");
dojo.require("dojo.widget.*");
dojo.require("dojo.widget.ContentPane");
dojo.require("dojo.html.style");
+// summary
+// LinkPane is just a ContentPane that loads data remotely (via the href attribute),
+// and has markup similar to an anchor. The anchor's body (the words between <a> and </a>)
+// become the label of the widget (used for TabContainer, AccordionContainer, etc.)
+// usage
+// <a href="foo.html">my label</a>
dojo.widget.defineWidget(
"dojo.widget.LinkPane",
dojo.widget.ContentPane,
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Menu2.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Menu2.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Menu2.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Menu2.js Sat Oct 7 11:22:33 2006
@@ -461,6 +461,8 @@
},
openSubmenu: function(){
+ if (this.disabled){ return; }
+
// first close any other open submenu
this.parent.closeSubpopup();
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PageContainer.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PageContainer.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PageContainer.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PageContainer.js Sat Oct 7 11:22:33 2006
@@ -15,10 +15,10 @@
dojo.require("dojo.event.*");
dojo.require("dojo.html.selection");
-// A PageContainer is a container that has multiple panes, but shows only
-// one pane at a time.
+// A PageContainer is a container that has multiple children, but shows only
+// one child at a time (like looking at the pages in a book one by one).
//
-// Publishes topics <widgetId>-addPane, <widgetId>-removePane, and <widgetId>-selectPane
+// Publishes topics <widgetId>-addChild, <widgetId>-removeChild, and <widgetId>-selectChild
//
// Can be base class for container, Wizard, Show, etc.
dojo.widget.defineWidget("dojo.widget.PageContainer", dojo.widget.HtmlWidget, {
@@ -32,7 +32,7 @@
// String
// id of the initially shown page
- selectedPage: "",
+ selectedChild: "",
fillInTemplate: function(args, frag) {
// Copy style info from input node to output node
@@ -43,106 +43,104 @@
postCreate: function(args, frag) {
// Setup each page panel
- dojo.lang.forEach(this.children, this._setupPage, this);
+ dojo.lang.forEach(this.children, this._setupChild, this);
// Display the selected page
- if(this.selectedPageWidget){
- this.selectPage(this.selectedPageWidget, true);
+ if(this.selectedChildWidget){
+ this.selectChild(this.selectedChildWidget, true);
}
},
addChild: function(child){
- this._setupPage(child);
+ this._setupChild(child);
dojo.widget.PageContainer.superclass.addChild.apply(this, arguments);
// in case the page labels have overflowed from one line to two lines
this.onResized();
},
- _setupPage: function(page){
- // Summary: Add the given pane to this page container
+ _setupChild: function(page){
+ // Summary: Add the given child to this page container
page.domNode.style.display="none";
- if(!this.selectedPageWidget || this.selectedPage==page.widgetId || page.selected || (this.children.length==0)){
+ if(!this.selectedChildWidget || this.selectedChild==page.widgetId || page.selected || (this.children.length==0)){
// Deselect old page and select new one
- // We do this instead of calling selectPage in this case, because other wise other widgets
- // listening for addChild and selectPage can run into a race condition
- if(this.selectedPageWidget){
- this._hidePage(this.selectedPageWidget);
+ // We do this instead of calling selectChild in this case, because other wise other widgets
+ // listening for addChild and selectChild can run into a race condition
+ if(this.selectedChildWidget){
+ this._hideChild(this.selectedChildWidget);
}
- this.selectedPageWidget = page;
- this._showPage(page);
+ this.selectedChildWidget = page;
+ this._showChild(page);
} else {
- this._hidePage(page);
+ this._hideChild(page);
}
- dojo.html.addClass(page.domNode, "selected");
-
- // publish the addPane event for panes added via addChild(), and the original panes too
- dojo.event.topic.publish(this.widgetId+"-addPane", page);
+ // publish the addChild event for panes added via addChild(), and the original panes too
+ dojo.event.topic.publish(this.widgetId+"-addChild", page);
},
removeChild: function(/* Widget */page){
dojo.widget.PageContainer.superclass.removeChild.apply(this, arguments);
- // If we are being destroyed than don't the code below (to select another pane), because we are deleting
- // every pane one by one
+ // If we are being destroyed than don't run the code below (to select another page), because we are deleting
+ // every page one by one
if(this._beingDestroyed){ return; }
// this will notify any tablists to remove a button; do this first because it may affect sizing
- dojo.event.topic.publish(this.widgetId+"-removePane", page);
+ dojo.event.topic.publish(this.widgetId+"-removeChild", page);
- if (this.selectedPageWidget === page) {
- this.selectedPageWidget = undefined;
+ if (this.selectedChildWidget === page) {
+ this.selectedChildWidget = undefined;
if (this.children.length > 0) {
- this.selectPage(this.children[0], true);
+ this.selectChild(this.children[0], true);
}
}
},
- selectPage: function(/* Widget */ page, /* Boolean */ _noRefresh, /* Widget */ callingWidget){
+ selectChild: function(/* Widget */ page, /* Boolean */ _noRefresh, /* Widget */ callingWidget){
// summary
// Show the given widget (which must be one of my children)
page = dojo.widget.byId(page);
this.correspondingPageButton = callingWidget;
// Deselect old page and select new one
- if(this.selectedPageWidget){
- this._hidePage(this.selectedPageWidget);
+ if(this.selectedChildWidget){
+ this._hideChild(this.selectedChildWidget);
}
- this.selectedPageWidget = page;
- this._showPage(page, _noRefresh);
- page.isFirstPage = (page == this.children[0]);
- page.isLastPage = (page == this.children[this.children.length-1]);
- dojo.event.topic.publish(this.widgetId+"-selectPane", page);
+ this.selectedChildWidget = page;
+ this._showChild(page, _noRefresh);
+ page.isFirstChild = (page == this.children[0]);
+ page.isLastChild = (page == this.children[this.children.length-1]);
+ dojo.event.topic.publish(this.widgetId+"-selectChild", page);
},
- nextPage: function(){
+ forward: function(){
// Summary: advance to next page
- var index = dojo.lang.find(this.children, this.selectedPageWidget);
- this.selectPage(this.children[index+1]);
+ var index = dojo.lang.find(this.children, this.selectedChildWidget);
+ this.selectChild(this.children[index+1]);
},
- previousPage: function(){
+ back: function(){
// Summary: go back to previous page
- var index = dojo.lang.find(this.children, this.selectedPageWidget);
- this.selectPage(this.children[index-1]);
+ var index = dojo.lang.find(this.children, this.selectedChildWidget);
+ this.selectChild(this.children[index-1]);
},
onResized: function(){
// Summary: called when any page is shown, to make it fit the container correctly
- if(this.doLayout && this.selectedPageWidget){
- with(this.selectedPageWidget.domNode.style){
+ if(this.doLayout && this.selectedChildWidget){
+ with(this.selectedChildWidget.domNode.style){
top = dojo.html.getPixelValue(this.containerNode, "padding-top", true);
left = dojo.html.getPixelValue(this.containerNode, "padding-left", true);
}
var content = dojo.html.getContentBox(this.containerNode);
- this.selectedPageWidget.resizeTo(content.width, content.height);
+ this.selectedChildWidget.resizeTo(content.width, content.height);
}
},
- _showPage: function(page, _noRefresh) {
+ _showChild: function(page, _noRefresh) {
page.selected=true;
// size the current page (in case this is the first time it's being shown, or I have been resized)
@@ -163,12 +161,12 @@
}
},
- _hidePage: function(page) {
- page.selected=false;
+ _hideChild: function(page) {
+ page.x=false;
page.hide();
},
- closePage: function(page) {
+ closeChild: function(page) {
// summary
// callback when user clicks the [X] to remove a page
// if onClose() returns true then remove and destroy the childd
@@ -182,16 +180,16 @@
destroy: function(){
this._beingDestroyed = true;
- dojo.event.topic.destroy(this.widgetId+"-addPane");
- dojo.event.topic.destroy(this.widgetId+"-removePane");
- dojo.event.topic.destroy(this.widgetId+"-selectPane");
+ dojo.event.topic.destroy(this.widgetId+"-addChild");
+ dojo.event.topic.destroy(this.widgetId+"-removeChild");
+ dojo.event.topic.destroy(this.widgetId+"-selectChild");
dojo.widget.PageContainer.superclass.destroy.apply(this, arguments);
}
});
// PageController - set of buttons to select the page in a page list
-// When intialized, the PageController monitors the container, and whenever a pane is
+// When intialized, the PageController monitors the container, and whenever a page is
// added or deleted updates itself accordingly.
dojo.widget.defineWidget(
"dojo.widget.PageController",
@@ -223,74 +221,74 @@
// If children have already been added to the page container then create buttons for them
var container = dojo.widget.byId(this.containerId);
if(container){
- dojo.lang.forEach(container.children, this.onAddPage, this);
+ dojo.lang.forEach(container.children, this.onAddChild, this);
}
- dojo.event.topic.subscribe(this.containerId+"-addPane", this, "onAddPage");
- dojo.event.topic.subscribe(this.containerId+"-removePane", this, "onRemovePage");
- dojo.event.topic.subscribe(this.containerId+"-selectPane", this, "onSelectPage");
+ dojo.event.topic.subscribe(this.containerId+"-addChild", this, "onAddChild");
+ dojo.event.topic.subscribe(this.containerId+"-removeChild", this, "onRemoveChild");
+ dojo.event.topic.subscribe(this.containerId+"-selectChild", this, "onSelectChild");
},
destroy: function(){
- dojo.event.topic.unsubscribe(this.containerId+"-addPane", this, "onAddPage");
- dojo.event.topic.unsubscribe(this.containerId+"-removePane", this, "onRemovePage");
- dojo.event.topic.unsubscribe(this.containerId+"-selectPane", this, "onSelectPage");
+ dojo.event.topic.unsubscribe(this.containerId+"-addChild", this, "onAddChild");
+ dojo.event.topic.unsubscribe(this.containerId+"-removeChild", this, "onRemoveChild");
+ dojo.event.topic.unsubscribe(this.containerId+"-selectChild", this, "onSelectChild");
dojo.widget.PageController.superclass.destroy.apply(this, arguments);
},
- onAddPage: function(/* Widget */ pane){
+ onAddChild: function(/* Widget */ page){
// summary
- // Called whenever a pane is added to the container.
- // Create button corresponding to the pane.
+ // Called whenever a page is added to the container.
+ // Create button corresponding to the page.
var button = dojo.widget.createWidget(this.buttonWidget,
{
- label: pane.label,
- closable: pane.tabCloseButton
+ label: page.label,
+ closeButton: page.closable
});
this.addChild(button);
this.domNode.appendChild(button.domNode);
- this.pane2button[pane]=button;
- pane.tabButton = button; // this value might be overwritten if two tabs point to same container
+ this.pane2button[page]=button;
+ page.controlButton = button; // this value might be overwritten if two tabs point to same container
var _this = this;
- dojo.event.connect(button, "onClick", function(){ _this.onButtonClick(pane); });
- dojo.event.connect(button, "onCloseButtonClick", function(){ _this.onCloseButtonClick(pane); });
+ dojo.event.connect(button, "onClick", function(){ _this.onButtonClick(page); });
+ dojo.event.connect(button, "onCloseButtonClick", function(){ _this.onCloseButtonClick(page); });
},
- onRemovePage: function(/* Widget */ pane){
+ onRemoveChild: function(/* Widget */ page){
// summary
- // Called whenever a pane is removed from the container.
- // Remove the button corresponding to the pane.
- if(this.currentPane == pane){ this.currentPane = null; }
- var button = this.pane2button[pane];
+ // Called whenever a page is removed from the container.
+ // Remove the button corresponding to the page.
+ if(this._currentChild == page){ this._currentChild = null; }
+ var button = this.pane2button[page];
button.destroy();
- this.pane2button[pane] = null;
+ this.pane2button[page] = null;
},
- onSelectPage: function(/*Widget*/ page){
+ onSelectChild: function(/*Widget*/ page){
// Summary
- // Called when a page has been selected in the PageContainer, either by me or by someone another PageController
- if(this.currentPane){
- var oldButton=this.pane2button[this.currentPane];
+ // Called when a page has been selected in the PageContainer, either by me or by another PageController
+ if(this._currentChild){
+ var oldButton=this.pane2button[this._currentChild];
oldButton.clearSelected();
}
var newButton=this.pane2button[page];
newButton.setSelected();
- this.currentPane=page;
+ this._currentChild=page;
},
onButtonClick: function(/*Widget*/ page){
// summary
- // Called whenever one of my child buttons is pressed in an attempt to select a pane
+ // Called whenever one of my child buttons is pressed in an attempt to select a page
var container = dojo.widget.byId(this.containerId); // TODO: do this via topics?
- container.selectPage(page, false, this);
+ container.selectChild(page, false, this);
},
onCloseButtonClick: function(/*Widget*/ page){
// summary
- // Called whenever one of my child buttons [X] is pressed in an attempt to close a pane
+ // Called whenever one of my child buttons [X] is pressed in an attempt to close a page
var container = dojo.widget.byId(this.containerId);
- container.closePage(page);
+ container.closeChild(page);
},
onKey: function(evt){
@@ -303,7 +301,7 @@
var next = null; // the next button to focus on
// find currently focused button in children array
- var current = dojo.lang.find(this.children, this._currentPage);
+ var current = dojo.lang.find(this.children, this.pane2button[this._currentChild]);
// pick next button to focus on
if(evt.keyCode == evt.KEY_RIGHT_ARROW){
@@ -332,8 +330,8 @@
label: "foo",
// Boolean
- // true iff we should also print a close icon to destroy corresponding pane
- closable: false,
+ // true iff we should also print a close icon to destroy corresponding page
+ closeButton: false,
onClick: function(){
// summary
@@ -360,14 +358,14 @@
setSelected: function(){
// summary
- // This is run whenever the pane corresponding to this button has been selected
+ // This is run whenever the page corresponding to this button has been selected
dojo.html.addClass(this.domNode, "current");
this.titleNode.setAttribute("tabIndex","0");
},
clearSelected: function(){
// summary
- // This function is run whenever the pane corresponding to this button has been deselected (and another pane has been shown)
+ // This function is run whenever the page corresponding to this button has been deselected (and another page has been shown)
dojo.html.removeClass(this.domNode, "current");
this.titleNode.setAttribute("tabIndex","-1");
},
@@ -378,7 +376,6 @@
if(this.titleNode.focus){ // mozilla 1.7 doesn't have focus() func
this.titleNode.focus();
}
- this.parent._currentPage = this;
}
});
@@ -388,6 +385,6 @@
dojo.lang.extend(dojo.widget.Widget, {
label: "",
selected: false, // is this tab currently selected?
- closeButton: false,
+ closable: false, // true if user can close this tab pane
onClose: function(){ return true; } // callback if someone tries to close the child, child will be closed if func returns true
});
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Parse.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Parse.js?view=diff&rev=453979&r1=453978&r2=453979
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Parse.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Parse.js Sat Oct 7 11:22:33 2006
@@ -148,7 +148,21 @@
}
}catch(e){ dojo.debug(e); }
}
- }
+ switch(item.toLowerCase()){
+ case "checked":
+ if (!properties[item] || typeof properties[item] == "string"){
+ properties[item] = Boolean(!properties[item] ||
+ properties[item].toLowerCase() == "checked");
+ }
+ break;
+ case "disabled":
+ if (!properties[item] || typeof properties[item] == "string"){
+ properties[item] = Boolean(!properties[item] ||
+ properties[item].toLowerCase() == "disabled");
+ }
+ break;
+ }
+ }
}
return properties;
}