You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sv...@apache.org on 2006/11/10 10:15:40 UTC
svn commit: r473277 [37/45] - in
/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource:
./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/
src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/...
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Spinner.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Spinner.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Spinner.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Spinner.js Fri Nov 10 01:15:01 2006
@@ -9,72 +9,320 @@
*/
dojo.provide("dojo.widget.Spinner");
-dojo.provide("dojo.widget.AdjustableIntegerTextbox");
-dojo.require("dojo.widget.validate.IntegerTextbox");
+dojo.require("dojo.io.*");
+dojo.require("dojo.lfx.*");
+dojo.require("dojo.html.*");
+dojo.require("dojo.html.layout");
+dojo.require("dojo.string");
dojo.require("dojo.widget.*");
-dojo.require("dojo.event.*");
+dojo.require("dojo.widget.IntegerTextbox");
+dojo.require("dojo.widget.RealNumberTextbox");
+dojo.require("dojo.widget.DateTextbox");
+
+dojo.require("dojo.experimental");
+
+// summary: Mixin for validation widgets with a spinner
+// description: This class basically (conceptually) extends dojo.widget.ValidationTextbox.
+// It modifies the template to have up/down arrows, and provides related handling code.
+dojo.declare(
+ "dojo.widget.Spinner",
+ null,
+ {
+ _typamaticTimer: null,
+ _typamaticFunction: null,
+ _currentTimeout: this.defaultTimeout,
+ _eventCount: 0,
+ // Number
+ // number of milliseconds before a held key or button becomes typematic
+ defaultTimeout: 500,
+ // Number
+ // fraction of time used to change the typematic timer between events
+ // 1.0 means that each typematic event fires at defaultTimeout intervals
+ // < 1.0 means that each typematic event fires at an increasing faster rate
+ timeoutChangeRate: 0.90,
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Spinner.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/Spinner.css"),
+ // String
+ // up arrow graphic URL
+ incrementSrc: dojo.uri.dojoUri("src/widget/templates/images/spinnerIncrement.gif"),
+ // String
+ // down arrow graphic URL
+ decrementSrc: dojo.uri.dojoUri("src/widget/templates/images/spinnerDecrement.gif"),
+
+ // does the keyboard related stuff
+ _handleKeyEvents: function(/*Event*/ evt){
+ if(!evt.key){ return; }
+
+ if(!evt.ctrlKey && !evt.altKey){
+ switch(evt.key){
+ case evt.KEY_DOWN_ARROW:
+ dojo.event.browser.stopEvent(evt);
+ this._downArrowPressed(evt);
+ return;
+ case evt.KEY_UP_ARROW:
+ dojo.event.browser.stopEvent(evt);
+ this._upArrowPressed(evt);
+ return;
+ }
+ }
+ this._eventCount++;
+ },
-/*
- ****** AdjustableIntegerTextbox ******
+ _onSpinnerKeyUp: function(/*Event*/ evt){
+ this._arrowReleased(evt);
+ this.onkeyup(evt);
+ },
+
+ // reset button size; this function is called when the input area has changed size
+ _resize: function(){
+ var inputSize = dojo.html.getBorderBox(this.textbox);
+ this.buttonSize = { width: inputSize.height / 2, height: inputSize.height / 2 };
+ if(this.upArrowNode){
+ dojo.html.setMarginBox(this.upArrowNode, this.buttonSize);
+ dojo.html.setMarginBox(this.downArrowNode, this.buttonSize);
+ }
+ },
- A subclass of IntegerTextbox.
-*/
-dojo.widget.AdjustableIntegerTextbox = function(node) {
- // this property isn't a primitive and needs to be created on a per-item basis.
- this.flags = {};
-}
-dojo.inherits(dojo.widget.AdjustableIntegerTextbox, dojo.widget.validate.IntegerTextbox);
-dojo.lang.extend(dojo.widget.AdjustableIntegerTextbox, {
- // new subclass properties
- widgetType: "AdjustableIntegerTextbox",
- delta: "1",
-
- adjustValue: function(direction, x){
- var val = this.getValue().replace(/[^\-+\d]/g, "");
- if(val.length == 0){ return; }
+ _pressButton: function(/*DomNode*/ node){
+ node.style.borderWidth = "1px 0px 0px 1px";
+ node.style.borderStyle = "inset";
+ },
+
+ _releaseButton: function(/*DomNode*/ node){
+ node.style.borderWidth = "0px 1px 1px 0px";
+ node.style.borderStyle = "outset";
+ },
+
+ _arrowPressed: function(/*Event*/ evt, /*Number*/ direction){
+ var nodePressed = (direction == -1) ? this.downArrowNode : this.upArrowNode;
+ var nodeReleased = (direction == +1) ? this.downArrowNode : this.upArrowNode;
+ if(typeof evt != "number"){
+ if(this._typamaticTimer != null){
+ if(this._typamaticNode == nodePressed){
+ return;
+ }
+ dojo.lang.clearTimeout(this._typamaticTimer);
+ }
+ this._releaseButton(nodeReleased);
+ this._eventCount++;
+ this._typamaticTimer = null;
+ this._currentTimeout = this.defaultTimeout;
+
+ }else if (evt != this._eventCount){
+ this._releaseButton(nodePressed);
+ return;
+ }
+ this._pressButton(nodePressed);
+ this._setCursorX(this.adjustValue(direction,this._getCursorX()));
+ this._typamaticNode = nodePressed;
+ this._typamaticTimer = dojo.lang.setTimeout(this, "_arrowPressed", this._currentTimeout, this._eventCount, direction);
+ this._currentTimeout = Math.round(this._currentTimeout * this.timeoutChangeRate);
+ },
+
+ _downArrowPressed: function(/*Event*/ evt){
+ return this._arrowPressed(evt,-1);
+ },
+
+ // IE sends these events when rapid clicking, mimic an extra single click
+ _downArrowDoubleClicked: function(/*Event*/ evt){
+ var rc = this._downArrowPressed(evt);
+ dojo.lang.setTimeout(this, "_arrowReleased", 50, null);
+ return rc;
+ },
+
+ _upArrowPressed: function(/*Event*/ evt){
+ return this._arrowPressed(evt,+1);
+ },
+
+ // IE sends these events when rapid clicking, mimic an extra single click
+ _upArrowDoubleClicked: function(/*Event*/ evt){
+ var rc = this._upArrowPressed(evt);
+ dojo.lang.setTimeout(this, "_arrowReleased", 50, null);
+ return rc;
+ },
+
+ _arrowReleased: function(/*Event*/ evt){
+ this.textbox.focus();
+ if(evt != null && typeof evt == "object" && evt.keyCode && evt.keyCode != null){
+ var keyCode = evt.keyCode;
+ var k = dojo.event.browser.keys;
+
+ switch(keyCode){
+ case k.KEY_DOWN_ARROW:
+ case k.KEY_UP_ARROW:
+ dojo.event.browser.stopEvent(evt);
+ break;
+ }
+ }
+ this._releaseButton(this.upArrowNode);
+ this._releaseButton(this.downArrowNode);
+ this._eventCount++;
+ if(this._typamaticTimer != null){
+ dojo.lang.clearTimeout(this._typamaticTimer);
+ }
+ this._typamaticTimer = null;
+ this._currentTimeout = this.defaultTimeout;
+ },
+
+ _mouseWheeled: function(/*Event*/ evt){
+ var scrollAmount = 0;
+ if(typeof evt.wheelDelta == 'number'){ // IE
+ scrollAmount = evt.wheelDelta;
+ }else if (typeof evt.detail == 'number'){ // Mozilla+Firefox
+ scrollAmount = -evt.detail;
+ }
+ if(scrollAmount > 0){
+ this._upArrowPressed(evt);
+ this._arrowReleased(evt);
+ }else if (scrollAmount < 0){
+ this._downArrowPressed(evt);
+ this._arrowReleased(evt);
+ }
+ },
- num = Math.min(Math.max((parseInt(val)+(parseInt(this.delta) * direction)), this.flags.min), this.flags.max);
- val = (new Number(num)).toString();
+ _discardEvent: function(/*Event*/ evt){
+ dojo.event.browser.stopEvent(evt);
+ },
+
+ _getCursorX: function(){
+ var x = -1;
+ try{
+ this.textbox.focus();
+ if (typeof this.textbox.selectionEnd == "number"){
+ x = this.textbox.selectionEnd;
+ }else if (document.selection && document.selection.createRange){
+ var range = document.selection.createRange().duplicate();
+ if(range.parentElement() == this.textbox){
+ range.moveStart('textedit', -1);
+ x = range.text.length;
+ }
+ }
+ }catch(e){ /* squelch! */ }
+ return x;
+ },
- if(num >= 0){
- val = ((this.flags.signed == true)?'+':' ')+val; // make sure first char is a nondigit
+ _setCursorX: function(/*Number*/ x){
+ try{
+ this.textbox.focus();
+ if(!x){ x = 0; }
+ if(typeof this.textbox.selectionEnd == "number"){
+ this.textbox.selectionEnd = x;
+ }else if(this.textbox.createTextRange){
+ var range = this.textbox.createTextRange();
+ range.collapse(true);
+ range.moveEnd('character', x);
+ range.moveStart('character', x);
+ range.select();
+ }
+ }catch(e){ /* squelch! */ }
+ },
+
+ _spinnerPostMixInProperties: function(/*Object*/ args, /*Object*/ frag){
+ // summary: the widget's postMixInProperties() method should call this method
+
+ // set image size before instantiating template;
+ // changing it aftwards doesn't work on FF
+ var inputNode = this.getFragNodeRef(frag);
+ var inputSize = dojo.html.getBorderBox(inputNode);
+ this.buttonSize = { width: inputSize.height / 2 - 1, height: inputSize.height / 2 - 1};
+ },
+
+ _spinnerPostCreate: function(/*Object*/ args, /*Object*/ frag){
+ // summary: the widget's postCreate() method should call this method
+
+ // extra listeners
+ if(this.textbox.addEventListener){
+ // dojo.event.connect() doesn't seem to work with DOMMouseScroll
+ this.textbox.addEventListener('DOMMouseScroll', dojo.lang.hitch(this, "_mouseWheeled"), false); // Mozilla + Firefox + Netscape
+ }else{
+ dojo.event.connect(this.textbox, "onmousewheel", this, "_mouseWheeled"); // IE + Safari
}
+ //dojo.event.connect(window, "onchange", this, "_resize");
+ }
+ }
+);
- if(this.flags.separator.length > 0){
- for (var i=val.length-3; i > 1; i-=3){
- val = val.substr(0,i)+this.flags.separator+val.substr(i);
- }
+// summary
+// create spinable, single integer, input field
+dojo.widget.defineWidget(
+ "dojo.widget.IntegerSpinner",
+ [dojo.widget.IntegerTextbox, dojo.widget.Spinner],
+{
+ // summary: an IntegerSpinner with +/- buttons
+
+ // Number
+ // increment amount
+ delta: "1",
+
+ postMixInProperties: function(/*Object*/ args, /*Object*/ frag){
+ dojo.widget.IntegerSpinner.superclass.postMixInProperties.apply(this, arguments);
+ this._spinnerPostMixInProperties(args, frag);
+ },
+
+ postCreate: function(/*Object*/ args, /*Object*/ frag){
+ dojo.widget.IntegerSpinner.superclass.postCreate.apply(this, arguments);
+ this._spinnerPostCreate(args, frag);
+ },
+
+ // sumary
+ // spin the input field
+ // direction < 0: spin down
+ // direction > 0: spin up
+ // direction = 0: revalidate existing value
+ adjustValue: function(/*Number*/ direction, /*Number*/ x){
+ var val = this.getValue().replace(/[^\-+\d]/g, "");
+ if(val.length == 0){ return; }
+
+ var num = Math.min(Math.max((parseInt(val)+(parseInt(this.delta) * direction)), (this.flags.min?this.flags.min:-Infinity)), (this.flags.max?this.flags.max:+Infinity));
+ val = num.toString();
+
+ if(num >= 0){
+ val = ((this.flags.signed == true)?'+':' ')+val; // make sure first char is a nondigit
+ }
+
+ if(this.flags.separator.length > 0){
+ for (var i=val.length-3; i > 1; i-=3){
+ val = val.substr(0,i)+this.flags.separator+val.substr(i);
}
+ }
- if(val.substr(0,1) == ' '){ val = val.substr(1); } // remove space
+ if(val.substr(0,1) == ' '){ val = val.substr(1); } // remove space
- this.setValue(val);
+ this.setValue(val);
- return val.length;
+ return val.length;
}
});
-dojo.widget.tags.addParseTreeHandler("dojo:AdjustableIntegerTextbox");
/*
- ****** AdjustableRealNumberTextbox ******
+ ****** RealNumberSpinner ******
A subclass of RealNumberTextbox.
@attr places The exact number of decimal places. If omitted, it's unlimited and optional.
@attr exponent Can be true or false. If omitted the exponential part is optional.
@attr eSigned Is the exponent signed? Can be true or false, if omitted the sign is optional.
*/
-dojo.widget.AdjustableRealNumberTextbox = function(node) {
- // this property isn't a primitive and needs to be created on a per-item basis.
- this.flags = {};
-}
-dojo.inherits(dojo.widget.AdjustableRealNumberTextbox, dojo.widget.validate.RealNumberTextbox);
-dojo.lang.extend(dojo.widget.AdjustableRealNumberTextbox, {
- // new subclass properties
- widgetType: "AdjustableRealNumberTextbox",
- delta: "1e1",
+dojo.widget.defineWidget(
+ "dojo.widget.RealNumberSpinner",
+ [dojo.widget.RealNumberTextbox, dojo.widget.Spinner],
+ function(){ dojo.experimental("dojo.widget.RealNumberSpinner"); },
+{
+ // new subclass properties
+ delta: "1e1",
+
+ postMixInProperties: function(/*Object*/ args, /*Object*/ frag){
+ dojo.widget.RealNumberSpinner.superclass.postMixInProperties.apply(this, arguments);
+ this._spinnerPostMixInProperties(args, frag);
+ },
+
+ postCreate: function(/*Object*/ args, /*Object*/ frag){
+ dojo.widget.RealNumberSpinner.superclass.postCreate.apply(this, arguments);
+ this._spinnerPostCreate(args, frag);
+ },
- adjustValue: function(direction, x){
+ adjustValue: function(/*Number*/ direction, /*Number*/ x){
var val = this.getValue().replace(/[^\-+\.eE\d]/g, "");
if(!val.length){ return; }
@@ -109,7 +357,7 @@
numExp = 0;
}
}
- num = Math.min(Math.max((numBase * Math.pow(10,numExp)), this.flags.min), this.flags.max);
+ num = Math.min(Math.max((numBase * Math.pow(10,numExp)), (this.flags.min?this.flags.min:-Infinity)), (this.flags.max?this.flags.max:+Infinity));
if((this.flags.exponent == true || (this.flags.exponent != false && x != 0)) && num.toExponential){
if (isNaN(this.flags.places) || this.flags.places == Infinity){
val = num.toExponential();
@@ -117,7 +365,7 @@
val = num.toExponential(this.flags.places);
}
}else if(num.toFixed && num.toPrecision){
- if(isNaN(this.flags.places)){
+ if(isNaN(this.flags.places) || this.flags.places == Infinity){
val = num.toPrecision((1/3).toString().length-1);
}else{
val = num.toFixed(this.flags.places);
@@ -167,28 +415,208 @@
return x;
}
});
-dojo.widget.tags.addParseTreeHandler("dojo:AdjustableRealNumberTextbox");
-
-dojo.widget.Spinner = function(){
- dojo.widget.Widget.call(this);
-}
-dojo.inherits(dojo.widget.Spinner, dojo.widget.Widget);
-
-dojo.widget.Spinner.defaults = {
- widgetType: "Spinner",
- isContainer: false
-};
-
-dojo.lang.extend(dojo.widget.Spinner, dojo.widget.Spinner.defaults);
-
-dojo.widget.DomSpinner = function(){
- dojo.widget.Spinner.call(this);
- dojo.widget.DomWidget.call(this, true);
-}
-
-dojo.inherits(dojo.widget.DomSpinner, dojo.widget.DomWidget);
-dojo.widget.tags.addParseTreeHandler("dojo:Spinner");
+dojo.widget.defineWidget(
+ "dojo.widget.TimeSpinner",
+ [dojo.widget.TimeTextbox, dojo.widget.Spinner],
+ function(){ dojo.experimental("dojo.widget.TimeSpinner"); },
+{
+ postMixInProperties: function(/*Object*/ args, /*Object*/ frag){
+ dojo.widget.TimeSpinner.superclass.postMixInProperties.apply(this, arguments);
+ this._spinnerPostMixInProperties(args, frag);
+ },
+
+ postCreate: function(/*Object*/ args, /*Object*/ frag){
+ dojo.widget.TimeSpinner.superclass.postCreate.apply(this, arguments);
+ this._spinnerPostCreate(args, frag);
+ },
+
+ adjustValue: function(/*Number*/ direction, /*Number*/ x){
+ //FIXME: formatting should make use of dojo.date.format?
+ var val = this.getValue();
+ var format = (this.flags.format && this.flags.format.search(/[Hhmst]/) >= 0) ? this.flags.format : "hh:mm:ss t";
+ if(direction == 0 || !val.length || !this.isValid()){ return; }
+ if (!this.flags.amSymbol){
+ this.flags.amSymbol = "AM";
+ }
+ if (!this.flags.pmSymbol){
+ this.flags.pmSymbol = "PM";
+ }
+ var re = dojo.regexp.time(this.flags);
+ var qualifiers = format.replace(/H/g,"h").replace(/[^hmst]/g,"").replace(/([hmst])\1/g,"$1");
+ var hourPos = qualifiers.indexOf('h') + 1;
+ var minPos = qualifiers.indexOf('m') + 1;
+ var secPos = qualifiers.indexOf('s') + 1;
+ var ampmPos = qualifiers.indexOf('t') + 1;
+ // tweak format to match the incoming data exactly to help find where the cursor is
+ var cursorFormat = format;
+ var ampm = "";
+ if (ampmPos > 0){
+ ampm = val.replace(new RegExp(re),"$"+ampmPos);
+ cursorFormat = cursorFormat.replace(/t+/, ampm.replace(/./g,"t"));
+ }
+ var hour = 0;
+ var deltaHour = 1;
+ if (hourPos > 0){
+ hour = val.replace(new RegExp(re),"$"+hourPos);
+ if (dojo.lang.isString(this.delta)){
+ deltaHour = this.delta.replace(new RegExp(re),"$"+hourPos);
+ }
+ if (isNaN(deltaHour)){
+ deltaHour = 1;
+ } else {
+ deltaHour = parseInt(deltaHour);
+ }
+ if (hour.length == 2){
+ cursorFormat = cursorFormat.replace(/([Hh])+/, "$1$1");
+ } else {
+ cursorFormat = cursorFormat.replace(/([Hh])+/, "$1");
+ }
+ if (isNaN(hour)){
+ hour = 0;
+ } else {
+ hour = parseInt(hour.replace(/^0(\d)/,"$1"));
+ }
+ }
+ var min = 0;
+ var deltaMin = 1;
+ if (minPos > 0){
+ min = val.replace(new RegExp(re),"$"+minPos);
+ if (dojo.lang.isString(this.delta)){
+ deltaMin = this.delta.replace(new RegExp(re),"$"+minPos);
+ }
+ if (isNaN(deltaMin)){
+ deltaMin = 1;
+ } else {
+ deltaMin = parseInt(deltaMin);
+ }
+ cursorFormat = cursorFormat.replace(/m+/, min.replace(/./g,"m"));
+ if (isNaN(min)){
+ min = 0;
+ } else {
+ min = parseInt(min.replace(/^0(\d)/,"$1"));
+ }
+ }
+ var sec = 0;
+ var deltaSec = 1;
+ if (secPos > 0){
+ sec = val.replace(new RegExp(re),"$"+secPos);
+ if (dojo.lang.isString(this.delta)){
+ deltaSec = this.delta.replace(new RegExp(re),"$"+secPos);
+ }
+ if (isNaN(deltaSec)){
+ deltaSec = 1;
+ } else {
+ deltaSec = parseInt(deltaSec);
+ }
+ cursorFormat = cursorFormat.replace(/s+/, sec.replace(/./g,"s"));
+ if (isNaN(sec)){
+ sec = 0;
+ } else {
+ sec = parseInt(sec.replace(/^0(\d)/,"$1"));
+ }
+ }
+ if (isNaN(x) || x >= cursorFormat.length){
+ x = cursorFormat.length-1;
+ }
+ var cursorToken = cursorFormat.charAt(x);
+
+ switch(cursorToken){
+ case 't':
+ if (ampm == this.flags.amSymbol){
+ ampm = this.flags.pmSymbol;
+ }
+ else if (ampm == this.flags.pmSymbol){
+ ampm = this.flags.amSymbol;
+ }
+ break;
+ default:
+ if (hour >= 1 && hour < 12 && ampm == this.flags.pmSymbol){
+ hour += 12;
+ }
+ if (hour == 12 && ampm == this.flags.amSymbol){
+ hour = 0;
+ }
+ switch(cursorToken){
+ case 's':
+ sec += deltaSec * direction;
+ while (sec < 0){
+ min--;
+ sec += 60;
+ }
+ while (sec >= 60){
+ min++;
+ sec -= 60;
+ }
+ case 'm':
+ if (cursorToken == 'm'){
+ min += deltaMin * direction;
+ }
+ while (min < 0){
+ hour--;
+ min += 60;
+ }
+ while (min >= 60){
+ hour++;
+ min -= 60;
+ }
+ case 'h':
+ case 'H':
+ if (cursorToken == 'h' || cursorToken == 'H'){
+ hour += deltaHour * direction;
+ }
+ while (hour < 0){
+ hour += 24;
+ }
+ while (hour >= 24){
+ hour -= 24;
+ }
+ break;
+ default: // should never get here
+ return;
+ }
+ if (hour >= 12){
+ ampm = this.flags.pmSymbol;
+ if (format.indexOf('h') >= 0 && hour >= 13){
+ hour -= 12;
+ }
+ } else {
+ ampm = this.flags.amSymbol;
+ if (format.indexOf('h') >= 0 && hour == 0){
+ hour = 12;
+ }
+ }
+ }
-// render-specific includes
-dojo.requireAfterIf("html", "dojo.widget.html.Spinner");
+ cursorFormat = format;
+ if (hour >= 0 && hour < 10 && format.search(/[hH]{2}/) >= 0){
+ hour = "0" + hour.toString();
+ }
+ if (hour >= 10 && cursorFormat.search(/[hH]{2}/) < 0 ){
+ cursorFormat = cursorFormat.replace(/(h|H)/, "$1$1");
+ }
+ if (min >= 0 && min < 10 && cursorFormat.search(/mm/) >= 0){
+ min = "0" + min.toString();
+ }
+ if (min >= 10 && cursorFormat.search(/mm/) < 0 ){
+ cursorFormat = cursorFormat.replace(/m/, "$1$1");
+ }
+ if (sec >= 0 && sec < 10 && cursorFormat.search(/ss/) >= 0){
+ sec = "0" + sec.toString();
+ }
+ if (sec >= 10 && cursorFormat.search(/ss/) < 0 ){
+ cursorFormat = cursorFormat.replace(/s/, "$1$1");
+ }
+ x = cursorFormat.indexOf(cursorToken);
+ if (x == -1){
+ x = format.length;
+ }
+ format = format.replace(/[hH]+/, hour);
+ format = format.replace(/m+/, min);
+ format = format.replace(/s+/, sec);
+ format = format.replace(/t/, ampm);
+ this.setValue(format);
+ if(x > format.length){ x = format.length; }
+ return x;
+ }
+});
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SplitContainer.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SplitContainer.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SplitContainer.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SplitContainer.js Fri Nov 10 01:15:01 2006
@@ -9,9 +9,6 @@
*/
dojo.provide("dojo.widget.SplitContainer");
-dojo.provide("dojo.widget.SplitContainerPanel");
-dojo.provide("dojo.widget.html.SplitContainer");
-dojo.provide("dojo.widget.html.SplitContainerPanel");
//
// TODO
@@ -20,68 +17,68 @@
//
dojo.require("dojo.widget.*");
-dojo.require("dojo.widget.LayoutContainer");
+dojo.require("dojo.widget.ContentPane");
dojo.require("dojo.widget.HtmlWidget");
-dojo.require("dojo.html");
-dojo.require("dojo.style");
-dojo.require("dojo.dom");
-dojo.require("dojo.io"); // workaround dojo bug. dojo.io.cookie requires dojo.io but it still doesn't get pulled in
+dojo.require("dojo.html.style");
+dojo.require("dojo.html.layout");
+dojo.require("dojo.html.selection");
dojo.require("dojo.io.cookie");
-dojo.widget.html.SplitContainer = function(){
-
- dojo.widget.HtmlWidget.call(this);
-
- this.sizers = [];
-}
-
-dojo.inherits(dojo.widget.html.SplitContainer, dojo.widget.HtmlWidget);
-
-dojo.lang.extend(dojo.widget.html.SplitContainer, {
- widgetType: "SplitContainer",
+dojo.widget.defineWidget(
+ "dojo.widget.SplitContainer",
+ dojo.widget.HtmlWidget,
+ function(){
+ this.sizers = [];
+ },
+{
isContainer: true,
+ // variables
virtualSizer: null,
- isHorizontal: 0,
+ isHorizontal: null,
paneBefore: null,
paneAfter: null,
isSizing: false,
- dragOffset: null,
- startPoint: null,
- lastPoint: null,
+ dragOffset: 0,
+ startPoint: 0,
+ lastPoint: 0,
sizingSplitter: null,
- isActiveResize: 0,
- offsetX: 0,
- offsetY: 0,
+ screenToClientOffset: 0,
isDraggingLeft: 0,
- templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlSplitContainer.css"),
- originPos: null,
- persist: true, // save splitter positions in a cookie
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/SplitContainer.css"),
+ originPos: 0,
- activeSizing: '',
+ // parameters (user settable)
+ activeSizing: false,
sizerWidth: 15,
orientation: 'horizontal',
+ persist: true, // save splitter positions in a cookie
debugName: '',
fillInTemplate: function(){
- dojo.style.insertCssFile(this.templateCssPath, null, true);
+ dojo.html.insertCssFile(this.templateCssPath, null, true);
dojo.html.addClass(this.domNode, "dojoSplitContainer");
- this.domNode.style.overflow='hidden'; // workaround firefox bug
-
- this.paneWidth = dojo.style.getContentWidth(this.domNode);
- this.paneHeight = dojo.style.getContentHeight(this.domNode);
+ // overflow has to be explicitly hidden for splitContainers using gekko (trac #1435)
+ // to keep other combined css classes from inadvertantly making the overflow visible
+ if (dojo.render.html.moz) {
+ this.domNode.style.overflow = '-moz-scrollbars-none'; // hidden doesn't work
+ }
+
+ var content = dojo.html.getContentBox(this.domNode);
+ this.paneWidth = content.width;
+ this.paneHeight = content.height;
- this.isHorizontal = (this.orientation == 'horizontal') ? 1 : 0;
- this.isActiveResize = (this.activeSizing == '1') ? 1 : 0;
+ this.isHorizontal = (this.orientation == 'horizontal');
//dojo.debug("fillInTemplate for "+this.debugName);
},
onResized: function(e){
- this.paneWidth = dojo.style.getContentWidth(this.domNode);
- this.paneHeight = dojo.style.getContentHeight(this.domNode);
+ var content = dojo.html.getContentBox(this.domNode);
+ this.paneWidth = content.width;
+ this.paneHeight = content.height;
this.layoutPanels();
},
@@ -105,6 +102,11 @@
}
// create the fake dragger
+ if (typeof this.sizerWidth == "object") {
+ try {
+ this.sizerWidth = parseInt(this.sizerWidth.toString());
+ } catch(e) { this.sizerWidth = 15; }
+ }
this.virtualSizer = document.createElement('div');
this.virtualSizer.style.position = 'absolute';
this.virtualSizer.style.display = 'none';
@@ -161,12 +163,12 @@
}
// Remove widget and repaint
- dojo.widget.html.SplitContainer.superclass.removeChild.call(this, widget, arguments);
+ dojo.widget.SplitContainer.superclass.removeChild.call(this, widget, arguments);
this.onResized();
},
addChild: function(widget, overrideContainerNode, pos, ref, insertIndex){
- dojo.widget.html.SplitContainer.superclass.addChild.call(this, widget, overrideContainerNode, pos, ref, insertIndex);
+ dojo.widget.SplitContainer.superclass.addChild.call(this, widget, overrideContainerNode, pos, ref, insertIndex);
this._injectChild(widget);
if (this.children.length > 1) {
@@ -239,7 +241,7 @@
var size = this.children[0].sizeActual;
this.movePanel(this.children[0].domNode, pos, size);
this.children[0].position = pos;
- this.children[0].checkSize();
+ this.children[0].checkSize();
pos += size;
for(var i=1; i<this.children.length; i++){
@@ -252,7 +254,7 @@
size = this.children[i].sizeActual;
this.movePanel(this.children[i].domNode, pos, size);
this.children[i].position = pos;
- this.children[i].checkSize();
+ this.children[i].checkSize();
pos += size;
}
},
@@ -262,14 +264,12 @@
panel.style.left = pos + 'px';
panel.style.top = 0;
- dojo.style.setOuterWidth(panel, size);
- dojo.style.setOuterHeight(panel, this.paneHeight);
+ dojo.html.setMarginBox(panel, { width: size, height: this.paneHeight });
}else{
panel.style.left = 0;
panel.style.top = pos + 'px';
- dojo.style.setOuterWidth(panel, this.paneWidth);
- dojo.style.setOuterHeight(panel, size);
+ dojo.html.setMarginBox(panel, { width: this.paneWidth, height: size });
}
},
@@ -338,25 +338,26 @@
},
beginSizing: function(e, i){
- var clientX = e.layerX;
- var clientY = e.layerY;
- var screenX = e.pageX;
- var screenY = e.pageY;
-
this.paneBefore = this.children[i];
this.paneAfter = this.children[i+1];
this.isSizing = true;
this.sizingSplitter = this.sizers[i];
- this.originPos = dojo.style.getAbsolutePosition(this.domNode, true);
- this.dragOffset = {'x':clientX, 'y':clientY};
- this.startPoint = {'x':screenX, 'y':screenY};
- this.lastPoint = {'x':screenX, 'y':screenY};
-
- this.offsetX = screenX - clientX;
- this.offsetY = screenY - clientY;
+ this.originPos = dojo.html.getAbsolutePosition(this.children[0].domNode, true, dojo.html.boxSizing.MARGIN_BOX);
+ if (this.isHorizontal){
+ var client = (e.layerX ? e.layerX : e.offsetX);
+ var screen = e.pageX;
+ this.originPos = this.originPos.x;
+ }else{
+ var client = (e.layerY ? e.layerY : e.offsetY);
+ var screen = e.pageY;
+ this.originPos = this.originPos.y;
+ }
+ this.startPoint = this.lastPoint = screen;
+ this.screenToClientOffset = screen - client;
+ this.dragOffset = this.lastPoint - this.paneBefore.sizeActual - this.originPos - this.paneBefore.position;
- if (!this.isActiveResize){
+ if (!this.activeSizing){
this.showSizingLine();
}
@@ -366,26 +367,24 @@
dojo.event.connect(document.documentElement, "onmousemove", this, "changeSizing");
dojo.event.connect(document.documentElement, "onmouseup", this, "endSizing");
+ dojo.event.browser.stopEvent(e);
},
changeSizing: function(e){
- var screenX = e.pageX;
- var screenY = e.pageY;
-
- if (this.isActiveResize){
- this.lastPoint = {'x':screenX, 'y':screenY};
+ this.lastPoint = this.isHorizontal ? e.pageX : e.pageY;
+ if (this.activeSizing){
this.movePoint();
this.updateSize();
}else{
- this.lastPoint = {'x':screenX, 'y':screenY};
this.movePoint();
this.moveSizingLine();
}
+ dojo.event.browser.stopEvent(e);
},
endSizing: function(e){
- if (!this.isActiveResize){
+ if (!this.activeSizing){
this.hideSizingLine();
}
@@ -403,53 +402,14 @@
movePoint: function(){
- // make sure FLastPoint is a legal point to drag to
- var p = this.screenToMainClient(this.lastPoint);
+ // make sure lastPoint is a legal point to drag to
+ var p = this.lastPoint - this.screenToClientOffset;
- if (this.isHorizontal){
+ var a = p - this.dragOffset;
+ a = this.legaliseSplitPoint(a);
+ p = a + this.dragOffset;
- var a = p.x - this.dragOffset.x;
- a = this.legaliseSplitPoint(a);
- p.x = a + this.dragOffset.x;
- }else{
- var a = p.y - this.dragOffset.y;
- a = this.legaliseSplitPoint(a);
- p.y = a + this.dragOffset.y;
- }
-
- this.lastPoint = this.mainClientToScreen(p);
- },
-
- screenToClient: function(pt){
-
- pt.x -= (this.offsetX + this.sizingSplitter.position);
- pt.y -= (this.offsetY + this.sizingSplitter.position);
-
- return pt;
- },
-
- clientToScreen: function(pt){
-
- pt.x += (this.offsetX + this.sizingSplitter.position);
- pt.y += (this.offsetY + this.sizingSplitter.position);
-
- return pt;
- },
-
- screenToMainClient: function(pt){
-
- pt.x -= this.offsetX;
- pt.y -= this.offsetY;
-
- return pt;
- },
-
- mainClientToScreen: function(pt){
-
- pt.x += this.offsetX;
- pt.y += this.offsetY;
-
- return pt;
+ this.lastPoint = p + this.screenToClientOffset;
},
legaliseSplitPoint: function(a){
@@ -458,7 +418,7 @@
this.isDraggingLeft = (a > 0) ? 1 : 0;
- if (!this.isActiveResize){
+ if (!this.activeSizing){
if (a < this.paneBefore.position + this.paneBefore.sizeMin){
@@ -479,11 +439,7 @@
},
updateSize: function(){
-
- var p = this.clientToScreen(this.lastPoint);
- var p = this.screenToClient(this.lastPoint);
-
- var pos = this.isHorizontal ? p.x - (this.dragOffset.x + this.originPos.x) : p.y - (this.dragOffset.y + this.originPos.y);
+ var pos = this.lastPoint - this.dragOffset - this.originPos;
var start_region = this.paneBefore.position;
var end_region = this.paneAfter.position + this.paneAfter.sizeActual;
@@ -505,33 +461,27 @@
this.moveSizingLine();
if (this.isHorizontal){
- dojo.style.setOuterWidth(this.virtualSizer, this.sizerWidth);
- dojo.style.setOuterHeight(this.virtualSizer, this.paneHeight);
+ dojo.html.setMarginBox(this.virtualSizer, { width: this.sizerWidth, height: this.paneHeight });
}else{
- dojo.style.setOuterWidth(this.virtualSizer, this.paneWidth);
- dojo.style.setOuterHeight(this.virtualSizer, this.sizerWidth);
+ dojo.html.setMarginBox(this.virtualSizer, { width: this.paneWidth, height: this.sizerWidth });
}
this.virtualSizer.style.display = 'block';
},
hideSizingLine: function(){
-
this.virtualSizer.style.display = 'none';
},
moveSizingLine: function(){
-
- var origin = {'x':0, 'y':0};
-
+ var pos = this.lastPoint - this.startPoint + this.sizingSplitter.position;
if (this.isHorizontal){
- origin.x += (this.lastPoint.x - this.startPoint.x) + this.sizingSplitter.position;
+ this.virtualSizer.style.left = pos + 'px';
}else{
- origin.y += (this.lastPoint.y - this.startPoint.y) + this.sizingSplitter.position;
+ var pos = (this.lastPoint - this.startPoint) + this.sizingSplitter.position;
+ this.virtualSizer.style.top = pos + 'px';
}
- this.virtualSizer.style.left = origin.x + 'px';
- this.virtualSizer.style.top = origin.y + 'px';
},
_getCookieName: function(i) {
@@ -544,7 +494,9 @@
var cookieValue = dojo.io.cookie.getCookie(cookieName);
if (cookieValue != null) {
var pos = parseInt(cookieValue);
- this.children[i].sizeShare=pos;
+ if (typeof pos == "number") {
+ this.children[i].sizeShare=pos;
+ }
}
}
},
@@ -567,13 +519,9 @@
// Deprecated class for split pane children.
// Actually any widget can be the child of a split pane
-dojo.widget.html.SplitContainerPanel = function(){
- dojo.widget.html.LayoutContainer.call(this);
-}
-dojo.inherits(dojo.widget.html.SplitContainerPanel, dojo.widget.html.LayoutContainer);
-dojo.lang.extend(dojo.widget.html.SplitContainerPanel, {
- widgetType: "SplitContainerPanel"
-});
+dojo.widget.defineWidget(
+ "dojo.widget.SplitContainerPanel",
+ dojo.widget.ContentPane,
+ {}
+);
-dojo.widget.tags.addParseTreeHandler("dojo:SplitContainer");
-dojo.widget.tags.addParseTreeHandler("dojo:SplitContainerPanel");
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgWidget.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgWidget.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgWidget.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgWidget.js Fri Nov 10 01:15:01 2006
@@ -15,13 +15,10 @@
dojo.require("dojo.dom");
// SVGWidget is a mixin ONLY
-dojo.widget.SvgWidget = function(args){
- // mix in the parent type
- // dojo.widget.DomWidget.call(this);
-}
-dojo.inherits(dojo.widget.SvgWidget, dojo.widget.DomWidget);
-
-dojo.lang.extend(dojo.widget.SvgWidget, {
+dojo.widget.declare(
+ "dojo.widget.SvgWidget",
+ dojo.widget.DomWidget,
+{
getContainerHeight: function(){
// NOTE: container height must be returned as the INNER height
dojo.unimplemented("dojo.widget.SvgWidget.getContainerHeight");
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SwtWidget.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SwtWidget.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SwtWidget.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SwtWidget.js Fri Nov 10 01:15:01 2006
@@ -19,13 +19,13 @@
try{
importPackage(Packages.org.eclipse.swt.widgets);
- dojo.declare("dojo.widget.SwtWidget", dojo.widget.Widget, {
- initializer: function() {
+ dojo.declare("dojo.widget.SwtWidget", dojo.widget.Widget,
+ function() {
if((arguments.length>0)&&(typeof arguments[0] == "object")){
this.create(arguments[0]);
}
},
-
+ {
display: null,
shell: null,
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TabContainer.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TabContainer.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TabContainer.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TabContainer.js Fri Nov 10 01:15:01 2006
@@ -8,254 +8,208 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-dojo.provide("dojo.widget.TabContainer");
-dojo.provide("dojo.widget.html.TabContainer");
-dojo.provide("dojo.widget.Tab");
-
-dojo.require("dojo.lang.func");
-dojo.require("dojo.widget.*");
-dojo.require("dojo.widget.HtmlWidget");
-dojo.require("dojo.event.*");
-dojo.require("dojo.html");
-dojo.require("dojo.style");
-dojo.require("dojo.html.layout");
-
-//////////////////////////////////////////
-// TabContainer -- a set of Tabs
-//////////////////////////////////////////
-dojo.widget.html.TabContainer = function() {
- dojo.widget.HtmlWidget.call(this);
-}
-
-dojo.inherits(dojo.widget.html.TabContainer, dojo.widget.HtmlWidget);
-
-dojo.lang.extend(dojo.widget.html.TabContainer, {
- widgetType: "TabContainer",
- isContainer: true,
-
- // Constructor arguments
- labelPosition: "top",
- closeButton: "none",
-
- useVisibility: false, // true-->use visibility:hidden instead of display:none
-
- // if false, TabContainers size changes according to size of currently selected tab
- doLayout: true,
-
- templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlTabContainer.html"),
- templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlTabContainer.css"),
-
- selectedTab: "", // initially selected tab (widgetId)
-
- fillInTemplate: function(args, frag) {
- // Copy style info from input node to output node
- var source = this.getFragNodeRef(frag);
- dojo.html.copyStyle(this.domNode, source);
-
- dojo.widget.html.TabContainer.superclass.fillInTemplate.call(this, args, frag);
- },
-
- postCreate: function(args, frag) {
- // Load all the tabs, creating a label for each one
- for(var i=0; i<this.children.length; i++){
- this._setupTab(this.children[i]);
- }
-
- if (this.closeButton=="pane") {
- var div = document.createElement("div");
- dojo.html.addClass(div, "dojoTabPanePaneClose");
- var self = this;
- dojo.event.connect(div, "onclick", function(){ self._runOnCloseTab(self.selectedTabWidget); });
- dojo.event.connect(div, "onmouseover", function(){ dojo.html.addClass(div, "dojoTabPanePaneCloseHover"); });
- dojo.event.connect(div, "onmouseout", function(){ dojo.html.removeClass(div, "dojoTabPanePaneCloseHover"); });
- this.dojoTabLabels.appendChild(div);
- }
-
- if(this.doLayout){
- dojo.html.addClass(this.dojoTabLabels, "dojoTabLabels-"+this.labelPosition);
- } else {
- dojo.html.addClass(this.dojoTabLabels, "dojoTabLabels-"+this.labelPosition+"-noLayout");
- }
-
- this._doSizing();
-
- // Display the selected tab
- if(this.selectedTabWidget){
- this.selectTab(this.selectedTabWidget, true);
- }
- },
-
- addChild: function(child, overrideContainerNode, pos, ref, insertIndex){
- this._setupTab(child);
- dojo.widget.html.TabContainer.superclass.addChild.call(this,child, overrideContainerNode, pos, ref, insertIndex);
-
- // in case the tab labels have overflowed from one line to two lines
- this._doSizing();
- },
-
- _setupTab: function(tab){
- tab.domNode.style.display="none";
-
- // Create label
- tab.div = document.createElement("div");
- dojo.widget.wai.setAttr(tab.div, "waiRole", "tab");
- dojo.html.addClass(tab.div, "dojoTabPaneTab");
- var span = document.createElement("span");
- span.innerHTML = tab.label;
- dojo.html.disableSelection(span);
- if (this.closeButton=="tab") {
- var img = document.createElement("div");
- dojo.html.addClass(img, "dojoTabPaneTabClose");
- var self = this;
- dojo.event.connect(img, "onclick", function(evt){ self._runOnCloseTab(tab); dojo.event.browser.stopEvent(evt); });
- dojo.event.connect(img, "onmouseover", function(){ dojo.html.addClass(img,"dojoTabPaneTabCloseHover"); });
- dojo.event.connect(img, "onmouseout", function(){ dojo.html.removeClass(img,"dojoTabPaneTabCloseHover"); });
- span.appendChild(img);
- }
- tab.div.appendChild(span);
- this.dojoTabLabels.appendChild(tab.div);
-
- var self = this;
- dojo.event.connect(tab.div, "onclick", function(){ self.selectTab(tab); });
-
- if(!this.selectedTabWidget || this.selectedTab==tab.widgetId || tab.selected){
- this.selectedTabWidget = tab;
- } else {
- this._hideTab(tab);
- }
-
- dojo.html.addClass(tab.domNode, "dojoTabPane");
- with(tab.domNode.style){
- top = dojo.style.getPixelValue(this.containerNode, "padding-top", true);
- left = dojo.style.getPixelValue(this.containerNode, "padding-left", true);
- }
- },
-
- // Configure the content pane to take up all the space except for where the tab labels are
- _doSizing: function(){
- // position the labels and the container node
- var labelAlign=this.labelPosition.replace(/-h/,"");
- var children = [
- {domNode: this.dojoTabLabels, layoutAlign: labelAlign},
- {domNode: this.containerNode, layoutAlign: "client"}
- ];
-
-
- if (this.doLayout) {
- dojo.html.layout(this.domNode, children);
- }
-
- // size the current tab
- // TODO: should have ptr to current tab rather than searching
- var cw=dojo.style.getContentWidth(this.containerNode);
- var ch=dojo.style.getContentHeight(this.containerNode);
- dojo.lang.forEach(this.children, function(child){
- //if (this.doLayout) {
- if(child.selected){
- child.resizeTo(cw, ch);
- }
- //} else {
- // child.onResized();
- //}
- });
-
- },
-
- removeChild: function(tab) {
-
- // remove tab event handlers
- dojo.event.disconnect(tab.div, "onclick", function () { });
- if (this.closeButton=="tab") {
- var img = tab.div.lastChild.lastChild;
- if (img) {
- dojo.html.removeClass(img, "dojoTabPaneTabClose", function () { });
- dojo.event.disconnect(img, "onclick", function () { });
- dojo.event.disconnect(img, "onmouseover", function () { });
- dojo.event.disconnect(img, "onmouseout", function () { });
- }
- }
-
- dojo.widget.html.TabContainer.superclass.removeChild.call(this, tab);
-
- dojo.html.removeClass(tab.domNode, "dojoTabPane");
- this.dojoTabLabels.removeChild(tab.div);
- delete(tab.div);
-
- if (this.selectedTabWidget === tab) {
- this.selectedTabWidget = undefined;
- if (this.children.length > 0) {
- this.selectTab(this.children[0], true);
- }
- }
-
- // in case the tab labels have overflowed from one line to two lines
- this._doSizing();
- },
-
- selectTab: function(tab, _noRefresh) {
- // Deselect old tab and select new one
- if (this.selectedTabWidget) {
- this._hideTab(this.selectedTabWidget);
- }
- this.selectedTabWidget = tab;
- this._showTab(tab, _noRefresh);
- },
-
- _showTab: function(tab, _noRefresh) {
- dojo.html.addClass(tab.div, "current");
- tab.selected=true;
- if ( this.useVisibility && !dojo.render.html.ie ) {
- tab.domNode.style.visibility="visible";
- } else {
- // make sure we dont refresh onClose and on postCreate
- // speeds up things a bit when using refreshOnShow and fixes #646
- if(_noRefresh && tab.refreshOnShow){
- var tmp = tab.refreshOnShow;
- tab.refreshOnShow = false;
- tab.show();
- tab.refreshOnShow = tmp;
- }else{
- tab.show();
- }
-
- tab.resizeTo(
- dojo.style.getContentWidth(this.containerNode),
- dojo.style.getContentHeight(this.containerNode)
- );
- }
- },
-
- _hideTab: function(tab) {
- dojo.html.removeClass(tab.div, "current");
- tab.selected=false;
- if( this.useVisibility ){
- tab.domNode.style.visibility="hidden";
- }else{
- tab.hide();
- }
- },
-
- _runOnCloseTab: function(tab) {
- var onc = tab.extraArgs.onClose || tab.extraArgs.onclose;
- var fcn = dojo.lang.isFunction(onc) ? onc : window[onc];
- var remove = dojo.lang.isFunction(fcn) ? fcn(this,tab) : true;
- if(remove) {
- this.removeChild(tab);
- // makes sure we can clean up executeScripts in ContentPane onUnLoad
- tab.destroy();
- }
- },
-
- onResized: function() {
- this._doSizing();
- }
-});
-dojo.widget.tags.addParseTreeHandler("dojo:TabContainer");
-
-// These arguments can be specified for the children of a TabContainer.
-// Since any widget can be specified as a TabContainer child, mix them
-// into the base widget class. (This is a hack, but it's effective.)
-dojo.lang.extend(dojo.widget.Widget, {
- label: "",
- selected: false // is this tab currently selected?
-});
+dojo.provide("dojo.widget.TabContainer");
+
+dojo.require("dojo.lang.func");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.PageContainer");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html.selection");
+dojo.require("dojo.widget.html.layout");
+
+// summary
+// A TabContainer is a container that has multiple panes, but shows only
+// one pane at a time. There are a set of tabs corresponding to each pane,
+// where each tab has the title (aka label) of the pane, and optionally a close button.
+//
+// Publishes topics <widgetId>-addChild, <widgetId>-removeChild, and <widgetId>-selectChild
+// (where <widgetId> is the id of the TabContainer itself.
+dojo.widget.defineWidget("dojo.widget.TabContainer", dojo.widget.PageContainer, {
+
+ // String
+ // Defines where tab labels go relative to tab content.
+ // "top", "bottom", "left-h", "right-h"
+ labelPosition: "top",
+
+ // String
+ // If closebutton=="tab", then every tab gets a close button.
+ // DEPRECATED: Should just say closable=true on each
+ // pane you want to be closable.
+ closeButton: "none",
+
+ templateString: null, // override setting in PageContainer
+ templatePath: dojo.uri.dojoUri("src/widget/templates/TabContainer.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/TabContainer.css"),
+
+ // String
+ // initially selected tab (widgetId)
+ // DEPRECATED: use selectedChild instead.
+ selectedTab: "",
+
+ postMixInProperties: function() {
+ if(this.selectedTab){
+ dojo.deprecated("selectedTab deprecated, use selectedChild instead, will be removed in", "0.5");
+ this.selectedChild=this.selectedTab;
+ }
+ if(this.closeButton!="none"){
+ dojo.deprecated("closeButton deprecated, use closable='true' on each child instead, will be removed in", "0.5");
+ }
+ dojo.widget.TabContainer.superclass.postMixInProperties.apply(this, arguments);
+ },
+
+ fillInTemplate: function() {
+ // create the tab list that will have a tab (a.k.a. tab button) for each tab panel
+ this.tablist = dojo.widget.createWidget("TabController",
+ {
+ id: this.widgetId + "_tablist",
+ labelPosition: this.labelPosition,
+ doLayout: this.doLayout,
+ containerId: this.widgetId
+ }, this.tablistNode);
+ dojo.widget.TabContainer.superclass.fillInTemplate.apply(this, arguments);
+ },
+
+ postCreate: function(args, frag) {
+ dojo.widget.TabContainer.superclass.postCreate.apply(this, arguments);
+
+ // size the container pane to take up the space not used by the tabs themselves
+ this.onResized();
+ },
+
+ _setupChild: function(tab){
+ if(this.closeButton=="tab" || this.closeButton=="pane"){
+ // TODO: remove in 0.5
+ tab.closable=true;
+ }
+ dojo.html.addClass(tab.domNode, "dojoTabPane");
+ dojo.widget.TabContainer.superclass._setupChild.apply(this, arguments);
+ },
+
+ onResized: function(){
+ // Summary: Configure the content pane to take up all the space except for where the tabs are
+ if(!this.doLayout){ return; }
+
+ // position the labels and the container node
+ var labelAlign=this.labelPosition.replace(/-h/,"");
+ var children = [
+ {domNode: this.tablist.domNode, layoutAlign: labelAlign},
+ {domNode: this.containerNode, layoutAlign: "client"}
+ ];
+ dojo.widget.html.layout(this.domNode, children);
+
+ if(this.selectedChildWidget){
+ var containerSize = dojo.html.getContentBox(this.containerNode);
+ this.selectedChildWidget.resizeTo(containerSize.width, containerSize.height);
+ }
+ },
+
+ selectTab: function(tab, callingWidget){
+ dojo.deprecated("use selectChild() rather than selectTab(), selectTab() will be removed in", "0.5");
+ this.selectChild(tab, callingWidget);
+ },
+
+ onKey: function(e){
+ // summary
+ // Keystroke handling for keystrokes on the tab panel itself (that were bubbled up to me)
+ // Ctrl-up: focus is returned from the pane to the tab button
+ // Alt-del: close tab
+ if(e.keyCode == e.KEY_UP_ARROW && e.ctrlKey){
+ // set focus to current tab
+ var button = this.correspondingTabButton || this.selectedTabWidget.tabButton;
+ button.focus();
+ dojo.event.browser.stopEvent(e);
+ }else if(e.keyCode == e.KEY_DELETE && e.altKey){
+ if (this.selectedChildWidget.closable){
+ this.closeChild(this.selectedChildWidget);
+ dojo.event.browser.stopEvent(e);
+ }
+ }
+ },
+
+ destroy: function(){
+ this.tablist.destroy();
+ dojo.widget.TabContainer.superclass.destroy.apply(this, arguments);
+ }
+});
+
+// summary
+// Set of tabs (the things with labels and a close button, that you click to show a tab panel).
+// Lets the user select the currently shown pane in a TabContainer or PageContainer.
+// TabController also monitors the TabContainer, and whenever a pane is
+// added or deleted updates itself accordingly.
+dojo.widget.defineWidget(
+ "dojo.widget.TabController",
+ dojo.widget.PageController,
+ {
+ templateString: "<div wairole='tablist' dojoAttachEvent='onKey'></div>",
+
+ // String
+ // Defines where tab labels go relative to tab content.
+ // "top", "bottom", "left-h", "right-h"
+ labelPosition: "top",
+
+ doLayout: true,
+
+ // String
+ // Class name to apply to the top dom node
+ "class": "",
+
+ // String
+ // the name of the tab widget to create to correspond to each page
+ buttonWidget: "TabButton",
+
+ postMixInProperties: function() {
+ if(!this["class"]){
+ this["class"] = "dojoTabLabels-" + this.labelPosition + (this.doLayout ? "" : " dojoTabNoLayout");
+ }
+ dojo.widget.TabController.superclass.postMixInProperties.apply(this, arguments);
+ }
+ }
+);
+
+// summary
+// A tab (the thing you click to select a pane).
+// Contains the title (aka label) of the pane, and optionally a close-button to destroy the pane.
+// This is an internal widget and should not be instantiated directly.
+dojo.widget.defineWidget("dojo.widget.TabButton", dojo.widget.PageButton,
+{
+ templateString: "<div class='dojoTab' dojoAttachEvent='onClick'>"
+ +"<div dojoAttachPoint='innerDiv'>"
+ +"<span dojoAttachPoint='titleNode' tabIndex='-1' waiRole='tab'>${this.label}</span>"
+ +"<span dojoAttachPoint='closeButtonNode' class='close closeImage' style='${this.closeButtonStyle}'"
+ +" dojoAttachEvent='onMouseOver:onCloseButtonMouseOver; onMouseOut:onCloseButtonMouseOut; onClick:onCloseButtonClick'></span>"
+ +"</div>"
+ +"</div>",
+
+ postMixInProperties: function(){
+ this.closeButtonStyle = this.closeButton ? "" : "display: none";
+ dojo.widget.TabButton.superclass.postMixInProperties.apply(this, arguments);
+ },
+
+ fillInTemplate: function(){
+ dojo.html.disableSelection(this.titleNode);
+ dojo.widget.TabButton.superclass.fillInTemplate.apply(this, arguments);
+ }
+});
+
+
+// summary
+// Tab for display in high-contrast mode (where background images don't show up).
+// This is an internal widget and shouldn't be instantiated directly.
+dojo.widget.defineWidget(
+ "dojo.widget.a11y.TabButton",
+ dojo.widget.TabButton,
+ {
+ imgPath: dojo.uri.dojoUri("src/widget/templates/images/tab_close.gif"),
+
+ templateString: "<div class='dojoTab' dojoAttachEvent='onClick;onKey'>"
+ +"<div dojoAttachPoint='innerDiv'>"
+ +"<span dojoAttachPoint='titleNode' tabIndex='-1' waiRole='tab'>${this.label}</span>"
+ +"<img class='close' src='${this.imgPath}' alt='[x]' style='${this.closeButtonStyle}'"
+ +" dojoAttachEvent='onClick:onCloseButtonClick'>"
+ +"</div>"
+ +"</div>"
+ }
+);
+
+
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TaskBar.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TaskBar.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TaskBar.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TaskBar.js Fri Nov 10 01:15:01 2006
@@ -8,25 +8,86 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-dojo.provide("dojo.widget.TaskBar");
-dojo.provide("dojo.widget.TaskBarItem");
-dojo.require("dojo.widget.Widget");
-
-dojo.widget.TaskBar = function(){
- dojo.widget.Widget.call(this);
-
- this.widgetType = "TaskBar";
- this.isContainer = true;
-}
-dojo.inherits(dojo.widget.TaskBar, dojo.widget.Widget);
-dojo.widget.tags.addParseTreeHandler("dojo:taskbar");
-
-dojo.widget.TaskBarItem = function(){
- dojo.widget.Widget.call(this);
-
- this.widgetType = "TaskBarItem";
-}
-dojo.inherits(dojo.widget.TaskBarItem, dojo.widget.Widget);
-dojo.widget.tags.addParseTreeHandler("dojo:taskbaritem");
-
-dojo.requireAfterIf("html", "dojo.widget.html.TaskBar");
+dojo.provide("dojo.widget.TaskBar");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.FloatingPane");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html.selection");
+
+// summary
+// Widget used internally by the TaskBar;
+// shows an icon associated w/a floating pane
+dojo.widget.defineWidget(
+ "dojo.widget.TaskBarItem",
+ dojo.widget.HtmlWidget,
+{
+ // String
+ // path of icon for associated floating pane
+ iconSrc: '',
+
+ // String
+ // name of associated floating pane
+ caption: 'Untitled',
+
+ // String
+ // widget id of associated floating pane
+ widgetId: "",
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/TaskBarItemTemplate.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/TaskBar.css"),
+
+ fillInTemplate: function() {
+ if (this.iconSrc) {
+ var img = document.createElement("img");
+ img.src = this.iconSrc;
+ this.domNode.appendChild(img);
+ }
+ this.domNode.appendChild(document.createTextNode(this.caption));
+ dojo.html.disableSelection(this.domNode);
+ },
+
+ postCreate: function() {
+ this.window=dojo.widget.getWidgetById(this.windowId);
+ this.window.explodeSrc = this.domNode;
+ dojo.event.connect(this.window, "destroy", this, "destroy")
+ },
+
+ onClick: function() {
+ this.window.toggleDisplay();
+ }
+});
+
+// summary:
+// Displays an icon for each associated floating pane, like Windows task bar
+dojo.widget.defineWidget(
+ "dojo.widget.TaskBar",
+ dojo.widget.FloatingPane,
+ function(){
+ this._addChildStack = [];
+ },
+{
+ // TODO: this class extends floating pane merely to get the shadow;
+ // it should extend HtmlWidget and then just call the shadow code directly
+ resizable: false,
+ titleBarDisplay: "none",
+
+ addChild: function(/*Widget*/ child) {
+ // summary: add taskbar item for specified FloatingPane
+ // TODO: this should not be called addChild(), as that has another meaning.
+ if(!this.containerNode){
+ this._addChildStack.push(child);
+ }else if(this._addChildStack.length > 0){
+ var oarr = this._addChildStack;
+ this._addChildStack = [];
+ dojo.lang.forEach(oarr, this.addChild, this);
+ }
+ var tbi = dojo.widget.createWidget("TaskBarItem",
+ { windowId: child.widgetId,
+ caption: child.title,
+ iconSrc: child.iconSrc
+ });
+ dojo.widget.TaskBar.superclass.addChild.call(this,tbi);
+ }
+});
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Textbox.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Textbox.js?view=auto&rev=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Textbox.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Textbox.js Fri Nov 10 01:15:01 2006
@@ -0,0 +1,94 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Textbox");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.Manager");
+dojo.require("dojo.widget.Parse");
+dojo.require("dojo.xml.Parse");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.lang.common");
+
+dojo.require("dojo.i18n.common");
+dojo.requireLocalization("dojo.widget", "validate");
+
+/*
+ ****** Textbox ******
+
+ This widget is a generic textbox field.
+ Serves as a base class to derive more specialized functionality in subclasses.
+ Has the following properties that can be specified as attributes in the markup.
+
+ @attr id The textbox id attribute.
+ @attr className The textbox class attribute.
+ @attr name The textbox name attribute.
+ @attr value The textbox value attribute.
+ @attr trim Removes leading and trailing whitespace if true. Default is false.
+ @attr uppercase Converts all characters to uppercase if true. Default is false.
+ @attr lowercase Converts all characters to lowercase if true. Default is false.
+ @attr ucFirst Converts the first character of each word to uppercase if true.
+ @attr lowercase Removes all characters that are not digits if true. Default is false.
+*/
+dojo.widget.defineWidget(
+ "dojo.widget.Textbox",
+ dojo.widget.HtmlWidget,
+ {
+ // default values for new subclass properties
+ className: "",
+ name: "",
+ value: "",
+ type: "",
+ trim: false,
+ uppercase: false,
+ lowercase: false,
+ ucFirst: false,
+ digit: false,
+ htmlfloat: "none",
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Textbox.html"),
+
+ // our DOM nodes
+ textbox: null,
+
+ // Apply various filters to textbox value
+ filter: function() {
+ if (this.trim) {
+ this.textbox.value = this.textbox.value.replace(/(^\s*|\s*$)/g, "");
+ }
+ if (this.uppercase) {
+ this.textbox.value = this.textbox.value.toUpperCase();
+ }
+ if (this.lowercase) {
+ this.textbox.value = this.textbox.value.toLowerCase();
+ }
+ if (this.ucFirst) {
+ this.textbox.value = this.textbox.value.replace(/\b\w+\b/g,
+ function(word) { return word.substring(0,1).toUpperCase() + word.substring(1).toLowerCase(); });
+ }
+ if (this.digit) {
+ this.textbox.value = this.textbox.value.replace(/\D/g, "");
+ }
+ },
+
+ // event handlers, you can over-ride these in your own subclasses
+ onfocus: function() {},
+ onblur: function() { this.filter(); },
+
+ // All functions below are called by create from dojo.widget.Widget
+ mixInProperties: function(localProperties, frag) {
+ dojo.widget.Textbox.superclass.mixInProperties.apply(this, arguments);
+ if ( localProperties["class"] ) {
+ this.className = localProperties["class"];
+ }
+ }
+ }
+);
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Textbox.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Textbox.js
------------------------------------------------------------------------------
svn:keywords = "Id Author LastChangedDate LastChangedBy LastChangedRevision"
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Textbox.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TimePicker.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TimePicker.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TimePicker.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TimePicker.js Fri Nov 10 01:15:01 2006
@@ -9,25 +9,284 @@
*/
dojo.provide("dojo.widget.TimePicker");
-dojo.provide("dojo.widget.TimePicker.util");
-dojo.require("dojo.widget.DomWidget");
-dojo.require("dojo.date");
-
-dojo.widget.TimePicker = function(){
- dojo.widget.Widget.call(this);
- this.widgetType = "TimePicker";
- this.isContainer = false;
- // the following aliases prevent breaking people using 0.2.x
- this.toRfcDateTime = dojo.widget.TimePicker.util.toRfcDateTime;
- this.fromRfcDateTime = dojo.widget.TimePicker.util.fromRfcDateTime;
- this.toAmPmHour = dojo.widget.TimePicker.util.toAmPmHour;
- this.fromAmPmHour = dojo.widget.TimePicker.util.fromAmPmHour;
-}
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.event.*");
+dojo.require("dojo.date.serialize");
+dojo.require("dojo.date.format");
+dojo.require("dojo.dom");
+dojo.require("dojo.html.style");
-dojo.inherits(dojo.widget.TimePicker, dojo.widget.Widget);
-dojo.widget.tags.addParseTreeHandler("dojo:timepicker");
+dojo.requireLocalization("dojo.i18n.calendar", "gregorian");
+dojo.requireLocalization("dojo.widget", "TimePicker");
-dojo.requireAfterIf("html", "dojo.widget.html.TimePicker");
+dojo.widget.defineWidget(
+ "dojo.widget.TimePicker",
+ dojo.widget.HtmlWidget,
+ function(){
+ // selected time, JS Date object
+ this.time = "";
+ // set following flag to true if a default time should be set
+ this.useDefaultTime = false;
+ // set the following to true to set default minutes to current time, false to // use zero
+ this.useDefaultMinutes = false;
+ // rfc 3339 date
+ this.storedTime = "";
+ // time currently selected in the UI, stored in hours, minutes, seconds in the format that will be actually displayed
+ this.currentTime = {};
+ this.classNames = {
+ selectedTime: "selectedItem"
+ };
+ this.any = "any"; //FIXME: never used?
+ // dom node indecies for selected hour, minute, amPm, and "any time option"
+ this.selectedTime = {
+ hour: "",
+ minute: "",
+ amPm: "",
+ anyTime: false
+ };
+
+ // minutes are ordered as follows: ["12", "6", "1", "7", "2", "8", "3", "9", "4", "10", "5", "11"]
+ this.hourIndexMap = ["", 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11, 0];
+ // minutes are ordered as follows: ["00", "30", "05", "35", "10", "40", "15", "45", "20", "50", "25", "55"]
+ this.minuteIndexMap = [0, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11];
+ },
+{
+ isContainer: false,
+ templatePath: dojo.uri.dojoUri("src/widget/templates/TimePicker.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/TimePicker.css"),
+
+ fillInTemplate: function(args, frag){
+ // Copy style info from input node to output node
+ var source = this.getFragNodeRef(frag);
+ dojo.html.copyStyle(this.domNode, source);
+
+ this.initData();
+ this.initUI();
+ },
+
+ postMixInProperties: function(localProperties, frag) {
+ dojo.widget.TimePicker.superclass.postMixInProperties.apply(this, arguments);
+ this.calendar = dojo.i18n.getLocalization("dojo.i18n.calendar", "gregorian", this.lang); // "am","pm"
+ this.widgetStrings = dojo.i18n.getLocalization("dojo.widget", "TimePicker", this.lang); // "any"
+ },
+
+ initData: function() {
+ // FIXME: doesn't currently validate the time before trying to set it
+ // Determine the date/time from stored info, or by default don't
+ // have a set time
+ // FIXME: should normalize against whitespace on storedTime... for now
+ // just a lame hack
+ if(this.storedTime.indexOf("T")!=-1 && this.storedTime.split("T")[1] && this.storedTime!=" " && this.storedTime.split("T")[1]!="any") {
+ this.time = dojo.widget.TimePicker.util.fromRfcDateTime(this.storedTime, this.useDefaultMinutes, this.selectedTime.anyTime);
+ } else if (this.useDefaultTime) {
+ this.time = dojo.widget.TimePicker.util.fromRfcDateTime("", this.useDefaultMinutes, this.selectedTime.anyTime);
+ } else {
+ this.selectedTime.anyTime = true;
+ this.time = dojo.widget.TimePicker.util.fromRfcDateTime("", 0, 1);
+ }
+ },
+
+ initUI: function() {
+ // set UI to match the currently selected time
+ if(!this.selectedTime.anyTime && this.time) {
+ var amPmHour = dojo.widget.TimePicker.util.toAmPmHour(this.time.getHours());
+ var hour = amPmHour[0];
+ var isAm = amPmHour[1];
+ var minute = this.time.getMinutes();
+ var minuteIndex = parseInt(minute/5);
+ this.onSetSelectedHour(this.hourIndexMap[hour]);
+ this.onSetSelectedMinute(this.minuteIndexMap[minuteIndex]);
+ this.onSetSelectedAmPm(isAm);
+ } else {
+ this.onSetSelectedAnyTime();
+ }
+ },
+
+ setTime: function(date) {
+ if(date) {
+ this.selectedTime.anyTime = false;
+ this.setDateTime(dojo.date.toRfc3339(date));
+ } else {
+ this.selectedTime.anyTime = true;
+ }
+ this.initData();
+ this.initUI();
+ },
+
+ setDateTime: function(rfcDate) {
+ this.storedTime = rfcDate;
+ },
+
+ onClearSelectedHour: function(evt) {
+ this.clearSelectedHour();
+ },
+
+ onClearSelectedMinute: function(evt) {
+ this.clearSelectedMinute();
+ },
+
+ onClearSelectedAmPm: function(evt) {
+ this.clearSelectedAmPm();
+ },
+
+ onClearSelectedAnyTime: function(evt) {
+ this.clearSelectedAnyTime();
+ if(this.selectedTime.anyTime) {
+ this.selectedTime.anyTime = false;
+ this.time = dojo.widget.TimePicker.util.fromRfcDateTime("", this.useDefaultMinutes);
+ this.initUI();
+ }
+ },
+
+ clearSelectedHour: function() {
+ var hourNodes = this.hourContainerNode.getElementsByTagName("td");
+ for (var i=0; i<hourNodes.length; i++) {
+ dojo.html.setClass(hourNodes.item(i), "");
+ }
+ },
+
+ clearSelectedMinute: function() {
+ var minuteNodes = this.minuteContainerNode.getElementsByTagName("td");
+ for (var i=0; i<minuteNodes.length; i++) {
+ dojo.html.setClass(minuteNodes.item(i), "");
+ }
+ },
+
+ clearSelectedAmPm: function() {
+ var amPmNodes = this.amPmContainerNode.getElementsByTagName("td");
+ for (var i=0; i<amPmNodes.length; i++) {
+ dojo.html.setClass(amPmNodes.item(i), "");
+ }
+ },
+
+ clearSelectedAnyTime: function() {
+ dojo.html.setClass(this.anyTimeContainerNode, "anyTimeContainer");
+ },
+
+ onSetSelectedHour: function(evt) {
+ this.onClearSelectedAnyTime();
+ this.onClearSelectedHour();
+ this.setSelectedHour(evt);
+ this.onSetTime();
+ },
+
+ setSelectedHour: function(evt) {
+ if(evt && evt.target) {
+ if(evt.target.nodeType == dojo.dom.ELEMENT_NODE) {
+ var eventTarget = evt.target;
+ } else {
+ var eventTarget = evt.target.parentNode;
+ }
+ dojo.event.browser.stopEvent(evt);
+ dojo.html.setClass(eventTarget, this.classNames.selectedTime);
+ this.selectedTime["hour"] = eventTarget.innerHTML;
+ } else if (!isNaN(evt)) {
+ var hourNodes = this.hourContainerNode.getElementsByTagName("td");
+ if(hourNodes.item(evt)) {
+ dojo.html.setClass(hourNodes.item(evt), this.classNames.selectedTime);
+ this.selectedTime["hour"] = hourNodes.item(evt).innerHTML;
+ }
+ }
+ this.selectedTime.anyTime = false;
+ },
+
+ onSetSelectedMinute: function(evt) {
+ this.onClearSelectedAnyTime();
+ this.onClearSelectedMinute();
+ this.setSelectedMinute(evt);
+ this.selectedTime.anyTime = false;
+ this.onSetTime();
+ },
+
+ setSelectedMinute: function(evt) {
+ if(evt && evt.target) {
+ if(evt.target.nodeType == dojo.dom.ELEMENT_NODE) {
+ var eventTarget = evt.target;
+ } else {
+ var eventTarget = evt.target.parentNode;
+ }
+ dojo.event.browser.stopEvent(evt);
+ dojo.html.setClass(eventTarget, this.classNames.selectedTime);
+ this.selectedTime["minute"] = eventTarget.innerHTML;
+ } else if (!isNaN(evt)) {
+ var minuteNodes = this.minuteContainerNode.getElementsByTagName("td");
+ if(minuteNodes.item(evt)) {
+ dojo.html.setClass(minuteNodes.item(evt), this.classNames.selectedTime);
+ this.selectedTime["minute"] = minuteNodes.item(evt).innerHTML;
+ }
+ }
+ },
+
+ onSetSelectedAmPm: function(evt) {
+ this.onClearSelectedAnyTime();
+ this.onClearSelectedAmPm();
+ this.setSelectedAmPm(evt);
+ this.selectedTime.anyTime = false;
+ this.onSetTime();
+ },
+
+ setSelectedAmPm: function(evt) {
+ var eventTarget = evt.target;
+ if(evt && eventTarget) {
+ if(eventTarget.nodeType != dojo.dom.ELEMENT_NODE) {
+ eventTarget = eventTarget.parentNode;
+ }
+ dojo.event.browser.stopEvent(evt);
+ this.selectedTime.amPm = eventTarget.id;
+ dojo.html.setClass(eventTarget, this.classNames.selectedTime);
+ } else {
+ evt = evt ? 0 : 1;
+ var amPmNodes = this.amPmContainerNode.getElementsByTagName("td");
+ if(amPmNodes.item(evt)) {
+ this.selectedTime.amPm = amPmNodes.item(evt).id;
+ dojo.html.setClass(amPmNodes.item(evt), this.classNames.selectedTime);
+ }
+ }
+ },
+
+ onSetSelectedAnyTime: function(evt) {
+ this.onClearSelectedHour();
+ this.onClearSelectedMinute();
+ this.onClearSelectedAmPm();
+ this.setSelectedAnyTime();
+ this.onSetTime();
+ },
+
+ setSelectedAnyTime: function(evt) {
+ this.selectedTime.anyTime = true;
+ dojo.html.setClass(this.anyTimeContainerNode, this.classNames.selectedTime + " " + "anyTimeContainer");
+ },
+
+ onClick: function(evt) {
+ dojo.event.browser.stopEvent(evt);
+ },
+
+ onSetTime: function() {
+ if(this.selectedTime.anyTime) {
+ this.time = new Date();
+ var tempDateTime = dojo.widget.TimePicker.util.toRfcDateTime(this.time);
+ this.setDateTime(tempDateTime.split("T")[0]);
+ } else {
+ var hour = 12;
+ var minute = 0;
+ var isAm = false;
+ if(this.selectedTime["hour"]) {
+ hour = parseInt(this.selectedTime["hour"], 10);
+ }
+ if(this.selectedTime["minute"]) {
+ minute = parseInt(this.selectedTime["minute"], 10);
+ }
+ if(this.selectedTime["amPm"]) {
+ isAm = (this.selectedTime["amPm"].toLowerCase() == "am");
+ }
+ this.time = new Date();
+ this.time.setHours(dojo.widget.TimePicker.util.fromAmPmHour(hour, isAm));
+ this.time.setMinutes(minute);
+ this.setDateTime(dojo.widget.TimePicker.util.toRfcDateTime(this.time));
+ }
+ }
+});
dojo.widget.TimePicker.util = new function() {
// utility functions
@@ -35,7 +294,8 @@
if(!jsDate) {
jsDate = new Date();
}
- return dojo.date.format(jsDate, "%Y-%m-%dT%H:%M:00%z");
+ jsDate.setSeconds(0);
+ return dojo.date.strftime(jsDate, "%Y-%m-%dT%H:%M:00%z"); //FIXME: use dojo.date.toRfc3339 instead
}
this.fromRfcDateTime = function(rfcDate, useDefaultMinutes, isAnyTime) {
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TitlePane.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TitlePane.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TitlePane.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TitlePane.js Fri Nov 10 01:15:01 2006
@@ -9,4 +9,53 @@
*/
dojo.provide("dojo.widget.TitlePane");
-dojo.requireAfterIf("html", "dojo.widget.html.TitlePane");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.ContentPane");
+dojo.require("dojo.html.style");
+dojo.require("dojo.lfx.*");
+
+dojo.widget.defineWidget(
+ "dojo.widget.TitlePane",
+ dojo.widget.ContentPane,
+{
+ labelNode: "",
+ labelNodeClass: "",
+ containerNodeClass: "",
+ label: "",
+
+ open: true,
+ templatePath: dojo.uri.dojoUri("src/widget/templates/TitlePane.html"),
+
+ postCreate: function() {
+ if (this.label) {
+ this.labelNode.appendChild(document.createTextNode(this.label));
+ }
+
+ if (this.labelNodeClass) {
+ dojo.html.addClass(this.labelNode, this.labelNodeClass);
+ }
+
+ if (this.containerNodeClass) {
+ dojo.html.addClass(this.containerNode, this.containerNodeClass);
+ }
+
+ if (!this.open) {
+ dojo.html.hide(this.containerNode);
+ }
+ dojo.widget.TitlePane.superclass.postCreate.apply(this, arguments);
+ },
+
+ onLabelClick: function() {
+ if (this.open) {
+ dojo.lfx.wipeOut(this.containerNode, 250).play();
+ this.open=false;
+ } else {
+ dojo.lfx.wipeIn(this.containerNode, 250).play();
+ this.open=true;
+ }
+ },
+
+ setLabel: function(label) {
+ this.labelNode.innerHTML=label;
+ }
+});
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toaster.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toaster.js?view=auto&rev=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toaster.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toaster.js Fri Nov 10 01:15:01 2006
@@ -0,0 +1,245 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.Toaster");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.lfx.*");
+dojo.require("dojo.html.iframe");
+
+// This is mostly taken from Jesse Kuhnert's MessageNotifier.
+// Modified by Bryan Forbes to support topics and a variable delay.
+
+dojo.widget.defineWidget(
+ "dojo.widget.Toaster",
+ dojo.widget.HtmlWidget,
+ {
+ templateString: '<div dojoAttachPoint="clipNode"><div dojoAttachPoint="containerNode" dojoAttachEvent="onClick:onSelect"><div dojoAttachPoint="contentNode"></div></div></div>',
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/Toaster.css"),
+
+ clipNode: null,
+
+ messageTopic: "",
+ contentNode: null,
+
+ _scrollConnected: false,
+
+ // possible message types
+ messageTypes: {
+ MESSAGE: "MESSAGE",
+ WARNING: "WARNING",
+ ERROR: "ERROR",
+ FATAL: "FATAL"
+ },
+ defaultType: "MESSAGE",
+
+ // css classes
+ clipCssClass: "dojoToasterClip",
+ containerCssClass: "dojoToasterContainer",
+ contentCssClass: "dojoToasterContent",
+ messageCssClass: "dojoToasterMessage",
+ warningCssClass: "dojoToasterWarning",
+ errorCssClass: "dojoToasterError",
+ fatalCssClass: "dojoToasterFatal",
+
+ positionDirection: "br-up",
+ positionDirectionTypes: ["br-up", "br-left", "bl-up", "bl-right", "tr-down", "tr-left", "tl-down", "tl-right"],
+ showDelay: 2000,
+
+ slideAnim: null,
+ fadeAnim: null,
+
+ bgIframe: null,
+
+ postCreate: function(){
+ this.hide();
+ dojo.html.setClass(this.clipNode, this.clipCssClass);
+ dojo.html.addClass(this.containerNode, this.containerCssClass);
+ dojo.html.setClass(this.contentNode, this.contentCssClass);
+ if(this.messageTopic){
+ dojo.event.topic.subscribe(this.messageTopic, this, "handleMessage");
+ }
+ if(!this.positionDirection || !dojo.lang.inArray(this.positionDirectionTypes, this.positionDirection)){
+ this.positionDirection = this.positionDirectionTypes.BRU;
+ }
+ },
+
+ handleMessage: function(msg){
+ if(dojo.lang.isString(msg)){
+ this.setContent(msg);
+ }else{
+ this.setContent(msg["message"], msg["type"], msg["delay"]);
+ }
+ },
+
+ setContent: function(msg, messageType, delay){
+ var delay = delay||this.showDelay;
+ // sync animations so there are no ghosted fades and such
+ if(this.slideAnim && this.slideAnim.status() == "playing"){
+ dojo.lang.setTimeout(50, dojo.lang.hitch(this, function(){
+ this.setContent(msg, messageType);
+ }));
+ return;
+ }else if(this.slideAnim){
+ this.slideAnim.stop();
+ if(this.fadeAnim) this.fadeAnim.stop();
+ }
+ if(!msg){
+ dojo.debug(this.widgetId + ".setContent() incoming content was null, ignoring.");
+ return;
+ }
+ if(!this.positionDirection || !dojo.lang.inArray(this.positionDirectionTypes, this.positionDirection)){
+ dojo.raise(this.widgetId + ".positionDirection is an invalid value: " + this.positionDirection);
+ }
+
+ // determine type of content and apply appropriately
+ dojo.html.removeClass(this.containerNode, this.messageCssClass);
+ dojo.html.removeClass(this.containerNode, this.warningCssClass);
+ dojo.html.removeClass(this.containerNode, this.errorCssClass);
+ dojo.html.removeClass(this.containerNode, this.fatalCssClass);
+
+ dojo.html.clearOpacity(this.containerNode);
+
+ if(msg instanceof String || typeof msg == "string"){
+ this.contentNode.innerHTML = msg;
+ }else if(dojo.html.isNode(msg)){
+ this.contentNode.innerHTML = dojo.html.getContentAsString(msg);
+ }else{
+ dojo.raise("Toaster.setContent(): msg is of unknown type:" + msg);
+ }
+
+ switch(messageType){
+ case this.messageTypes.WARNING:
+ dojo.html.addClass(this.containerNode, this.warningCssClass);
+ break;
+ case this.messageTypes.ERROR:
+ dojo.html.addClass(this.containerNode, this.errorCssClass);
+ break
+ case this.messageTypes.FATAL:
+ dojo.html.addClass(this.containerNode, this.fatalCssClass);
+ break;
+ case this.messageTypes.MESSAGE:
+ default:
+ dojo.html.addClass(this.containerNode, this.messageCssClass);
+ break;
+ }
+
+ // now do funky animation of widget appearing from
+ // bottom right of page and up
+ this.show();
+
+ var nodeSize = dojo.html.getMarginBox(this.containerNode);
+
+ // sets up initial position of container node and slide-out direction
+ if(this.positionDirection.indexOf("-up") >= 0){
+ this.containerNode.style.left=0+"px";
+ this.containerNode.style.top=nodeSize.height + 10 + "px";
+ }else if(this.positionDirection.indexOf("-left") >= 0){
+ this.containerNode.style.left=nodeSize.width + 10 +"px";
+ this.containerNode.style.top=0+"px";
+ }else if(this.positionDirection.indexOf("-right") >= 0){
+ this.containerNode.style.left = 0 - nodeSize.width - 10 + "px";
+ this.containerNode.style.top = 0+"px";
+ }else if(this.positionDirection.indexOf("-down") >= 0){
+ this.containerNode.style.left = 0+"px";
+ this.containerNode.style.top = 0 - nodeSize.height - 10 + "px";
+ }else{
+ dojo.raise(this.widgetId + ".positionDirection is an invalid value: " + this.positionDirection);
+ }
+
+ this.slideAnim = dojo.lfx.html.slideTo(
+ this.containerNode,
+ { top: 0, left: 0 },
+ 450,
+ null,
+ dojo.lang.hitch(this, function(nodes, anim){
+ dojo.lang.setTimeout(dojo.lang.hitch(this, function(evt){
+ // we must hide the iframe in order to fade
+ // TODO: figure out how to fade with a BackgroundIframe
+ if(this.bgIframe){
+ this.bgIframe.hide();
+ }
+ // can't do a fadeHide because we're fading the
+ // inner node rather than the clipping node
+ this.fadeAnim = dojo.lfx.html.fadeOut(
+ this.containerNode,
+ 1000,
+ null,
+ dojo.lang.hitch(this, function(evt){
+ this.hide();
+ })).play();
+ }), delay);
+ })).play();
+ },
+
+ placeClip: function(){
+ var scroll = dojo.html.getScroll();
+ var view = dojo.html.getViewport();
+
+ var nodeSize = dojo.html.getMarginBox(this.containerNode);
+
+ // sets up the size of the clipping node
+ this.clipNode.style.height = nodeSize.height+"px";
+ this.clipNode.style.width = nodeSize.width+"px";
+
+ // sets up the position of the clipping node
+ if(this.positionDirection.match(/^t/)){
+ this.clipNode.style.top = scroll.top+"px";
+ }else if(this.positionDirection.match(/^b/)){
+ this.clipNode.style.top = (view.height - nodeSize.height - 2 + scroll.top)+"px";
+ }
+ if(this.positionDirection.match(/^[tb]r-/)){
+ this.clipNode.style.left = (view.width - nodeSize.width - 1 - scroll.left)+"px";
+ }else if(this.positionDirection.match(/^[tb]l-/)){
+ this.clipNode.style.left = 0 + "px";
+ }
+
+ this.clipNode.style.clip = "rect(0px, " + nodeSize.width + "px, " + nodeSize.height + "px, 0px)";
+
+ if(dojo.render.html.ie){
+ if(!this.bgIframe){
+ this.bgIframe = new dojo.html.BackgroundIframe(this.containerNode);
+ this.bgIframe.setZIndex(this.containerNode);
+ }
+ this.bgIframe.onResized();
+ this.bgIframe.show();
+ }
+ },
+
+ onSelect: function(e) { },
+
+ onScroll: function(){
+ this.placeClip();
+ },
+
+ show: function(){
+ dojo.widget.Toaster.superclass.show.call(this);
+
+ this.placeClip();
+
+ if(!this._scrollConnected){
+ this._scrollConnected = true;
+ dojo.event.connect(window, "onscroll", this, "onScroll");
+ }
+ },
+
+ hide: function(){
+ dojo.widget.Toaster.superclass.hide.call(this);
+
+ if(this._scrollConnected){
+ this._scrollConnected = false;
+ dojo.event.disconnect(window, "onscroll", this, "onScroll");
+ }
+
+ dojo.html.setOpacity(this.containerNode, 1.0);
+ }
+ },
+ "html"
+);
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toaster.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toaster.js
------------------------------------------------------------------------------
svn:keywords = "Id Author LastChangedDate LastChangedBy LastChangedRevision"
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toaster.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toggler.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toggler.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toggler.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toggler.js Fri Nov 10 01:15:01 2006
@@ -8,33 +8,27 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-dojo.provide("dojo.widget.Toggler");
-dojo.require("dojo.widget.*");
-dojo.require("dojo.event.*");
-
-// clicking on this node shows/hides another widget
-
-dojo.widget.Toggler = function(){
- dojo.widget.DomWidget.call(this);
-}
-
-dojo.inherits(dojo.widget.Toggler, dojo.widget.DomWidget);
-
-dojo.lang.extend(dojo.widget.Toggler, {
- widgetType: "Toggler",
-
- // Associated widget
- targetId: '',
-
- fillInTemplate: function() {
- dojo.event.connect(this.domNode, "onclick", this, "onClick");
- },
-
- onClick: function() {
- var pane = dojo.widget.byId(this.targetId);
- if(!pane){ return; }
- pane.explodeSrc = this.domNode;
- pane.toggleShowing();
- }
-});
-dojo.widget.tags.addParseTreeHandler("dojo:toggler");
+dojo.provide("dojo.widget.Toggler");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+
+// clicking on this node shows/hides another widget
+
+dojo.widget.defineWidget(
+ "dojo.widget.Toggler",
+ dojo.widget.HtmlWidget,
+{
+ // Associated widget
+ targetId: '',
+
+ fillInTemplate: function() {
+ dojo.event.connect(this.domNode, "onclick", this, "onClick");
+ },
+
+ onClick: function() {
+ var pane = dojo.widget.byId(this.targetId);
+ if(!pane){ return; }
+ pane.explodeSrc = this.domNode;
+ pane.toggleShowing();
+ }
+});