(note: probably eventually should move this into the book somewhere)
Implementations
Widgets can have (but are not required to have) multiple
implementations, as follows:
- svg - will run on any svg enabled browser (FF, later safari, soon other
browsers)
- vml - will run on IE
-
html - can run on any browser
Note that the so-called "html" version of the widget might actually run
special code for IE, FF, etc., either through calls to utility functions (such as the graphics library) that branch based on browser version, or
"if/else" statements, or whatever.
Namespaces for Implementations
1. The Button widget only has a single "html" implementation. It's
defined in dojo.widget.html.Button
2. In the future, the Chart widget will have both "svg" and "vml"
implementations, defined in dojo.widget.svg.Chart and
dojo.widget.vml.Chart. (The widget doesn't instantiate at all on
browsers that don't match either svg or vml)
Which widget gets run?
The HTML file just specifies the widget name, without specifying the
implementation. For example, "Foo".
Dojo will pick which version of the widget to run based on the user's
browser and what versions of the widget are available. For example, on
IE, it will run dojo.widget.vml.Foo if it exists, and otherwise run
dojo.widget.html.Foo.
Class Hierarchy
For widgets w/only a single implementation (usually "html"), there is
just a single file. No widget base class. (For example, there is
dojo.widget.html.Button, but no dojo.widget.Button)
For widgets w/multiple implementations, there's a base class that
defines common functionality and the parameter list for the widget.
Widgets with multiple implementations are defined using mixins, which
are similar (but subtly different) than multiple-inheritance. IE,
dojo.widget.svg.Chart extends HtmlWidget but mixes in dojo.widget.Chart
base class.
Directory Structure
For widgets w/a single implementation, like Button:
- src/widget/Button.js - defines dojo.widget.html.Button
For widgets w/multiple implementations, like Chart (in the future):
- src/widget/Chart.js - defines dojo.widget.Chart base class
- src/widget/svg/Chart.js - dojo.widget.svg.Chart, svg implementation
- src/widget/vml/Chart.js - dojo.widget.vml.Chart, vml implementation
Open issues
Will discuss at 2006/07/20 meeting.
1. core/
Scott has suggested that the infrastructure files (Manager.js, Parse.js, Widget.js, DomWidget?.js, HtmlWidget?.js etc.) be moved into src/widget/core directory.
2. James suggested that where a widget has multiple versions,
put them in Button/html.js and Button/svg.js rather than html/Button.js
and svg/Button.js