diff options
Diffstat (limited to 'webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang')
9 files changed, 1470 insertions, 0 deletions
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Array.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Array.js new file mode 100644 index 0000000000..57f124e884 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Array.js @@ -0,0 +1,158 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(core) + +************************************************************************ */ + +qx.OO.defineClass("qx.lang.Array"); + +qx.lang.Array.fromArguments = function(args) { + return Array.prototype.slice.call(args, 0); +} + +/*! + Utility function for padding/margin and all other shorthand handling. +*/ +qx.lang.Array.fromShortHand = function(params) +{ + var l = params.length; + + if (l > 4) { + throw new Error("Invalid number of arguments!"); + } + + var v; + var list = []; + + for (var i=0; i<l; i++) + { + v = params[i]; + + if (qx.util.Validation.isValidNumber(v)) + { + list.push(v); + } + else if (qx.util.Validation.isInvalidString(v)) + { + list.push(null); + } + else + { + throw new Error("Invalid shorthand value: " + v); + } + } + + // Fix Values (Shorthand) + switch(l) + { + case 1: + list[1] = list[2] = list[3] = list[0]; + break; + + case 2: + list[2] = list[0]; + + case 3: + list[3] = list[1]; + } + + return list; +} + +qx.lang.Array.copy = function(arr) { + return arr.concat(); +} + +qx.lang.Array.clone = function(arr) { + return arr.concat(); +} + +qx.lang.Array.getLast = function(arr) { + return arr[arr.length-1]; +} + +qx.lang.Array.getFirst = function(arr) { + return arr[0]; +} + +qx.lang.Array.insertAt = function(arr, obj, i) +{ + arr.splice(i, 0, obj); + + return arr; +} + +qx.lang.Array.insertBefore = function(arr, obj, obj2) +{ + var i = arr.indexOf(obj2); + + if (i == -1) + { + arr.push(obj); + } + else + { + arr.splice(i, 0, obj); + } + + return arr; +} + +qx.lang.Array.insertAfter = function(arr, o, o2) +{ + var i = arr.indexOf(o2); + + if (i == -1 || i == (arr.length-1)) + { + arr.push(o); + } + else + { + arr.splice(i+1, 0, o); + } + + return arr; +} + +qx.lang.Array.removeAt = function(arr, i) { + return arr.splice(i, 1); +} + +qx.lang.Array.removeAll = function(arr) { + return arr.splice(0, arr.length); +} + +qx.lang.Array.append = function(arr, a) { + Array.prototype.push.apply(arr, a); +} + +qx.lang.Array.remove = function(arr, obj) +{ + var i = arr.indexOf(obj); + + if (i != -1) { + return arr.splice(i, 1); + } +} + +qx.lang.Array.contains = function(arr, obj) { + return arr.indexOf(obj) != -1; +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Core.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Core.js new file mode 100644 index 0000000000..11a620e0d6 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Core.js @@ -0,0 +1,238 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(core) + +************************************************************************ */ + +qx.OO.defineClass("qx.lang.Core"); + + +/* +--------------------------------------------------------------------------- + ADDITIONS FOR NATIVE ERROR OBJECT +--------------------------------------------------------------------------- +*/ + +if (!Error.prototype.toString) +{ + Error.prototype.toString = function() { + return this.message; + } +} + + + + + + +/* +--------------------------------------------------------------------------- + ADDITIONS FOR NATIVE FUNCTION OBJECT +--------------------------------------------------------------------------- +*/ + +/** + * function apply for browsers that do not support it natively, e.g. IE 5.0 + * <p> + * Based on code from youngpup.net licensed under + * Creative Commons Attribution 2.0 + * </p> + */ +if (!Function.prototype.apply) +{ + Function.prototype.apply = function(oScope, args) + { + var sarg = []; + var rtrn, call; + + if (!oScope) { + oScope = window; + } + + if (!args) { + args = []; + } + + for (var i = 0; i < args.length; i++) { + sarg[i] = "args["+i+"]"; + } + + call = "oScope._applyTemp_(" + sarg.join(",") + ");"; + + oScope._applyTemp_ = this; + rtrn = eval(call); + + delete oScope._applyTemp_; + + return rtrn; + } +} + + + + + + +/* +--------------------------------------------------------------------------- + ADDITIONS FOR NATIVE ARRAY OBJECT +--------------------------------------------------------------------------- +*/ + +// Add all JavaScript 1.5 Features if they are missing +// Mozilla 1.8 has support for indexOf, lastIndexOf, forEach, filter, map, some, every + +// Some of them from Erik Arvidsson <http://erik.eae.net/> +// More documentation could be found here: +// http://www.webreference.com/programming/javascript/ncz/column4/ +// An alternative implementation can be found here: +// http://www.nczonline.net/archive/2005/7/231 + +// http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:lastIndexOf +if (!Array.prototype.indexOf) +{ + Array.prototype.indexOf = function(obj, fromIndex) + { + if (fromIndex == null) + { + fromIndex = 0; + } + else if (fromIndex < 0) + { + fromIndex = Math.max(0, this.length + fromIndex); + } + + for (var i=fromIndex; i<this.length; i++) { + if (this[i] === obj) { + return i; + } + } + + return -1; + } +} + +// http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:lastIndexOf +if (!Array.prototype.lastIndexOf) +{ + Array.prototype.lastIndexOf = function(obj, fromIndex) + { + if (fromIndex == null) + { + fromIndex = this.length-1; + } + else if (fromIndex < 0) + { + fromIndex = Math.max(0, this.length + fromIndex); + } + + for (var i=fromIndex; i>=0; i--) { + if (this[i] === obj) { + return i; + } + } + + return -1; + } +} + +// http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach +if (!Array.prototype.forEach) +{ + Array.prototype.forEach = function(f, obj) + { + // 'l' must be fixed during loop... see docs + for (var i=0, l=this.length; i<l; i++) { + f.call(obj, this[i], i, this); + } + } +} + +// http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:filter +if (!Array.prototype.filter) +{ + Array.prototype.filter = function(f, obj) + { + // must be fixed during loop... see docs + var l = this.length; + var res = []; + + for (var i=0; i<l; i++) + { + if (f.call(obj, this[i], i, this)) { + res.push(this[i]); + } + } + + return res; + } +} + +// http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:map +if (!Array.prototype.map) +{ + Array.prototype.map = function(f, obj) + { + var l = this.length; // must be fixed during loop... see docs + var res = []; + + for (var i=0; i<l; i++) { + res.push(f.call(obj, this[i], i, this)); + } + + return res; + } +} + +// http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:some +if (!Array.prototype.some) +{ + Array.prototype.some = function(f, obj) + { + var l = this.length; // must be fixed during loop... see docs + + for (var i=0; i<l; i++) + { + if (f.call(obj, this[i], i, this)) { + return true; + } + } + + return false; + } +} + +// http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:every +if (!Array.prototype.every) +{ + Array.prototype.every = function (f, obj) + { + var l = this.length; // must be fixed during loop... see docs + for (var i=0; i<l; i++) + { + if (!f.call(obj, this[i], i, this)) { + return false; + } + } + + return true; + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Generics.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Generics.js new file mode 100644 index 0000000000..71010a587d --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Generics.js @@ -0,0 +1,142 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + + + +************************************************************************ */ + +qx.OO.defineClass("qx.lang.Generics"); + + +/* +--------------------------------------------------------------------------- + DEFAULT SETTINGS +--------------------------------------------------------------------------- +*/ + +qx.Settings.setDefault("enable", false); + + + + + +/* +--------------------------------------------------------------------------- + JAVASCRIPT 1.6 GENERICS +--------------------------------------------------------------------------- +*/ + +// Copyright 2006 Erik Arvidsson +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// http://erik.eae.net/archives/2006/02/28/00.39.52/ + +// Relicensed under LGPL for qooxdoo. + +qx.lang.Generics.init = function() +{ + // Make generic versions of instance methods + var makeGeneric = [ + { + object: Array, + methods: + [ + "join", + "reverse", + "sort", + "push", + "pop", + "shift", + "unshift", + "splice", + "concat", + "slice", + "indexOf", + "lastIndexOf", + "forEach", + "map", + "filter", + "some", + "every" + ] + }, + { + object: String, + methods: + [ + "quote", + "substring", + "toLowerCase", + "toUpperCase", + "charAt", + "charCodeAt", + "indexOf", + "lastIndexOf", + "toLocaleLowerCase", + "toLocaleUpperCase", + "localeCompare", + "match", + "search", + "replace", + "split", + "substr", + "concat", + "slice" + ] + }]; + + for (var i=0, l=makeGeneric.length; i<l; i++) + { + var constr = makeGeneric[i].object; + var methods = makeGeneric[i].methods; + + for (var j=0; j<methods.length; j++) + { + var name = methods[j]; + + if (!constr[name]) + { + constr[methods[j]] = (function(constr, name) + { + return function(s) + { + var args = Array.prototype.slice.call(arguments, 1); + return constr.prototype[name].apply(s, args); + } + })(constr, name); + } + } + } +} + +if (qx.Settings.getValueOfClass("qx.lang.Generics", "enable")) { + qx.lang.Generics.init(); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/MshtmlEmu.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/MshtmlEmu.js new file mode 100644 index 0000000000..eb21669003 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/MshtmlEmu.js @@ -0,0 +1,348 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#require(qx.sys.Client) + +************************************************************************ */ + +qx.OO.defineClass("qx.lang.MshtmlEmu"); + +/* + Parts are based on: + moz-behaviors.xml - version 1.1.1 (2005-08-19) + Copyright 2004-2005, Dean Edwards + License: http://creativecommons.org/licenses/LGPL/2.1/ + Thanks to Erik Arvidsson (http://webfx.eae.net/dhtml/ieemu/) +*/ + +/* + We're going to mess about with some of mozilla's interfaces to + make them more explorer-like +*/ + +/* + Note: + In my comments where i say support/mimic a property: + + * support = exactly the same as explorer + * mimic = close enough +*/ + +if (qx.sys.Client.getInstance().isGecko()) +{ + /* + -------------------------------------------------------------------------------- + CSS STYLES: FLOAT + -------------------------------------------------------------------------------- + */ + + /* + Support microsoft's styleFloat + */ + + CSSStyleDeclaration.prototype.__defineGetter__("styleFloat", function() { + return this.cssFloat; + }); + + CSSStyleDeclaration.prototype.__defineSetter__("styleFloat", function(vValue) { + this.cssFloat = vValue; + }); + + + + + + /* + -------------------------------------------------------------------------------- + CSS STYLES: DIMENSIONS + -------------------------------------------------------------------------------- + */ + + /* + Mimic microsoft's pixel representations of left/top/width/height + the getters only work for values that are already pixels + */ + + CSSStyleDeclaration.prototype.__defineGetter__("pixelLeft", function() { + return parseInt(this.left) || 0; + }); + + CSSStyleDeclaration.prototype.__defineSetter__("pixelLeft", function(vValue) { + this.left = vValue + "px"; + }); + + CSSStyleDeclaration.prototype.__defineGetter__("pixelTop", function() { + return parseInt(this.top) || 0; + }); + + CSSStyleDeclaration.prototype.__defineSetter__("pixelTop", function(vValue) { + this.top = vValue + "px"; + }); + + CSSStyleDeclaration.prototype.__defineGetter__("pixelWidth", function() { + return parseInt(this.width) || 0; + }); + + CSSStyleDeclaration.prototype.__defineSetter__("pixelWidth", function(vValue) { + this.width = vValue + "px"; + }); + + CSSStyleDeclaration.prototype.__defineGetter__("pixelHeight", function() { + return parseInt(this.height) || 0; + }); + + CSSStyleDeclaration.prototype.__defineSetter__("pixelHeight", function(vValue) { + this.height = vValue + "px"; + }); + + + + + + /* + -------------------------------------------------------------------------------- + HTML DOCUMENT EXTENSIONS + -------------------------------------------------------------------------------- + */ + + /* + Support Microsoft's "all" property + */ + HTMLDocument.prototype.__defineGetter__("all", function() { + return this.getElementsByTagName("*"); + }); + + /* + Mimic the "createEventObject" method for the document object + */ + HTMLDocument.prototype.createEventObject = function() { + return document.createEvent("Events"); + } + + + + + + + /* + -------------------------------------------------------------------------------- + HTML ELEMENT EXTENSIONS + -------------------------------------------------------------------------------- + */ + + /* + Mimic Microsoft's "all" property + */ + HTMLElement.prototype.__defineGetter__("all", function() { + return this.getElementsByTagName("*"); + }); + + /* + Support "parentElement" + */ + HTMLElement.prototype.__defineGetter__("parentElement", function() { + return (this.parentNode == this.ownerDocument) ? null : this.parentNode; + }); + + /* + Support "uniqueID" + */ + HTMLElement.prototype.__defineGetter__("uniqueID", function() + { + // a global counter is stored privately as a property of this getter function. + // initialise the counter + if (!arguments.callee.count) { + arguments.callee.count = 0; + } + + // create the id and increment the counter + var vUniqueID = "moz_id" + arguments.callee.count++; + + // creating a unique id, creates a global reference + window[vUniqueID] = this; + + // we don't want to increment next time, so redefine the getter + this.__defineGetter__("uniqueID", function(){return vUniqueID;}); + + return vUniqueID; + }); + + /* + Mimic Microsoft's "currentStyle" + */ + HTMLElement.prototype.__defineGetter__("currentStyle", function() { + return getComputedStyle(this, null); + }); + + /* + Mimic Microsoft's "runtimeStyle" + */ + HTMLElement.prototype.__defineGetter__("runtimeStyle", function() + { + /* + this doesn't work yet (https://bugzilla.mozilla.org/show_bug.cgi?id=45424) + return this.ownerDocument.defaultView.getOverrideStyle(this, null); + */ + + return this.style; + }); + + /* + Support "innerText" + */ + HTMLElement.prototype.__defineGetter__("innerText", function() { + return this.textContent; + }); + + HTMLElement.prototype.__defineSetter__("innerText", function(vValue) { + this.textContent = vValue; + }); + + /* + Mimic the "attachEvent" method + */ + HTMLElement.prototype.attachEvent = function(vName, vHandler) { + this.addEventListener(vName.slice(2), vHandler, false); + } + + /* + Mimic the "removeEvent" method + */ + HTMLElement.prototype.removeEvent = function(vName, vHandler) { + this.removeEventListener(vName.slice(2), vHandler, false); + } + + /* + Mimic the "createEventObject" method + */ + HTMLElement.prototype.createEventObject = function() { + return this.ownerDocument.createEventObject(); + } + + /* + Mimic the "fireEvent" method + */ + HTMLElement.prototype.fireEvent = function(vName, vEvent) + { + if (!vEvent) { + vEvent = this.ownerDocument.createEventObject(); + } + + vEvent.initEvent(vName.slice(2), false, false); + + this.dispatchEvent(vEvent); + + // not sure that this should be here?? + if (typeof this[vName] === "function") + { + this[vName](); + } + else if (this.getAttribute(vName)) + { + eval(this.getAttribute(vName)); + } + } + + /* + Support the "contains" method + */ + HTMLElement.prototype.contains = function(vElement) { + return Boolean(vElement == this || (vElement && this.contains(vElement.parentElement))); + } + + + + + + /* + -------------------------------------------------------------------------------- + EVENT EXTENSIONS + -------------------------------------------------------------------------------- + */ + + /* + Support Microsoft's proprietary event properties + */ + Event.prototype.__defineGetter__("srcElement", function() { + return (this.target.nodeType == Node.ELEMENT_NODE) ? this.target : this.target.parentNode; + }); + + Event.prototype.__defineGetter__("fromElement",function() { + return (this.type == "mouseover") ? this.relatedTarget : (this.type == "mouseout") ? this.srcElement : null; + }); + + Event.prototype.__defineGetter__("toElement", function() { + return (this.type == "mouseout") ? this.relatedTarget : (this.type == "mouseover") ? this.srcElement : null; + }); + + /* + Convert w3c button id's to Microsoft's + Breaks with qooxdoo's internal event handling!!! + */ + /* + Event.prototype.__defineGetter__("button", function() { + return (this.which == 1) ? 1 : (this.which == 2) ? 4 : 2; + }); + */ + + + /* + Mimic "returnValue" (default is "true") + Breaks with qooxdoo's internal event handling!!! + */ + /* + Event.prototype.__defineGetter__("returnValue", function() { + return true; + }); + + Event.prototype.__defineSetter__("returnValue", function(vValue) + { + if (this.cancelable && !vValue) + { + // this can't be undone! + this.preventDefault(); + + this.__defineGetter__("returnValue", function() { + return false; + }); + } + }); + */ + + /* + Mozilla already supports the read-only "cancelBubble" + so we only need to define the setter + */ + Event.prototype.__defineSetter__("cancelBubble", function(vValue) + { + // this can't be undone! + if (vValue) { + this.stopPropagation(); + } + }); + + Event.prototype.__defineGetter__("offsetX", function() { + return this.layerX; + }); + + Event.prototype.__defineGetter__("offsetY", function() { + return this.layerY; + }); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Number.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Number.js new file mode 100644 index 0000000000..dc6984ba36 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Number.js @@ -0,0 +1,48 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + + +************************************************************************ */ + +qx.OO.defineClass("qx.lang.Number"); + +qx.lang.Number.isInRange = function(nr, vmin, vmax) { + return nr >= vmin && nr <= vmax; +} + +qx.lang.Number.isBetweenRange = function(nr, vmin, vmax) { + return nr > vmin && nr < vmax; +} + +qx.lang.Number.limit = function(nr, vmin, vmax) +{ + if (typeof vmax === "number" && nr > vmax) + { + return vmax; + } + else if (typeof vmin === "number" && nr < vmin) + { + return vmin; + } + else + { + return nr; + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Object.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Object.js new file mode 100644 index 0000000000..31e316ef50 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Object.js @@ -0,0 +1,121 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(core) + +************************************************************************ */ + +qx.OO.defineClass("qx.lang.Object"); + +/*! + Function to check if a hash has any keys +*/ +qx.Class.isEmpty = function(h) +{ + for (var s in h) { + return false; + } + + return true; +} + +qx.Class.hasMinLength = function(h, j) +{ + var i=0; + + for (var s in h) + { + if ((++i)>=j) { + return true; + } + } + + return false; +} + +qx.Class.getLength = function(h) +{ + var i=0; + + for (var s in h) { + i++; + } + + return i; +} + +qx.Class.getKeys = function(h) +{ + var r = []; + for (var s in h) { + r.push(s); + } + + return r; +} + +qx.Class.getKeysAsString = function(h) { + return qx.lang.Object.getKeys(h).join(", "); +} + +qx.Class.getValues = function(h) +{ + var r = []; + for (var s in h) { + r.push(h[s]); + } + + return r; +} + +qx.Class.mergeWith = function(vObjectA, vObjectB) +{ + for (var vKey in vObjectB) { + vObjectA[vKey] = vObjectB[vKey]; + } + + return vObjectA; +} + +qx.Class.carefullyMergeWith = function(vObjectA, vObjectB) { + for (vKey in vObjectB) + { + if (typeof vObjectA[vKey] === "undefined") { + vObjectA[vKey] = vObjectB[vKey]; + } + } + + return vObjectA; +} + +qx.Class.merge = function(vObjectA) +{ + var vLength = arguments.length; + + for (var i=1; i<vLength; i++) { + qx.lang.Object.mergeWith(vObjectA, arguments[i]); + } + + return vObjectA; +} + +qx.Class.copy = function(vObject) { + return qx.lang.Object.mergeWith({}, vObject); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Prototypes.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Prototypes.js new file mode 100644 index 0000000000..fa678c5403 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/Prototypes.js @@ -0,0 +1,69 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + + +************************************************************************ */ + +qx.OO.defineClass("qx.lang.Prototypes"); + + + +/* +--------------------------------------------------------------------------- + DEFAULT SETTINGS +--------------------------------------------------------------------------- +*/ + +qx.Settings.setDefault("enable", false); + + + + + +/* +--------------------------------------------------------------------------- + PROTOTYPES MAPPER +--------------------------------------------------------------------------- +*/ + +qx.lang.Prototypes.init = function() +{ + var key, obj; + var objs = [ "String", "Number", "Array" ]; + + for (var i=0, len=objs.length; i<len; i++) + { + obj = objs[i]; + + for (key in qx.lang[obj]) + { + window[obj].prototype[key] = (function(key, obj) + { + return function() { + return qx.lang[obj][key].apply(null, Array.prototype.concat.call([this], Array.prototype.slice.call(arguments, 0))); + } + })(key, obj); + } + } +} + +if (qx.Settings.getValueOfClass("qx.lang.Generics", "enable")) { + qx.lang.Prototypes.init(); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/String.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/String.js new file mode 100644 index 0000000000..9f20f819fc --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/String.js @@ -0,0 +1,158 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(core) + +************************************************************************ */ + +qx.OO.defineClass("qx.lang.String"); + +qx.Class.toCamelCase = function(str) +{ + var vArr = str.split("-"), vLength = vArr.length; + + if(vLength == 1) { + return vArr[0]; + } + + var vNew = str.indexOf("-") == 0 ? vArr[0].charAt(0).toUpperCase() + vArr[0].substring(1) : vArr[0]; + + for (var vPart, i=1; i<vLength; i++) + { + vPart = vArr[i]; + vNew += vPart.charAt(0).toUpperCase() + vPart.substring(1); + } + + return vNew; +} + +qx.Class.trimLeft = function(str) { + return str.replace(/^\s+/, ""); +} + +qx.Class.trimRight = function(str) { + return str.replace(/\s+$/, ""); +} + +qx.Class.trim = function(str) { + return str.replace(/^\s+|\s+$/g, ""); +} + +qx.Class.stripTags = function(str) { + return str.replace(/<\/?[^>]+>/gi, ""); +} + +qx.Class.startsWith = function(fullstr, substr) { + return !fullstr.indexOf(substr); +} + +qx.Class.endsWith = function(fullstr, substr) { + return fullstr.lastIndexOf(substr) === fullstr.length-substr.length; +} + +qx.Class.pad = function(str, length, ch) +{ + if (typeof ch === "undefined") { + ch = "0"; + } + + var temp = ""; + + for (var i=length, l=str.length; l<i; l++) { + temp += ch; + } + + return temp + str; +} + +qx.Class.toFirstUp = function(str) { + return str.charAt(0).toUpperCase() + str.substr(1); +} + +qx.Class.add = function(str, v, sep) +{ + if (str == v) + { + return str; + } + else if (str == "") + { + return v; + } + else + { + if (qx.util.Validation.isInvalid(sep)) { + sep = ","; + } + + var a = str.split(sep); + + if (a.indexOf(v) == -1) + { + a.push(v); + return a.join(sep); + } + else + { + return str; + } + } +} + +qx.Class.remove = function(str, v, sep) +{ + if (str == v || str == "") + { + return ""; + } + else + { + if (qx.util.Validation.isInvalid(sep)) { + sep = ","; + } + + var a = str.split(sep); + var p = a.indexOf(v); + + if (p === -1) { + return str; + } + + do { a.splice(p, 1); } + while((p = a.indexOf(v)) != -1); + + return a.join(sep); + } +} + +qx.Class.contains = function(str, s) { + return str.indexOf(s) != -1; +} + + +/** + * Escapes all chars that have a special meaning in regular expressions + * + * @param str {string} the string where to escape the chars. + * @return {string} the string with the escaped chars. + */ +qx.Class.escapeRegexpChars = function(str) { + return str.replace(/([\\\.\(\)\[\]\{\}\^\$\?\+\*])/g, "\\$1"); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/XmlEmu.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/XmlEmu.js new file mode 100644 index 0000000000..326effde5d --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/lang/XmlEmu.js @@ -0,0 +1,188 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + + +************************************************************************ */ + +qx.OO.defineClass("qx.lang.XmlEmu"); + +/* + Based on: + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name) + License: http://creativecommons.org/licenses/LGPL/2.1/ + Modelled after: http://www.mozilla.org/xmlextras +*/ + +if (qx.sys.Client.getInstance().isMshtml()) +{ + var DOMParser = function() { + /* empty constructor */ + } + + DOMParser.prototype = + { + toString: function() { + return "[object DOMParser]"; + }, + + parseFromString: function(str, contentType) + { + /* + According to information on the Microsoft XML Team's WebLog + it is recommended to check for availability of MSXML versions 6.0 and 3.0. + Other versions are included for completeness, 5.0 is excluded as it is + "off-by-default" in IE7 (which could trigger a goldbar). + + http://blogs.msdn.com/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx + http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/aabe29a2-bad2-4cea-8387-314174252a74.asp + + See similar code in qx.xml.Core, qx.io.remote.XmlHttpTransport + */ + var vServers = + [ + "MSXML2.DOMDocument.6.0", + "MSXML2.DOMDocument.3.0", + "MSXML2.DOMDocument.4.0", + "MSXML2.DOMDocument", // v3.0 + "MSXML.DOMDocument", // v2.x + "Microsoft.XMLDOM" // v2.x + ]; + + var xmlDocument; + + for (var i=0, l=vServers.length; i<l; i++) + { + + try + { + xmlDocument = new ActiveXObject(vServers[i]); + break; + } + catch(ex) + { + xmlDocument = null; + } + } + + if(xmlDocument) { + xmlDocument.loadXML(str); + } + + return xmlDocument; + }, + + // not supported + parseFromStream: new Function, + baseURI: "" + } + + var XMLSerializer = function() { + /* empty constructor */ + } + + XMLSerializer.prototype = + { + toString: function() { + return "[object XMLSerializer]"; + }, + + serializeToString: function(root) { + return root.xml || root.outerHTML; + }, + + // not supported + serializeToStream: new Function + } +} + +// Implementation of selectNodes() and selectSingleNode() +// for Gecko/Mozilla browsers + +if (window.XPathEvaluator && Element.prototype.__defineGetter__) +{ + qx.lang.XmlEmu._xpe = new XPathEvaluator(); + + if (!Element.prototype.selectSingleNode) + { + Element.prototype.selectSingleNode = function (xpath) { + return qx.lang.XmlEmu._xpe.evaluate(xpath, this, qx.lang.XmlEmu._xpe.createNSResolver(this), XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; + } + } + + if (!Element.prototype.selectNodes) + { + Element.prototype.selectNodes = function (xpath) { + var result = qx.lang.XmlEmu._xpe.evaluate(xpath, this, qx.lang.XmlEmu._xpe.createNSResolver(this), XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + var nodes = []; + + for (var i=0; i<result.snapshotLength; i++) { + nodes[i] = result.snapshotItem(i); + } + + return nodes; + } + } + + if (!Document.prototype.selectSingleNode) + { + Document.prototype.selectSingleNode = function (xpath) { + return qx.lang.XmlEmu._xpe.evaluate(xpath, this, qx.lang.XmlEmu._xpe.createNSResolver(this), XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; + } + } + + if (!Document.prototype.selectNodes) + { + Document.prototype.selectNodes = function (xpath) { + var result = qx.lang.XmlEmu._xpe.evaluate(xpath, this, qx.lang.XmlEmu._xpe.createNSResolver(this), XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + var nodes = []; + + for (var i=0; i<result.snapshotLength; i++) { + nodes[i] = result.snapshotItem(i); + } + + return nodes; + } + } + + Element.prototype.__defineGetter__('text', + function() { + var text = ""; + for (var i=0; i<this.childNodes.length; i++) { + text += this.childNodes[i].text != null ? this.childNodes[i].text : ""; + } + return text; + } + ); + + Element.prototype.__lookupGetter__('text'); + + if (!window.Attr) { + Attr = new Function(); + } + Attr.prototype.__defineGetter__('text', function(){ return this.nodeValue; }); + Attr.prototype.__lookupGetter__('text'); + + if (!window.Text) { + Text = new Function(); + } + Text.prototype.__defineGetter__('text', function(){ return this.nodeValue; }); + Text.prototype.__lookupGetter__('text'); +} |