Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/browser.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/browser.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/browser.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/browser.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,363 @@ +/* + 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.storage.browser"); + +dojo.require("dojo.storage"); +dojo.require("dojo.flash"); +dojo.require("dojo.json"); +dojo.require("dojo.uri.*"); + + + +dojo.storage.browser.WhatWGStorageProvider = function(){ + // summary: + // Storage provider that uses WHAT Working Group features in Firefox 2 + // to achieve permanent storage. + // description: + // The WHAT WG storage API is documented at + // http://www.whatwg.org/specs/web-apps/current-work/#scs-client-side + // + // You can disable this storage provider with the following djConfig + // variable: + // var djConfig = { disableWhatWGStorage: true }; + // + // Authors of this storage provider- + // JB Boisseau, [hidden email] + // Brad Neuberg, [hidden email] +} + +dojo.inherits(dojo.storage.browser.WhatWGStorageProvider, dojo.storage); + +// instance methods and properties +dojo.lang.extend(dojo.storage.browser.WhatWGStorageProvider, { + namespace: "default", + initialized: false, + + _domain: null, + _available: null, + _statusHandler: null, + + initialize: function(){ + if(djConfig["disableWhatWGStorage"] == true){ + return; + } + + // get current domain + this._domain = location.hostname; + + // indicate that this storage provider is now loaded + this.initialized = true; + dojo.storage.manager.loaded(); + }, + + isAvailable: function(){ + try{ + var myStorage = globalStorage[location.hostname]; + }catch(e){ + this._available = false; + return this._available; + } + + this._available = true; + return this._available; + }, + + put: function(key, value, resultsHandler){ + if(this.isValidKey(key) == false){ + dojo.raise("Invalid key given: " + key); + } + + this._statusHandler = resultsHandler; + + // serialize the value; + // handle strings differently so they have better performance + if(dojo.lang.isString(value)){ + value = "string:" + value; + }else{ + value = dojo.json.serialize(value); + } + + // register for successful storage events + window.addEventListener("storage", function(evt){ + // indicate we succeeded + resultsHandler.call(null, dojo.storage.SUCCESS, key); + }, false); + + // try to store the value + try{ + var myStorage = globalStorage[this._domain]; + myStorage.setItem(key,value); + }catch(e){ + // indicate we failed + this._statusHandler.call(null, dojo.storage.FAILED, + key, e.toString()); + } + }, + + get: function(key){ + if(this.isValidKey(key) == false){ + dojo.raise("Invalid key given: " + key); + } + + var myStorage = globalStorage[this._domain]; + + var results = myStorage.getItem(key); + + if(results == null){ + return null; + } + + results = results.value; + + // destringify the content back into a + // real JavaScript object; + // handle strings differently so they have better performance + if(!dojo.lang.isUndefined(results) && results != null + && /^string:/.test(results)){ + results = results.substring("string:".length); + }else{ + results = dojo.json.evalJson(results); + } + + return results; + }, + + getKeys: function(){ + var myStorage = globalStorage[this._domain]; + var keysArray = new Array(); + for(i=0; i<myStorage.length;i++){ + keysArray[i] = myStorage.key(i); + } + + return keysArray; + }, + + clear: function(){ + var myStorage = globalStorage[this._domain]; + var keys = new Array(); + for(var i = 0; i < myStorage.length; i++){ + keys[keys.length] = myStorage.key(i); + } + + for(var i = 0; i < keys.length; i++){ + myStorage.removeItem(keys[i]); + } + }, + + remove: function(key){ + var myStorage = globalStorage[this._domain]; + myStorage.removeItem(key); + }, + + isPermanent: function(){ + return true; + }, + + getMaximumSize: function(){ + return dojo.storage.SIZE_NO_LIMIT; + }, + + hasSettingsUI: function(){ + return false; + }, + + showSettingsUI: function(){ + dojo.raise(this.getType() + " does not support a storage settings user-interface"); + }, + + hideSettingsUI: function(){ + dojo.raise(this.getType() + " does not support a storage settings user-interface"); + }, + + getType: function(){ + return "dojo.storage.browser.WhatWGStorageProvider"; + } +}); + + + + +dojo.storage.browser.FlashStorageProvider = function(){ + // summary: Storage provider that uses features in Flash to achieve permanent storage + // description: + // Authors of this storage provider- + // Brad Neuberg, [hidden email] +} + +dojo.inherits(dojo.storage.browser.FlashStorageProvider, dojo.storage); + +// instance methods and properties +dojo.lang.extend(dojo.storage.browser.FlashStorageProvider, { + namespace: "default", + initialized: false, + _available: null, + _statusHandler: null, + + initialize: function(){ + if(djConfig["disableFlashStorage"] == true){ + return; + } + + // initialize our Flash + var loadedListener = function(){ + dojo.storage._flashLoaded(); + } + dojo.flash.addLoadedListener(loadedListener); + var swfloc6 = dojo.uri.dojoUri("Storage_version6.swf").toString(); + var swfloc8 = dojo.uri.dojoUri("Storage_version8.swf").toString(); + dojo.flash.setSwf({flash6: swfloc6, flash8: swfloc8, visible: false}); + }, + + isAvailable: function(){ + if(djConfig["disableFlashStorage"] == true){ + this._available = false; + }else{ + this._available = true; + } + + return this._available; + }, + + put: function(key, value, resultsHandler){ + if(this.isValidKey(key) == false){ + dojo.raise("Invalid key given: " + key); + } + + this._statusHandler = resultsHandler; + + // serialize the value; + // handle strings differently so they have better performance + if(dojo.lang.isString(value)){ + value = "string:" + value; + }else{ + value = dojo.json.serialize(value); + } + + dojo.flash.comm.put(key, value, this.namespace); + }, + + get: function(key){ + if(this.isValidKey(key) == false){ + dojo.raise("Invalid key given: " + key); + } + + var results = dojo.flash.comm.get(key, this.namespace); + + if(results == ""){ + return null; + } + + // destringify the content back into a + // real JavaScript object; + // handle strings differently so they have better performance + if(!dojo.lang.isUndefined(results) && results != null + && /^string:/.test(results)){ + results = results.substring("string:".length); + }else{ + results = dojo.json.evalJson(results); + } + + return results; + }, + + getKeys: function(){ + var results = dojo.flash.comm.getKeys(this.namespace); + + if(results == ""){ + return []; + } + + // the results are returned comma seperated; split them + return results.split(","); + }, + + clear: function(){ + dojo.flash.comm.clear(this.namespace); + }, + + remove: function(key){ + // summary: + // Note- This one method is not implemented on the + // FlashStorageProvider yet + + dojo.unimplemented("dojo.storage.browser.FlashStorageProvider.remove"); + }, + + isPermanent: function(){ + return true; + }, + + getMaximumSize: function(){ + return dojo.storage.SIZE_NO_LIMIT; + }, + + hasSettingsUI: function(){ + return true; + }, + + showSettingsUI: function(){ + dojo.flash.comm.showSettings(); + dojo.flash.obj.setVisible(true); + dojo.flash.obj.center(); + }, + + hideSettingsUI: function(){ + // hide the dialog + dojo.flash.obj.setVisible(false); + + // call anyone who wants to know the dialog is + // now hidden + if(dojo.storage.onHideSettingsUI != null && + !dojo.lang.isUndefined(dojo.storage.onHideSettingsUI)){ + dojo.storage.onHideSettingsUI.call(null); + } + }, + + getType: function(){ + return "dojo.storage.browser.FlashStorageProvider"; + }, + + /** Called when the Flash is finished loading. */ + _flashLoaded: function(){ + this._initialized = true; + + // indicate that this storage provider is now loaded + dojo.storage.manager.loaded(); + }, + + // Called if the storage system needs to tell us about the status + // of a put() request. + _onStatus: function(statusResult, key){ + var ds = dojo.storage; + var dfo = dojo.flash.obj; + + if(statusResult == ds.PENDING){ + dfo.center(); + dfo.setVisible(true); + }else{ + dfo.setVisible(false); + } + + if((!dj_undef("_statusHandler", ds))&&(ds._statusHandler != null)){ + ds._statusHandler.call(null, statusResult, key); + } + } +}); + +// register the existence of our storage providers +dojo.storage.manager.register("dojo.storage.browser.WhatWGStorageProvider", + new dojo.storage.browser.WhatWGStorageProvider()); +dojo.storage.manager.register("dojo.storage.browser.FlashStorageProvider", + new dojo.storage.browser.FlashStorageProvider()); + +// now that we are loaded and registered tell the storage manager to initialize +// itself +dojo.storage.manager.initialize(); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/browser.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/browser.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/browser.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/storage_dialog.fla URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/storage_dialog.fla?view=auto&rev=509273 ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/storage/storage_dialog.fla ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/string.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/string.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/string.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/string.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,12 @@ +/* + 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.string"); +dojo.require("dojo.string.common"); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/Builder.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/string/Builder.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/string/Builder.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/string/Builder.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,128 @@ +/* + 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.string.Builder"); +dojo.require("dojo.string"); +dojo.require("dojo.lang.common"); + +// NOTE: testing shows that direct "+=" concatenation is *much* faster on +// Spidermoneky and Rhino, while arr.push()/arr.join() style concatenation is +// significantly quicker on IE (Jscript/wsh/etc.). + +dojo.string.Builder = function(/* string? */str){ + // summary + this.arrConcat = (dojo.render.html.capable && dojo.render.html["ie"]); + + var a = []; + var b = ""; + var length = this.length = b.length; + + if(this.arrConcat){ + if(b.length > 0){ + a.push(b); + } + b = ""; + } + + this.toString = this.valueOf = function(){ + // summary + // Concatenate internal buffer and return as a string + return (this.arrConcat) ? a.join("") : b; // string + }; + + this.append = function(){ + // summary + // Append all arguments to the end of the internal buffer + for(var x=0; x<arguments.length; x++){ + var s = arguments[x]; + if(dojo.lang.isArrayLike(s)){ + this.append.apply(this, s); + } else { + if(this.arrConcat){ + a.push(s); + }else{ + b+=s; + } + length += s.length; + this.length = length; + } + } + return this; // dojo.string.Builder + }; + + this.clear = function(){ + // summary + // Clear the internal buffer. + a = []; + b = ""; + length = this.length = 0; + return this; // dojo.string.Builder + }; + + this.remove = function(/* integer */f, /* integer */l){ + // summary + // Remove a section of string from the internal buffer. + var s = ""; + if(this.arrConcat){ + b = a.join(""); + } + a=[]; + if(f>0){ + s = b.substring(0, (f-1)); + } + b = s + b.substring(f + l); + length = this.length = b.length; + if(this.arrConcat){ + a.push(b); + b=""; + } + return this; // dojo.string.Builder + }; + + this.replace = function(/* string */o, /* string */n){ + // summary + // replace phrase *o* with phrase *n*. + if(this.arrConcat){ + b = a.join(""); + } + a = []; + b = b.replace(o,n); + length = this.length = b.length; + if(this.arrConcat){ + a.push(b); + b=""; + } + return this; // dojo.string.Builder + }; + + this.insert = function(/* integer */idx, /* string */s){ + // summary + // Insert string s at index idx. + if(this.arrConcat){ + 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; + if(this.arrConcat){ + a.push(b); + b=""; + } + return this; // dojo.string.Builder + }; + + this.append.apply(this, arguments); +}; Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/Builder.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/Builder.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/Builder.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/__package__.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/string/__package__.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/string/__package__.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/string/__package__.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,19 @@ +/* + 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.string", + "dojo.string.common", + "dojo.string.extras", + "dojo.string.Builder" + ] +}); +dojo.provide("dojo.string.*"); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/__package__.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/__package__.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/__package__.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/common.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/string/common.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/string/common.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/string/common.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,78 @@ +/* + 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.string.common"); + +dojo.string.trim = function(/* string */str, /* integer? */wh){ + // summary + // Trim whitespace from str. If wh > 0, trim from start, if wh < 0, trim from end, else both + if(!str.replace){ return str; } + if(!str.length){ return str; } + var re = (wh > 0) ? (/^\s+/) : (wh < 0) ? (/\s+$/) : (/^\s+|\s+$/g); + return str.replace(re, ""); // string +} + +dojo.string.trimStart = function(/* string */str) { + // summary + // Trim whitespace at the beginning of 'str' + return dojo.string.trim(str, 1); // string +} + +dojo.string.trimEnd = function(/* string */str) { + // summary + // Trim whitespace at the end of 'str' + return dojo.string.trim(str, -1); +} + +dojo.string.repeat = function(/* string */str, /* integer */count, /* string? */separator) { + // summary + // Return 'str' repeated 'count' times, optionally placing 'separator' between each rep + var out = ""; + for(var i = 0; i < count; i++) { + out += str; + if(separator && i < count - 1) { + out += separator; + } + } + return out; // string +} + +dojo.string.pad = function(/* string */str, /* integer */len/*=2*/, /* string */ c/*='0'*/, /* integer */dir/*=1*/) { + // summary + // 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 + 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; // string +} + +dojo.string.padLeft = function(/* string */str, /* integer */len, /* string */c) { + // summary + // same as dojo.string.pad(str, len, c, 1) + return dojo.string.pad(str, len, c, 1); // string +} + +dojo.string.padRight = function(/* string */str, /* integer */len, /* string */c) { + // summary + // same as dojo.string.pad(str, len, c, -1) + return dojo.string.pad(str, len, c, -1); // string +} Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/common.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/common.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/common.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/extras.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/string/extras.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/string/extras.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/string/extras.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,261 @@ +/* + 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.string.extras"); + +dojo.require("dojo.string.common"); +dojo.require("dojo.lang.common"); +dojo.require("dojo.lang.array"); + +//TODO: should we use ${} substitution syntax instead, like widgets do? +dojo.string.substituteParams = function(/*string*/template, /* object - optional or ... */hash){ +// summary: +// Performs parameterized substitutions on a string. Throws an exception if any parameter is unmatched. +// +// description: +// For example, +// dojo.string.substituteParams("File '%{0}' is not found in directory '%{1}'.","foo.html","/temp"); +// returns +// "File 'foo.html' is not found in directory '/temp'." +// +// template: the original string template with %{values} to be replaced +// hash: name/value pairs (type object) to provide substitutions. Alternatively, substitutions may be +// included as arguments 1..n to this function, corresponding to template parameters 0..n-1 + + var map = (typeof hash == 'object') ? hash : dojo.lang.toArray(arguments, 1); + + return template.replace(/\%\{(\w+)\}/g, function(match, key){ + if(typeof(map[key]) != "undefined" && map[key] != null){ + return map[key]; + } + dojo.raise("Substitution not found: " + key); + }); // string +}; + +dojo.string.capitalize = function(/*string*/str){ +// summary: +// Uppercases the first letter of each word + + if(!dojo.lang.isString(str)){ return ""; } + if(arguments.length == 0){ str = this; } + + var words = str.split(' '); + for(var i=0; i<words.length; i++){ + words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1); + } + return words.join(" "); // string +} + +dojo.string.isBlank = function(/*string*/str){ +// summary: +// Return true if the entire string is whitespace characters + + if(!dojo.lang.isString(str)){ return true; } + return (dojo.string.trim(str).length == 0); // boolean +} + +//FIXME: not sure exactly what encodeAscii is trying to do, or if it's working right +dojo.string.encodeAscii = function(/*string*/str){ + if(!dojo.lang.isString(str)){ return str; } // unknown + var ret = ""; + var value = escape(str); + var match, re = /%u([0-9A-F]{4})/i; + while((match = value.match(re))){ + var num = Number("0x"+match[1]); + var newVal = escape("&#" + num + ";"); + ret += value.substring(0, match.index) + newVal; + value = value.substring(match.index+match[0].length); + } + ret += value.replace(/\+/g, "%2B"); + return ret; // string +} + +dojo.string.escape = function(/*string*/type, /*string*/str){ +// summary: +// Adds escape sequences for special characters according to the convention of 'type' +// +// type: one of xml|html|xhtml|sql|regexp|regex|javascript|jscript|js|ascii +// str: the string to be escaped + + var args = dojo.lang.toArray(arguments, 1); + switch(type.toLowerCase()){ + case "xml": + case "html": + case "xhtml": + return dojo.string.escapeXml.apply(this, args); // string + case "sql": + return dojo.string.escapeSql.apply(this, args); // string + case "regexp": + case "regex": + return dojo.string.escapeRegExp.apply(this, args); // string + case "javascript": + case "jscript": + case "js": + return dojo.string.escapeJavaScript.apply(this, args); // string + case "ascii": + // so it's encode, but it seems useful + return dojo.string.encodeAscii.apply(this, args); // string + default: + return str; // string + } +} + +dojo.string.escapeXml = function(/*string*/str, /*boolean*/noSingleQuotes){ +//summary: +// Adds escape sequences for special characters in XML: &<>"' +// Optionally skips escapes for single quotes + + str = str.replace(/&/gm, "&").replace(/</gm, "<") + .replace(/>/gm, ">").replace(/"/gm, """); + if(!noSingleQuotes){ str = str.replace(/'/gm, "'"); } + return str; // string +} + +dojo.string.escapeSql = function(/*string*/str){ +//summary: +// Adds escape sequences for single quotes in SQL expressions + + return str.replace(/'/gm, "''"); //string +} + +dojo.string.escapeRegExp = function(/*string*/str){ +//summary: +// Adds escape sequences for special characters in regular expressions + + return str.replace(/\\/gm, "\\\\").replace(/([\f\b\n\t\r[\^$|?*+(){}])/gm, "\\$1"); // string +} + +//FIXME: should this one also escape backslash? +dojo.string.escapeJavaScript = function(/*string*/str){ +//summary: +// Adds escape sequences for single and double quotes as well +// as non-visible characters in JavaScript string literal expressions + + return str.replace(/(["'\f\b\n\t\r])/gm, "\\$1"); // string +} + +//FIXME: looks a lot like escapeJavaScript, just adds quotes? deprecate one? +dojo.string.escapeString = function(/*string*/str){ +//summary: +// Adds escape sequences for non-visual characters, double quote and backslash +// and surrounds with double quotes to form a valid string literal. + return ('"' + str.replace(/(["\\])/g, '\\$1') + '"' + ).replace(/[\f]/g, "\\f" + ).replace(/[\b]/g, "\\b" + ).replace(/[\n]/g, "\\n" + ).replace(/[\t]/g, "\\t" + ).replace(/[\r]/g, "\\r"); // string +} + +// TODO: make an HTML version +dojo.string.summary = function(/*string*/str, /*number*/len){ +// summary: +// Truncates 'str' after 'len' characters and appends periods as necessary so that it ends with "..." + + if(!len || str.length <= len){ + return str; // string + } + + return str.substring(0, len).replace(/\.+$/, "") + "..."; // string +} + +dojo.string.endsWith = function(/*string*/str, /*string*/end, /*boolean*/ignoreCase){ +// summary: +// Returns true if 'str' ends with 'end' + + if(ignoreCase){ + str = str.toLowerCase(); + end = end.toLowerCase(); + } + if((str.length - end.length) < 0){ + return false; // boolean + } + return str.lastIndexOf(end) == str.length - end.length; // boolean +} + +dojo.string.endsWithAny = function(/*string*/str /* , ... */){ +// summary: +// Returns true if 'str' ends with any of the arguments[2 -> n] + + for(var i = 1; i < arguments.length; i++) { + if(dojo.string.endsWith(str, arguments[i])) { + return true; // boolean + } + } + return false; // boolean +} + +dojo.string.startsWith = function(/*string*/str, /*string*/start, /*boolean*/ignoreCase){ +// summary: +// Returns true if 'str' starts with 'start' + + if(ignoreCase) { + str = str.toLowerCase(); + start = start.toLowerCase(); + } + return str.indexOf(start) == 0; // boolean +} + +dojo.string.startsWithAny = function(/*string*/str /* , ... */){ +// summary: +// Returns true if 'str' starts with any of the arguments[2 -> n] + + for(var i = 1; i < arguments.length; i++) { + if(dojo.string.startsWith(str, arguments[i])) { + return true; // boolean + } + } + return false; // boolean +} + +dojo.string.has = function(/*string*/str /* , ... */) { +// summary: +// Returns true if 'str' contains any of the arguments 2 -> n + + for(var i = 1; i < arguments.length; i++) { + if(str.indexOf(arguments[i]) > -1){ + return true; // boolean + } + } + return false; // boolean +} + +dojo.string.normalizeNewlines = function(/*string*/text, /*string? (\n or \r)*/newlineChar){ +// summary: +// Changes occurences of CR and LF in text to CRLF, or if newlineChar is provided as '\n' or '\r', +// substitutes newlineChar for occurrences of CR/LF and CRLF + + if (newlineChar == "\n"){ + text = text.replace(/\r\n/g, "\n"); + text = text.replace(/\r/g, "\n"); + } else if (newlineChar == "\r"){ + text = text.replace(/\r\n/g, "\r"); + text = text.replace(/\n/g, "\r"); + }else{ + text = text.replace(/([^\r])\n/g, "$1\r\n").replace(/\r([^\n])/g, "\r\n$1"); + } + return text; // string +} + +dojo.string.splitEscaped = function(/*string*/str, /*string of length=1*/charac){ +// summary: +// Splits 'str' into an array separated by 'charac', but skips characters escaped with a backslash + + var components = []; + for (var i = 0, prevcomma = 0; i < str.length; i++){ + if (str.charAt(i) == '\\'){ i++; continue; } + if (str.charAt(i) == charac){ + components.push(str.substring(prevcomma, i)); + prevcomma = i + 1; + } + } + components.push(str.substr(prevcomma)); + return components; // array +} Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/extras.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/extras.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/string/extras.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/style.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/style.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/style.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/style.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,17 @@ +/* + 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.style"); +dojo.require("dojo.lang.common"); +dojo.kwCompoundRequire({ + browser: ["dojo.html.style"] +}); +dojo.deprecated("dojo.style", "replaced by dojo.html.style", "0.5"); +dojo.lang.mixin(dojo.style, dojo.html); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/style.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/style.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/style.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/svg.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/svg.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/svg.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/svg.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,320 @@ +/* + 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.svg"); +dojo.require("dojo.lang.common"); +dojo.require("dojo.dom"); + +dojo.mixin(dojo.svg, dojo.dom); + +dojo.svg.graphics=dojo.svg.g=new function(/* DOMDocument */ d){ + // summary + // Singleton to encapsulate SVG rendering functions. + this.suspend=function(){ + // summary + // Suspend the rendering engine + try { d.documentElement.suspendRedraw(0); } catch(e){ } + }; + this.resume=function(){ + // summary + // Resume the rendering engine + try { d.documentElement.unsuspendRedraw(0); } catch(e){ } + }; + this.force=function(){ + // summary + // Force the render engine to redraw + try { d.documentElement.forceRedraw(); } catch(e){ } + }; +}(document); + +dojo.svg.animations=dojo.svg.anim=new function(/* DOMDocument */ d){ + // summary + // Singleton to encapsulate SVG animation functionality. + this.arePaused=function(){ + // summary + // check to see if all animations are paused + try { + return d.documentElement.animationsPaused(); // bool + } catch(e){ + return false; // bool + } + } ; + this.pause=function(){ + // summary + // pause all animations + try { d.documentElement.pauseAnimations(); } catch(e){ } + }; + this.resume=function(){ + // summary + // resume all animations + try { d.documentElement.unpauseAnimations(); } catch(e){ } + }; +}(document); + +// fixme: these functions should be mixed in from dojo.style, but dojo.style is HTML-centric and needs to change. +dojo.svg.toCamelCase=function(/* string */ selector){ + // summary + // converts a CSS-style selector to a camelCased one + 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; // string +}; +dojo.svg.toSelectorCase=function(/* string */ selector) { + // summary + // converts a camelCased selector to a CSS style one + return selector.replace(/([A-Z])/g, "-$1" ).toLowerCase(); // string +}; +dojo.svg.getStyle=function(/* SVGElement */ node, /* string */ cssSelector){ + // summary + // get the computed style of selector for node. + return document.defaultView.getComputedStyle(node, cssSelector); // object +}; +dojo.svg.getNumericStyle=function(/* SVGElement */ node, /* string */ cssSelector){ + // summary + // return the numeric version of the computed style of selector on node. + return parseFloat(dojo.svg.getStyle(node, cssSelector)); +}; + +// fixme: there are different ways of doing the following, need to take into account +dojo.svg.getOpacity=function(/* SVGElement */node){ + // summary + // Return the opacity of the passed element + return Math.min(1.0, dojo.svg.getNumericStyle(node, "fill-opacity")); // float +}; +dojo.svg.setOpacity=function(/* SVGElement */ node, /* float */ opacity){ + // summary + // set the opacity of node using attributes. + node.setAttributeNS(this.xmlns.svg, "fill-opacity", opacity); + node.setAttributeNS(this.xmlns.svg, "stroke-opacity", opacity); +}; +dojo.svg.clearOpacity=function(/* SVGElement */ node){ + // summary + // Set any attributes setting opacity to opaque (1.0) + node.setAttributeNS(this.xmlns.svg, "fill-opacity", "1.0"); + node.setAttributeNS(this.xmlns.svg, "stroke-opacity", "1.0"); +}; + +/** + * Coordinates and dimensions. + */ + +// TODO ////////////////////////////////////////////////////////// TODO +dojo.svg.getCoords=function(/* SVGElement */ node){ + // summary + // Returns the x/y coordinates of the passed node, if available. + if (node.getBBox) { + var box=node.getBBox(); + return { x: box.x, y: box.y }; // object + } + return null; // object +}; +dojo.svg.setCoords=function(/* SVGElement */node, /* object */coords){ + // summary + // Set the x/y coordinates of the passed node + 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(/* SVGElement */node){ + // summary + // Get the height and width of the passed node. + if (node.getBBox){ + var box=node.getBBox(); + return { width: box.width, height : box.height }; // object + } + return null; // object +}; +dojo.svg.setDimensions=function(/* SVGElement */node, /* object */dim){ + // summary + // Set the dimensions of the passed element if possible. + // 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.value=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(/* SVGElement */node, /* int */dx, /* int */dy){ + // summary + // Translates the passed node by dx and 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(/* SVGElement */node, /* float */scaleX, /* float? */scaleY){ + // summary + // Scales the passed element by factor scaleX and scaleY. If scaleY not passed, scaleX is used. + 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(/* SVGElement */node, /* float */ang, /* int? */cx, /* int? */cy){ + // summary + // rotate the passed node by ang, with optional cx/cy as the rotation point. + if (node.transform && node.ownerSVGElement && node.ownerSVGElement.createSVGTransform){ + var t=node.ownerSVGElement.createSVGTransform(); + if (cx == null) t.setMatrix(t.matrix.rotate(ang)); + else t.setRotate(ang, cx, cy); + node.transform.baseVal.appendItem(t); + } +}; +dojo.svg.skew=function(/* SVGElement */node, /* float */ang, /* string? */axis){ + // summary + // skew the passed node by ang over 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(/* SVGElement */node, /* string? */axis){ + // summary + // flip the passed element over 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(/* SVGElement */node){ + // summary + // transform the passed node by the inverse of the current matrix + 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( + /* SVGElement */node, + /* int || SVGMatrix */a, + /* int? */b, + /* int? */c, + /* int? */d, + /* int? */e, + /* int? */f +){ + // summary + // apply the passed matrix to node. If params b - f are passed, a matrix will be created. + 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(/* Nodelist || array */nodes){ + // summary + // 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(/* SVGGElement */g){ + // summary + // 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(/* SVGElement */node){ + // summary + // 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(/* SVGElement */node){ + // summary + // move the passed node the to top of the group (i.e. last child) + var n=this.getGroup(node) || node; + n.ownerSVGElement.appendChild(n); +}; +dojo.svg.sendToBack=function(/* SVGElement */node){ + // summary + // move the passed node to the bottom of the group (i.e. first child) + 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(/* SVGElement */node){ + // summary + // move the passed node up one in the child node chain + var n=this.getGroup(node) || node; + if (this.getLastChildElement(n.parentNode) != n){ + this.insertAfter(n, this.getNextSiblingElement(n), true); + } +}; +dojo.svg.sendBackward=function(/* SVGElement */node){ + // summary + // move the passed node down one in the child node chain + var n=this.getGroup(node) || node; + if (this.getFirstChildElement(n.parentNode) != n){ + this.insertBefore(n, this.getPreviousSiblingElement(n), true); + } +}; +// END TODO ////////////////////////////////////////////////////// TODO + +dojo.svg.createNodesFromText=function(/* string */ txt, /* bool? */ wrap){ + // summary + // Create a list of nodes from text + var docFrag=(new DOMParser()).parseFromString(txt, "text/xml").normalize(); + if(wrap){ + return [docFrag.firstChild.cloneNode(true)]; // array + } + var nodes=[]; + for(var x=0; x<docFrag.childNodes.length; x++){ + nodes.push(docFrag.childNodes.item(x).cloneNode(true)); + } + return nodes; // array +} +// vim:ts=4:noet:tw=0: Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/svg.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/svg.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/svg.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/text/__package__.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/text/__package__.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/text/__package__.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/text/__package__.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,18 @@ +/* + 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.text.String", + "dojo.text.Builder" + ] +}); + +dojo.deprecated("dojo.text", "textDirectory moved to cal, text.String and text.Builder havne't been here for awhile", "0.5"); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/text/__package__.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/text/__package__.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/text/__package__.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/text/textDirectory.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/text/textDirectory.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/text/textDirectory.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/text/textDirectory.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,12 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.require("dojo.cal.textDirectory"); +dojo.deprecate("dojo.text.textDirectory", "use dojo.cal.textDirectory", "0.5"); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/text/textDirectory.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/text/textDirectory.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/text/textDirectory.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/Manager.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/Manager.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/Manager.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/Manager.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,254 @@ +/* + 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.undo.Manager"); +dojo.require("dojo.lang.common"); + +dojo.undo.Manager = function(/*dojo.undo.Manager Object */parent) { + //summary: Constructor for a dojo.undo.Manager object. + this.clear(); + this._parent = parent; +}; +dojo.extend(dojo.undo.Manager, { + _parent: null, + _undoStack: null, + _redoStack: null, + _currentManager: null, + + canUndo: false, + canRedo: false, + + isUndoing: false, + isRedoing: false, + + onUndo: function(/*Object*/manager, /*Object*/item) { + //summary: An event that fires when undo is called. + //It allows you to hook in and update your code (UI?) as necessary. + + //manager: Object: the dojo.undo.Manager instance. + //item: Object: The object stored by the undo stack. It has the following properties: + // undo: Function: the undo function for this item in the stack. + // redo: Function: the redo function for this item in the stack. May be null. + // description: String: description of this item. May be null. + }, + onRedo: function(/*Object*/manager, /*Object*/item) { + //summary: An event that fires when redo is called. + //It allows you to hook in and update your code (UI?) as necessary. + + //manager: Object: the dojo.undo.Manager instance. + //item: Object: The object stored by the redo stack. It has the following properties: + // undo: Function: the undo function for this item in the stack. + // redo: Function: the redo function for this item in the stack. May be null. + // description: String: description of this item. May be null. + }, + + onUndoAny: function(/*Object*/manager, /*Object*/item) { + //summary: An event that fires when *any* undo action is done, + //which means you'll have one for every item + //in a transaction. This is usually only useful for debugging. + //See notes for onUndo for info on the function parameters. + }, + + onRedoAny: function(/*Object*/manager, /*Object*/item) { + //summary: An event that fires when *any* redo action is done, + //which means you'll have one for every item + //in a transaction. This is usually only useful for debugging. + //See notes for onRedo for info on the function parameters. + }, + + _updateStatus: function() { + //summary: Private method used to set some internal state. + this.canUndo = this._undoStack.length > 0; + this.canRedo = this._redoStack.length > 0; + }, + + clear: function() { + //summary: Clears this instance of dojo.undo.Manager. + this._undoStack = []; + this._redoStack = []; + this._currentManager = this; + + this.isUndoing = false; + this.isRedoing = false; + + this._updateStatus(); + }, + + undo: function() { + //summary: Call this method to go one place back in the undo + //stack. Returns true if the manager successfully completed + //the undo step. + if(!this.canUndo) { return false; /*boolean*/} + + this.endAllTransactions(); + + this.isUndoing = true; + var top = this._undoStack.pop(); + if(top instanceof dojo.undo.Manager){ + top.undoAll(); + }else{ + top.undo(); + } + if(top.redo){ + this._redoStack.push(top); + } + this.isUndoing = false; + + this._updateStatus(); + this.onUndo(this, top); + if(!(top instanceof dojo.undo.Manager)) { + this.getTop().onUndoAny(this, top); + } + return true; //boolean + }, + + redo: function() { + //summary: Call this method to go one place forward in the redo + //stack. Returns true if the manager successfully completed + //the redo step. + if(!this.canRedo){ return false; /*boolean*/} + + this.isRedoing = true; + var top = this._redoStack.pop(); + if(top instanceof dojo.undo.Manager) { + top.redoAll(); + }else{ + top.redo(); + } + this._undoStack.push(top); + this.isRedoing = false; + + this._updateStatus(); + this.onRedo(this, top); + if(!(top instanceof dojo.undo.Manager)){ + this.getTop().onRedoAny(this, top); + } + return true; //boolean + }, + + undoAll: function() { + //summary: Call undo as many times as it takes to get all the + //way through the undo stack. + while(this._undoStack.length > 0) { + this.undo(); + } + }, + + redoAll: function() { + //summary: Call redo as many times as it takes to get all the + //way through the redo stack. + while(this._redoStack.length > 0) { + this.redo(); + } + }, + + push: function(/*Function*/undo, /*Function?*/redo, /*String?*/description) { + //summary: add something to the undo manager. + if(!undo) { return; } + + if(this._currentManager == this) { + this._undoStack.push({ + undo: undo, + redo: redo, + description: description + }); + } else { + this._currentManager.push.apply(this._currentManager, arguments); + } + // adding a new undo-able item clears out the redo stack + this._redoStack = []; + this._updateStatus(); + }, + + concat: function(/*Object*/manager) { + //summary: Adds all undo and redo stack items to another dojo.undo.Manager + //instance. + if ( !manager ) { return; } + + if (this._currentManager == this ) { + for(var x=0; x < manager._undoStack.length; x++) { + this._undoStack.push(manager._undoStack[x]); + } + // adding a new undo-able item clears out the redo stack + if (manager._undoStack.length > 0) { + this._redoStack = []; + } + this._updateStatus(); + } else { + this._currentManager.concat.apply(this._currentManager, arguments); + } + }, + + beginTransaction: function(/*String?*/description) { + //summary: All undo/redo items added via + //push() after this call is made but before endTransaction() is called are + //treated as one item in the undo and redo stacks. When undo() or redo() is + //called then undo/redo is called on all of the items in the transaction. + //Transactions can be nested. + if(this._currentManager == this) { + var mgr = new dojo.undo.Manager(this); + mgr.description = description ? description : ""; + this._undoStack.push(mgr); + this._currentManager = mgr; + return mgr; + } else { + //for nested transactions need to make sure the top level _currentManager is set + this._currentManager = this._currentManager.beginTransaction.apply(this._currentManager, arguments); + } + }, + + endTransaction: function(flatten /* optional */) { + //summary: Ends a transaction started by beginTransaction(). See beginTransaction() + //for details. + + //flatten: boolean: If true, adds the current transaction to the parent's + //undo stack. + + if(this._currentManager == this) { + if(this._parent) { + this._parent._currentManager = this._parent; + // don't leave empty transactions hangin' around + if(this._undoStack.length == 0 || flatten) { + var idx = dojo.lang.find(this._parent._undoStack, this); + if (idx >= 0) { + this._parent._undoStack.splice(idx, 1); + //add the current transaction to parents undo stack + if (flatten) { + for(var x=0; x < this._undoStack.length; x++){ + this._parent._undoStack.splice(idx++, 0, this._undoStack[x]); + } + this._updateStatus(); + } + } + } + return this._parent; + } + } else { + //for nested transactions need to make sure the top level _currentManager is set + this._currentManager = this._currentManager.endTransaction.apply(this._currentManager, arguments); + } + }, + + endAllTransactions: function() { + //summary: Ends all nested transactions. + while(this._currentManager != this) { + this.endTransaction(); + } + }, + + getTop: function() { + //summary: Finds the top parent of an undo manager. + if(this._parent) { + return this._parent.getTop(); + } else { + return this; + } + } +}); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/Manager.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/Manager.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/Manager.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/__package__.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/__package__.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/__package__.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/__package__.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,12 @@ +/* + Copyright (c) 2004-2006, The Dojo Foundation + All Rights Reserved. + + Licensed under the Academic Free License version 2.1 or above OR the + modified BSD license. For more information on Dojo licensing, see: + + http://dojotoolkit.org/community/licensing.shtml +*/ + +dojo.require("dojo.undo.Manager"); +dojo.provide("dojo.undo.*"); Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/__package__.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/__package__.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/__package__.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/browser.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/browser.js?view=auto&rev=509273 ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/browser.js (added) +++ ofbiz/trunk/framework/images/webapp/images/dojo/src/undo/browser.js Mon Feb 19 09:56:06 2007 @@ -0,0 +1,322 @@ +/* + 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.undo.browser"); +dojo.require("dojo.io.common"); + +try{ + if((!djConfig["preventBackButtonFix"])&&(!dojo.hostenv.post_load_)){ + document.write("<iframe style='border: 0px; width: 1px; height: 1px; position: absolute; bottom: 0px; right: 0px; visibility: visible;' name='djhistory' id='djhistory' src='"+(dojo.hostenv.getBaseScriptUri()+'iframe_history.html')+"'></iframe>"); + } +}catch(e){/* squelch */} + +if(dojo.render.html.opera){ + dojo.debug("Opera is not supported with dojo.undo.browser, so back/forward detection will not work."); +} + +dojo.undo.browser = { + initialHref: (!dj_undef("window")) ? window.location.href : "", + initialHash: (!dj_undef("window")) ? window.location.hash : "", + + moveForward: false, + historyStack: [], + forwardStack: [], + historyIframe: null, + bookmarkAnchor: null, + locationTimer: null, + + /** + * + */ + setInitialState: function(/*Object*/args){ + //summary: Sets the state object and back callback for the very first page that is loaded. + //description: It is recommended that you call this method as part of an event listener that is registered via + //dojo.addOnLoad(). + //args: Object + // See the addToHistory() function for the list of valid args properties. + this.initialState = this._createState(this.initialHref, args, this.initialHash); + }, + + //FIXME: Would like to support arbitrary back/forward jumps. Have to rework iframeLoaded among other things. + //FIXME: is there a slight race condition in moz using change URL with the timer check and when + // the hash gets set? I think I have seen a back/forward call in quick succession, but not consistent. + addToHistory: function(args){ + //summary: adds a state object (args) to the history list. You must set + //djConfig.preventBackButtonFix = false to use dojo.undo.browser. + + //args: Object + // args can have the following properties: + // To support getting back button notifications, the object argument should implement a + // function called either "back", "backButton", or "handle". The string "back" will be + // passed as the first and only argument to this callback. + // - To support getting forward button notifications, the object argument should implement a + // function called either "forward", "forwardButton", or "handle". The string "forward" will be + // passed as the first and only argument to this callback. + // - If you want the browser location string to change, define "changeUrl" on the object. If the + // value of "changeUrl" is true, then a unique number will be appended to the URL as a fragment + // identifier (http://some.domain.com/path#uniquenumber). If it is any other value that does + // not evaluate to false, that value will be used as the fragment identifier. For example, + // if changeUrl: 'page1', then the URL will look like: http://some.domain.com/path#page1 + // Full example: + // dojo.undo.browser.addToHistory({ + // back: function() { alert('back pressed'); }, + // forward: function() { alert('forward pressed'); }, + // changeUrl: true + // }); + // + // BROWSER NOTES: + // Safari 1.2: + // back button "works" fine, however it's not possible to actually + // DETECT that you've moved backwards by inspecting window.location. + // Unless there is some other means of locating. + // FIXME: perhaps we can poll on history.length? + // Safari 2.0.3+ (and probably 1.3.2+): + // works fine, except when changeUrl is used. When changeUrl is used, + // Safari jumps all the way back to whatever page was shown before + // the page that uses dojo.undo.browser support. + // IE 5.5 SP2: + // back button behavior is macro. It does not move back to the + // previous hash value, but to the last full page load. This suggests + // that the iframe is the correct way to capture the back button in + // these cases. + // Don't test this page using local disk for MSIE. MSIE will not create + // a history list for iframe_history.html if served from a file: URL. + // The XML served back from the XHR tests will also not be prop |
Free forum by Nabble | Edit this page |