You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2005/12/06 20:30:51 UTC
svn commit: r354516 [8/15] - in /portals/jetspeed-2/trunk:
applications/j2-admin/src/java/org/apache/jetspeed/portlets/customizer/
applications/j2-admin/src/webapp/WEB-INF/
applications/j2-admin/src/webapp/WEB-INF/view/customizer/
applications/j2-admin...
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/DropdownButtons.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/DropdownButtons.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/DropdownButtons.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/DropdownButtons.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,9 @@
+dojo.provide("dojo.webui.widgets.DropdownButtons");
+dojo.provide("dojo.webui.widgets.HTMLDropdownButtons");
+
+dojo.require("dojo.widget.DropdownButtons");
+
+dj_deprecated("dojo.webui.widgets.DropdownButtons is deprecated, use dojo.widget.DropdownButtons");
+
+dojo.webui.widgets.DropdownButtons = dojo.widget.DropdownButtons;
+dojo.webui.widgets.HTMLDropdownButtons = dojo.widget.HtmlDropdownButtons;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLButton.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLButton.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLButton.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLButton.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,7 @@
+dojo.provide("dojo.webui.widgets.HTMLButton");
+
+dojo.require("dojo.widget.HtmlButton");
+
+dj_deprecated("dojo.webui.widgets.HTMLButton is deprecated, use dojo.widget.HtmlButton");
+
+dojo.webui.widgets.HTMLButton = dojo.widget.HtmlButton;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLComboBox.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLComboBox.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLComboBox.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLComboBox.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,7 @@
+dojo.provide("dojo.webui.widgets.HTMLComboBox");
+
+dojo.require("dojo.widget.HtmlComboBox");
+
+dj_deprecated("dojo.webui.widgets.HTMLComboBox is deprecated, use dojo.widget.HtmlComboBox");
+
+dojo.webui.widgets.HTMLComboBox = dojo.widget.HtmlComboBox;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLContextMenu.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLContextMenu.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLContextMenu.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLContextMenu.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,7 @@
+dojo.provide("dojo.webui.widgets.HTMLContextMenu");
+
+dojo.require("dojo.widget.HtmlContextMenu");
+
+dj_deprecated("dojo.webui.widgets.HTMLContextMenu is deprecated, use dojo.widget.HtmlContextMenu");
+
+dojo.webui.widgets.HTMLContextMenu = dojo.widget.HtmlContextMenu;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLMenu.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLMenu.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLMenu.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLMenu.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,7 @@
+dojo.provide("dojo.webui.widgets.HTMLMenu");
+
+dojo.require("dojo.widget.HtmlMenu");
+
+dj_deprecated("dojo.webui.widgets.HTMLMenu is deprecated, use dojo.widget.HtmlMenu");
+
+dojo.webui.widgets.HTMLMenu = dojo.widget.HtmlMenu;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLMenuItem.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLMenuItem.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLMenuItem.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLMenuItem.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,7 @@
+dojo.provide("dojo.webui.widgets.HTMLMenuItem");
+
+dojo.require("dojo.widget.HtmlMenuItem");
+
+dj_deprecated("dojo.webui.widgets.HTMLMenuItem is deprecated, use dojo.widget.HtmlMenuItem");
+
+dojo.webui.widgets.HTMLMenuItem = dojo.widget.HtmlMenuItem;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLResizableTextarea.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLResizableTextarea.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLResizableTextarea.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/HTMLResizableTextarea.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,7 @@
+dojo.provide("dojo.webui.widgets.HTMLResizableTextarea");
+
+dojo.require("dojo.widget.HtmlResizeableTextarea");
+
+dj_deprecated("dojo.webui.widgets.HTMLResizeableTextarea is deprecated, use dojo.widget.HtmlResizeableTextarea");
+
+dojo.webui.widgets.HTMLResizeableTextarea = dojo.widget.HtmlResizeableTextarea;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/InlineEditBox.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/InlineEditBox.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/InlineEditBox.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/InlineEditBox.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,8 @@
+dojo.provide("dojo.webui.widgets.InlineEditBox");
+dojo.provide("dojo.webui.widgets.HTMLInlineEditBox");
+
+dojo.require("dojo.widget.HtmlInlineEditBox");
+
+dj_deprecated("dojo.webui.widgets.InlineEditBox is deprecated, use dojo.widget.HtmlInlineEditBox");
+
+dojo.webui.widgets.HTMLInlineEditBox = dojo.widget.HtmlInlineEditBox;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Menu.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Menu.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Menu.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Menu.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,8 @@
+dojo.provide("dojo.webui.widgets.Menu");
+
+dojo.require("dojo.widget.Menu");
+
+dj_deprecated("dojo.webui.widgets.Menu is deprecated, use dojo.widget.Menu");
+
+dojo.webui.widgets.Menu = dojo.widget.Menu;
+dojo.webui.widgets.DomMenu = dojo.widget.DomMenu;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/MenuItem.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/MenuItem.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/MenuItem.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/MenuItem.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,8 @@
+dojo.provide("dojo.webui.widgets.MenuItem");
+
+dojo.require("dojo.widget.MenuItem");
+
+dj_deprecated("dojo.webui.widgets.MenuItem is deprecated, use dojo.widget.MenuItem");
+
+dojo.webui.widgets.MenuItem = dojo.widget.MenuItem;
+dojo.webui.widgets.DomMenuItem = dojo.widget.DomMenuItem;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Parse.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Parse.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Parse.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Parse.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,12 @@
+dojo.provide("dojo.webui.widgets.Parse");
+
+dojo.require("dojo.widget.Parse");
+
+dj_deprecated("dojo.webui.widgets.Parse is deprecated; use dojo.widget.Parse");
+
+dojo.webui.widgets.Parse = dojo.widget.Parse;
+dojo.webui.widgets._parser_collection = dojo.widget._parser_collection
+dojo.webui.widgets.getParser = dojo.widget.getParser
+dojo.webui.widgets.fromScript = dojo.widget.fromScript;
+dojo.webui.widgets.oldFromScript = dojo.widget._oldFromScript;
+dojo.webui.fromScript = dojo.widget.fromScript;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/SVGButton.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/SVGButton.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/SVGButton.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/SVGButton.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,7 @@
+dojo.provide("dojo.webui.widgets.SVGButton");
+
+dojo.require("dojo.widget.SvgButton");
+
+dj_deprecated("dojo.webui.widgets.SVGButton is deprecated, use dojo.widget.SvgButton");
+
+dojo.webui.widgets.SVGButton = dojo.widget.SvgButton;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/SlideShow.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/SlideShow.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/SlideShow.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/SlideShow.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,8 @@
+dojo.provide("dojo.webui.widgets.SlideShow");
+dojo.provide("dojo.webui.widgets.HTMLSlideShow");
+
+dojo.require("dojo.widget.HtmlSlideShow");
+
+dj_deprecated("dojo.webui.widgets.HTMLSlideShow is deprecated, use dojo.widget.HtmlSlideShow");
+
+dojo.webui.widgets.HTMLSlideShow = dojo.widget.HtmlSlideShow;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Tabs.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Tabs.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Tabs.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Tabs.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,8 @@
+dojo.provide("dojo.webui.widgets.Tabs");
+dojo.provide("dojo.webui.widgets.HTMLTabs");
+
+dojo.require("dojo.widget.HtmlTabs");
+
+dj_deprecated("dojo.webui.widgets.Tabs is deprecated, use dojo.widget.HtmlTabs");
+
+dojo.webui.widgets.HTMLTabs = dojo.widget.HtmlTabs;
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/__package__.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/__package__.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/__package__.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/__package__.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,4 @@
+dojo.hostenv.conditionalLoadModule({
+ common: ["dojo.webui.widgets.parse"]
+});
+dojo.hostenv.moduleLoaded("dojo.widgets.*");
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Accordion.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Accordion.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Accordion.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Accordion.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,190 @@
+dojo.provide("dojo.widget.Accordion");
+
+//
+// TODO
+// make it prettier
+// active dragging upwards doesn't always shift other bars (direction calculation is wrong in this case)
+//
+
+// pull in widget infrastructure
+dojo.require("dojo.widget.*");
+// pull in our superclass
+dojo.require("dojo.widget.HtmlSplitPane");
+// pull in animation libraries
+dojo.require("dojo.animation.Animation");
+
+dojo.widget.Accordion = function(){
+
+ dojo.widget.HtmlSplitPane.call(this);
+ this.widgetType = "Accordion";
+ this._super = dojo.widget.AccordionPanel.superclass;
+ dojo.event.connect(this, "postCreate", this, "myPostCreate");
+
+}
+dojo.inherits(dojo.widget.Accordion, dojo.widget.HtmlSplitPane);
+dojo.lang.extend(dojo.widget.Accordion, {
+ sizerWidth: 1,
+ activeSizing: 1,
+ animationInterval: 250,
+ openPanel: null,
+ myPostCreate: function(args, frag){
+ for(var i=0; i<this.sizers.length; i++){
+ var sn = this.sizers[i];
+ if(sn){
+ sn.style.border = "0px";
+ }
+ }
+ for(var i=0; i<this.children.length; i++){
+ this.children[i].setMinHeight();
+ if(this.children[i].open){
+ this.openPanel = this.children[i];
+ }
+ }
+ this.onResized();
+ },
+
+ setOpenPanel: function(panel){
+ if(!panel){ return; }
+ if(!this.openPanel){
+ this.openPanel = panel;
+ panel.open = true;
+ }else if(panel === this.openPanel){
+ // no-op
+ }else{
+ var closingPanel = this.openPanel;
+ var openingPanel = panel;
+ this.openPanel.sizeShare = 0;
+ this.openPanel.open = false;
+ this.openPanel.setMinHeight(true);
+ this.openPanel = panel;
+ this.openPanel.sizeShare = 100;
+ this.openPanel.open = true;
+ this.onResized();
+ // Don't animate if there is no interval
+ if (this.animationInterval == 0){
+ openingPanel.sizeShare = 100;
+ closingPanel.sizeShare = 0;
+ e.animation.accordion.onResized();
+ }else{
+ var line = new dojo.math.curves.Line([0,0], [0,100]);
+ var anim = new dojo.animation.Animation(
+ line,
+ this.animationInterval,
+ new dojo.math.curves.Bezier([[0],[0.05],[0.1],[0.9],[0.95],[1]])
+ );
+
+ var accordion = this;
+
+ anim.handler = function(e) {
+ switch(e.type) {
+ case "animate":
+ openingPanel.sizeShare = parseInt(e.y);
+ closingPanel.sizeShare = parseInt(100 - e.y);
+ accordion.onResized();
+ break;
+ case "end":
+ break;
+ }
+ }
+ anim.play();
+ }
+ }
+ }
+});
+dojo.widget.tags.addParseTreeHandler("dojo:Accordion");
+
+dojo.widget.AccordionPanel = function(){
+ dojo.widget.HtmlSplitPanePanel.call(this);
+ this.widgetType = "AccordionPanel";
+ dojo.event.connect(this, "fillInTemplate", this, "myFillInTemplate");
+ dojo.event.connect(this, "postCreate", this, "myPostCreate");
+}
+
+dojo.inherits(dojo.widget.AccordionPanel, dojo.widget.HtmlSplitPanePanel);
+
+dojo.lang.extend(dojo.widget.AccordionPanel, {
+ sizeMin:0,
+ initialSizeMin: null,
+ sizeShare: 0,
+ open: false,
+ label: "",
+ initialContent: "",
+ labelNode: null,
+ scrollContent: true,
+ initalContentNode: null,
+ contentNode: null,
+ templatePath: dojo.uri.dojoUri("src/widget/templates/AccordionPanel.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/AccordionPanel.css"),
+
+ setMinHeight: function(ignoreIC){
+ // now handle our setup
+ var lh = dojo.style.getContentHeight(this.labelNode);
+ if(!ignoreIC){
+ lh += dojo.style.getContentHeight(this.initialContentNode);
+ this.initialSizeMin = lh;
+ }
+ this.sizeMin = lh;
+ },
+
+ myFillInTemplate: function(args, frag){
+ var sn;
+ if(this.label.length > 0){
+ this.labelNode.innerHTML = this.label;
+ }else{
+ try{
+ sn = frag["dojo:label"][0]["dojo:label"].nodeRef;
+ while(sn.firstChild){
+ this.labelNode.firstChild.appendChild(sn.firstChild);
+ }
+ }catch(e){ }
+ }
+ if(this.initialContent.length > 0){
+ this.initialContentNode.innerHTML = this.initialContent;
+ }else{
+ try{
+ sn = frag["dojo:initialcontent"][0]["dojo:initialcontent"].nodeRef;
+ while(sn.firstChild){
+ this.initialContentNode.firstChild.appendChild(sn.firstChild);
+ }
+ }catch(e){ }
+ }
+ sn = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+ while(sn.firstChild){
+ this.contentNode.appendChild(sn.firstChild);
+ }
+ if(this.open){
+ this.sizeShare = 100;
+ }
+ },
+
+ myPostCreate: function(){
+ // this.domNode.style.overflow = "auto";
+ // this.domNode.style.position = "relative";
+ },
+
+ sizeSet: function(size){
+ if(!this.scrollContent){
+ return;
+ }
+ if(size <= this.sizeMin){
+ this.contentNode.style.display = "none";
+ }else{
+ // this.domNode.style.overflow = "hidden";
+ this.contentNode.style.display = "block";
+ this.contentNode.style.overflow = "auto";
+ var scrollSize = (size-((this.initialSizeMin) ? this.initialSizeMin : this.sizeMin));
+ if(dojo.render.html.ie){
+ this.contentNode.style.height = scrollSize+"px";
+ }else{
+ dojo.style.setOuterHeight(this.contentNode, scrollSize);
+ }
+ }
+ },
+
+ toggleOpen: function(evt){
+ this.parent.setOpenPanel(this);
+ }
+});
+dojo.widget.tags.addParseTreeHandler("dojo:AccordionPanel");
+
+
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Button.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Button.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Button.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Button.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,14 @@
+dojo.provide("dojo.widget.Button");
+dojo.require("dojo.widget.Widget");
+
+dojo.requireIf("html", "dojo.widget.html.Button");
+
+dojo.widget.tags.addParseTreeHandler("dojo:button");
+
+dojo.widget.Button = function(){
+ dojo.widget.Widget.call(this);
+
+ this.widgetType = "Button";
+ this.isContainer = true;
+}
+dojo.inherits(dojo.widget.Button, dojo.widget.Widget);
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Button2.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Button2.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Button2.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Button2.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,34 @@
+dojo.provide("dojo.widget.Button2");
+dojo.provide("dojo.widget.DropDownButton2");
+dojo.provide("dojo.widget.ComboButton2");
+dojo.require("dojo.widget.Widget");
+
+dojo.requireIf("html", "dojo.widget.html.Button2");
+
+dojo.widget.tags.addParseTreeHandler("dojo:button2");
+dojo.widget.tags.addParseTreeHandler("dojo:dropdownbutton2");
+dojo.widget.tags.addParseTreeHandler("dojo:combobutton2");
+
+dojo.widget.Button2 = function(){
+ dojo.widget.Widget.call(this);
+
+ this.widgetType = "Button2";
+ this.isContainer = true;
+}
+dojo.inherits(dojo.widget.Button2, dojo.widget.Widget);
+
+dojo.widget.DropDownButton2 = function(){
+ dojo.widget.Widget.call(this);
+
+ this.widgetType = "DropDownButton2";
+ this.isContainer = true;
+}
+dojo.inherits(dojo.widget.DropDownButton2, dojo.widget.Widget);
+
+dojo.widget.ComboButton2 = function(){
+ dojo.widget.Widget.call(this);
+
+ this.widgetType = "ComboButton2";
+ this.isContainer = true;
+}
+dojo.inherits(dojo.widget.ComboButton2, dojo.widget.Widget);
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Chart.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Chart.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Chart.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Chart.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,161 @@
+dojo.provide("dojo.widget.Chart");
+dojo.provide("dojo.widget.Chart.DataSeries");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.Widget");
+dojo.require("dojo.graphics.color");
+dojo.widget.tags.addParseTreeHandler("dojo:chart");
+
+dojo.requireIf(dojo.render.svg.support.builtin, "dojo.widget.svg.Chart");
+//dojo.requireIf(dojo.render.vml, "dojo.widget.vml.Chart");
+
+dojo.widget.Chart=function(){
+ dojo.widget.Widget.call(this);
+ this.widgetType="Chart";
+ this.isContainer=false;
+ this.series=[];
+ this.assignColors=function(){
+ var hue=30, sat=120, lum=120;
+ var steps = Math.round(330/this.series.length);
+ for (var i=0; i<this.series.length; i++){
+ var c=dojo.graphics.color.hsl2rgb(hue,sat,lum);
+ if (!this.series[i].color)
+ this.series[i].color=dojo.graphics.color.rgb2hex(c[0],c[1],c[2]);
+ hue+=steps;
+ }
+ };
+}
+dojo.inherits(dojo.widget.Chart, dojo.widget.Widget);
+
+/* Every chart has a set of data series; this is the series.
+ Note that each member of value is an object and in the
+ minimum has 2 properties: .x and .value.
+ */
+dojo.widget.Chart.DataSeries=function(key, label, plotType, color){
+ this.id="DataSeries"+dojo.widget.Chart.DataSeries.count++;
+ this.key=key;
+ this.label=label||this.id;
+ this.plotType=plotType||0;
+ this.color=color;
+ this.values=[];
+};
+dojo.widget.Chart.DataSeries.prototype={
+ add:function(v){
+ if(v.x==null||v.value==null){
+ dojo.raise("dojo.widget.Chart.DataSeries.add: v must have both an 'x' and 'value' property.");
+ }
+ this.values.push(v);
+ },
+ clear:function(){
+ this.values=[];
+ },
+ createRange:function(len){
+ var idx=this.values.length-1;
+ var length=len||this.values.length;
+ return {index:idx, length:length, start:Math.max(idx-length,0)};
+ },
+ // trend values
+ getMean:function(len){
+ var range=this.createRange(len);
+ if (range.index<0) return 0;
+ var t=0, c=0;
+ for (var i=range.index; i>=range.start; i--){
+ var n=parseFloat(this.values[i].value);
+ if (!isNaN(n)){
+ t+=n; c++;
+ }
+ }
+ t/=Math.max(c,1);
+ return t;
+ },
+ getMovingAverage:function(len){
+ var range=this.createRange(len);
+ if (range.index<0) return 0;
+ var t=0, c=0;
+ for (var i=range.index; i>=range.start; i--){
+ var n=parseFloat(this.values[i].value);
+ if (!isNaN(n)){
+ t+=n; c++;
+ }
+ }
+ t/=Math.max(c,1);
+ return t;
+ },
+ getVariance:function(len){
+ var range=this.createRange(len);
+ if (range.index < 0) return 0;
+ var t=0, s=0, c=0;
+ for (var i=range.index; i>=range.start; i--){
+ var n=parseFloat(this.values[i].value);
+ if (!isNaN(n)){
+ t+=n;
+ s+=Math.pow(n,2);
+ c++;
+ }
+ }
+ return (s/c)-Math.pow(t/c,2);
+ },
+ getStandardDeviation:function(len){
+ return Math.sqrt(this.getVariance(len));
+ },
+ getMax:function(len){
+ var range=this.createRange(len);
+ if (range.index < 0) return 0;
+ var t=0;
+ for (var i=range.index; i>=range.start; i--){
+ var n=parseFloat(this.values[i].value);
+ if (!isNaN(n)){
+ t=Math.max(n,t);
+ }
+ }
+ return t;
+ },
+ getMin:function(len){
+ var range=this.createRange(len);
+ if (range.index < 0) return 0;
+ var t=0;
+ for (var i=range.index; i>=range.start; i--){
+ var n=parseFloat(this.values[i].value);
+ if (!isNaN(n)){
+ t=Math.min(n,t);
+ }
+ }
+ return t;
+ },
+ getMedian:function(len){
+ var range=this.createRange(len);
+ if (range.index<0) return 0;
+ var a=[];
+ for (var i=range.index; i>=range.start; i--){
+ var n=parseFloat(this.values[i].value);
+ if (!isNaN(n)){
+ var b=false;
+ for(var j=0; j<a.length&&!b; j++){
+ if (n==a[j]) b=true;
+ }
+ if(!b) a.push(n);
+ }
+ }
+ a.sort();
+ if(a.length>0) return a[Math.ceil(a.length/2)];
+ return 0;
+ },
+ getMode:function(len){
+ var range=this.createRange(len);
+ if (range.index<0) return 0;
+ var o={}, ret=0, m=0;
+ for (var i=range.index; i>=range.start; i--){
+ var n=parseFloat(this.values[i].value);
+ if (!isNaN(n)){
+ if (!o[this.values[i].value]) o[this.values[i].value] = 1;
+ else o[this.values[i].value]++;
+ }
+ }
+ for (var p in o){
+ if(m<o[p]){
+ m=o[p]; ret=p;
+ }
+ }
+ return parseFloat(ret);
+ }
+};
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/CiviCrmDatePicker.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/CiviCrmDatePicker.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/CiviCrmDatePicker.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/CiviCrmDatePicker.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,109 @@
+dojo.provide("dojo.widget.CiviCrmDatePicker");
+dojo.provide("dojo.widget.HtmlCiviCrmDatePicker");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.widget.DatePicker");
+dojo.require("dojo.widget.html.DatePicker");
+dojo.require("dojo.widget.html.TimePicker");
+dojo.require("dojo.html");
+
+dojo.widget.HtmlCiviCrmDatePicker = function(){
+ this.widgetType = "CiviCrmDatePicker";
+ this.idPrefix = "scheduled_date_time";
+ this.mode = "datetime"; // can also be date or time
+
+ this.datePicker = null;
+ this.timePicker = null;
+
+ // html nodes
+ this.dateHolderTd = null;
+ this.timeHolderTd = null;
+ this.formItemsTd = null;
+ this.formItemsTr = null;
+
+ this.monthSelect = null;
+ this.daySelect = null;
+ this.yearSelect = null;
+ this.hourSelect = null;
+ this.minSelect = null;
+ this.apSelect = null;
+
+ this.templatePath = dojo.uri.dojoUri("src/widget/templates/HtmlCiviCrmDatePicker.html");
+
+ this.modeFormats = {
+ date: "MdY",
+ time: "hiA"
+ };
+
+ this.formatMappings = {
+ "M": "monthSelect",
+ "d": "daySelect",
+ "Y": "yearSelect",
+ "h": "hourSelect",
+ "i": "minSelect",
+ "A": "apSelect"
+ };
+
+ this.setDateSelects = function(){
+ var dateObj = this.datePicker.date;
+ this.monthSelect.value = new String(dateObj.getMonth()+1);
+ this.daySelect.value = new String(dateObj.getDate());
+ this.yearSelect.value = new String(dateObj.getFullYear());
+ }
+
+ this.setTimeSelects = function(){
+ var st = this.timePicker.selectedTime;
+ this.hourSelect.value = new String(st.hour);
+ this.minSelect.value = new String(st.minute);
+ this.apSelect.value = st.amPm.toUpperCase();
+ }
+
+ this.fillInTemplate = function(args, frag){
+ var nr = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+ var sref = {};
+ while(nr.firstChild){
+ if(nr.firstChild.name){
+ sref[nr.firstChild.name] = nr.firstChild;
+ }
+ this.formItemsTd.appendChild(nr.firstChild);
+ }
+
+ if(this.mode.indexOf("date") != -1){
+ this.datePicker = dojo.widget.fromScript("DatePicker", {}, this.dateHolderTd);
+ dojo.event.connect( this.datePicker, "onSetDate",
+ this, "setDateSelects");
+
+ var mfd = this.modeFormats.date;
+ for(var x=0; x<mfd.length; x++){
+ this[this.formatMappings[mfd[x]]] = sref[this.idPrefix+"["+mfd[x]+"]"];
+ fr = this[this.formatMappings[mfd[x]]].form;
+ }
+ }
+ if(this.mode.indexOf("time") != -1){
+ this.timePicker = dojo.widget.fromScript("TimePicker", {}, this.timeHolderTd);
+ dojo.event.connect( this.timePicker, "onSetTime",
+ this, "setTimeSelects");
+ var mfd = this.modeFormats.time;
+ for(var x=0; x<mfd.length; x++){
+ this[this.formatMappings[mfd[x]]] = sref[this.idPrefix+"["+mfd[x]+"]"];
+ }
+ }
+ }
+
+ this.unhide = function(){
+ this.formItemsTr.style.display = "";
+ }
+
+ this.postCreate = function(){
+ dojo.event.kwConnect({
+ type: "before",
+ srcObj: dojo.html.getParentOfType(this.domNode, "form"),
+ srcFunc: "onsubmit",
+ targetObj: this,
+ targetFunc: "unhide"
+ });
+ }
+}
+dojo.inherits(dojo.widget.HtmlCiviCrmDatePicker, dojo.widget.HtmlWidget);
+dojo.widget.tags.addParseTreeHandler("dojo:civicrmdatepicker");
+
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/ComboBox.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/ComboBox.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/ComboBox.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/ComboBox.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,187 @@
+dojo.provide("dojo.widget.ComboBox");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+
+dojo.widget.incrementalComboBoxDataProvider = function(url, limit, timeout){
+ this.searchUrl = url;
+ this.inFlight = false;
+ this.activeRequest = null;
+ this.allowCache = false;
+
+ this.cache = {};
+ this.addToCache = function(keyword, data){
+ if(this.allowCache){
+ this.cache[keyword] = data;
+ }
+ }
+
+ this.startSearch = function(searchStr, type, ignoreLimit){
+ if(this.inFlight){
+ // FIXME: implement backoff!
+ }
+ var tss = encodeURIComponent(searchStr);
+ var realUrl = dojo.string.paramString(this.searchUrl, {"searchString": tss});
+ var _this = this;
+ var request = dojo.io.bind({
+ url: realUrl,
+ method: "get",
+ mimetype: "text/javascript",
+ load: function(type, data, evt){
+ _this.inFlight = false;
+ _this.addToCache(searchStr, data);
+ _this.provideSearchResults(data);
+ }
+ });
+ this.inFlight = true;
+ }
+}
+
+dojo.widget.ComboBoxDataProvider = function(dataPairs, limit, timeout){
+ // NOTE: this data provider is designed as a naive reference
+ // implementation, and as such it is written more for readability than
+ // speed. A deployable data provider would implement lookups, search
+ // caching (and invalidation), and a significantly less naive data
+ // structure for storage of items.
+
+ this.data = [];
+ this.searchTimeout = 500;
+ this.searchLimit = 30;
+ this.searchType = "STARTSTRING"; // may also be "STARTWORD" or "SUBSTRING"
+ this.caseSensitive = false;
+ // for caching optimizations
+ this._lastSearch = "";
+ this._lastSearchResults = null;
+
+ this.startSearch = function(searchStr, type, ignoreLimit){
+ // FIXME: need to add timeout handling here!!
+ this._preformSearch(searchStr, type, ignoreLimit);
+ }
+
+ this._preformSearch = function(searchStr, type, ignoreLimit){
+ //
+ // NOTE: this search is LINEAR, which means that it exhibits perhaps
+ // the worst possible speed charachteristics of any search type. It's
+ // written this way to outline the responsibilities and interfaces for
+ // a search.
+ //
+ var st = type||this.searchType;
+ // FIXME: this is just an example search, which means that we implement
+ // only a linear search without any of the attendant (useful!) optimizations
+ var ret = [];
+ if(!this.caseSensitive){
+ searchStr = searchStr.toLowerCase();
+ }
+ for(var x=0; x<this.data.length; x++){
+ if((!ignoreLimit)&&(ret.length >= this.searchLimit)){
+ break;
+ }
+ // FIXME: we should avoid copies if possible!
+ var dataLabel = new String((!this.caseSensitive) ? this.data[x][0].toLowerCase() : this.data[x][0]);
+ if(dataLabel.length < searchStr.length){
+ // this won't ever be a good search, will it? What if we start
+ // to support regex search?
+ continue;
+ }
+
+ if(st == "STARTSTRING"){
+ // jum.debug(dataLabel.substr(0, searchStr.length))
+ // jum.debug(searchStr);
+ if(searchStr == dataLabel.substr(0, searchStr.length)){
+ ret.push(this.data[x]);
+ }
+ }else if(st == "SUBSTRING"){
+ // this one is a gimmie
+ if(dataLabel.indexOf(searchStr) >= 0){
+ ret.push(this.data[x]);
+ }
+ }else if(st == "STARTWORD"){
+ // do a substring search and then attempt to determine if the
+ // preceeding char was the beginning of the string or a
+ // whitespace char.
+ var idx = dataLabel.indexOf(searchStr);
+ if(idx == 0){
+ // implicit match
+ ret.push(this.data[x]);
+ }
+ if(idx <= 0){
+ // if we didn't match or implicily matched, march onward
+ continue;
+ }
+ // otherwise, we have to go figure out if the match was at the
+ // start of a word...
+ // this code is taken almost directy from nWidgets
+ var matches = false;
+ while(idx!=-1){
+ // make sure the match either starts whole string, or
+ // follows a space, or follows some punctuation
+ if(" ,/(".indexOf(dataLabel.charAt(idx-1)) != -1){
+ // FIXME: what about tab chars?
+ matches = true; break;
+ }
+ idx = dataLabel.indexOf(searchStr, tti+1);
+ }
+ if(!matches){
+ continue;
+ }else{
+ ret.push(this.data[x]);
+ }
+ }
+ }
+ this.provideSearchResults(ret);
+ }
+
+ this.provideSearchResults = function(resultsDataPairs){
+ }
+
+ this.addData = function(pairs){
+ // FIXME: incredibly naive and slow!
+ this.data = this.data.concat(pairs);
+ }
+
+ this.setData = function(pdata){
+ // populate this.data and initialize lookup structures
+ this.data = pdata;
+ }
+
+ if(dataPairs){
+ this.setData(dataPairs);
+ }
+}
+
+dojo.widget.ComboBox = function(){
+ dojo.widget.Widget.call(this);
+}
+
+dojo.inherits(dojo.widget.ComboBox, dojo.widget.Widget);
+
+dojo.widget.ComboBox.defaults = {
+ widgetType: "ComboBox",
+ isContainer: false,
+
+ forceValidOption: false,
+ searchType: "stringstart",
+ dataProvider: null,
+
+ startSearch: function(searchString){},
+ openResultList: function(results){},
+ clearResultList: function(){},
+ hideResultList: function(){},
+ selectNextResult: function(){},
+ selectPrevResult: function(){},
+ setSelectedResult: function(){}
+};
+
+dojo.lang.extend(dojo.widget.ComboBox, dojo.widget.ComboBox.defaults);
+
+dojo.widget.DomComboBox = function(){
+ dojo.widget.ComboBox.call(this);
+ dojo.widget.DomWidget.call(this, true);
+}
+
+dojo.inherits(dojo.widget.DomComboBox, dojo.widget.DomWidget);
+dojo.widget.tags.addParseTreeHandler("dojo:combobox");
+
+// render-specific includes
+dojo.requireIf("html", "dojo.widget.html.ComboBox");
+
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/ContextMenu.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/ContextMenu.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/ContextMenu.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/ContextMenu.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,20 @@
+dojo.provide("dojo.widget.ContextMenu");
+
+dojo.requireIf("html", "dojo.widget.html.ContextMenu");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.DomWidget");
+
+dojo.widget.ContextMenu = function(){
+ dojo.widget.Widget.call(this);
+ this.widgetType = "ContextMenu";
+ this.isContainer = true;
+ this.isOpened = false;
+
+ // copy children widgets output directly to parent (this node), to avoid
+ // errors trying to insert an <li> under a <div>
+ this.snarfChildDomOutput = true;
+
+}
+
+dojo.inherits(dojo.widget.ContextMenu, dojo.widget.Widget);
+dojo.widget.tags.addParseTreeHandler("dojo:contextmenu");
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DatePicker.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DatePicker.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DatePicker.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DatePicker.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,15 @@
+dojo.provide("dojo.widget.DatePicker");
+dojo.require("dojo.widget.DomWidget");
+dojo.requireIf("html", "dojo.widget.html.DatePicker");
+
+dojo.widget.DatePicker = function(){
+ dojo.widget.Widget.call(this);
+ this.widgetType = "DatePicker";
+ this.isContainer = false;
+
+ this.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+ this.weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
+}
+
+dojo.inherits(dojo.widget.DatePicker, dojo.widget.Widget);
+dojo.widget.tags.addParseTreeHandler("dojo:datepicker");
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Dialog.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Dialog.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Dialog.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Dialog.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,279 @@
+dojo.provide("dojo.widget.Dialog");
+dojo.provide("dojo.widget.HtmlDialog");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.graphics.color");
+dojo.require("dojo.fx.*");
+dojo.require("dojo.html");
+
+dojo.widget.tags.addParseTreeHandler("dojo:dialog");
+
+dojo.widget.HtmlDialog = function(){
+ dojo.widget.HtmlWidget.call(this);
+
+ this.resizeConnectArgs = {
+ srcObj: window,
+ srcFunc: "onresize",
+ adviceObj: this,
+ adviceFunc: "onResize",
+ rate: 500
+ }
+}
+
+dojo.inherits(dojo.widget.HtmlDialog, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.HtmlDialog, {
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlDialog.html"),
+ widgetType: "Dialog",
+ isContainer: true,
+
+ _scrollConnected: false,
+ _resizeConnected: false,
+
+ // provide a focusable element or element id if you need to
+ // work around FF's tendency to send focus into outer space on hide
+ focusElement: "",
+
+ // Only supports fade right now
+ effect: "fade",
+ effectDuration: 250,
+
+ bg: null,
+ bgIframe: null,
+ bgColor: "black",
+ bgOpacity: 0.4,
+ followScroll: 1,
+ _fromTrap: false,
+ anim: null,
+
+ trapTabs: function(e){
+ if(e.target == this.tabStart) {
+ if(this._fromTrap) {
+ this._fromTrap = false;
+ } else {
+ this._fromTrap = true;
+ this.tabEnd.focus();
+ }
+ } else if(e.target == this.tabEnd) {
+ if(this._fromTrap) {
+ this._fromTrap = false;
+ } else {
+ this._fromTrap = true;
+ this.tabStart.focus();
+ }
+ }
+ },
+
+ clearTrap: function(e) {
+ var _this = this;
+ setTimeout(function() {
+ _this._fromTrap = false;
+ }, 100);
+ },
+
+ postCreate: function(args, frag, parentComp) {
+ var b = dojo.html.body();
+ b.appendChild(this.domNode);
+ this.nodeRef = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+ if(this.nodeRef) {
+ this.setContent(this.nodeRef);
+ }
+
+ this.bgIframe = new dojo.html.BackgroundIframe();
+
+ this.bg = document.createElement("div");
+ this.bg.className = "dialogUnderlay";
+ with(this.bg.style) {
+ position = "absolute";
+ left = top = "0px";
+ zIndex = 998;
+ display = "none";
+ }
+ this.setBackgroundColor(this.bgColor);
+ b.appendChild(this.bg);
+ with(this.domNode.style) {
+ position = "absolute";
+ zIndex = 999;
+ display = "none";
+ }
+ this.bgIframe.setZIndex(this.bg);
+ },
+
+ setContent: function(content) {
+ if(typeof content == "string") {
+ this.containerNode.innerHTML = content;
+ } else if(content.nodeType != undefined) {
+ // dojo.dom.removeChildren(this.containerNode);
+ this.containerNode.appendChild(content);
+ } else {
+ dojo.raise("Tried to setContent with unknown content (" + content + ")");
+ }
+ },
+
+ setBackgroundColor: function(color) {
+ if(arguments.length >= 3) {
+ color = new dojo.graphics.color.Color(arguments[0], arguments[1], arguments[2]);
+ } else {
+ color = new dojo.graphics.color.Color(color);
+ }
+ this.bg.style.backgroundColor = color.toString();
+ return this.bgColor = color;
+ },
+
+ setBackgroundOpacity: function(op) {
+ if(arguments.length == 0) { op = this.bgOpacity; }
+ dojo.style.setOpacity(this.bg, op);
+ try {
+ this.bgOpacity = dojo.style.getOpacity(this.bg);
+ } catch (e) {
+ this.bgOpacity = op;
+ }
+ return this.bgOpacity;
+ },
+
+ sizeBackground: function() {
+ if(this.bgOpacity > 0) {
+ var h = document.documentElement.scrollHeight || dojo.html.body().scrollHeight;
+ var w = dojo.html.getViewportWidth();
+ this.bg.style.width = w + "px";
+ this.bg.style.height = h + "px";
+ this.bgIframe.size([0, 0, w, h]);
+ } else {
+ this.bgIframe.size(this.domNode);
+ }
+ },
+
+ showBackground: function() {
+ this.sizeBackground();
+ this.bgIframe.show();
+ if(this.bgOpacity > 0) {
+ this.bg.style.display = "block";
+ }
+ },
+
+ placeDialog: function() {
+ var scroll_offset = dojo.html.getScrollOffset();
+ var viewport_size = dojo.html.getViewportSize();
+
+ // find the size of the dialog
+ // we should really be using dojo.style but i'm not sure
+ // which (inner, outer, box, content, client) --cal
+ this.domNode.style.display = "block";
+ var w = this.domNode.offsetWidth;
+ var h = this.domNode.offsetHeight;
+ this.domNode.style.display = "none";
+
+ var x = scroll_offset[0] + (viewport_size[0] - w)/2;
+ var y = scroll_offset[1] + (viewport_size[1] - h)/2;
+
+ with(this.domNode.style) {
+ left = x + "px";
+ top = y + "px";
+ }
+
+ // tied to domNode, so we need to update the position
+ if(this.bgOpacity == 0) {
+ this.bgIframe.size([x, y, w, h]);
+ }
+ },
+
+ show: function() {
+ this.setBackgroundOpacity();
+ this.placeDialog();
+ this.showBackground();
+ switch((this.effect||"").toLowerCase()) {
+ case "fade":
+ this.domNode.style.display = "block";
+ var _this = this;
+ if(this.anim){ this.anim.stop(); }
+ this.anim = dojo.fx.fade(this.domNode, this.effectDuration, 0, 1, function(node) {
+ if(dojo.lang.isFunction(_this.onShow)) {
+ _this.onShow(node);
+ }
+ });
+ break;
+ default:
+ this.domNode.style.display = "block";
+ if(dojo.lang.isFunction(this.onShow)) {
+ this.onShow(node);
+ }
+ break;
+ }
+
+ // FIXME: moz doesn't generate onscroll events for mouse or key scrolling (wtf)
+ // we should create a fake event by polling the scrolltop/scrollleft every X ms.
+ // this smells like it should be a dojo feature rather than just for this widget.
+
+ if (this.followScroll && !this._scrollConnected){
+ this._scrollConnected = true;
+ dojo.event.connect(window, "onscroll", this, "onScroll");
+ }
+
+ if(!this._resizeConnected) {
+ this._resizeConnected = true;
+ dojo.event.kwConnect(this.resizeConnectArgs);
+ }
+ },
+
+ hide: function(){
+ // workaround for FF focus going into outer space
+ if (this.focusElement) {
+ dojo.byId(this.focusElement).focus();
+ dojo.byId(this.focusElement).blur();
+ }
+ switch((this.effect||"").toLowerCase()) {
+ case "fade":
+ this.bg.style.display = "none";
+ this.bgIframe.hide();
+ var _this = this;
+ if(this.anim){ this.anim.stop(); }
+ this.anim = dojo.fx.fadeOut(this.domNode, this.effectDuration, function(node) {
+ node.style.display = "none";
+ if(dojo.lang.isFunction(_this.onHide)) {
+ _this.onHide(node);
+ }
+ _this.anim = null;
+ });
+ break;
+ default:
+ this.bg.style.display = "none";
+ this.bgIframe.hide();
+ this.domNode.style.display = "none";
+ if(dojo.lang.isFunction(this.onHide)) {
+ this.onHide(node);
+ }
+ break;
+ }
+
+ this.bg.style.width = this.bg.style.height = "1px";
+
+ if (this._scrollConnected){
+ this._scrollConnected = false;
+ dojo.event.disconnect(window, "onscroll", this, "onScroll");
+ }
+
+ if(this._resizeConnected) {
+ this._resizeConnected = false;
+ dojo.event.kwDisconnect(this.resizeConnectArgs);
+ }
+ },
+
+ setCloseControl: function(node) {
+ dojo.event.connect(node, "onclick", this, "hide");
+ },
+
+ setShowControl: function(node) {
+ dojo.event.connect(node, "onclick", this, "show");
+ },
+
+ onScroll: function(){
+ this.placeDialog();
+ this.domNode.style.display = "block";
+ },
+
+ onResize: function(e) {
+ this.sizeBackground();
+ }
+});
+
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DomWidget.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DomWidget.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DomWidget.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DomWidget.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,516 @@
+dojo.provide("dojo.widget.DomWidget");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.string");
+dojo.require("dojo.widget.Widget");
+dojo.require("dojo.dom");
+dojo.require("dojo.xml.Parse");
+dojo.require("dojo.uri.*");
+
+dojo.widget._cssFiles = {};
+
+dojo.widget.defaultStrings = {
+ dojoRoot: dojo.hostenv.getBaseScriptUri(),
+ baseScriptUri: dojo.hostenv.getBaseScriptUri()
+};
+
+
+// static method to build from a template w/ or w/o a real widget in place
+dojo.widget.buildFromTemplate = function(obj, templatePath, templateCssPath, templateString) {
+ var tpath = templatePath || obj.templatePath;
+ var cpath = templateCssPath || obj.templateCssPath;
+
+ if (!cpath && obj.templateCSSPath) {
+ obj.templateCssPath = cpath = obj.templateCSSPath;
+ obj.templateCSSPath = null;
+ dj_deprecated("templateCSSPath is deprecated, use templateCssPath");
+ }
+
+ // DEPRECATED: use Uri objects, not strings
+ if (tpath && !(tpath instanceof dojo.uri.Uri)) {
+ tpath = dojo.uri.dojoUri(tpath);
+ dj_deprecated("templatePath should be of type dojo.uri.Uri");
+ }
+ if (cpath && !(cpath instanceof dojo.uri.Uri)) {
+ cpath = dojo.uri.dojoUri(cpath);
+ dj_deprecated("templateCssPath should be of type dojo.uri.Uri");
+ }
+
+ var tmplts = dojo.widget.DomWidget.templates;
+ if(!obj["widgetType"]) { // don't have a real template here
+ do {
+ var dummyName = "__dummyTemplate__" + dojo.widget.buildFromTemplate.dummyCount++;
+ } while(tmplts[dummyName]);
+ obj.widgetType = dummyName;
+ }
+
+ if((cpath)&&(!dojo.widget._cssFiles[cpath])){
+ dojo.html.insertCssFile(cpath);
+ obj.templateCssPath = null;
+ dojo.widget._cssFiles[cpath] = true;
+ }
+
+ var ts = tmplts[obj.widgetType];
+ if(!ts){
+ tmplts[obj.widgetType] = {};
+ ts = tmplts[obj.widgetType];
+ }
+ if(!obj.templateString){
+ obj.templateString = templateString || ts["string"];
+ }
+ if(!obj.templateNode){
+ obj.templateNode = ts["node"];
+ }
+ if((!obj.templateNode)&&(!obj.templateString)&&(tpath)){
+ // fetch a text fragment and assign it to templateString
+ // NOTE: we rely on blocking IO here!
+ var tstring = dojo.hostenv.getText(tpath);
+ if(tstring){
+ var matches = tstring.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
+ if(matches){
+ tstring = matches[1];
+ }
+ }else{
+ tstring = "";
+ }
+ obj.templateString = tstring;
+ ts.string = tstring;
+ }
+ if(!ts["string"]) {
+ ts.string = obj.templateString;
+ }
+}
+dojo.widget.buildFromTemplate.dummyCount = 0;
+
+dojo.widget.attachProperties = ["dojoAttachPoint", "id"];
+dojo.widget.eventAttachProperty = "dojoAttachEvent";
+dojo.widget.onBuildProperty = "dojoOnBuild";
+
+dojo.widget.attachTemplateNodes = function(rootNode, targetObj, events){
+ // FIXME: this method is still taking WAAAY too long. We need ways of optimizing:
+ // a.) what we are looking for on each node
+ // b.) the nodes that are subject to interrogation (use xpath instead?)
+ // c.) how expensive event assignment is (less eval(), more connect())
+ // var start = new Date();
+ var elementNodeType = dojo.dom.ELEMENT_NODE;
+
+ if(!rootNode){
+ rootNode = targetObj.domNode;
+ }
+
+ if(rootNode.nodeType != elementNodeType){
+ return;
+ }
+ // alert(events.length);
+
+ var nodes = rootNode.getElementsByTagName("*");
+ var _this = targetObj;
+ for(var x=-1; x<nodes.length; x++){
+ var baseNode = (x == -1) ? rootNode : nodes[x];
+ // FIXME: is this going to have capitalization problems?
+ var attachPoint = [];
+ for(var y=0; y<this.attachProperties.length; y++){
+ var tmpAttachPoint = baseNode.getAttribute(this.attachProperties[y]);
+ if(tmpAttachPoint){
+ attachPoint = tmpAttachPoint.split(";");
+ for(var z=0; z<this.attachProperties.length; z++){
+ if((targetObj[attachPoint[z]])&&(dojo.lang.isArray(targetObj[attachPoint[z]]))){
+ targetObj[attachPoint[z]].push(baseNode);
+ }else{
+ targetObj[attachPoint[z]]=baseNode;
+ }
+ }
+ break;
+ }
+ }
+ // continue;
+
+ // FIXME: we need to put this into some kind of lookup structure
+ // instead of direct assignment
+ var tmpltPoint = baseNode.getAttribute(this.templateProperty);
+ if(tmpltPoint){
+ targetObj[tmpltPoint]=baseNode;
+ }
+
+ var attachEvent = baseNode.getAttribute(this.eventAttachProperty);
+ if(attachEvent){
+ // NOTE: we want to support attributes that have the form
+ // "domEvent: nativeEvent; ..."
+ var evts = attachEvent.split(";");
+ for(var y=0; y<evts.length; y++){
+ if((!evts[y])||(!evts[y].length)){ continue; }
+ var thisFunc = null;
+ // var tevt = dojo.string.trim(evts[y]);
+ var tevt = dojo.string.trim(evts[y]);
+ if(evts[y].indexOf(":") >= 0){
+ // oh, if only JS had tuple assignment
+ var funcNameArr = tevt.split(":");
+ tevt = dojo.string.trim(funcNameArr[0]);
+ thisFunc = dojo.string.trim(funcNameArr[1]);
+ }
+ if(!thisFunc){
+ thisFunc = tevt;
+ }
+
+ var tf = function(){
+ var ntf = new String(thisFunc);
+ return function(evt){
+ if(_this[ntf]){
+ _this[ntf](dojo.event.browser.fixEvent(evt));
+ }
+ };
+ }();
+ dojo.event.browser.addListener(baseNode, tevt, tf, false, true);
+ }
+ }
+
+ for(var y=0; y<events.length; y++){
+ //alert(events[x]);
+ var evtVal = baseNode.getAttribute(events[y]);
+ if((evtVal)&&(evtVal.length)){
+ var thisFunc = null;
+ var domEvt = events[y].substr(4); // clober the "dojo" prefix
+ thisFunc = dojo.string.trim(evtVal);
+ var tf = function(){
+ var ntf = new String(thisFunc);
+ return function(evt){
+ if(_this[ntf]){
+ _this[ntf](dojo.event.browser.fixEvent(evt));
+ }
+ }
+ }();
+ dojo.event.browser.addListener(baseNode, domEvt, tf, false, true);
+ }
+ }
+
+ var onBuild = baseNode.getAttribute(this.onBuildProperty);
+ if(onBuild){
+ eval("var node = baseNode; var widget = targetObj; "+onBuild);
+ }
+
+ // strip IDs to prevent dupes
+ baseNode.id = "";
+ }
+
+}
+
+dojo.widget.getDojoEventsFromStr = function(str){
+ // var lstr = str.toLowerCase();
+ var re = /(dojoOn([a-z]+)(\s?))=/gi;
+ var evts = str ? str.match(re)||[] : [];
+ var ret = [];
+ var lem = {};
+ for(var x=0; x<evts.length; x++){
+ if(evts[x].legth < 1){ continue; }
+ var cm = evts[x].replace(/\s/, "");
+ cm = (cm.slice(0, cm.length-1));
+ if(!lem[cm]){
+ lem[cm] = true;
+ ret.push(cm);
+ }
+ }
+ return ret;
+}
+
+
+dojo.widget.buildAndAttachTemplate = function(obj, templatePath, templateCssPath, templateString, targetObj) {
+ this.buildFromTemplate(obj, templatePath, templateCssPath, templateString);
+ var node = dojo.dom.createNodesFromText(obj.templateString, true)[0];
+ this.attachTemplateNodes(node, targetObj||obj, dojo.widget.getDojoEventsFromStr(templateString));
+ return node;
+}
+
+dojo.widget.DomWidget = function(){
+ dojo.widget.Widget.call(this);
+ if((arguments.length>0)&&(typeof arguments[0] == "object")){
+ this.create(arguments[0]);
+ }
+}
+dojo.inherits(dojo.widget.DomWidget, dojo.widget.Widget);
+
+dojo.lang.extend(dojo.widget.DomWidget, {
+ templateNode: null,
+ templateString: null,
+ preventClobber: false,
+ domNode: null, // this is our visible representation of the widget!
+ containerNode: null, // holds child elements
+
+ // Process the given child widget, inserting it's dom node as a child of our dom node
+ // FIXME: should we support addition at an index in the children arr and
+ // order the display accordingly? Right now we always append.
+ addChild: function(widget, overrideContainerNode, pos, ref, insertIndex){
+ if(!this.isContainer){ // we aren't allowed to contain other widgets, it seems
+ dojo.debug("dojo.widget.DomWidget.addChild() attempted on non-container widget");
+ return null;
+ }else{
+ this.addWidgetAsDirectChild(widget, overrideContainerNode, pos, ref, insertIndex);
+ this.registerChild(widget);
+ }
+ return widget;
+ },
+
+ addWidgetAsDirectChild: function(widget, overrideContainerNode, pos, ref, insertIndex){
+ if((!this.containerNode)&&(!overrideContainerNode)){
+ this.containerNode = this.domNode;
+ }
+ var cn = (overrideContainerNode) ? overrideContainerNode : this.containerNode;
+ if(!pos){ pos = "after"; }
+ if(!ref){ ref = cn.lastChild; }
+ if(!insertIndex) { insertIndex = 0; }
+ widget.domNode.setAttribute("dojoinsertionindex", insertIndex);
+
+ // insert the child widget domNode directly underneath my domNode, in the
+ // specified position (by default, append to end)
+ if(!ref){
+ cn.appendChild(widget.domNode);
+ }else{
+ // FIXME: was this meant to be the (ugly hack) way to support insert @ index?
+ //dojo.dom[pos](widget.domNode, ref, insertIndex);
+
+ // CAL: this appears to be the intended way to insert a node at a given position...
+ if (pos == 'insertAtIndex'){
+ // dojo.debug("idx:", insertIndex, "isLast:", ref === cn.lastChild);
+ dojo.dom.insertAtIndex(widget.domNode, ref.parentNode, insertIndex);
+ }else{
+ // dojo.debug("pos:", pos, "isLast:", ref === cn.lastChild);
+ if((pos == "after")&&(ref === cn.lastChild)){
+ cn.appendChild(widget.domNode);
+ }else{
+ dojo.dom.insertAtPosition(widget.domNode, cn, pos);
+ }
+ }
+ }
+ },
+
+ // Record that given widget descends from me
+ registerChild: function(widget, insertionIndex){
+
+ // we need to insert the child at the right point in the parent's
+ // 'children' array, based on the insertionIndex
+
+ widget.dojoInsertionIndex = insertionIndex;
+
+ var idx = -1;
+ for(var i=0; i<this.children.length; i++){
+ if (this.children[i].dojoInsertionIndex < insertionIndex){
+ idx = i;
+ }
+ }
+
+ this.children.splice(idx+1, 0, widget);
+
+ widget.parent = this;
+ widget.addedTo(this);
+
+ // If this widget was created programatically, then it was erroneously added
+ // to dojo.widget.manager.topWidgets. Fix that here.
+ delete dojo.widget.manager.topWidgets[widget.widgetId];
+ },
+
+ // FIXME: we really need to normalize how we do things WRT "destroy" vs. "remove"
+ removeChild: function(widget){
+ for(var x=0; x<this.children.length; x++){
+ if(this.children[x] === widget){
+ this.children.splice(x, 1);
+ break;
+ }
+ }
+ return widget;
+ },
+
+ getFragNodeRef: function(frag)
+ {
+ return (frag ? frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"] : null);
+ },
+
+ // Replace source domNode with generated dom structure, and register
+ // widget with parent.
+ postInitialize: function(args, frag, parentComp){
+ var sourceNodeRef = this.getFragNodeRef(frag);
+ // Stick my generated dom into the output tree
+ //alert(this.widgetId + ": replacing " + sourceNodeRef + " with " + this.domNode.innerHTML);
+ if (parentComp && (parentComp.snarfChildDomOutput || !sourceNodeRef)){
+ // Add my generated dom as a direct child of my parent widget
+ // This is important for generated widgets, and also cases where I am generating an
+ // <li> node that can't be inserted back into the original DOM tree
+ parentComp.addWidgetAsDirectChild(this, "", "insertAtIndex", "", args["dojoinsertionindex"], sourceNodeRef);
+ } else if (sourceNodeRef){
+ // Do in-place replacement of the my source node with my generated dom
+ if(this.domNode && (this.domNode !== sourceNodeRef)){
+ var oldNode = sourceNodeRef.parentNode.replaceChild(this.domNode, sourceNodeRef);
+ }
+ }
+
+ // Register myself with my parent, or with the widget manager if
+ // I have no parent
+ // TODO: the code below erroneously adds all programatically generated widgets
+ // to topWidgets (since we don't know who the parent is until after creation finishes)
+ if ( parentComp ) {
+ parentComp.registerChild(this, args.dojoinsertionindex);
+ } else {
+ dojo.widget.manager.topWidgets[this.widgetId]=this;
+ }
+
+ // Expand my children widgets
+ if(this.isContainer){
+ //alert("recurse from " + this.widgetId);
+ // build any sub-components with us as the parent
+ var fragParser = dojo.widget.getParser();
+ fragParser.createComponents(frag, this);
+ }
+ },
+
+ startResize: function(coords){
+ dj_unimplemented("dojo.widget.DomWidget.startResize");
+ },
+
+ updateResize: function(coords){
+ dj_unimplemented("dojo.widget.DomWidget.updateResize");
+ },
+
+ endResize: function(coords){
+ dj_unimplemented("dojo.widget.DomWidget.endResize");
+ },
+
+ // method over-ride
+ buildRendering: function(args, frag){
+ // DOM widgets construct themselves from a template
+ var ts = dojo.widget.DomWidget.templates[this.widgetType];
+ if(
+ (!this.preventClobber)&&(
+ (this.templatePath)||
+ (this.templateNode)||
+ (
+ (this["templateString"])&&(this.templateString.length)
+ )||
+ (
+ (typeof ts != "undefined")&&( (ts["string"])||(ts["node"]) )
+ )
+ )
+ ){
+ // if it looks like we can build the thing from a template, do it!
+ this.buildFromTemplate(args, frag);
+ }else{
+ // otherwise, assign the DOM node that was the source of the widget
+ // parsing to be the root node
+ this.domNode = this.getFragNodeRef(frag);
+ }
+ this.fillInTemplate(args, frag); // this is where individual widgets
+ // will handle population of data
+ // from properties, remote data
+ // sets, etc.
+ },
+
+ buildFromTemplate: function(args, frag){
+ // var start = new Date();
+ // copy template properties if they're already set in the templates object
+ var ts = dojo.widget.DomWidget.templates[this.widgetType];
+ if(ts){
+ if(!this.templateString.length){
+ this.templateString = ts["string"];
+ }
+ if(!this.templateNode){
+ this.templateNode = ts["node"];
+ }
+ }
+ var node = null;
+ // attempt to clone a template node, if there is one
+ if((!this.templateNode)&&(this.templateString)){
+ // some special matching fun (this is a first pass, but could end up being useful for i8n)...
+ var matches = this.templateString.match(/\$\{([^\}]+)\}/g);
+ if(matches) {
+ var hash = this.strings || {};
+ for(var key in dojo.widget.defaultStrings) {
+ if(dojo.lang.isUndefined(hash[key])) {
+ hash[key] = dojo.widget.defaultStrings[key];
+ }
+ }
+ for(var i = 0; i < matches.length; i++) {
+ var key = matches[i];
+ key = key.substring(2, key.length-1);
+ if(hash[key]) {
+ if(dojo.lang.isFunction(hash[key])) {
+ var value = hash[key].call(this, key, this.templateString)
+ } else {
+ var value = hash[key];
+ }
+ this.templateString = this.templateString.replace(matches[i], value);
+ }
+ }
+ }
+
+ // otherwise, we are required to instantiate a copy of the template
+ // string if one is provided.
+
+ // FIXME: need to be able to distinguish here what should be done
+ // or provide a generic interface across all DOM implementations
+ // FIMXE: this breaks if the template has whitespace as its first
+ // characters
+ // node = this.createNodesFromText(this.templateString, true);
+ // this.templateNode = node[0].cloneNode(true); // we're optimistic here
+ this.templateNode = this.createNodesFromText(this.templateString, true)[0];
+ ts.node = this.templateNode;
+ }
+ if(!this.templateNode){
+ dojo.debug("weren't able to create template!");
+ return false;
+ }
+
+ // dojo.debug("toc0: ", new Date()-start, "ms");
+ var node = this.templateNode.cloneNode(true);
+ if(!node){ return false; }
+
+ // recurse through the node, looking for, and attaching to, our
+ // attachment points which should be defined on the template node.
+
+ this.domNode = node;
+ // dojo.profile.start("attachTemplateNodes");
+ this.attachTemplateNodes(this.domNode, this);
+ // dojo.profile.end("attachTemplateNodes");
+
+ // relocate source contents to templated container node
+ // this.containerNode must be able to receive children, or exceptions will be thrown
+ if (this.isContainer && this.containerNode){
+ var src = this.getFragNodeRef(frag);
+ if (src){
+ dojo.dom.moveChildren(src, this.containerNode);
+ }
+ }
+ },
+
+ attachTemplateNodes: function(baseNode, targetObj){
+ if(!targetObj){ targetObj = this; }
+ return dojo.widget.attachTemplateNodes(baseNode, targetObj,
+ dojo.widget.getDojoEventsFromStr(this.templateString));
+ },
+
+ fillInTemplate: function(){
+ // dj_unimplemented("dojo.widget.DomWidget.fillInTemplate");
+ },
+
+ // method over-ride
+ destroyRendering: function(){
+ try{
+ var tempNode = this.domNode.parentNode.removeChild(this.domNode);
+ delete tempNode;
+ }catch(e){ /* squelch! */ }
+ },
+
+ // FIXME: method over-ride
+ cleanUp: function(){},
+
+ getContainerHeight: function(){
+ // FIXME: the generic DOM widget shouldn't be using HTML utils!
+ return dojo.html.getInnerHeight(this.domNode.parentNode);
+ },
+
+ getContainerWidth: function(){
+ // FIXME: the generic DOM widget shouldn't be using HTML utils!
+ return dojo.html.getInnerWidth(this.domNode.parentNode);
+ },
+
+ createNodesFromText: function(){
+ dj_unimplemented("dojo.widget.DomWidget.createNodesFromText");
+ }
+});
+dojo.widget.DomWidget.templates = {};
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DropdownButton.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DropdownButton.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DropdownButton.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/DropdownButton.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,17 @@
+dojo.provide("dojo.widget.DropdownButton");
+
+// Draws a button with a down arrow;
+// when you press the down arrow something appears (usually a menu)
+
+dojo.require("dojo.widget.Widget");
+
+dojo.requireIf("html", "dojo.widget.html.DropdownButton");
+
+dojo.widget.tags.addParseTreeHandler("dojo:dropdownbutton");
+
+dojo.widget.DropdownButton = function(){
+ dojo.widget.Widget.call(this);
+
+ this.widgetType = "DropdownButton";
+}
+dojo.inherits(dojo.widget.DropdownButton, dojo.widget.Widget);
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Editor.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Editor.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Editor.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/Editor.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,579 @@
+/* TODO:
+ * - font selector
+ * - test, bug fix, more features :)
+*/
+dojo.provide("dojo.widget.Editor");
+dojo.provide("dojo.widget.HtmlEditor");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.Toolbar");
+dojo.require("dojo.widget.RichText");
+dojo.require("dojo.widget.HtmlColorPalette");
+
+dojo.widget.tags.addParseTreeHandler("dojo:Editor");
+
+dojo.widget.HtmlEditor = function() {
+ dojo.widget.HtmlWidget.call(this);
+ this.contentFilters = [];
+}
+dojo.inherits(dojo.widget.HtmlEditor, dojo.widget.HtmlWidget);
+
+dojo.widget.HtmlEditor.itemGroups = {
+ textGroup: ["bold", "italic", "underline", "strikethrough"],
+ blockGroup: ["fontFace", "formatBlock"],
+ justifyGroup: ["justifyleft", "justifycenter", "justifyright"],
+ commandGroup: ["save", "cancel"],
+ colorGroup: ["forecolor", "hilitecolor"],
+ listGroup: ["insertorderedlist", "insertunorderedlist"],
+ indentGroup: ["outdent", "indent"],
+ linkGroup: ["createlink", "insertimage"]
+};
+
+dojo.widget.HtmlEditor.formatBlockValues = {
+ "Normal": "p",
+ "Main heading": "h2",
+ "Sub heading": "h3",
+ "Sub sub headering": "h4",
+ "Preformatted": "pre"
+};
+
+dojo.widget.HtmlEditor.defaultItems = [
+ "commandGroup", "|", "linkGroup", "|", "textGroup", "|", "justifyGroup", "|", "listGroup", "indentGroup", "|", "colorGroup"
+];
+
+// ones we support by default without asking the RichText component
+// NOTE: you shouldn't put buttons like bold, italic, etc in here
+dojo.widget.HtmlEditor.supportedCommands = ["save", "cancel", "|", "-", "/", " "];
+
+dojo.lang.extend(dojo.widget.HtmlEditor, {
+ widgetType: "Editor",
+
+ items: dojo.widget.HtmlEditor.defaultItems,
+
+ formatBlockItems: dojo.lang.shallowCopy(dojo.widget.HtmlEditor.formatBlockValues),
+
+ // used to get the properties of an item if it is given as a string
+ getItemProperties: function(name) {
+ var props = {};
+ switch(name.toLowerCase()) {
+ case "bold":
+ case "italic":
+ case "underline":
+ case "strikethrough":
+ props.toggleItem = true;
+ break;
+
+ case "justifygroup":
+ props.defaultButton = "justifyleft";
+ props.preventDeselect = true;
+ props.buttonGroup = true;
+ break;
+
+ case "listgroup":
+ props.buttonGroup = true;
+ break;
+
+ case "save":
+ case "cancel":
+ props.label = dojo.string.capitalize(name);
+ break;
+
+ case "forecolor":
+ case "hilitecolor":
+ props.name = name;
+ props.toggleItem = true; // FIXME: they aren't exactly toggle items
+ props.icon = this.getCommandImage(name);
+ break;
+
+ case "formatblock":
+ props.name = "formatBlock";
+ props.values = this.formatBlockItems;
+ break;
+ }
+ return props;
+ },
+
+ validateItems: true, // set to false to add items, regardless of support
+
+ _richText: null, // RichText widget
+ _richTextType: "RichText",
+
+ _toolbarContainer: null, // ToolbarContainer widget
+ _toolbarContainerType: "ToolbarContainer",
+
+ _toolbars: [],
+ _toolbarType: "Toolbar",
+
+ _toolbarItemType: "ToolbarItem",
+
+ buildRendering: function(args, frag) {
+ // get the node from args/frag
+ var node = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+ var trt = dojo.widget.fromScript(this._richTextType, {}, node)
+ var _this = this;
+ // this appears to fix a weird timing bug on Safari
+ setTimeout(function(){
+ _this.setRichText(trt);
+
+ _this.initToolbar();
+
+ _this.fillInTemplate(args, frag);
+ }, 0);
+ },
+
+ setRichText: function(richText) {
+ if(this._richText && this._richText == richText) {
+ dojo.debug("Already set the richText to this richText!");
+ return;
+ }
+
+ if(this._richText && !this._richText.isClosed) {
+ dojo.debug("You are switching richTexts yet you haven't closed the current one. Losing reference!");
+ }
+ this._richText = richText;
+ dojo.event.connect(this._richText, "close", this, "onClose");
+ dojo.event.connect(this._richText, "onDisplayChanged", this, "updateToolbar");
+ if(this._toolbarContainer) {
+ this._toolbarContainer.enable();
+ this.updateToolbar(true);
+ }
+ },
+
+ initToolbar: function() {
+ // var tic = new Date();
+ if(this._toolbarContainer) { return; } // only create it once
+ this._toolbarContainer = dojo.widget.fromScript(this._toolbarContainerType);
+ var tb = this.addToolbar();
+ var last = true;
+ for(var i = 0; i < this.items.length; i++) {
+ if(this.items[i] == "\n") { // new row
+ tb = this.addToolbar();
+ } else {
+ if((this.items[i] == "|")&&(!last)){
+ last = true;
+ }else{
+ last = this.addItem(this.items[i], tb);
+ }
+ }
+ }
+ this.insertToolbar(this._toolbarContainer.domNode, this._richText.domNode);
+ // alert(new Date - tic);
+ },
+
+ // allow people to override this so they can make their own placement logic
+ insertToolbar: function(tbNode, richTextNode) {
+ dojo.html.insertBefore(tbNode, richTextNode);
+ //dojo.html.insertBefore(this._toolbarContainer.domNode, this._richText.domNode);
+ },
+
+ addToolbar: function(toolbar) {
+ this.initToolbar();
+ if(!(toolbar instanceof dojo.widget.HTMLToolbar)) {
+ toolbar = dojo.widget.fromScript(this._toolbarType);
+ }
+ this._toolbarContainer.addChild(toolbar);
+ this._toolbars.push(toolbar);
+ return toolbar;
+ },
+
+ addItem: function(item, tb, dontValidate) {
+ if(!tb) { tb = this._toolbars[0]; }
+ var cmd = ((item)&&(!dojo.lang.isUndefined(item["getValue"]))) ? cmd = item["getValue"](): item;
+
+ var groups = dojo.widget.HtmlEditor.itemGroups;
+ if(item instanceof dojo.widget.ToolbarItem) {
+ tb.addChild(item);
+ } else if(groups[cmd]) {
+ var group = groups[cmd];
+ var worked = true;
+ if(cmd == "justifyGroup" || cmd == "listGroup") {
+ var btnGroup = [cmd];
+ for(var i = 0 ; i < group.length; i++) {
+ if(dontValidate || this.isSupportedCommand(group[i])) {
+ btnGroup.push(this.getCommandImage(group[i]));
+ }else{
+ worked = false;
+ }
+ }
+ if(btnGroup.length) {
+ var btn = tb.addChild(btnGroup, null, this.getItemProperties(cmd));
+ dojo.event.connect(btn, "onClick", this, "_action");
+ dojo.event.connect(btn, "onChangeSelect", this, "_action");
+ }
+ return worked;
+ } else {
+ for(var i = 0; i < group.length; i++) {
+ if(!this.addItem(group[i], tb)){
+ worked = false;
+ }
+ }
+ return worked;
+ }
+ } else {
+ if((!dontValidate)&&(!this.isSupportedCommand(cmd))){
+ return false;
+ }
+ if(dontValidate || this.isSupportedCommand(cmd)) {
+ cmd = cmd.toLowerCase();
+ if(cmd == "formatblock") {
+ var select = dojo.widget.fromScript("ToolbarSelect", {
+ name: "formatBlock",
+ values: this.formatBlockItems
+ });
+ tb.addChild(select);
+ var _this = this;
+ dojo.event.connect(select, "onSetValue", function(item, value) {
+ _this.onAction("formatBlock", value);
+ });
+ } else if(dojo.lang.inArray(cmd, ["forecolor", "hilitecolor"])) {
+ var btn = tb.addChild(dojo.widget.fromScript("ToolbarColorDialog", this.getItemProperties(cmd)));
+ dojo.event.connect(btn, "onSetValue", this, "_setValue");
+ } else {
+ var btn = tb.addChild(this.getCommandImage(cmd), null, this.getItemProperties(cmd));
+ if(dojo.lang.inArray(cmd, ["save", "cancel"])) {
+ dojo.event.connect(btn, "onClick", this, "_close");
+ } else {
+ dojo.event.connect(btn, "onClick", this, "_action");
+ dojo.event.connect(btn, "onChangeSelect", this, "_action");
+ }
+ }
+ }
+ }
+ return true;
+ },
+
+ enableToolbar: function() {
+ if(this._toolbarContainer) {
+ this._toolbarContainer.domNode.style.display = "";
+ this._toolbarContainer.enable();
+ }
+ },
+
+ disableToolbar: function(hide){
+ if(hide){
+ if(this._toolbarContainer){
+ this._toolbarContainer.domNode.style.display = "none";
+ }
+ }else{
+ if(this._toolbarContainer){
+ this._toolbarContainer.disable();
+ }
+ }
+ },
+
+ _updateToolbarLastRan: null,
+ _updateToolbarTimer: null,
+ _updateToolbarFrequency: 500,
+
+ updateToolbar: function(force) {
+ if(!this._toolbarContainer) { 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
+
+ var items = this._toolbarContainer.getItems();
+ for(var i = 0; i < items.length; i++) {
+ var item = items[i];
+ if(item instanceof dojo.widget.HTMLToolbarSeparator) { continue; }
+ var cmd = item._name;
+ if (cmd == "save" || cmd == "cancel") { continue; }
+ else if(cmd == "justifyGroup") {
+ try {
+ if(!this._richText.queryCommandEnabled("justifyleft")) {
+ item.disable(false, true);
+ } else {
+ item.enable(false, true);
+ var jitems = item.getItems();
+ for(var j = 0; j < jitems.length; j++) {
+ var name = jitems[j]._name;
+ var value = this._richText.queryCommandValue(name);
+ if(typeof value == "boolean" && value) {
+ value = name;
+ break;
+ } else if(typeof value == "string") {
+ value = "justify"+value;
+ } else {
+ value = null;
+ }
+ }
+ if(!value) { value = "justifyleft"; } // TODO: query actual style
+ item.setValue(value, false, true);
+ }
+ } catch(err) {}
+ } else if(cmd == "listGroup") {
+ var litems = item.getItems();
+ for(var j = 0; j < litems.length; j++) {
+ this.updateItem(litems[j]);
+ }
+ } else {
+ this.updateItem(item);
+ }
+ }
+ },
+
+ updateItem: function(item) {
+ try {
+ var cmd = item._name;
+ var enabled = this._richText.queryCommandEnabled(cmd);
+ item.setEnabled(enabled, false, true);
+
+ var active = this._richText.queryCommandState(cmd);
+ if(active && cmd == "underline") {
+ // don't activate underlining if we are on a link
+ active = !this._richText.queryCommandEnabled("unlink");
+ }
+ item.setSelected(active, false, true);
+ return true;
+ } catch(err) {
+ return false;
+ }
+ },
+
+ supportedCommands: dojo.widget.HtmlEditor.supportedCommands.concat(),
+
+ isSupportedCommand: function(cmd) {
+ // FIXME: how do we check for ActiveX?
+ var yes = dojo.lang.inArray(cmd, this.supportedCommands);
+ if(!yes) {
+ try {
+ var richText = this._richText || dojo.widget.HtmlRichText.prototype;
+ yes = richText.queryCommandAvailable(cmd);
+ } catch(E) {}
+ }
+ return yes;
+ },
+
+ getCommandImage: function(cmd) {
+ if(cmd == "|") {
+ return cmd;
+ } else {
+ return dojo.uri.dojoUri("src/widget/templates/buttons/" + cmd + ".gif");
+ }
+ },
+
+ _action: function(e) {
+ this._fire("onAction", e.getValue());
+ },
+
+ _setValue: function(a, b) {
+ this._fire("onAction", a.getValue(), b);
+ },
+
+ _close: function(e) {
+ if(!this._richText.isClosed) {
+ this._richText.close(e.getName().toLowerCase() == "save");
+ }
+ },
+
+ onAction: function(cmd, value) {
+ switch(cmd) {
+ case "createlink":
+ if(!(value = prompt("Please enter the URL of the link:", "http://"))) {
+ return;
+ }
+ break;
+ case "insertimage":
+ if(!(value = prompt("Please enter the URL of the image:", "http://"))) {
+ return;
+ }
+ break;
+ }
+ this._richText.execCommand(cmd, value);
+ },
+
+ fillInTemplate: function(args, frag) {
+ // useless?
+ },
+
+ _fire: function(eventName) {
+ if(dojo.lang.isFunction(this[eventName])) {
+ var args = [];
+ if(arguments.length == 1) {
+ args.push(this);
+ } else {
+ for(var i = 1; i < arguments.length; i++) {
+ args.push(arguments[i]);
+ }
+ }
+ this[eventName].apply(this, args);
+ }
+ },
+
+ getHtml: function(){
+ this._richText.contentFilters = this.contentFilters;
+ return this._richText.getEditorContent();
+ },
+
+ getEditorContent: function(){
+ return this.getHtml();
+ },
+
+ onClose: function(save, hide){
+ this.disableToolbar(hide);
+ if(save) {
+ this._fire("onSave");
+ } else {
+ this._fire("onCancel");
+ }
+ },
+
+ // events baby!
+ onSave: null,
+ onCancel: null
+});
+
+/*
+function dontRunMe() {
+function createToolbar() {
+ tick("createToolbar");
+ tick("ct-init");
+ tbCont = dojo.widget.fromScript("toolbarContainer");
+ tb = dojo.widget.fromScript("toolbar");
+ tbCont.addChild(tb);
+
+ var saveBtn = tb.addChild("Save");
+ dojo.event.connect(saveBtn, "onClick", function() { editor.close(true); });
+ var cancelBtn = tb.addChild("Cancel");
+ dojo.event.connect(cancelBtn, "onClick", function() { editor.close(false); });
+ tb.addChild("|");
+
+ var headings = dojo.widget.fromScript("ToolbarSelect", {
+ name: "formatBlock",
+ values: {
+ "Normal": "p",
+ "Main heading": "h2",
+ "Sub heading": "h3",
+ "Sub sub heading": "h4",
+ "Preformatted": "pre"
+ }
+ });
+ dojo.event.connect(headings, "onSetValue", function(item, val) {
+ editor.execCommand("formatBlock", val);
+ });
+ tb.addChild(headings);
+ tb.addChild("|");
+ tock("ct-init");
+
+ // toolbar layout (2 rows):
+ // Save Cancel | WikiWord | Link Img | Table
+ // Heading FontFace | B I U | Alignment | OL UL < > | FG BG
+ var rows = [
+ ["save", "cancel", "|", "wikiword", "|", "createlink", "insertimage", "|", "table"],
+ ["formatBlock", "font", "|", "bold", "italic", "underline", "|", "justification", "|", "ol", "ul", "forecolor", "hilitecolor"]
+ ];
+
+ tick("command array");
+ var commands = [
+ { values: ["bold", "italic", "underline", "strikethrough"], toggleItem: true },
+ { values: [
+ dojo.widget.fromScript("ToolbarColorDialog", {toggleItem: true, name: "forecolor", icon: cmdImg("forecolor")}),
+ dojo.widget.fromScript("ToolbarColorDialog", {toggleItem: true, name: "hilitecolor", icon: cmdImg("hilitecolor")})
+ ]},
+ { values: ["justifyleft", "justifycenter", "justifyright"], name: "justify", defaultButton: "justifyleft", buttonGroup: true, preventDeselect: true },
+ { values: ["createlink", "insertimage"] },
+ { values: ["outdent", "indent"] },
+ { values: ["insertorderedlist", "insertunorderedlist"], name: "list", buttonGroup: true },
+ { values: ["undo", "redo"] },
+ { values: ["wikiword"], title: "WikiWord" }
+ ];
+ tock("command array");
+
+ tick("processCommands");
+ for(var i = 0; i < commands.length; i++) {
+ var set = commands[i];
+ var values = set.values;
+ var btnGroup = [set.name];
+ for(var j = 0; j < values.length; j++) {
+ if(typeof values[j] == "string") {
+ var cmd = values[j];
+ if(cmd == "wikiword") {
+ var btn = tb.addChild(cmdImg(cmd), null, {name:cmd, label:"WikiWord"});
+ //dojo.event.connect(bt, "onClick", listenWikiWord);
+ //dojo.event.connect(bt, "onChangeSelect", listenWikiWord);
+ } else if(dojo.widget.HtmlRichText.prototype.queryCommandAvailable(cmd)) {
+ if(set.buttonGroup) {
+ btnGroup.push(cmdImg(cmd));
+ } else {
+ var btn = tb.addChild(cmdImg(cmd), null, {name:cmd, toggleItem:set.toggleItem});
+ dojo.event.connect(btn, "onClick", listen);
+ dojo.event.connect(btn, "onChangeSelect", listen);
+ }
+ }
+ } else {
+ if(dojo.widget.HtmlRichText.prototype.queryCommandAvailable(values[j].getName())) {
+ var btn = tb.addChild(values[j]);
+ dojo.event.connect(btn, "onSetValue", colorListen, values[j].getName());
+ }
+ }
+ }
+ if(set.buttonGroup && btnGroup.length > 1) {
+ var btn = tb.addChild(btnGroup, null, {defaultButton:set.defaultButton});
+ dojo.event.connect(btn, "onClick", listen);
+ dojo.event.connect(btn, "onChangeSelect", listen);
+ }
+
+ if(i + 1 != commands.length
+ && !(tb.children[tb.children.length-1] instanceof dojo.widget.HTMLToolbarSeparator)) {
+ tb.addChild("|");
+ }
+ }
+ tock("processCommands");
+ tock("createToolbar");
+ return tbCont;
+}
+function cmdImg(cmd) {
+ return dojo.uri.dojoUri("src/widget/templates/buttons/" + cmd + ".gif");
+}
+function createWysiwyg(node) {
+ tick("createWysiwyg");
+ tick("editor");
+ editor = dojo.widget.fromScript("RichText", {}, node);
+ tock("editor");
+ dojo.event.connect(editor, "close", function(changed) {
+ if(changed) { setTimeout(save, 5); }
+ setTimeout(function() {
+ dojo.io.bind({
+ url: location,
+ content: {
+ edit: "0",
+ cancel: "Cancel"
+ },
+ handler: function() {
+ hideLoad();
+ }
+ });
+ }, 15);
+ finishEdit();
+ });
+ autolinkWikiWords(editor);
+ cleanupWord(editor);
+ //createToolbar();
+ dojo.event.connect(editor, "onDisplayChanged", updateToolbar);
+
+ if(editor && tbCont && tb) {
+ var top = document.getElementById("jot-topbar");
+ dojo.html.addClass(top, "hidden");
+ //placeToolbar(tbCont.domNode);
+ //top.appendChild(tbCont.domNode);
+ //document.getElementById("jot-bottombar").innerHTML = " ";
+ } else {
+ alert("Something went wrong trying to create the toolbar + editor.");
+ }
+ tock("createWysiwyg");
+
+ return editor;
+}
+
+}
+*/
Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/HtmlCheckbox.js
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/HtmlCheckbox.js?rev=354516&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/HtmlCheckbox.js (added)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/widget/HtmlCheckbox.js Tue Dec 6 11:29:56 2005
@@ -0,0 +1,100 @@
+dojo.provide("dojo.widget.Checkbox");
+dojo.provide("dojo.widget.HtmlCheckbox");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event");
+dojo.require("dojo.html");
+
+// FIXME: the input doesn't get taken out of the tab list (i think)
+// FIXME: the image doesn't get into the tab list (needs to steal the tabindex value from the input)
+
+dojo.widget.HtmlCheckbox = function(){
+
+ dojo.widget.HtmlWidget.call(this);
+
+ this.widgetType = "Checkbox";
+
+ this._testImg = null;
+ this.domNode = null;
+
+ this.srcOn = dojo.uri.dojoUri('src/widget/templates/check_on.gif');
+ this.srcOff = dojo.uri.dojoUri('src/widget/templates/check_off.gif');
+
+ this.fillInTemplate = function(){
+
+ // FIXME: if images are disabled, we DON'T want to swap out the element
+ // we can use the usual 'load image to check' trick
+ // i don't know what image we can check yet, so we'll skip this for now...
+
+ // this._testImg = document.createElement("img");
+ // document.body.appendChild(this._testImg);
+ // this._testImg.src = "spacer.gif?cachebust=" + new Date().valueOf();
+ // dojo.connect(this._testImg, 'onload', this, 'onImagesLoaded');
+
+ this.onImagesLoaded();
+ }
+
+ this.onImagesLoaded = function(){
+
+ // FIXME: if we actually check for loading images, remove the thing here
+ // document.body.removeChild(this._testImg);
+
+ // 'hide' the checkbox
+ this.domNode.style.position = "absolute";
+ this.domNode.style.left = "-9000px";
+
+ // create a replacement image
+ this.imgNode = document.createElement("img");
+ dojo.html.addClass(this.imgNode, "dojoHtmlCheckbox");
+ this.updateImgSrc();
+ dojo.event.connect(this.imgNode, 'onclick', this, 'onClick');
+ dojo.event.connect(this.domNode, 'onchange', this, 'onChange');
+ this.domNode.parentNode.insertBefore(this.imgNode, this.domNode.nextSibling)
+
+
+ // real ugly - make sure the image has all the events that the checkbox did
+ var events = new Array(
+ "onclick",
+ "onfocus",
+ "onblur",
+ "onselect",
+ "onchange",
+ "onclick",
+ "ondblclick",
+ "onmousedown",
+ "onmouseup",
+ "onmouseover",
+ "onmousemove",
+ "onmouseout",
+ "onkeypress",
+ "onkeydown",
+ "onkeyup"
+ );
+
+ for(var i=0; i<events.length; i++){
+ if (this.domNode[events[i]]){
+ dojo.event.connect(this.imgNode, events[i], this.domNode[events[i]]);
+ }
+ }
+ }
+
+ this.onClick = function(){
+
+ this.domNode.checked = !this.domNode.checked ? true : false;
+ this.updateImgSrc();
+ }
+
+ this.onChange = function(){
+
+ this.updateImgSrc();
+ }
+
+ this.updateImgSrc = function(){
+
+ this.imgNode.src = this.domNode.checked ? this.srcOn : this.srcOff;
+ }
+}
+
+dojo.inherits(dojo.widget.HtmlCheckbox, dojo.widget.HtmlWidget);
+
+dojo.widget.tags.addParseTreeHandler("dojo:Checkbox");
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org