From xap-commits-return-1256-apmail-incubator-xap-commits-archive=incubator.apache.org@incubator.apache.org Wed Mar 14 20:40:10 2007 Return-Path: Delivered-To: apmail-incubator-xap-commits-archive@locus.apache.org Received: (qmail 2272 invoked from network); 14 Mar 2007 20:40:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Mar 2007 20:40:06 -0000 Received: (qmail 66230 invoked by uid 500); 14 Mar 2007 20:40:05 -0000 Delivered-To: apmail-incubator-xap-commits-archive@incubator.apache.org Received: (qmail 66151 invoked by uid 500); 14 Mar 2007 20:40:05 -0000 Mailing-List: contact xap-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: xap-dev@incubator.apache.org Delivered-To: mailing list xap-commits@incubator.apache.org Received: (qmail 66104 invoked by uid 99); 14 Mar 2007 20:40:05 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Mar 2007 13:40:05 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Mar 2007 13:39:46 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 1FCA51A98A5; Wed, 14 Mar 2007 13:38:06 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r518313 [39/43] - in /incubator/xap/trunk/codebase/src/dojo: ./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/ src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/core/ src/data/old/ src/data/old/format/ src/data... Date: Wed, 14 Mar 2007 20:37:27 -0000 To: xap-commits@incubator.apache.org From: mturyn@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070314203806.1FCA51A98A5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: incubator/xap/trunk/codebase/src/dojo/src/widget/ValidationTextbox.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/ValidationTextbox.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/ValidationTextbox.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/ValidationTextbox.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,204 @@ +/* + 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.ValidationTextbox"); + +dojo.require("dojo.widget.Textbox"); +dojo.require("dojo.i18n.common"); + +dojo.widget.defineWidget( + "dojo.widget.ValidationTextbox", + dojo.widget.Textbox, + function() { + // summary: + // A subclass of Textbox. + // Over-ride isValid in subclasses to perform specific kinds of validation. + + // this property isn't a primitive and needs to be created on a per-item basis. + this.flags = {}; + }, + { + // default values for new subclass properties + // required: Boolean + // Can be true or false, default is false. + required: false, + rangeClass: "range", + // invalidClass: String + // Class used to format displayed text in page if necessary to override default class + invalidClass: "invalid", + // missingClass: String + // Override default class used for missing input data + missingClass: "missing", + classPrefix: "dojoValidate", + // size: String + // Basic input tag size declaration. + size: "", + // maxlength: String + // Basic input tag maxlength declaration. + maxlength: "", + // promptMessage: String + // Will not issue invalid message if field is populated with default user-prompt text + promptMessage: "", + // invalidMessage: String + // The message to display if value is invalid. + invalidMessage: "", + // missingMessage: String + // The message to display if value is missing. + missingMessage: "", + rangeMessage: "", + // listenOnKeyPress: Boolean + // Updates messages on each key press. Default is true. + listenOnKeyPress: true, + htmlfloat: "none", + lastCheckedValue: null, + + templatePath: dojo.uri.dojoUri("src/widget/templates/ValidationTextbox.html"), + templateCssPath: dojo.uri.dojoUri("src/widget/templates/Validate.css"), + + // new DOM nodes + invalidSpan: null, + missingSpan: null, + rangeSpan: null, + + getValue: function() { + return this.textbox.value; + }, + + setValue: function(value) { + this.textbox.value = value; + this.update(); + }, + + isValid: function() { + // summary: Need to over-ride with your own validation code in subclasses + return true; + }, + + isInRange: function() { + // summary: Need to over-ride with your own validation code in subclasses + return true; + }, + + isEmpty: function() { + // summary: Checks for whitespace + return ( /^\s*$/.test(this.textbox.value) ); // Boolean + }, + + isMissing: function() { + // summary: Checks to see if value is required and is whitespace + return ( this.required && this.isEmpty() ); // Boolean + }, + + update: function() { + // summary: + // Called by oninit, onblur, and onkeypress. + // description: + // Show missing or invalid messages if appropriate, and highlight textbox field. + this.lastCheckedValue = this.textbox.value; + this.missingSpan.style.display = "none"; + this.invalidSpan.style.display = "none"; + this.rangeSpan.style.display = "none"; + + var empty = this.isEmpty(); + var valid = true; + if(this.promptMessage != this.textbox.value){ + valid = this.isValid(); + } + var missing = this.isMissing(); + + // Display at most one error message + if(missing){ + this.missingSpan.style.display = ""; + }else if( !empty && !valid ){ + this.invalidSpan.style.display = ""; + }else if( !empty && !this.isInRange() ){ + this.rangeSpan.style.display = ""; + } + this.highlight(); + }, + + updateClass: function(className){ + // summary: used to ensure that only 1 validation class is set at a time + var pre = this.classPrefix; + dojo.html.removeClass(this.textbox,pre+"Empty"); + dojo.html.removeClass(this.textbox,pre+"Valid"); + dojo.html.removeClass(this.textbox,pre+"Invalid"); + dojo.html.addClass(this.textbox,pre+className); + }, + + highlight: function() { + // summary: by Called oninit, and onblur. + + // highlight textbox background + if (this.isEmpty()) { + this.updateClass("Empty"); + }else if (this.isValid() && this.isInRange() ){ + this.updateClass("Valid"); + }else if(this.textbox.value != this.promptMessage){ + this.updateClass("Invalid"); + }else{ + this.updateClass("Empty"); + } + }, + + onfocus: function(evt) { + if ( !this.listenOnKeyPress) { + this.updateClass("Empty"); +// this.textbox.style.backgroundColor = ""; + } + }, + + onblur: function(evt) { + this.filter(); + this.update(); + }, + + onkeyup: function(evt){ + if(this.listenOnKeyPress){ + //this.filter(); trim is problem if you have to type two words + this.update(); + }else if (this.textbox.value != this.lastCheckedValue){ + this.updateClass("Empty"); +// this.textbox.style.backgroundColor = ""; + } + }, + + postMixInProperties: function(localProperties, frag) { + dojo.widget.ValidationTextbox.superclass.postMixInProperties.apply(this, arguments); + this.messages = dojo.i18n.getLocalization("dojo.widget", "validate", this.lang); + dojo.lang.forEach(["invalidMessage", "missingMessage", "rangeMessage"], function(prop) { + if(this[prop]){ this.messages[prop] = this[prop]; } + }, this); + }, + + fillInTemplate: function() { + dojo.widget.ValidationTextbox.superclass.fillInTemplate.apply(this, arguments); + + // Attach isMissing and isValid methods to the textbox. + // We may use them later in connection with a submit button widget. + // TODO: this is unorthodox; it seems better to do it another way -- Bill + this.textbox.isValid = function() { this.isValid.call(this); }; + this.textbox.isMissing = function() { this.isMissing.call(this); }; + this.textbox.isInRange = function() { this.isInRange.call(this); }; + dojo.html.setClass(this.invalidSpan,this.invalidClass); + this.update(); + + // apply any filters to initial value + this.filter(); + + // set table to be inlined (technique varies by browser) + // TODO: use method in dojo.html that does this + if(dojo.render.html.ie){ dojo.html.addClass(this.domNode, "ie"); } + if(dojo.render.html.moz){ dojo.html.addClass(this.domNode, "moz"); } + if(dojo.render.html.opera){ dojo.html.addClass(this.domNode, "opera"); } + if(dojo.render.html.safari){ dojo.html.addClass(this.domNode, "safari"); } + } + } +); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/Widget.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/Widget.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/Widget.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/Widget.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,761 @@ +/* + 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.Widget"); + +dojo.require("dojo.lang.func"); +dojo.require("dojo.lang.array"); +dojo.require("dojo.lang.extras"); +dojo.require("dojo.lang.declare"); +dojo.require("dojo.ns"); +dojo.require("dojo.widget.Manager"); +dojo.require("dojo.event.*"); +dojo.require("dojo.a11y"); + +dojo.declare("dojo.widget.Widget", null, + function(){ + // these properties aren't primitives and need to be created on a per-item + // basis. + + // children: Array + // a list of all of the widgets that have been added as children of + // this component. Should only have values if isContainer is true. + this.children = []; + + // extraArgs: Object + // a map of properties which the widget system tried to assign from + // user input but did not correspond to any of the properties set on + // the class prototype. These names will also be available in all + // lower-case form in this map + this.extraArgs = {}; + }, +{ + // parent: Widget + // the parent of this widget + parent: null, + + // isTopLevel: Boolean + // should this widget eat all events that bubble up to it? + // obviously, top-level and modal widgets should set these appropriately + isTopLevel: false, + + // disabled: Boolean + // should this widget respond to user input? + // in markup, this is specified as "disabled='disabled'", or just "disabled" + disabled: false, + + // isContainer: Boolean + // can this widget contain other widgets? + isContainer: false, + + // widgetId: String + // a unique, opaque ID string that can be assigned by users or by the + // system. If the developer passes an ID which is known not to be + // unique, the specified ID is ignored and the system-generated ID is + // used instead. + widgetId: "", + + // widgetType: String + // used for building generic widgets + widgetType: "Widget", + + // ns: String + // defaults to 'dojo'. "namespace" is a reserved word in JavaScript, so we abbreviate + ns: "dojo", + + getNamespacedType: function(){ + // summary: + // get the "full" name of the widget. If the widget comes from the + // "dojo" namespace and is a Button, calling this method will + // return "dojo:button", all lower-case + return (this.ns ? this.ns + ":" + this.widgetType : this.widgetType).toLowerCase(); // String + }, + + toString: function(){ + // summary: + // returns a string that represents the widget. When a widget is + // cast to a string, this method will be used to generate the + // output. Currently, it does not implement any sort of reversable + // serialization. + return '[Widget ' + this.getNamespacedType() + ', ' + (this.widgetId || 'NO ID') + ']'; // String + }, + + repr: function(){ + // summary: returns the string representation of the widget. + return this.toString(); // String + }, + + enable: function(){ + // summary: + // enables the widget, usually involving unmasking inputs and + // turning on event handlers. Not implemented here. + this.disabled = false; + }, + + disable: function(){ + // summary: + // disables the widget, usually involves masking inputs and + // unsetting event handlers. Not implemented here. + this.disabled = true; + }, + + // TODO: + // 1) this would be better in HtmlWidget rather than here? + // 2) since many widgets don't care if they've been resized, maybe this should be a mixin? + onResized: function(){ + // summary: + // A signal that widgets will call when they have been resized. + // Can be connected to for determining if a layout needs to be + // reflowed. Clients should override this function to do special + // processing, then call this.notifyChildrenOfResize() to notify + // children of resize. + this.notifyChildrenOfResize(); + }, + + notifyChildrenOfResize: function(){ + // summary: dispatches resized events to all children of this widget + for(var i=0; i mixInProperties"); + //dojo.profile.start(this.widgetType + " mixInProperties"); + this.mixInProperties(args, fragment, parent); + //dojo.profile.end(this.widgetType + " mixInProperties"); + // dojo.debug(this.widgetType, "-> postMixInProperties"); + //dojo.profile.start(this.widgetType + " postMixInProperties"); + this.postMixInProperties(args, fragment, parent); + //dojo.profile.end(this.widgetType + " postMixInProperties"); + // dojo.debug(this.widgetType, "-> dojo.widget.manager.add"); + dojo.widget.manager.add(this); + // dojo.debug(this.widgetType, "-> buildRendering"); + //dojo.profile.start(this.widgetType + " buildRendering"); + this.buildRendering(args, fragment, parent); + //dojo.profile.end(this.widgetType + " buildRendering"); + // dojo.debug(this.widgetType, "-> initialize"); + //dojo.profile.start(this.widgetType + " initialize"); + this.initialize(args, fragment, parent); + //dojo.profile.end(this.widgetType + " initialize"); + // dojo.debug(this.widgetType, "-> postInitialize"); + // postinitialize includes subcomponent creation + // profile is put directly to function + this.postInitialize(args, fragment, parent); + // dojo.debug(this.widgetType, "-> postCreate"); + //dojo.profile.start(this.widgetType + " postCreate"); + this.postCreate(args, fragment, parent); + //dojo.profile.end(this.widgetType + " postCreate"); + // dojo.debug(this.widgetType, "done!"); + + //dojo.profile.end(this.widgetType + " create"); + + return this; + }, + + destroy: function(finalize){ + // summary: + // Destroy this widget and it's descendants. This is the generic + // "destructor" function that all widget users should call to + // clealy discard with a widget. Once a widget is destroyed, it's + // removed from the manager object. + // finalize: Boolean + // is this function being called part of global environment + // tear-down? + + // FIXME: this is woefully incomplete + if(this.parent){ + this.parent.removeChild(this); + } + this.destroyChildren(); + this.uninitialize(); + this.destroyRendering(finalize); + dojo.widget.manager.removeById(this.widgetId); + }, + + destroyChildren: function(){ + // summary: + // Recursively destroy the children of this widget and their + // descendents. + var widget; + var i=0; + while(this.children.length > i){ + widget = this.children[i]; + if (widget instanceof dojo.widget.Widget) { // find first widget + this.removeChild(widget); + widget.destroy(); + continue; + } + + i++; // skip data object + } + + }, + + getChildrenOfType: function(/*String*/type, recurse){ + // summary: + // return an array of descendant widgets who match the passed type + // recurse: Boolean + // should we try to get all descendants that match? Defaults to + // false. + var ret = []; + var isFunc = dojo.lang.isFunction(type); + if(!isFunc){ + type = type.toLowerCase(); + } + for(var x=0; xsi)){ + this[x][pairs[y].substr(0, si).replace(/^\s+|\s+$/g, "")] = pairs[y].substr(si+1); + } + } + } + }else{ + // the default is straight-up string assignment. When would + // we ever hit this? + this[x] = args[x]; + } + } + }else{ + // collect any extra 'non mixed in' args + this.extraArgs[x.toLowerCase()] = args[x]; + } + } + // dojo.profile.end("mixInProperties"); + }, + + postMixInProperties: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary + // Called after the parameters to the widget have been read-in, + // but before the widget template is instantiated. + // Especially useful to set properties that are referenced in the widget template. + }, + + initialize: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary: stub function. + return false; + // dojo.unimplemented("dojo.widget.Widget.initialize"); + }, + + postInitialize: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary: stub function. + return false; + }, + + postCreate: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary: stub function. + return false; + }, + + uninitialize: function(){ + // summary: + // stub function. Over-ride to implement custom widget tear-down + // behavior. + return false; + }, + + buildRendering: function(/*Object*/args, /*Object*/frag, /*Widget*/parent){ + // summary: stub function. SUBCLASSES MUST IMPLEMENT + dojo.unimplemented("dojo.widget.Widget.buildRendering, on "+this.toString()+", "); + return false; + }, + + destroyRendering: function(){ + // summary: stub function. SUBCLASSES MUST IMPLEMENT + dojo.unimplemented("dojo.widget.Widget.destroyRendering"); + return false; + }, + + addedTo: function(parent){ + // summary: + // stub function this is just a signal that can be caught + // parent: Widget + // instance of dojo.widget.Widget that we were added to + }, + + addChild: function(child){ + // summary: stub function. SUBCLASSES MUST IMPLEMENT + dojo.unimplemented("dojo.widget.Widget.addChild"); + return false; + }, + + // Detach the given child widget from me, but don't destroy it + removeChild: function(/*Widget*/widget){ + // summary: + // removes the passed widget instance from this widget but does + // not destroy it + for(var x=0; x +dojo.widget.tags["dojo:connect"] = function(fragment, widgetParser, parentComp){ + var properties = widgetParser.parseProperties(fragment["dojo:connect"]); +} + +// FIXME: if we know the insertion point (to a reasonable location), why then do we: +// - create a template node +// - clone the template node +// - render the clone and set properties +// - remove the clone from the render tree +// - place the clone +// this is quite dumb +dojo.widget.buildWidgetFromParseTree = function(/*String*/ type, + /*Object*/ frag, + /*dojo.widget.Parse*/ parser, + /*Widget, optional*/ parentComp, + /*int, optional*/ insertionIndex, + /*Object*/ localProps){ + + // summary: creates a tree of widgets from the data structure produced by the first-pass parser (frag) + + // test for accessibility mode + dojo.a11y.setAccessibleMode(); + //dojo.profile.start("buildWidgetFromParseTree"); + // FIXME: for codepath from createComponentFromScript, we are now splitting a path + // that we already split and then joined + var stype = type.split(":"); + stype = (stype.length == 2) ? stype[1] : type; + + // FIXME: we don't seem to be doing anything with this! + // var propertySets = parser.getPropertySets(frag); + var localProperties = localProps || parser.parseProperties(frag[frag["ns"]+":"+stype]); + var twidget = dojo.widget.manager.getImplementation(stype,null,null,frag["ns"]); + if(!twidget){ + throw new Error('cannot find "' + type + '" widget'); + }else if (!twidget.create){ + throw new Error('"' + type + '" widget object has no "create" method and does not appear to implement *Widget'); + } + localProperties["dojoinsertionindex"] = insertionIndex; + // FIXME: we lose no less than 5ms in construction! + var ret = twidget.create(localProperties, frag, parentComp, frag["ns"]); + // dojo.profile.end("buildWidgetFromParseTree"); + return ret; +} + +dojo.widget.defineWidget = function(widgetClass, renderer, superclasses, init, props){ + // summary: Create a widget constructor function (aka widgetClass) + // widgetClass: String + // the location in the object hierarchy to place the new widget class constructor + // renderer: String + // usually "html", determines when this delcaration will be used + // superclasses: Function||Function[] + // can be either a single function or an array of functions to be + // mixed in as superclasses. If an array, only the first will be used + // to set prototype inheritance. + // init: Function + // an optional constructor function. Will be called after superclasses are mixed in. + // props: Object + // a map of properties and functions to extend the class prototype with + + // This meta-function does parameter juggling for backward compat and overloading + // if 4th argument is a string, we are using the old syntax + // old sig: widgetClass, superclasses, props (object), renderer (string), init (function) + if(dojo.lang.isString(arguments[3])){ + dojo.widget._defineWidget(arguments[0], arguments[3], arguments[1], arguments[4], arguments[2]); + }else{ + // widgetClass + var args = [ arguments[0] ], p = 3; + if(dojo.lang.isString(arguments[1])){ + // renderer, superclass + args.push(arguments[1], arguments[2]); + }else{ + // superclass + args.push('', arguments[1]); + p = 2; + } + if(dojo.lang.isFunction(arguments[p])){ + // init (function), props (object) + args.push(arguments[p], arguments[p+1]); + }else{ + // props (object) + args.push(null, arguments[p]); + } + dojo.widget._defineWidget.apply(this, args); + } +} + +dojo.widget.defineWidget.renderers = "html|svg|vml"; + +dojo.widget._defineWidget = function(widgetClass /*string*/, renderer /*string*/, superclasses /*function||array*/, init /*function*/, props /*object*/){ + // FIXME: uncomment next line to test parameter juggling ... remove when confidence improves + // dojo.debug('(c:)' + widgetClass + '\n\n(r:)' + renderer + '\n\n(i:)' + init + '\n\n(p:)' + props); + // widgetClass takes the form foo.bar.baz<.renderer>.WidgetName (e.g. foo.bar.baz.WidgetName or foo.bar.baz.html.WidgetName) + var module = widgetClass.split("."); + var type = module.pop(); // type <= WidgetName, module <= foo.bar.baz<.renderer> + var regx = "\\.(" + (renderer ? renderer + '|' : '') + dojo.widget.defineWidget.renderers + ")\\."; + var r = widgetClass.search(new RegExp(regx)); + module = (r < 0 ? module.join(".") : widgetClass.substr(0, r)); + + // deprecated in favor of namespace system, remove for 0.5 + dojo.widget.manager.registerWidgetPackage(module); + + var pos = module.indexOf("."); + var nsName = (pos > -1) ? module.substring(0,pos) : module; + + // FIXME: hrm, this might make things simpler + //dojo.widget.tags.addParseTreeHandler(nsName+":"+type.toLowerCase()); + + props=(props)||{}; + props.widgetType = type; + if((!init)&&(props["classConstructor"])){ + init = props.classConstructor; + delete props.classConstructor; + } + dojo.declare(widgetClass, superclasses, init, props); +} Added: incubator/xap/trunk/codebase/src/dojo/src/widget/Wizard.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/Wizard.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/Wizard.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/Wizard.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,233 @@ +/* + 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.Wizard"); + +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.LayoutContainer"); +dojo.require("dojo.widget.ContentPane"); +dojo.require("dojo.event.*"); +dojo.require("dojo.html.style"); + +// TODO: base this on PageContainer +dojo.widget.defineWidget( + "dojo.widget.WizardContainer", + dojo.widget.LayoutContainer, +{ + // summary + // A set of panels that display sequentially, typically notating a step-by-step + // procedure like an install + + templatePath: dojo.uri.dojoUri("src/widget/templates/Wizard.html"), + templateCssPath: dojo.uri.dojoUri("src/widget/templates/Wizard.css"), + + // selected: DomNode + // Currently selected panel. (Read-only) + selected: null, + + // nextButtonLabel: String + // Label for the "Next" button. + nextButtonLabel: "next", + + // previousButtonLabel: String + // Label for the "Previous" button. + previousButtonLabel: "previous", + + // cancelButtonLabel: String + // Label for the "Cancel" button. + cancelButtonLabel: "cancel", + + // doneButtonLabel: String + // Label for the "Done" button. + doneButtonLabel: "done", + + // cancelButtonLabel: FunctionName + // Name of function to call if user presses cancel button. + // Cancel button is not displayed if function is not specified. + cancelFunction: "", + + // hideDisabledButtons: Boolean + // If true, disabled buttons are hidden; otherwise, they are assigned the + // "WizardButtonDisabled" CSS class + hideDisabledButtons: false, + + fillInTemplate: function(args, frag){ + dojo.event.connect(this.nextButton, "onclick", this, "_onNextButtonClick"); + dojo.event.connect(this.previousButton, "onclick", this, "_onPreviousButtonClick"); + if (this.cancelFunction){ + dojo.event.connect(this.cancelButton, "onclick", this.cancelFunction); + }else{ + this.cancelButton.style.display = "none"; + } + dojo.event.connect(this.doneButton, "onclick", this, "done"); + this.nextButton.value = this.nextButtonLabel; + this.previousButton.value = this.previousButtonLabel; + this.cancelButton.value = this.cancelButtonLabel; + this.doneButton.value = this.doneButtonLabel; + }, + + _checkButtons: function(){ + var lastStep = !this.hasNextPanel(); + this.nextButton.disabled = lastStep; + this._setButtonClass(this.nextButton); + if(this.selected.doneFunction){ + this.doneButton.style.display = ""; + // hide the next button if this is the last one and we have a done function + if(lastStep){ + this.nextButton.style.display = "none"; + } + }else{ + this.doneButton.style.display = "none"; + } + this.previousButton.disabled = ((!this.hasPreviousPanel()) || (!this.selected.canGoBack)); + this._setButtonClass(this.previousButton); + }, + + _setButtonClass: function(button){ + if(!this.hideDisabledButtons){ + button.style.display = ""; + dojo.html.setClass(button, button.disabled ? "WizardButtonDisabled" : "WizardButton"); + }else{ + button.style.display = button.disabled ? "none" : ""; + } + }, + + registerChild: function(panel, insertionIndex){ + dojo.widget.WizardContainer.superclass.registerChild.call(this, panel, insertionIndex); + this.wizardPanelContainerNode.appendChild(panel.domNode); + panel.hide(); + + if(!this.selected){ + this.onSelected(panel); + } + this._checkButtons(); + }, + + onSelected: function(/*WizardPanel*/ panel){ + // summary: Callback when new panel is selected.. Deselect old panel and select new one + if(this.selected ){ + if (this.selected._checkPass()) { + this.selected.hide(); + } else { + return; + } + } + panel.show(); + this.selected = panel; + }, + + getPanels: function() { + // summary: returns array of WizardPane children + return this.getChildrenOfType("WizardPane", false); // WizardPane[] + }, + + selectedIndex: function() { + // summary: Returns index (into this.children[]) for currently selected child. + if (this.selected) { + return dojo.lang.indexOf(this.getPanels(), this.selected); // Integer + } + return -1; + }, + + _onNextButtonClick: function() { + // summary: callback when next button is clicked + var selectedIndex = this.selectedIndex(); + if ( selectedIndex > -1 ) { + var childPanels = this.getPanels(); + if (childPanels[selectedIndex + 1]) { + this.onSelected(childPanels[selectedIndex + 1]); + } + } + this._checkButtons(); + }, + + _onPreviousButtonClick: function() { + // summary: callback when previous button is clicked + var selectedIndex = this.selectedIndex(); + if ( selectedIndex > -1 ) { + var childPanels = this.getPanels(); + if (childPanels[selectedIndex - 1]) { + this.onSelected(childPanels[selectedIndex - 1]); + } + } + this._checkButtons(); + }, + + hasNextPanel: function() { + // summary: Returns true if there's a another panel after the current panel + var selectedIndex = this.selectedIndex(); + return (selectedIndex < (this.getPanels().length - 1)); + }, + + hasPreviousPanel: function() { + // summary: Returns true if there's a panel before the current panel + var selectedIndex = this.selectedIndex(); + return (selectedIndex > 0); + }, + + done: function() { + // summary: Finish the wizard's operation + this.selected.done(); + } +}); + +dojo.widget.defineWidget( + "dojo.widget.WizardPane", + dojo.widget.ContentPane, +{ + // summary + // a panel in a WizardContainer + + // canGoBack: Boolean + // If true, then can move back to a previous panel (by clicking the "Previous" button) + canGoBack: true, + + // passFunction: String + // Name of function that checks if it's OK to advance to the next panel. + // If it's not OK (for example, mandatory field hasn't been entered), then + // returns an error message (String) explaining the reason. + passFunction: "", + + // doneFunction: String + // Name of function that is run if you press the "Done" button from this panel + doneFunction: "", + + postMixInProperties: function(args, frag) { + if (this.passFunction) { + this.passFunction = dj_global[this.passFunction]; + } + if (this.doneFunction) { + this.doneFunction = dj_global[this.doneFunction]; + } + dojo.widget.WizardPane.superclass.postMixInProperties.apply(this, arguments); + }, + + _checkPass: function() { + // summary: + // Called when the user presses the "next" button. + // Calls passFunction to see if it's OK to advance to next panel, and + // if it isn't, then display error. + // Returns true to advance, false to not advance. + if (this.passFunction && dojo.lang.isFunction(this.passFunction)) { + var failMessage = this.passFunction(); + if (failMessage) { + alert(failMessage); + return false; + } + } + return true; + }, + + done: function() { + if (this.doneFunction && dojo.lang.isFunction(this.doneFunction)) { + this.doneFunction(); + } + } +}); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/YahooMap.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/YahooMap.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/YahooMap.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/YahooMap.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,195 @@ +/* + 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.YahooMap"); +dojo.require("dojo.event.*"); +dojo.require("dojo.math"); +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.HtmlWidget"); + +(function(){ + var yappid = djConfig["yAppId"]||djConfig["yahooAppId"]||"dojotoolkit"; + if(!dojo.hostenv.post_load_){ + if(yappid == "dojotoolkit"){ + dojo.debug("please provide a unique Yahoo App ID in djConfig.yahooAppId when using the map widget"); + } + var tag = ""; + if(!dj_global["YMap"]){ + document.write(tag); + } + }else{ + dojo.debug("cannot initialize map system after the page has been loaded! Please either manually include the script block provided by Yahoo in your page or require() the YahooMap widget before onload has fired"); + } +})(); + +dojo.widget.defineWidget( + "dojo.widget.YahooMap", + dojo.widget.HtmlWidget, + function(){ + // summary: Creates a widget that wraps the Yahoo Map API. + // description: + // Widget wrapper for the Yahoo Map API; it allows you to easily embed a Yahoo Map + // within your Dojo application. + // map: YMap + // Reference to the Yahoo Map object. + // datasrc: String + // Reference to an external (to the widget) source for point data. + // data: Object[] + // Array of point information objects. + // width: Number + // Width of the map control. + // height: Number + // Height of the map control + // controls: String[] + // Array of strings that map to corresponding controls on a Yahoo Map. + this.map=null; + this.datasrc=""; + this.data=[]; + this.width=0; + this.height=0; + this.controls=["zoomlong","maptype","pan"]; + }, +{ + isContainer: false, + templatePath:null, + templateCssPath:null, + + findCenter:function(/* array */aPts){ + // summary + // Find the center lat/lng coordinate based on the passed points. + var start=new YGeoPoint(37,-90); + if(aPts.length==0) return start; + var minLat,maxLat, minLon, maxLon, cLat, cLon; + minLat=maxLat=aPts[0].Lat; + minLon=maxLon=aPts[0].Lon; + for(var i=0; i"+d[i].description+""); + } + this.map.addOverlay(m); + } + var c=this.findCenter(pts); + var z=this.map.getZoomLevel(pts); + this.map.drawZoomAndCenter(c,z); + }, + + initialize:function(/* object */args, /* object */frag){ + // summary + // Initialize the widget. + if(!YMap || !YGeoPoint){ + dojo.raise("dojo.widget.YahooMap: The Yahoo Map script must be included in order to use this widget."); + } + if(this.datasrc){ + this.parse(dojo.byId(this.datasrc)); + } + else if(this.domNode.getElementsByTagName("table")[0]){ + this.parse(this.domNode.getElementsByTagName("table")[0]); + } + }, + postCreate:function(){ + // summary + // Finalize and plot all points on the widget. + while(this.domNode.childNodes.length>0){ + this.domNode.removeChild(this.domNode.childNodes[0]); + } + + if(this.width>0&&this.height>0){ + this.map=new YMap(this.domNode, YAHOO_MAP_REG, new YSize(this.width, this.height)); + }else{ + this.map=new YMap(this.domNode); + } + this.setControls(); + this.render(); + } +}); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/__package__.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/__package__.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/__package__.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/__package__.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,23 @@ +/* + 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.kwCompoundRequire({ + common: ["dojo.xml.Parse", + "dojo.widget.Widget", + "dojo.widget.Parse", + "dojo.widget.Manager"], + browser: ["dojo.widget.DomWidget", + "dojo.widget.HtmlWidget"], + dashboard: ["dojo.widget.DomWidget", + "dojo.widget.HtmlWidget"], + svg: ["dojo.widget.SvgWidget"], + rhino: ["dojo.widget.SwtWidget"] +}); +dojo.provide("dojo.widget.*"); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoContainer.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoContainer.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoContainer.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoContainer.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,107 @@ +/* + 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.demoEngine.DemoContainer"); +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.HtmlWidget"); +dojo.require("dojo.widget.demoEngine.DemoPane"); +dojo.require("dojo.widget.demoEngine.SourcePane"); +dojo.require("dojo.widget.TabContainer"); + +dojo.widget.defineWidget("my.widget.demoEngine.DemoContainer", + dojo.widget.HtmlWidget, + { + templatePath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoContainer.html"), + templateCssPath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoContainer.css"), + postCreate: function() { + dojo.html.addClass(this.domNode,this.domNodeClass); + dojo.html.addClass(this.tabNode, this.tabClass); + dojo.html.addClass(this.returnImageNode, this.returnClass); + this.returnImageNode.src=this.returnImage; + + this.tabContainer = dojo.widget.createWidget("TabContainer",{},this.tabNode); + + this.demoTab = dojo.widget.createWidget("DemoPane",{}); + this.tabContainer.addChild(this.demoTab); + + this.sourceTab= dojo.widget.createWidget("SourcePane",{}); + this.tabContainer.addChild(this.sourceTab); + + dojo.html.setOpacity(this.domNode,0); + dojo.html.hide(this.domNode); + }, + + loadDemo: function(url) { + this.demoTab.setHref(url); + this.sourceTab.setHref(url); + this.showDemo(); + }, + + setName: function(name) { + dojo.html.removeChildren(this.demoNameNode); + this.demoNameNode.appendChild(document.createTextNode(name)); + }, + + setSummary: function(summary) { + dojo.html.removeChildren(this.summaryNode); + this.summaryNode.appendChild(document.createTextNode(summary)); + }, + + showSource: function() { + dojo.html.removeClass(this.demoButtonNode,this.selectedButtonClass); + dojo.html.addClass(this.sourceButtonNode,this.selectedButtonClass); + this.tabContainer.selectTab(this.sourceTab); + }, + + showDemo: function() { + dojo.html.removeClass(this.sourceButtonNode,this.selectedButtonClass); + dojo.html.addClass(this.demoButtonNode,this.selectedButtonClass); + this.tabContainer.selectTab(this.demoTab); + }, + + returnToDemos: function() { + dojo.debug("Return To Demos"); + }, + + show: function() { + dojo.html.setOpacity(this.domNode,1); + dojo.html.show(this.domNode); + this.tabContainer.checkSize(); + } + }, + "", + function() { + dojo.debug("DemoPane Init"); + this.domNodeClass="demoContainer"; + + this.tabContainer=""; + this.sourceTab=""; + this.demoTab=""; + + this.headerNode=""; + this.returnNode=""; + + this.returnImageNode=""; + this.returnImage="images/dojoDemos.gif"; + this.returnClass="return"; + + this.summaryNode=""; + this.demoNameNode=""; + this.tabControlNode=""; + + this.tabNode=""; + this.tabClass = "demoContainerTabs"; + + this.sourceButtonNode=""; + this.demoButtonNode=""; + + this.selectedButtonClass="selected"; + } +); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoItem.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoItem.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoItem.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoItem.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,71 @@ +/* + 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.demoEngine.DemoItem"); +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.HtmlWidget"); + +dojo.widget.defineWidget("my.widget.demoEngine.DemoItem", + dojo.widget.HtmlWidget, + { + templatePath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoItem.html"), + templateCssPath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoItem.css"), + postCreate: function() { + dojo.html.addClass(this.domNode,this.domNodeClass); + dojo.html.addClass(this.summaryBoxNode, this.summaryBoxClass); + dojo.html.addClass(this.screenshotTdNode, this.screenshotTdClass); + dojo.html.addClass(this.summaryContainerNode, this.summaryContainerClass); + dojo.html.addClass(this.summaryNode, this.summaryClass); + dojo.html.addClass(this.viewDemoLinkNode, this.viewDemoLinkClass); + + this.nameNode.appendChild(document.createTextNode(this.name)); + this.descriptionNode.appendChild(document.createTextNode(this.description)); + this.thumbnailImageNode.src = this.thumbnail; + this.thumbnailImageNode.name=this.name; + this.viewDemoImageNode.src = this.viewDemoImage; + this.viewDemoImageNode.name=this.name; + }, + onSelectDemo: function() { + //Attach to this to do something when a demo is selected + } + }, + "", + function() { + this.demo = ""; + + this.domNodeClass="demoItemWrapper"; + + this.summaryBoxNode=""; + this.summaryBoxClass="demoItemSummaryBox"; + + this.nameNode=""; + this.thumbnailImageNode=""; + this.viewDemoImageNode=""; + + this.screenshotTdNode=""; + this.screenshotTdClass="demoItemScreenshot"; + + this.summaryContainerNode=""; + this.summaryContainerClass="demoItemSummaryContainer"; + + this.summaryNode=""; + this.summaryClass="demoItemSummary"; + + this.viewDemoLinkNode=""; + this.viewDemoLinkClass="demoItemView"; + + this.descriptionNode=""; + + this.name="Some Demo"; + this.description="This is the description of this demo."; + this.thumbnail="images/test_thumb.gif"; + this.viewDemoImage="images/viewDemo.png"; + } +); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoNavigator.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoNavigator.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoNavigator.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoNavigator.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,188 @@ +/* + 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.demoEngine.DemoNavigator"); +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.HtmlWidget"); +dojo.require("dojo.widget.Button"); +dojo.require("dojo.widget.demoEngine.DemoItem"); +dojo.require("dojo.io.*"); +dojo.require("dojo.lfx.*"); +dojo.require("dojo.lang.common"); + +dojo.widget.defineWidget("my.widget.demoEngine.DemoNavigator", + dojo.widget.HtmlWidget, + { + templatePath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoNavigator.html"), + templateCssPath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoNavigator.css"), + postCreate: function() { + dojo.html.addClass(this.domNode,this.domNodeClass); + dojo.html.addClass(this.demoListWrapperNode,this.demoListWrapperClass); + dojo.html.addClass(this.demoListContainerNode,this.demoListContainerClass); + + if (dojo.render.html.ie) { + dojo.debug("render ie"); + dojo.html.hide(this.demoListWrapperNode); + } else { + dojo.debug("render non-ie"); + dojo.lfx.html.fadeHide(this.demoListWrapperNode, 0).play(); + } + + this.getRegistry(this.demoRegistryUrl); + + this.demoContainer = dojo.widget.createWidget("DemoContainer",{returnImage: this.returnImage},this.demoNode); + dojo.event.connect(this.demoContainer,"returnToDemos", this, "returnToDemos"); + this.demoContainer.hide(); + }, + + returnToDemos: function() { + this.demoContainer.hide(); + if (dojo.render.html.ie) { + dojo.debug("render ie"); + dojo.html.show(this.navigationContainer) ; + } else { + dojo.debug("render non-ie"); + dojo.lfx.html.fadeShow(this.navigationContainer,250).play(); + } + + //if (dojo.render.html.ie) { + // dojo.html.setOpacity(this.navigationContainer); + //} + + dojo.lang.forEach(this.categoriesChildren, dojo.lang.hitch(this, function(child){ + child.checkSize(); + })); + + dojo.lang.forEach(this.demoListChildren, dojo.lang.hitch(this, function(child){ + child.checkSize(); + })); + }, + + show: function() { + //dojo.widget.demoEngine.DemoNavigator.superclass.show.call(this); + dojo.html.show(this.domNode); + dojo.html.setOpacity(this.domNode,1); + //dojo.html.setOpacity(this.navigationContainer); + //dojo.html.show(this.navigationContainer); + dojo.html.setOpacity(this.navigationContainer,1); + + dojo.lang.forEach(this.categoriesChildren, dojo.lang.hitch(this, function(child){ + child.checkSize(); + })); + + dojo.lang.forEach(this.demoListChildren, dojo.lang.hitch(this, function(child){ + child.checkSize(); + })); + }, + getRegistry: function(url) { + dojo.io.bind({ + url: url, + load: dojo.lang.hitch(this,this.processRegistry), + mimetype: "text/json" + }); + }, + + processRegistry: function(type,registry,e) { + dojo.debug("Processing Registry"); + this.registry = registry; + dojo.lang.forEach(this.registry.navigation, dojo.lang.hitch(this,this.addCategory)); + }, + + addCategory: function(category) { + var newCat = dojo.widget.createWidget("Button",{caption: category.name}); + + if(!dojo.lang.isObject(this.registry.categories)) { + this.registry.categories=function(){}; + } + + this.registry.categories[category.name] = category; + this.categoriesChildren.push(newCat); + this.categoriesButtonsNode.appendChild(newCat.domNode); + newCat.domNode.categoryName = category.name; + dojo.event.connect(newCat,"onClick", this, "onSelectCategory"); + }, + + addDemo: function(demoName) { + var demo = this.registry.definitions[demoName]; + + if (dojo.render.html.ie) { + dojo.html.show(this.demoListWrapperNode) + } else { + dojo.lfx.html.fadeShow(this.demoListWrapperNode, 250).play(); + } + + var newDemo = dojo.widget.createWidget("DemoItem",{viewDemoImage: this.viewDemoImage, name: demoName, description: demo.description, thumbnail: demo.thumbnail}); + this.demoListChildren.push(newDemo); + this.demoListContainerNode.appendChild(newDemo.domNode); + dojo.event.connect(newDemo,"onSelectDemo",this,"onSelectDemo"); + }, + + onSelectCategory: function(e) { + catName = e.currentTarget.categoryName; + dojo.debug("Selected Category: " + catName); + //Remove current list of demos + dojo.lang.forEach(this.demoListChildren, function(child) { + child.destroy(); + }); + this.demoListChildren=[]; + + //add demos from this cat + dojo.lang.forEach(this.registry.categories[catName].demos, dojo.lang.hitch(this,function(demoName){ + this.addDemo(demoName); + })); + }, + + onSelectDemo: function(e) { + //Attach to this to do something when a demo is selected + dojo.debug("Demo Selected: " + e.target.name); + + if (dojo.render.html.ie) { + dojo.debug("render ie"); + dojo.html.hide(this.navigationContainer) ; + this.demoContainer.show(); + this.demoContainer.showDemo(); + } else { + dojo.debug("render non-ie"); + dojo.lfx.html.fadeHide(this.navigationContainer,250,null,dojo.lang.hitch(this, function() { + this.demoContainer.show(); + this.demoContainer.showDemo(); + })).play(); + } + + this.demoContainer.loadDemo(this.registry.definitions[e.target.name].url); + this.demoContainer.setName(e.target.name); + this.demoContainer.setSummary(this.registry.definitions[e.target.name].description); + } + + }, + "", + function() { + this.demoRegistryUrl="demoRegistry.json"; + this.registry=function(){}; + + this.categoriesNode=""; + this.categoriesButtonsNode=""; + this.navigationContainer=""; + + this.domNodeClass="demoNavigator"; + + this.demoNode=""; + this.demoContainer=""; + + this.demoListWrapperNode=""; + this.demoListWrapperClass="demoNavigatorListWrapper"; + this.demoListContainerClass="demoNavigatorListContainer"; + + this.returnImage="images/dojoDemos.gif"; + this.viewDemoImage="images/viewDemo.png"; + this.demoListChildren = []; + this.categoriesChildren = []; + } +); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoPane.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoPane.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoPane.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/DemoPane.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,44 @@ +/* + 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.demoEngine.DemoPane"); +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.HtmlWidget"); + +dojo.widget.defineWidget("my.widget.demoEngine.DemoPane", + dojo.widget.HtmlWidget, + { + templatePath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoPane.html"), + templateCssPath: dojo.uri.dojoUri("src/widget/demoEngine/templates/DemoPane.css"), + postCreate: function() { + dojo.html.addClass(this.domNode,this.domNodeClass); + dojo.debug("PostCreate"); + this._launchDemo(); + }, + + _launchDemo: function() { + dojo.debug("Launching Demo"); + dojo.debug(this.demoNode); + this.demoNode.src=this.href; + }, + + setHref: function(url) { + this.href = url; + this._launchDemo(); + } + }, + "", + function() { + dojo.debug("DemoPane Init"); + this.domNodeClass="demoPane"; + this.demoNode = ""; + this.href = ""; + } +); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/SourcePane.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/SourcePane.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/SourcePane.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/SourcePane.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,52 @@ +/* + 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.demoEngine.SourcePane"); +dojo.require("dojo.widget.*"); +dojo.require("dojo.widget.HtmlWidget"); +dojo.require("dojo.io.*"); + +dojo.widget.defineWidget("my.widget.demoEngine.SourcePane", + dojo.widget.HtmlWidget, + { + templatePath: dojo.uri.dojoUri("src/widget/demoEngine/templates/SourcePane.html"), + templateCssPath: dojo.uri.dojoUri("src/widget/demoEngine/templates/SourcePane.css"), + postCreate: function() { + dojo.html.addClass(this.domNode,this.domNodeClass); + dojo.debug("PostCreate"); + }, + + getSource: function() { + if (this.href) { + dojo.io.bind({ + url: this.href, + load: dojo.lang.hitch(this, "fillInSource"), + mimetype: "text/plain" + }); + } + }, + + fillInSource: function(type, source, e) { + this.sourceNode.value=source; + }, + + setHref: function(url) { + this.href = url; + this.getSource(); + } + }, + "", + function() { + dojo.debug("SourcePane Init"); + this.domNodeClass="sourcePane"; + this.sourceNode = ""; + this.href = ""; + } +); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/__package__.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/__package__.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/__package__.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/__package__.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,20 @@ +/* + 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.kwCompoundRequire({ + browser: [ + "dojo.widget.demoEngine.DemoItem", + "dojo.widget.demoEngine.DemoNavigator", + "dojo.widget.demoEngine.DemoPane", + "dojo.widget.demoEngine.SourcePane", + "dojo.widget.demoEngine.DemoContainer" + ] +}); +dojo.provide("dojo.widget.demoEngine.*"); Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoContainer.css URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoContainer.css?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoContainer.css (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoContainer.css Wed Mar 14 13:36:44 2007 @@ -0,0 +1,39 @@ +.demoContainer{ + width: 100%; + height: 100%; + padding: 0px; + margin: 0px; +} + +.demoContainer .return { + cursor: pointer; +} + +.demoContainer span { + margin-right: 10px; + cursor: pointer; +} + +.demoContainer .selected { + border-bottom: 5px solid #95bfff; +} + +.demoContainer table { + background: #f5f5f5; + width: 100%; + height: 100%; +} + +.demoContainerTabs { + width: 100%; + height: 400px; +} + +.demoContainerTabs .dojoTabLabels-top { + display: none; +} + +.demoContainerTabs .dojoTabPaneWrapper { + border: 0px; +} + Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoContainer.html URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoContainer.html?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoContainer.html (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoContainer.html Wed Mar 14 13:36:44 2007 @@ -0,0 +1,25 @@ +
+ + + + + + + + + + + +
+ + +

+

+
+ source + demo +
+
+
+
+
Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoItem.css URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoItem.css?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoItem.css (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoItem.css Wed Mar 14 13:36:44 2007 @@ -0,0 +1,58 @@ +.demoItemSummaryBox { + background: #efefef; + border:1px solid #dae3ee; +} + +.demoItemScreenshot { + padding:0.65em; + width:175px; + border-right:1px solid #fafafa; + text-align:center; + cursor: pointer; +} + +.demoItemWrapper{ + margin-bottom:1em; +} + +.demoItemWrapper a:link, .demoItemWrapper a:visited { + color:#a6238f; + text-decoration:none; +} + +.demoItemSummaryContainer { + border-left:1px solid #ddd; +} + +.demoItemSummaryContainer h1 { + background-color:#e8e8e8; + border-bottom: 1px solid #e6e6e6; + color:#738fb9; + margin:1px; + padding:0.5em; + font-family:"Lucida Grande", "Tahoma", serif; + font-size:1.25em; + font-weight:normal; +} + +.demoItemSummaryContainer h1 .packageSummary { + display:block; + color:#000; + font-size:10px; + margin-top:2px; +} + +.demoItemSummaryContainer .demoItemSummary{ + padding:1em; +} + +.demoItemSummaryContainer .demoItemSummary p { + font-size:0.85em; + padding:0; + margin:0; +} + +.demoItemView { + text-align:right; + cursor: pointer; +} Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoItem.html URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoItem.html?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoItem.html (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoItem.html Wed Mar 14 13:36:44 2007 @@ -0,0 +1,21 @@ +
+
+ + + + + + + +
+ + +

+

+
+

+
+
+
+
+
Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoNavigator.css URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoNavigator.css?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoNavigator.css (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoNavigator.css Wed Mar 14 13:36:44 2007 @@ -0,0 +1,28 @@ +.demoNavigatorListWrapper { + border:1px solid #dcdbdb; + background-color:#f8f8f8; + padding:2px; +} + +.demoNavigatorListContainer { + border:1px solid #f0f0f0; + background-color:#fff; + padding:1em; +} + +.demoNavigator h1 { + margin-top: 0px; + margin-bottom: 10px; + font-size: 1.2em; + border-bottom:1px dotted #a9ccf5; +} + +.demoNavigator .dojoButton { + margin-bottom: 5px; +} + +.demoNavigator .dojoButton .dojoButtonContents { + font-size: 1.1em; + width: 100px; + color: black; +} Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoNavigator.html URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoNavigator.html?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoNavigator.html (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoNavigator.html Wed Mar 14 13:36:44 2007 @@ -0,0 +1,24 @@ +
+ + + + + + + + + + + +
+

Categories

+
+
+
+
+
+
+
+
+
+
Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoPane.css URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoPane.css?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoPane.css (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoPane.css Wed Mar 14 13:36:44 2007 @@ -0,0 +1,18 @@ +.demoPane { + width: 100%; + height: 100%; + padding: 0px; + margin: 0px; + overflow: hidden; +} + +.demoPane iframe { + width: 100%; + height: 100%; + border: 0px; + border: none; + overflow: auto; + padding: 0px; + margin:0px; + background: #ffffff; +} Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoPane.html URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoPane.html?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoPane.html (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/DemoPane.html Wed Mar 14 13:36:44 2007 @@ -0,0 +1,3 @@ +
+ +
Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/SourcePane.css URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/SourcePane.css?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/SourcePane.css (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/SourcePane.css Wed Mar 14 13:36:44 2007 @@ -0,0 +1,20 @@ +.sourcePane { + width: 100%; + height: 100%; + padding: 0px; + margin: 0px; + overflow: hidden; +} + +.sourcePane textarea{ + width: 100%; + height: 100%; + border: 0px; + overflow: auto; + padding: 0px; + margin:0px; +} + +* html .sourcePane { + overflow: auto; +} Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/SourcePane.html URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/SourcePane.html?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/SourcePane.html (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/SourcePane.html Wed Mar 14 13:36:44 2007 @@ -0,0 +1,3 @@ +
+ +
Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/general.css URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/general.css?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/general.css (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/general.css Wed Mar 14 13:36:44 2007 @@ -0,0 +1,73 @@ +.demoListWrapper { + border:1px solid #dcdbdb; + background-color:#f8f8f8; + padding:2px; +} + +.demoListContainer { + border:1px solid #f0f0f0; + background-color:#fff; + padding:1em; +} + +.demoSummaryBox { + background: #efefef; + border:1px solid #dae3ee; +} + +.screenshot { + padding:0.65em; + width:175px; + border-right:1px solid #fafafa; + text-align:center; +} + +.demoSummary { + margin-bottom:1em; +} + +.demoSummary a:link, .demoSummary a:visited { + color:#a6238f; + text-decoration:none; +} + +.summaryContainer { + border-left:1px solid #ddd; +} + +.summaryContainer h1 { + background-color:#e8e8e8; + border-bottom: 1px solid #e6e6e6; + color:#738fb9; + margin:1px; + padding:0.5em; + font-family:"Lucida Grande", "Tahoma", serif; + font-size:1.25em; + font-weight:normal; +} + +.summaryContainer h1 .packageSummary { + display:block; + color:#000; + font-size:10px; + margin-top:2px; +} + +.summaryContainer .summary { + padding:1em; +} + +.summaryContainer .summary p { + font-size:0.85em; + padding:0; + margin:0; +} + +.reflection { + background: url("images/demoBoxReflection.gif") repeat-x top left; + height:25px; +} + +.view { + text-align:right; +} Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/images/test_thumb.gif URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/images/test_thumb.gif?view=auto&rev=518313 ============================================================================== Binary file - no diff available. Propchange: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/images/test_thumb.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/images/viewDemo.png URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/images/viewDemo.png?view=auto&rev=518313 ============================================================================== Binary file - no diff available. Propchange: incubator/xap/trunk/codebase/src/dojo/src/widget/demoEngine/templates/images/viewDemo.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/xap/trunk/codebase/src/dojo/src/widget/html/layout.js URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/widget/html/layout.js?view=auto&rev=518313 ============================================================================== --- incubator/xap/trunk/codebase/src/dojo/src/widget/html/layout.js (added) +++ incubator/xap/trunk/codebase/src/dojo/src/widget/html/layout.js Wed Mar 14 13:36:44 2007 @@ -0,0 +1,133 @@ +/* + 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.html.layout"); + +dojo.require("dojo.lang.common"); +dojo.require("dojo.string.extras"); +dojo.require("dojo.html.style"); +dojo.require("dojo.html.layout"); + +dojo.widget.html.layout = function(/*DomNode*/ container, /*Object[]*/ children, /*String*/ layoutPriority) { + /** + * summary + * Layout a bunch of child dom nodes within a parent dom node + * container: + * parent node + * layoutPriority: + * "top-bottom" or "left-right" + * children: + * an array like [ {domNode: foo, layoutAlign: "bottom" }, {domNode: bar, layoutAlign: "client"} ] + */ + + dojo.html.addClass(container, "dojoLayoutContainer"); + + // Copy children array and remove elements w/out layout. + // Also record each child's position in the input array, for sorting purposes. + children = dojo.lang.filter(children, function(child, idx){ + child.idx = idx; + return dojo.lang.inArray(["top","bottom","left","right","client","flood"], child.layoutAlign) + }); + + // Order the children according to layoutPriority. + // Multiple children w/the same layoutPriority will be sorted by their position in the input array. + if(layoutPriority && layoutPriority!="none"){ + var rank = function(child){ + switch(child.layoutAlign){ + case "flood": + return 1; + case "left": + case "right": + return (layoutPriority=="left-right") ? 2 : 3; + case "top": + case "bottom": + return (layoutPriority=="left-right") ? 3 : 2; + default: + return 4; + } + }; + children.sort(function(a,b){ + return (rank(a)-rank(b)) || (a.idx - b.idx); + }); + } + + // remaining space (blank area where nothing has been written) + var f={ + top: dojo.html.getPixelValue(container, "padding-top", true), + left: dojo.html.getPixelValue(container, "padding-left", true) + }; + dojo.lang.mixin(f, dojo.html.getContentBox(container)); + + // set positions/sizes + dojo.lang.forEach(children, function(child){ + var elm=child.domNode; + var pos=child.layoutAlign; + // set elem to upper left corner of unused space; may move it later + with(elm.style){ + left = f.left+"px"; + top = f.top+"px"; + bottom = "auto"; + right = "auto"; + } + dojo.html.addClass(elm, "dojoAlign" + dojo.string.capitalize(pos)); + + // set size && adjust record of remaining space. + // note that setting the width of a
may affect it's height. + // TODO: same is true for widgets but need to implement API to support that + if ( (pos=="top")||(pos=="bottom") ) { + dojo.html.setMarginBox(elm, { width: f.width }); + var h = dojo.html.getMarginBox(elm).height; + f.height -= h; + if(pos=="top"){ + f.top += h; + }else{ + elm.style.top = f.top + f.height + "px"; + } + // TODO: for widgets I want to call resizeTo(), but I can't because + // I only want to set the width, and have the height determined + // dynamically. (The thinner you make a div, the more height it consumes.) + if(child.onResized){ + child.onResized(); + } + }else if(pos=="left" || pos=="right"){ + var w = dojo.html.getMarginBox(elm).width; + + // TODO: I only want to set the height, not the width, but see bug#941 (FF), + // and also the resizeTo() function demands both height and width arguments + if(child.resizeTo){ + child.resizeTo(w, f.height); + }else{ + dojo.html.setMarginBox(elm, { width: w, height: f.height }); + } + + f.width -= w; + if(pos=="left"){ + f.left += w; + }else{ + elm.style.left = f.left + f.width + "px"; + } + } else if(pos=="flood" || pos=="client"){ + if(child.resizeTo){ + child.resizeTo(f.width, f.height); + }else{ + dojo.html.setMarginBox(elm, { width: f.width, height: f.height }); + } + } + }); +}; + +// This is essential CSS to make layout work (it isn't "styling" CSS) +// make sure that the position:absolute in dojoAlign* overrides other classes +dojo.html.insertCssText( + ".dojoLayoutContainer{ position: relative; display: block; overflow: hidden; }\n" + + "body .dojoAlignTop, body .dojoAlignBottom, body .dojoAlignLeft, body .dojoAlignRight { position: absolute; overflow: hidden; }\n" + + "body .dojoAlignClient { position: absolute }\n" + + ".dojoAlignClient { overflow: auto; }\n" +);