Return-Path: Delivered-To: apmail-portals-jetspeed-dev-archive@www.apache.org Received: (qmail 47407 invoked from network); 6 Dec 2005 19:34:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Dec 2005 19:34:29 -0000 Received: (qmail 53544 invoked by uid 500); 6 Dec 2005 19:32:36 -0000 Delivered-To: apmail-portals-jetspeed-dev-archive@portals.apache.org Received: (qmail 53304 invoked by uid 500); 6 Dec 2005 19:32:34 -0000 Mailing-List: contact jetspeed-dev-help@portals.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@portals.apache.org Received: (qmail 53043 invoked by uid 99); 6 Dec 2005 19:32:31 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2005 11:32:31 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 06 Dec 2005 11:32:04 -0800 Received: (qmail 45266 invoked by uid 65534); 6 Dec 2005 19:31:43 -0000 Message-ID: <20051206193143.45265.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r354516 [7/15] - in /portals/jetspeed-2/trunk: applications/j2-admin/src/java/org/apache/jetspeed/portlets/customizer/ applications/j2-admin/src/webapp/WEB-INF/ applications/j2-admin/src/webapp/WEB-INF/view/customizer/ applications/j2-admin... Date: Tue, 06 Dec 2005 19:30:51 -0000 To: jetspeed-dev@portals.apache.org From: taylor@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/Storage.as URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/Storage.as?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/Storage.as (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/Storage.as Tue Dec 6 11:29:56 2005 @@ -0,0 +1,51 @@ +import flash.external.ExternalInterface; + +class Storage { + static var app : Storage; + var store: SharedObject; + static var started: Boolean = false; + + public function Storage(){ + ExternalInterface.addCallback("set", null, set); + ExternalInterface.addCallback("get", null, get); + ExternalInterface.addCallback("free", null, free); + } + + public function set(key, value, namespace){ + var primeForReHide = false; + store = SharedObject.getLocal(namespace); + store.onStatus = function(status){ + // ExternalInterface.call("alert", status.code == "SharedObject.Flush.Failed"); + // ExternalInterface.call("alert", status.code == "SharedObject.Flush.Success"); + if(primeForReHide){ + primeForReHide = false; + ExternalInterface.call("dojo.storage.provider.hideStore"); + } + } + store.data[key] = value; + var ret = store.flush(); + if(typeof ret == "string"){ + ExternalInterface.call("dojo.storage.provider.unHideStore"); + primeForReHide = true; + } + return store.getSize(namespace); + } + + public function get(key, namespace){ + store = SharedObject.getLocal(namespace); + return store.data[key]; + } + + public function free(namespace){ + return SharedObject.getDiskUsage(namespace); + } + + static function main(mc){ + app = new Storage(); + if(!started){ + ExternalInterface.call("dojo.storage.provider.storageOnLoad"); + started = true; + } + } +} + Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/Storage.swf URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/Storage.swf?rev=354516&view=auto ============================================================================== Binary file - no diff available. Propchange: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/Storage.swf ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/__package__.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/__package__.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/__package__.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/__package__.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,6 @@ +dojo.hostenv.conditionalLoadModule({ + common: ["dojo.storage"], + browser: ["dojo.storage.browser"] +}); +dojo.hostenv.moduleLoaded("dojo.storage.*"); + Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/browser.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/browser.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/browser.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/browser.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,92 @@ +dojo.provide("dojo.storage.browser"); +dojo.require("dojo.storage"); +dojo.require("dojo.uri.*"); + +dojo.storage.browser.StorageProvider = function(){ + this.initialized = false; + this.flash = null; + this.backlog = []; +} + +dojo.inherits( dojo.storage.browser.StorageProvider, + dojo.storage.StorageProvider); + +dojo.lang.extend(dojo.storage.browser.StorageProvider, { + storageOnLoad: function(){ + this.initialized = true; + this.hideStore(); + while(this.backlog.length){ + this.set.apply(this, this.backlog.shift()); + } + }, + + unHideStore: function(){ + var container = dojo.byId("dojo-storeContainer"); + with(container.style){ + position = "absolute"; + overflow = "visible"; + width = "215px"; + height = "138px"; + // FIXME: make these positions dependent on screen size/scrolling! + left = "30px"; + top = "30px"; + visiblity = "visible"; + zIndex = "20"; + border = "1px solid black"; + } + }, + + hideStore: function(status){ + var container = dojo.byId("dojo-storeContainer"); + with(container.style){ + left = "-300px"; + top = "-300px"; + } + }, + + set: function(key, value, ns){ + if(!this.initialized){ + this.backlog.push([key, value, ns]); + return "pending"; + } + return this.flash.set(key, value, ns||this.namespace); + }, + + get: function(key, ns){ + return this.flash.get(key, ns||this.namespace); + }, + + writeStorage: function(){ + var swfloc = dojo.uri.dojoUri("src/storage/Storage.swf").toString(); + // alert(swfloc); + var storeParts = [ + '
']; + if(dojo.render.html.ie){ + storeParts.push(''); + storeParts.push(' '); + storeParts.push(' '); + storeParts.push(''); + }else{ + storeParts.push(''); + storeParts.push(''); + } + storeParts.push('
'); + document.write(storeParts.join("")); + } +}); + +dojo.storage.setProvider(new dojo.storage.browser.StorageProvider()); +dojo.storage.provider.writeStorage(); + +dojo.addOnLoad(function(){ + dojo.storage.provider.flash = (dojo.render.html.ie) ? window["dojoStorage"] : document["dojoStorage"]; +}); Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/storage.sh URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/storage.sh?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/storage.sh (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/storage/storage.sh Tue Dec 6 11:29:56 2005 @@ -0,0 +1,3 @@ +#! /bin/bash + +mtasc -version 8 -swf Storage.swf -main -header 215:138:10 Storage.as Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,276 @@ +dojo.provide("dojo.string"); +dojo.require("dojo.lang"); + +/** + * Trim whitespace from 'str'. If 'wh' > 0, + * only trim from start, if 'wh' < 0, only trim + * from end, otherwise trim both ends + */ +dojo.string.trim = function(str, wh){ + if(!dojo.lang.isString(str)){ return str; } + if(!str.length){ return str; } + if(wh > 0) { + return str.replace(/^\s+/, ""); + } else if(wh < 0) { + return str.replace(/\s+$/, ""); + } else { + return str.replace(/^\s+|\s+$/g, ""); + } +} + +/** + * Trim whitespace at the beginning of 'str' + */ +dojo.string.trimStart = function(str) { + return dojo.string.trim(str, 1); +} + +/** + * Trim whitespace at the end of 'str' + */ +dojo.string.trimEnd = function(str) { + return dojo.string.trim(str, -1); +} + +/** + * Parameterized string function + * str - formatted string with %{values} to be replaces + * pairs - object of name: "value" value pairs + * killExtra - remove all remaining %{values} after pairs are inserted + */ +dojo.string.paramString = function(str, pairs, killExtra) { + for(var name in pairs) { + var re = new RegExp("\\%\\{" + name + "\\}", "g"); + str = str.replace(re, pairs[name]); + } + + if(killExtra) { str = str.replace(/%\{([^\}\s]+)\}/g, ""); } + return str; +} + +/** Uppercases the first letter of each word */ +dojo.string.capitalize = function (str) { + if (!dojo.lang.isString(str)) { return ""; } + if (arguments.length == 0) { str = this; } + var words = str.split(' '); + var retval = ""; + var len = words.length; + for (var i=0; i/gm, ">").replace(/"/gm, """).replace(/'/gm, "'"); +} + +dojo.string.escapeSql = function(str) { + return str.replace(/'/gm, "''"); +} + +dojo.string.escapeRegExp = function(str) { + return str.replace(/\\/gm, "\\\\").replace(/([\f\b\n\t\r])/gm, "\\$1"); +} + +dojo.string.escapeJavaScript = function(str) { + return str.replace(/(["'\f\b\n\t\r])/gm, "\\$1"); +} + +/** + * Return 'str' repeated 'count' times, optionally + * placing 'separator' between each rep + */ +dojo.string.repeat = function(str, count, separator) { + var out = ""; + for(var i = 0; i < count; i++) { + out += str; + if(separator && i < count - 1) { + out += separator; + } + } + return out; +} + +/** + * Returns true if 'str' ends with 'end' + */ +dojo.string.endsWith = function(str, end, ignoreCase) { + if(ignoreCase) { + str = str.toLowerCase(); + end = end.toLowerCase(); + } + return str.lastIndexOf(end) == str.length - end.length; +} + +/** + * Returns true if 'str' ends with any of the arguments[2 -> n] + */ +dojo.string.endsWithAny = function(str /* , ... */) { + for(var i = 1; i < arguments.length; i++) { + if(dojo.string.endsWith(str, arguments[i])) { + return true; + } + } + return false; +} + +/** + * Returns true if 'str' starts with 'start' + */ +dojo.string.startsWith = function(str, start, ignoreCase) { + if(ignoreCase) { + str = str.toLowerCase(); + start = start.toLowerCase(); + } + return str.indexOf(start) == 0; +} + +/** + * Returns true if 'str' starts with any of the arguments[2 -> n] + */ +dojo.string.startsWithAny = function(str /* , ... */) { + for(var i = 1; i < arguments.length; i++) { + if(dojo.string.startsWith(str, arguments[i])) { + return true; + } + } + return false; +} + +/** + * Returns true if 'str' starts with any of the arguments 2 -> n + */ +dojo.string.has = function(str /* , ... */) { + for(var i = 1; i < arguments.length; i++) { + if(str.indexOf(arguments[i] > -1)) { + return true; + } + } + return false; +} + +/** + * Pad 'str' to guarantee that it is at least 'len' length + * with the character 'c' at either the start (dir=1) or + * end (dir=-1) of the string + */ +dojo.string.pad = function(str, len/*=2*/, c/*='0'*/, dir/*=1*/) { + var out = String(str); + if(!c) { + c = '0'; + } + if(!dir) { + dir = 1; + } + while(out.length < len) { + if(dir > 0) { + out = c + out; + } else { + out += c; + } + } + return out; +} + +/** same as dojo.string.pad(str, len, c, 1) */ +dojo.string.padLeft = function(str, len, c) { + return dojo.string.pad(str, len, c, 1); +} + +/** same as dojo.string.pad(str, len, c, -1) */ +dojo.string.padRight = function(str, len, c) { + return dojo.string.pad(str, len, c, -1); +} + +// do we even want to offer this? is it worth it? +dojo.string.addToPrototype = function() { + for(var method in dojo.string) { + if(dojo.lang.isFunction(dojo.string[method])) { + var func = (function() { + var meth = method; + switch(meth) { + case "addToPrototype": + return null; + break; + case "escape": + return function(type) { + return dojo.string.escape(type, this); + } + break; + default: + return function() { + var args = [this]; + for(var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + dojo.debug(args); + return dojo.string[meth].apply(dojo.string, args); + } + } + })(); + if(func) { String.prototype[method] = func; } + } + } +} Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string/Builder.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string/Builder.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string/Builder.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string/Builder.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,69 @@ +dojo.provide("dojo.string.Builder"); +dojo.require("dojo.string"); + +dojo.string.Builder = function(str){ + var a = []; + var b = str || ""; + var length = this.length = b.length; + + if(b.length > 0){ + a.push(b); + } + b = ""; + this.toString = this.valueOf = function(){ + return a.join(""); + }; + + this.append = function(s){ + a.push(s); + length += s.length; + this.length = length; + return this; + }; + + this.clear = function(){ + a=[]; + length = this.length = 0; + return this; + }; + + this.remove = function(f,l){ + var s = ""; + b = a.join(""); + a=[]; + if(f>0){ + s = b.substring(0, (f-1)); + } + b = s + b.substring(f + l); + a.push(b); + length = this.length = b.length; + b=""; + return this; + }; + + this.replace = function(o,n){ + b = a.join(""); + a = []; + b = b.replace(o,n); + a.push(b); + length = this.length = b.length; + b=""; + return this; + }; + + this.insert = function(idx,s){ + b = a.join(""); + a=[]; + if(idx == 0){ + b = s + b; + }else{ + var t = b.split(""); + t.splice(idx,0,s); + b = t.join("") + } + length = this.length = b.length; + a.push(b); + b=""; + return this; + }; +}; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string/__package__.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string/__package__.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string/__package__.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/string/__package__.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,7 @@ +dojo.hostenv.conditionalLoadModule({ + common: [ + "dojo.string", + "dojo.string.Builder" + ] +}); +dojo.hostenv.moduleLoaded("dojo.string.*"); Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/style.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/style.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/style.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/style.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,514 @@ +dojo.provide("dojo.style"); +dojo.require("dojo.dom"); +dojo.require("dojo.uri.Uri"); +dojo.require("dojo.graphics.color"); + +// values: content-box, border-box +dojo.style.boxSizing = { + marginBox: "margin-box", + borderBox: "border-box", + paddingBox: "padding-box", + contentBox: "content-box" +}; + +dojo.style.getBoxSizing = function(node) +{ + if (dojo.render.html.ie || dojo.render.html.opera){ + var cm = document["compatMode"]; + if (cm == "BackCompat" || cm == "QuirksMode"){ + return dojo.style.boxSizing.borderBox; + }else{ + return dojo.style.boxSizing.contentBox; + } + }else{ + if(arguments.length == 0){ node = document.documentElement; } + var sizing = dojo.style.getStyle(node, "-moz-box-sizing"); + if(!sizing){ sizing = dojo.style.getStyle(node, "box-sizing"); } + return (sizing ? sizing : dojo.style.boxSizing.contentBox); + } +} + +/* + +The following several function use the dimensions shown below + + +-------------------------+ + | margin | + | +---------------------+ | + | | border | | + | | +-----------------+ | | + | | | padding | | | + | | | +-------------+ | | | + | | | | content | | | | + | | | +-------------+ | | | + | | +-|-------------|-+ | | + | +-|-|-------------|-|-+ | + +-|-|-|-------------|-|-|-+ + | | | | | | | | + | | | |<- content ->| | | | + | |<------ inner ------>| | + |<-------- outer -------->| + +-------------------------+ + + * content-box + + |m|b|p| |p|b|m| + | |<------ offset ----->| | + | | |<---- client --->| | | + | | | |<-- width -->| | | | + + * border-box + + |m|b|p| |p|b|m| + | |<------ offset ----->| | + | | |<---- client --->| | | + | |<------ width ------>| | +*/ + +/* + Notes: + + General: + - Uncomputable values are returned as NaN. + - setOuterWidth/Height return *false* if the outer size could not be computed, otherwise *true*. + - I (sjmiles) know no way to find the calculated values for auto-margins. + - All returned values are floating point in 'px' units. If a non-zero computed style value is not specified in 'px', NaN is returned. + + FF: + - styles specified as '0' (unitless 0) show computed as '0pt'. + + IE: + - clientWidth/Height are unreliable (0 unless the object has 'layout'). + - margins must be specified in px, or 0 (in any unit) for any sizing function to work. Otherwise margins detect as 'auto'. + - padding can be empty or, if specified, must be in px, or 0 (in any unit) for any sizing function to work. + + Safari: + - Safari defaults padding values to 'auto'. + + See the unit tests for examples of (un)computable values in a given browser. + +*/ + +// FIXME: these work for most elements (e.g. DIV) but not all (e.g. TEXTAREA) + +dojo.style.isBorderBox = function(node) +{ + return (dojo.style.getBoxSizing(node) == dojo.style.boxSizing.borderBox); +} + +dojo.style.getUnitValue = function (element, cssSelector, autoIsZero){ + var result = { value: 0, units: 'px' }; + var s = dojo.style.getComputedStyle(element, cssSelector); + if (s == '' || (s == 'auto' && autoIsZero)){ return result; } + if (dojo.lang.isUndefined(s)){ + result.value = NaN; + }else{ + // FIXME: is regex inefficient vs. parseInt or some manual test? + var match = s.match(/([\d.]+)([a-z%]*)/i); + if (!match){ + result.value = NaN; + }else{ + result.value = Number(match[1]); + result.units = match[2].toLowerCase(); + } + } + return result; +} + +dojo.style.getPixelValue = function (element, cssSelector, autoIsZero){ + var result = dojo.style.getUnitValue(element, cssSelector, autoIsZero); + // FIXME: code exists for converting other units to px (see Dean Edward's IE7) + // but there are cross-browser complexities + if (isNaN(result.value) || (result.value && result.units != 'px')) { return NaN; } + return result.value; +} + +dojo.style.getNumericStyle = dojo.style.getPixelValue; // backward compat + +dojo.style.isPositionAbsolute = function(node){ + return (dojo.style.getComputedStyle(node, 'position') == 'absolute'); +} + +dojo.style.getMarginWidth = function(node){ + var autoIsZero = dojo.style.isPositionAbsolute(node); + var left = dojo.style.getPixelValue(node, "margin-left", autoIsZero); + var right = dojo.style.getPixelValue(node, "margin-right", autoIsZero); + return left + right; +} + +dojo.style.getBorderWidth = function(node){ + // the removed calculation incorrectly includes scrollbar + //if (node.clientWidth){ + // return node.offsetWidth - node.clientWidth; + //}else + { + var left = (dojo.style.getStyle(node, 'border-left-style') == 'none' ? 0 : dojo.style.getPixelValue(node, "border-left-width")); + var right = (dojo.style.getStyle(node, 'border-right-style') == 'none' ? 0 : dojo.style.getPixelValue(node, "border-right-width")); + return left + right; + } +} + +dojo.style.getPaddingWidth = function(node){ + var left = dojo.style.getPixelValue(node, "padding-left", true); + var right = dojo.style.getPixelValue(node, "padding-right", true); + return left + right; +} + +dojo.style.getContentWidth = function (node){ + return node.offsetWidth - dojo.style.getPaddingWidth(node) - dojo.style.getBorderWidth(node); +} + +dojo.style.getInnerWidth = function (node){ + return node.offsetWidth; +} + +dojo.style.getOuterWidth = function (node){ + return dojo.style.getInnerWidth(node) + dojo.style.getMarginWidth(node); +} + +dojo.style.setOuterWidth = function (node, pxWidth){ + if (!dojo.style.isBorderBox(node)){ + pxWidth -= dojo.style.getPaddingWidth(node) + dojo.style.getBorderWidth(node); + } + pxWidth -= dojo.style.getMarginWidth(node); + if (!isNaN(pxWidth) && pxWidth > 0){ + node.style.width = pxWidth + 'px'; + return true; + }else return false; +} + +// FIXME: these aliases are actually the preferred names +dojo.style.getContentBoxWidth = dojo.style.getContentWidth; +dojo.style.getBorderBoxWidth = dojo.style.getInnerWidth; +dojo.style.getMarginBoxWidth = dojo.style.getOuterWidth; +dojo.style.setMarginBoxWidth = dojo.style.setOuterWidth; + +dojo.style.getMarginHeight = function(node){ + var autoIsZero = dojo.style.isPositionAbsolute(node); + var top = dojo.style.getPixelValue(node, "margin-top", autoIsZero); + var bottom = dojo.style.getPixelValue(node, "margin-bottom", autoIsZero); + return top + bottom; +} + +dojo.style.getBorderHeight = function(node){ + // this removed calculation incorrectly includes scrollbar +// if (node.clientHeight){ +// return node.offsetHeight- node.clientHeight; +// }else + { + var top = (dojo.style.getStyle(node, 'border-top-style') == 'none' ? 0 : dojo.style.getPixelValue(node, "border-top-width")); + var bottom = (dojo.style.getStyle(node, 'border-bottom-style') == 'none' ? 0 : dojo.style.getPixelValue(node, "border-bottom-width")); + return top + bottom; + } +} + +dojo.style.getPaddingHeight = function(node){ + var top = dojo.style.getPixelValue(node, "padding-top", true); + var bottom = dojo.style.getPixelValue(node, "padding-bottom", true); + return top + bottom; +} + +dojo.style.getContentHeight = function (node){ + return node.offsetHeight - dojo.style.getPaddingHeight(node) - dojo.style.getBorderHeight(node); +} + +dojo.style.getInnerHeight = function (node){ + return node.offsetHeight; // FIXME: does this work? +} + +dojo.style.getOuterHeight = function (node){ + return dojo.style.getInnerHeight(node) + dojo.style.getMarginHeight(node); +} + +dojo.style.setOuterHeight = function (node, pxHeight){ + if (!dojo.style.isBorderBox(node)){ + pxHeight -= dojo.style.getPaddingHeight(node) + dojo.style.getBorderHeight(node); + } + pxHeight -= dojo.style.getMarginHeight(node); + if (!isNaN(pxHeight) && pxHeight > 0){ + node.style.height = pxHeight + 'px'; + return true; + }else return false; +} + +dojo.style.setContentWidth = function(node, pxWidth){ + + if (dojo.style.isBorderBox(node)){ + pxWidth += dojo.style.getPaddingWidth(node) + dojo.style.getBorderWidth(node); + } + + if (!isNaN(pxWidth) && pxWidth > 0){ + node.style.width = pxWidth + 'px'; + return true; + }else return false; +} + +dojo.style.setContentHeight = function(node, pxHeight){ + + if (dojo.style.isBorderBox(node)){ + pxHeight += dojo.style.getPaddingHeight(node) + dojo.style.getBorderHeight(node); + } + + if (!isNaN(pxHeight) && pxHeight > 0){ + node.style.height = pxHeight + 'px'; + return true; + }else return false; +} + +// FIXME: these aliases are actually the preferred names +dojo.style.getContentBoxHeight = dojo.style.getContentHeight; +dojo.style.getBorderBoxHeight = dojo.style.getInnerHeight; +dojo.style.getMarginBoxHeight = dojo.style.getOuterHeight; +dojo.style.setMarginBoxHeight = dojo.style.setOuterHeight; + +dojo.style.getTotalOffset = function (node, type, includeScroll){ + var typeStr = (type=="top") ? "offsetTop" : "offsetLeft"; + var typeScroll = (type=="top") ? "scrollTop" : "scrollLeft"; + + var alt = (type=="top") ? "y" : "x"; + var ret = 0; + if(node["offsetParent"]){ + + if(includeScroll && node.parentNode != document.body) { + ret -= dojo.style.sumAncestorProperties(node, typeScroll); + } + // FIXME: this is known not to work sometimes on IE 5.x since nodes + // soemtimes need to be "tickled" before they will display their + // offset correctly + do { + ret += node[typeStr]; + node = node.offsetParent; + } while (node != document.getElementsByTagName("body")[0].parentNode && node != null); + + }else if(node[alt]){ + ret += node[alt]; + } + return ret; +} + +dojo.style.sumAncestorProperties = function (node, prop) { + if (!node) { return 0; } // FIXME: throw an error? + + var retVal = 0; + while (node) { + var val = node[prop]; + if (val) { + retVal += val - 0; + } + node = node.parentNode; + } + return retVal; +} + +dojo.style.totalOffsetLeft = function (node, includeScroll){ + return dojo.style.getTotalOffset(node, "left", includeScroll); +} + +dojo.style.getAbsoluteX = dojo.style.totalOffsetLeft; + +dojo.style.totalOffsetTop = function (node, includeScroll){ + return dojo.style.getTotalOffset(node, "top", includeScroll); +} + +dojo.style.getAbsoluteY = dojo.style.totalOffsetTop; + +dojo.style.getAbsolutePosition = function(node, includeScroll) { + var position = [ + dojo.style.getAbsoluteX(node, includeScroll), + dojo.style.getAbsoluteY(node, includeScroll) + ]; + position.x = position[0]; + position.y = position[1]; + return position; +} + +dojo.style.styleSheet = null; + +// FIXME: this is a really basic stub for adding and removing cssRules, but +// it assumes that you know the index of the cssRule that you want to add +// or remove, making it less than useful. So we need something that can +// search for the selector that you you want to remove. +dojo.style.insertCssRule = function (selector, declaration, index) { + if (!dojo.style.styleSheet) { + if (document.createStyleSheet) { // IE + dojo.style.styleSheet = document.createStyleSheet(); + } else if (document.styleSheets[0]) { // rest + // FIXME: should create a new style sheet here + // fall back on an exsiting style sheet + dojo.style.styleSheet = document.styleSheets[0]; + } else { return null; } // fail + } + + if (arguments.length < 3) { // index may == 0 + if (dojo.style.styleSheet.cssRules) { // W3 + index = dojo.style.styleSheet.cssRules.length; + } else if (dojo.style.styleSheet.rules) { // IE + index = dojo.style.styleSheet.rules.length; + } else { return null; } // fail + } + + if (dojo.style.styleSheet.insertRule) { // W3 + var rule = selector + " { " + declaration + " }"; + return dojo.style.styleSheet.insertRule(rule, index); + } else if (dojo.style.styleSheet.addRule) { // IE + return dojo.style.styleSheet.addRule(selector, declaration, index); + } else { return null; } // fail +} + +dojo.style.removeCssRule = function (index){ + if(!dojo.style.styleSheet){ + dojo.debug("no stylesheet defined for removing rules"); + return false; + } + if(dojo.render.html.ie){ + if(!index){ + index = dojo.style.styleSheet.rules.length; + dojo.style.styleSheet.removeRule(index); + } + }else if(document.styleSheets[0]){ + if(!index){ + index = dojo.style.styleSheet.cssRules.length; + } + dojo.style.styleSheet.deleteRule(index); + } + return true; +} + +dojo.style.insertCssFile = function (URI, doc, checkDuplicates){ + if(!URI) { return; } + if(!doc){ doc = document; } + // Safari doesn't have this property, but it doesn't support + // styleSheets.href either so it beomces moot + if(doc.baseURI) { URI = new dojo.uri.Uri(doc.baseURI, URI); } + if(checkDuplicates && doc.styleSheets){ + // get the host + port info from location + var loc = location.href.split("#")[0].substring(0, location.href.indexOf(location.pathname)); + for(var i = 0; i < doc.styleSheets.length; i++){ + if(doc.styleSheets[i].href && URI.toString() == + new dojo.uri.Uri(doc.styleSheets[i].href.toString())) { return; } + } + } + var file = doc.createElement("link"); + file.setAttribute("type", "text/css"); + file.setAttribute("rel", "stylesheet"); + file.setAttribute("href", URI); + var head = doc.getElementsByTagName("head")[0]; + if(head){ // FIXME: why isn't this working on Opera 8? + head.appendChild(file); + } +} + +dojo.style.getBackgroundColor = function (node) { + var color; + do{ + color = dojo.style.getStyle(node, "background-color"); + // Safari doesn't say "transparent" + if(color.toLowerCase() == "rgba(0, 0, 0, 0)") { color = "transparent"; } + if(node == document.getElementsByTagName("body")[0]) { node = null; break; } + node = node.parentNode; + }while(node && dojo.lang.inArray(color, ["transparent", ""])); + + if( color == "transparent" ) { + color = [255, 255, 255, 0]; + } else { + color = dojo.graphics.color.extractRGB(color); + } + return color; +} + +dojo.style.getComputedStyle = function (element, cssSelector, inValue) { + var value = inValue; + if (element.style.getPropertyValue) { // W3 + value = element.style.getPropertyValue(cssSelector); + } + if(!value) { + if (document.defaultView) { // gecko + value = document.defaultView.getComputedStyle(element, "") + .getPropertyValue(cssSelector); + } else if (element.currentStyle) { // IE + value = element.currentStyle[dojo.style.toCamelCase(cssSelector)]; + } + } + return value; +} + +dojo.style.getStyle = function (element, cssSelector) { + var camelCased = dojo.style.toCamelCase(cssSelector); + var value = element.style[camelCased]; // dom-ish + return (value ? value : dojo.style.getComputedStyle(element, cssSelector, value)); +} + +dojo.style.toCamelCase = function (selector) { + var arr = selector.split('-'), cc = arr[0]; + for(var i = 1; i < arr.length; i++) { + cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1); + } + return cc; +} + +dojo.style.toSelectorCase = function (selector) { + return selector.replace(/([A-Z])/g, "-$1" ).toLowerCase() ; +} + +/* float between 0.0 (transparent) and 1.0 (opaque) */ +dojo.style.setOpacity = function setOpacity (node, opacity, dontFixOpacity) { + node = dojo.byId(node); + var h = dojo.render.html; + if(!dontFixOpacity){ + if( opacity >= 1.0){ + if(h.ie){ + dojo.style.clearOpacity(node); + return; + }else{ + opacity = 0.999999; + } + }else if( opacity < 0.0){ opacity = 0; } + } + if(h.ie){ + if(node.nodeName.toLowerCase() == "tr"){ + // FIXME: is this too naive? will we get more than we want? + var tds = node.getElementsByTagName("td"); + for(var x=0; x= 0.999999 ? 1.0 : Number(opac); +} + +dojo.style.clearOpacity = function clearOpacity (node) { + var h = dojo.render.html; + if(h.ie){ + if( node.filters && node.filters.alpha ) { + node.style.filter = ""; // FIXME: may get rid of other filter effects + } + }else if(h.moz){ + node.style.opacity = 1; + node.style.MozOpacity = 1; + }else if(h.safari){ + node.style.opacity = 1; + node.style.KhtmlOpacity = 1; + }else{ + node.style.opacity = 1; + } +} Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/svg.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/svg.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/svg.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/svg.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,267 @@ +dojo.provide("dojo.svg"); +dojo.require("dojo.lang"); +dojo.require("dojo.dom"); + +dojo.lang.mixin(dojo.svg, dojo.dom); + +/** + * The Graphics object. Hopefully gives the user a way into + * XPlatform rendering functions supported correctly and incorrectly. +**/ +dojo.svg.graphics = dojo.svg.g = new function(d){ + this.suspend = function(){ + try { d.documentElement.suspendRedraw(0); } catch(e){ } + }; + this.resume = function(){ + try { d.documentElement.unsuspendRedraw(0); } catch(e){ } + }; + this.force = function(){ + try { d.documentElement.forceRedraw(); } catch(e){ } + }; +}(document); + +/** + * The Animations control object. Hopefully gives the user a way into + * XPlatform animation functions supported correctly and incorrectly. +**/ +dojo.svg.animations = dojo.svg.anim = new function(d){ + this.arePaused = function(){ + try { + return d.documentElement.animationsPaused(); + } catch(e){ + return false; + } + } ; + this.pause = function(){ + try { d.documentElement.pauseAnimations(); } catch(e){ } + }; + this.resume = function(){ + try { d.documentElement.unpauseAnimations(); } catch(e){ } + }; +}(document); + +/** + * signatures from dojo.style. + */ +dojo.svg.toCamelCase = function(selector){ + var arr = selector.split('-'), cc = arr[0]; + for(var i = 1; i < arr.length; i++) { + cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1); + } + return cc; +}; +dojo.svg.toSelectorCase = function (selector) { + return selector.replace(/([A-Z])/g, "-$1" ).toLowerCase() ; +}; +dojo.svg.getStyle = function(node, cssSelector){ + return document.defaultView.getComputedStyle(node, cssSelector); +}; +dojo.svg.getNumericStyle = function(node, cssSelector){ + return parseFloat(dojo.svg.getStyle(node, cssSelector)); +}; + +/** + * alpha channel operations + */ +dojo.svg.getOpacity = function(node){ + return Math.min(1.0, dojo.svg.getNumericStyle(node, "fill-opacity")); +}; +dojo.svg.setOpacity = function(node, opacity){ + node.setAttributeNS(this.xmlns.svg, "fill-opacity", opacity); + node.setAttributeNS(this.xmlns.svg, "stroke-opacity", opacity); +}; +dojo.svg.clearOpacity = function(node){ + node.setAttributeNS(this.xmlns.svg, "fill-opacity", "1.0"); + node.setAttributeNS(this.xmlns.svg, "stroke-opacity", "1.0"); +}; + +/** + * Coordinates and dimensions. + */ +dojo.svg.getCoords = function(node){ + if (node.getBBox) { + var box = node.getBBox(); + return { x: box.x, y: box.y }; + } + return null; +}; +dojo.svg.setCoords = function(node, coords){ + var p = dojo.svg.getCoords(); + if (!p) return; + var dx = p.x - coords.x; + var dy = p.y - coords.y; + dojo.svg.translate(node, dx, dy); +}; +dojo.svg.getDimensions = function(node){ + if (node.getBBox){ + var box = node.getBBox(); + return { width: box.width, height : box.height }; + } + return null; +}; +dojo.svg.setDimensions = function(node, dim){ + // will only support shape-based and container elements; path-based elements are ignored. + if (node.width){ + node.width.baseVal.value = dim.width; + node.height.baseVal.vaule = dim.height; + } + else if (node.r){ + node.r.baseVal.value = Math.min(dim.width, dim.height)/2; + } + else if (node.rx){ + node.rx.baseVal.value = dim.width/2; + node.ry.baseVal.value = dim.height/2; + } +}; + +/** + * Transformations. + */ +dojo.svg.translate = function(node, dx, dy){ + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ + var t = node.ownerSVGElement.createSVGTransform(); + t.setTranslate(dx, dy); + node.transform.baseVal.appendItem(t); + } +}; +dojo.svg.scale = function(node, scaleX, scaleY){ + if (!scaleY) var scaleY = scaleX; + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ + var t = node.ownerSVGElement.createSVGTransform(); + t.setScale(scaleX, scaleY); + node.transform.baseVal.appendItem(t); + } +}; +dojo.svg.rotate = function(node, ang, cx, cy){ + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ + var t = node.ownerSVGElement.createSVGTransform(); + if (!cx) t.setMatrix(t.matrix.rotate(ang)); + else t.setRotate(ang, cx, cy); + node.transform.baseVal.appendItem(t); + } +}; +dojo.svg.skew = function(node, ang, axis){ + var dir = axis || "x"; + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ + var t = node.ownerSVGElement.createSVGTransform(); + if (dir != "x") t.setSkewY(ang); + else t.setSkewX(ang); + node.transform.baseVal.appendItem(t); + } +}; +dojo.svg.flip = function(node, axis){ + var dir = axis || "x"; + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ + var t = node.ownerSVGElement.createSVGTransform(); + t.setMatrix((dir != "x") ? t.matrix.flipY() : t.matrix.flipX()); + node.transform.baseVal.appendItem(t); + } +}; +dojo.svg.invert = function(node){ + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ + var t = node.ownerSVGElement.createSVGTransform(); + t.setMatrix(t.matrix.inverse()); + node.transform.baseVal.appendItem(t); + } +}; +dojo.svg.applyMatrix = function(node, a, b, c, d, e, f){ + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ + var m; + if (b){ + var m = node.ownerSVGElement.createSVGMatrix(); + m.a = a; + m.b = b; + m.c = c; + m.d = d; + m.e = e; + m.f = f; + } else m = a; + var t = node.ownerSVGElement.createSVGTransform(); + t.setMatrix(m); + node.transform.baseVal.appendItem(t); + } +}; + +/** + * Grouping and z-index operations. + */ +dojo.svg.group = function(nodes){ + // expect an array of nodes, attaches the group to the parent of the first node. + var p = nodes.item(0).parentNode; + var g = document.createElementNS(this.xmlns.svg, "g"); + for (var i = 0; i < nodes.length; i++) g.appendChild(nodes.item(i)); + p.appendChild(g); + return g; +}; +dojo.svg.ungroup = function(g){ + // puts the children of the group on the same level as group was. + var p = g.parentNode; + while (g.childNodes.length > 0) p.appendChild(g.childNodes.item(0)); + p.removeChild(g); +}; +// if the node is part of a group, return the group, else return null. +dojo.svg.getGroup = function(node){ + // if the node is part of a group, return the group, else return null. + var a = this.getAncestors(node); + for (var i = 0; i < a.length; i++){ + if (a[i].nodeType == this.ELEMENT_NODE && a[i].nodeName.toLowerCase() == "g") + return a[i]; + } + return null; +}; +dojo.svg.bringToFront = function(node){ + var n = this.getGroup(node) || node; + n.ownerSVGElement.appendChild(n); +}; +dojo.svg.sendToBack = function(node){ + var n = this.getGroup(node) || node; + n.ownerSVGElement.insertBefore(n, n.ownerSVGElement.firstChild); +}; +// TODO: possibly push node up a level in the DOM if it's at the beginning or end of the childNodes list. +dojo.svg.bringForward = function(node){ + var n = this.getGroup(node) || node; + if (this.getLastChildElement(n.parentNode) != n){ + this.insertAfter(n, this.getNextSiblingElement(n), true); + } +}; +dojo.svg.sendBackward = function(node){ + var n = this.getGroup(node) || node; + if (this.getFirstChildElement(n.parentNode) != n){ + this.insertBefore(n, this.getPreviousSiblingElement(n), true); + } +}; +// modded to account for FF 1.5 mixed environment, will try ASVG first, then w3 standard. +dojo.dom.createNodesFromText = function (txt, wrap){ + var docFrag; + if (window.parseXML) docFrag = parseXML(txt, window.document); + else if (window.DOMParser) docFrag = (new DOMParser()).parseFromString(txt, "text/xml"); + else dojo.raise("dojo.dom.createNodesFromText: environment does not support XML parsing"); + docFrag.normalize(); + if(wrap){ + var ret = [docFrag.firstChild.cloneNode(true)]; + return ret; + } + var nodes = []; + for(var x=0; x"); + document.write(""); +} +*/ +// vim:ts=4:noet:tw=0: Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/Builder.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/Builder.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/Builder.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/Builder.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,6 @@ +dojo.provide("dojo.text.Builder"); +dojo.require("dojo.string.Builder"); + +dj_deprecated("dojo.text.Builder is deprecated, use dojo.string.Builder instead"); + +dojo.text.Builder = dojo.string.Builder; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/String.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/String.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/String.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/String.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,5 @@ +dj_deprecated("dojo.text.String is being replaced by dojo.string"); +dojo.require("dojo.string"); + +dojo.text = dojo.string; +dojo.provide("dojo.text.String"); Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/Text.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/Text.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/Text.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/Text.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,5 @@ +dj_deprecated("dojo.text.Text is being replaced by dojo.string"); +dojo.require("dojo.string"); + +dojo.text = dojo.string; +dojo.provide("dojo.text.Text"); Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/__package__.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/__package__.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/__package__.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/text/__package__.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,7 @@ +dojo.hostenv.conditionalLoadModule({ + common: [ + "dojo.text.String", + "dojo.text.Builder" + ] +}); +dojo.hostenv.moduleLoaded("dojo.text.*"); Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/undo/Manager.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/undo/Manager.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/undo/Manager.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/undo/Manager.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,81 @@ +dojo.provide("dojo.undo.Manager"); + +dojo.undo.Manager = function () { + + this._undoStack = []; + this._redoStack = []; + + this._undoRegistrationLevel = 0; +} + +dojo.undo.Manager.prototype = { + +//Registering undo operations + //registerUndoWithTarget:selector:object: + prepareWithInvocationTarget: function () {}, + forwardInvocation: function () {}, + +//Checking undo ability + canUndo: false, + canRedo: false, + +//Performing undo and redo + undo: function () {}, + undoNestedGroup: function () {}, + redo: function () {}, + +//Limiting the undo stack + setLevelsOfUndo: function (levels) { + this.levelsOfUndo = levels; + if (levels != 0 && this._undoStack.length > levels) { + this._undoStack.splice(levels, this._undoStack.length - levels); + } + }, + levelsOfUndo: 0, + +//Creating undo groups + beginUndoGrouping: function () {}, + endUndoGrouping: function () {}, + enableUndoRegistration: function () { + if (++this._undoRegistrationLevel >= 0) { + this._undoRegistrationLevel = 0; + this.isUndoRegistrationEnabled = true; + } + }, + groupsByEvent: true, + setGroupsByEvent: function (bool) { this.groupsByEvent = bool; }, + groupingLevel: 0, + +//Disabling undo + disableUndoRegistration = function () { + this.isUndoRegistrationEnabled = false; + this._undoRegistrationLevel--; + }, + isUndoRegistrationEnabled: true, + +//Checking whether undo or redo is being performed + isUndoing: false, + isRedoing: false, + +//Clearing undo operations + removeAllActions: function () { + this._undoStack = []; + this._redoStack = []; + }, + removeAllActionsWithTarget: function (target) {}, + +//Setting and getting the action name + setActionName: function () {}, + redoActionName: null, + undoActionName: null, + +//Getting and localizing menu item title + redoMenuItemTitle: null, + undoMenuItemTitle: null, + redoMenuTitleForUndoActionName: function () {}, + undoMenuTitleForUndoActionName: function () {}, + +//Working with run loops + runLoopModes: [], + setRunLoopModes: function () {} +} \ No newline at end of file Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/uri/Uri.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/uri/Uri.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/uri/Uri.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/uri/Uri.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,100 @@ +dojo.provide("dojo.uri.Uri"); + +dojo.uri = new function() { + this.joinPath = function() { + // DEPRECATED: use the dojo.uri.Uri object instead + var arr = []; + for(var i = 0; i < arguments.length; i++) { arr.push(arguments[i]); } + return arr.join("/").replace(/\/{2,}/g, "/").replace(/((https*|ftps*):)/i, "$1/"); + } + + this.dojoUri = function (uri) { + // returns a Uri object resolved relative to the dojo root + return new dojo.uri.Uri(dojo.hostenv.getBaseScriptUri(), uri); + } + + this.Uri = function (/*uri1, uri2, [...]*/) { + // An object representing a Uri. + // Each argument is evaluated in order relative to the next until + // a conanical uri is producued. To get an absolute Uri relative + // to the current document use + // new dojo.uri.Uri(document.baseURI, uri) + + // TODO: support for IPv6, see RFC 2732 + + // resolve uri components relative to each other + var uri = arguments[0]; + for (var i = 1; i < arguments.length; i++) { + if(!arguments[i]) { continue; } + + // Safari doesn't support this.constructor so we have to be explicit + var relobj = new dojo.uri.Uri(arguments[i].toString()); + var uriobj = new dojo.uri.Uri(uri.toString()); + + if (relobj.path == "" && relobj.scheme == null && + relobj.authority == null && relobj.query == null) + { + if (relobj.fragment != null) { uriobj.fragment = relobj.fragment; } + relobj = uriobj; + } + else if (relobj.scheme == null) { + relobj.scheme = uriobj.scheme; + + if (relobj.authority == null) { + relobj.authority = uriobj.authority; + + if (relobj.path.charAt(0) != "/") { + var path = uriobj.path.substring(0, + uriobj.path.lastIndexOf("/") + 1) + relobj.path; + + var segs = path.split("/"); + for (var j = 0; j < segs.length; j++) { + if (segs[j] == ".") { + if (j == segs.length - 1) { segs[j] = ""; } + else { segs.splice(j, 1); j--; } + } else if (j > 0 && !(j == 1 && segs[0] == "") && + segs[j] == ".." && segs[j-1] != "..") + { + if (j == segs.length - 1) { segs.splice(j, 1); segs[j - 1] = ""; } + else { segs.splice(j - 1, 2); j -= 2; } + } + } + relobj.path = segs.join("/"); + } + } + } + + uri = ""; + if (relobj.scheme != null) { uri += relobj.scheme + ":"; } + if (relobj.authority != null) { uri += "//" + relobj.authority; } + uri += relobj.path; + if (relobj.query != null) { uri += "?" + relobj.query; } + if (relobj.fragment != null) { uri += "#" + relobj.fragment; } + } + + this.uri = uri.toString(); + + // break the uri into its main components + var regexp = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"; + var r = this.uri.match(new RegExp(regexp)); + + this.scheme = r[2] || (r[1] ? "" : null); + this.authority = r[4] || (r[3] ? "" : null); + this.path = r[5]; // can never be undefined + this.query = r[7] || (r[6] ? "" : null); + this.fragment = r[9] || (r[8] ? "" : null); + + if (this.authority != null) { + // server based naming authority + regexp = "^((([^:]+:)?([^@]+))@)?([^:]*)(:([0-9]+))?$"; + r = this.authority.match(new RegExp(regexp)); + + this.user = r[3] || null; + this.password = r[4] || null; + this.host = r[5]; + this.port = r[7] || null; + } + + this.toString = function () { return this.uri; } + } +}; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/uri/__package__.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/uri/__package__.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/uri/__package__.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/uri/__package__.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,4 @@ +dojo.hostenv.conditionalLoadModule({ + common: ["dojo.uri.Uri", false, false] +}); +dojo.hostenv.moduleLoaded("dojo.uri.*"); Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/validate.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/validate.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/validate.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/validate.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,781 @@ +dojo.provide("dojo.validate"); +dojo.provide("dojo.validate.us"); +dojo.require("dojo.regexp"); + +// *** Validation Functions **** + +/** + Checks if a string has non whitespace characters. + Parameters allow you to constrain the length. + + @param value A string. + @param flags An object. + flags.length If set, checks if there are exactly flags.length number of characters. + flags.minlength If set, checks if there are at least flags.minlength number of characters. + flags.maxlength If set, checks if there are at most flags.maxlength number of characters. + @return true or false. +*/ +dojo.validate.isText = function(value, flags) { + flags = (typeof flags == "object") ? flags : {}; + + // test for text + if ( /^\s*$/.test(value) ) { return false; } + + // length tests + if ( typeof flags.length == "number" && flags.length != value.length ) { return false; } + if ( typeof flags.minlength == "number" && flags.minlength > value.length ) { return false; } + if ( typeof flags.maxlength == "number" && flags.maxlength < value.length ) { return false; } + + return true; +} + +/** + Validates an IP address. + Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal. + Supports 2 formats for Ipv6. + + @param value A string. + @param flags An object. All flags are boolean with default = true. + flags.allowDottedDecimal Example, 207.142.131.235. No zero padding. + flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed. + flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed. + flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295. + flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF. + Case insensitive. Zero padding allowed. + flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits. + flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits + followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d + @return true or false +*/ +dojo.validate.isIpAddress = function(value, flags) { + var re = new RegExp("^" + dojo.regexp.ipAddress(flags) + "$", "i"); + return re.test(value); +} + +/** + Checks if a string could be a valid URL. + + @param value A string. + @param flags An object. + flags.scheme Can be true, false, or [true, false]. + This means: required, not allowed, or either. + flags in regexp.host can be applied. + flags in regexp.ipAddress can be applied. + flags in regexp.tld can be applied. + @return true or false +*/ +dojo.validate.isUrl = function(value, flags) { + var re = new RegExp("^" + dojo.regexp.url(flags) + "$", "i"); + return re.test(value); +} + +/** + Checks if a string could be a valid email address. + + @param value A string. + @param flags An object. + flags.allowCruft Allow address like . Default is false. + flags in regexp.host can be applied. + flags in regexp.ipAddress can be applied. + flags in regexp.tld can be applied. + @return true or false. +*/ +dojo.validate.isEmailAddress = function(value, flags) { + var re = new RegExp("^" + dojo.regexp.emailAddress(flags) + "$", "i"); + return re.test(value); +} + +/** + Checks if a string could be a valid email address list. + + @param value A string. + @param flags An object. + flags.listSeparator The character used to separate email addresses. Default is ";", ",", or " ". + flags in regexp.emailAddress can be applied. + flags in regexp.host can be applied. + flags in regexp.ipAddress can be applied. + flags in regexp.tld can be applied. + @return true or false. +*/ +dojo.validate.isEmailAddressList = function(value, flags) { + if(!flags) { flags = {}; } + if(!flags.listSeparator) { flags.listSeparator = "\\s;,"; } + var re = new RegExp("^" + dojo.regexp.emailAddressList(flags) + "$", "i"); + return re.test(value); +} + +/** + Check if value is an email address list. If an empty list + is returned, the value didn't pass the test or it was empty. + + @param value A string + @param flags An object (same as isEmailAddressList) + @return array of emails +*/ +dojo.validate.getEmailAddressList = function(value, flags) { + if(!flags) { flags = {}; } + if(!flags.listSeparator) { flags.listSeparator = "\\s;,"; } + + var re = new RegExp("^" + dojo.regexp.emailAddress(flags) + "$", "i"); + + var emails = []; + var vals = value.split(new RegExp("\\s*[" + flags.listSeparator + "]\\s*")); + for(var i = 0; i < vals.length; i++) { + if(re.test(vals[i])) { + emails.push(vals[i]); + } else { + return []; + } + } + return emails; +} + +/** + Validates whether a string is in an integer format. + + @param value A string. + @param flags An object. + flags.signed The leading plus-or-minus sign. Can be true, false, or [true, false]. + Default is [true, false], (i.e. sign is optional). + flags.separator The character used as the thousands separator. Default is no separator. + For more than one symbol use an array, e.g. [",", ""], makes ',' optional. + @return true or false. +*/ +dojo.validate.isInteger = function(value, flags) { + var re = new RegExp("^" + dojo.regexp.integer(flags) + "$"); + return re.test(value); +} + +/** + Validates whether a string is a real valued number. + Format is the usual exponential notation. + + @param value A string. + @param flags An object. + flags.places The integer number of decimal places. + If not given, the decimal part is optional and the number of places is unlimited. + flags.decimal The character used for the decimal point. Default is ".". + flags.exponent Express in exponential notation. Can be true, false, or [true, false]. + Default is [true, false], (i.e. the exponential part is optional). + flags.eSigned The leading plus-or-minus sign on the exponent. Can be true, false, + or [true, false]. Default is [true, false], (i.e. sign is optional). + flags in regexp.integer can be applied. + @return true or false. +*/ +dojo.validate.isRealNumber = function(value, flags) { + var re = new RegExp("^" + dojo.regexp.realNumber(flags) + "$"); + return re.test(value); +} + +/** + Validates whether a string denotes a monetary value. + + @param value A string. + @param flags An object. + flags.signed The leading plus-or-minus sign. Can be true, false, or [true, false]. + Default is [true, false], (i.e. sign is optional). + flags.symbol A currency symbol such as Yen "¥", Pound "£", or the Euro sign "€". + Default is "$". For more than one symbol use an array, e.g. ["$", ""], makes $ optional. + flags.placement The symbol can come "before" the number or "after". Default is "before". + flags.separator The character used as the thousands separator. The default is ",". + flags.cents The two decimal places for cents. Can be true, false, or [true, false]. + Default is [true, false], (i.e. cents are optional). + flags.decimal The character used for the decimal point. Default is ".". + @return true or false. +*/ +dojo.validate.isCurrency = function(value, flags) { + var re = new RegExp("^" + dojo.regexp.currency(flags) + "$"); + return re.test(value); +} + +/** + Validates U.S. currency. + + @param value A string. + @param flags An object. + flags in validate.isCurrency can be applied. + @return true or false. +*/ +dojo.validate.us.isCurrency = function(value, flags) { + return dojo.validate.isCurrency(value, flags); +} + +/** + Validates German currency. + + @param value A string. + @return true or false. +*/ +dojo.validate.isGermanCurrency = function(value) { + flags = { + symbol: "€", + placement: "after", + decimal: ",", + separator: "." + }; + return dojo.validate.isCurrency(value, flags); +} + +/** + Validates Japanese currency. + + @param value A string. + @return true or false. +*/ +dojo.validate.isJapaneseCurrency = function(value) { + flags = { + symbol: "¥", + cents: false + }; + return dojo.validate.isCurrency(value, flags); +} + +/** + Validates whether a string denoting an integer, + real number, or monetary value is between a max and min. + + @param value A string. + @param flags An object. + flags.max A number, which the value must be less than or equal to for the validation to be true. + flags.min A number, which the value must be greater than or equal to for the validation to be true. + flags.decimal The character used for the decimal point. Default is ".". + @return true or false. +*/ +dojo.validate.isInRange = function(value, flags) { + // assign default values to missing paramters + flags = (typeof flags == "object") ? flags : {}; + var max = (typeof flags.max == "number") ? flags.max : Infinity; + var min = (typeof flags.min == "number") ? flags.min : -Infinity; + var dec = (typeof flags.decimal == "string") ? flags.decimal : "."; + + // splice out anything not part of a number + var pattern = "[^" + dec + "\\deE+-]"; + value = value.replace(RegExp(pattern, "g"), ""); + + // trim ends of things like e, E, or the decimal character + value = value.replace(/^([+-]?)(\D*)/, "$1"); + value = value.replace(/(\D*)$/, ""); + + // replace decimal with ".". The minus sign '-' could be the decimal! + pattern = "(\\d)[" + dec + "](\\d)"; + value = value.replace(RegExp(pattern, "g"), "$1.$2"); + + value = Number(value); + if ( value < min || value > max ) { return false; } + + return true; +} + +/** + Validates a time value in any International format. + The value can be validated against one format or one of multiple formats. + + Format + h 12 hour, no zero padding. + hh 12 hour, has leading zero. + H 24 hour, no zero padding. + HH 24 hour, has leading zero. + m minutes, no zero padding. + mm minutes, has leading zero. + s seconds, no zero padding. + ss seconds, has leading zero. + All other characters must appear literally in the expression. + + Example + "h:m:s t" -> 2:5:33 PM + "HH:mm:ss" -> 14:05:33 + + @param value A string. + @param flags An object. + flags.format A string or an array of strings. Default is "h:mm:ss t". + flags.amSymbol The symbol used for AM. Default is "AM". + flags.pmSymbol The symbol used for PM. Default is "PM". + @return true or false +*/ +dojo.validate.isValidTime = function(value, flags) { + var re = new RegExp("^" + dojo.regexp.time(flags) + "$", "i"); + return re.test(value); +} + +/** + Validates 12-hour time format. + Zero-padding is not allowed for hours, required for minutes and seconds. + Seconds are optional. + + @param value A string. + @return true or false +*/ +dojo.validate.is12HourTime = function(value) { + return dojo.validate.isValidTime(value, {format: ["h:mm:ss t", "h:mm t"]}); +} + +/** + Validates 24-hour military time format. + Zero-padding is required for hours, minutes, and seconds. + Seconds are optional. + + @param value A string. + @return true or false +*/ +dojo.validate.is24HourTime = function(value) { + return dojo.validate.isValidTime(value, {format: ["HH:mm:ss", "HH:mm"]} ); +} + +/** + Returns true if the date conforms to the format given and is a valid date. Otherwise returns false. + + @param dateValue A string for the date. + @param format A string, default is "MM/DD/YYYY". + @return true or false + + Accepts any type of format, including ISO8601. + All characters in the format string are treated literally except the following tokens: + + YYYY - matches a 4 digit year + M - matches a non zero-padded month + MM - matches a zero-padded month + D - matches a non zero-padded date + DD - matches a zero-padded date + DDD - matches an ordinal date, 001-365, and 366 on leapyear + ww - matches week of year, 01-53 + d - matches day of week, 1-7 + + Examples: These are all today's date. + + Date Format + 2005-W42-3 YYYY-Www-d + 2005-292 YYYY-DDD + 20051019 YYYYMMDD + 10/19/2005 M/D/YYYY + 19.10.2005 D.M.YYYY +*/ +dojo.validate.isValidDate = function(dateValue, format) { + // Default is the American format + if (typeof format != "string") { format = "MM/DD/YYYY"; } + + // Create a literal regular expression based on format + var reLiteral = format.replace(/([$^.*+?=!:|\/\\\(\)\[\]\{\}])/g, "\\$1"); + + // Convert all the tokens to RE elements + reLiteral = reLiteral.replace( "YYYY", "([0-9]{4})" ); + reLiteral = reLiteral.replace( "MM", "(0[1-9]|10|11|12)" ); + reLiteral = reLiteral.replace( "M", "([1-9]|10|11|12)" ); + reLiteral = reLiteral.replace( "DDD", "(00[1-9]|0[1-9][0-9]|[12][0-9][0-9]|3[0-5][0-9]|36[0-6])" ); + reLiteral = reLiteral.replace( "DD", "(0[1-9]|[12][0-9]|30|31)" ); + reLiteral = reLiteral.replace( "D", "([1-9]|[12][0-9]|30|31)" ); + reLiteral = reLiteral.replace( "ww", "(0[1-9]|[1-4][0-9]|5[0-3])" ); + reLiteral = reLiteral.replace( "d", "([1-7])" ); + + // Anchor pattern to begining and end of string + reLiteral = "^" + reLiteral + "$"; + + // Dynamic RE that parses the original format given + var re = new RegExp(reLiteral); + + // Test if date is in a valid format + if (!re.test(dateValue)) return false; + + // Parse date to get elements and check if date is valid + // Assume valid values for date elements not given. + var year = 0, month = 1, date = 1, dayofyear = 1, week = 1, day = 1; + + // Capture tokens + var tokens = format.match( /(YYYY|MM|M|DDD|DD|D|ww|d)/g ); + + // Capture date values + var values = re.exec(dateValue); + + // Match up tokens with date values + for (var i = 0; i < tokens.length; i++) { + switch (tokens[i]) { + case "YYYY": + year = Number(values[i+1]); break; + case "M": + case "MM": + month = Number(values[i+1]); break; + case "D": + case "DD": + date = Number(values[i+1]); break; + case "DDD": + dayofyear = Number(values[i+1]); break; + case "ww": + week = Number(values[i+1]); break; + case "d": + day = Number(values[i+1]); break; + } + } + + // Leap years are divisible by 4, but not by 100, unless by 400 + var leapyear = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); + + // 31st of a month with 30 days + if (date == 31 && (month == 4 || month == 6 || month == 9 || month == 11)) return false; + + // February 30th or 31st + if (date >= 30 && month == 2) return false; + + // February 29th outside a leap year + if (date == 29 && month == 2 && !leapyear) return false; + if (dayofyear == 366 && !leapyear) return false; + + return true; +} + +/** + Validates US state and territory abbreviations. + + @param value A two character string. + @param flags An object. + flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true. + flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true. + @return true or false +*/ +dojo.validate.us.isState = function(value, flags) { + var re = new RegExp("^" + dojo.regexp.us.state(flags) + "$", "i"); + return re.test(value); +} + +/** + Validates any sort of number based format. + Use it for phone numbers, social security numbers, zip-codes, etc. + The value can be validated against one format or one of multiple formats. + + Format + # Stands for a digit, 0-9. + ? Stands for an optional digit, 0-9 or nothing. + All other characters must appear literally in the expression. + + Example + "(###) ###-####" -> (510) 542-9742 + "(###) ###-#### x#???" -> (510) 542-9742 x153 + "###-##-####" -> 506-82-1089 i.e. social security number + "#####-####" -> 98225-1649 i.e. zip code + + @param value A string. + @param flags An object. + flags.format A string or an Array of strings for multiple formats. + @return true or false +*/ +dojo.validate.isNumberFormat = function(value, flags) { + var re = new RegExp("^" + dojo.regexp.numberFormat(flags) + "$", "i"); + return re.test(value); +} + +/** + Validates 10 US digit phone number for several common formats: + + @param value The telephone number string + @return true or false +*/ +dojo.validate.us.isPhoneNumber = function(value) { + flags = { + format: [ + "###-###-####", + "(###) ###-####", + "(###) ### ####", + "###.###.####", + "###/###-####", + "### ### ####", + "###-###-#### x#???", + "(###) ###-#### x#???", + "(###) ### #### x#???", + "###.###.#### x#???", + "###/###-#### x#???", + "### ### #### x#???" + ] + }; + + return dojo.validate.isNumberFormat(value, flags); +} + +// Validates social security number +dojo.validate.us.isSocialSecurityNumber = function(value) { + flags = { + format: [ + "###-##-####", + "### ## ####", + "#########" + ] + }; + + return dojo.validate.isNumberFormat(value, flags); +} + +// Validates U.S. zip-code +dojo.validate.us.isZipCode = function(value) { + flags = { + format: [ + "#####-####", + "##### ####", + "#########", + "#####" + ] + }; + + return dojo.validate.isNumberFormat(value, flags); +} + + +/** + Procedural API Description + + The main aim is to make input validation expressible in a simple format. + You define profiles which declare the required and optional fields and any constraints they might have. + The results are provided as an object that makes it easy to handle missing and invalid input. + + Usage + + var results = dojo.validate.check(form, profile); + + Profile Object + + var profile = { + // filters change the field value and are applied before validation. + trim: ["tx1", "tx2"], + uppercase: ["tx9"], + lowercase: ["tx5", "tx6", "tx7"], + ucfirst: ["tx10"], + digit: ["tx11"], + + // required input fields that are blank will be reported missing. + // required radio button groups and drop-down lists with no selection will be reported missing. + // checkbox groups and selectboxes can be required to have more than one value selected. + // List required fields by name and use this notation to require more than one value: {checkboxgroup: 2}, {selectboxname: 3}. + required: ["tx7", "tx8", "pw1", "ta1", "rb1", "rb2", "cb3", "s1", {"doubledip":2}, {"tripledip":3}], + + // dependant/conditional fields are required if the target field is present and not blank. + // At present only textbox, password, and textarea fields are supported. + dependancies: { + cc_exp: "cc_no", + cc_type: "cc_no", + }, + + // Fields can be validated using any boolean valued function. + // Use arrays to specify parameters in addition to the field value. + constraints: { + field_name1: myValidationFunction, + field_name2: dojo.validate.isInteger, + field_name3: [myValidationFunction, additional parameters], + field_name4: [dojo.validate.isValidDate, "YYYY.MM.DD"], + field_name5: [dojo.validate.isEmailAddress, false, true], + }, + + // Confirm is a sort of conditional validation. + // It associates each field in its property list with another field whose value should be equal. + // If the values are not equal, the field in the property list is reported as Invalid. Unless the target field is blank. + confirm: { + email_confirm: "email", + pw2: "pw1", + } + }; + + Results Object + + isSuccessful(): Returns true if there were no invalid or missing fields, else it returns false. + hasMissing(): Returns true if the results contain any missing fields. + getMissing(): Returns a list of required fields that have values missing. + isMissing(field): Returns true if the field is required and the value is missing. + hasInvalid(): Returns true if the results contain fields with invalid data. + getInvalid(): Returns a list of fields that have invalid values. + isInvalid(field): Returns true if the field has an invalid value. + +*/ + +/** + Validates user input of an HTML form based on input profile. + + @param form The form object to be validated. + @param profile The input profile that specifies how the form fields are to be validated. + @return results An object that contains several methods summarizing the results of the validation. +*/ +dojo.validate.check = function(form, profile) { + // Essentially private properties of results object + var missing = []; + var invalid = []; + + // results object summarizes the validation + var results = { + isSuccessful: function() {return ( !this.hasInvalid() && !this.hasMissing() );}, + hasMissing: function() {return ( missing.length > 0 );}, + getMissing: function() {return missing;}, + isMissing: function(elemname) { + for (var i = 0; i < missing.length; i++) { + if ( elemname == missing[i] ) { return true; } + } + return false; + }, + hasInvalid: function() {return ( invalid.length > 0 );}, + getInvalid: function() {return invalid;}, + isInvalid: function(elemname) { + for (var i = 0; i < invalid.length; i++) { + if ( elemname == invalid[i] ) { return true; } + } + return false; + } + }; + + // Filters are applied before fields are validated. + // Trim removes white space at the front and end of the fields. + if ( profile.trim instanceof Array ) { + for (var i = 0; i < profile.trim.length; i++) { + var elem = form[profile.trim[i]]; + if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; } + elem.value = elem.value.replace(/(^\s*|\s*$)/g, ""); + } + } + // Convert to uppercase + if ( profile.uppercase instanceof Array ) { + for (var i = 0; i < profile.uppercase.length; i++) { + var elem = form[profile.uppercase[i]]; + if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; } + elem.value = elem.value.toUpperCase(); + } + } + // Convert to lowercase + if ( profile.lowercase instanceof Array ) { + for (var i = 0; i < profile.lowercase.length; i++) { + var elem = form[profile.lowercase[i]]; + if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; } + elem.value = elem.value.toLowerCase(); + } + } + // Uppercase first letter + if ( profile.ucfirst instanceof Array ) { + for (var i = 0; i < profile.ucfirst.length; i++) { + var elem = form[profile.ucfirst[i]]; + if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; } + elem.value = elem.value.replace(/\b\w+\b/g, function(word) { return word.substring(0,1).toUpperCase() + word.substring(1).toLowerCase(); }); + } + } + // Remove non digits characters from the input. + if ( profile.digit instanceof Array ) { + for (var i = 0; i < profile.digit.length; i++) { + var elem = form[profile.digit[i]]; + if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; } + elem.value = elem.value.replace(/\D/g, ""); + } + } + + // See if required input fields have values missing. + if ( profile.required instanceof Array ) { + for (var i = 0; i < profile.required.length; i++) { + if ( typeof profile.required[i] != "string" ) { continue; } + var elem = form[profile.required[i]]; + // Are textbox, textarea, or password fields blank. + if ( (elem.type == "text" || elem.type == "textarea" || elem.type == "password") && /^\s*$/.test(elem.value) ) { + missing[missing.length] = elem.name; + } + // Does drop-down box have option selected. + else if ( (elem.type == "select-one" || elem.type == "select-multiple") && elem.selectedIndex == -1 ) { + missing[missing.length] = elem.name; + } + // Does radio button group (or check box group) have option checked. + else if ( elem instanceof Array ) { + var checked = false; + for (var j = 0; j < elem.length; j++) { + if (elem[j].checked) { checked = true; } + } + if ( !checked ) { + missing[missing.length] = elem[0].name; + } + } + } + } + + // See if checkbox groups and select boxes have x number of required values. + if ( profile.required instanceof Array ) { + for (var i = 0; i < profile.required.length; i++) { + if ( typeof profile.required[i] != "object" ) { continue; } + var elem, numRequired; + for (var name in profile.required[i]) { + elem = form[name]; + numRequired = profile.required[i][name]; + } + // case 1: elem is a check box group + if ( elem instanceof Array ) { + var checked = 0; + for (var j = 0; j < elem.length; j++) { + if (elem[j].checked) { checked++; } + } + if ( checked < numRequired ) { + missing[missing.length] = elem[0].name; + } + } + // case 2: elem is a select box + else if ( elem.type == "select-multiple" ) { + var selected = 0; + for (var j = 0; j < elem.options.length; j++) { + if (elem.options[j].selected) { selected++; } + } + if ( selected < numRequired ) { + missing[missing.length] = elem.name; + } + } + } + } + + // Dependant fields are required when the target field is present (not blank). + // Todo: Support dependant and target fields that are radio button groups, or select drop-down lists. + // Todo: Make the dependancy based on a specific value of the target field. + // Todo: allow dependant fields to have several required values, like {checkboxgroup: 3}. + if ( typeof profile.dependancies == "object" ) { + // properties of dependancies object are the names of dependant fields to be checked + for (name in profile.dependancies) { + var elem = form[name]; // the dependant element + if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; } // limited support + if ( /\S+/.test(elem.value) ) { continue; } // has a value already + if ( results.isMissing(elem.name) ) { continue; } // already listed as missing + var target = form[profile.dependancies[name]]; + if ( target.type != "text" && target.type != "textarea" && target.type != "password" ) { continue; } // limited support + if ( /^\s*$/.test(target.value) ) { continue; } // skip if blank + missing[missing.length] = elem.name; // ok the dependant field is missing + } + } + + // Find invalid input fields. + if ( typeof profile.constraints == "object" ) { + // constraint properties are the names of fields to be validated + for (name in profile.constraints) { + var elem = form[name]; + if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; } + // skip if blank - its optional unless required, in which case it is already listed as missing. + if ( /^\s*$/.test(elem.value) ) { continue; } + + var isValid = true; + // case 1: constraint value is validation function + if ( typeof profile.constraints[name] == "function" ) { + isValid = profile.constraints[name](elem.value); + } + // case 2: constraint value is array, first elem is function, tail is parameters + else if ( profile.constraints[name] instanceof Array ) { + var isValidSomething = profile.constraints[name][0]; + var params = profile.constraints[name].slice(1); + params.unshift(elem.value); + isValid = isValidSomething.apply(null, params); + } + + if ( !isValid ) { + invalid[invalid.length] = elem.name; + } + } + } + + // Find unequal confirm fields and report them as Invalid. + if ( typeof profile.confirm == "object" ) { + for (name in profile.confirm) { + var elem = form[name]; // the confirm element + var target = form[profile.confirm[name]]; + if ( (elem.type != "text" && elem.type != "textarea" && elem.type != "password") + || target.type != elem.type + || target.value == elem.value // it's valid + || results.isInvalid(elem.name) // already listed as invalid + || /^\s*$/.test(target.value) ) // skip if blank - only confirm if target has a value + { + continue; + } + invalid[invalid.length] = elem.name; + } + } + + return results; +} Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/DomWidget.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/DomWidget.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/DomWidget.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/DomWidget.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,18 @@ +dojo.provide("dojo.webui.DomWidget"); +dojo.require("dojo.widget.DomWidget"); + +dj_deprecated("dojo.webui.DomWidget is deprecated, use dojo.widget.DomWidget"); + +dojo.webui.DomWidget = dojo.widget.DomWidget; +dojo.webui._cssFiles = dojo.widget._cssFiles; + +dojo.webui.buildFromTemplate = dojo.widget.buildFromTemplate; + +dojo.webui.attachProperty = dojo.widget.attachProperty; +dojo.webui.eventAttachProperty = dojo.widget.eventAttachProperty; +dojo.webui.subTemplateProperty = dojo.widget.subTemplateProperty; +dojo.webui.onBuildProperty = dojo.widget.onBuildProperty; + +dojo.webui.attachTemplateNodes = dojo.widget.attachTemplateNodes; +dojo.webui.getDojoEventsFromStr = dojo.widget.getDojoEventsFromStr; +dojo.webui.buildAndAttachTemplate = dojo.widget.buildAndAttachTemplate; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/HtmlWidget.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/HtmlWidget.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/HtmlWidget.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/HtmlWidget.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,9 @@ +dojo.provide("dojo.webui.HtmlWidget"); +dojo.provide("dojo.webui.HTMLWidget"); + +dojo.require("dojo.widget.HtmlWidget"); + +dj_deprecated("dojo.webui.HtmlWidget is deprecated, use dojo.widget.HtmlWidget"); + +dojo.webui.HtmlWidget = dojo.widget.HtmlWidget; +dojo.webui.HTMLWidget = dojo.widget.HtmlWidget; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/SvgWidget.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/SvgWidget.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/SvgWidget.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/SvgWidget.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,9 @@ +dojo.provide("dojo.webui.SvgWidget"); +dojo.provide("dojo.webui.SVGWidget"); + +dojo.require("dojo.widget.SvgWidget"); + +dj_deprecated("dojo.webui.SvgWidget is deprecated, use dojo.widget.SvgWidget"); + +dojo.webui.SvgWidget = dojo.widget.SvgWidget; +dojo.webui.SVGWidget = dojo.widget.SvgWidget; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/Widget.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/Widget.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/Widget.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/Widget.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,11 @@ +dojo.provide("dojo.webui.Widget"); +dojo.provide("dojo.webui.widgets.tags"); + +dojo.require("dojo.widget.Widget"); + +dj_deprecated("dojo.webui.Widget is deprecated, use dojo.widget.Widget"); + +dojo.webui.Widget = dojo.widget.Widget; +dojo.webui.widgets.tags = dojo.widget.tags; + +dojo.webui.widgets.buildWidgetFromParseTree = dojo.widget.buildWidgetFromParseTree; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/WidgetManager.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/WidgetManager.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/WidgetManager.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/WidgetManager.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,8 @@ +dojo.provide("dojo.webui.widgetManager"); +dojo.provide("dojo.webui.WidgetManager"); + +dojo.require("dojo.widget.Manager"); + +dj_deprecated("dojo.webui.WidgetManager is deprecated, use dojo.widget.WidgetManager"); + +dojo.webui.widgetManager = dojo.widget.manager; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/__package__.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/__package__.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/__package__.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/__package__.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,11 @@ +dojo.hostenv.conditionalLoadModule({ + common: ["dojo.xml.Parse", + "dojo.webui.Widget", + "dojo.webui.widgets.Parse", + // "dojo.webui.DragAndDrop", + "dojo.webui.WidgetManager"], + browser: ["dojo.webui.DomWidget", + "dojo.webui.HtmlWidget"], + svg: ["dojo.webui.SvgWidget"] +}); +dojo.hostenv.moduleLoaded("dojo.webui.*"); Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Button.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Button.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Button.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/Button.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,7 @@ +dojo.provide("dojo.webui.widgets.Button"); + +dojo.require("dojo.widget.Button"); + +dj_deprecated("dojo.webui.widgets.Button is deprecated, use dojo.widget.Button"); + +dojo.webui.widgets.Button = dojo.widget.Button; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/ComboBox.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/ComboBox.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/ComboBox.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/ComboBox.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,9 @@ +dojo.provide("dojo.webui.widgets.ComboBox"); + +dojo.require("dojo.widget.ComboBox"); + +dj_deprecated("dojo.webui.widgets.ComboBox is deprecated, use dojo.widget.ComboBox"); + +dojo.webui.widgets.ComboBoxDataProvider = dojo.widget.ComboBoxDataProvider; +dojo.webui.widgets.ComboBox = dojo.widget.ComboBox; +dojo.webui.widgets.DomComboBox = dojo.widget.DomComboBox; Added: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/ContextMenu.js URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/ContextMenu.js?rev=354516&view=auto ============================================================================== --- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/ContextMenu.js (added) +++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/dojo/src/webui/widgets/ContextMenu.js Tue Dec 6 11:29:56 2005 @@ -0,0 +1,7 @@ +dojo.provide("dojo.webui.widgets.ContextMenu"); + +dojo.require("dojo.widget.ContextMenu"); + +dj_deprecated("dojo.webui.widgets.ContextMenu is deprecated, use dojo.widget.ContextMenu"); + +dojo.webui.widgets.ContextMenu = dojo.widget.ContextMenu; --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org For additional commands, e-mail: jetspeed-dev-help@portals.apache.org