Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RadioGroup.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RadioGroup.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RadioGroup.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RadioGroup.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,206 @@ +/* + 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.RadioGroup"); + +dojo.require("dojo.lang.common"); +dojo.require("dojo.event.browser"); +dojo.require("dojo.html.selection"); +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.HtmlWidget"); + +dojo.widget.defineWidget( + "dojo.widget.RadioGroup", + dojo.widget.HtmlWidget, + function(){ + // summary: + // Widget that provides useful/common functionality that may be desirable + // when interacting with ul/ol html lists. + // + // The core behaviour of the lists this widget manages is expected to be determined + // by the css class names defined: + // + // "radioGroup" - Applied to main ol or ul + // "selected" - Applied to the currently selected li, if any. + // "itemContent" - Applied to the content contained in a li, this widget embeds a span + // within each <li></li> to contain the contents of the li. + // This widget was mostly developed under supervision/guidance from Tom Trenka. + + // selectedItem: DomNode: Currently selected li, if any + this.selectedItem=null; + + // items: DomNode[]: Array of li nodes being managed by widget + this.items=[]; + + // selected: String[]: List of optional ids specifying which li's should be selected by default + this.selected=[]; + + // groupCssClass: String: Css class applied to main ol or ul, value is "radioGroup" + this.groupCssClass="radioGroup"; + + // selectedCssClass: String: Css class applied to the currently selected li, if any. value of "selected" + this.selectedCssClass="selected"; + + // itemContentCssClass: String: Css class Applied to the content contained in a li, this widget embeds a span + // within each <li></li> to contain the contents of the li. value is "itemContent" + this.itemContentCssClass="itemContent"; + }, + { + isContainer:false, + templatePath: null, + templateCssPath: null, + + postCreate:function(){ + // summary: Parses content of widget and sets up the default state of any + // default selections / etc. The onSelect function will also be fired for any + // default selections. + this._parseStructure(); + dojo.html.addClass(this.domNode, this.groupCssClass); + this._setupChildren(); + + dojo.event.browser.addListener(this.domNode, "onclick", dojo.lang.hitch(this, "onSelect")); + if (this.selectedItem){ + this._selectItem(this.selectedItem); + } + }, + + _parseStructure: function() { + // summary: Sets local radioGroup and items properties, also validates + // that domNode contains an expected list. + // + // Exception raised if a ul or ol node can't be found in this widgets domNode. + if(this.domNode.tagName.toLowerCase() != "ul" + && this.domNode.tagName.toLowerCase() != "ol") { + dojo.raise("RadioGroup: Expected ul or ol content."); + return; + } + + this.items=[]; // reset the items. + var nl=this.domNode.getElementsByTagName("li"); + for (var i=0; i<nl.length; i++){ + if(nl[i].parentNode==this.domNode){ + this.items.push(nl[i]); + } + } + }, + + add:function(/*DomNode*/ node){ + // summary: Allows the app to add a node on the fly, finishing up + // the setup so that we don't need to deal with it on a + // widget-wide basis. + if(node.parentNode!=this.domNode){ + this.domNode.appendChild(node); + } + this.items.push(node); + this._setup(node); + }, + + remove:function(/*DomNode*/ node){ + // summary: Removes the specified node from this group, if it exists. + var idx=-1; + for(var i=0; i<this.items.length; i++){ + if(this.items[i]==node){ + idx=i; + break; + } + } + if(idx<0) {return;} + this.items.splice(idx,1); + node.parentNode.removeChild(node); + }, + + clear:function(){ + // summary: Removes all items in this list + for(var i=0; i<this.items.length; i++){ + this.domNode.removeChild(this.items[i]); + } + this.items=[]; + }, + + clearSelections:function(){ + // summary: Clears any selected items from being selected + for(var i=0; i<this.items.length; i++){ + dojo.html.removeClass(this.items[i], this.selectedCssClass); + } + this.selectedItem=null; + }, + + _setup:function(node){ + var span = document.createElement("span"); + dojo.html.disableSelection(span); + dojo.html.addClass(span, this.itemContentCssClass); + dojo.dom.moveChildren(node, span); + node.appendChild(span); + + if (this.selected.length > 0) { + var uid = dojo.html.getAttribute(node, "id"); + if (uid && uid == this.selected){ + this.selectedItem = node; + } + } + dojo.event.browser.addListener(node, "onclick", dojo.lang.hitch(this, "onItemSelect")); + if (dojo.html.hasAttribute(node, "onitemselect")) { + var tn = dojo.lang.nameAnonFunc(new Function(dojo.html.getAttribute(node, "onitemselect")), + this); + dojo.event.browser.addListener(node, "onclick", dojo.lang.hitch(this, tn)); + } + }, + + _setupChildren:function(){ + for (var i=0; i<this.items.length; i++){ + this._setup(this.items[i]); + } + }, + + _selectItem:function(node, event, nofire){ + // summary: Sets the selectedItem to passed in node, applies + // css selection class on new item + if(this.selectedItem){ + dojo.html.removeClass(this.selectedItem, this.selectedCssClass); + } + + this.selectedItem = node; + dojo.html.addClass(this.selectedItem, this.selectedCssClass); + + // if this is the result of an event, stop here. + if (!dj_undef("currentTarget", event)){ + return; + } + + // if there's no nofire flag, passed when this is nailed internally. + if(!nofire){ + if(dojo.render.html.ie){ + this.selectedItem.fireEvent("onclick"); + }else{ + var e = document.createEvent("MouseEvents"); + e.initEvent("click", true, false); + this.selectedItem.dispatchEvent(e); + } + } + }, + + getValue:function() { + // summary: Gets the currently selected item, if any. + return this.selectedItem; /*DomNode*/ + }, + + onSelect:function(e) { + // summary: When the ul or ol contained by this widget is selected this function + // is fired. A good function to listen to via dojo.event.connect. + }, + + onItemSelect:function(e) { + // summary: when an individual li is selected + if (!dj_undef("currentTarget", e)){ + this._selectItem(e.currentTarget, e); + } + } + } +); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RadioGroup.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RadioGroup.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RadioGroup.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RealNumberTextbox.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RealNumberTextbox.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RealNumberTextbox.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RealNumberTextbox.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,82 @@ +/* + 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.RealNumberTextbox"); + +dojo.require("dojo.widget.IntegerTextbox"); +dojo.require("dojo.validate.common"); + +dojo.widget.defineWidget( + "dojo.widget.RealNumberTextbox", + dojo.widget.IntegerTextbox, + { + /* + summary + A subclass that extends IntegerTextbox. + Over-rides isValid/isInRange to test for real number input. + Has 5 new properties that can be specified as attributes in the markup. + + places: Integer + The exact number of decimal places. If omitted, it's unlimited and optional. + + exponent: Boolean + Can be true or false. If omitted the exponential part is optional. + + eSigned: Boolean + Is the exponent signed? Can be true or false, if omitted the sign is optional. + + min: Number + Minimum signed value. Default is -Infinity. + + max: Number + Maximum signed value. Default is +Infinity + */ + + mixInProperties: function(localProperties, frag){ + // First initialize properties in super-class. + dojo.widget.RealNumberTextbox.superclass.mixInProperties.apply(this, arguments); + + // Get properties from markup attributes, and assign to flags object. + if (localProperties.places){ + this.flags.places = Number(localProperties.places); + } + if((localProperties.exponent == "true")|| + (localProperties.exponent == "always")){ + this.flags.exponent = true; + }else if((localProperties.exponent == "false")||(localProperties.exponent == "never")){ + this.flags.exponent = false; + }else{ + this.flags.exponent = [ true, false ]; // optional + } + if((localProperties.esigned == "true")||(localProperties.esigned == "always")){ + this.flags.eSigned = true; + }else if((localProperties.esigned == "false")||(localProperties.esigned == "never")){ + this.flags.eSigned = false; + }else{ + this.flags.eSigned = [ true, false ]; // optional + } + if(localProperties.min){ + this.flags.min = parseFloat(localProperties.min); + } + if(localProperties.max){ + this.flags.max = parseFloat(localProperties.max); + } + }, + + // Over-ride for real number validation + isValid: function(){ + return dojo.validate.isRealNumber(this.textbox.value, this.flags); + }, + isInRange: function(){ + return dojo.validate.isInRange(this.textbox.value, this.flags); + } + + } +); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RealNumberTextbox.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RealNumberTextbox.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RealNumberTextbox.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RegexpTextbox.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RegexpTextbox.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RegexpTextbox.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RegexpTextbox.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,50 @@ +/* + 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.RegexpTextbox"); + +dojo.require("dojo.widget.ValidationTextbox"); + +dojo.widget.defineWidget( + "dojo.widget.RegexpTextbox", + dojo.widget.ValidationTextbox, + { + /* + summary + A subclass of ValidationTextbox. + Over-rides isValid to test input based on a regular expression. + Has a new property that can be specified as attributes in the markup. + + regexp: String + The regular expression string to use + flags: String + Flags to pass to the regular expression (e.g. 'i', 'g', etc) + */ + + mixInProperties: function(localProperties, frag){ + // First initialize properties in super-class. + dojo.widget.RegexpTextbox.superclass.mixInProperties.apply(this, arguments); + + // Get properties from markup attibutes, and assign to flags object. + if(localProperties.regexp){ + this.flags.regexp = localProperties.regexp; + } + if(localProperties.flags){ + this.flags.flags = localProperties.flags; + } + }, + + // Over-ride for integer validation + isValid: function(){ + var regexp = new RegExp(this.flags.regexp, this.flags.flags); + return regexp.test(this.textbox.value); + } + } +); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RegexpTextbox.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RegexpTextbox.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RegexpTextbox.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RemoteTabController.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RemoteTabController.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RemoteTabController.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RemoteTabController.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,50 @@ +/* + 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.RemoteTabController"); + +//Summary +//Remote Tab Controller widget. Can be located independently of a tab +//container and control the selection of its tabs +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.TabContainer"); +dojo.require("dojo.event.*"); + +dojo.deprecated("dojo.widget.RemoteTabController is slated for removal in 0.5; use PageController or TabController instead.", "0.5"); + +dojo.widget.defineWidget( + "dojo.widget.RemoteTabController", + dojo.widget.TabController, + { + templateCssPath: dojo.uri.dojoUri("src/widget/templates/RemoteTabControl.css"), + templateString: '<div dojoAttachPoint="domNode" wairole="tablist"></div>', + + "class": "dojoRemoteTabController", + + // String + // ID of page container that I connect to + tabContainer: "", + + postMixInProperties: function(){ + this.containerId = this.tabContainer; + dojo.widget.RemoteTabController.superclass.postMixInProperties.apply(this, arguments); + }, + + fillInTemplate: function() { + dojo.html.addClass(this.domNode, this["class"]); // "class" is a reserved word in JS + + if (this.tabContainer) { + dojo.addOnLoad(dojo.lang.hitch(this, "setupTabs")); + } + + dojo.widget.RemoteTabController.superclass.fillInTemplate.apply(this, arguments); + } + } +); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RemoteTabController.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RemoteTabController.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/RemoteTabController.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Repeater.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Repeater.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Repeater.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Repeater.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,177 @@ +/* + 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.Repeater"); +dojo.require("dojo.widget.HtmlWidget"); +dojo.require("dojo.string"); +dojo.require("dojo.event.*"); +dojo.require("dojo.experimental"); +dojo.experimental("dojo.widget.Repeater"); + +dojo.widget.defineWidget("dojo.widget.Repeater", dojo.widget.HtmlWidget, + { + /* + summary: + Makes it easy to add dynamicly new segments to form, ie. add new rows. + + description: + + usage: + <div dojoType="Repeater" pattern="row.%{index}" useDnd="false"> + <p>Name: <input typ="text" name="row.%{index}.name" value="" /><input type="button" rowAction="delete" value="remove this" </p> + </div> + + or: + var myRepeater=dojo.widget.createWidget("Repeater",{pattern: "row.%{index}", useDnd: false}); + myRepeater.setRow("<p>Name: <input typ="text" name="row.%{index}.name" value="" rowFunction="doThis" /><input type="button" rowAction="delete" value="remove this" /></p>", {doThis: function(node) { dojo.event.connect(node,"onClick", function() { alert("HERE"); }); } ); + + */ + + + name: "", + rowTemplate: "", + // myObject: + // Used to bind functionality to rowFunctions + myObject: null, + // myObject: + // defines pattern of the names + pattern: "", + // useDnd: + // if true, you can change position of rows by DnD + // you can also remove rows by dragging row away + useDnd: false, + isContainer: true, + + initialize: function(args,frag) { + var node = this.getFragNodeRef(frag); + node.removeAttribute("dojotype"); + this.setRow(dojo.string.trim(node.innerHTML), {}); + node.innerHTML=""; + frag=null; + }, + + postCreate: function(args,frag){ + if (this.useDnd) { + dojo.require("dojo.dnd.*"); + var dnd = new dojo.dnd.HtmlDropTarget(this.domNode, [this.widgetId]); + } + }, + + _reIndexRows: function() { + for(var i=0,len=this.domNode.childNodes.length; i<len;i++) { + var elems = ["INPUT", "SELECT", "TEXTAREA"]; + for (var k=0; k < elems.length; k++) { + var list = this.domNode.childNodes[i].getElementsByTagName(elems[k]); + for (var j=0,len2=list.length; j<len2; j++) { + var name = list[j].name; + var index=dojo.string.escape("regexp", this.pattern); + index = index.replace(/(%\\\{index\\\})/g,"%{index}"); + var nameRegexp = dojo.string.substituteParams(index, {"index": "[0-9]*"}); + var newName= dojo.string.substituteParams(this.pattern, {"index": "" + i}); + var re=new RegExp(nameRegexp,"g"); + list[j].name = name.replace(re,newName); + } + } + } + }, + + onDeleteRow: function(e) { + var index=dojo.string.escape("regexp", this.pattern); + index = index.replace(/%\\\{index\\\}/g,"\%{index}"); + var nameRegexp = dojo.string.substituteParams(index, {"index": "([0-9]*)"}); + var re=new RegExp(nameRegexp,"g"); + this.deleteRow(re.exec(e.target.name)[1]); + }, + hasRows: function() { + if (this.domNode.childNodes.length > 0) { + return true; + } + return false; + }, + + getRowCount: function() { + return this.domNode.childNodes.length; + }, + + deleteRow: function(/*integer*/idx) { + this.domNode.removeChild(this.domNode.childNodes[idx]); + this._reIndexRows(); + }, + + _changeRowPosition: function(e) { + if (e.dragStatus == "dropFailure") { + this.domNode.removeChild(e["dragSource"].domNode); + } else if (e.dragStatus == "dropSuccess") { + // nothing to do + } // else-if + this._reIndexRows(); + }, + setRow: function(/*string*/template, /*object*/myObject) { + //template = dojo.string.substituteParams(template, {"index": "0"}); + template= template.replace(/\%\{(index)\}/g, "0"); + this.rowTemplate=template; + this.myObject = myObject; + }, + getRow: function() { + return this.rowTemplate; + }, + _initRow: function(/*integer or dom node*/node) { + if (typeof(node) == "number") { + node=this.domNode.childNodes[node]; + } // if + var elems = ["INPUT", "SELECT", "IMG"]; + for (var k=0; k < elems.length; k++) { + var list = node.getElementsByTagName(elems[k]); + for(var i=0, len=list.length; i<len; i++) { + var child = list[i]; + if(child.nodeType != 1) {continue}; + if (child.getAttribute("rowFunction") != null) { + if(typeof(this.myObject[child.getAttribute("rowFunction")]) == "undefined") { + dojo.debug("Function " + child.getAttribute("rowFunction") + " not found"); + } else { + this.myObject[child.getAttribute("rowFunction")](child); + } // ifelse + } else if (child.getAttribute("rowAction") != null) { + if(child.getAttribute("rowAction") == "delete") { + child.name=dojo.string.substituteParams(this.pattern, {"index": "" + (this.getRowCount() - 1)}); + dojo.event.connect(child, "onclick", this, "onDeleteRow"); + } // if + } // else-if + } // for + } // for + }, + onAddRow: function(e) { + }, + addRow: function(/*boolean*/doInit) { + if (typeof(doInit) == "undefined") { + doInit=true; + } + var node = document.createElement('span'); + node.innerHTML=this.getRow(); + if (node.childNodes.length == 1) { + node=node.childNodes[0]; + } + this.domNode.appendChild(node); + var parser = new dojo.xml.Parse(); + var frag = parser.parseElement(node, null, true); + dojo.widget.getParser().createSubComponents(frag, this); + this._reIndexRows(); + if (doInit) { + this._initRow(node); + } + if (this.useDnd) { // bind to DND + node=new dojo.dnd.HtmlDragSource(node, this.widgetId); + dojo.event.connect(node, "onDragEnd", this, "_changeRowPosition"); + } + this.onAddRow(node); + } +}); + + Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Repeater.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Repeater.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/Repeater.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizableTextarea.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizableTextarea.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizableTextarea.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizableTextarea.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,86 @@ +/* + 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.ResizableTextarea"); +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.LayoutContainer"); +dojo.require("dojo.widget.ResizeHandle"); + +dojo.widget.defineWidget( + "dojo.widget.ResizableTextarea", + dojo.widget.HtmlWidget, +{ + // summary + // A resizable textarea. + // Takes all the parameters (name, value, etc.) that a vanilla textarea takes. + // usage + // <textarea dojoType="ResizableTextArea">...</textarea> + + templatePath: dojo.uri.dojoUri("src/widget/templates/ResizableTextarea.html"), + templateCssPath: dojo.uri.dojoUri("src/widget/templates/ResizableTextarea.css"), + + fillInTemplate: function(args, frag){ + this.textAreaNode = this.getFragNodeRef(frag).cloneNode(true); + + // FIXME: Safari apparently needs this! + dojo.body().appendChild(this.domNode); + + this.rootLayout = dojo.widget.createWidget( + "LayoutContainer", + { + minHeight: 50, + minWidth: 100 + }, + this.rootLayoutNode + ); + + // TODO: all this code should be replaced with a template + // (especially now that templates can contain subwidgets) + this.textAreaContainer = dojo.widget.createWidget( + "LayoutContainer", + { layoutAlign: "client" }, + this.textAreaContainerNode + ); + this.rootLayout.addChild(this.textAreaContainer); + + this.textAreaContainer.domNode.appendChild(this.textAreaNode); + with(this.textAreaNode.style){ + width="100%"; + height="100%"; + } + + this.statusBar = dojo.widget.createWidget( + "LayoutContainer", + { + layoutAlign: "bottom", + minHeight: 28 + }, + this.statusBarContainerNode + ); + this.rootLayout.addChild(this.statusBar); + + this.statusLabel = dojo.widget.createWidget( + "LayoutContainer", + { + layoutAlign: "client", + minWidth: 50 + }, + this.statusLabelNode + ); + this.statusBar.addChild(this.statusLabel); + + this.resizeHandle = dojo.widget.createWidget( + "ResizeHandle", + { targetElmId: this.rootLayout.widgetId }, + this.resizeHandleNode + ); + this.statusBar.addChild(this.resizeHandle); + } +}); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizableTextarea.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizableTextarea.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizableTextarea.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizeHandle.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizeHandle.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizeHandle.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizeHandle.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,105 @@ +/* + 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.ResizeHandle"); + +dojo.require("dojo.widget.*"); +dojo.require("dojo.html.layout"); +dojo.require("dojo.event.*"); + +dojo.widget.defineWidget( + "dojo.widget.ResizeHandle", + dojo.widget.HtmlWidget, +{ + // summary + // The handle on the bottom-right corner of FloatingPane or other widgets that allows + // the widget to be resized. + // Typically not used directly. + + // targetElmId: String + // id of the Widget OR DomNode that I will size + targetElmId: '', + + templateCssPath: dojo.uri.dojoUri("src/widget/templates/ResizeHandle.css"), + templateString: '<div class="dojoHtmlResizeHandle"><div></div></div>', + + postCreate: function(){ + dojo.event.connect(this.domNode, "onmousedown", this, "_beginSizing"); + }, + + _beginSizing: function(/*Event*/ e){ + if (this._isSizing){ return false; } + + // get the target dom node to adjust. targetElmId can refer to either a widget or a simple node + this.targetWidget = dojo.widget.byId(this.targetElmId); + this.targetDomNode = this.targetWidget ? this.targetWidget.domNode : dojo.byId(this.targetElmId); + if (!this.targetDomNode){ return; } + + this._isSizing = true; + this.startPoint = {'x':e.clientX, 'y':e.clientY}; + var mb = dojo.html.getMarginBox(this.targetDomNode); + this.startSize = {'w':mb.width, 'h':mb.height}; + + dojo.event.kwConnect({ + srcObj: dojo.body(), + srcFunc: "onmousemove", + targetObj: this, + targetFunc: "_changeSizing", + rate: 25 + }); + dojo.event.connect(dojo.body(), "onmouseup", this, "_endSizing"); + + e.preventDefault(); + }, + + _changeSizing: function(/*Event*/ e){ + // On IE, if you move the mouse above/to the left of the object being resized, + // sometimes clientX/Y aren't set, apparently. Just ignore the event. + try{ + if(!e.clientX || !e.clientY){ return; } + }catch(e){ + // sometimes you get an exception accessing above fields... + return; + } + var dx = this.startPoint.x - e.clientX; + var dy = this.startPoint.y - e.clientY; + + var newW = this.startSize.w - dx; + var newH = this.startSize.h - dy; + + // minimum size check + if (this.minSize) { + var mb = dojo.html.getMarginBox(this.targetDomNode); + if (newW < this.minSize.w) { + newW = mb.width; + } + if (newH < this.minSize.h) { + newH = mb.height; + } + } + + if(this.targetWidget){ + this.targetWidget.resizeTo(newW, newH); + }else{ + dojo.html.setMarginBox(this.targetDomNode, { width: newW, height: newH}); + } + + e.preventDefault(); + }, + + _endSizing: function(/*Event*/ e){ + dojo.event.disconnect(dojo.body(), "onmousemove", this, "_changeSizing"); + dojo.event.disconnect(dojo.body(), "onmouseup", this, "_endSizing"); + + this._isSizing = false; + } + + +}); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizeHandle.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizeHandle.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/widget/ResizeHandle.js ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |