Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Spinner.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Spinner.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Spinner.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Spinner.js Mon Feb 19 09:56:06 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; + } +}); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Spinner.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Spinner.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Spinner.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SplitContainer.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SplitContainer.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SplitContainer.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SplitContainer.js Mon Feb 19 09:56:06 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, + {} +); + Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SplitContainer.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SplitContainer.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SplitContainer.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgButton.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgButton.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgButton.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgButton.js Mon Feb 19 09:56:06 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>"; +} Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgButton.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgButton.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgButton.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgWidget.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgWidget.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgWidget.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgWidget.js Mon Feb 19 09:56:06 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); } Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgWidget.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgWidget.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SvgWidget.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SwtWidget.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SwtWidget.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SwtWidget.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SwtWidget.js Mon Feb 19 09:56:06 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"); +} Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SwtWidget.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SwtWidget.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/SwtWidget.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TabContainer.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TabContainer.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TabContainer.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TabContainer.js Mon Feb 19 09:56:06 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>" + } +); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TabContainer.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TabContainer.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TabContainer.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TaskBar.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TaskBar.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TaskBar.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TaskBar.js Mon Feb 19 09:56:06 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); + } +}); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TaskBar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TaskBar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/TaskBar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Textbox.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Textbox.js?view=auto&rev=509273 =================================================================== |
Free forum by Nabble | Edit this page |