You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/01/27 00:58:20 UTC
svn commit: r372668 [15/16] - in
/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource:
./ src/ src/alg/ src/animation/ src/collections/ src/crypto/ src/data/
src/dnd/ src/event/ src/flash/ src/flash/flash6/ sr...
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Wizard.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Wizard.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Wizard.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Wizard.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,209 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Wizard");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.LayoutPane");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html");
+dojo.require("dojo.style");
+
+//////////////////////////////////////////
+// Wizard -- a set of panels
+//////////////////////////////////////////
+dojo.widget.Wizard = function() {
+ dojo.widget.html.LayoutPane.call(this);
+}
+dojo.inherits(dojo.widget.Wizard, dojo.widget.html.LayoutPane);
+
+dojo.lang.extend(dojo.widget.Wizard, {
+
+ widgetType: "Wizard",
+
+ labelPosition: "top",
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Wizard.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/Wizard.css"),
+
+ selected: null, // currently selected panel
+ wizardNode: null, // the outer wizard node
+ wizardPanelContainerNode: null, // the container for the panels
+ wizardControlContainerNode: null, // the container for the wizard controls
+ previousButton: null, // the previous button
+ nextButton: null, // the next button
+ cancelButton: null, // the cancel button
+ doneButton: null, // the done button
+ nextButtonLabel: "next",
+ previousButtonLabel: "previous",
+ cancelButtonLabel: "cancel",
+ doneButtonLabel: "done",
+ cancelFunction : "",
+
+ hideDisabledButtons: false,
+
+ fillInTemplate: function(args, frag){
+ dojo.event.connect(this.nextButton, "onclick", this, "nextPanel");
+ dojo.event.connect(this.previousButton, "onclick", this, "previousPanel");
+ if (this.cancelFunction){
+ dojo.event.connect(this.cancelButton, "onclick", this.cancelFunction);
+ }else{
+ this.cancelButton.style.display = "none";
+ }
+ dojo.event.connect(this.doneButton, "onclick", this, "done");
+ this.nextButton.value = this.nextButtonLabel;
+ this.previousButton.value = this.previousButtonLabel;
+ this.cancelButton.value = this.cancelButtonLabel;
+ this.doneButton.value = this.doneButtonLabel;
+ },
+
+ checkButtons: function(){
+ var lastStep = !this.hasNextPanel();
+ this.nextButton.disabled = lastStep;
+ this.setButtonClass(this.nextButton);
+ if(this.selected.doneFunction){
+ this.doneButton.style.display = "";
+ // hide the next button if this is the last one and we have a done function
+ if(lastStep){
+ this.nextButton.style.display = "none";
+ }
+ }else{
+ this.doneButton.style.display = "none";
+ }
+ this.previousButton.disabled = ((!this.hasPreviousPanel()) || (!this.selected.canGoBack));
+ this.setButtonClass(this.previousButton);
+ },
+
+ setButtonClass: function(button){
+ if(!this.hideDisabledButtons){
+ button.style.display = "";
+ dojo.html.setClass(button, button.disabled ? "WizardButtonDisabled" : "WizardButton");
+ }else{
+ button.style.display = button.disabled ? "none" : "";
+ }
+ },
+
+ registerChild: function(panel, insertionIndex){
+ dojo.widget.Wizard.superclass.registerChild.call(this, panel, insertionIndex);
+ this.wizardPanelContainerNode.appendChild(panel.domNode);
+ panel.hide();
+
+ if(!this.selected){
+ this.onSelected(panel);
+ }
+ this.checkButtons();
+ },
+
+ onSelected: function(panel){
+ // Deselect old panel and select new one
+ if(this.selected ){
+ if (this.selected.checkPass()) {
+ this.selected.hide();
+ } else {
+ return;
+ }
+ }
+ panel.show();
+ this.selected = panel;
+ },
+
+ getPanels: function() {
+ return this.getChildrenOfType("WizardPane", false);
+ },
+
+ selectedIndex: function() {
+ if (this.selected) {
+ return dojo.lang.indexOf(this.getPanels(), this.selected);
+ }
+ return -1;
+ },
+
+ nextPanel: function() {
+ var selectedIndex = this.selectedIndex();
+ if ( selectedIndex > -1 ) {
+ var childPanels = this.getPanels();
+ if (childPanels[selectedIndex + 1]) {
+ this.onSelected(childPanels[selectedIndex + 1]);
+ }
+ }
+ this.checkButtons();
+ },
+
+ previousPanel: function() {
+ var selectedIndex = this.selectedIndex();
+ if ( selectedIndex > -1 ) {
+ var childPanels = this.getPanels();
+ if (childPanels[selectedIndex - 1]) {
+ this.onSelected(childPanels[selectedIndex - 1]);
+ }
+ }
+ this.checkButtons();
+ },
+
+ hasNextPanel: function() {
+ var selectedIndex = this.selectedIndex();
+ return (selectedIndex < (this.getPanels().length - 1));
+ },
+
+ hasPreviousPanel: function() {
+ var selectedIndex = this.selectedIndex();
+ return (selectedIndex > 0);
+ },
+
+ done: function() {
+ this.selected.done();
+ }
+});
+dojo.widget.tags.addParseTreeHandler("dojo:Wizard");
+
+//////////////////////////////////////////
+// WizardPane -- a panel in a wizard
+//////////////////////////////////////////
+dojo.widget.WizardPane = function() {
+ dojo.widget.html.LayoutPane.call(this);
+}
+dojo.inherits(dojo.widget.WizardPane, dojo.widget.html.LayoutPane);
+
+dojo.lang.extend(dojo.widget.WizardPane, {
+ widgetType: "WizardPane",
+
+ canGoBack: true,
+
+ passFunction: "",
+ doneFunction: "",
+
+ fillInTemplate: function(args, frag) {
+ if (this.passFunction) {
+ this.passFunction = dj_global[this.passFunction];
+ }
+ if (this.doneFunction) {
+ this.doneFunction = dj_global[this.doneFunction];
+ }
+ },
+
+ checkPass: function() {
+ if (this.passFunction && dojo.lang.isFunction(this.passFunction)) {
+ var failMessage = this.passFunction();
+ if (failMessage) {
+ alert(failMessage);
+ return false;
+ }
+ }
+ return true;
+ },
+
+ done: function() {
+ if (this.doneFunction && dojo.lang.isFunction(this.doneFunction)) {
+ this.doneFunction();
+ }
+ }
+});
+
+dojo.widget.tags.addParseTreeHandler("dojo:WizardPane");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/__package__.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/__package__.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/__package__.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/__package__.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,20 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.hostenv.conditionalLoadModule({
+ common: ["dojo.xml.Parse",
+ "dojo.widget.Widget",
+ "dojo.widget.Parse",
+ "dojo.widget.Manager"],
+ browser: ["dojo.widget.DomWidget",
+ "dojo.widget.HtmlWidget"],
+ svg: ["dojo.widget.SvgWidget"]
+});
+dojo.hostenv.moduleLoaded("dojo.widget.*");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,63 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.Button");
+dojo.require("dojo.widget.Button");
+
+dojo.deprecated("dojo.widget.Button", "use dojo.widget.Button2", "0.4");
+
+dojo.widget.html.Button = function(){
+ // mix in the button properties
+ dojo.widget.Button.call(this);
+ dojo.widget.HtmlWidget.call(this);
+}
+dojo.inherits(dojo.widget.html.Button, dojo.widget.HtmlWidget);
+dojo.lang.extend(dojo.widget.html.Button, {
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlButtonTemplate.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlButtonTemplate.css"),
+
+ label: "",
+ labelNode: null,
+ containerNode: null,
+
+ postCreate: function(args, frag){
+ this.labelNode = this.containerNode;
+ /*
+ if(this.label != "undefined"){
+ this.domNode.appendChild(document.createTextNode(this.label));
+ }
+ */
+ },
+
+ onMouseOver: function(e){
+ dojo.html.addClass(this.domNode, "dojoButtonHover");
+ dojo.html.removeClass(this.domNode, "dojoButtonNoHover");
+ },
+
+ onMouseOut: function(e){
+ dojo.html.removeClass(this.domNode, "dojoButtonHover");
+ dojo.html.addClass(this.domNode, "dojoButtonNoHover");
+ },
+
+ // By default, when I am clicked, click the item (link) inside of me.
+ // By default, a button is a disguised link.
+ // Todo: support actual submit and reset buttons.
+ onClick: function (e) {
+ var child = dojo.dom.getFirstChildElement(this.domNode);
+ if(child){
+ if(child.click){
+ child.click();
+ }else if(child.href){
+ location.href = child.href;
+ }
+ }
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button2.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button2.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button2.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button2.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,280 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.Button2");
+dojo.require("dojo.lang");
+dojo.require("dojo.html");
+dojo.require("dojo.style");
+
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.Button2");
+
+dojo.widget.html.Button2 = function(){
+ // call superclass constructors
+ dojo.widget.HtmlWidget.call(this);
+ dojo.widget.Button2.call(this);
+}
+dojo.inherits(dojo.widget.html.Button2, dojo.widget.HtmlWidget);
+dojo.lang.extend(dojo.widget.html.Button2, dojo.widget.Button2.prototype);
+dojo.lang.extend(dojo.widget.html.Button2, {
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlButton2Template.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlButton2Template.css"),
+
+ // button images
+ inactiveImg: "src/widget/templates/images/pill-button-blue_benji-",
+ activeImg: "src/widget/templates/images/pill-button-seagreen_benji-",
+ pressedImg: "src/widget/templates/images/pill-button-purple_benji-",
+ disabledImg: "src/widget/templates/images/pill-button-gray_benji-",
+ width2height: 1.0/3.0,
+
+ // attach points
+ containerNode: null,
+ leftImage: null,
+ centerImage: null,
+ rightImage: null,
+
+ fillInTemplate: function(args, frag){
+ if(this.caption != ""){
+ this.containerNode.appendChild(document.createTextNode(this.caption));
+ }
+ dojo.html.disableSelection(this.containerNode);
+ if ( this.disabled ) {
+ dojo.html.prependClass(this.domNode, "dojoButtonDisabled");
+ }
+
+ // after the browser has had a little time to calculate the size needed
+ // for the button contents, size the button
+ dojo.lang.setTimeout(this, this.sizeMyself, 0);
+ },
+
+ onResized: function(){
+ this.sizeMyself();
+ },
+
+ sizeMyself: function(e){
+ this.height = dojo.style.getOuterHeight(this.containerNode);
+ this.containerWidth = dojo.style.getOuterWidth(this.containerNode);
+ var endWidth= this.height * this.width2height;
+
+ this.containerNode.style.left=endWidth+"px";
+
+ this.leftImage.height = this.rightImage.height = this.centerImage.height = this.height;
+ this.leftImage.width = this.rightImage.width = endWidth+1;
+ this.centerImage.width = this.containerWidth;
+ this.centerImage.style.left=endWidth+"px";
+ this._setImage(this.disabled ? this.disabledImg : this.inactiveImg);
+
+ this.domNode.style.height=this.height + "px";
+ this.domNode.style.width= (this.containerWidth+2*endWidth) + "px";
+ },
+
+ onMouseOver: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.prependClass(this.domNode, "dojoButtonHover");
+ this._setImage(this.activeImg);
+ },
+
+ onMouseDown: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.prependClass(this.domNode, "dojoButtonDepressed");
+ dojo.html.removeClass(this.domNode, "dojoButtonHover");
+ this._setImage(this.pressedImg);
+ },
+ onMouseUp: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.prependClass(this.domNode, "dojoButtonHover");
+ dojo.html.removeClass(this.domNode, "dojoButtonDepressed");
+ this._setImage(this.activeImg);
+ },
+
+ onMouseOut: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.removeClass(this.domNode, "dojoButtonHover");
+ this._setImage(this.inactiveImg);
+ },
+
+ buttonClick: function(e){
+ if( !this.disabled && this.onClick ) { this.onClick(e); }
+ },
+
+ _setImage: function(prefix){
+ this.leftImage.src=dojo.uri.dojoUri(prefix + "l.gif");
+ this.centerImage.src=dojo.uri.dojoUri(prefix + "c.gif");
+ this.rightImage.src=dojo.uri.dojoUri(prefix + "r.gif");
+ },
+
+ _toggleMenu: function(menuId){
+ var menu = dojo.widget.getWidgetById(menuId);
+ if ( !menu ) { return; }
+
+ if ( menu.open && !menu.isShowing) {
+ var x = dojo.style.getAbsoluteX(this.domNode, true);
+ var y = dojo.style.getAbsoluteY(this.domNode, true) + this.height;
+ menu.open(x, y, null, this.domNode);
+ } else if ( menu.close && menu.isShowing ){
+ menu.close();
+ } else {
+ menu.toggle();
+ }
+ }
+});
+
+/**** DropDownButton - push the button and a menu shows up *****/
+dojo.widget.html.DropDownButton2 = function(){
+ // call constructors of superclasses
+ dojo.widget.DropDownButton2.call(this);
+ dojo.widget.html.Button2.call(this);
+}
+dojo.inherits(dojo.widget.html.DropDownButton2, dojo.widget.html.Button2);
+dojo.lang.extend(dojo.widget.html.DropDownButton2, dojo.widget.DropDownButton2.prototype);
+
+dojo.lang.extend(dojo.widget.html.DropDownButton2, {
+
+ downArrow: "src/widget/templates/images/whiteDownArrow.gif",
+ disabledDownArrow: "src/widget/templates/images/whiteDownArrow.gif",
+
+ fillInTemplate: function(args, frag){
+ dojo.widget.html.DropDownButton2.superclass.fillInTemplate.call(this, args, frag);
+
+ // draw the arrow
+ var arrow = document.createElement("img");
+ arrow.src = dojo.uri.dojoUri(this.disabled ? this.disabledDownArrow : this.downArrow);
+ dojo.html.setClass(arrow, "downArrow");
+ this.containerNode.appendChild(arrow);
+ },
+
+ onClick: function (e){
+ if( this.disabled ){ return; }
+ this._toggleMenu(this.menuId);
+ }
+});
+
+/**** ComboButton - left side is normal button, right side shows menu *****/
+dojo.widget.html.ComboButton2 = function(){
+ // call constructors of superclasses
+ dojo.widget.html.Button2.call(this);
+ dojo.widget.ComboButton2.call(this);
+}
+dojo.inherits(dojo.widget.html.ComboButton2, dojo.widget.html.Button2);
+dojo.lang.extend(dojo.widget.html.ComboButton2, dojo.widget.ComboButton2.prototype);
+dojo.lang.extend(dojo.widget.html.ComboButton2, {
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlComboButton2Template.html"),
+
+ // attach points
+ leftPart: null,
+ rightPart: null,
+ arrowBackgroundImage: null,
+
+ // constants
+ splitWidth: 1, // pixels between left&right part of button
+ arrowWidth: 10, // width of segment holding down arrow
+
+ sizeMyself: function(e){
+ this.height = dojo.style.getOuterHeight(this.containerNode);
+ this.containerWidth = dojo.style.getOuterWidth(this.containerNode);
+ var endWidth= this.height/3;
+
+ // left part
+ this.leftImage.height = this.rightImage.height = this.centerImage.height =
+ this.arrowBackgroundImage.height = this.height;
+ this.leftImage.width = endWidth+1;
+ this.centerImage.width = this.containerWidth;
+ this.leftPart.style.height = this.height + "px";
+ this.leftPart.style.width = endWidth + this.containerWidth + "px";
+ this._setImageL(this.disabled ? this.disabledImg : this.inactiveImg);
+
+ // right part
+ this.arrowBackgroundImage.width=this.arrowWidth;
+ this.rightImage.width = endWidth+1;
+ this.rightPart.style.height = this.height + "px";
+ this.rightPart.style.width = this.arrowWidth + endWidth + "px";
+ this._setImageR(this.disabled ? this.disabledImg : this.inactiveImg);
+
+ // outer container
+ this.domNode.style.height=this.height + "px";
+ var totalWidth = this.containerWidth+this.splitWidth+this.arrowWidth+2*endWidth;
+ this.domNode.style.width= totalWidth + "px";
+ },
+
+ /** functions on left part of button**/
+ leftOver: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.prependClass(this.leftPart, "dojoButtonHover");
+ this._setImageL(this.activeImg);
+ },
+
+ leftDown: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.prependClass(this.leftPart, "dojoButtonDepressed");
+ dojo.html.removeClass(this.leftPart, "dojoButtonHover");
+ this._setImageL(this.pressedImg);
+ },
+ leftUp: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.prependClass(this.leftPart, "dojoButtonHover");
+ dojo.html.removeClass(this.leftPart, "dojoButtonDepressed");
+ this._setImageL(this.activeImg);
+ },
+
+ leftOut: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.removeClass(this.leftPart, "dojoButtonHover");
+ this._setImageL(this.inactiveImg);
+ },
+
+ leftClick: function(e){
+ if ( !this.disabled && this.onClick ) {
+ this.onClick(e);
+ }
+ },
+
+ _setImageL: function(prefix){
+ this.leftImage.src=dojo.uri.dojoUri(prefix + "l.gif");
+ this.centerImage.src=dojo.uri.dojoUri(prefix + "c.gif");
+ },
+
+ /*** functions on right part of button ***/
+ rightOver: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.prependClass(this.rightPart, "dojoButtonHover");
+ this._setImageR(this.activeImg);
+ },
+
+ rightDown: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.prependClass(this.rightPart, "dojoButtonDepressed");
+ dojo.html.removeClass(this.rightPart, "dojoButtonHover");
+ this._setImageR(this.pressedImg);
+ },
+ rightUp: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.prependClass(this.rightPart, "dojoButtonHover");
+ dojo.html.removeClass(this.rightPart, "dojoButtonDepressed");
+ this._setImageR(this.activeImg);
+ },
+
+ rightOut: function(e){
+ if( this.disabled ){ return; }
+ dojo.html.removeClass(this.rightPart, "dojoButtonHover");
+ this._setImageR(this.inactiveImg);
+ },
+
+ rightClick: function(e){
+ if( this.disabled ){ return; }
+ this._toggleMenu(this.menuId);
+ },
+
+ _setImageR: function(prefix){
+ this.arrowBackgroundImage.src=dojo.uri.dojoUri(prefix + "c.gif");
+ this.rightImage.src=dojo.uri.dojoUri(prefix + "r.gif");
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Checkbox.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Checkbox.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Checkbox.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Checkbox.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,105 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.require("dojo.widget.Checkbox");
+dojo.provide("dojo.widget.html.Checkbox");
+
+// 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.html.Checkbox = function(){
+ dojo.widget.HtmlWidget.call(this);
+}
+
+dojo.inherits(dojo.widget.html.Checkbox, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.Checkbox, {
+ widgetType: "Checkbox",
+
+ _testImg: null,
+
+ _events: [
+ "onclick",
+ "onfocus",
+ "onblur",
+ "onselect",
+ "onchange",
+ "onclick",
+ "ondblclick",
+ "onmousedown",
+ "onmouseup",
+ "onmouseover",
+ "onmousemove",
+ "onmouseout",
+ "onkeypress",
+ "onkeydown",
+ "onkeyup"
+ ],
+
+ srcOn: dojo.uri.dojoUri('src/widget/templates/check_on.gif'),
+ srcOff: dojo.uri.dojoUri('src/widget/templates/check_off.gif'),
+
+ 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();
+ },
+
+ 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
+ for(var i=0; i<this._events.length; i++){
+ if(this.domNode[this._events[i]]){
+ dojo.event.connect( this.imgNode, this._events[i],
+ this.domNode[this._events[i]]);
+ }
+ }
+ },
+
+ onClick: function(){
+
+ this.domNode.checked = !this.domNode.checked ? true : false;
+ this.updateImgSrc();
+ },
+
+ onChange: function(){
+
+ this.updateImgSrc();
+ },
+
+ updateImgSrc: function(){
+
+ this.imgNode.src = this.domNode.checked ? this.srcOn : this.srcOff;
+ }
+});
+
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ComboBox.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ComboBox.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ComboBox.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ComboBox.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,419 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.ComboBox");
+dojo.require("dojo.widget.ComboBox");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.fx.*");
+dojo.require("dojo.dom");
+dojo.require("dojo.html");
+dojo.require("dojo.string");
+dojo.require("dojo.widget.html.stabile");
+
+dojo.widget.html.ComboBox = function(){
+ dojo.widget.ComboBox.call(this);
+ dojo.widget.HtmlWidget.call(this);
+
+ this.autoComplete = true;
+ this.formInputName = "";
+ this.name = ""; // clone in the name from the DOM node
+ this.textInputNode = null;
+ this.comboBoxValue = null;
+ this.comboBoxSelectionValue = null;
+ this.optionsListWrapper = null;
+ this.optionsListNode = null;
+ this.downArrowNode = null;
+ this.cbTableNode = null;
+ this.searchTimer = null;
+ this.searchDelay = 100;
+ this.dataUrl = "";
+ // mode can also be "remote" for JSON-returning live search or "html" for
+ // dumber live search
+ this.mode = "local";
+ this.selectedResult = null;
+ this._highlighted_option = null;
+ this._prev_key_backspace = false;
+ this._prev_key_esc = false;
+ this._result_list_open = false;
+}
+
+dojo.inherits(dojo.widget.html.ComboBox, dojo.widget.HtmlWidget);
+
+// copied from superclass since we can't really over-ride via prototype
+dojo.lang.extend(dojo.widget.html.ComboBox, dojo.widget.ComboBox.defaults);
+
+dojo.lang.extend(dojo.widget.html.ComboBox, {
+
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlComboBox.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlComboBox.css"),
+
+ setValue: function(value) {
+ this.comboBoxValue.value = this.textInputNode.value = value;
+ dojo.widget.html.stabile.setState(this.widgetId, this.getState(), true);
+ },
+
+ getValue: function() {
+ return this.comboBoxValue.value;
+ },
+
+ getState: function() {
+ return {value: this.getValue()};
+ },
+
+ setState: function(state) {
+ this.setValue(state.value);
+ },
+
+
+ getCaretPos: function(element){
+ // FIXME: we need to figure this out for Konq/Safari!
+ if(dojo.render.html.mozilla){
+ // FIXME: this is totally borked on Moz < 1.3. Any recourse?
+ return element.selectionStart;
+ }else if(dojo.render.html.ie){
+ // in the case of a mouse click in a popup being handled,
+ // then the document.selection is not the textarea, but the popup
+ // var r = document.selection.createRange();
+ // hack to get IE 6 to play nice. What a POS browser.
+ // var tr = r.duplicate();
+ var tr = document.selection.createRange().duplicate();
+ // var ntr = document.selection.createRange().duplicate();
+ var ntr = element.createTextRange();
+ // FIXME: this seems to work but I'm getting some execptions on reverse-tab
+ tr.move("character",0);
+ ntr.move("character",0);
+ /*
+ try{
+ ntr.moveToElementText(element);
+ }catch(e){ dojo.debug(e); }
+ */
+ ntr.setEndPoint("EndToEnd", tr);
+ return String(ntr.text).replace(/\r/g,"").length;
+ }
+ },
+
+ setCaretPos: function(element, location){
+ location = parseInt(location);
+ this.setSelectedRange(element, location, location);
+ },
+
+ setSelectedRange: function(element, start, end){
+ if(!end){ end = element.value.length; }
+ // Mozilla
+ // parts borrowed from http://www.faqts.com/knowledge_base/view.phtml/aid/13562/fid/130
+ if(element.setSelectionRange){
+ element.focus();
+ element.setSelectionRange(start, end);
+ }else if(element.createTextRange){ // IE
+ var range = element.createTextRange();
+ with(range){
+ collapse(true);
+ moveEnd('character', end);
+ moveStart('character', start);
+ select();
+ }
+ }else{ //otherwise try the event-creation hack (our own invention)
+ // do we need these?
+ element.value = element.value;
+ element.blur();
+ element.focus();
+ // figure out how far back to go
+ var dist = parseInt(element.value.length)-end;
+ var tchar = String.fromCharCode(37);
+ var tcc = tchar.charCodeAt(0);
+ for(var x = 0; x < dist; x++){
+ var te = document.createEvent("KeyEvents");
+ te.initKeyEvent("keypress", true, true, null, false, false, false, false, tcc, tcc);
+ twe.dispatchEvent(te);
+ }
+ }
+ },
+
+ killEvent: function(evt){
+ evt.preventDefault();
+ evt.stopPropagation();
+ },
+
+ onKeyDown: function(evt){
+ },
+
+ setSelectedValue: function(value){
+ // FIXME, not sure what to do here!
+ this.comboBoxSelectionValue.value = value;
+ this.hideResultList();
+ },
+
+ highlightNextOption: function(){
+ if(this._highlighted_option){
+ dojo.html.removeClass(this._highlighted_option, "cbItemHighlight");
+ }
+ if((!this._highlighted_option)||(!this._highlighted_option.nextSibling)){
+ this._highlighted_option = this.optionsListNode.firstChild;
+ }else{
+ this._highlighted_option = this._highlighted_option.nextSibling;
+ }
+ dojo.html.addClass(this._highlighted_option, "cbItemHighlight");
+ },
+
+ highlightPrevOption: function(){
+ if(this._highlighted_option){
+ dojo.html.removeClass(this._highlighted_option, "cbItemHighlight");
+ }
+ if((!this._highlighted_option)||(!this._highlighted_option.previousSibling)){
+ this._highlighted_option = this.optionsListNode.lastChild;
+ }else{
+ this._highlighted_option = this._highlighted_option.previousSibling;
+ }
+ dojo.html.addClass(this._highlighted_option, "cbItemHighlight");
+ },
+
+ onKeyUp: function(evt){
+ if(evt.keyCode == 27){ // esc is 27
+ this.hideResultList();
+ if(this._prev_key_esc){
+ this.textInputNode.blur();
+ this.selectedResult = null;
+ }
+ this._prev_key_esc = true;
+ return;
+ }else if((evt.keyCode == 32)||(evt.keyCode == 13)){ // space is 32, enter is 13.
+ /*
+ // Cancel the enter key event bubble to avoid submitting the form.
+ if (evt.keyCode == 13) {
+ // FIXME: the does not cancel the form submission.
+ this.killEvent(evt);
+ }
+ */
+ // If the list is open select the option with the event.
+ if(this._result_list_open){
+ evt = { target: this._highlighted_option };
+ this.selectOption(evt);
+ }else{
+ // Otherwise select the option with out the event.
+ this.selectOption();
+ }
+ return;
+ }else if(evt.keyCode == 40){ // down is 40
+ if(!this._result_list_open){
+ this.startSearchFromInput();
+ }
+ this.highlightNextOption();
+ return;
+ }else if(evt.keyCode == 38){ // up is 38
+ this.highlightPrevOption();
+ return;
+ }else{
+ this.setValue(this.textInputNode.value);
+ }
+
+ // backspace is 8
+ this._prev_key_backspace = (evt.keyCode == 8) ? true : false;
+ this._prev_key_esc = false;
+
+ if(this.searchTimer){
+ clearTimeout(this.searchTimer);
+ }
+ if((this._prev_key_backspace)&&(!this.textInputNode.value.length)){
+ this.hideResultList();
+ }else{
+ this.searchTimer = setTimeout(dojo.lang.hitch(this, this.startSearchFromInput), this.searchDelay);
+ }
+ },
+
+ fillInTemplate: function(args, frag){
+ // FIXME: need to get/assign DOM node names for form participation here.
+ this.comboBoxValue.name = this.name;
+ this.comboBoxSelectionValue.name = this.name+"_selected";
+
+ // NOTE: this doesn't copy style info inherited from classes;
+ // it's just primitive support for direct style setting
+ var sourceNodeStyle = this.getFragNodeRef(frag).style;
+ if ( sourceNodeStyle ){
+ this.domNode.style.cssText = sourceNodeStyle.cssText;
+ }
+
+ // FIXME: add logic
+ this.dataProvider = new dojo.widget.ComboBoxDataProvider();
+
+ if(!dojo.string.isBlank(this.dataUrl)){
+ if("local" == this.mode){
+ var _this = this;
+ dojo.io.bind({
+ url: this.dataUrl,
+ load: function(type, data, evt){
+ if(type=="load"){
+ _this.dataProvider.setData(data);
+ }
+ },
+ mimetype: "text/javascript"
+ });
+ }else if("remote" == this.mode){
+ this.dataProvider = new dojo.widget.incrementalComboBoxDataProvider(this.dataUrl);
+ }
+ }else{
+ // check to see if we can populate the list from <option> elements
+ var node = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+ if((node)&&(node.nodeName.toLowerCase() == "select")){
+ // NOTE: we're not handling <optgroup> here yet
+ var opts = node.getElementsByTagName("option");
+ var ol = opts.length;
+ var data = [];
+ for(var x=0; x<ol; x++){
+ data.push([new String(opts[x].innerHTML), new String(opts[x].value)]);
+ }
+ this.dataProvider.setData(data);
+ }
+ }
+
+ // Prevent IE bleed-through problem
+ this.bgIframe = new dojo.html.BackgroundIframe();
+ if(this.bgIframe.iframe){
+ this.optionsListWrapper.appendChild(this.bgIframe.iframe);
+ }
+ },
+
+ openResultList: function(results){
+ this.clearResultList();
+ if(!results.length){
+ this.hideResultList();
+ }else{
+ this.showResultList();
+ }
+ if( (this.autoComplete)&&
+ (results.length)&&
+ (!this._prev_key_backspace)&&
+ (this.textInputNode.value.length > 0)){
+ var cpos = this.getCaretPos(this.textInputNode);
+ // only try to extend if we added the last charachter at the end of the input
+ if((cpos+1) >= this.textInputNode.value.length){
+ this.textInputNode.value = results[0][0];
+ // build a new range that has the distance from the earlier
+ // caret position to the end of the first string selected
+ this.setSelectedRange(this.textInputNode, cpos, this.textInputNode.value.length);
+ }
+ }
+
+ var even = true;
+ while(results.length){
+ var tr = results.shift();
+ if(tr){
+ var td = document.createElement("div");
+ td.appendChild(document.createTextNode(tr[0]));
+ td.setAttribute("resultName", tr[0]);
+ td.setAttribute("resultValue", tr[1]);
+ td.className = "cbItem "+((even) ? "cbItemEven" : "cbItemOdd");
+ even = (!even);
+ this.optionsListNode.appendChild(td);
+ }
+ }
+
+ dojo.event.kwConnect({
+ once: true,
+ srcObj: dojo.html.body(),
+ srcFunc: "onclick",
+ adviceObj: this,
+ adviceFunc: "hideResultList"
+ });
+
+ // prevent IE bleed through
+ dojo.lang.setTimeout(this, "showBackgroundIframe", 100);
+ },
+
+ showBackgroundIframe: function(){
+ var w = dojo.style.getOuterWidth(this.optionsListNode);
+ var h = dojo.style.getOuterHeight(this.optionsListNode);
+ if ( isNaN(w) || isNaN(h) ){
+ // need more time to calculate size
+ dojo.lang.setTimeout(this, "showBackgroundIframe", 100);
+ return;
+ }
+ this.bgIframe.show([0,0,w,h]);
+ this.bgIframe.setZIndex(1);
+ },
+
+ selectOption: function(evt){
+ if(!evt){
+ evt = { target: this._highlighted_option };
+ }
+
+ if(!dojo.dom.isDescendantOf(evt.target, this.optionsListNode)){
+ return;
+ }
+
+ var tgt = evt.target;
+ while((tgt.nodeType!=1)||(!tgt.getAttribute("resultName"))){
+ tgt = tgt.parentNode;
+ if(tgt === dojo.html.body()){
+ return false;
+ }
+ }
+
+ this.textInputNode.value = tgt.getAttribute("resultName");
+ this.selectedResult = [tgt.getAttribute("resultName"), tgt.getAttribute("resultValue")];
+ this.setValue(tgt.getAttribute("resultName"));
+ this.comboBoxSelectionValue.value = tgt.getAttribute("resultValue");
+ this.hideResultList();
+ },
+
+ clearResultList: function(){
+ var oln = this.optionsListNode;
+ while(oln.firstChild){
+ oln.removeChild(oln.firstChild);
+ }
+ },
+
+ hideResultList: function(){
+ dojo.fx.fadeHide(this.optionsListNode, 200);
+ dojo.event.disconnect(dojo.html.body(), "onclick", this, "hideResultList");
+ this._result_list_open = false;
+ this.bgIframe.hide();
+ return;
+ },
+
+ showResultList: function(){
+ if(this._result_list_open){ return; }
+ with(this.optionsListNode.style){
+ display = "";
+ // visibility = "hidden";
+ height = "";
+ width = dojo.html.getInnerWidth(this.downArrowNode)+dojo.html.getInnerWidth(this.textInputNode)+"px";
+ if(dojo.render.html.khtml){
+ marginTop = dojo.html.totalOffsetTop(this.optionsListNode.parentNode)+"px";
+ }
+ }
+ dojo.html.setOpacity(this.optionsListNode, 0);
+ dojo.fx.fadeIn(this.optionsListNode, 200);
+ this._result_list_open = true;
+ },
+
+ handleArrowClick: function(){
+ if(this._result_list_open){
+ this.hideResultList();
+ }else{
+ this.startSearchFromInput();
+ }
+ },
+
+ startSearchFromInput: function(){
+ this.startSearch(this.textInputNode.value);
+ },
+
+ postCreate: function(){
+ dojo.event.connect(this, "startSearch", this.dataProvider, "startSearch");
+ dojo.event.connect(this.dataProvider, "provideSearchResults", this, "openResultList");
+ var s = dojo.widget.html.stabile.getState(this.widgetId);
+ if (s) {
+ this.setState(s);
+ }
+ }
+
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Container.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Container.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Container.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Container.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,46 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.Container");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.Container");
+
+dojo.widget.html.Container = function(){
+ dojo.widget.HtmlWidget.call(this);
+}
+
+dojo.inherits(dojo.widget.html.Container, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.Container, {
+ widgetType: "Container",
+
+ isContainer: true,
+ containerNode: null,
+ domNode: null,
+
+ onResized: function() {
+ // Clients should override this function to do special processing,
+ // then call this.notifyChildrenOfResize() to notify children of resize
+ this.notifyChildrenOfResize();
+ },
+
+ notifyChildrenOfResize: function() {
+ for(var i=0; i<this.children.length; i++) {
+ var child = this.children[i];
+ //dojo.debug(this.widgetId + " resizing child " + child.widgetId);
+ if ( child.onResized ) {
+ child.onResized();
+ }
+ }
+ }
+});
+
+dojo.widget.tags.addParseTreeHandler("dojo:Container");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContentPane.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContentPane.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContentPane.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContentPane.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,127 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.ContentPane");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.Container");
+dojo.require("dojo.widget.ContentPane");
+
+dojo.widget.html.ContentPane = function(){
+ dojo.widget.html.Container.call(this);
+}
+dojo.inherits(dojo.widget.html.ContentPane, dojo.widget.html.Container);
+
+dojo.lang.extend(dojo.widget.html.ContentPane, {
+ widgetType: "ContentPane",
+
+ href: "",
+ extractContent: true,
+ parseContent: true,
+ cacheContent: true,
+
+ // To generate pane content from a java function
+ handler: "",
+
+ postCreate: function(args, frag, parentComp){
+ if ( this.handler != "" ){
+ this.setHandler(this.handler);
+ }
+ },
+
+ onResized: function(){
+ if(this.isVisible()){
+ this.loadContents();
+ }
+ dojo.widget.html.ContentPane.superclass.onResized.call(this);
+ },
+
+ show: function(){
+ this.loadContents();
+ dojo.widget.html.ContentPane.superclass.show.call(this);
+ },
+
+ loadContents: function() {
+ if ( this.isLoaded ){
+ return;
+ }
+ this.isLoaded=true;
+ if ( dojo.lang.isFunction(this.handler)) {
+ this._runHandler();
+ } else if ( this.href != "" ) {
+ this._downloadExternalContent(this.href, this.cacheContent);
+ }
+ },
+
+ // Reset the (external defined) content of this pane
+ setUrl: function(url) {
+ this.href = url;
+ this.isLoaded = false;
+ if ( this.isVisible() ){
+ this.loadContents();
+ }
+ },
+
+ _downloadExternalContent: function(url, useCache) {
+ this.setContent("Loading...");
+
+ var self = this;
+ dojo.io.bind({
+ url: url,
+ useCache: useCache,
+ mimetype: "text/html",
+ handler: function(type, data, e) {
+ if(type == "load") {
+ if(self.extractContent) {
+ var matches = data.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
+ if(matches) { data = matches[1]; }
+ }
+ self.setContent.call(self, data);
+ } else {
+ self.setContent.call(self, "Error loading '" + url + "' (" + e.status + " " + e.statusText + ")");
+ }
+ }
+ });
+ },
+
+ setContent: function(data){
+ var node = this.containerNode || this.domNode;
+ node.innerHTML = data;
+ if(this.parseContent) {
+ var parser = new dojo.xml.Parse();
+ var frag = parser.parseElement(node, null, true);
+ dojo.widget.getParser().createComponents(frag);
+ this.onResized();
+ }
+ },
+
+ // Generate pane content from given java function
+ setHandler: function(handler) {
+ var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];
+ if(!dojo.lang.isFunction(fcn)) {
+ throw new Error("Unable to set handler, '" + handler + "' not a function.");
+ return;
+ }
+ this.handler = function() {
+ return fcn.apply(this, arguments);
+ }
+ },
+
+ _runHandler: function() {
+ if(dojo.lang.isFunction(this.handler)) {
+ this.handler(this, this.domNode);
+ return false;
+ }
+ return true;
+ }
+});
+
+dojo.widget.tags.addParseTreeHandler("dojo:ContentPane");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContextMenu.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContextMenu.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContextMenu.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContextMenu.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,166 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.ContextMenu");
+dojo.require("dojo.html");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.ContextMenu");
+dojo.require("dojo.lang");
+
+dojo.widget.html.ContextMenu = function(){
+ dojo.widget.ContextMenu.call(this);
+ dojo.widget.HtmlWidget.call(this);
+
+ this.isShowing = 0;
+ this.templatePath = dojo.uri.dojoUri("src/widget/templates/HtmlContextMenuTemplate.html");
+ this.templateCssPath = dojo.uri.dojoUri("src/widget/templates/Menu.css");
+
+ this.targetNodeIds = []; // fill this with nodeIds upon widget creation and it only responds to those nodes
+
+ // default event detection method
+ var eventType = "oncontextmenu";
+
+ var doc = document.documentElement || dojo.html.body();
+
+ var _blockHide = false;
+
+ this.fillInTemplate = function(args, frag){
+
+ var func = "onOpen";
+ var attached = false;
+
+ // connect with rightclick if oncontextmenu is not around
+ // NOTE: It would be very nice to have a dojo.event.browser.supportsEvent here
+ // NOTE: Opera does not have rightclick events, it is listed here only because
+ // it bails out when connecting with oncontextmenu event
+
+ if((dojo.render.html.khtml && !dojo.render.html.safari) || (dojo.render.html.opera)){
+ eventType = "onmousedown";
+ func = "_checkRightClick";
+ }
+
+ // attach event listeners to our selected nodes
+ for(var i=0; i<this.targetNodeIds.length; i++){
+ var node = document.getElementById(this.targetNodeIds[i]);
+ if(node){
+ dojo.event.connect(node, eventType, this, func);
+ attached = true;
+ }else{
+ // remove this nodeId
+ dj_debug("Couldent find "+this.targetNodeIds[i]+", cant do ContextMenu on this node");
+ this.targetNodeIds.splice(i,1);
+ }
+ }
+
+ // if we got attached to a node, hide on all non node contextevents
+ if(attached){ func = "_canHide"; }
+
+ dojo.event.connect(doc, eventType, this, func);
+ }
+
+ this.onOpen = function(evt){
+ // if (this.isShowing){ this.onHide(evt); } // propably not needed
+ this.isShowing = 1;
+
+ // if I do this, I cant preventDefault in khtml
+ //evt = dojo.event.browser.fixEvent(evt);
+
+ // stop default contextmenu, needed in khtml
+ if (evt.preventDefault){ evt.preventDefault(); }
+
+ // need to light up this one before we check width and height
+ this.domNode.style.left = "-9999px";
+ this.domNode.style.top = "-9999px";
+ this.domNode.style.display = "block";
+
+ // calculate if menu is going to apear within window
+ // or if its partially out of visable area
+ with(dojo.html){
+
+ var menuW = getInnerWidth(this.domNode);
+ var menuH = getInnerHeight(this.domNode);
+
+ var viewport = getViewportSize();
+ var scrolloffset = getScrollOffset();
+ }
+
+ var minX = viewport[0];
+ var minY = viewport[1];
+
+ var maxX = (viewport[0] + scrolloffset[0]) - menuW;
+ var maxY = (viewport[1] + scrolloffset[1]) - menuH;
+
+ var posX = evt.clientX + scrolloffset[0];
+ var posY = evt.clientY + scrolloffset[1];
+
+ if (posX > maxX){ posX = posX - menuW; }
+ if (posY > maxY){ posY = posY - menuH; }
+
+ this.domNode.style.left = posX + "px";
+ this.domNode.style.top = posY + "px";
+
+
+ // block the onclick that follows this particular right click
+ // not if the eventtrigger is documentElement and always when
+ // we use onmousedown hack
+ _blockHide = (evt.currentTarget!=doc || eventType=='onmousedown');
+
+ //return false; // we propably doesnt need to return false as we dont stop the event as we did before
+ }
+
+ /*
+ * _canHide is meant to block the onHide call that follows the event that triggered
+ * onOpen. This is (hopefully) faster that event.connect and event.disconnect every
+ * time the code executes and it makes connecting with onmousedown event possible
+ * and we dont have to stop the event from bubbling further.
+ *
+ * this code is moved into a separete function because it makes it possible for the
+ * user to connect to a onHide event, if anyone would like that.
+ */
+
+ this._canHide = function(evt){
+ // block the onclick that follows the same event that turn on contextmenu
+ if(_blockHide){
+ // the onclick check is needed to prevent displaying multiple
+ // menus when we have 2 or more contextmenus loaded and are using
+ // the onmousedown hack
+ if(evt.type=='click' || eventType=='oncontextmenu'){
+ _blockHide = false;
+ return;
+ }else{
+ return;
+ }
+ }
+
+ this.onHide(evt);
+ }
+
+ this.onHide = function(evt){
+ // FIXME: use whatever we use to do more general style setting?
+ this.domNode.style.display = "none";
+ //dojo.event.disconnect(doc, "onclick", this, "onHide");
+ this.isShowing = 0;
+ }
+
+ // callback for rightclicks, needed for browsers that doesnt implement oncontextmenu, konqueror and more?
+ this._checkRightClick = function(evt){
+
+ // for some reason konq comes here even when we are not clicking on the attached nodes
+ // added check for targetnode
+ if (evt.button==2 && (this.targetNodeIds.length==0 || (evt.currentTarget.id!="" && dojo.lang.inArray(this.targetNodeIds, evt.currentTarget.id)))){
+
+ return this.onOpen(evt);
+ }
+ }
+
+ dojo.event.connect(doc, "onclick", this, "_canHide");
+}
+
+dojo.inherits(dojo.widget.html.ContextMenu, dojo.widget.HtmlWidget);
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DatePicker.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DatePicker.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DatePicker.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DatePicker.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,307 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.DatePicker");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.DatePicker");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html");
+
+/*
+ Some assumptions:
+ - I'm planning on always showing 42 days at a time, and we can scroll by week,
+ not just by month or year
+ - To get a sense of what month to highlight, I basically initialize on the
+ first Saturday of each month, since that will be either the first of two or
+ the second of three months being partially displayed, and then I work forwards
+ and backwards from that point.
+ Currently, I assume that dates are stored in the RFC 3339 format,
+ because I find it to be most human readable and easy to parse
+ http://www.faqs.org/rfcs/rfc3339.html: 2005-06-30T08:05:00-07:00
+ FIXME: scroll by week not yet implemented
+*/
+
+
+dojo.widget.html.DatePicker = function(){
+ dojo.widget.DatePicker.call(this);
+ dojo.widget.HtmlWidget.call(this);
+
+ var _this = this;
+ // today's date, JS Date object
+ this.today = "";
+ // selected date, JS Date object
+ this.date = "";
+ // rfc 3339 date
+ this.storedDate = "";
+ // date currently selected in the UI, stored in year, month, date in the format that will be actually displayed
+ this.currentDate = {};
+ // stored in year, month, date in the format that will be actually displayed
+ this.firstSaturday = {};
+ this.classNames = {
+ previous: "previousMonth",
+ current: "currentMonth",
+ next: "nextMonth",
+ currentDate: "currentDate",
+ selectedDate: "selectedItem"
+ }
+
+ this.templatePath = dojo.uri.dojoUri("src/widget/templates/HtmlDatePicker.html");
+ this.templateCssPath = dojo.uri.dojoUri("src/widget/templates/HtmlDatePicker.css");
+
+ this.fillInTemplate = function(){
+ this.initData();
+ this.initUI();
+ }
+
+ this.initData = function() {
+ this.today = new Date();
+ if(this.storedDate && (this.storedDate.split("-").length > 2)) {
+ this.date = dojo.widget.DatePicker.util.fromRfcDate(this.storedDate);
+ } else {
+ this.date = this.today;
+ }
+ // calendar math is simplified if time is set to 0
+ this.today.setHours(0);
+ this.date.setHours(0);
+ var month = this.date.getMonth();
+ var tempSaturday = dojo.widget.DatePicker.util.initFirstSaturday(this.date.getMonth().toString(), this.date.getFullYear());
+ this.firstSaturday.year = tempSaturday.year;
+ this.firstSaturday.month = tempSaturday.month;
+ this.firstSaturday.date = tempSaturday.date;
+ }
+
+ this.setDate = function(rfcDate) {
+ this.storedDate = rfcDate;
+ }
+
+
+ this.initUI = function() {
+ this.selectedIsUsed = false;
+ this.currentIsUsed = false;
+ var currentClassName = "";
+ var previousDate = new Date();
+ var calendarNodes = this.calendarDatesContainerNode.getElementsByTagName("td");
+ var currentCalendarNode;
+ // set hours of date such that there is no chance of rounding error due to
+ // time change in local time zones
+ previousDate.setHours(8);
+ var nextDate = new Date(this.firstSaturday.year, this.firstSaturday.month, this.firstSaturday.date, 8);
+
+
+ if(this.firstSaturday.date < 7) {
+ // this means there are days to show from the previous month
+ var dayInWeek = 6;
+ for (var i=this.firstSaturday.date; i>0; i--) {
+ currentCalendarNode = calendarNodes.item(dayInWeek);
+ currentCalendarNode.innerHTML = nextDate.getDate();
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "current"));
+ dayInWeek--;
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, false);
+ }
+ for(var i=dayInWeek; i>-1; i--) {
+ currentCalendarNode = calendarNodes.item(i);
+ currentCalendarNode.innerHTML = nextDate.getDate();
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "previous"));
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, false);
+ }
+ } else {
+ nextDate.setDate(1);
+ for(var i=0; i<7; i++) {
+ currentCalendarNode = calendarNodes.item(i);
+ currentCalendarNode.innerHTML = i + 1;
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "current"));
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, true);
+ }
+ }
+ previousDate.setDate(this.firstSaturday.date);
+ previousDate.setMonth(this.firstSaturday.month);
+ previousDate.setFullYear(this.firstSaturday.year);
+ nextDate = this.incrementDate(previousDate, true);
+ var count = 7;
+ currentCalendarNode = calendarNodes.item(count);
+ while((nextDate.getMonth() == previousDate.getMonth()) && (count<42)) {
+ currentCalendarNode.innerHTML = nextDate.getDate();
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "current"));
+ currentCalendarNode = calendarNodes.item(++count);
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, true);
+ }
+
+ while(count < 42) {
+ currentCalendarNode.innerHTML = nextDate.getDate();
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "next"));
+ currentCalendarNode = calendarNodes.item(++count);
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, true);
+ }
+ this.setMonthLabel(this.firstSaturday.month);
+ this.setYearLabels(this.firstSaturday.year);
+ }
+
+ this.incrementDate = function(date, bool) {
+ // bool: true to increase, false to decrease
+ var time = date.getTime();
+ var increment = 1000 * 60 * 60 * 24;
+ time = (bool) ? (time + increment) : (time - increment);
+ var returnDate = new Date();
+ returnDate.setTime(time);
+ return returnDate;
+ }
+
+ this.incrementWeek = function(date, bool) {
+ dojo.unimplemented('dojo.widget.html.DatePicker.incrementWeek');
+ }
+
+ this.incrementMonth = function(date, bool) {
+ dojo.unimplemented('dojo.widget.html.DatePicker.incrementMonth');
+ }
+
+ this.incrementYear = function(date, bool) {
+ dojo.unimplemented('dojo.widget.html.DatePicker.incrementYear');
+ }
+
+ this.onIncrementDate = function(evt) {
+ dojo.unimplemented('dojo.widget.html.DatePicker.onIncrementDate');
+ }
+
+ this.onIncrementWeek = function(evt) {
+ // FIXME: should make a call to incrementWeek when that is implemented
+ evt.stopPropagation();
+ dojo.unimplemented('dojo.widget.html.DatePicker.onIncrementWeek');
+ switch(evt.target) {
+ case this.increaseWeekNode:
+ break;
+ case this.decreaseWeekNode:
+ break;
+ }
+ }
+
+ this.onIncrementMonth = function(evt) {
+ // FIXME: should make a call to incrementMonth when that is implemented
+ evt.stopPropagation();
+ var month = this.firstSaturday.month;
+ var year = this.firstSaturday.year;
+ switch(evt.currentTarget) {
+ case this.increaseMonthNode:
+ if(month < 11) {
+ month++;
+ } else {
+ month = 0;
+ year++;
+
+ this.setYearLabels(year);
+ }
+ break;
+ case this.decreaseMonthNode:
+ if(month > 0) {
+ month--;
+ } else {
+ month = 11;
+ year--;
+ this.setYearLabels(year);
+ }
+ break;
+ case this.increaseMonthNode.getElementsByTagName("img").item(0):
+ if(month < 11) {
+ month++;
+ } else {
+ month = 0;
+ year++;
+ this.setYearLabels(year);
+ }
+ break;
+ case this.decreaseMonthNode.getElementsByTagName("img").item(0):
+ if(month > 0) {
+ month--;
+ } else {
+ month = 11;
+ year--;
+ this.setYearLabels(year);
+ }
+ break;
+ }
+ var tempSaturday = dojo.widget.DatePicker.util.initFirstSaturday(month.toString(), year);
+ this.firstSaturday.year = tempSaturday.year;
+ this.firstSaturday.month = tempSaturday.month;
+ this.firstSaturday.date = tempSaturday.date;
+ this.initUI();
+ }
+
+ this.onIncrementYear = function(evt) {
+ // FIXME: should make a call to incrementYear when that is implemented
+ evt.stopPropagation();
+ var year = this.firstSaturday.year;
+ switch(evt.target) {
+ case this.nextYearLabelNode:
+ year++;
+ break;
+ case this.previousYearLabelNode:
+ year--;
+ break;
+ }
+ var tempSaturday = dojo.widget.DatePicker.util.initFirstSaturday(this.firstSaturday.month.toString(), year);
+ this.firstSaturday.year = tempSaturday.year;
+ this.firstSaturday.month = tempSaturday.month;
+ this.firstSaturday.date = tempSaturday.date;
+ this.initUI();
+ }
+
+ this.setMonthLabel = function(monthIndex) {
+ this.monthLabelNode.innerHTML = this.months[monthIndex];
+ }
+
+ this.setYearLabels = function(year) {
+ this.previousYearLabelNode.innerHTML = year - 1;
+ this.currentYearLabelNode.innerHTML = year;
+ this.nextYearLabelNode.innerHTML = year + 1;
+ }
+
+ this.getDateClassName = function(date, monthState) {
+ var currentClassName = this.classNames[monthState];
+ if ((!this.selectedIsUsed) && (date.getDate() == this.date.getDate()) && (date.getMonth() == this.date.getMonth()) && (date.getFullYear() == this.date.getFullYear())) {
+ currentClassName = this.classNames.selectedDate + " " + currentClassName;
+ this.selectedIsUsed = 1;
+ }
+ if((!this.currentIsUsed) && (date.getDate() == this.today.getDate()) && (date.getMonth() == this.today.getMonth()) && (date.getFullYear() == this.today.getFullYear())) {
+ currentClassName = currentClassName + " " + this.classNames.currentDate;
+ this.currentIsUsed = 1;
+ }
+ return currentClassName;
+ }
+
+ this.onClick = function(evt) {
+ dojo.event.browser.stopEvent(evt)
+ }
+
+ this.onSetDate = function(evt) {
+ dojo.event.browser.stopEvent(evt);
+ this.selectedIsUsed = 0;
+ this.todayIsUsed = 0;
+ var month = this.firstSaturday.month;
+ var year = this.firstSaturday.year;
+ if (dojo.html.hasClass(evt.target, this.classNames["next"])) {
+ month = ++month % 12;
+ // if month is now == 0, add a year
+ year = (month==0) ? ++year : year;
+ } else if (dojo.html.hasClass(evt.target, this.classNames["previous"])) {
+ month = --month % 12;
+ // if month is now == 0, add a year
+ year = (month==11) ? --year : year;
+ }
+ this.date = new Date(year, month, evt.target.innerHTML);
+ this.setDate(dojo.widget.DatePicker.util.toRfcDate(this.date));
+ this.initUI();
+ }
+}
+dojo.inherits(dojo.widget.html.DatePicker, dojo.widget.HtmlWidget);
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DebugConsole.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DebugConsole.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DebugConsole.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DebugConsole.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,32 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.DebugConsole");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.FloatingPane");
+
+// Collection of widgets in a bar, like Windows task bar
+dojo.widget.html.DebugConsole= function(){
+
+ dojo.widget.html.FloatingPane.call(this);
+ dojo.widget.DebugConsole.call(this);
+}
+
+dojo.inherits(dojo.widget.html.DebugConsole, dojo.widget.html.FloatingPane);
+
+dojo.lang.extend(dojo.widget.html.DebugConsole, {
+ postCreate: function() {
+ dojo.widget.html.DebugConsole.superclass.postCreate.call(this);
+ this.clientPane.domNode.id = "debugConsoleClientPane"
+ djConfig.isDebug = true;
+ djConfig.debugContainerId = this.clientPane.domNode.id;
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DropdownButton.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DropdownButton.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DropdownButton.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DropdownButton.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,188 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+/* TODO:
+ * - make the dropdown "smart" so it can't get cutoff on bottom of page, sides of page, etc.
+ */
+
+dojo.provide("dojo.widget.html.DropdownButton");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.uri.Uri");
+dojo.require("dojo.dom");
+dojo.require("dojo.style");
+dojo.require("dojo.html");
+
+dojo.widget.html.DropdownButton = function() {
+ // mix in the button properties
+ dojo.widget.DropdownButton.call(this);
+ dojo.widget.HtmlWidget.call(this);
+}
+
+dojo.inherits(dojo.widget.html.DropdownButton, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.DropdownButton, {
+
+ // In IE, event handlers on objects inside buttons don't work correctly, so
+ // we just set onClick on the button itself.
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlDropDownButtonTemplate.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlButtonTemplate.css"),
+
+ // attach points
+ button: null,
+ table: null,
+ labelCell: null,
+ borderCell: null,
+ arrowCell: null,
+ arrow: null,
+
+ fillInTemplate: function(args, frag) {
+ // input data (containing the anchor for the button itself, plus the
+ // thing to display when you push the down arrow)
+ var input = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+
+ // Recursively expand widgets inside of the <dojo:dropdownButton>
+ var parser = new dojo.xml.Parse();
+ var frag = parser.parseElement(input, null, true);
+ var ary = dojo.widget.getParser().createComponents(frag);
+
+ this.a = dojo.dom.getFirstChildElement(input); // the button contents
+ this.menu = dojo.dom.getNextSiblingElement(this.a); // the menu under the button
+
+ this.disabled = dojo.html.hasClass(this.a, "disabled");
+ if( this.disabled ) {
+ dojo.html.addClass(this.button, "dojoDisabled");
+ this.domNode.setAttribute("disabled", "true");
+ }
+
+ dojo.html.disableSelection(this.a);
+ this.a.style["text-decoration"]="none";
+ this.labelCell.appendChild(this.a);
+
+ this.arrow.src =
+ dojo.uri.dojoUri("src/widget/templates/images/dropdownButtonsArrow" +
+ (this.disabled ? "-disabled" : "") + ".gif");
+
+ // Attach menu to body so that it appears above other buttons
+ this.menu.style.position="absolute";
+ this.menu.style.display="none";
+ this.menu.style["z-index"] = 99;
+ dojo.html.body().appendChild(this.menu);
+ },
+
+ postCreate: function() {
+ if ( dojo.render.html.ie ) {
+ // Compensate for IE's weird padding of button content, which seems to be relative
+ // to the length of the content
+ var contentWidth = dojo.style.getOuterWidth(this.table);
+ this.labelCell.style["left"] = "-" + (contentWidth / 10) + "px";
+ this.arrowCell.style["left"] = (contentWidth / 10) + "px";
+ }
+
+ // Make menu at least as wide as the button
+ var buttonWidth = dojo.style.getOuterWidth(this.button);
+ var menuWidth = dojo.style.getOuterWidth(this.menu);
+ if ( buttonWidth > menuWidth ) {
+ dojo.style.setOuterWidth(this.menu, buttonWidth);
+ }
+ },
+
+ // If someone clicks anywhere else on the screen (including another menu),
+ // then close this menu.
+ onCanvasMouseDown: function(e) {
+ if( !dojo.dom.isDescendantOf(e.target, this.button) &&
+ !dojo.dom.isDescendantOf(e.target, this.menu) ) {
+ this.hideMenu();
+ }
+ },
+
+ eventWasOverArrow: function(e) {
+ // want to use dojo.html.overElement() but also need to detect clicks
+ // on the area between the arrow and the edge of the button
+ var eventX = e.clientX;
+ var borderX = dojo.style.totalOffsetLeft(this.borderCell);
+ return (eventX > borderX );
+ },
+
+ onMouseOver: function(e) {
+ dojo.html.addClass(this.button, "dojoButtonHover");
+ dojo.html.removeClass(this.button, "dojoButtonNoHover");
+ },
+
+ onMouseOut: function(e) {
+ dojo.html.removeClass(this.button, "dojoButtonHover");
+ dojo.html.addClass(this.button, "dojoButtonNoHover");
+ },
+
+ onClick: function(e) {
+ if ( this.eventWasOverArrow(e) ) {
+ this._onClickArrow();
+ } else {
+ this._onClickButton();
+ }
+ },
+
+ // Action when the user presses the button
+ _onClickButton: function(e) {
+ if ( this.a ) {
+ if ( this.a.click ) {
+ this.a.click();
+ } else if ( this.a.href ) {
+ location.href = this.a.href;
+ }
+ }
+ },
+
+ // Action when user presses the arrow
+ _onClickArrow: function() {
+ if ( this.menu.style.display == "none" ) {
+ this.showMenu();
+ } else {
+ this.hideMenu();
+ }
+ },
+
+ showMenu: function() {
+ if ( this.disabled )
+ return;
+
+ // Position it accordingly, relative to screen root (since
+ // it's attached to document.body)
+ this.menu.style.left = dojo.style.totalOffsetLeft(this.button) + "px";
+ this.menu.style.top = dojo.style.totalOffsetTop(this.button) + dojo.style.getOuterHeight(this.button) + "px";
+
+ // Display the menu; do this funky code below to stop the menu from extending
+ // all the way to the right edge of the screen.
+ // TODO: retest simple display="" to confirm that it doesn't work.
+ try {
+ this.menu.style.display="table"; // mozilla
+ } catch(e) {
+ this.menu.style.display="block"; // IE
+ }
+
+ // If someone clicks somewhere else on the screen then close the menu
+ dojo.event.connect(document.documentElement, "onmousedown", this, "onCanvasMouseDown");
+
+ // When someone clicks the menu, after the menu handles the event,
+ // close the menu (be careful not to close the menu too early or else
+ // the menu will never receive the event.)
+ dojo.event.connect(this.menu, "onclick", this, "hideMenu");
+ },
+
+ hideMenu: function() {
+ this.menu.style.display = "none";
+ dojo.event.disconnect(document.documentElement, "onmousedown", this, "onCanvasMouseDown");
+ dojo.event.disconnect(this.menu, "onclick", this, "hideMenu");
+ }
+});
+
+
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LayoutPane.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LayoutPane.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LayoutPane.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LayoutPane.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,418 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.LayoutPane");
+dojo.provide("dojo.widget.html.LayoutPane");
+
+//
+// this widget provides Delphi-style panel layout semantics
+// this is a good place to stash layout logic, then derive components from it
+//
+// TODO: allow more edge priority orders (e.g. t,r,l,b)
+// TODO: allow percentage sizing stuff
+//
+
+dojo.require("dojo.widget.LayoutPane");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.Container");
+dojo.require("dojo.html");
+dojo.require("dojo.style");
+dojo.require("dojo.dom");
+dojo.require("dojo.string");
+
+
+dojo.widget.html.LayoutPane = function(){
+ dojo.widget.html.Container.call(this);
+}
+
+dojo.inherits(dojo.widget.html.LayoutPane, dojo.widget.html.Container);
+
+dojo.lang.extend(dojo.widget.html.LayoutPane, {
+ widgetType: "LayoutPane",
+
+ isChild: false,
+
+ clientWidth: 0,
+ clientHeight: 0,
+
+ layoutChildPriority: 'top-bottom',
+
+ cssPath: dojo.uri.dojoUri("src/widget/templates/HtmlLayoutPane.css"),
+
+ // If this pane's content is external then set the url here
+ url: "inline",
+ extractContent: true,
+ parseContent: true,
+ cacheContent: true,
+
+ // To generate pane content from a java function
+ handler: "none",
+
+ minWidth: 0,
+ minHeight: 0,
+
+ fillInTemplate: function(){
+ this.filterAllowed(this, 'layoutChildPriority', ['left-right', 'top-bottom']);
+
+ // Need to include CSS manually because there is no template file/string
+ dojo.style.insertCssFile(this.cssPath, null, true);
+ dojo.html.addClass(this.domNode, "dojoLayoutPane");
+ },
+
+ postCreate: function(args, fragment, parentComp){
+ for(var i=0; i<this.children.length; i++){
+ this._injectChild(this.children[i]);
+ }
+
+ if ( this.handler != "none" ){
+ this.setHandler(this.handler);
+ }
+ if ( this.isVisible() ){
+ this.loadContents();
+ }
+ },
+
+ // If the pane contents are external then load them
+ loadContents: function() {
+ if ( this.isLoaded ){
+ return;
+ }
+ if ( dojo.lang.isFunction(this.handler)) {
+ this._runHandler();
+ } else if ( this.url != "inline" ) {
+ this._downloadExternalContent(this.url, this.cacheContent);
+ }
+ this.isLoaded=true;
+ },
+
+ // Reset the (external defined) content of this pane
+ setUrl: function(url) {
+ this.url = url;
+ this.isLoaded = false;
+ if ( this.isVisible() ){
+ this.loadContents();
+ }
+ },
+
+ _downloadExternalContent: function(url, useCache) {
+ dojo.deprecated("LayoutPane url parameter.", "use LinkPane to download from a URL", "0.4");
+ //dojo.debug(this.widgetId + " downloading " + url);
+ var node = this.containerNode || this.domNode;
+ node.innerHTML = "Loading...";
+
+ var extract = this.extractContent;
+ var parse = this.parseContent;
+ var self = this;
+
+ dojo.io.bind({
+ url: url,
+ useCache: useCache,
+ mimetype: "text/html",
+ handler: function(type, data, e) {
+ if(type == "load") {
+ if(extract) {
+ var matches = data.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
+ if(matches) { data = matches[1]; }
+ }
+ node.innerHTML = data;
+ if(parse) {
+ var parser = new dojo.xml.Parse();
+ var frag = parser.parseElement(node, null, true);
+ dojo.widget.getParser().createComponents(frag);
+ }
+ self.onResized();
+ } else {
+ node.innerHTML = "Error loading '" + url + "' (" + e.status + " " + e.statusText + ")";
+ }
+ }
+ });
+ },
+
+ // Generate pane content from given java function
+ setHandler: function(handler) {
+ var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];
+ if(!dojo.lang.isFunction(fcn)) {
+ throw new Error("Unable to set handler, '" + handler + "' not a function.");
+ return;
+ }
+ this.handler = function() {
+ return fcn.apply(this, arguments);
+ }
+ },
+
+ _runHandler: function() {
+ if(dojo.lang.isFunction(this.handler)) {
+ dojo.deprecated("use LinkPane to download content from a java function", "0.4");
+ this.handler(this, this.domNode);
+ return false;
+ }
+ return true;
+ },
+
+ filterAllowed: function(node, param, values){
+ if ( !dojo.lang.inArray(values, node[param]) ) {
+ node[param] = values[0];
+ }
+ },
+
+ layoutChildren: function(){
+ // find the children to arrange
+
+ var kids = {'left':[], 'right':[], 'top':[], 'bottom':[], 'client':[], 'flood':[]};
+ var hits = 0;
+
+ for(var i=0; i<this.children.length; i++){
+ if (this.hasLayoutAlign(this.children[i])){
+ kids[this.children[i].layoutAlign].push(this.children[i]);
+ hits++;
+ }
+ }
+
+ if (!hits){
+ return;
+ }
+
+ var container = this.containerNode || this.domNode;
+
+ // calc layout space
+
+ this.clientWidth = dojo.style.getContentWidth(container);
+ this.clientHeight = dojo.style.getContentHeight(container);
+
+ // note: don't setup clientRect as a member of the prototype because that
+ // would make the contents shared between instances
+ this.clientRect={};
+ this.clientRect['left'] = dojo.style.getPixelValue(container, "padding-left", true);
+ this.clientRect['right'] = dojo.style.getPixelValue(container, "padding-right", true);
+ this.clientRect['top'] = dojo.style.getPixelValue(container, "padding-top", true);
+ this.clientRect['bottom'] = dojo.style.getPixelValue(container, "padding-bottom", true);
+
+ // arrange them in order
+ this._layoutCenter(kids, "flood");
+ if (this.layoutChildPriority == 'top-bottom'){
+ this._layoutFloat(kids, "top");
+ this._layoutFloat(kids, "bottom");
+ this._layoutFloat(kids, "left");
+ this._layoutFloat(kids, "right");
+ }else{
+ this._layoutFloat(kids, "left");
+ this._layoutFloat(kids, "right");
+ this._layoutFloat(kids, "top");
+ this._layoutFloat(kids, "bottom");
+ }
+ this._layoutCenter(kids, "client");
+ },
+
+ // Position the left/right/top/bottom aligned elements
+ _layoutFloat: function(kids, position){
+ var ary = kids[position];
+
+ // figure out which two of the left/right/top/bottom properties to set
+ var lr = (position=="right")?"right":"left";
+ var tb = (position=="bottom")?"bottom":"top";
+
+ for(var i=0; i<ary.length; i++){
+ var elm=ary[i];
+
+ // set two of left/right/top/bottom properties
+ elm.domNode.style[lr]=this.clientRect[lr] + "px";
+ elm.domNode.style[tb]=this.clientRect[tb] + "px";
+
+ // adjust record of remaining space
+ if ( (position=="top")||(position=="bottom") ) {
+ dojo.style.setOuterWidth(elm.domNode, this.clientWidth);
+ var height = dojo.style.getOuterHeight(elm.domNode);
+ this.clientHeight -= height;
+ this.clientRect[position] += height;
+ } else {
+ dojo.style.setOuterHeight(elm.domNode, this.clientHeight);
+ var width = dojo.style.getOuterWidth(elm.domNode);
+ this.clientWidth -= width;
+ this.clientRect[position] += width;
+ }
+ }
+ },
+
+ // Position elements into the remaining space (in the center)
+ // If multiple elements are present they overlap each other
+ _layoutCenter: function(kids, position){
+ var ary = kids[position];
+ for(var i=0; i<ary.length; i++){
+ var elm=ary[i];
+ elm.domNode.style.left=this.clientRect.left + "px";
+ elm.domNode.style.top=this.clientRect.top + "px";
+ dojo.style.setOuterWidth(elm.domNode, this.clientWidth);
+ dojo.style.setOuterHeight(elm.domNode, this.clientHeight);
+ }
+
+ },
+
+ hasLayoutAlign: function(child){
+ return dojo.lang.inArray(['left','right','top','bottom','client', 'flood'], child.layoutAlign);
+ },
+
+ addChild: function(child, overrideContainerNode, pos, ref, insertIndex){
+ this._injectChild(child);
+ dojo.widget.html.LayoutPane.superclass.addChild.call(this, child, overrideContainerNode, pos, ref, insertIndex);
+ this.resizeSoon();
+ },
+
+ _injectChild: function(child){
+ if ( this.hasLayoutAlign(child) ){
+ child.domNode.style.position = 'absolute';
+ child.isChild = true;
+ this.filterAllowed(child, 'layoutAlign', ['none', 'left', 'top', 'right', 'bottom', 'client', 'flood']);
+ dojo.html.addClass(child.domNode, "dojoAlign" + dojo.string.capitalize(child.layoutAlign));
+ }
+ },
+
+ removeChild: function(pane){
+ dojo.widget.html.LayoutPane.superclass.removeChild.call(this,pane);
+ dojo.dom.removeNode(pane.domNode);
+ this.resizeSoon();
+ },
+
+ onResized: function(){
+ if ( !this.isVisible() ) {
+ return;
+ }
+
+ //dojo.debug(this.widgetId + ": resized");
+
+ // set position/size for my children
+ this.layoutChildren();
+
+ // notify children that they have been moved/resized
+ this.notifyChildrenOfResize();
+ },
+
+ resizeTo: function(w, h){
+
+ w = Math.max(w, this.getMinWidth());
+ h = Math.max(h, this.getMinHeight());
+
+ dojo.style.setOuterWidth(this.domNode, w);
+ dojo.style.setOuterHeight(this.domNode, h);
+ this.onResized();
+ },
+
+ show: function(){
+ // If this is the first time we are displaying this object,
+ // and the contents are external, then download them.
+ this.loadContents();
+
+ // If this node was created while display=="none" then it
+ // hasn't been laid out yet. Do that now.
+ this.domNode.style.display="";
+ this.onResized();
+ this.domNode.style.display="none";
+ this.domNode.style.visibility="";
+
+ dojo.widget.html.LayoutPane.superclass.show.call(this);
+ },
+
+ getMinWidth: function(){
+
+ //
+ // we need to first get the cumulative width
+ //
+
+ var w = this.minWidth;
+
+ if ((this.layoutAlign == 'left') || (this.layoutAlign == 'right')){
+
+ w = dojo.style.getOuterWidth(this.domNode);
+ }
+
+ for(var i=0; i<this.children.length; i++){
+ var ch = this.children[i];
+ var a = ch.layoutAlign;
+
+ if ((a == 'left') || (a == 'right') || (a == 'client')){
+
+ if (dojo.lang.isFunction(ch.getMinWidth)){
+ w += ch.getMinWidth();
+ }
+ }
+ }
+
+ //
+ // but then we need to check to see if the top/bottom kids are larger
+ //
+
+ for(var i=0; i<this.children.length; i++){
+ var ch = this.children[i];
+ var a = ch.layoutAlign;
+
+ if ((a == 'top') || (a == 'bottom')){
+
+ if (dojo.lang.isFunction(ch.getMinWidth)){
+ w = Math.max(w, ch.getMinWidth());
+ }
+ }
+ }
+
+ return w;
+ },
+
+ getMinHeight: function(){
+
+ //
+ // we need to first get the cumulative height
+ //
+
+ var h = this.minHeight;
+
+ if ((this.layoutAlign == 'top') || (this.layoutAlign == 'bottom')){
+
+ h = dojo.style.getOuterHeight(this.domNode);
+ }
+
+ for(var i=0; i<this.children.length; i++){
+ var ch = this.children[i];
+ var a = ch.layoutAlign;
+
+ if ((a == 'top') || (a == 'bottom') || (a == 'client')){
+
+ if (dojo.lang.isFunction(ch.getMinHeight)){
+ h += ch.getMinHeight();
+ }
+ }
+ }
+
+ //
+ // but then we need to check to see if the left/right kids are larger
+ //
+
+ for(var i=0; i<this.children.length; i++){
+ var ch = this.children[i];
+ var a = ch.layoutAlign;
+
+ if ((a == 'left') || (a == 'right')){
+
+ if (dojo.lang.isFunction(ch.getMinHeight)){
+ h = Math.max(h, ch.getMinHeight());
+ }
+ }
+ }
+
+ return h;
+ }
+});
+
+// This arguments can be specified for the children of a LayoutPane.
+// Since any widget can be specified as a LayoutPane child, mix it
+// into the base widget class. (This is a hack, but it's effective.)
+dojo.lang.extend(dojo.widget.Widget, {
+ layoutAlign: 'none'
+});
+
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LinkPane.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LinkPane.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LinkPane.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LinkPane.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,55 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.LinkPane");
+dojo.provide("dojo.widget.html.LinkPane");
+
+//
+// a div that loads from a URL. (Similar to an iframe, but
+// it's in the same environment as the main window)
+//
+
+dojo.require("dojo.widget.LinkPane");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.ContentPane");
+dojo.require("dojo.html");
+dojo.require("dojo.style");
+dojo.require("dojo.dom");
+dojo.require("dojo.string");
+
+
+dojo.widget.html.LinkPane = function(){
+ dojo.widget.html.ContentPane.call(this);
+}
+
+dojo.inherits(dojo.widget.html.LinkPane, dojo.widget.html.ContentPane);
+
+dojo.lang.extend(dojo.widget.html.LinkPane, {
+ widgetType: "LinkPane",
+
+ // I'm using a template because the user may specify the input as
+ // <a href="foo.html">label</a>, in which case we need to get rid of the
+ // <a> because we don't want a link.
+ templateString: '<div class="dojoLinkPane"></div>',
+
+ fillInTemplate: function(args, frag){
+ var source = this.getFragNodeRef(frag);
+
+ // If user has specified node contents, they become the label
+ // (the link must be plain text)
+ this.label += source.innerHTML;
+
+ // Copy style info from input node to output node
+ this.domNode.style.cssText = source.style.cssText;
+ dojo.html.addClass(this.domNode, dojo.html.getClass(source));
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Menu.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Menu.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Menu.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Menu.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,51 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.require("dojo.widget.Menu");
+dojo.provide("dojo.widget.html.Menu");
+
+/* HtmlMenu
+ ***********/
+
+dojo.widget.html.Menu = function(){
+ dojo.widget.html.Menu.superclass.constructor.call(this);
+ this.items = [];
+}
+dojo.inherits(dojo.widget.html.Menu, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.Menu, {
+ widgetType: "Menu",
+ isContainer: true,
+
+ // copy children widgets output directly to parent (this node), to avoid
+ // errors trying to insert an <li> under a <div>
+ snarfChildDomOutput: true,
+
+ templateString: '<ul></ul>',
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/Menu.css"),
+
+ fillInTemplate: function (args, frag){
+ //dojo.widget.HtmlMenu.superclass.fillInTemplate.apply(this, arguments);
+ this.domNode.className = "dojoMenu";
+ },
+
+
+ _register: function (item ) {
+ dojo.event.connect(item, "onSelect", this, "onSelect");
+ this.items.push(item);
+ },
+
+ push: function (item) {
+ this.domNode.appendChild(item.domNode);
+ this._register(item);
+ }
+
+});
+
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,60 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.MenuItem");
+
+/* HtmlMenuItem
+ ***************/
+
+dojo.widget.html.MenuItem = function(){
+ dojo.widget.HtmlWidget.call(this);
+}
+dojo.inherits(dojo.widget.html.MenuItem, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.MenuItem, {
+ widgetType: "MenuItem",
+ templateString: '<li class="dojoMenuItem" dojoAttachEvent="onMouseOver; onMouseOut; onMouseDown; onMouseUp; onClick;"></li>',
+ title: "",
+
+ fillInTemplate: function(args, frag){
+ dojo.html.disableSelection(this.domNode);
+
+ if(!dojo.string.isBlank(this.title)){
+ this.domNode.appendChild(document.createTextNode(this.title));
+ }else{
+ this.domNode.appendChild(frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"]);
+ }
+ },
+
+ onMouseOver: function(e){
+ dojo.html.addClass(this.domNode, "dojoMenuItemHover");
+ },
+
+ onMouseOut: function(e){
+ dojo.html.removeClass(this.domNode, "dojoMenuItemHover");
+ },
+
+ onClick: function(e){ this.onSelect(this, e); },
+ onMouseDown: function(e){},
+ onMouseUp: function(e){},
+
+ // By default, when I am clicked, click the item inside of me
+ onSelect: function (item, e) {
+ var child = dojo.dom.getFirstChildElement(this.domNode);
+ if(child){
+ if(child.click){
+ child.click();
+ }else if(child.href){
+ location.href = child.href;
+ }
+ }
+ }
+});
+