You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/01/11 23:36:18 UTC
svn commit: r495409 [38/47] - 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/...
Added: 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=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Spinner.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Spinner.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,622 @@
+/*
+ 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.Spinner");
+
+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.widget.IntegerTextbox");
+dojo.require("dojo.widget.RealNumberTextbox");
+dojo.require("dojo.widget.DateTextbox");
+
+dojo.require("dojo.experimental");
+
+dojo.declare(
+ "dojo.widget.Spinner",
+ null,
+ {
+ // 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.
+
+ _typamaticTimer: null,
+ _typamaticFunction: null,
+ _currentTimeout: this.defaultTimeout,
+ _eventCount: 0,
+
+ // defaultTimeout: Number
+ // number of milliseconds before a held key or button becomes typematic
+ defaultTimeout: 500,
+
+ // timeoutChangeRate: 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"),
+
+ // incrementSrc: String
+ // up arrow graphic URL
+ incrementSrc: dojo.uri.dojoUri("src/widget/templates/images/spinnerIncrement.gif"),
+
+ // decrementSrc: 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++;
+ },
+
+ _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);
+ }
+ },
+
+ _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);
+ }
+ },
+
+ _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;
+ },
+
+ _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");
+ }
+ }
+);
+
+dojo.widget.defineWidget(
+ "dojo.widget.IntegerSpinner",
+ [dojo.widget.IntegerTextbox, dojo.widget.Spinner],
+{
+ // summary: an IntegerTextbox with +/- buttons
+
+ // delta: 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);
+ },
+
+ adjustValue: function(/*Number*/ direction, /*Number*/ x){
+ // sumary
+ // spin the input field
+ // direction < 0: spin down
+ // direction > 0: spin up
+ // direction = 0: revalidate existing value
+
+ 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
+
+ this.setValue(val);
+
+ return val.length;
+ }
+});
+
+dojo.widget.defineWidget(
+ "dojo.widget.RealNumberSpinner",
+ [dojo.widget.RealNumberTextbox, dojo.widget.Spinner],
+ function(){ dojo.experimental("dojo.widget.RealNumberSpinner"); },
+{
+ // summary
+ // A RealNumberTextbox with +/- buttons
+
+ // delta: Number
+ // amount that pushing a button changes the value?
+ 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(/*Number*/ direction, /*Number*/ x){
+ var val = this.getValue().replace(/[^\-+\.eE\d]/g, "");
+ if(!val.length){ return; }
+
+ var num = parseFloat(val);
+ if(isNaN(num)){ return; }
+ var delta = this.delta.split(/[eE]/);
+ if(!delta.length){
+ delta = [1, 1];
+ }else{
+ delta[0] = parseFloat(delta[0].replace(/[^\-+\.\d]/g, ""));
+ if(isNaN(delta[0])){ delta[0] = 1; }
+ if(delta.length > 1){
+ delta[1] = parseInt(delta[1]);
+ }
+ if(isNaN(delta[1])){ delta[1] = 1; }
+ }
+ val = this.getValue().split(/[eE]/);
+ if(!val.length){ return; }
+ var numBase = parseFloat(val[0].replace(/[^\-+\.\d]/g, ""));
+ if(val.length == 1){
+ var numExp = 0;
+ }else{
+ var numExp = parseInt(val[1].replace(/[^\-+\d]/g, ""));
+ }
+ if(x <= val[0].length){
+ x = 0;
+ numBase += delta[0] * direction;
+ }else{
+ x = Number.MAX_VALUE;
+ numExp += delta[1] * direction;
+ if(this.flags.eSigned == false && numExp < 0){
+ numExp = 0;
+ }
+ }
+ 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();
+ }else{
+ val = num.toExponential(this.flags.places);
+ }
+ }else if(num.toFixed && num.toPrecision){
+ if(isNaN(this.flags.places) || this.flags.places == Infinity){
+ val = num.toPrecision((1/3).toString().length-1);
+ }else{
+ val = num.toFixed(this.flags.places);
+ }
+ }else{
+ val = num.toString();
+ }
+
+ if(num >= 0){
+ if(this.flags.signed == true){
+ val = '+' + val;
+ }
+ }
+ val = val.split(/[eE]/);
+ if(this.flags.separator.length > 0){
+ if(num >= 0 && val[0].substr(0,1) != '+'){
+ val[0] = ' ' + val[0]; // make sure first char is nondigit for easy algorithm
+ }
+ var i = val[0].lastIndexOf('.');
+ if(i >= 0){
+ i -= 3;
+ }else{
+ i = val[0].length-3;
+ }
+ for (; i > 1; i-=3){
+ val[0] = val[0].substr(0,i)+this.flags.separator+val[0].substr(i);
+ }
+ if(val[0].substr(0,1) == ' '){ val[0] = val[0].substr(1); } // remove space
+ }
+ if(val.length > 1){
+ if((this.flags.eSigned == true)&&(val[1].substr(0,1) != '+')){
+ val[1] = '+' + val[1];
+ }else if((!this.flags.eSigned)&&(val[1].substr(0,1) == '+')){
+ val[1] = val[1].substr(1);
+ }else if((!this.flags.eSigned)&&(val[1].substr(0,1) == '-')&&(num.toFixed && num.toPrecision)){
+ if(isNaN(this.flags.places)){
+ val[0] = num.toPrecision((1/3).toString().length-1);
+ }else{
+ val[0] = num.toFixed(this.flags.places).toString();
+ }
+ val[1] = "0";
+ }
+ val[0] += 'e' + val[1];
+ }
+ this.setValue(val[0]);
+ if(x > val[0].length){ x = val[0].length; }
+ return x;
+ }
+});
+
+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;
+ }
+ }
+ }
+
+ 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;
+ }
+});
Added: 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=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SplitContainer.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SplitContainer.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,540 @@
+/*
+ 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.SplitContainer");
+
+//
+// TODO
+// make it prettier
+// active dragging upwards doesn't always shift other bars (direction calculation is wrong in this case)
+//
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.ContentPane");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.html.style");
+dojo.require("dojo.html.layout");
+dojo.require("dojo.html.selection");
+dojo.require("dojo.io.cookie");
+
+dojo.widget.defineWidget(
+ "dojo.widget.SplitContainer",
+ dojo.widget.HtmlWidget,
+ function(){
+ this.sizers = [];
+ },
+{
+ // summary
+ // Contains multiple children widgets, all of which are displayed side by side
+ // (either horizontally or vertically); there's a bar between each of the children,
+ // and you can adjust the relative size of each child by dragging the bars.
+ //
+ // You must specify a size (width and height) for the SplitContainer.
+
+ isContainer: true,
+
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/SplitContainer.css"),
+
+ // activeSizing: Boolean
+ // If true, the children's size changes as you drag the bar;
+ // otherwise, the sizes don't change until you drop the bar (by mouse-up)
+ activeSizing: false,
+
+ // sizerWidget: Integer
+ // Size in pixels of the bar between each child
+ sizerWidth: 15,
+
+ // orientation: String
+ // either 'horizontal' or vertical; indicates whether the children are
+ // arranged side-by-side or up/down.
+ orientation: 'horizontal',
+
+ // persist: Boolean
+ // Save splitter positions in a cookie
+ persist: true,
+
+ postMixInProperties: function(){
+ dojo.widget.SplitContainer.superclass.postMixInProperties.apply(this, arguments);
+ this.isHorizontal = (this.orientation == 'horizontal');
+ },
+
+ fillInTemplate: function(){
+ dojo.widget.SplitContainer.superclass.fillInTemplate.apply(this, arguments);
+ dojo.html.addClass(this.domNode, "dojoSplitContainer");
+ // 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;
+ },
+
+ onResized: function(e){
+ var content = dojo.html.getContentBox(this.domNode);
+ this.paneWidth = content.width;
+ this.paneHeight = content.height;
+ this._layoutPanels();
+ },
+
+ postCreate: function(args, fragment, parentComp){
+ dojo.widget.SplitContainer.superclass.postCreate.apply(this, arguments);
+ // attach the children and create the draggers
+ for(var i=0; i<this.children.length; i++){
+ with(this.children[i].domNode.style){
+ position = "absolute";
+ }
+ dojo.html.addClass(this.children[i].domNode,
+ "dojoSplitPane");
+
+ if(i == this.children.length-1){
+ break;
+ }
+
+ this._addSizer();
+ }
+
+ // 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';
+ //this.virtualSizer.style.backgroundColor = 'lime';
+ this.virtualSizer.style.zIndex = 10;
+ this.virtualSizer.className = this.isHorizontal ? 'dojoSplitContainerVirtualSizerH' : 'dojoSplitContainerVirtualSizerV';
+ this.domNode.appendChild(this.virtualSizer);
+
+ dojo.html.disableSelection(this.virtualSizer);
+
+ if(this.persist){
+ this._restoreState();
+ }
+
+ // size the panels once the browser has caught up
+ this.resizeSoon();
+ },
+
+ _injectChild: function(child) {
+ with(child.domNode.style){
+ position = "absolute";
+ }
+ dojo.html.addClass(child.domNode,
+ "dojoSplitPane");
+ },
+
+ _addSizer: function() {
+ var i = this.sizers.length;
+
+ this.sizers[i] = document.createElement('div');
+ this.sizers[i].style.position = 'absolute';
+ this.sizers[i].className = this.isHorizontal ? 'dojoSplitContainerSizerH' : 'dojoSplitContainerSizerV';
+
+ var self = this;
+ var handler = (function(){ var sizer_i = i; return function(e){ self.beginSizing(e, sizer_i); } })();
+ dojo.event.connect(this.sizers[i], "onmousedown", handler);
+
+ this.domNode.appendChild(this.sizers[i]);
+ dojo.html.disableSelection(this.sizers[i]);
+ },
+
+ removeChild: function(widget){
+ // Remove sizer, but only if widget is really our child and
+ // we have at least one sizer to throw away
+ if (this.sizers.length > 0) {
+ for(var x=0; x<this.children.length; x++){
+ if(this.children[x] === widget){
+ var i = this.sizers.length - 1;
+ this.domNode.removeChild(this.sizers[i]);
+ this.sizers.length = i;
+ break;
+ }
+ }
+ }
+
+ // Remove widget and repaint
+ dojo.widget.SplitContainer.superclass.removeChild.call(this, widget, arguments);
+ this.onResized();
+ },
+
+ addChild: function(widget){
+ dojo.widget.SplitContainer.superclass.addChild.apply(this, arguments);
+ this._injectChild(widget);
+
+ if (this.children.length > 1) {
+ this._addSizer();
+ }
+
+ this._layoutPanels();
+ },
+
+ _layoutPanels: function(){
+ if (this.children.length == 0){ return; }
+
+ //
+ // calculate space
+ //
+
+ var space = this.isHorizontal ? this.paneWidth : this.paneHeight;
+ if (this.children.length > 1){
+ space -= this.sizerWidth * (this.children.length - 1);
+ }
+
+
+ //
+ // calculate total of SizeShare values
+ //
+
+ var out_of = 0;
+ for(var i=0; i<this.children.length; i++){
+ out_of += this.children[i].sizeShare;
+ }
+
+
+ //
+ // work out actual pixels per sizeshare unit
+ //
+
+ var pix_per_unit = space / out_of;
+
+
+ //
+ // set the SizeActual member of each pane
+ //
+
+ var total_size = 0;
+
+ for(var i=0; i<this.children.length-1; i++){
+ var size = Math.round(pix_per_unit * this.children[i].sizeShare);
+ this.children[i].sizeActual = size;
+ total_size += size;
+ }
+ this.children[this.children.length-1].sizeActual = space - total_size;
+
+ //
+ // make sure the sizes are ok
+ //
+
+ this._checkSizes();
+
+
+ //
+ // now loop, positioning each pane and letting children resize themselves
+ //
+
+ var pos = 0;
+ var size = this.children[0].sizeActual;
+ this._movePanel(this.children[0], pos, size);
+ this.children[0].position = pos;
+ pos += size;
+
+ for(var i=1; i<this.children.length; i++){
+
+ // first we position the sizing handle before this pane
+ this._moveSlider(this.sizers[i-1], pos, this.sizerWidth);
+ this.sizers[i-1].position = pos;
+ pos += this.sizerWidth;
+
+ size = this.children[i].sizeActual;
+ this._movePanel(this.children[i], pos, size);
+ this.children[i].position = pos;
+ pos += size;
+ }
+ },
+
+ _movePanel: function(/*Widget*/ panel, pos, size){
+ if (this.isHorizontal){
+ panel.domNode.style.left = pos + 'px';
+ panel.domNode.style.top = 0;
+ panel.resizeTo(size, this.paneHeight);
+ }else{
+ panel.domNode.style.left = 0;
+ panel.domNode.style.top = pos + 'px';
+ panel.resizeTo(this.paneWidth, size);
+ }
+ },
+
+ _moveSlider: function(/*DomNode*/ slider, pos, size){
+ if (this.isHorizontal){
+ slider.style.left = pos + 'px';
+ slider.style.top = 0;
+ dojo.html.setMarginBox(slider, { width: size, height: this.paneHeight });
+ }else{
+ slider.style.left = 0;
+ slider.style.top = pos + 'px';
+ dojo.html.setMarginBox(slider, { width: this.paneWidth, height: size });
+ }
+ },
+
+ _growPane: function(growth, pane){
+ if (growth > 0){
+ if (pane.sizeActual > pane.sizeMin){
+ if ((pane.sizeActual - pane.sizeMin) > growth){
+
+ // stick all the growth in this pane
+ pane.sizeActual = pane.sizeActual - growth;
+ growth = 0;
+ }else{
+ // put as much growth in here as we can
+ growth -= pane.sizeActual - pane.sizeMin;
+ pane.sizeActual = pane.sizeMin;
+ }
+ }
+ }
+ return growth;
+ },
+
+ _checkSizes: function(){
+
+ var total_min_size = 0;
+ var total_size = 0;
+
+ for(var i=0; i<this.children.length; i++){
+
+ total_size += this.children[i].sizeActual;
+ total_min_size += this.children[i].sizeMin;
+ }
+
+ // only make adjustments if we have enough space for all the minimums
+
+ if (total_min_size <= total_size){
+
+ var growth = 0;
+
+ for(var i=0; i<this.children.length; i++){
+
+ if (this.children[i].sizeActual < this.children[i].sizeMin){
+
+ growth += this.children[i].sizeMin - this.children[i].sizeActual;
+ this.children[i].sizeActual = this.children[i].sizeMin;
+ }
+ }
+
+ if (growth > 0){
+ if (this.isDraggingLeft){
+ for(var i=this.children.length-1; i>=0; i--){
+ growth = this._growPane(growth, this.children[i]);
+ }
+ }else{
+ for(var i=0; i<this.children.length; i++){
+ growth = this._growPane(growth, this.children[i]);
+ }
+ }
+ }
+ }else{
+
+ for(var i=0; i<this.children.length; i++){
+ this.children[i].sizeActual = Math.round(total_size * (this.children[i].sizeMin / total_min_size));
+ }
+ }
+ },
+
+ beginSizing: function(e, i){
+ this.paneBefore = this.children[i];
+ this.paneAfter = this.children[i+1];
+
+ this.isSizing = true;
+ this.sizingSplitter = this.sizers[i];
+ 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.activeSizing){
+ this._showSizingLine();
+ }
+
+ //
+ // attach mouse events
+ //
+
+ dojo.event.connect(document.documentElement, "onmousemove", this, "changeSizing");
+ dojo.event.connect(document.documentElement, "onmouseup", this, "endSizing");
+ dojo.event.browser.stopEvent(e);
+ },
+
+ changeSizing: function(e){
+ this.lastPoint = this.isHorizontal ? e.pageX : e.pageY;
+ if (this.activeSizing){
+ this.movePoint();
+ this._updateSize();
+ }else{
+ this.movePoint();
+ this._moveSizingLine();
+ }
+ dojo.event.browser.stopEvent(e);
+ },
+
+ endSizing: function(e){
+
+ if (!this.activeSizing){
+ this._hideSizingLine();
+ }
+
+ this._updateSize();
+
+ this.isSizing = false;
+
+ dojo.event.disconnect(document.documentElement, "onmousemove", this, "changeSizing");
+ dojo.event.disconnect(document.documentElement, "onmouseup", this, "endSizing");
+
+ if(this.persist){
+ this._saveState(this);
+ }
+ },
+
+ movePoint: function(){
+
+ // make sure lastPoint is a legal point to drag to
+ var p = this.lastPoint - this.screenToClientOffset;
+
+ var a = p - this.dragOffset;
+ a = this.legaliseSplitPoint(a);
+ p = a + this.dragOffset;
+
+ this.lastPoint = p + this.screenToClientOffset;
+ },
+
+ legaliseSplitPoint: function(a){
+
+ a += this.sizingSplitter.position;
+
+ this.isDraggingLeft = (a > 0) ? true : false;
+
+ if (!this.activeSizing){
+
+ if (a < this.paneBefore.position + this.paneBefore.sizeMin){
+
+ a = this.paneBefore.position + this.paneBefore.sizeMin;
+ }
+
+ if (a > this.paneAfter.position + (this.paneAfter.sizeActual - (this.sizerWidth + this.paneAfter.sizeMin))){
+
+ a = this.paneAfter.position + (this.paneAfter.sizeActual - (this.sizerWidth + this.paneAfter.sizeMin));
+ }
+ }
+
+ a -= this.sizingSplitter.position;
+
+ this._checkSizes();
+
+ return a;
+ },
+
+ _updateSize: function(){
+ var pos = this.lastPoint - this.dragOffset - this.originPos;
+
+ var start_region = this.paneBefore.position;
+ var end_region = this.paneAfter.position + this.paneAfter.sizeActual;
+
+ this.paneBefore.sizeActual = pos - start_region;
+ this.paneAfter.position = pos + this.sizerWidth;
+ this.paneAfter.sizeActual = end_region - this.paneAfter.position;
+
+ for(var i=0; i<this.children.length; i++){
+
+ this.children[i].sizeShare = this.children[i].sizeActual;
+ }
+
+ this._layoutPanels();
+ },
+
+ _showSizingLine: function(){
+
+ this._moveSizingLine();
+
+ if (this.isHorizontal){
+ dojo.html.setMarginBox(this.virtualSizer, { width: this.sizerWidth, height: this.paneHeight });
+ }else{
+ 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 pos = this.lastPoint - this.startPoint + this.sizingSplitter.position;
+ if (this.isHorizontal){
+ this.virtualSizer.style.left = pos + 'px';
+ }else{
+ var pos = (this.lastPoint - this.startPoint) + this.sizingSplitter.position;
+ this.virtualSizer.style.top = pos + 'px';
+ }
+
+ },
+
+ _getCookieName: function(i) {
+ return this.widgetId + "_" + i;
+ },
+
+ _restoreState: function () {
+ for(var i=0; i<this.children.length; i++) {
+ var cookieName = this._getCookieName(i);
+ var cookieValue = dojo.io.cookie.getCookie(cookieName);
+ if (cookieValue != null) {
+ var pos = parseInt(cookieValue);
+ if (typeof pos == "number") {
+ this.children[i].sizeShare=pos;
+ }
+ }
+ }
+ },
+
+ _saveState: function (){
+ for(var i=0; i<this.children.length; i++) {
+ var cookieName = this._getCookieName(i);
+ dojo.io.cookie.setCookie(cookieName, this.children[i].sizeShare, null, null, null, null);
+ }
+ }
+});
+
+// These arguments can be specified for the children of a SplitContainer.
+// Since any widget can be specified as a SplitContainer child, mix them
+// into the base widget class. (This is a hack, but it's effective.)
+dojo.lang.extend(dojo.widget.Widget, {
+ // sizeMin: Integer
+ // Minimum size (width or height) of a child of a SplitContainer.
+ // The value is relative to other children's sizeShare properties.
+ sizeMin: 10,
+
+ // sizeShare: Integer
+ // Size (width or height) of a child of a SplitContainer.
+ // The value is relative to other children's sizeShare properties.
+ // For example, if there are two children and each has sizeShare=10, then
+ // each takes up 50% of the available space.
+ sizeShare: 10
+});
+
+// Deprecated class for split pane children.
+// Actually any widget can be the child of a split pane
+dojo.widget.defineWidget(
+ "dojo.widget.SplitContainerPanel",
+ dojo.widget.ContentPane,
+ {}
+);
+
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgButton.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgButton.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgButton.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgButton.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,142 @@
+/*
+ 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
+*/
+
+// FIXME: not yet functional
+
+dojo.provide("dojo.widget.SvgButton");
+
+dojo.require("dojo.experimental");
+dojo.experimental("dojo.widget.SvgButton");
+
+dojo.widget.SvgButton = function(){
+ // FIXME: this is incomplete and doesn't work yet
+ // if DOMButton turns into a mixin, we should subclass Button instead and
+ // just mix in the DOMButton properties.
+
+ dojo.widget.DomButton.call(this);
+ dojo.widget.SvgWidget.call(this);
+
+ // FIXME: freaking implement this already!
+ this.onFoo = function(){ alert("bar"); }
+
+ this.label = "huzzah!";
+
+ this.setLabel = function(x, y, textSize, label, shape){
+ //var labelNode = this.domNode.ownerDocument.createTextNode(this.label);
+ //var textNode = this.domNode.ownerDocument.createElement("text");
+ var coords = dojo.widget.SvgButton.prototype.coordinates(x, y, textSize, label, shape);
+ var textString = "";
+ switch(shape) {
+ case "ellipse":
+ textString = "<text x='"+ coords[6] + "' y='"+ coords[7] + "'>"+ label + "</text>";
+ //textNode.setAttribute("x", coords[6]);
+ //textNode.setAttribute("y", coords[7]);
+ break;
+ case "rectangle":
+ //FIXME: implement
+ textString = "";
+ //textNode.setAttribute("x", coords[6]);
+ //textNode.setAttribute("y", coords[7]);
+ break;
+ case "circle":
+ //FIXME: implement
+ textString = "";
+ //textNode.setAttribute("x", coords[6]);
+ //textNode.setAttribute("y", coords[7]);
+ break;
+ }
+ //textNode.appendChild(labelNode);
+ //this.domNode.appendChild(textNode);
+ return textString;
+ //alert(textNode.getComputedTextLength());
+ }
+
+ this.fillInTemplate = function(x, y, textSize, label, shape){
+ // the idea is to set the text to the appropriate place given its length
+ // and the template shape
+
+ // FIXME: For now, assuming text sizes are integers in SVG units
+ this.textSize = textSize || 12;
+ this.label = label;
+ // FIXEME: for now, I'm going to fake this... need to come up with a real way to
+ // determine the actual width of the text, such as computedStyle
+ var textWidth = this.label.length*this.textSize ;
+ //this.setLabel();
+ }
+}
+
+dojo.inherits(dojo.widget.SvgButton, dojo.widget.DomButton);
+
+// FIXME
+dojo.widget.SvgButton.prototype.shapeString = function(x, y, textSize, label, shape) {
+ switch(shape) {
+ case "ellipse":
+ var coords = dojo.widget.SvgButton.prototype.coordinates(x, y, textSize, label, shape)
+ return "<ellipse cx='"+ coords[4]+"' cy='"+ coords[5]+"' rx='"+ coords[2]+"' ry='"+ coords[3]+"'/>";
+ break;
+ case "rect":
+ //FIXME: implement
+ return "";
+ //return "<rect x='110' y='45' width='70' height='30'/>";
+ break;
+ case "circle":
+ //FIXME: implement
+ return "";
+ //return "<circle cx='210' cy='60' r='23'/>";
+ break;
+ }
+}
+
+dojo.widget.SvgButton.prototype.coordinates = function(x, y, textSize, label, shape) {
+ switch(shape) {
+ case "ellipse":
+ var buttonWidth = label.length*textSize;
+ var buttonHeight = textSize*2.5
+ var rx = buttonWidth/2;
+ var ry = buttonHeight/2;
+ var cx = rx + x;
+ var cy = ry + y;
+ var textX = cx - rx*textSize/25;
+ var textY = cy*1.1;
+ return [buttonWidth, buttonHeight, rx, ry, cx, cy, textX, textY];
+ break;
+ case "rectangle":
+ //FIXME: implement
+ return "";
+ break;
+ case "circle":
+ //FIXME: implement
+ return "";
+ break;
+ }
+}
+
+dojo.widget.SvgButton.prototype.labelString = function(x, y, textSize, label, shape){
+ var textString = "";
+ var coords = dojo.widget.SvgButton.prototype.coordinates(x, y, textSize, label, shape);
+ switch(shape) {
+ case "ellipse":
+ textString = "<text x='"+ coords[6] + "' y='"+ coords[7] + "'>"+ label + "</text>";
+ break;
+ case "rectangle":
+ //FIXME: implement
+ textString = "";
+ break;
+ case "circle":
+ //FIXME: implement
+ textString = "";
+ break;
+ }
+ return textString;
+}
+
+dojo.widget.SvgButton.prototype.templateString = function(x, y, textSize, label, shape) {
+ return "<g class='dojoButton' dojoAttachEvent='onClick; onMouseMove: onFoo;' dojoAttachPoint='labelNode'>"+ dojo.widgets.SVGButton.prototype.shapeString(x, y, textSize, label, shape) + dojo.widget.SVGButton.prototype.labelString(x, y, textSize, label, shape) + "</g>";
+}
Added: 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=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgWidget.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SvgWidget.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,77 @@
+/*
+ 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.require("dojo.widget.DomWidget");
+dojo.provide("dojo.widget.SvgWidget");
+dojo.provide("dojo.widget.SVGWidget"); // back compat
+
+dojo.require("dojo.dom");
+
+
+dojo.require("dojo.experimental");
+dojo.experimental("dojo.widget.SvgWidget");
+
+// SVGWidget is a mixin ONLY
+dojo.widget.declare(
+ "dojo.widget.SvgWidget",
+ dojo.widget.DomWidget,
+{
+ createNodesFromText: function(txt, wrap){
+ return dojo.svg.createNodesFromText(txt, wrap);
+ }
+});
+
+dojo.widget.SVGWidget = dojo.widget.SvgWidget;
+
+try{
+(function(){
+ var tf = function(){
+ // FIXME: fill this in!!!
+ var rw = new function(){
+ dojo.widget.SvgWidget.call(this);
+ this.buildRendering = function(){ return; }
+ this.destroyRendering = function(){ return; }
+ this.postInitialize = function(){ return; }
+ this.widgetType = "SVGRootWidget";
+ this.domNode = document.documentElement;
+ }
+ var wm = dojo.widget.manager;
+ wm.root = rw;
+ wm.add(rw);
+
+ // extend the widgetManager with a getWidgetFromNode method
+ wm.getWidgetFromNode = function(node){
+ var filter = function(x){
+ if(x.domNode == node){
+ return true;
+ }
+ }
+ var widgets = [];
+ while((node)&&(widgets.length < 1)){
+ widgets = this.getWidgetsByFilter(filter);
+ node = node.parentNode;
+ }
+ if(widgets.length > 0){
+ return widgets[0];
+ }else{
+ return null;
+ }
+ }
+
+ wm.getWidgetFromEvent = function(domEvt){
+ return this.getWidgetFromNode(domEvt.target);
+ }
+
+ wm.getWidgetFromPrimitive = wm.getWidgetFromNode;
+ }
+ // make sure we get called when the time is right
+ dojo.event.connect(dojo.hostenv, "loaded", tf);
+})();
+}catch(e){ alert(e); }
Added: 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=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SwtWidget.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/SwtWidget.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,66 @@
+/*
+ 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.SwtWidget");
+
+dojo.require("dojo.experimental");
+dojo.experimental("dojo.widget.SwtWidget");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.widget.Widget");
+dojo.require("dojo.uri.*");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.lang.extras");
+
+try{
+ importPackage(Packages.org.eclipse.swt.widgets);
+
+ 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,
+
+ show: function(){ },
+ hide: function(){ },
+
+ addChild: function(){ },
+ registerChild: function(){ },
+ addWidgetAsDirectChild: function(){ },
+ removeChild: function(){ },
+ destroyRendering: function(){ },
+ postInitialize: function(){ }
+ });
+
+ // initialize SWT runtime
+
+ dojo.widget.SwtWidget.prototype.display = new Display();
+ dojo.widget.SwtWidget.prototype.shell = new Shell(dojo.widget.SwtWidget.prototype.display);
+
+ dojo.widget.manager.startShell = function(){
+ var sh = dojo.widget.SwtWidget.prototype.shell;
+ var d = dojo.widget.SwtWidget.prototype.display;
+ sh.open();
+ while(!sh.isDisposed()){
+ dojo.widget.manager.doNext();
+ if(!d.readAndDispatch()){
+ d.sleep();
+ }
+ }
+ d.dispose();
+ };
+}catch(e){
+ // seems we didn't have the SWT classes in the environment. Log it.
+ dojo.debug("dojo.widget.SwtWidget not loaded. SWT classes not available");
+}
Added: 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=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TabContainer.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TabContainer.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,224 @@
+/*
+ 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.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");
+
+dojo.widget.defineWidget("dojo.widget.TabContainer", dojo.widget.PageContainer, {
+
+ // 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.
+
+ // labelPosition: String
+ // Defines where tab labels go relative to tab content.
+ // "top", "bottom", "left-h", "right-h"
+ labelPosition: "top",
+
+ // closeButton: 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"),
+
+ // selectedTab: 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);
+ }
+});
+
+dojo.widget.defineWidget(
+ "dojo.widget.TabController",
+ dojo.widget.PageController,
+ {
+ // 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.
+
+ templateString: "<div wairole='tablist' dojoAttachEvent='onKey'></div>",
+
+ // labelPosition: String
+ // Defines where tab labels go relative to tab content.
+ // "top", "bottom", "left-h", "right-h"
+ labelPosition: "top",
+
+ doLayout: true,
+
+ // class: String
+ // Class name to apply to the top dom node
+ "class": "",
+
+ // buttonWidget: 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);
+ }
+ }
+);
+
+dojo.widget.defineWidget("dojo.widget.TabButton", dojo.widget.PageButton,
+{
+ // 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.
+
+ 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);
+ },
+
+ onCloseButtonClick: function(/*Event*/ evt){
+ // since the close button is located inside the select button, make sure that the select
+ // button doesn't inadvertently get an onClick event
+ evt.stopPropagation();
+ dojo.widget.TabButton.superclass.onCloseButtonClick.apply(this, arguments);
+ }
+});
+
+
+dojo.widget.defineWidget(
+ "dojo.widget.a11y.TabButton",
+ dojo.widget.TabButton,
+ {
+ // 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.
+
+ 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>"
+ }
+);
Added: 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=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TaskBar.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TaskBar.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,92 @@
+/*
+ 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.TaskBar");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.FloatingPane");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html.selection");
+
+dojo.widget.defineWidget(
+ "dojo.widget.TaskBarItem",
+ dojo.widget.HtmlWidget,
+{
+ // summary
+ // Widget used internally by the TaskBar;
+ // shows an icon associated w/a floating pane
+
+ // iconSrc: String
+ // path of icon for associated floating pane
+ iconSrc: '',
+
+ // caption: String
+ // name of associated floating pane
+ caption: 'Untitled',
+
+ 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();
+ }
+});
+
+dojo.widget.defineWidget(
+ "dojo.widget.TaskBar",
+ dojo.widget.FloatingPane,
+ function(){
+ this._addChildStack = [];
+ },
+{
+ // summary:
+ // Displays an icon for each associated floating pane, like Windows task bar
+
+ // 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: false,
+
+ 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=495409
==============================================================================
--- 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 Thu Jan 11 14:35:53 2007
@@ -0,0 +1,115 @@
+/*
+ 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", null, "fr,ja,zh-cn,ROOT");
+
+dojo.widget.defineWidget(
+ "dojo.widget.Textbox",
+ dojo.widget.HtmlWidget,
+ {
+ // summary:
+ // A generic textbox field.
+ // Serves as a base class to derive more specialized functionality in subclasses.
+
+ // className: String
+ // The textbox class attribute.
+ className: "",
+
+ // name: String
+ // The textbox name attribute.
+ name: "",
+
+ // value: String
+ // The textbox value attribute.
+ value: "",
+
+ // type: String
+ // Basic input tag type declaration.
+ type: "",
+
+ // trim: Boolean
+ // Removes leading and trailing whitespace if true. Default is false.
+ trim: false,
+
+ // uppercase: Boolean
+ // Converts all characters to uppercase if true. Default is false.
+ uppercase: false,
+
+ // lowercase: Boolean
+ // Converts all characters to lowercase if true. Default is false.
+ lowercase: false,
+
+ // ucFirst: Boolean
+ // Converts the first character of each word to uppercase if true.
+ ucFirst: false,
+
+ // digit: Boolean
+ // Removes all characters that are not digits if true. Default is false.
+ digit: false,
+
+ // htmlfloat: String
+ // "none", "left", or "right". CSS float attribute applied to generated dom node.
+ htmlfloat: "none",
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/Textbox.html"),
+
+ // textbox DomNode:
+ // our DOM node
+ textbox: null,
+
+ fillInTemplate: function() {
+ // assign value programatically in case it has a quote in it
+ this.textbox.value = this.value;
+ },
+
+ filter: function() {
+ // summary: Apply various filters to textbox value
+ 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"];
+ }
+ }
+ }
+);
Added: 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=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TimePicker.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TimePicker.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,401 @@
+/*
+ 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.TimePicker");
+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.requireLocalization("dojo.i18n.calendar", "gregorian", null, "de,en,es,fi,fr,hu,ja,it,ko,nl,pt,sv,zh,pt-br,zh-cn,zh-hk,zh-tw,ROOT");
+dojo.requireLocalization("dojo.widget", "TimePicker", null, "ROOT");
+
+
+dojo.widget.defineWidget(
+ "dojo.widget.TimePicker",
+ dojo.widget.HtmlWidget,
+ function(){
+
+ /*
+ summary:
+ Base class for a stand-alone TimePicker widget
+ which makes it easy to select a time.
+ description:
+ A stand-alone TimePicker widget that makes it easy to select a time.
+ It is designed to be used on its own, or inside of other widgets
+ (see dojo.widget.DropdownTimePicker) or other similar combination widgets.
+
+ Times attributes passed in the `RFC 3339` format:
+ http://www.faqs.org/rfcs/rfc3339.html (2005-06-30T08:05:00-07:00)
+ so that they are serializable and locale-independent.
+
+ usage:
+ var timePicker = dojo.widget.createWidget("TimePicker", {},
+ dojo.byId("timePickerNode"));
+
+ <div dojoType="TimePicker"></div>
+ */
+
+ // time: Date
+ // selected time
+ this.time = "";
+
+ // useDefaultTime: Boolean
+ // set following flag to true if a default time should be set
+ this.useDefaultTime = false;
+
+ // useDefaultMinutes: Boolean
+ // set the following to true to set default minutes to current time, false to // use zero
+ this.useDefaultMinutes = false;
+
+ // storedTime: String
+ // rfc 3339 time
+ this.storedTime = "";
+
+ // currentTime: Object
+ // time currently selected in the UI, stored in hours, minutes, seconds in the format that will be actually displayed
+ this.currentTime = {};
+
+ this.classNames = {
+ // summary:
+ // stores a list of class names that may be overriden
+ 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"),
+
+ postMixInProperties: function(localProperties, frag) {
+ // summary: see dojo.widget.DomWidget
+ 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"
+ },
+
+ fillInTemplate: function(args, frag){
+ // summary: see dojo.widget.DomWidget
+
+ // Copy style info from input node to output node
+ var source = this.getFragNodeRef(frag);
+ dojo.html.copyStyle(this.domNode, source);
+
+ if(args.value){
+ if(args.value instanceof Date){
+ this.storedTime = dojo.date.toRfc3339(args.value);
+ }else{
+ this.storedTime = args.value;
+ }
+ }
+
+ this.initData();
+ this.initUI();
+ },
+
+ 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) {
+ //summary: set the current date and update the UI
+ 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));
+ }
+ this.onValueChanged(this.time);
+ },
+
+ onValueChanged: function(/*Date*/date) {
+ //summary: the set date event handler
+ }
+});
+
+dojo.widget.TimePicker.util = new function() {
+ //summary: utility functions
+
+ this.toRfcDateTime = function(jsDate) {
+ //summary: formats a Date object to RFC 3339 string
+ if(!jsDate) {
+ jsDate = new Date();
+ }
+ 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) {
+ //summary: constructs a Date object from RFC 3339 string
+ var tempDate = new Date();
+ if(!rfcDate || rfcDate.indexOf("T")==-1) {
+ if(useDefaultMinutes) {
+ tempDate.setMinutes(Math.floor(tempDate.getMinutes()/5)*5);
+ } else {
+ tempDate.setMinutes(0);
+ }
+ } else {
+ var tempTime = rfcDate.split("T")[1].split(":");
+ // fullYear, month, date
+ var tempDate = new Date();
+ tempDate.setHours(tempTime[0]);
+ tempDate.setMinutes(tempTime[1]);
+ }
+ return tempDate;
+ }
+
+ this.toAmPmHour = function(hour) {
+ //summary: converts a 24-hour-based hour value to a 12-hour-based hour value, and an AM/PM flag
+ var amPmHour = hour;
+ var isAm = true;
+ if (amPmHour == 0) {
+ amPmHour = 12;
+ } else if (amPmHour>12) {
+ amPmHour = amPmHour - 12;
+ isAm = false;
+ } else if (amPmHour == 12) {
+ isAm = false;
+ }
+ return [amPmHour, isAm];
+ }
+
+ this.fromAmPmHour = function(amPmHour, isAm) {
+ //summary: converts a 12-hour-based hour value and an AM/PM flag to a 24-hour-based hour value
+ var hour = parseInt(amPmHour, 10);
+ if(isAm && hour == 12) {
+ hour = 0;
+ } else if (!isAm && hour<12) {
+ hour = hour + 12;
+ }
+ return hour;
+ }
+}
Added: 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=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TitlePane.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/TitlePane.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,76 @@
+/*
+ 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.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,
+{
+ // summary
+ // A pane with a title on top, that can be opened or collapsed.
+
+ // labelNodeClass: String
+ // CSS class name for <div> containing title of the pane.
+ labelNodeClass: "",
+
+ // containerNodeClass: String
+ // CSS class name for <div> containing content of the pane.
+ containerNodeClass: "",
+
+ // label: String
+ // Title of the pane
+ label: "",
+
+ // open: Boolean
+ // Whether pane is opened or closed.
+ 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() {
+ // summary: callback when label is clicked
+ 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(/*String*/ label) {
+ // summary: sets the text of the 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=495409
==============================================================================
--- 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 Thu Jan 11 14:35:53 2007
@@ -0,0 +1,265 @@
+/*
+ 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,
+ {
+ // summary
+ // Message that slides in from the corner of the screen, used for notifications
+ // like "new email".
+
+ 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"),
+
+ // messageTopic: String
+ // Name of topic; anything published to this topic will be displayed as a message.
+ // Message format is either String or an object like
+ // {message: "hello word", type: "ERROR", delay: 500}
+ messageTopic: "",
+
+ // messageTypes: Enumeration
+ // Possible message types.
+ messageTypes: {
+ MESSAGE: "MESSAGE",
+ WARNING: "WARNING",
+ ERROR: "ERROR",
+ FATAL: "FATAL"
+ },
+
+ // defaultType: String
+ // If message type isn't specified (see "messageTopic" parameter),
+ // then display message as this type.
+ // Possible values in messageTypes enumeration ("MESSAGE", "WARNING", "ERROR", "FATAL")
+ defaultType: "MESSAGE",
+
+ // css classes
+ clipCssClass: "dojoToasterClip",
+ containerCssClass: "dojoToasterContainer",
+ contentCssClass: "dojoToasterContent",
+ messageCssClass: "dojoToasterMessage",
+ warningCssClass: "dojoToasterWarning",
+ errorCssClass: "dojoToasterError",
+ fatalCssClass: "dojoToasterFatal",
+
+ // positionDirection: String
+ // Position from which message slides into screen, one of
+ // ["br-up", "br-left", "bl-up", "bl-right", "tr-down", "tr-left", "tl-down", "tl-right"]
+ positionDirection: "br-up",
+
+ // positionDirectionTypes: Enumeration
+ // Possible values for positionDirection parameter
+ positionDirectionTypes: ["br-up", "br-left", "bl-up", "bl-right", "tr-down", "tr-left", "tl-down", "tl-right"],
+
+ // showDelay: Integer
+ // Number of milliseconds to show message
+ // TODO: this is a strange name. "duration" makes more sense
+ showDelay: 2000,
+
+ 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){
+ // summary
+ // sets and displays the given message and show duration
+ // msg: String
+ // the message
+ // messageType: Enumeration
+ // type of message; possible values in messageTypes array ("MESSAGE", "WARNING", "ERROR", "FATAL")
+ // delay: Integer
+ // number of milliseconds to display message
+
+ 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) {
+ // summary: callback for when user clicks the message
+ },
+
+ show: function(){
+ dojo.widget.Toaster.superclass.show.call(this);
+
+ this._placeClip();
+
+ if(!this._scrollConnected){
+ this._scrollConnected = true;
+ dojo.event.connect(window, "onscroll", this, "_placeClip");
+ }
+ },
+
+ hide: function(){
+ dojo.widget.Toaster.superclass.hide.call(this);
+
+ if(this._scrollConnected){
+ this._scrollConnected = false;
+ dojo.event.disconnect(window, "onscroll", this, "_placeClip");
+ }
+
+ dojo.html.setOpacity(this.containerNode, 1.0);
+ }
+ }
+);
Added: 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=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toggler.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/Toggler.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,36 @@
+/*
+ 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.Toggler");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+
+dojo.widget.defineWidget(
+ "dojo.widget.Toggler",
+ dojo.widget.HtmlWidget,
+{
+ // summary:
+ // clicking on this widget shows/hides another widget
+
+ // targetId: String
+ // Id of widget to show/hide when this widget is clicked
+ 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();
+ }
+});