> 5] |= 128 << (24 - len % 32);
+ x[((len + 64 >> 9) << 4) + 15] = len;
+ var w = [];
+ var a = 1732584193;
+ var b = -271733879;
+ var c = -1732584194;
+ var d = 271733878;
+ var e = -1009589776;
+ for (var i = 0; i < x.length; i += 16) {
+ var olda = a;
+ var oldb = b;
+ var oldc = c;
+ var oldd = d;
+ var olde = e;
+ for (var j = 0; j < 80; j++) {
+ if (j < 16) {
+ w[j] = x[i + j];
+ } else {
+ w[j] = r(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
+ }
+ var t = add(add(r(a, 5), fn(j, b, c, d)), add(add(e, w[j]), cnst(j)));
+ e = d;
+ d = c;
+ c = r(b, 30);
+ b = a;
+ a = t;
}
-
- a=add(a,olda);
- b=add(b,oldb);
- c=add(c,oldc);
- d=add(d,oldd);
- e=add(e,olde);
+ a = add(a, olda);
+ b = add(b, oldb);
+ c = add(c, oldc);
+ d = add(d, oldd);
+ e = add(e, olde);
}
- return [a,b,c,d,e];
+ return [a, b, c, d, e];
}
- function hmac(data,key){
- var wa=toWord(key);
- if(wa.length>16) wa=core(wa,key.length*chrsz);
- var l=[], r=[];
- for(var i=0; i<16; i++){
- l[i]=wa[i]^0x36363636;
- r[i]=wa[i]^0x5c5c5c5c;
+ function hmac(data, key) {
+ var wa = toWord(key);
+ if (wa.length > 16) {
+ wa = core(wa, key.length * chrsz);
}
- var h=core(l.concat(toWord(data)),512+data.length*chrsz);
- return core(r.concat(h),640);
+ var l = [], r = [];
+ for (var i = 0; i < 16; i++) {
+ l[i] = wa[i] ^ 909522486;
+ r[i] = wa[i] ^ 1549556828;
+ }
+ var h = core(l.concat(toWord(data)), 512 + data.length * chrsz);
+ return core(r.concat(h), 640);
}
-
- this.compute=function(data,outputType){
- var out=outputType||dojo.crypto.outputTypes.Base64;
- switch(out){
- case dojo.crypto.outputTypes.Hex:{
- return toHex(core(toWord(data),data.length*chrsz));
- }
- case dojo.crypto.outputTypes.String:{
- return toString(core(toWord(data),data.length*chrsz));
- }
- default:{
- return toBase64(core(toWord(data),data.length*chrsz));
- }
+ this.compute = function (data, outputType) {
+ var out = outputType || dojo.crypto.outputTypes.Base64;
+ switch (out) {
+ case dojo.crypto.outputTypes.Hex:
+ return toHex(core(toWord(data), data.length * chrsz));
+ case dojo.crypto.outputTypes.String:
+ return toString(core(toWord(data), data.length * chrsz));
+ default:
+ return toBase64(core(toWord(data), data.length * chrsz));
}
};
- this.getHMAC=function(data,key,outputType){
- var out=outputType||dojo.crypto.outputTypes.Base64;
- switch(out){
- case dojo.crypto.outputTypes.Hex:{
- return toHex(hmac(data,key));
- }
- case dojo.crypto.outputTypes.String:{
- return toString(hmac(data,key));
- }
- default:{
- return toBase64(hmac(data,key));
- }
+ this.getHMAC = function (data, key, outputType) {
+ var out = outputType || dojo.crypto.outputTypes.Base64;
+ switch (out) {
+ case dojo.crypto.outputTypes.Hex:
+ return toHex(hmac(data, key));
+ case dojo.crypto.outputTypes.String:
+ return toString(hmac(data, key));
+ default:
+ return toBase64(hmac(data, key));
}
};
}();
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA256.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA256.js
index 00a97c6b8..50d10a264 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA256.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/crypto/SHA256.js
@@ -11,10 +11,9 @@
dojo.provide("dojo.crypto.SHA256");
dojo.require("dojo.crypto");
dojo.require("dojo.experimental");
-
dojo.experimental("dojo.crypto.SHA256");
-
-dojo.crypto.SHA256 = new function(){
- this.compute=function(s){
+dojo.crypto.SHA256 = new function () {
+ this.compute = function (s) {
};
}();
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/crypto/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/crypto/__package__.js
index 652b66d79..d87f2563c 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/crypto/__package__.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/crypto/__package__.js
@@ -8,10 +8,6 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-dojo.kwCompoundRequire({
- common: [
- "dojo.crypto",
- "dojo.crypto.MD5"
- ]
-});
+dojo.kwCompoundRequire({common:["dojo.crypto", "dojo.crypto.MD5"]});
dojo.provide("dojo.crypto.*");
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data.js
index 36532e9f7..4ea183b5b 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data.js
@@ -9,7 +9,5 @@
*/
dojo.provide("dojo.data");
-
-// currently a stub for dojo.data
-
dojo.data = {};
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/CsvStore.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/CsvStore.js
new file mode 100644
index 000000000..0a86ba514
--- /dev/null
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/CsvStore.js
@@ -0,0 +1,113 @@
+/*
+ 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.data.CsvStore");
+dojo.require("dojo.data.core.RemoteStore");
+dojo.require("dojo.lang.assert");
+dojo.declare("dojo.data.CsvStore", dojo.data.core.RemoteStore, {_setupQueryRequest:function (result, requestKw) {
+ var serverQueryUrl = this._serverQueryUrl ? this._serverQueryUrl : "";
+ var queryUrl = result.query ? result.query : "";
+ requestKw.url = serverQueryUrl + queryUrl;
+ requestKw.method = "get";
+}, _resultToQueryData:function (serverResponseData) {
+ var csvFileContentString = serverResponseData;
+ var arrayOfArrays = this._getArrayOfArraysFromCsvFileContents(csvFileContentString);
+ var arrayOfObjects = this._getArrayOfObjectsFromArrayOfArrays(arrayOfArrays);
+ var remoteStoreData = this._getRemoteStoreDataFromArrayOfObjects(arrayOfObjects);
+ return remoteStoreData;
+}, _setupSaveRequest:function (saveKeywordArgs, requestKw) {
+}, _getArrayOfArraysFromCsvFileContents:function (csvFileContents) {
+ dojo.lang.assertType(csvFileContents, String);
+ var lineEndingCharacters = new RegExp("\r\n|\n|\r");
+ var leadingWhiteSpaceCharacters = new RegExp("^\\s+", "g");
+ var trailingWhiteSpaceCharacters = new RegExp("\\s+$", "g");
+ var doubleQuotes = new RegExp("\"\"", "g");
+ var arrayOfOutputRecords = [];
+ var arrayOfInputLines = csvFileContents.split(lineEndingCharacters);
+ for (var i in arrayOfInputLines) {
+ var singleLine = arrayOfInputLines[i];
+ if (singleLine.length > 0) {
+ var listOfFields = singleLine.split(",");
+ var j = 0;
+ while (j < listOfFields.length) {
+ var space_field_space = listOfFields[j];
+ var field_space = space_field_space.replace(leadingWhiteSpaceCharacters, "");
+ var field = field_space.replace(trailingWhiteSpaceCharacters, "");
+ var firstChar = field.charAt(0);
+ var lastChar = field.charAt(field.length - 1);
+ var secondToLastChar = field.charAt(field.length - 2);
+ var thirdToLastChar = field.charAt(field.length - 3);
+ if ((firstChar == "\"") && ((lastChar != "\"") || ((lastChar == "\"") && (secondToLastChar == "\"") && (thirdToLastChar != "\"")))) {
+ if (j + 1 === listOfFields.length) {
+ return null;
+ }
+ var nextField = listOfFields[j + 1];
+ listOfFields[j] = field_space + "," + nextField;
+ listOfFields.splice(j + 1, 1);
+ } else {
+ if ((firstChar == "\"") && (lastChar == "\"")) {
+ field = field.slice(1, (field.length - 1));
+ field = field.replace(doubleQuotes, "\"");
+ }
+ listOfFields[j] = field;
+ j += 1;
+ }
+ }
+ arrayOfOutputRecords.push(listOfFields);
+ }
+ }
+ return arrayOfOutputRecords;
+}, _getArrayOfObjectsFromArrayOfArrays:function (arrayOfArrays) {
+ dojo.lang.assertType(arrayOfArrays, Array);
+ var arrayOfItems = [];
+ if (arrayOfArrays.length > 1) {
+ var arrayOfKeys = arrayOfArrays[0];
+ for (var i = 1; i < arrayOfArrays.length; ++i) {
+ var row = arrayOfArrays[i];
+ var item = {};
+ for (var j in row) {
+ var value = row[j];
+ var key = arrayOfKeys[j];
+ item[key] = value;
+ }
+ arrayOfItems.push(item);
+ }
+ }
+ return arrayOfItems;
+}, _getRemoteStoreDataFromArrayOfObjects:function (arrayOfObjects) {
+ dojo.lang.assertType(arrayOfObjects, Array);
+ var output = {};
+ for (var i = 0; i < arrayOfObjects.length; ++i) {
+ var object = arrayOfObjects[i];
+ for (var key in object) {
+ var value = object[key];
+ object[key] = [value];
+ }
+ output[i] = object;
+ }
+ return output;
+}, newItem:function (attributes, keywordArgs) {
+ dojo.unimplemented("dojo.data.CsvStore.newItem");
+}, deleteItem:function (item) {
+ dojo.unimplemented("dojo.data.CsvStore.deleteItem");
+}, setValues:function (item, attribute, values) {
+ dojo.unimplemented("dojo.data.CsvStore.setValues");
+}, set:function (item, attribute, value) {
+ dojo.unimplemented("dojo.data.CsvStore.set");
+}, unsetAttribute:function (item, attribute) {
+ dojo.unimplemented("dojo.data.CsvStore.unsetAttribute");
+}, save:function (keywordArgs) {
+ dojo.unimplemented("dojo.data.CsvStore.save");
+}, revert:function () {
+ dojo.unimplemented("dojo.data.CsvStore.revert");
+}, isDirty:function (item) {
+ dojo.unimplemented("dojo.data.CsvStore.isDirty");
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/OpmlStore.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/OpmlStore.js
new file mode 100644
index 000000000..e6d63b287
--- /dev/null
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/OpmlStore.js
@@ -0,0 +1,164 @@
+/*
+ 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.data.OpmlStore");
+dojo.require("dojo.data.core.Read");
+dojo.require("dojo.data.core.Result");
+dojo.require("dojo.lang.assert");
+dojo.require("dojo.json");
+dojo.require("dojo.experimental");
+dojo.experimental("dojo.data.OpmlStore");
+dojo.declare("dojo.data.OpmlStore", dojo.data.core.Read, {initializer:function (keywordParameters) {
+ this._arrayOfTopLevelItems = [];
+ this._metadataNodes = null;
+ this._loadFinished = false;
+ this._opmlFileUrl = keywordParameters["url"];
+}, _assertIsItem:function (item) {
+ if (!this.isItem(item)) {
+ throw new Error("dojo.data.OpmlStore: a function was passed an item argument that was not an item");
+ }
+}, _removeChildNodesThatAreNotElementNodes:function (node, recursive) {
+ var childNodes = node.childNodes;
+ if (childNodes.length == 0) {
+ return;
+ }
+ var nodesToRemove = [];
+ var i, childNode;
+ for (i = 0; i < childNodes.length; ++i) {
+ childNode = childNodes[i];
+ if (childNode.nodeType != Node.ELEMENT_NODE) {
+ nodesToRemove.push(childNode);
+ }
+ }
+ for (i = 0; i < nodesToRemove.length; ++i) {
+ childNode = nodesToRemove[i];
+ node.removeChild(childNode);
+ }
+ if (recursive) {
+ for (i = 0; i < childNodes.length; ++i) {
+ childNode = childNodes[i];
+ this._removeChildNodesThatAreNotElementNodes(childNode, recursive);
+ }
+ }
+}, _processRawXmlTree:function (rawXmlTree) {
+ var headNodes = rawXmlTree.getElementsByTagName("head");
+ var headNode = headNodes[0];
+ this._removeChildNodesThatAreNotElementNodes(headNode);
+ this._metadataNodes = headNode.childNodes;
+ var bodyNodes = rawXmlTree.getElementsByTagName("body");
+ var bodyNode = bodyNodes[0];
+ this._removeChildNodesThatAreNotElementNodes(bodyNode, true);
+ var bodyChildNodes = bodyNodes[0].childNodes;
+ for (var i = 0; i < bodyChildNodes.length; ++i) {
+ var node = bodyChildNodes[i];
+ if (node.tagName == "outline") {
+ this._arrayOfTopLevelItems.push(node);
+ }
+ }
+}, get:function (item, attribute, defaultValue) {
+ this._assertIsItem(item);
+ if (attribute == "children") {
+ return (item.firstChild || defaultValue);
+ } else {
+ var value = item.getAttribute(attribute);
+ value = (value != undefined) ? value : defaultValue;
+ return value;
+ }
+}, getValues:function (item, attribute) {
+ this._assertIsItem(item);
+ if (attribute == "children") {
+ var array = [];
+ for (var i = 0; i < item.childNodes.length; ++i) {
+ array.push(item.childNodes[i]);
+ }
+ return array;
+ } else {
+ return [item.getAttribute(attribute)];
+ }
+}, getAttributes:function (item) {
+ this._assertIsItem(item);
+ var attributes = [];
+ var xmlNode = item;
+ var xmlAttributes = xmlNode.attributes;
+ for (var i = 0; i < xmlAttributes.length; ++i) {
+ var xmlAttribute = xmlAttributes.item(i);
+ attributes.push(xmlAttribute.nodeName);
+ }
+ if (xmlNode.childNodes.length > 0) {
+ attributes.push("children");
+ }
+ return attributes;
+}, hasAttribute:function (item, attribute) {
+ return (this.getValues(item, attribute).length > 0);
+}, containsValue:function (item, attribute, value) {
+ var values = this.getValues(item, attribute);
+ for (var i = 0; i < values.length; ++i) {
+ var possibleValue = values[i];
+ if (value == possibleValue) {
+ return true;
+ }
+ }
+ return false;
+}, isItem:function (something) {
+ return (something && something.nodeType == Node.ELEMENT_NODE && something.tagName == "outline");
+}, isItemAvailable:function (something) {
+ return this.isItem(something);
+}, find:function (keywordArgs) {
+ var result = null;
+ if (keywordArgs instanceof dojo.data.core.Result) {
+ result = keywordArgs;
+ result.store = this;
+ } else {
+ result = new dojo.data.core.Result(keywordArgs, this);
+ }
+ var self = this;
+ var bindHandler = function (type, data, evt) {
+ var scope = result.scope || dj_global;
+ if (type == "load") {
+ self._processRawXmlTree(data);
+ if (result.saveResult) {
+ result.items = self._arrayOfTopLevelItems;
+ }
+ if (result.onbegin) {
+ result.onbegin.call(scope, result);
+ }
+ for (var i = 0; i < self._arrayOfTopLevelItems.length; i++) {
+ var item = self._arrayOfTopLevelItems[i];
+ if (result.onnext && !result._aborted) {
+ result.onnext.call(scope, item, result);
+ }
+ }
+ if (result.oncompleted && !result._aborted) {
+ result.oncompleted.call(scope, result);
+ }
+ } else {
+ if (type == "error" || type == "timeout") {
+ var errorObject = data;
+ if (result.onerror) {
+ result.onerror.call(scope, data);
+ }
+ }
+ }
+ };
+ if (!this._loadFinished) {
+ if (this._opmlFileUrl) {
+ var bindRequest = dojo.io.bind({url:this._opmlFileUrl, handle:bindHandler, mimetype:"text/xml", sync:(result.sync || false)});
+ result._abortFunc = bindRequest.abort;
+ }
+ }
+ return result;
+}, getIdentity:function (item) {
+ dojo.unimplemented("dojo.data.OpmlStore.getIdentity()");
+ return null;
+}, findByIdentity:function (identity) {
+ dojo.unimplemented("dojo.data.OpmlStore.findByIdentity()");
+ return null;
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/RdfStore.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/RdfStore.js
new file mode 100644
index 000000000..ee2d3a2ad
--- /dev/null
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/RdfStore.js
@@ -0,0 +1,183 @@
+/*
+ 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.data.RdfStore");
+dojo.provide("dojo.data.RhizomeStore");
+dojo.require("dojo.lang.declare");
+dojo.require("dojo.data.core.RemoteStore");
+dojo.require("dojo.experimental");
+dojo.data.RdfDatatypeSerializer = function (type, convertFunc, uri) {
+ this.type = type;
+ this._converter = convertFunc;
+ this.uri = uri;
+ this.serialize = function (value) {
+ return this._converter.call(value, value);
+ };
+};
+dojo.declare("dojo.data.RdfStore", dojo.data.core.RemoteStore, {_datatypeMap:{literal:function (value) {
+ var literal = value.value;
+ if (value["xml:lang"]) {
+ literal.lang = value["xml:lang"];
+ }
+ return literal;
+}, uri:function (value) {
+ return {id:value.value};
+}, bnode:function (value) {
+ return {id:"_:" + value.value};
+}, "http://www.w3.org/2001/XMLSchema#int":function (value) {
+ return parseInt(value.value);
+}, "http://www.w3.org/2001/XMLSchema#integer":function (value) {
+ return parseInt(value.value);
+}, "http://www.w3.org/2001/XMLSchema#long":function (value) {
+ return parseInt(value.value);
+}, "http://www.w3.org/2001/XMLSchema#float":function (value) {
+ return parseFloat(value.value);
+}, "http://www.w3.org/2001/XMLSchema#double":function (value) {
+ return parseFloat(value.value);
+}, "http://www.w3.org/2001/XMLSchema#boolean":function (value) {
+ return !value || value == "false" || value == "0" ? false : true;
+}}, _datatypeSerializers:[new dojo.data.RdfDatatypeSerializer(Number, Number.toString, "http://www.w3.org/2001/XMLSchema#float"), new dojo.data.RdfDatatypeSerializer(Boolean, Boolean.toString, "http://www.w3.org/2001/XMLSchema#boolean")], _findDatatypeSerializer:function (value) {
+ var length = this._datatypeSerializers.length;
+ for (var i = 0; i < length; i++) {
+ var datatype = this._datatypeSerializers[i];
+ if (value instanceof datatype.type) {
+ return datatype;
+ }
+ }
+}, _toRDFValue:function (value) {
+ var rdfvalue = {};
+ if (value.id) {
+ if (value.id.slice(0, 2) == "_:") {
+ rdfvalue.type = "bnode";
+ rdfvalue.value = value.id.substring(2);
+ } else {
+ rdfvalue.type = "uri";
+ rdfvalue.value = value.id;
+ }
+ } else {
+ if (typeof value == "string" || value instanceof String) {
+ rdfvalue.type = "literal";
+ rdfvalue.value = value;
+ if (value.lang) {
+ rdfvalue["xml:lang"] = value.lang;
+ }
+ } else {
+ if (typeof value == "number") {
+ value = new Number(value);
+ } else {
+ if (typeof value == "boolean") {
+ value = new Boolean(value);
+ }
+ }
+ var datatype = this._findDatatypeSerializer(value);
+ if (datatype) {
+ rdfvalue = {"type":"typed-literal", "datatype":datatype.uri, "value":value.toString()};
+ } else {
+ rdfvalue = {"type":"literal", "value":value.toString()};
+ }
+ }
+ }
+ return rdfvalue;
+}, _setupSaveRequest:function (saveKeywordArgs, requestKw) {
+ var rdfResult = {"head":{"vars":["s", "p", "o"]}, "results":{"bindings":[]}};
+ var resources = [];
+ for (var key in this._deleted) {
+ resources.push(key);
+ }
+ rdfResult.results.deleted = resources;
+ for (key in this._changed) {
+ var subject = this._toRDFValue(this.getIdentity(key));
+ var attributes = this._changed[key];
+ for (var attr in attributes) {
+ var predicate = {type:"uri", value:attr};
+ var values = attributes[attr];
+ if (!values.length) {
+ continue;
+ }
+ var rdfvalues = [];
+ for (var i = 0; i < values.length; i++) {
+ var rdfvalue = this._toRDFValue(values[i]);
+ rdfResult.results.bindings.push({s:subject, p:predicate, o:rdfvalue});
+ }
+ }
+ }
+ var oldRegistry = dojo.json.jsonRegistry;
+ dojo.json.jsonRegistry = this._jsonRegistry;
+ var jsonString = dojo.json.serialize(rdfResult);
+ dojo.json.jsonRegistry = oldRegistry;
+ requestKw.postContent = jsonString;
+}, _resultToQueryMetadata:function (json) {
+ return json.head;
+}, _resultToQueryData:function (json) {
+ var items = {};
+ var stmts = json.results.bindings;
+ for (var i = 0; i < stmts.length; i++) {
+ var stmt = stmts[i];
+ var subject = stmt.s.value;
+ if (stmt.s.type == "bnode") {
+ subject = "_:" + subject;
+ }
+ var attributes = data[subject];
+ if (!attributes) {
+ attributes = {};
+ data[stmt.s] = attributes;
+ }
+ var attr = attributes[stmt.p.value];
+ if (!attr) {
+ attributes[stmt.p.value] = [stmt.o];
+ } else {
+ attr.push(stmt.o);
+ }
+ }
+ return items;
+}});
+dojo.declare("dojo.data.RhizomeStore", dojo.data.RdfStore, {initializer:function (kwArgs) {
+ this._serverQueryUrl = kwArgs.baseUrl + "search?view=json&searchType=RxPath&search=";
+ this._serverSaveUrl = kwArgs.baseUrl + "save-metadata";
+}, _resultToQueryMetadata:function (json) {
+ return json;
+}, _resultToQueryData:function (json) {
+ return json;
+}, _setupSaveRequest:function (saveKeywordArgs, requestKw) {
+ requestKw.url = this._serverSaveUrl;
+ requestKw.method = "post";
+ requestKw.mimetype = "text/plain";
+ var resources = [];
+ for (var key in this._deleted) {
+ resources.push(key);
+ }
+ var changes = {};
+ for (key in this._changed) {
+ if (!this._added[key]) {
+ resources.push(key);
+ }
+ var attributes = this._changed[key];
+ var rdfattributes = {};
+ for (var attr in attributes) {
+ var values = attributes[attr];
+ if (!values.length) {
+ continue;
+ }
+ var rdfvalues = [];
+ for (var i = 0; i < values.length; i++) {
+ var rdfvalue = this._toRDFValue(values[i]);
+ rdfvalues.push(rdfvalue);
+ }
+ rdfattributes[attr] = rdfvalues;
+ }
+ changes[key] = rdfattributes;
+ }
+ var oldRegistry = dojo.json.jsonRegistry;
+ dojo.json.jsonRegistry = this._jsonRegistry;
+ var jsonString = dojo.json.serialize(changes);
+ dojo.json.jsonRegistry = oldRegistry;
+ requestKw.content = {rdfFormat:"json", resource:resources, metadata:jsonString};
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/YahooStore.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/YahooStore.js
new file mode 100644
index 000000000..c1506260b
--- /dev/null
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/YahooStore.js
@@ -0,0 +1,42 @@
+/*
+ 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.data.YahooStore");
+dojo.require("dojo.data.core.RemoteStore");
+dojo.require("dojo.lang.declare");
+dojo.require("dojo.io.ScriptSrcIO");
+dojo.declare("dojo.data.YahooStore", dojo.data.core.RemoteStore, {_setupQueryRequest:function (result, requestKw) {
+ var start = 1;
+ var count = 1;
+ if (result) {
+ start = result.start || start;
+ count = result.count || count;
+ }
+ var sourceUrl = "http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=dojo&language=en&query=" + result.query + "&start=" + start + "&results=" + count + "&output=json";
+ requestKw.url = sourceUrl;
+ requestKw.transport = "ScriptSrcTransport";
+ requestKw.mimetype = "text/json";
+ requestKw.jsonParamName = "callback";
+}, _resultToQueryMetadata:function (json) {
+ return json.ResultSet;
+}, _resultToQueryData:function (json) {
+ var data = {};
+ for (var i = 0; i < json.ResultSet.totalResultsReturned; ++i) {
+ var record = json.ResultSet.Result[i];
+ var item = {};
+ item["Url"] = [record.Url];
+ item["Title"] = [record.Title];
+ item["Summary"] = [record.Summary];
+ var arrayIndex = (json.ResultSet.firstResultPosition - 1) + i;
+ data[arrayIndex.toString()] = item;
+ }
+ return data;
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/Read.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/Read.js
new file mode 100644
index 000000000..4f808c567
--- /dev/null
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/Read.js
@@ -0,0 +1,53 @@
+/*
+ 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.data.core.Read");
+dojo.require("dojo.data.core.Result");
+dojo.require("dojo.lang.declare");
+dojo.require("dojo.experimental");
+dojo.experimental("dojo.data.core.Read");
+dojo.declare("dojo.data.core.Read", null, {get:function (item, attribute, defaultValue) {
+ dojo.unimplemented("dojo.data.core.Read.get");
+ var attributeValue = null;
+ return attributeValue;
+}, getValues:function (item, attribute) {
+ dojo.unimplemented("dojo.data.core.Read.getValues");
+ var array = null;
+ return array;
+}, getAttributes:function (item) {
+ dojo.unimplemented("dojo.data.core.Read.getAttributes");
+ var array = null;
+ return array;
+}, hasAttribute:function (item, attribute) {
+ dojo.unimplemented("dojo.data.core.Read.hasAttribute");
+ return false;
+}, containsValue:function (item, attribute, value) {
+ dojo.unimplemented("dojo.data.core.Read.containsValue");
+ return false;
+}, isItem:function (something) {
+ dojo.unimplemented("dojo.data.core.Read.isItem");
+ return false;
+}, isItemAvailable:function (something) {
+ dojo.unimplemented("dojo.data.core.Read.isItemAvailable");
+ return false;
+}, find:function (keywordArgs) {
+ dojo.unimplemented("dojo.data.core.Read.find");
+ var result = null;
+ return result;
+}, getIdentity:function (item) {
+ dojo.unimplemented("dojo.data.core.Read.getIdentity");
+ var itemIdentifyString = null;
+ return itemIdentifyString;
+}, findByIdentity:function (identity) {
+ dojo.unimplemented("dojo.data.core.Read.getByIdentity");
+ var item = null;
+ return item;
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/RemoteStore.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/RemoteStore.js
new file mode 100644
index 000000000..b05c764f2
--- /dev/null
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/RemoteStore.js
@@ -0,0 +1,352 @@
+/*
+ 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.data.core.RemoteStore");
+dojo.require("dojo.data.core.Read");
+dojo.require("dojo.data.core.Write");
+dojo.require("dojo.data.core.Result");
+dojo.require("dojo.experimental");
+dojo.require("dojo.Deferred");
+dojo.require("dojo.lang.declare");
+dojo.require("dojo.json");
+dojo.require("dojo.io.*");
+dojo.experimental("dojo.data.core.RemoteStore");
+dojo.lang.declare("dojo.data.core.RemoteStore", [dojo.data.core.Read, dojo.data.core.Write], {_datatypeMap:{}, _jsonRegistry:dojo.json.jsonRegistry, initializer:function (kwArgs) {
+ if (!kwArgs) {
+ kwArgs = {};
+ }
+ this._serverQueryUrl = kwArgs.queryUrl || "";
+ this._serverSaveUrl = kwArgs.saveUrl || "";
+ this._deleted = {};
+ this._changed = {};
+ this._added = {};
+ this._results = {};
+ this._data = {};
+ this._numItems = 0;
+}, _setupQueryRequest:function (result, requestKw) {
+ result.query = result.query || "";
+ requestKw.url = this._serverQueryUrl + encodeURIComponent(result.query);
+ requestKw.method = "get";
+ requestKw.mimetype = "text/json";
+}, _resultToQueryMetadata:function (serverResponseData) {
+ return serverResponseData;
+}, _resultToQueryData:function (serverResponseData) {
+ return serverResponseData.data;
+}, _remoteToLocalValues:function (attributes) {
+ for (var key in attributes) {
+ var values = attributes[key];
+ for (var i = 0; i < values.length; i++) {
+ var value = values[i];
+ var type = value.datatype || value.type;
+ if (type) {
+ var localValue = value.value;
+ if (this._datatypeMap[type]) {
+ localValue = this._datatypeMap[type](value);
+ }
+ values[i] = localValue;
+ }
+ }
+ }
+ return attributes;
+}, _queryToQueryKey:function (query) {
+ if (typeof query == "string") {
+ return query;
+ } else {
+ return dojo.json.serialize(query);
+ }
+}, _assertIsItem:function (item) {
+ if (!this.isItem(item)) {
+ throw new Error("dojo.data.RemoteStore: a function was passed an item argument that was not an item");
+ }
+}, get:function (item, attribute, defaultValue) {
+ var valueArray = this.getValues(item, attribute);
+ if (valueArray.length == 0) {
+ return defaultValue;
+ }
+ return valueArray[0];
+}, getValues:function (item, attribute) {
+ var itemIdentity = this.getIdentity(item);
+ this._assertIsItem(itemIdentity);
+ var changes = this._changed[itemIdentity];
+ if (changes) {
+ var newvalues = changes[attribute];
+ if (newvalues !== undefined) {
+ return newvalues;
+ } else {
+ return [];
+ }
+ }
+ return this._data[itemIdentity][0][attribute];
+}, getAttributes:function (item) {
+ var itemIdentity = this.getIdentity(item);
+ if (!itemIdentity) {
+ return undefined;
+ }
+ var atts = [];
+ var attrDict = this._data[itemIdentity][0];
+ for (var att in attrDict) {
+ atts.push(att);
+ }
+ return atts;
+}, hasAttribute:function (item, attribute) {
+ var valueArray = this.getValues(item, attribute);
+ return valueArray.length ? true : false;
+}, containsValue:function (item, attribute, value) {
+ var valueArray = this.getValues(item, attribute);
+ for (var i = 0; i < valueArray.length; i++) {
+ if (valueArray[i] == value) {
+ return true;
+ }
+ }
+ return false;
+}, isItem:function (something) {
+ if (!something) {
+ return false;
+ }
+ var itemIdentity = something;
+ if (this._deleted[itemIdentity]) {
+ return false;
+ }
+ if (this._data[itemIdentity]) {
+ return true;
+ }
+ if (this._added[itemIdentity]) {
+ return true;
+ }
+ return false;
+}, find:function (keywordArgs) {
+ var result = null;
+ if (keywordArgs instanceof dojo.data.core.Result) {
+ result = keywordArgs;
+ result.store = this;
+ } else {
+ result = new dojo.data.core.Result(keywordArgs, this);
+ }
+ var query = result.query;
+ var self = this;
+ var bindfunc = function (type, data, evt) {
+ var scope = result.scope || dj_global;
+ if (type == "load") {
+ result.resultMetadata = self._resultToQueryMetadata(data);
+ var dataDict = self._resultToQueryData(data);
+ if (result.onbegin) {
+ result.onbegin.call(scope, result);
+ }
+ var count = 0;
+ var resultData = [];
+ var newItemCount = 0;
+ for (var key in dataDict) {
+ if (result._aborted) {
+ break;
+ }
+ if (!self._deleted[key]) {
+ var values = dataDict[key];
+ var attributeDict = self._remoteToLocalValues(values);
+ var existingValue = self._data[key];
+ var refCount = 1;
+ if (existingValue) {
+ refCount = ++existingValue[1];
+ } else {
+ newItemCount++;
+ }
+ self._data[key] = [attributeDict, refCount];
+ resultData.push(key);
+ count++;
+ if (result.onnext) {
+ result.onnext.call(scope, key, result);
+ }
+ }
+ }
+ self._results[self._queryToQueryKey(query)] = resultData;
+ self._numItems += newItemCount;
+ result.length = count;
+ if (result.saveResult) {
+ result.items = resultData;
+ }
+ if (!result._aborted && result.oncompleted) {
+ result.oncompleted.call(scope, result);
+ }
+ } else {
+ if (type == "error" || type == "timeout") {
+ dojo.debug("find error: " + dojo.json.serialize(data));
+ if (result.onerror) {
+ result.onerror.call(scope, data);
+ }
+ }
+ }
+ };
+ var bindKw = keywordArgs.bindArgs || {};
+ bindKw.sync = result.sync;
+ bindKw.handle = bindfunc;
+ this._setupQueryRequest(result, bindKw);
+ var request = dojo.io.bind(bindKw);
+ result._abortFunc = request.abort;
+ return result;
+}, getIdentity:function (item) {
+ if (!this.isItem(item)) {
+ return null;
+ }
+ return (item.id ? item.id : item);
+}, newItem:function (attributes, keywordArgs) {
+ var itemIdentity = keywordArgs["identity"];
+ if (this._deleted[itemIdentity]) {
+ delete this._deleted[itemIdentity];
+ } else {
+ this._added[itemIdentity] = 1;
+ }
+ if (attributes) {
+ for (var attribute in attributes) {
+ var valueOrArrayOfValues = attributes[attribute];
+ if (dojo.lang.isArray(valueOrArrayOfValues)) {
+ this.setValues(itemIdentity, attribute, valueOrArrayOfValues);
+ } else {
+ this.set(itemIdentity, attribute, valueOrArrayOfValues);
+ }
+ }
+ }
+ return {id:itemIdentity};
+}, deleteItem:function (item) {
+ var identity = this.getIdentity(item);
+ if (!identity) {
+ return false;
+ }
+ if (this._added[identity]) {
+ delete this._added[identity];
+ } else {
+ this._deleted[identity] = 1;
+ }
+ if (this._changed[identity]) {
+ delete this._changed[identity];
+ }
+ return true;
+}, setValues:function (item, attribute, values) {
+ var identity = this.getIdentity(item);
+ if (!identity) {
+ return undefined;
+ }
+ var changes = this._changed[identity];
+ if (!changes) {
+ changes = {};
+ this._changed[identity] = changes;
+ }
+ changes[attribute] = values;
+ return true;
+}, set:function (item, attribute, value) {
+ return this.setValues(item, attribute, [value]);
+}, unsetAttribute:function (item, attribute) {
+ return this.setValues(item, attribute, []);
+}, _initChanges:function () {
+ this._deleted = {};
+ this._changed = {};
+ this._added = {};
+}, _setupSaveRequest:function (saveKeywordArgs, requestKw) {
+ requestKw.url = this._serverSaveUrl;
+ requestKw.method = "post";
+ requestKw.mimetype = "text/plain";
+ var deleted = [];
+ for (var key in this._deleted) {
+ deleted.push(key);
+ }
+ var saveStruct = {"changed":this._changed, "deleted":deleted};
+ var oldRegistry = dojo.json.jsonRegistry;
+ dojo.json.jsonRegistry = this._jsonRegistry;
+ var jsonString = dojo.json.serialize(saveStruct);
+ dojo.json.jsonRegistry = oldRegistry;
+ requestKw.postContent = jsonString;
+}, save:function (keywordArgs) {
+ keywordArgs = keywordArgs || {};
+ var result = new dojo.Deferred();
+ var self = this;
+ var bindfunc = function (type, data, evt) {
+ if (type == "load") {
+ if (result.fired == 1) {
+ return;
+ }
+ var key = null;
+ for (key in self._added) {
+ if (!self._data[key]) {
+ self._data[key] = [{}, 1];
+ }
+ }
+ for (key in self._changed) {
+ var existing = self._data[key];
+ var changes = self._changed[key];
+ if (existing) {
+ existing[0] = changes;
+ } else {
+ self._data[key] = [changes, 1];
+ }
+ }
+ for (key in self._deleted) {
+ if (self._data[key]) {
+ delete self._data[key];
+ }
+ }
+ self._initChanges();
+ result.callback(true);
+ } else {
+ if (type == "error" || type == "timeout") {
+ result.errback(data);
+ }
+ }
+ };
+ var bindKw = {sync:keywordArgs["sync"], handle:bindfunc};
+ this._setupSaveRequest(keywordArgs, bindKw);
+ var request = dojo.io.bind(bindKw);
+ result.canceller = function (deferred) {
+ request.abort();
+ };
+ return result;
+}, revert:function () {
+ this._initChanges();
+ return true;
+}, isDirty:function (item) {
+ if (item) {
+ var identity = item.id || item;
+ return this._deleted[identity] || this._changed[identity];
+ } else {
+ var key = null;
+ for (key in this._changed) {
+ return true;
+ }
+ for (key in this._deleted) {
+ return true;
+ }
+ for (key in this._added) {
+ return true;
+ }
+ return false;
+ }
+}, createReference:function (idstring) {
+ return {id:idstring};
+}, getSize:function () {
+ return this._numItems;
+}, forgetResults:function (query) {
+ var queryKey = this._queryToQueryKey(query);
+ var results = this._results[queryKey];
+ if (!results) {
+ return false;
+ }
+ var removed = 0;
+ for (var i = 0; i < results.length; i++) {
+ var key = results[i];
+ var existingValue = this._data[key];
+ if (existingValue[1] <= 1) {
+ delete this._data[key];
+ removed++;
+ } else {
+ existingValue[1] = --existingValue[1];
+ }
+ }
+ delete this._results[queryKey];
+ this._numItems -= removed;
+ return true;
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/Result.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/Result.js
new file mode 100644
index 000000000..5300fa99f
--- /dev/null
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/Result.js
@@ -0,0 +1,34 @@
+/*
+ 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.data.core.Result");
+dojo.require("dojo.lang.declare");
+dojo.require("dojo.experimental");
+dojo.experimental("dojo.data.core.Result");
+dojo.declare("dojo.data.core.Result", null, {initializer:function (keywordArgs, store) {
+ this.fromKwArgs(keywordArgs || {});
+ this.items = null;
+ this.resultMetadata = null;
+ this.length = -1;
+ this.store = store;
+ this._aborted = false;
+ this._abortFunc = null;
+}, sync:true, abort:function () {
+ this._aborted = true;
+ if (this._abortFunc) {
+ this._abortFunc();
+ }
+}, fromKwArgs:function (kwArgs) {
+ if (typeof kwArgs.saveResult == "undefined") {
+ this.saveResult = kwArgs.onnext ? false : true;
+ }
+ dojo.lang.mixin(this, kwArgs);
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/Write.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/Write.js
new file mode 100644
index 000000000..5d2b9796a
--- /dev/null
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/core/Write.js
@@ -0,0 +1,42 @@
+/*
+ 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.data.core.Write");
+dojo.require("dojo.data.core.Read");
+dojo.require("dojo.lang.declare");
+dojo.require("dojo.experimental");
+dojo.experimental("dojo.data.core.Write");
+dojo.declare("dojo.data.core.Write", dojo.data.core.Read, {newItem:function (keywordArgs) {
+ var newItem;
+ dojo.unimplemented("dojo.data.core.Write.newItem");
+ return newItem;
+}, deleteItem:function (item) {
+ dojo.unimplemented("dojo.data.core.Write.deleteItem");
+ return false;
+}, set:function (item, attribute, value) {
+ dojo.unimplemented("dojo.data.core.Write.set");
+ return false;
+}, setValues:function (item, attribute, values) {
+ dojo.unimplemented("dojo.data.core.Write.setValues");
+ return false;
+}, unsetAttribute:function (item, attribute) {
+ dojo.unimplemented("dojo.data.core.Write.clear");
+ return false;
+}, save:function () {
+ dojo.unimplemented("dojo.data.core.Write.save");
+ return false;
+}, revert:function () {
+ dojo.unimplemented("dojo.data.core.Write.revert");
+ return false;
+}, isDirty:function (item) {
+ dojo.unimplemented("dojo.data.core.Write.isDirty");
+ return false;
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Attribute.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Attribute.js
index 3c0a4ceb1..ae260d89c 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Attribute.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Attribute.js
@@ -11,52 +11,23 @@
dojo.provide("dojo.data.old.Attribute");
dojo.require("dojo.data.old.Item");
dojo.require("dojo.lang.assert");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.Attribute = function(/* dojo.data.old.provider.Base */ dataProvider, /* string */ attributeId) {
- /**
- * summary:
- * An Attribute object represents something like a column in
- * a relational database.
- */
- dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional: true});
+dojo.data.old.Attribute = function (dataProvider, attributeId) {
+ dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional:true});
dojo.lang.assertType(attributeId, String);
dojo.data.old.Item.call(this, dataProvider);
this._attributeId = attributeId;
};
dojo.inherits(dojo.data.old.Attribute, dojo.data.old.Item);
-
-// -------------------------------------------------------------------
-// Public instance methods
-// -------------------------------------------------------------------
-dojo.data.old.Attribute.prototype.toString = function() {
- return this._attributeId; // string
+dojo.data.old.Attribute.prototype.toString = function () {
+ return this._attributeId;
+};
+dojo.data.old.Attribute.prototype.getAttributeId = function () {
+ return this._attributeId;
+};
+dojo.data.old.Attribute.prototype.getType = function () {
+ return this.get("type");
+};
+dojo.data.old.Attribute.prototype.setType = function (type) {
+ this.set("type", type);
};
-dojo.data.old.Attribute.prototype.getAttributeId = function() {
- /**
- * summary:
- * Returns the string token that uniquely identifies this
- * attribute within the context of a data provider.
- * For a data provider that accesses relational databases,
- * typical attributeIds might be tokens like "name", "age",
- * "ssn", or "dept_key".
- */
- return this._attributeId; // string
-};
-
-dojo.data.old.Attribute.prototype.getType = function() {
- /**
- * summary: Returns the data type of the values of this attribute.
- */
- return this.get('type'); // dojo.data.old.Type or null
-};
-
-dojo.data.old.Attribute.prototype.setType = function(/* dojo.data.old.Type or null */ type) {
- /**
- * summary: Sets the data type for this attribute.
- */
- this.set('type', type);
-};
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Item.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Item.js
index 0a2df32a0..efa8e3acc 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Item.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Item.js
@@ -13,44 +13,14 @@ dojo.require("dojo.data.old.Observable");
dojo.require("dojo.data.old.Value");
dojo.require("dojo.lang.common");
dojo.require("dojo.lang.assert");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.Item = function(/* dojo.data.old.provider.Base */ dataProvider) {
- /**
- * summary:
- * An Item has attributes and attribute values, sort of like
- * a record in a database, or a 'struct' in C. Instances of
- * the Item class know how to store and retrieve their
- * attribute values.
- */
- dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional: true});
+dojo.data.old.Item = function (dataProvider) {
+ dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional:true});
dojo.data.old.Observable.call(this);
this._dataProvider = dataProvider;
this._dictionaryOfAttributeValues = {};
};
dojo.inherits(dojo.data.old.Item, dojo.data.old.Observable);
-
-// -------------------------------------------------------------------
-// Public class methods
-// -------------------------------------------------------------------
-dojo.data.old.Item.compare = function(/* dojo.data.old.Item */ itemOne, /* dojo.data.old.Item */ itemTwo) {
- /**
- * summary:
- * Given two Items to compare, this method returns 0, 1, or -1.
- * This method is designed to be used by sorting routines, like
- * the JavaScript built-in Array sort() method.
- *
- * Example:
- *
- * var a = dataProvider.newItem("kermit");
- * var b = dataProvider.newItem("elmo");
- * var c = dataProvider.newItem("grover");
- * var array = new Array(a, b, c);
- * array.sort(dojo.data.old.Item.compare);
- *
- */
+dojo.data.old.Item.compare = function (itemOne, itemTwo) {
dojo.lang.assertType(itemOne, dojo.data.old.Item);
if (!dojo.lang.isOfType(itemTwo, dojo.data.old.Item)) {
return -1;
@@ -62,7 +32,7 @@ dojo.data.old.Item.compare = function(/* dojo.data.old.Item */ itemOne, /* dojo.
var attributeArrayTwo = itemTwo.getAttributes();
if (attributeArrayOne.length != attributeArrayTwo.length) {
if (attributeArrayOne.length > attributeArrayTwo.length) {
- return 1;
+ return 1;
} else {
return -1;
}
@@ -77,7 +47,7 @@ dojo.data.old.Item.compare = function(/* dojo.data.old.Item */ itemOne, /* dojo.
}
if (arrayOfValuesOne.length != arrayOfValuesTwo.length) {
if (arrayOfValuesOne.length > arrayOfValuesTwo.length) {
- return 1;
+ return 1;
} else {
return -1;
}
@@ -92,20 +62,13 @@ dojo.data.old.Item.compare = function(/* dojo.data.old.Item */ itemOne, /* dojo.
}
} else {
if (nameOne > nameTwo) {
- return 1;
+ return 1;
} else {
- return -1; // 0, 1, or -1
+ return -1;
}
}
};
-
-// -------------------------------------------------------------------
-// Public instance methods
-// -------------------------------------------------------------------
-dojo.data.old.Item.prototype.toString = function() {
- /**
- * Returns a simple string representation of the item.
- */
+dojo.data.old.Item.prototype.toString = function () {
var arrayOfStrings = [];
var attributes = this.getAttributes();
for (var i in attributes) {
@@ -115,109 +78,77 @@ dojo.data.old.Item.prototype.toString = function() {
if (arrayOfValues.length == 1) {
valueString = arrayOfValues[0];
} else {
- valueString = '[';
- valueString += arrayOfValues.join(', ');
- valueString += ']';
+ valueString = "[";
+ valueString += arrayOfValues.join(", ");
+ valueString += "]";
}
- arrayOfStrings.push(' ' + attribute + ': ' + valueString);
+ arrayOfStrings.push(" " + attribute + ": " + valueString);
}
- var returnString = '{ ';
- returnString += arrayOfStrings.join(',\n');
- returnString += ' }';
- return returnString; // string
+ var returnString = "{ ";
+ returnString += arrayOfStrings.join(",\n");
+ returnString += " }";
+ return returnString;
};
-
-dojo.data.old.Item.prototype.compare = function(/* dojo.data.old.Item */ otherItem) {
- /**
- * summary: Compares this Item to another Item, and returns 0, 1, or -1.
- */
- return dojo.data.old.Item.compare(this, otherItem); // 0, 1, or -1
+dojo.data.old.Item.prototype.compare = function (otherItem) {
+ return dojo.data.old.Item.compare(this, otherItem);
};
-
-dojo.data.old.Item.prototype.isEqual = function(/* dojo.data.old.Item */ otherItem) {
- /**
- * summary: Returns true if this Item is equal to the otherItem, or false otherwise.
- */
- return (this.compare(otherItem) == 0); // boolean
+dojo.data.old.Item.prototype.isEqual = function (otherItem) {
+ return (this.compare(otherItem) == 0);
};
-
-dojo.data.old.Item.prototype.getName = function() {
- return this.get('name');
+dojo.data.old.Item.prototype.getName = function () {
+ return this.get("name");
};
-
-dojo.data.old.Item.prototype.get = function(/* string or dojo.data.old.Attribute */ attributeId) {
- /**
- * summary: Returns a single literal value, like "foo" or 33.
- */
- // dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+dojo.data.old.Item.prototype.get = function (attributeId) {
var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
if (dojo.lang.isUndefined(literalOrValueOrArray)) {
- return null; // null
+ return null;
}
if (literalOrValueOrArray instanceof dojo.data.old.Value) {
- return literalOrValueOrArray.getValue(); // literal
+ return literalOrValueOrArray.getValue();
}
if (dojo.lang.isArray(literalOrValueOrArray)) {
var dojoDataValue = literalOrValueOrArray[0];
- return dojoDataValue.getValue(); // literal
+ return dojoDataValue.getValue();
}
- return literalOrValueOrArray; // literal
+ return literalOrValueOrArray;
};
-
-dojo.data.old.Item.prototype.getValue = function(/* string or dojo.data.old.Attribute */ attributeId) {
- /**
- * summary: Returns a single instance of dojo.data.old.Value.
- */
- // dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+dojo.data.old.Item.prototype.getValue = function (attributeId) {
var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
if (dojo.lang.isUndefined(literalOrValueOrArray)) {
- return null; // null
+ return null;
}
if (literalOrValueOrArray instanceof dojo.data.old.Value) {
- return literalOrValueOrArray; // dojo.data.old.Value
+ return literalOrValueOrArray;
}
if (dojo.lang.isArray(literalOrValueOrArray)) {
var dojoDataValue = literalOrValueOrArray[0];
- return dojoDataValue; // dojo.data.old.Value
+ return dojoDataValue;
}
var literal = literalOrValueOrArray;
dojoDataValue = new dojo.data.old.Value(literal);
this._dictionaryOfAttributeValues[attributeId] = dojoDataValue;
- return dojoDataValue; // dojo.data.old.Value
+ return dojoDataValue;
};
-
-dojo.data.old.Item.prototype.getValues = function(/* string or dojo.data.old.Attribute */ attributeId) {
- /**
- * summary: Returns an array of dojo.data.old.Value objects.
- */
- // dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+dojo.data.old.Item.prototype.getValues = function (attributeId) {
var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
if (dojo.lang.isUndefined(literalOrValueOrArray)) {
- return null; // null
+ return null;
}
if (literalOrValueOrArray instanceof dojo.data.old.Value) {
var array = [literalOrValueOrArray];
this._dictionaryOfAttributeValues[attributeId] = array;
- return array; // Array
+ return array;
}
if (dojo.lang.isArray(literalOrValueOrArray)) {
- return literalOrValueOrArray; // Array
+ return literalOrValueOrArray;
}
var literal = literalOrValueOrArray;
var dojoDataValue = new dojo.data.old.Value(literal);
array = [dojoDataValue];
this._dictionaryOfAttributeValues[attributeId] = array;
- return array; // Array
+ return array;
};
-
-dojo.data.old.Item.prototype.load = function(/* string or dojo.data.old.Attribute */ attributeId, /* anything */ value) {
- /**
- * summary:
- * Used for loading an attribute value into an item when
- * the item is first being loaded into memory from some
- * data store (such as a file).
- */
- // dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+dojo.data.old.Item.prototype.load = function (attributeId, value) {
this._dataProvider.registerAttribute(attributeId);
var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
if (dojo.lang.isUndefined(literalOrValueOrArray)) {
@@ -241,40 +172,19 @@ dojo.data.old.Item.prototype.load = function(/* string or dojo.data.old.Attribut
array = [dojoDataValue, value];
this._dictionaryOfAttributeValues[attributeId] = array;
};
-
-dojo.data.old.Item.prototype.set = function(/* string or dojo.data.old.Attribute */ attributeId, /* anything */ value) {
- /**
- * summary:
- * Used for setting an attribute value as a result of a
- * user action.
- */
- // dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+dojo.data.old.Item.prototype.set = function (attributeId, value) {
this._dataProvider.registerAttribute(attributeId);
this._dictionaryOfAttributeValues[attributeId] = value;
this._dataProvider.noteChange(this, attributeId, value);
};
-
-dojo.data.old.Item.prototype.setValue = function(/* string or dojo.data.old.Attribute */ attributeId, /* dojo.data.old.Value */ value) {
+dojo.data.old.Item.prototype.setValue = function (attributeId, value) {
this.set(attributeId, value);
};
-
-dojo.data.old.Item.prototype.addValue = function(/* string or dojo.data.old.Attribute */ attributeId, /* anything */ value) {
- /**
- * summary:
- * Used for adding an attribute value as a result of a
- * user action.
- */
+dojo.data.old.Item.prototype.addValue = function (attributeId, value) {
this.load(attributeId, value);
this._dataProvider.noteChange(this, attributeId, value);
};
-
-dojo.data.old.Item.prototype.setValues = function(/* string or dojo.data.old.Attribute */ attributeId, /* Array */ arrayOfValues) {
- /**
- * summary:
- * Used for setting an array of attribute values as a result of a
- * user action.
- */
- // dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
+dojo.data.old.Item.prototype.setValues = function (attributeId, arrayOfValues) {
dojo.lang.assertType(arrayOfValues, Array);
this._dataProvider.registerAttribute(attributeId);
var finalArray = [];
@@ -288,40 +198,24 @@ dojo.data.old.Item.prototype.setValues = function(/* string or dojo.data.old.Att
this._dataProvider.noteChange(this, attributeId, value);
}
};
-
-dojo.data.old.Item.prototype.getAttributes = function() {
- /**
- * summary:
- * Returns an array containing all of the attributes for which
- * this item has attribute values.
- */
+dojo.data.old.Item.prototype.getAttributes = function () {
var arrayOfAttributes = [];
for (var key in this._dictionaryOfAttributeValues) {
arrayOfAttributes.push(this._dataProvider.getAttribute(key));
}
- return arrayOfAttributes; // Array
+ return arrayOfAttributes;
};
-
-dojo.data.old.Item.prototype.hasAttribute = function(/* string or dojo.data.old.Attribute */ attributeId) {
- /**
- * summary: Returns true if the given attribute of the item has been assigned any value.
- */
- // dojo.lang.assertType(attributeId, [String, dojo.data.old.Attribute]);
- return (attributeId in this._dictionaryOfAttributeValues); // boolean
+dojo.data.old.Item.prototype.hasAttribute = function (attributeId) {
+ return (attributeId in this._dictionaryOfAttributeValues);
};
-
-dojo.data.old.Item.prototype.hasAttributeValue = function(/* string or dojo.data.old.Attribute */ attributeId, /* anything */ value) {
- /**
- * summary: Returns true if the given attribute of the item has been assigned the given value.
- */
+dojo.data.old.Item.prototype.hasAttributeValue = function (attributeId, value) {
var arrayOfValues = this.getValues(attributeId);
for (var i in arrayOfValues) {
var candidateValue = arrayOfValues[i];
if (candidateValue.isEqual(value)) {
- return true; // boolean
+ return true;
}
}
- return false; // boolean
+ return false;
};
-
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Kind.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Kind.js
index d0d33395d..5226129ab 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Kind.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Kind.js
@@ -10,19 +10,8 @@
dojo.provide("dojo.data.old.Kind");
dojo.require("dojo.data.old.Item");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.Kind = function(/* dojo.data.old.provider.Base */ dataProvider) {
- /**
- * summary:
- * A Kind represents a kind of item. In the dojo data model
- * the item Snoopy might belong to the 'kind' Dog, where in
- * a Java program the object Snoopy would belong to the 'class'
- * Dog, and in MySQL the record for Snoopy would be in the
- * table Dog.
- */
+dojo.data.old.Kind = function (dataProvider) {
dojo.data.old.Item.call(this, dataProvider);
};
dojo.inherits(dojo.data.old.Kind, dojo.data.old.Item);
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Observable.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Observable.js
index 92ed9730f..70c30f1b7 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Observable.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Observable.js
@@ -11,21 +11,9 @@
dojo.provide("dojo.data.old.Observable");
dojo.require("dojo.lang.common");
dojo.require("dojo.lang.assert");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.Observable = function() {
+dojo.data.old.Observable = function () {
};
-
-// -------------------------------------------------------------------
-// Public instance methods
-// -------------------------------------------------------------------
-dojo.data.old.Observable.prototype.addObserver = function(/* object */ observer) {
- /**
- * summary: Registers an object as an observer of this item,
- * so that the object will be notified when the item changes.
- */
+dojo.data.old.Observable.prototype.addObserver = function (observer) {
dojo.lang.assertType(observer, Object);
dojo.lang.assertType(observer.observedObjectHasChanged, Function);
if (!this._arrayOfObservers) {
@@ -35,12 +23,7 @@ dojo.data.old.Observable.prototype.addObserver = function(/* object */ observer)
this._arrayOfObservers.push(observer);
}
};
-
-dojo.data.old.Observable.prototype.removeObserver = function(/* object */ observer) {
- /**
- * summary: Removes the observer registration for a previously
- * registered object.
- */
+dojo.data.old.Observable.prototype.removeObserver = function (observer) {
if (!this._arrayOfObservers) {
return;
}
@@ -49,11 +32,7 @@ dojo.data.old.Observable.prototype.removeObserver = function(/* object */ observ
this._arrayOfObservers.splice(index, 1);
}
};
-
-dojo.data.old.Observable.prototype.getObservers = function() {
- /**
- * summary: Returns an array with all the observers of this item.
- */
- return this._arrayOfObservers; // Array or undefined
+dojo.data.old.Observable.prototype.getObservers = function () {
+ return this._arrayOfObservers;
};
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/ResultSet.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/ResultSet.js
index 14cee415c..9510c8d4a 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/ResultSet.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/ResultSet.js
@@ -11,19 +11,9 @@
dojo.provide("dojo.data.old.ResultSet");
dojo.require("dojo.lang.assert");
dojo.require("dojo.collections.Collections");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.ResultSet = function(/* dojo.data.old.provider.Base */ dataProvider, /* Array */ arrayOfItems) {
- /**
- * summary:
- * A ResultSet holds a collection of Items. A data provider
- * returns a ResultSet in reponse to a query.
- * (The name "Result Set" comes from the MySQL terminology.)
- */
- dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional: true});
- dojo.lang.assertType(arrayOfItems, Array, {optional: true});
+dojo.data.old.ResultSet = function (dataProvider, arrayOfItems) {
+ dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional:true});
+ dojo.lang.assertType(arrayOfItems, Array, {optional:true});
dojo.data.old.Observable.call(this);
this._dataProvider = dataProvider;
this._arrayOfItems = [];
@@ -32,39 +22,29 @@ dojo.data.old.ResultSet = function(/* dojo.data.old.provider.Base */ dataProvide
}
};
dojo.inherits(dojo.data.old.ResultSet, dojo.data.old.Observable);
-
-// -------------------------------------------------------------------
-// Public instance methods
-// -------------------------------------------------------------------
-dojo.data.old.ResultSet.prototype.toString = function() {
- var returnString = this._arrayOfItems.join(', ');
- return returnString; // string
+dojo.data.old.ResultSet.prototype.toString = function () {
+ var returnString = this._arrayOfItems.join(", ");
+ return returnString;
};
-
-dojo.data.old.ResultSet.prototype.toArray = function() {
- return this._arrayOfItems; // Array
+dojo.data.old.ResultSet.prototype.toArray = function () {
+ return this._arrayOfItems;
};
-
-dojo.data.old.ResultSet.prototype.getIterator = function() {
+dojo.data.old.ResultSet.prototype.getIterator = function () {
return new dojo.collections.Iterator(this._arrayOfItems);
};
-
-dojo.data.old.ResultSet.prototype.getLength = function() {
- return this._arrayOfItems.length; // integer
+dojo.data.old.ResultSet.prototype.getLength = function () {
+ return this._arrayOfItems.length;
};
-
-dojo.data.old.ResultSet.prototype.getItemAt = function(/* numeric */ index) {
+dojo.data.old.ResultSet.prototype.getItemAt = function (index) {
return this._arrayOfItems[index];
};
-
-dojo.data.old.ResultSet.prototype.indexOf = function(/* dojo.data.old.Item */ item) {
- return dojo.lang.indexOf(this._arrayOfItems, item); // integer
+dojo.data.old.ResultSet.prototype.indexOf = function (item) {
+ return dojo.lang.indexOf(this._arrayOfItems, item);
+};
+dojo.data.old.ResultSet.prototype.contains = function (item) {
+ return dojo.lang.inArray(this._arrayOfItems, item);
+};
+dojo.data.old.ResultSet.prototype.getDataProvider = function () {
+ return this._dataProvider;
};
-dojo.data.old.ResultSet.prototype.contains = function(/* dojo.data.old.Item */ item) {
- return dojo.lang.inArray(this._arrayOfItems, item); // boolean
-};
-
-dojo.data.old.ResultSet.prototype.getDataProvider = function() {
- return this._dataProvider; // dojo.data.old.provider.Base
-};
\ No newline at end of file
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Type.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Type.js
index 19f175583..ca86cc3c4 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Type.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Type.js
@@ -10,16 +10,8 @@
dojo.provide("dojo.data.old.Type");
dojo.require("dojo.data.old.Item");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.Type = function(/* dojo.data.old.provider.Base */ dataProvider) {
- /**
- * summary:
- * A Type represents a type of value, like Text, Number, Picture,
- * or Varchar.
- */
+dojo.data.old.Type = function (dataProvider) {
dojo.data.old.Item.call(this, dataProvider);
};
dojo.inherits(dojo.data.old.Type, dojo.data.old.Item);
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Value.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Value.js
index 7ff1f6fc3..23d870656 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Value.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/Value.js
@@ -10,46 +10,24 @@
dojo.provide("dojo.data.old.Value");
dojo.require("dojo.lang.assert");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.Value = function(/* anything */ value) {
- /**
- * summary:
- * A Value represents a simple literal value (like "foo" or 334),
- * or a reference value (a pointer to an Item).
- */
+dojo.data.old.Value = function (value) {
this._value = value;
this._type = null;
};
-
-// -------------------------------------------------------------------
-// Public instance methods
-// -------------------------------------------------------------------
-dojo.data.old.Value.prototype.toString = function() {
- return this._value.toString(); // string
+dojo.data.old.Value.prototype.toString = function () {
+ return this._value.toString();
+};
+dojo.data.old.Value.prototype.getValue = function () {
+ return this._value;
+};
+dojo.data.old.Value.prototype.getType = function () {
+ dojo.unimplemented("dojo.data.old.Value.prototype.getType");
+ return this._type;
+};
+dojo.data.old.Value.prototype.compare = function () {
+ dojo.unimplemented("dojo.data.old.Value.prototype.compare");
+};
+dojo.data.old.Value.prototype.isEqual = function () {
+ dojo.unimplemented("dojo.data.old.Value.prototype.isEqual");
};
-dojo.data.old.Value.prototype.getValue = function() {
- /**
- * summary: Returns the value itself.
- */
- return this._value; // anything
-};
-
-dojo.data.old.Value.prototype.getType = function() {
- /**
- * summary: Returns the data type of the value.
- */
- dojo.unimplemented('dojo.data.old.Value.prototype.getType');
- return this._type; // dojo.data.old.Type
-};
-
-dojo.data.old.Value.prototype.compare = function() {
- dojo.unimplemented('dojo.data.old.Value.prototype.compare');
-};
-
-dojo.data.old.Value.prototype.isEqual = function() {
- dojo.unimplemented('dojo.data.old.Value.prototype.isEqual');
-};
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/__package__.js
index 673d3e939..c9375eee2 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/__package__.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/__package__.js
@@ -9,14 +9,7 @@
*/
dojo.require("dojo.experimental");
-
dojo.experimental("dojo.data.old.*");
-dojo.kwCompoundRequire({
- common: [
- "dojo.data.old.Item",
- "dojo.data.old.ResultSet",
- "dojo.data.old.provider.FlatFile"
- ]
-});
+dojo.kwCompoundRequire({common:["dojo.data.old.Item", "dojo.data.old.ResultSet", "dojo.data.old.provider.FlatFile"]});
dojo.provide("dojo.data.old.*");
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/format/Csv.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/format/Csv.js
index 44cfc78d3..c2a2dcf85 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/format/Csv.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/format/Csv.js
@@ -10,70 +10,39 @@
dojo.provide("dojo.data.old.format.Csv");
dojo.require("dojo.lang.assert");
-
-
-dojo.data.old.format.Csv = new function() {
-
- // -------------------------------------------------------------------
- // Public functions
- // -------------------------------------------------------------------
- this.getArrayStructureFromCsvFileContents = function(/* string */ csvFileContents) {
- /**
- * Given a string containing CSV records, this method parses
- * the string and returns a data structure containing the parsed
- * content. The data structure we return is an array of length
- * R, where R is the number of rows (lines) in the CSV data. The
- * return array contains one sub-array for each CSV line, and each
- * sub-array contains C string values, where C is the number of
- * columns in the CSV data.
- *
- * For example, given this CSV string as input:
- *
- * "Title, Year, Producer \n Alien, 1979, Ridley Scott \n Blade Runner, 1982, Ridley Scott"
- *
- * We will return this data structure:
- *
- * [["Title", "Year", "Producer"]
- * ["Alien", "1979", "Ridley Scott"],
- * ["Blade Runner", "1982", "Ridley Scott"]]
- *
- */
+dojo.data.old.format.Csv = new function () {
+ this.getArrayStructureFromCsvFileContents = function (csvFileContents) {
dojo.lang.assertType(csvFileContents, String);
-
var lineEndingCharacters = new RegExp("\r\n|\n|\r");
- var leadingWhiteSpaceCharacters = new RegExp("^\\s+",'g');
- var trailingWhiteSpaceCharacters = new RegExp("\\s+$",'g');
- var doubleQuotes = new RegExp('""','g');
+ var leadingWhiteSpaceCharacters = new RegExp("^\\s+", "g");
+ var trailingWhiteSpaceCharacters = new RegExp("\\s+$", "g");
+ var doubleQuotes = new RegExp("\"\"", "g");
var arrayOfOutputRecords = [];
-
var arrayOfInputLines = csvFileContents.split(lineEndingCharacters);
for (var i in arrayOfInputLines) {
var singleLine = arrayOfInputLines[i];
if (singleLine.length > 0) {
- var listOfFields = singleLine.split(',');
+ var listOfFields = singleLine.split(",");
var j = 0;
while (j < listOfFields.length) {
var space_field_space = listOfFields[j];
- var field_space = space_field_space.replace(leadingWhiteSpaceCharacters, ''); // trim leading whitespace
- var field = field_space.replace(trailingWhiteSpaceCharacters, ''); // trim trailing whitespace
+ var field_space = space_field_space.replace(leadingWhiteSpaceCharacters, "");
+ var field = field_space.replace(trailingWhiteSpaceCharacters, "");
var firstChar = field.charAt(0);
var lastChar = field.charAt(field.length - 1);
var secondToLastChar = field.charAt(field.length - 2);
var thirdToLastChar = field.charAt(field.length - 3);
- if ((firstChar == '"') &&
- ((lastChar != '"') ||
- ((lastChar == '"') && (secondToLastChar == '"') && (thirdToLastChar != '"')) )) {
- if (j+1 === listOfFields.length) {
- // alert("The last field in record " + i + " is corrupted:\n" + field);
+ if ((firstChar == "\"") && ((lastChar != "\"") || ((lastChar == "\"") && (secondToLastChar == "\"") && (thirdToLastChar != "\"")))) {
+ if (j + 1 === listOfFields.length) {
return null;
}
- var nextField = listOfFields[j+1];
- listOfFields[j] = field_space + ',' + nextField;
- listOfFields.splice(j+1, 1); // delete element [j+1] from the list
+ var nextField = listOfFields[j + 1];
+ listOfFields[j] = field_space + "," + nextField;
+ listOfFields.splice(j + 1, 1);
} else {
- if ((firstChar == '"') && (lastChar == '"')) {
- field = field.slice(1, (field.length - 1)); // trim the " characters off the ends
- field = field.replace(doubleQuotes, '"'); // replace "" with "
+ if ((firstChar == "\"") && (lastChar == "\"")) {
+ field = field.slice(1, (field.length - 1));
+ field = field.replace(doubleQuotes, "\"");
}
listOfFields[j] = field;
j += 1;
@@ -82,10 +51,9 @@ dojo.data.old.format.Csv = new function() {
arrayOfOutputRecords.push(listOfFields);
}
}
- return arrayOfOutputRecords; // Array
+ return arrayOfOutputRecords;
};
-
- this.loadDataProviderFromFileContents = function(/* dojo.data.old.provider.Base */ dataProvider, /* string */ csvFileContents) {
+ this.loadDataProviderFromFileContents = function (dataProvider, csvFileContents) {
dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base);
dojo.lang.assertType(csvFileContents, String);
var arrayOfArrays = this.getArrayStructureFromCsvFileContents(csvFileContents);
@@ -102,11 +70,10 @@ dojo.data.old.format.Csv = new function() {
}
}
};
-
- this.getCsvStringFromResultSet = function(/* dojo.data.old.ResultSet */ resultSet) {
- dojo.unimplemented('dojo.data.old.format.Csv.getCsvStringFromResultSet');
+ this.getCsvStringFromResultSet = function (resultSet) {
+ dojo.unimplemented("dojo.data.old.format.Csv.getCsvStringFromResultSet");
var csvString = null;
- return csvString; // String
+ return csvString;
};
-
}();
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/format/Json.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/format/Json.js
index 50d54eda1..9b1de2eb8 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/format/Json.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/format/Json.js
@@ -10,21 +10,15 @@
dojo.provide("dojo.data.old.format.Json");
dojo.require("dojo.lang.assert");
-
-dojo.data.old.format.Json = new function() {
-
- // -------------------------------------------------------------------
- // Public functions
- // -------------------------------------------------------------------
- this.loadDataProviderFromFileContents = function(/* dojo.data.old.provider.Base */ dataProvider, /* string */ jsonFileContents) {
+dojo.data.old.format.Json = new function () {
+ this.loadDataProviderFromFileContents = function (dataProvider, jsonFileContents) {
dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base);
dojo.lang.assertType(jsonFileContents, String);
var arrayOfJsonData = eval("(" + jsonFileContents + ")");
this.loadDataProviderFromArrayOfJsonData(dataProvider, arrayOfJsonData);
};
-
- this.loadDataProviderFromArrayOfJsonData = function(/* dojo.data.old.provider.Base */ dataProvider, /* Array */ arrayOfJsonData) {
- dojo.lang.assertType(arrayOfJsonData, Array, {optional: true});
+ this.loadDataProviderFromArrayOfJsonData = function (dataProvider, arrayOfJsonData) {
+ dojo.lang.assertType(arrayOfJsonData, Array, {optional:true});
if (arrayOfJsonData && (arrayOfJsonData.length > 0)) {
var firstRow = arrayOfJsonData[0];
dojo.lang.assertType(firstRow, [Array, "pureobject"]);
@@ -36,27 +30,12 @@ dojo.data.old.format.Json = new function() {
}
}
};
-
- this.getJsonStringFromResultSet = function(/* dojo.data.old.ResultSet */ resultSet) {
- dojo.unimplemented('dojo.data.old.format.Json.getJsonStringFromResultSet');
+ this.getJsonStringFromResultSet = function (resultSet) {
+ dojo.unimplemented("dojo.data.old.format.Json.getJsonStringFromResultSet");
var jsonString = null;
- return jsonString; // String
+ return jsonString;
};
-
- // -------------------------------------------------------------------
- // Private functions
- // -------------------------------------------------------------------
- function _loadDataProviderFromArrayOfArrays(/* dojo.data.old.provider.Base */ dataProvider, /* Array */ arrayOfJsonData) {
- /**
- * Example:
- * var arrayOfJsonStates = [
- * [ "abbr", "population", "name" ]
- * [ "WA", 5894121, "Washington" ],
- * [ "WV", 1808344, "West Virginia" ],
- * [ "WI", 5453896, "Wisconsin" ],
- * [ "WY", 493782, "Wyoming" ] ];
- * this._loadFromArrayOfArrays(arrayOfJsonStates);
- */
+ function _loadDataProviderFromArrayOfArrays(dataProvider, arrayOfJsonData) {
var arrayOfKeys = arrayOfJsonData[0];
for (var i = 1; i < arrayOfJsonData.length; ++i) {
var row = arrayOfJsonData[i];
@@ -68,18 +47,7 @@ dojo.data.old.format.Json = new function() {
}
}
}
-
- function _loadDataProviderFromArrayOfObjects(/* dojo.data.old.provider.Base */ dataProvider, /* Array */ arrayOfJsonData) {
- /**
- * Example:
- * var arrayOfJsonStates = [
- * { abbr: "WA", name: "Washington" },
- * { abbr: "WV", name: "West Virginia" },
- * { abbr: "WI", name: "Wisconsin", song: "On, Wisconsin!" },
- * { abbr: "WY", name: "Wyoming", cities: ["Lander", "Cheyenne", "Laramie"] } ];
- * this._loadFromArrayOfArrays(arrayOfJsonStates);
- */
- // dojo.debug("_loadDataProviderFromArrayOfObjects");
+ function _loadDataProviderFromArrayOfObjects(dataProvider, arrayOfJsonData) {
for (var i in arrayOfJsonData) {
var row = arrayOfJsonData[i];
var item = dataProvider.getNewItemToLoad();
@@ -90,7 +58,6 @@ dojo.data.old.format.Json = new function() {
for (var j in arrayOfValues) {
value = arrayOfValues[j];
item.load(key, value);
- // dojo.debug("loaded: " + key + " = " + value);
}
} else {
item.load(key, value);
@@ -98,6 +65,5 @@ dojo.data.old.format.Json = new function() {
}
}
}
-
}();
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/Base.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/Base.js
index 67509b0b5..2b64a9ad5 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/Base.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/Base.js
@@ -10,106 +10,63 @@
dojo.provide("dojo.data.old.provider.Base");
dojo.require("dojo.lang.assert");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.provider.Base = function() {
- /**
- * summary:
- * A Data Provider serves as a connection to some data source,
- * like a relational database. This data provider Base class
- * serves as an abstract superclass for other data provider
- * classes.
- */
+dojo.data.old.provider.Base = function () {
this._countOfNestedTransactions = 0;
this._changesInCurrentTransaction = null;
};
-
-// -------------------------------------------------------------------
-// Public instance methods
-// -------------------------------------------------------------------
-dojo.data.old.provider.Base.prototype.beginTransaction = function() {
- /**
- * Marks the beginning of a transaction.
- *
- * Each time you call beginTransaction() you open a new transaction,
- * which you need to close later using endTransaction(). Transactions
- * may be nested, but the beginTransaction and endTransaction calls
- * always need to come in pairs.
- */
+dojo.data.old.provider.Base.prototype.beginTransaction = function () {
if (this._countOfNestedTransactions === 0) {
this._changesInCurrentTransaction = [];
}
this._countOfNestedTransactions += 1;
};
-
-dojo.data.old.provider.Base.prototype.endTransaction = function() {
- /**
- * Marks the end of a transaction.
- */
+dojo.data.old.provider.Base.prototype.endTransaction = function () {
this._countOfNestedTransactions -= 1;
dojo.lang.assert(this._countOfNestedTransactions >= 0);
-
if (this._countOfNestedTransactions === 0) {
var listOfChangesMade = this._saveChanges();
this._changesInCurrentTransaction = null;
if (listOfChangesMade.length > 0) {
- // dojo.debug("endTransaction: " + listOfChangesMade.length + " changes made");
this._notifyObserversOfChanges(listOfChangesMade);
}
}
};
-
-dojo.data.old.provider.Base.prototype.getNewItemToLoad = function() {
- return this._newItem(); // dojo.data.old.Item
+dojo.data.old.provider.Base.prototype.getNewItemToLoad = function () {
+ return this._newItem();
};
-
-dojo.data.old.provider.Base.prototype.newItem = function(/* string */ itemName) {
- /**
- * Creates a new item.
- */
- dojo.lang.assertType(itemName, String, {optional: true});
+dojo.data.old.provider.Base.prototype.newItem = function (itemName) {
+ dojo.lang.assertType(itemName, String, {optional:true});
var item = this._newItem();
if (itemName) {
- item.set('name', itemName);
+ item.set("name", itemName);
}
- return item; // dojo.data.old.Item
+ return item;
};
-
-dojo.data.old.provider.Base.prototype.newAttribute = function(/* string */ attributeId) {
- /**
- * Creates a new attribute.
- */
- dojo.lang.assertType(attributeId, String, {optional: true});
+dojo.data.old.provider.Base.prototype.newAttribute = function (attributeId) {
+ dojo.lang.assertType(attributeId, String, {optional:true});
var attribute = this._newAttribute(attributeId);
- return attribute; // dojo.data.old.Attribute
+ return attribute;
};
-
-dojo.data.old.provider.Base.prototype.getAttribute = function(/* string */ attributeId) {
- dojo.unimplemented('dojo.data.old.provider.Base');
+dojo.data.old.provider.Base.prototype.getAttribute = function (attributeId) {
+ dojo.unimplemented("dojo.data.old.provider.Base");
var attribute;
- return attribute; // dojo.data.old.Attribute
+ return attribute;
};
-
-dojo.data.old.provider.Base.prototype.getAttributes = function() {
- dojo.unimplemented('dojo.data.old.provider.Base');
- return this._arrayOfAttributes; // Array
+dojo.data.old.provider.Base.prototype.getAttributes = function () {
+ dojo.unimplemented("dojo.data.old.provider.Base");
+ return this._arrayOfAttributes;
};
-
-dojo.data.old.provider.Base.prototype.fetchArray = function() {
- dojo.unimplemented('dojo.data.old.provider.Base');
- return []; // Array
+dojo.data.old.provider.Base.prototype.fetchArray = function () {
+ dojo.unimplemented("dojo.data.old.provider.Base");
+ return [];
};
-
-dojo.data.old.provider.Base.prototype.fetchResultSet = function() {
- dojo.unimplemented('dojo.data.old.provider.Base');
+dojo.data.old.provider.Base.prototype.fetchResultSet = function () {
+ dojo.unimplemented("dojo.data.old.provider.Base");
var resultSet;
- return resultSet; // dojo.data.old.ResultSet
+ return resultSet;
};
-
-dojo.data.old.provider.Base.prototype.noteChange = function(/* dojo.data.old.Item */ item, /* string or dojo.data.old.Attribute */ attribute, /* anything */ value) {
- var change = {item: item, attribute: attribute, value: value};
+dojo.data.old.provider.Base.prototype.noteChange = function (item, attribute, value) {
+ var change = {item:item, attribute:attribute, value:value};
if (this._countOfNestedTransactions === 0) {
this.beginTransaction();
this._changesInCurrentTransaction.push(change);
@@ -118,44 +75,27 @@ dojo.data.old.provider.Base.prototype.noteChange = function(/* dojo.data.old.Ite
this._changesInCurrentTransaction.push(change);
}
};
-
-dojo.data.old.provider.Base.prototype.addItemObserver = function(/* dojo.data.old.Item */ item, /* object */ observer) {
- /**
- * summary: Registers an object as an observer of an item,
- * so that the object will be notified when the item changes.
- */
+dojo.data.old.provider.Base.prototype.addItemObserver = function (item, observer) {
dojo.lang.assertType(item, dojo.data.old.Item);
item.addObserver(observer);
};
-
-dojo.data.old.provider.Base.prototype.removeItemObserver = function(/* dojo.data.old.Item */ item, /* object */ observer) {
- /**
- * summary: Removes the observer registration for a previously
- * registered object.
- */
+dojo.data.old.provider.Base.prototype.removeItemObserver = function (item, observer) {
dojo.lang.assertType(item, dojo.data.old.Item);
item.removeObserver(observer);
};
-
-// -------------------------------------------------------------------
-// Private instance methods
-// -------------------------------------------------------------------
-dojo.data.old.provider.Base.prototype._newItem = function() {
+dojo.data.old.provider.Base.prototype._newItem = function () {
var item = new dojo.data.old.Item(this);
- return item; // dojo.data.old.Item
+ return item;
};
-
-dojo.data.old.provider.Base.prototype._newAttribute = function(/* String */ attributeId) {
+dojo.data.old.provider.Base.prototype._newAttribute = function (attributeId) {
var attribute = new dojo.data.old.Attribute(this);
- return attribute; // dojo.data.old.Attribute
+ return attribute;
};
-
-dojo.data.old.provider.Base.prototype._saveChanges = function() {
+dojo.data.old.provider.Base.prototype._saveChanges = function () {
var arrayOfChangesMade = this._changesInCurrentTransaction;
- return arrayOfChangesMade; // Array
+ return arrayOfChangesMade;
};
-
-dojo.data.old.provider.Base.prototype._notifyObserversOfChanges = function(/* Array */ arrayOfChanges) {
+dojo.data.old.provider.Base.prototype._notifyObserversOfChanges = function (arrayOfChanges) {
var arrayOfResultSets = this._getResultSets();
for (var i in arrayOfChanges) {
var change = arrayOfChanges[i];
@@ -175,9 +115,8 @@ dojo.data.old.provider.Base.prototype._notifyObserversOfChanges = function(/* Ar
}
}
};
-
-dojo.data.old.provider.Base.prototype._getResultSets = function() {
- dojo.unimplemented('dojo.data.old.provider.Base');
- return []; // Array
+dojo.data.old.provider.Base.prototype._getResultSets = function () {
+ dojo.unimplemented("dojo.data.old.provider.Base");
+ return [];
};
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/Delicious.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/Delicious.js
index d5f354b9c..2d9858f20 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/Delicious.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/Delicious.js
@@ -11,75 +11,21 @@
dojo.provide("dojo.data.old.provider.Delicious");
dojo.require("dojo.data.old.provider.FlatFile");
dojo.require("dojo.data.old.format.Json");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.provider.Delicious = function() {
- /**
- * summary:
- * The Delicious Data Provider can be used to take data from
- * del.icio.us and make it available as dojo.data.old.Items
- * In order to use the Delicious Data Provider, you need
- * to have loaded a script tag that looks like this:
- *
- */
+dojo.data.old.provider.Delicious = function () {
dojo.data.old.provider.FlatFile.call(this);
- // Delicious = null;
if (Delicious && Delicious.posts) {
dojo.data.old.format.Json.loadDataProviderFromArrayOfJsonData(this, Delicious.posts);
} else {
- // document.write("");
- /*
- document.write("");
- document.write("");
- document.write("");
- fetchComplete();
- */
- // dojo.debug("Delicious line 29: constructor");
}
- var u = this.registerAttribute('u');
- var d = this.registerAttribute('d');
- var t = this.registerAttribute('t');
-
- u.load('name', 'Bookmark');
- d.load('name', 'Description');
- t.load('name', 'Tags');
-
- u.load('type', 'String');
- d.load('type', 'String');
- t.load('type', 'String');
+ var u = this.registerAttribute("u");
+ var d = this.registerAttribute("d");
+ var t = this.registerAttribute("t");
+ u.load("name", "Bookmark");
+ d.load("name", "Description");
+ t.load("name", "Tags");
+ u.load("type", "String");
+ d.load("type", "String");
+ t.load("type", "String");
};
dojo.inherits(dojo.data.old.provider.Delicious, dojo.data.old.provider.FlatFile);
-/********************************************************************
- * FIXME: the rest of this is work in progress
- *
-
-dojo.data.old.provider.Delicious.prototype.getNewItemToLoad = function() {
- var newItem = this._newItem();
- this._currentArray.push(newItem);
- return newItem; // dojo.data.old.Item
-};
-
-dojo.data.old.provider.Delicious.prototype.fetchArray = function(query) {
- if (!query) {
- query = "gumption";
- }
- this._currentArray = [];
- alert("Delicious line 60: loadDataProviderFromArrayOfJsonData");
- alert("Delicious line 61: " + dojo);
- var sourceUrl = "http://del.icio.us/feeds/json/" + query + "?count=8";
- document.write("");
- document.write("");
- document.write("");
- alert("line 66");
- dojo.data.old.format.Json.loadDataProviderFromArrayOfJsonData(this, Delicious.posts);
- return this._currentArray; // Array
-};
-
-callMe = function() {
- alert("callMe!");
-};
-
-*/
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/FlatFile.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/FlatFile.js
index fa95a11a1..f7b2f48b7 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/FlatFile.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/FlatFile.js
@@ -16,26 +16,16 @@ dojo.require("dojo.data.old.ResultSet");
dojo.require("dojo.data.old.format.Json");
dojo.require("dojo.data.old.format.Csv");
dojo.require("dojo.lang.assert");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.provider.FlatFile = function(/* keywords */ keywordParameters) {
- /**
- * summary:
- * A Json Data Provider knows how to read in simple JSON data
- * tables and make their contents accessable as Items.
- */
- dojo.lang.assertType(keywordParameters, "pureobject", {optional: true});
+dojo.data.old.provider.FlatFile = function (keywordParameters) {
+ dojo.lang.assertType(keywordParameters, "pureobject", {optional:true});
dojo.data.old.provider.Base.call(this);
this._arrayOfItems = [];
this._resultSet = null;
this._dictionaryOfAttributes = {};
-
if (keywordParameters) {
var jsonObjects = keywordParameters["jsonObjects"];
- var jsonString = keywordParameters["jsonString"];
- var fileUrl = keywordParameters["url"];
+ var jsonString = keywordParameters["jsonString"];
+ var fileUrl = keywordParameters["url"];
if (jsonObjects) {
dojo.data.old.format.Json.loadDataProviderFromArrayOfJsonData(this, jsonObjects);
}
@@ -43,7 +33,7 @@ dojo.data.old.provider.FlatFile = function(/* keywords */ keywordParameters) {
dojo.data.old.format.Json.loadDataProviderFromFileContents(this, jsonString);
}
if (fileUrl) {
- var arrayOfParts = fileUrl.split('.');
+ var arrayOfParts = fileUrl.split(".");
var lastPart = arrayOfParts[(arrayOfParts.length - 1)];
var formatParser = null;
if (lastPart == "json") {
@@ -62,25 +52,10 @@ dojo.data.old.provider.FlatFile = function(/* keywords */ keywordParameters) {
}
};
dojo.inherits(dojo.data.old.provider.FlatFile, dojo.data.old.provider.Base);
-
-// -------------------------------------------------------------------
-// Public instance methods
-// -------------------------------------------------------------------
-dojo.data.old.provider.FlatFile.prototype.getProviderCapabilities = function(/* string */ keyword) {
- dojo.lang.assertType(keyword, String, {optional: true});
+dojo.data.old.provider.FlatFile.prototype.getProviderCapabilities = function (keyword) {
+ dojo.lang.assertType(keyword, String, {optional:true});
if (!this._ourCapabilities) {
- this._ourCapabilities = {
- transactions: false,
- undo: false,
- login: false,
- versioning: false,
- anonymousRead: true,
- anonymousWrite: false,
- permissions: false,
- queries: false,
- strongTyping: false,
- datatypes: [String, Date, Number]
- };
+ this._ourCapabilities = {transactions:false, undo:false, login:false, versioning:false, anonymousRead:true, anonymousWrite:false, permissions:false, queries:false, strongTyping:false, datatypes:[String, Date, Number]};
}
if (keyword) {
return this._ourCapabilities[keyword];
@@ -88,66 +63,49 @@ dojo.data.old.provider.FlatFile.prototype.getProviderCapabilities = function(/*
return this._ourCapabilities;
}
};
-
-dojo.data.old.provider.FlatFile.prototype.registerAttribute = function(/* string or dojo.data.old.Attribute */ attributeId) {
+dojo.data.old.provider.FlatFile.prototype.registerAttribute = function (attributeId) {
var registeredAttribute = this.getAttribute(attributeId);
if (!registeredAttribute) {
var newAttribute = new dojo.data.old.Attribute(this, attributeId);
this._dictionaryOfAttributes[attributeId] = newAttribute;
registeredAttribute = newAttribute;
}
- return registeredAttribute; // dojo.data.old.Attribute
+ return registeredAttribute;
};
-
-dojo.data.old.provider.FlatFile.prototype.getAttribute = function(/* string or dojo.data.old.Attribute */ attributeId) {
+dojo.data.old.provider.FlatFile.prototype.getAttribute = function (attributeId) {
var attribute = (this._dictionaryOfAttributes[attributeId] || null);
- return attribute; // dojo.data.old.Attribute or null
+ return attribute;
};
-
-dojo.data.old.provider.FlatFile.prototype.getAttributes = function() {
+dojo.data.old.provider.FlatFile.prototype.getAttributes = function () {
var arrayOfAttributes = [];
for (var key in this._dictionaryOfAttributes) {
var attribute = this._dictionaryOfAttributes[key];
arrayOfAttributes.push(attribute);
}
- return arrayOfAttributes; // Array
+ return arrayOfAttributes;
};
-
-dojo.data.old.provider.FlatFile.prototype.fetchArray = function(query) {
- /**
- * summary: Returns an Array containing all of the Items.
- */
- return this._arrayOfItems; // Array
+dojo.data.old.provider.FlatFile.prototype.fetchArray = function (query) {
+ return this._arrayOfItems;
};
-
-dojo.data.old.provider.FlatFile.prototype.fetchResultSet = function(query) {
- /**
- * summary: Returns a ResultSet containing all of the Items.
- */
+dojo.data.old.provider.FlatFile.prototype.fetchResultSet = function (query) {
if (!this._resultSet) {
this._resultSet = new dojo.data.old.ResultSet(this, this.fetchArray(query));
}
- return this._resultSet; // dojo.data.old.ResultSet
+ return this._resultSet;
};
-
-// -------------------------------------------------------------------
-// Private instance methods
-// -------------------------------------------------------------------
-dojo.data.old.provider.FlatFile.prototype._newItem = function() {
+dojo.data.old.provider.FlatFile.prototype._newItem = function () {
var item = new dojo.data.old.Item(this);
this._arrayOfItems.push(item);
- return item; // dojo.data.old.Item
+ return item;
};
-
-dojo.data.old.provider.FlatFile.prototype._newAttribute = function(/* String */ attributeId) {
+dojo.data.old.provider.FlatFile.prototype._newAttribute = function (attributeId) {
dojo.lang.assertType(attributeId, String);
dojo.lang.assert(this.getAttribute(attributeId) === null);
var attribute = new dojo.data.old.Attribute(this, attributeId);
this._dictionaryOfAttributes[attributeId] = attribute;
- return attribute; // dojo.data.old.Attribute
-};
-
-dojo.data.old.provider.Base.prototype._getResultSets = function() {
- return [this._resultSet]; // Array
+ return attribute;
+};
+dojo.data.old.provider.Base.prototype._getResultSets = function () {
+ return [this._resultSet];
};
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/JotSpot.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/JotSpot.js
index 47b326b2e..3ec60e90c 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/JotSpot.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/JotSpot.js
@@ -10,18 +10,8 @@
dojo.provide("dojo.data.old.provider.JotSpot");
dojo.require("dojo.data.old.provider.Base");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.provider.JotSpot = function() {
- /**
- * summary:
- * A JotSpot Data Provider knows how to read data from a JotSpot data
- * store and make the contents accessable as dojo.data.old.Items.
- */
- dojo.unimplemented('dojo.data.old.provider.JotSpot');
+dojo.data.old.provider.JotSpot = function () {
+ dojo.unimplemented("dojo.data.old.provider.JotSpot");
};
-
dojo.inherits(dojo.data.old.provider.JotSpot, dojo.data.old.provider.Base);
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/MySql.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/MySql.js
index bbf443c2f..c52e1ba25 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/MySql.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/data/old/provider/MySql.js
@@ -10,18 +10,8 @@
dojo.provide("dojo.data.old.provider.MySql");
dojo.require("dojo.data.old.provider.Base");
-
-// -------------------------------------------------------------------
-// Constructor
-// -------------------------------------------------------------------
-dojo.data.old.provider.MySql = function() {
- /**
- * summary:
- * A MySql Data Provider knows how to connect to a MySQL database
- * on a server and and make the content records available as
- * dojo.data.old.Items.
- */
- dojo.unimplemented('dojo.data.old.provider.MySql');
+dojo.data.old.provider.MySql = function () {
+ dojo.unimplemented("dojo.data.old.provider.MySql");
};
-
dojo.inherits(dojo.data.old.provider.MySql, dojo.data.old.provider.Base);
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date.js
index 7754095ff..8fd67d68c 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date.js
@@ -9,5 +9,5 @@
*/
dojo.provide("dojo.date");
-
dojo.deprecated("dojo.date", "use one of the modules in dojo.date.* instead", "0.5");
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/common.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/common.js
index 43c26eb74..04ad24d0c 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/common.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/common.js
@@ -9,488 +9,306 @@
*/
dojo.provide("dojo.date.common");
-
-
-/* Supplementary Date Functions
- *******************************/
-
-dojo.date.setDayOfYear = function(/*Date*/dateObject, /*Number*/dayOfYear){
- // summary: sets dateObject according to day of the year (1..366)
+dojo.date.setDayOfYear = function (dateObject, dayOfYear) {
dateObject.setMonth(0);
dateObject.setDate(dayOfYear);
- return dateObject; // Date
-}
-
-dojo.date.getDayOfYear = function(/*Date*/dateObject){
- // summary: gets the day of the year as represented by dateObject
+ return dateObject;
+};
+dojo.date.getDayOfYear = function (dateObject) {
var fullYear = dateObject.getFullYear();
- var lastDayOfPrevYear = new Date(fullYear-1, 11, 31);
- return Math.floor((dateObject.getTime() -
- lastDayOfPrevYear.getTime()) / 86400000); // Number
-}
-
-
-dojo.date.setWeekOfYear = function(/*Date*/dateObject, /*Number*/week, /*Number*/firstDay){
- if(arguments.length == 1){ firstDay = 0; } // Sunday
+ var lastDayOfPrevYear = new Date(fullYear - 1, 11, 31);
+ return Math.floor((dateObject.getTime() - lastDayOfPrevYear.getTime()) / 86400000);
+};
+dojo.date.setWeekOfYear = function (dateObject, week, firstDay) {
+ if (arguments.length == 1) {
+ firstDay = 0;
+ }
dojo.unimplemented("dojo.date.setWeekOfYear");
-}
-
-dojo.date.getWeekOfYear = function(/*Date*/dateObject, /*Number*/firstDay){
- if(arguments.length == 1){ firstDay = 0; } // Sunday
-
- // work out the first day of the year corresponding to the week
+};
+dojo.date.getWeekOfYear = function (dateObject, firstDay) {
+ if (arguments.length == 1) {
+ firstDay = 0;
+ }
var firstDayOfYear = new Date(dateObject.getFullYear(), 0, 1);
var day = firstDayOfYear.getDay();
- firstDayOfYear.setDate(firstDayOfYear.getDate() -
- day + firstDay - (day > firstDay ? 7 : 0));
-
- return Math.floor((dateObject.getTime() -
- firstDayOfYear.getTime()) / 604800000);
-}
-
-dojo.date.setIsoWeekOfYear = function(/*Date*/dateObject, /*Number*/week, /*Number*/firstDay){
- // summary: unimplemented
- if (arguments.length == 1) { firstDay = 1; } // Monday
+ firstDayOfYear.setDate(firstDayOfYear.getDate() - day + firstDay - (day > firstDay ? 7 : 0));
+ return Math.floor((dateObject.getTime() - firstDayOfYear.getTime()) / 604800000);
+};
+dojo.date.setIsoWeekOfYear = function (dateObject, week, firstDay) {
+ if (arguments.length == 1) {
+ firstDay = 1;
+ }
dojo.unimplemented("dojo.date.setIsoWeekOfYear");
-}
-
-dojo.date.getIsoWeekOfYear = function(/*Date*/dateObject, /*Number*/firstDay) {
- // summary: unimplemented
- if (arguments.length == 1) { firstDay = 1; } // Monday
+};
+dojo.date.getIsoWeekOfYear = function (dateObject, firstDay) {
+ if (arguments.length == 1) {
+ firstDay = 1;
+ }
dojo.unimplemented("dojo.date.getIsoWeekOfYear");
-}
-
-
-/* Informational Functions
- **************************/
-
-//DEPRECATED: These timezone arrays will be deprecated in 0.5
-dojo.date.shortTimezones = ["IDLW", "BET", "HST", "MART", "AKST", "PST", "MST",
- "CST", "EST", "AST", "NFT", "BST", "FST", "AT", "GMT", "CET", "EET", "MSK",
- "IRT", "GST", "AFT", "AGTT", "IST", "NPT", "ALMT", "MMT", "JT", "AWST",
- "JST", "ACST", "AEST", "LHST", "VUT", "NFT", "NZT", "CHAST", "PHOT",
- "LINT"];
-dojo.date.timezoneOffsets = [-720, -660, -600, -570, -540, -480, -420, -360,
- -300, -240, -210, -180, -120, -60, 0, 60, 120, 180, 210, 240, 270, 300,
- 330, 345, 360, 390, 420, 480, 540, 570, 600, 630, 660, 690, 720, 765, 780,
- 840];
-/*
-dojo.date.timezones = ["International Date Line West", "Bering Standard Time",
- "Hawaiian Standard Time", "Marquesas Time", "Alaska Standard Time",
- "Pacific Standard Time (USA)", "Mountain Standard Time",
- "Central Standard Time (USA)", "Eastern Standard Time (USA)",
- "Atlantic Standard Time", "Newfoundland Time", "Brazil Standard Time",
- "Fernando de Noronha Standard Time (Brazil)", "Azores Time",
- "Greenwich Mean Time", "Central Europe Time", "Eastern Europe Time",
- "Moscow Time", "Iran Standard Time", "Gulf Standard Time",
- "Afghanistan Time", "Aqtobe Time", "Indian Standard Time", "Nepal Time",
- "Almaty Time", "Myanmar Time", "Java Time",
- "Australian Western Standard Time", "Japan Standard Time",
- "Australian Central Standard Time", "Lord Hove Standard Time (Australia)",
- "Vanuata Time", "Norfolk Time (Australia)", "New Zealand Standard Time",
- "Chatham Standard Time (New Zealand)", "Phoenix Islands Time (Kribati)",
- "Line Islands Time (Kribati)"];
-*/
-
-dojo.date.getDaysInMonth = function(/*Date*/dateObject){
- // summary: returns the number of days in the month used by dateObject
+};
+dojo.date.shortTimezones = ["IDLW", "BET", "HST", "MART", "AKST", "PST", "MST", "CST", "EST", "AST", "NFT", "BST", "FST", "AT", "GMT", "CET", "EET", "MSK", "IRT", "GST", "AFT", "AGTT", "IST", "NPT", "ALMT", "MMT", "JT", "AWST", "JST", "ACST", "AEST", "LHST", "VUT", "NFT", "NZT", "CHAST", "PHOT", "LINT"];
+dojo.date.timezoneOffsets = [-720, -660, -600, -570, -540, -480, -420, -360, -300, -240, -210, -180, -120, -60, 0, 60, 120, 180, 210, 240, 270, 300, 330, 345, 360, 390, 420, 480, 540, 570, 600, 630, 660, 690, 720, 765, 780, 840];
+dojo.date.getDaysInMonth = function (dateObject) {
var month = dateObject.getMonth();
var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
- if (month == 1 && dojo.date.isLeapYear(dateObject)) { return 29; } // Number
- else { return days[month]; } // Number
-}
-
-dojo.date.isLeapYear = function(/*Date*/dateObject){
-// summary:
-// Determines if the year of the dateObject is a leap year
-//
-// description:
-// Leap years are years with an additional day YYYY-02-29, where the year
-// number is a multiple of four with the following exception: If a year
-// is a multiple of 100, then it is only a leap year if it is also a
-// multiple of 400. For example, 1900 was not a leap year, but 2000 is one.
-
+ if (month == 1 && dojo.date.isLeapYear(dateObject)) {
+ return 29;
+ } else {
+ return days[month];
+ }
+};
+dojo.date.isLeapYear = function (dateObject) {
var year = dateObject.getFullYear();
- return (year%400 == 0) ? true : (year%100 == 0) ? false : (year%4 == 0) ? true : false; // Boolean
-}
-
-// FIXME: This is not localized
-dojo.date.getTimezoneName = function(/*Date*/dateObject){
-// summary:
-// Get the user's time zone as provided by the browser
-//
-// dateObject: needed because the timezone may vary with time (daylight savings)
-//
-// description:
-// Try to get time zone info from toString or toLocaleString
-// method of the Date object -- UTC offset is not a time zone.
-// See http://www.twinsun.com/tz/tz-link.htm
-// Note: results may be inconsistent across browsers.
-
- var str = dateObject.toString(); // Start looking in toString
- var tz = ''; // The result -- return empty string if nothing found
+ return (year % 400 == 0) ? true : (year % 100 == 0) ? false : (year % 4 == 0) ? true : false;
+};
+dojo.date.getTimezoneName = function (dateObject) {
+ var str = dateObject.toString();
+ var tz = "";
var match;
-
- // First look for something in parentheses -- fast lookup, no regex
- var pos = str.indexOf('(');
+ var pos = str.indexOf("(");
if (pos > -1) {
pos++;
- tz = str.substring(pos, str.indexOf(')'));
- }
- // If at first you don't succeed ...
- else{
- // If IE knows about the TZ, it appears before the year
- // Capital letters or slash before a 4-digit year
- // at the end of string
+ tz = str.substring(pos, str.indexOf(")"));
+ } else {
var pat = /([A-Z\/]+) \d{4}$/;
- if((match = str.match(pat))) {
+ if ((match = str.match(pat))) {
tz = match[1];
- }
- // Some browsers (e.g. Safari) glue the TZ on the end
- // of toLocaleString instead of putting it in toString
- else{
+ } else {
str = dateObject.toLocaleString();
- // Capital letters or slash -- end of string,
- // after space
pat = / ([A-Z\/]+)$/;
- if((match = str.match(pat))) {
+ if ((match = str.match(pat))) {
tz = match[1];
}
}
}
-
- // Make sure it doesn't somehow end up return AM or PM
- return tz == 'AM' || tz == 'PM' ? '' : tz; //String
-}
-
-
-//FIXME: not localized
-dojo.date.getOrdinal = function(dateObject){
- // summary: returns the appropriate suffix (English only) for the day of the month, e.g. 'st' for 1, 'nd' for 2, etc.)
+ return tz == "AM" || tz == "PM" ? "" : tz;
+};
+dojo.date.getOrdinal = function (dateObject) {
var date = dateObject.getDate();
-
- if(date%100 != 11 && date%10 == 1){ return "st"; } // String
- else if(date%100 != 12 && date%10 == 2){ return "nd"; } // String
- else if(date%100 != 13 && date%10 == 3){ return "rd"; } // String
- else{ return "th"; } // String
-}
-
-
-/* compare and add
- ******************/
-dojo.date.compareTypes={
- // summary
- // bitmask for comparison operations.
- DATE:1, TIME:2
+ if (date % 100 != 11 && date % 10 == 1) {
+ return "st";
+ } else {
+ if (date % 100 != 12 && date % 10 == 2) {
+ return "nd";
+ } else {
+ if (date % 100 != 13 && date % 10 == 3) {
+ return "rd";
+ } else {
+ return "th";
+ }
+ }
+ }
};
-dojo.date.compare=function(/* Date */ dateA, /* Date */ dateB, /* dojo.date.compareTypes */ options){
- // summary
- // Compare two date objects by date, time, or both. Returns 0 if equal, positive if a > b, else negative.
- var dA=dateA;
- var dB=dateB||new Date();
- var now=new Date();
- //FIXME: shorten this code
- with(dojo.date.compareTypes){
- var opt=options||(DATE|TIME);
- var d1=new Date(
- (opt&DATE)?dA.getFullYear():now.getFullYear(),
- (opt&DATE)?dA.getMonth():now.getMonth(),
- (opt&DATE)?dA.getDate():now.getDate(),
- (opt&TIME)?dA.getHours():0,
- (opt&TIME)?dA.getMinutes():0,
- (opt&TIME)?dA.getSeconds():0
- );
- var d2=new Date(
- (opt&DATE)?dB.getFullYear():now.getFullYear(),
- (opt&DATE)?dB.getMonth():now.getMonth(),
- (opt&DATE)?dB.getDate():now.getDate(),
- (opt&TIME)?dB.getHours():0,
- (opt&TIME)?dB.getMinutes():0,
- (opt&TIME)?dB.getSeconds():0
- );
+dojo.date.compareTypes = {DATE:1, TIME:2};
+dojo.date.compare = function (dateA, dateB, options) {
+ var dA = dateA;
+ var dB = dateB || new Date();
+ var now = new Date();
+ with (dojo.date.compareTypes) {
+ var opt = options || (DATE | TIME);
+ var d1 = new Date((opt & DATE) ? dA.getFullYear() : now.getFullYear(), (opt & DATE) ? dA.getMonth() : now.getMonth(), (opt & DATE) ? dA.getDate() : now.getDate(), (opt & TIME) ? dA.getHours() : 0, (opt & TIME) ? dA.getMinutes() : 0, (opt & TIME) ? dA.getSeconds() : 0);
+ var d2 = new Date((opt & DATE) ? dB.getFullYear() : now.getFullYear(), (opt & DATE) ? dB.getMonth() : now.getMonth(), (opt & DATE) ? dB.getDate() : now.getDate(), (opt & TIME) ? dB.getHours() : 0, (opt & TIME) ? dB.getMinutes() : 0, (opt & TIME) ? dB.getSeconds() : 0);
}
- if(d1.valueOf()>d2.valueOf()){
- return 1; // int
+ if (d1.valueOf() > d2.valueOf()) {
+ return 1;
}
- if(d1.valueOf() 0) ? 5 : -5;
- weeks = (incr > 0) ? ((incr-5)/5) : ((incr+5)/5);
- }
- else {
- days = mod;
- weeks = parseInt(incr/5);
- }
- // Get weekday value for orig date param
- strt = dt.getDay();
- // Orig date is Sat / positive incrementer
- // Jump over Sun
- if (strt == 6 && incr > 0) {
- adj = 1;
- }
- // Orig date is Sun / negative incrementer
- // Jump back over Sat
- else if (strt == 0 && incr < 0) {
+ with (dojo.date.dateParts) {
+ switch (interv) {
+ case YEAR:
+ sum.setFullYear(dt.getFullYear() + incr);
+ fixOvershoot();
+ break;
+ case QUARTER:
+ incr *= 3;
+ case MONTH:
+ sum.setMonth(dt.getMonth() + incr);
+ fixOvershoot();
+ break;
+ case WEEK:
+ incr *= 7;
+ case DAY:
+ sum.setDate(dt.getDate() + incr);
+ break;
+ case WEEKDAY:
+ var dat = dt.getDate();
+ var weeks = 0;
+ var days = 0;
+ var strt = 0;
+ var trgt = 0;
+ var adj = 0;
+ var mod = incr % 5;
+ if (mod == 0) {
+ days = (incr > 0) ? 5 : -5;
+ weeks = (incr > 0) ? ((incr - 5) / 5) : ((incr + 5) / 5);
+ } else {
+ days = mod;
+ weeks = parseInt(incr / 5);
+ }
+ strt = dt.getDay();
+ if (strt == 6 && incr > 0) {
+ adj = 1;
+ } else {
+ if (strt == 0 && incr < 0) {
adj = -1;
}
- // Get weekday val for the new date
- trgt = (strt + days);
- // New date is on Sat or Sun
- if (trgt == 0 || trgt == 6) {
- adj = (incr > 0) ? 2 : -2;
- }
- // Increment by number of weeks plus leftover days plus
- // weekend adjustments
- sum.setDate(dat + (7*weeks) + days + adj);
- break;
- case HOUR:
- sum.setHours(sum.getHours()+incr);
- break;
- case MINUTE:
- sum.setMinutes(sum.getMinutes()+incr);
- break;
- case SECOND:
- sum.setSeconds(sum.getSeconds()+incr);
- break;
- case MILLISECOND:
- sum.setMilliseconds(sum.getMilliseconds()+incr);
- break;
- default:
- // Do nothing
- break;
+ }
+ trgt = (strt + days);
+ if (trgt == 0 || trgt == 6) {
+ adj = (incr > 0) ? 2 : -2;
+ }
+ sum.setDate(dat + (7 * weeks) + days + adj);
+ break;
+ case HOUR:
+ sum.setHours(sum.getHours() + incr);
+ break;
+ case MINUTE:
+ sum.setMinutes(sum.getMinutes() + incr);
+ break;
+ case SECOND:
+ sum.setSeconds(sum.getSeconds() + incr);
+ break;
+ case MILLISECOND:
+ sum.setMilliseconds(sum.getMilliseconds() + incr);
+ break;
+ default:
+ break;
}
}
-
- return sum; // Date
+ return sum;
};
-
-dojo.date.diff = function(/* Date */ dtA, /* Date */ dtB, /* dojo.date.dateParts */ interv){
-// summary:
-// Get the difference in a specific unit of time (e.g., number of months, weeks,
-// days, etc.) between two dates.
-//
-// dtA:
-// A Javascript Date object
-//
-// dtB:
-// A Javascript Date object
-//
-// interv:
-// A constant representing the interval, e.g. YEAR, MONTH, DAY. See dojo.date.dateParts.
-
- // Accept timestamp input
- if(typeof dtA == 'number'){dtA = new Date(dtA);}
- if(typeof dtB == 'number'){dtB = new Date(dtB);}
+dojo.date.diff = function (dtA, dtB, interv) {
+ if (typeof dtA == "number") {
+ dtA = new Date(dtA);
+ }
+ if (typeof dtB == "number") {
+ dtB = new Date(dtB);
+ }
var yeaDiff = dtB.getFullYear() - dtA.getFullYear();
var monDiff = (dtB.getMonth() - dtA.getMonth()) + (yeaDiff * 12);
- var msDiff = dtB.getTime() - dtA.getTime(); // Millisecs
- var secDiff = msDiff/1000;
- var minDiff = secDiff/60;
- var houDiff = minDiff/60;
- var dayDiff = houDiff/24;
- var weeDiff = dayDiff/7;
- var delta = 0; // Integer return value
-
- with(dojo.date.dateParts){
- switch(interv){
- case YEAR:
- delta = yeaDiff;
- break;
- case QUARTER:
- var mA = dtA.getMonth();
- var mB = dtB.getMonth();
- // Figure out which quarter the months are in
- var qA = Math.floor(mA/3) + 1;
- var qB = Math.floor(mB/3) + 1;
- // Add quarters for any year difference between the dates
- qB += (yeaDiff * 4);
- delta = qB - qA;
- break;
- case MONTH:
- delta = monDiff;
- break;
- case WEEK:
- // Truncate instead of rounding
- // Don't use Math.floor -- value may be negative
- delta = parseInt(weeDiff);
- break;
- case DAY:
- delta = dayDiff;
- break;
- case WEEKDAY:
- var days = Math.round(dayDiff);
- var weeks = parseInt(days/7);
- var mod = days % 7;
-
- // Even number of weeks
- if (mod == 0) {
- days = weeks*5;
- }
- // Weeks plus spare change (< 7 days)
- else {
- var adj = 0;
- var aDay = dtA.getDay();
- var bDay = dtB.getDay();
-
- weeks = parseInt(days/7);
- mod = days % 7;
- // Mark the date advanced by the number of
- // round weeks (may be zero)
- var dtMark = new Date(dtA);
- dtMark.setDate(dtMark.getDate()+(weeks*7));
- var dayMark = dtMark.getDay();
- // Spare change days -- 6 or less
- // ----------
- // Positive diff
- if (dayDiff > 0) {
+ var msDiff = dtB.getTime() - dtA.getTime();
+ var secDiff = msDiff / 1000;
+ var minDiff = secDiff / 60;
+ var houDiff = minDiff / 60;
+ var dayDiff = houDiff / 24;
+ var weeDiff = dayDiff / 7;
+ var delta = 0;
+ with (dojo.date.dateParts) {
+ switch (interv) {
+ case YEAR:
+ delta = yeaDiff;
+ break;
+ case QUARTER:
+ var mA = dtA.getMonth();
+ var mB = dtB.getMonth();
+ var qA = Math.floor(mA / 3) + 1;
+ var qB = Math.floor(mB / 3) + 1;
+ qB += (yeaDiff * 4);
+ delta = qB - qA;
+ break;
+ case MONTH:
+ delta = monDiff;
+ break;
+ case WEEK:
+ delta = parseInt(weeDiff);
+ break;
+ case DAY:
+ delta = dayDiff;
+ break;
+ case WEEKDAY:
+ var days = Math.round(dayDiff);
+ var weeks = parseInt(days / 7);
+ var mod = days % 7;
+ if (mod == 0) {
+ days = weeks * 5;
+ } else {
+ var adj = 0;
+ var aDay = dtA.getDay();
+ var bDay = dtB.getDay();
+ weeks = parseInt(days / 7);
+ mod = days % 7;
+ var dtMark = new Date(dtA);
+ dtMark.setDate(dtMark.getDate() + (weeks * 7));
+ var dayMark = dtMark.getDay();
+ if (dayDiff > 0) {
+ switch (true) {
+ case aDay == 6:
+ adj = -1;
+ break;
+ case aDay == 0:
+ adj = 0;
+ break;
+ case bDay == 6:
+ adj = -1;
+ break;
+ case bDay == 0:
+ adj = -2;
+ break;
+ case (dayMark + mod) > 5:
+ adj = -2;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if (dayDiff < 0) {
switch (true) {
- // Range starts on Sat
- case aDay == 6:
- adj = -1;
- break;
- // Range starts on Sun
- case aDay == 0:
- adj = 0;
- break;
- // Range ends on Sat
- case bDay == 6:
- adj = -1;
- break;
- // Range ends on Sun
- case bDay == 0:
- adj = -2;
- break;
- // Range contains weekend
- case (dayMark + mod) > 5:
- adj = -2;
- break;
- default:
- // Do nothing
- break;
+ case aDay == 6:
+ adj = 0;
+ break;
+ case aDay == 0:
+ adj = 1;
+ break;
+ case bDay == 6:
+ adj = 2;
+ break;
+ case bDay == 0:
+ adj = 1;
+ break;
+ case (dayMark + mod) < 0:
+ adj = 2;
+ break;
+ default:
+ break;
}
}
- // Negative diff
- else if (dayDiff < 0) {
- switch (true) {
- // Range starts on Sat
- case aDay == 6:
- adj = 0;
- break;
- // Range starts on Sun
- case aDay == 0:
- adj = 1;
- break;
- // Range ends on Sat
- case bDay == 6:
- adj = 2;
- break;
- // Range ends on Sun
- case bDay == 0:
- adj = 1;
- break;
- // Range contains weekend
- case (dayMark + mod) < 0:
- adj = 2;
- break;
- default:
- // Do nothing
- break;
- }
- }
- days += adj;
- days -= (weeks*2);
}
- delta = days;
-
- break;
- case HOUR:
- delta = houDiff;
- break;
- case MINUTE:
- delta = minDiff;
- break;
- case SECOND:
- delta = secDiff;
- break;
- case MILLISECOND:
- delta = msDiff;
- break;
- default:
- // Do nothing
- break;
+ days += adj;
+ days -= (weeks * 2);
+ }
+ delta = days;
+ break;
+ case HOUR:
+ delta = houDiff;
+ break;
+ case MINUTE:
+ delta = minDiff;
+ break;
+ case SECOND:
+ delta = secDiff;
+ break;
+ case MILLISECOND:
+ delta = msDiff;
+ break;
+ default:
+ break;
}
}
-
- // Round for fractional values and DST leaps
- return Math.round(delta); // Number (integer)
+ return Math.round(delta);
};
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/format.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/format.js
index 20cfcd11a..1f4439d59 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/format.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/format.js
@@ -9,7 +9,6 @@
*/
dojo.provide("dojo.date.format");
-
dojo.require("dojo.date.common");
dojo.require("dojo.date.supplemental");
dojo.require("dojo.lang.array");
@@ -17,906 +16,696 @@ dojo.require("dojo.lang.common");
dojo.require("dojo.lang.func");
dojo.require("dojo.string.common");
dojo.require("dojo.i18n.common");
-
-// Load the bundles containing localization information for
-// names and formats
-dojo.requireLocalization("dojo.i18n.calendar", "gregorian");
-dojo.requireLocalization("dojo.i18n.calendar", "gregorianExtras");
-
-//NOTE: Everything in this module assumes Gregorian calendars.
-// Other calendars will be implemented in separate modules.
-
-(function(){
-dojo.date.format = function(/*Date*/dateObject, /*Object?*/options){
-//
-// summary:
-// Format a Date object as a String, using locale-specific settings.
-//
-// description:
-// Create a string from a Date object using a known localized pattern.
-// By default, this method formats both date and time from dateObject.
-// Formatting patterns are chosen appropriate to the locale. Different
-// formatting lengths may be chosen, with "full" used by default.
-// Custom patterns may be used or registered with translations using
-// the addCustomBundle method.
-// Formatting patterns are implemented using the syntax described at
-// http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns
-//
-// dateObject:
-// the date and/or time to be formatted. If a time only is formatted,
-// the values in the year, month, and day fields are irrelevant. The
-// opposite is true when formatting only dates.
-//
-// options: object {selector: string, formatLength: string, datePattern: string, timePattern: string, locale: string}
-// selector- choice of timeOnly,dateOnly (default: date and time)
-// formatLength- choice of long, short, medium or full (plus any custom additions). Defaults to 'full'
-// datePattern,timePattern- override pattern with this string
-// am,pm- override strings for am/pm in times
-// locale- override the locale used to determine formatting rules
-//
-
- if(typeof options == "string"){
- dojo.deprecated("dojo.date.format", "To format dates with POSIX-style strings, please use dojo.date.strftime instead", "0.5");
- return dojo.date.strftime(dateObject, options);
- }
-
- // Format a pattern without literals
- function formatPattern(dateObject, pattern){
- return pattern.replace(/[a-zA-Z]+/g, function(match){
- var s;
- var c = match.charAt(0);
- var l = match.length;
- var pad;
- var widthList = ["abbr", "wide", "narrow"];
- switch(c){
- case 'G':
- if(l>3){dojo.unimplemented("Era format not implemented");}
+dojo.requireLocalization("dojo.i18n.calendar", "gregorian", null, "de,en,es,fi,fr,hu,ja,it,ko,nl,pt,sv,zh,pt-br,zh-cn,zh-hk,zh-tw,ROOT");
+dojo.requireLocalization("dojo.i18n.calendar", "gregorianExtras", null, "ja,zh,ROOT");
+(function () {
+ dojo.date.format = function (dateObject, options) {
+ if (typeof options == "string") {
+ dojo.deprecated("dojo.date.format", "To format dates with POSIX-style strings, please use dojo.date.strftime instead", "0.5");
+ return dojo.date.strftime(dateObject, options);
+ }
+ function formatPattern(dateObject, pattern) {
+ return pattern.replace(/([a-z])\1*/ig, function (match) {
+ var s;
+ var c = match.charAt(0);
+ var l = match.length;
+ var pad;
+ var widthList = ["abbr", "wide", "narrow"];
+ switch (c) {
+ case "G":
+ if (l > 3) {
+ dojo.unimplemented("Era format not implemented");
+ }
s = info.eras[dateObject.getFullYear() < 0 ? 1 : 0];
break;
- case 'y':
+ case "y":
s = dateObject.getFullYear();
- switch(l){
- case 1:
- break;
- case 2:
- s = String(s).substr(-2);
- break;
- default:
- pad = true;
+ switch (l) {
+ case 1:
+ break;
+ case 2:
+ s = String(s).substr(-2);
+ break;
+ default:
+ pad = true;
}
break;
- case 'Q':
- case 'q':
- s = Math.ceil((dateObject.getMonth()+1)/3);
- switch(l){
- case 1: case 2:
- pad = true;
- break;
- case 3:
- case 4:
- dojo.unimplemented("Quarter format not implemented");
+ case "Q":
+ case "q":
+ s = Math.ceil((dateObject.getMonth() + 1) / 3);
+ switch (l) {
+ case 1:
+ case 2:
+ pad = true;
+ break;
+ case 3:
+ case 4:
+ dojo.unimplemented("Quarter format not implemented");
}
break;
- case 'M':
- case 'L':
+ case "M":
+ case "L":
var m = dateObject.getMonth();
var width;
- switch(l){
- case 1: case 2:
- s = m+1; pad = true;
- break;
- case 3: case 4: case 5:
- width = widthList[l-3];
- break;
+ switch (l) {
+ case 1:
+ case 2:
+ s = m + 1;
+ pad = true;
+ break;
+ case 3:
+ case 4:
+ case 5:
+ width = widthList[l - 3];
+ break;
}
- if(width){
+ if (width) {
var type = (c == "L") ? "standalone" : "format";
- var prop = ["months",type,width].join("-");
+ var prop = ["months", type, width].join("-");
s = info[prop][m];
}
break;
- case 'w':
+ case "w":
var firstDay = 0;
- s = dojo.date.getWeekOfYear(dateObject, firstDay); pad = true;
+ s = dojo.date.getWeekOfYear(dateObject, firstDay);
+ pad = true;
break;
- case 'd':
- s = dateObject.getDate(); pad = true;
+ case "d":
+ s = dateObject.getDate();
+ pad = true;
break;
- case 'D':
- s = dojo.date.getDayOfYear(dateObject); pad = true;
+ case "D":
+ s = dojo.date.getDayOfYear(dateObject);
+ pad = true;
break;
- case 'E':
- case 'e':
- case 'c': // REVIEW: don't see this in the spec?
+ case "E":
+ case "e":
+ case "c":
var d = dateObject.getDay();
var width;
- switch(l){
- case 1: case 2:
- if(c == 'e'){
- var first = dojo.date.getFirstDayOfWeek(options.locale);
- d = (d-first+7)%7;
- }
- if(c != 'c'){
- s = d+1; pad = true;
- break;
- }
- // else fallthrough...
- case 3: case 4: case 5:
- width = widthList[l-3];
+ switch (l) {
+ case 1:
+ case 2:
+ if (c == "e") {
+ var first = dojo.date.getFirstDayOfWeek(options.locale);
+ d = (d - first + 7) % 7;
+ }
+ if (c != "c") {
+ s = d + 1;
+ pad = true;
break;
+ }
+ case 3:
+ case 4:
+ case 5:
+ width = widthList[l - 3];
+ break;
}
- if(width){
+ if (width) {
var type = (c == "c") ? "standalone" : "format";
- var prop = ["days",type,width].join("-");
+ var prop = ["days", type, width].join("-");
s = info[prop][d];
}
break;
- case 'a':
- var timePeriod = (dateObject.getHours() < 12) ? 'am' : 'pm';
+ case "a":
+ var timePeriod = (dateObject.getHours() < 12) ? "am" : "pm";
s = info[timePeriod];
break;
- case 'h':
- case 'H':
- case 'K':
- case 'k':
+ case "h":
+ case "H":
+ case "K":
+ case "k":
var h = dateObject.getHours();
- // strange choices in the date format make it impossible to write this succinctly
switch (c) {
- case 'h': // 1-12
- s = (h % 12) || 12;
- break;
- case 'H': // 0-23
- s = h;
- break;
- case 'K': // 0-11
- s = (h % 12);
- break;
- case 'k': // 1-24
- s = h || 24;
- break;
+ case "h":
+ s = (h % 12) || 12;
+ break;
+ case "H":
+ s = h;
+ break;
+ case "K":
+ s = (h % 12);
+ break;
+ case "k":
+ s = h || 24;
+ break;
}
pad = true;
break;
- case 'm':
- s = dateObject.getMinutes(); pad = true;
+ case "m":
+ s = dateObject.getMinutes();
+ pad = true;
break;
- case 's':
- s = dateObject.getSeconds(); pad = true;
+ case "s":
+ s = dateObject.getSeconds();
+ pad = true;
break;
- case 'S':
- s = Math.round(dateObject.getMilliseconds() * Math.pow(10, l-3));
+ case "S":
+ s = Math.round(dateObject.getMilliseconds() * Math.pow(10, l - 3));
break;
- case 'v': // FIXME: don't know what this is. seems to be same as z?
- case 'z':
- // We only have one timezone to offer; the one from the browser
+ case "v":
+ case "z":
s = dojo.date.getTimezoneName(dateObject);
- if(s){break;}
- l=4;
- // fallthrough... use GMT if tz not available
- case 'Z':
+ if (s) {
+ break;
+ }
+ l = 4;
+ case "Z":
var offset = dateObject.getTimezoneOffset();
- var tz = [
- (offset<=0 ? "+" : "-"),
- dojo.string.pad(Math.floor(Math.abs(offset)/60), 2),
- dojo.string.pad(Math.abs(offset)% 60, 2)
- ];
- if(l==4){
+ var tz = [(offset <= 0 ? "+" : "-"), dojo.string.pad(Math.floor(Math.abs(offset) / 60), 2), dojo.string.pad(Math.abs(offset) % 60, 2)];
+ if (l == 4) {
tz.splice(0, 0, "GMT");
tz.splice(3, 0, ":");
}
s = tz.join("");
break;
- case 'Y':
- case 'u':
- case 'W':
- case 'F':
- case 'g':
- case 'A':
- dojo.debug(match+" modifier not yet implemented");
+ case "Y":
+ case "u":
+ case "W":
+ case "F":
+ case "g":
+ case "A":
+ dojo.debug(match + " modifier not yet implemented");
s = "?";
break;
- default:
- dojo.raise("dojo.date.format: invalid pattern char: "+pattern);
+ default:
+ dojo.raise("dojo.date.format: invalid pattern char: " + pattern);
+ }
+ if (pad) {
+ s = dojo.string.pad(s, l);
+ }
+ return s;
+ });
+ }
+ options = options || {};
+ var locale = dojo.hostenv.normalizeLocale(options.locale);
+ var formatLength = options.formatLength || "full";
+ var info = dojo.date._getGregorianBundle(locale);
+ var str = [];
+ var sauce = dojo.lang.curry(this, formatPattern, dateObject);
+ if (options.selector != "timeOnly") {
+ var datePattern = options.datePattern || info["dateFormat-" + formatLength];
+ if (datePattern) {
+ str.push(_processPattern(datePattern, sauce));
}
- if(pad){ s = dojo.string.pad(s, l); }
- return s;
- });
- }
-
- options = options || {};
-
- var locale = dojo.hostenv.normalizeLocale(options.locale);
- var formatLength = options.formatLength || 'full';
- var info = dojo.date._getGregorianBundle(locale);
- var str = [];
- var sauce = dojo.lang.curry(this, formatPattern, dateObject);
- if(options.selector != "timeOnly"){
- var datePattern = options.datePattern || info["dateFormat-"+formatLength];
- if(datePattern){str.push(_processPattern(datePattern, sauce));}
- }
- if(options.selector != "dateOnly"){
- var timePattern = options.timePattern || info["timeFormat-"+formatLength];
- if(timePattern){str.push(_processPattern(timePattern, sauce));}
- }
- var result = str.join(" "); //TODO: use locale-specific pattern to assemble date + time
- return result; /*String*/
-};
-
-dojo.date.parse = function(/*String*/value, /*Object?*/options){
-//
-// summary:
-// Convert a properly formatted string to a primitive Date object,
-// using locale-specific settings.
-//
-// description:
-// Create a Date object from a string using a known localized pattern.
-// By default, this method parses looking for both date and time in the string.
-// Formatting patterns are chosen appropriate to the locale. Different
-// formatting lengths may be chosen, with "full" used by default.
-// Custom patterns may be used or registered with translations using
-// the addCustomBundle method.
-// Formatting patterns are implemented using the syntax described at
-// http://www.unicode.org/reports/tr35/#Date_Format_Patterns
-//
-// value:
-// A string representation of a date
-//
-// options: object {selector: string, formatLength: string, datePattern: string, timePattern: string, locale: string, strict: boolean}
-// selector- choice of timeOnly, dateOnly, dateTime (default: dateOnly)
-// formatLength- choice of long, short, medium or full (plus any custom additions). Defaults to 'full'
-// datePattern,timePattern- override pattern with this string
-// am,pm- override strings for am/pm in times
-// locale- override the locale used to determine formatting rules
-// strict- strict parsing, off by default
-//
-
- options = options || {};
- var locale = dojo.hostenv.normalizeLocale(options.locale);
- var info = dojo.date._getGregorianBundle(locale);
- var formatLength = options.formatLength || 'full';
- if(!options.selector){ options.selector = 'dateOnly'; }
- var datePattern = options.datePattern || info["dateFormat-" + formatLength];
- var timePattern = options.timePattern || info["timeFormat-" + formatLength];
-
- var pattern;
- if(options.selector == 'dateOnly'){
- pattern = datePattern;
- }
- else if(options.selector == 'timeOnly'){
- pattern = timePattern;
- }else if(options.selector == 'dateTime'){
- pattern = datePattern + ' ' + timePattern; //TODO: use locale-specific pattern to assemble date + time
- }else{
- var msg = "dojo.date.parse: Unknown selector param passed: '" + options.selector + "'.";
- msg += " Defaulting to date pattern.";
- dojo.debug(msg);
- pattern = datePattern;
- }
-
- var groups = [];
- var dateREString = _processPattern(pattern, dojo.lang.curry(this, _buildDateTimeRE, groups, info, options));
- var dateRE = new RegExp("^" + dateREString + "$");
-
- var match = dateRE.exec(value);
- if(!match){
- return null;
- }
-
- var widthList = ['abbr', 'wide', 'narrow'];
- //1972 is a leap year. We want to avoid Feb 29 rolling over into Mar 1,
- //in the cases where the year is parsed after the month and day.
- var result = new Date(1972, 0);
- var expected = {};
- for(var i=1; i2) {
- if(!options.strict){
- //Tolerate abbreviating period in month part
- v = v.replace(/\./g,'');
- //Case-insensitive
+ case "M":
+ if (l > 2) {
+ if (!options.strict) {
+ v = v.replace(/\./g, "");
v = v.toLowerCase();
}
- var months = info['months-format-' + widthList[l-3]].concat();
- for (var j=0; j 15
- } else if(v == am && hours == 12){
- result.setHours(0); //12am -> 0
+ if (v == pm && hours < 12) {
+ result.setHours(hours + 12);
+ } else {
+ if (v == am && hours == 12) {
+ result.setHours(0);
+ }
}
break;
- case 'K': //hour (1-24)
- if(v==24){v=0;}
- // fallthrough...
- case 'h': //hour (1-12)
- case 'H': //hour (0-23)
- case 'k': //hour (0-11)
- //TODO: strict bounds checking, padding
- if(v>23){
+ case "K":
+ if (v == 24) {
+ v = 0;
+ }
+ case "h":
+ case "H":
+ case "k":
+ if (v > 23) {
dojo.debug("dojo.date.parse: Illegal hours value");
return null;
}
-
- //in the 12-hour case, adjusting for am/pm requires the 'a' part
- //which for now we will assume always comes after the 'h' part
result.setHours(v);
break;
- case 'm': //minutes
+ case "m":
result.setMinutes(v);
break;
- case 's': //seconds
+ case "s":
result.setSeconds(v);
break;
- case 'S': //milliseconds
+ case "S":
result.setMilliseconds(v);
break;
- default:
+ default:
dojo.unimplemented("dojo.date.parse: unsupported pattern char=" + grp.charAt(0));
+ }
}
- }
-
- //validate parse date fields versus input date fields
- if(expected.year && result.getFullYear() != expected.year){
- dojo.debug("Parsed year: '" + result.getFullYear() + "' did not match input year: '" + expected.year + "'.");
- return null;
- }
- if(expected.month && result.getMonth() != expected.month){
- dojo.debug("Parsed month: '" + result.getMonth() + "' did not match input month: '" + expected.month + "'.");
- return null;
- }
- if(expected.date && result.getDate() != expected.date){
- dojo.debug("Parsed day of month: '" + result.getDate() + "' did not match input day of month: '" + expected.date + "'.");
- return null;
- }
-
- //TODO: implement a getWeekday() method in order to test
- //validity of input strings containing 'EEE' or 'EEEE'...
-
- return result; /*Date*/
-};
-
-function _processPattern(pattern, applyPattern, applyLiteral, applyAll){
- // Process a pattern with literals in it
- // Break up on single quotes, treat every other one as a literal, except '' which becomes '
- var identity = function(x){return x;};
- applyPattern = applyPattern || identity;
- applyLiteral = applyLiteral || identity;
- applyAll = applyAll || identity;
-
- //split on single quotes (which escape literals in date format strings)
- //but preserve escaped single quotes (e.g., o''clock)
- var chunks = pattern.match(/(''|[^'])+/g);
- var literal = false;
-
- for(var i=0; i2) ? '\\S+' : '\\d{1,2}';
+ case "M":
+ s = (l > 2) ? "\\S+" : "\\d{1,2}";
break;
- case 'd':
- s = '\\d{1,2}';
+ case "d":
+ s = "\\d{1,2}";
break;
- case 'E':
- s = '\\S+';
+ case "E":
+ s = "\\S+";
break;
- case 'h':
- case 'H':
- case 'K':
- case 'k':
- s = '\\d{1,2}';
+ case "h":
+ case "H":
+ case "K":
+ case "k":
+ s = "\\d{1,2}";
break;
- case 'm':
- case 's':
- s = '[0-5]\\d';
+ case "m":
+ case "s":
+ s = "[0-5]\\d";
break;
- case 'S':
- s = '\\d{1,3}';
+ case "S":
+ s = "\\d{1,3}";
break;
- case 'a':
- var am = options.am || info.am || 'AM';
- var pm = options.pm || info.pm || 'PM';
- if(options.strict){
- s = am + '|' + pm;
- }else{
+ case "a":
+ var am = options.am || info.am || "AM";
+ var pm = options.pm || info.pm || "PM";
+ if (options.strict) {
+ s = am + "|" + pm;
+ } else {
s = am;
- s += (am != am.toLowerCase()) ? '|' + am.toLowerCase() : '';
- s += '|';
- s += (pm != pm.toLowerCase()) ? pm + '|' + pm.toLowerCase() : pm;
+ s += (am != am.toLowerCase()) ? "|" + am.toLowerCase() : "";
+ s += "|";
+ s += (pm != pm.toLowerCase()) ? pm + "|" + pm.toLowerCase() : pm;
}
break;
- default:
+ default:
dojo.unimplemented("parse of date format, pattern=" + pattern);
- }
-
- if(groups){ groups.push(match); }
-
-//FIXME: replace whitespace within final regexp with more flexible whitespace match instead?
- //tolerate whitespace
- return '\\s*(' + s + ')\\s*';
- });
-}
+ }
+ if (groups) {
+ groups.push(match);
+ }
+ return "\\s*(" + s + ")\\s*";
+ });
+ }
})();
-
-//TODO: try to common strftime and format code somehow?
-
-dojo.date.strftime = function(/*Date*/dateObject, /*String*/format, /*String?*/locale){
-//
-// summary:
-// Formats the date object using the specifications of the POSIX strftime function
-//
-// description:
-// see
-
- // zero pad
+dojo.date.strftime = function (dateObject, format, locale) {
var padChar = null;
- function _(s, n){
+ function _(s, n) {
return dojo.string.pad(s, n || 2, padChar || "0");
}
-
var info = dojo.date._getGregorianBundle(locale);
-
- function $(property){
- switch (property){
- case "a": // abbreviated weekday name according to the current locale
- return dojo.date.getDayShortName(dateObject, locale);
-
- case "A": // full weekday name according to the current locale
- return dojo.date.getDayName(dateObject, locale);
-
- case "b":
- case "h": // abbreviated month name according to the current locale
- return dojo.date.getMonthShortName(dateObject, locale);
-
- case "B": // full month name according to the current locale
- return dojo.date.getMonthName(dateObject, locale);
-
- case "c": // preferred date and time representation for the current
- // locale
- return dojo.date.format(dateObject, {locale: locale});
-
- case "C": // century number (the year divided by 100 and truncated
- // to an integer, range 00 to 99)
- return _(Math.floor(dateObject.getFullYear()/100));
-
- case "d": // day of the month as a decimal number (range 01 to 31)
- return _(dateObject.getDate());
-
- case "D": // same as %m/%d/%y
- return $("m") + "/" + $("d") + "/" + $("y");
-
- case "e": // day of the month as a decimal number, a single digit is
- // preceded by a space (range ' 1' to '31')
- if(padChar == null){ padChar = " "; }
- return _(dateObject.getDate());
-
- case "f": // month as a decimal number, a single digit is
- // preceded by a space (range ' 1' to '12')
- if(padChar == null){ padChar = " "; }
- return _(dateObject.getMonth()+1);
-
- case "g": // like %G, but without the century.
- break;
-
- case "G": // The 4-digit year corresponding to the ISO week number
- // (see %V). This has the same format and value as %Y,
- // except that if the ISO week number belongs to the
- // previous or next year, that year is used instead.
- dojo.unimplemented("unimplemented modifier 'G'");
- break;
-
- case "F": // same as %Y-%m-%d
- return $("Y") + "-" + $("m") + "-" + $("d");
-
- case "H": // hour as a decimal number using a 24-hour clock (range
- // 00 to 23)
- return _(dateObject.getHours());
-
- case "I": // hour as a decimal number using a 12-hour clock (range
- // 01 to 12)
- return _(dateObject.getHours() % 12 || 12);
-
- case "j": // day of the year as a decimal number (range 001 to 366)
- return _(dojo.date.getDayOfYear(dateObject), 3);
-
- case "k": // Hour as a decimal number using a 24-hour clock (range
- // 0 to 23 (space-padded))
- if (padChar == null) { padChar = " "; }
- return _(dateObject.getHours());
-
- case "l": // Hour as a decimal number using a 12-hour clock (range
- // 1 to 12 (space-padded))
- if (padChar == null) { padChar = " "; }
- return _(dateObject.getHours() % 12 || 12);
-
- case "m": // month as a decimal number (range 01 to 12)
- return _(dateObject.getMonth() + 1);
-
- case "M": // minute as a decimal number
- return _(dateObject.getMinutes());
-
- case "n":
- return "\n";
-
- case "p": // either `am' or `pm' according to the given time value,
- // or the corresponding strings for the current locale
- return info[dateObject.getHours() < 12 ? "am" : "pm"];
-
- case "r": // time in a.m. and p.m. notation
- return $("I") + ":" + $("M") + ":" + $("S") + " " + $("p");
-
- case "R": // time in 24 hour notation
- return $("H") + ":" + $("M");
-
- case "S": // second as a decimal number
- return _(dateObject.getSeconds());
-
- case "t":
- return "\t";
-
- case "T": // current time, equal to %H:%M:%S
- return $("H") + ":" + $("M") + ":" + $("S");
-
- case "u": // weekday as a decimal number [1,7], with 1 representing
- // Monday
- return String(dateObject.getDay() || 7);
-
- case "U": // week number of the current year as a decimal number,
- // starting with the first Sunday as the first day of the
- // first week
- return _(dojo.date.getWeekOfYear(dateObject));
-
- case "V": // week number of the year (Monday as the first day of the
- // week) as a decimal number [01,53]. If the week containing
- // 1 January has four or more days in the new year, then it
- // is considered week 1. Otherwise, it is the last week of
- // the previous year, and the next week is week 1.
- return _(dojo.date.getIsoWeekOfYear(dateObject));
-
- case "W": // week number of the current year as a decimal number,
- // starting with the first Monday as the first day of the
- // first week
- return _(dojo.date.getWeekOfYear(dateObject, 1));
-
- case "w": // day of the week as a decimal, Sunday being 0
- return String(dateObject.getDay());
-
- case "x": // preferred date representation for the current locale
- // without the time
- return dojo.date.format(dateObject, {selector:'dateOnly', locale:locale});
-
- case "X": // preferred time representation for the current locale
- // without the date
- return dojo.date.format(dateObject, {selector:'timeOnly', locale:locale});
-
- case "y": // year as a decimal number without a century (range 00 to
- // 99)
- return _(dateObject.getFullYear()%100);
-
- case "Y": // year as a decimal number including the century
- return String(dateObject.getFullYear());
-
- case "z": // time zone or name or abbreviation
- var timezoneOffset = dateObject.getTimezoneOffset();
- return (timezoneOffset > 0 ? "-" : "+") +
- _(Math.floor(Math.abs(timezoneOffset)/60)) + ":" +
- _(Math.abs(timezoneOffset)%60);
-
- case "Z": // time zone or name or abbreviation
- return dojo.date.getTimezoneName(dateObject);
-
- case "%":
- return "%";
+ function $(property) {
+ switch (property) {
+ case "a":
+ return dojo.date.getDayShortName(dateObject, locale);
+ case "A":
+ return dojo.date.getDayName(dateObject, locale);
+ case "b":
+ case "h":
+ return dojo.date.getMonthShortName(dateObject, locale);
+ case "B":
+ return dojo.date.getMonthName(dateObject, locale);
+ case "c":
+ return dojo.date.format(dateObject, {locale:locale});
+ case "C":
+ return _(Math.floor(dateObject.getFullYear() / 100));
+ case "d":
+ return _(dateObject.getDate());
+ case "D":
+ return $("m") + "/" + $("d") + "/" + $("y");
+ case "e":
+ if (padChar == null) {
+ padChar = " ";
+ }
+ return _(dateObject.getDate());
+ case "f":
+ if (padChar == null) {
+ padChar = " ";
+ }
+ return _(dateObject.getMonth() + 1);
+ case "g":
+ break;
+ case "G":
+ dojo.unimplemented("unimplemented modifier 'G'");
+ break;
+ case "F":
+ return $("Y") + "-" + $("m") + "-" + $("d");
+ case "H":
+ return _(dateObject.getHours());
+ case "I":
+ return _(dateObject.getHours() % 12 || 12);
+ case "j":
+ return _(dojo.date.getDayOfYear(dateObject), 3);
+ case "k":
+ if (padChar == null) {
+ padChar = " ";
+ }
+ return _(dateObject.getHours());
+ case "l":
+ if (padChar == null) {
+ padChar = " ";
+ }
+ return _(dateObject.getHours() % 12 || 12);
+ case "m":
+ return _(dateObject.getMonth() + 1);
+ case "M":
+ return _(dateObject.getMinutes());
+ case "n":
+ return "\n";
+ case "p":
+ return info[dateObject.getHours() < 12 ? "am" : "pm"];
+ case "r":
+ return $("I") + ":" + $("M") + ":" + $("S") + " " + $("p");
+ case "R":
+ return $("H") + ":" + $("M");
+ case "S":
+ return _(dateObject.getSeconds());
+ case "t":
+ return "\t";
+ case "T":
+ return $("H") + ":" + $("M") + ":" + $("S");
+ case "u":
+ return String(dateObject.getDay() || 7);
+ case "U":
+ return _(dojo.date.getWeekOfYear(dateObject));
+ case "V":
+ return _(dojo.date.getIsoWeekOfYear(dateObject));
+ case "W":
+ return _(dojo.date.getWeekOfYear(dateObject, 1));
+ case "w":
+ return String(dateObject.getDay());
+ case "x":
+ return dojo.date.format(dateObject, {selector:"dateOnly", locale:locale});
+ case "X":
+ return dojo.date.format(dateObject, {selector:"timeOnly", locale:locale});
+ case "y":
+ return _(dateObject.getFullYear() % 100);
+ case "Y":
+ return String(dateObject.getFullYear());
+ case "z":
+ var timezoneOffset = dateObject.getTimezoneOffset();
+ return (timezoneOffset > 0 ? "-" : "+") + _(Math.floor(Math.abs(timezoneOffset) / 60)) + ":" + _(Math.abs(timezoneOffset) % 60);
+ case "Z":
+ return dojo.date.getTimezoneName(dateObject);
+ case "%":
+ return "%";
}
}
-
- // parse the formatting string and construct the resulting string
var string = "";
var i = 0;
var index = 0;
var switchCase = null;
- while ((index = format.indexOf("%", i)) != -1){
+ while ((index = format.indexOf("%", i)) != -1) {
string += format.substring(i, index++);
-
- // inspect modifier flag
switch (format.charAt(index++)) {
- case "_": // Pad a numeric result string with spaces.
- padChar = " "; break;
- case "-": // Do not pad a numeric result string.
- padChar = ""; break;
- case "0": // Pad a numeric result string with zeros.
- padChar = "0"; break;
- case "^": // Convert characters in result string to uppercase.
- switchCase = "upper"; break;
- case "*": // Convert characters in result string to lowercase
- switchCase = "lower"; break;
- case "#": // Swap the case of the result string.
- switchCase = "swap"; break;
- default: // no modifier flag so decrement the index
- padChar = null; index--; break;
+ case "_":
+ padChar = " ";
+ break;
+ case "-":
+ padChar = "";
+ break;
+ case "0":
+ padChar = "0";
+ break;
+ case "^":
+ switchCase = "upper";
+ break;
+ case "*":
+ switchCase = "lower";
+ break;
+ case "#":
+ switchCase = "swap";
+ break;
+ default:
+ padChar = null;
+ index--;
+ break;
}
-
- // toggle case if a flag is set
var property = $(format.charAt(index++));
- switch (switchCase){
- case "upper":
- property = property.toUpperCase();
- break;
- case "lower":
- property = property.toLowerCase();
- break;
- case "swap": // Upper to lower, and versey-vicea
- var compareString = property.toLowerCase();
- var swapString = '';
- var j = 0;
- var ch = '';
- while (j < property.length){
- ch = property.charAt(j);
- swapString += (ch == compareString.charAt(j)) ?
- ch.toUpperCase() : ch.toLowerCase();
- j++;
- }
- property = swapString;
- break;
- default:
- break;
+ switch (switchCase) {
+ case "upper":
+ property = property.toUpperCase();
+ break;
+ case "lower":
+ property = property.toLowerCase();
+ break;
+ case "swap":
+ var compareString = property.toLowerCase();
+ var swapString = "";
+ var j = 0;
+ var ch = "";
+ while (j < property.length) {
+ ch = property.charAt(j);
+ swapString += (ch == compareString.charAt(j)) ? ch.toUpperCase() : ch.toLowerCase();
+ j++;
+ }
+ property = swapString;
+ break;
+ default:
+ break;
}
switchCase = null;
-
string += property;
i = index;
}
string += format.substring(i);
-
- return string; // String
-};
-
-(function(){
-var _customFormats = [];
-dojo.date.addCustomFormats = function(/*String*/packageName, /*String*/bundleName){
-//
-// summary:
-// Add a reference to a bundle containing localized custom formats to be
-// used by date/time formatting and parsing routines.
-//
-// description:
-// The user may add custom localized formats where the bundle has properties following the
-// same naming convention used by dojo for the CLDR data: dateFormat-xxxx / timeFormat-xxxx
-// The pattern string should match the format used by the CLDR.
-// See dojo.date.format for details.
-// The resources must be loaded by dojo.requireLocalization() prior to use
-
- _customFormats.push({pkg:packageName,name:bundleName});
-};
-
-dojo.date._getGregorianBundle = function(/*String*/locale){
- var gregorian = {};
- dojo.lang.forEach(_customFormats, function(desc){
- var bundle = dojo.i18n.getLocalization(desc.pkg, desc.name, locale);
- gregorian = dojo.lang.mixin(gregorian, bundle);
- }, this);
- return gregorian; /*Object*/
+ return string;
};
+(function () {
+ var _customFormats = [];
+ dojo.date.addCustomFormats = function (packageName, bundleName) {
+ _customFormats.push({pkg:packageName, name:bundleName});
+ };
+ dojo.date._getGregorianBundle = function (locale) {
+ var gregorian = {};
+ dojo.lang.forEach(_customFormats, function (desc) {
+ var bundle = dojo.i18n.getLocalization(desc.pkg, desc.name, locale);
+ gregorian = dojo.lang.mixin(gregorian, bundle);
+ }, this);
+ return gregorian;
+ };
})();
-
-dojo.date.addCustomFormats("dojo.i18n.calendar","gregorian");
-dojo.date.addCustomFormats("dojo.i18n.calendar","gregorianExtras");
-
-dojo.date.getNames = function(/*String*/item, /*String*/type, /*String?*/use, /*String?*/locale){
-//
-// summary:
-// Used to get localized strings for day or month names.
-//
-// item: 'months' || 'days'
-// type: 'wide' || 'narrow' || 'abbr' (e.g. "Monday", "Mon", or "M" respectively, in English)
-// use: 'standAlone' || 'format' (default)
-// locale: override locale used to find the names
-
+dojo.date.addCustomFormats("dojo.i18n.calendar", "gregorian");
+dojo.date.addCustomFormats("dojo.i18n.calendar", "gregorianExtras");
+dojo.date.getNames = function (item, type, use, locale) {
var label;
var lookup = dojo.date._getGregorianBundle(locale);
var props = [item, use, type];
- if(use == 'standAlone'){
- label = lookup[props.join('-')];
+ if (use == "standAlone") {
+ label = lookup[props.join("-")];
}
- props[1] = 'format';
-
- // return by copy so changes won't be made accidentally to the in-memory model
- return (label || lookup[props.join('-')]).concat(); /*Array*/
+ props[1] = "format";
+ return (label || lookup[props.join("-")]).concat();
};
-
-// Convenience methods
-
-dojo.date.getDayName = function(/*Date*/dateObject, /*String?*/locale){
-// summary: gets the full localized day of the week corresponding to the date object
- return dojo.date.getNames('days', 'wide', 'format', locale)[dateObject.getDay()]; /*String*/
+dojo.date.getDayName = function (dateObject, locale) {
+ return dojo.date.getNames("days", "wide", "format", locale)[dateObject.getDay()];
};
-
-dojo.date.getDayShortName = function(/*Date*/dateObject, /*String?*/locale){
-// summary: gets the abbreviated localized day of the week corresponding to the date object
- return dojo.date.getNames('days', 'abbr', 'format', locale)[dateObject.getDay()]; /*String*/
+dojo.date.getDayShortName = function (dateObject, locale) {
+ return dojo.date.getNames("days", "abbr", "format", locale)[dateObject.getDay()];
};
-
-dojo.date.getMonthName = function(/*Date*/dateObject, /*String?*/locale){
-// summary: gets the full localized month name corresponding to the date object
- return dojo.date.getNames('months', 'wide', 'format', locale)[dateObject.getMonth()]; /*String*/
+dojo.date.getMonthName = function (dateObject, locale) {
+ return dojo.date.getNames("months", "wide", "format", locale)[dateObject.getMonth()];
};
-
-dojo.date.getMonthShortName = function(/*Date*/dateObject, /*String?*/locale){
-// summary: gets the abbreviated localized month name corresponding to the date object
- return dojo.date.getNames('months', 'abbr', 'format', locale)[dateObject.getMonth()]; /*String*/
+dojo.date.getMonthShortName = function (dateObject, locale) {
+ return dojo.date.getNames("months", "abbr", "format", locale)[dateObject.getMonth()];
};
-
-//FIXME: not localized
-dojo.date.toRelativeString = function(/*Date*/dateObject){
-// summary:
-// Returns an description in English of the date relative to the current date. Note: this is not localized yet. English only.
-//
-// description: Example returns:
-// - "1 minute ago"
-// - "4 minutes ago"
-// - "Yesterday"
-// - "2 days ago"
-
+dojo.date.toRelativeString = function (dateObject) {
var now = new Date();
var diff = (now - dateObject) / 1000;
var end = " ago";
var future = false;
- if(diff < 0){
+ if (diff < 0) {
future = true;
end = " from now";
diff = -diff;
}
-
- if(diff < 60){
+ if (diff < 60) {
diff = Math.round(diff);
return diff + " second" + (diff == 1 ? "" : "s") + end;
}
- if(diff < 60*60){
- diff = Math.round(diff/60);
+ if (diff < 60 * 60) {
+ diff = Math.round(diff / 60);
return diff + " minute" + (diff == 1 ? "" : "s") + end;
}
- if(diff < 60*60*24){
- diff = Math.round(diff/3600);
+ if (diff < 60 * 60 * 24) {
+ diff = Math.round(diff / 3600);
return diff + " hour" + (diff == 1 ? "" : "s") + end;
}
- if(diff < 60*60*24*7){
- diff = Math.round(diff/(3600*24));
- if(diff == 1){
+ if (diff < 60 * 60 * 24 * 7) {
+ diff = Math.round(diff / (3600 * 24));
+ if (diff == 1) {
return future ? "Tomorrow" : "Yesterday";
- }else{
+ } else {
return diff + " days" + end;
}
}
- return dojo.date.format(dateObject); // String
+ return dojo.date.format(dateObject);
};
-
-//FIXME: SQL methods can probably be moved to a different module without i18n deps
-
-dojo.date.toSql = function(/*Date*/dateObject, /*Boolean?*/noTime){
-// summary:
-// Convert a Date to a SQL string
-// noTime: whether to ignore the time portion of the Date. Defaults to false.
-
- return dojo.date.strftime(dateObject, "%F" + !noTime ? " %T" : ""); // String
+dojo.date.toSql = function (dateObject, noTime) {
+ return dojo.date.strftime(dateObject, "%F" + !noTime ? " %T" : "");
};
-
-dojo.date.fromSql = function(/*String*/sqlDate){
-// summary:
-// Convert a SQL date string to a JavaScript Date object
-
+dojo.date.fromSql = function (sqlDate) {
var parts = sqlDate.split(/[\- :]/g);
- while(parts.length < 6){
+ while (parts.length < 6) {
parts.push(0);
}
- return new Date(parts[0], (parseInt(parts[1],10)-1), parts[2], parts[3], parts[4], parts[5]); // Date
+ return new Date(parts[0], (parseInt(parts[1], 10) - 1), parts[2], parts[3], parts[4], parts[5]);
};
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/serialize.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/serialize.js
index 6a43f9863..be62df5cc 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/serialize.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/serialize.js
@@ -9,33 +9,24 @@
*/
dojo.provide("dojo.date.serialize");
-
dojo.require("dojo.string.common");
-
-/* ISO 8601 Functions
- *********************/
-
-dojo.date.setIso8601 = function(/*Date*/dateObject, /*String*/formattedString){
- // summary: sets a Date object based on an ISO 8601 formatted string (uses date and time)
+dojo.date.setIso8601 = function (dateObject, formattedString) {
var comps = (formattedString.indexOf("T") == -1) ? formattedString.split(" ") : formattedString.split("T");
dateObject = dojo.date.setIso8601Date(dateObject, comps[0]);
- if(comps.length == 2){ dateObject = dojo.date.setIso8601Time(dateObject, comps[1]); }
- return dateObject; /* Date or null */
+ if (comps.length == 2) {
+ dateObject = dojo.date.setIso8601Time(dateObject, comps[1]);
+ }
+ return dateObject;
};
-
-dojo.date.fromIso8601 = function(/*String*/formattedString){
- // summary: returns a Date object based on an ISO 8601 formatted string (uses date and time)
+dojo.date.fromIso8601 = function (formattedString) {
return dojo.date.setIso8601(new Date(0, 0), formattedString);
};
-
-dojo.date.setIso8601Date = function(/*String*/dateObject, /*String*/formattedString){
- // summary: sets a Date object based on an ISO 8601 formatted string (date only)
- var regexp = "^([0-9]{4})((-?([0-9]{2})(-?([0-9]{2}))?)|" +
- "(-?([0-9]{3}))|(-?W([0-9]{2})(-?([1-7]))?))?$";
+dojo.date.setIso8601Date = function (dateObject, formattedString) {
+ var regexp = "^([0-9]{4})((-?([0-9]{2})(-?([0-9]{2}))?)|" + "(-?([0-9]{3}))|(-?W([0-9]{2})(-?([1-7]))?))?$";
var d = formattedString.match(new RegExp(regexp));
- if(!d){
+ if (!d) {
dojo.debug("invalid date string: " + formattedString);
- return null; // null
+ return null;
}
var year = d[1];
var month = d[4];
@@ -43,133 +34,94 @@ dojo.date.setIso8601Date = function(/*String*/dateObject, /*String*/formattedStr
var dayofyear = d[8];
var week = d[10];
var dayofweek = d[12] ? d[12] : 1;
-
dateObject.setFullYear(year);
-
- if(dayofyear){
+ if (dayofyear) {
dateObject.setMonth(0);
dateObject.setDate(Number(dayofyear));
- }
- else if(week){
- dateObject.setMonth(0);
- dateObject.setDate(1);
- var gd = dateObject.getDay();
- var day = gd ? gd : 7;
- var offset = Number(dayofweek) + (7 * Number(week));
-
- if(day <= 4){ dateObject.setDate(offset + 1 - day); }
- else{ dateObject.setDate(offset + 8 - day); }
- } else{
- if(month){
+ } else {
+ if (week) {
+ dateObject.setMonth(0);
dateObject.setDate(1);
- dateObject.setMonth(month - 1);
+ var gd = dateObject.getDay();
+ var day = gd ? gd : 7;
+ var offset = Number(dayofweek) + (7 * Number(week));
+ if (day <= 4) {
+ dateObject.setDate(offset + 1 - day);
+ } else {
+ dateObject.setDate(offset + 8 - day);
+ }
+ } else {
+ if (month) {
+ dateObject.setDate(1);
+ dateObject.setMonth(month - 1);
+ }
+ if (date) {
+ dateObject.setDate(date);
+ }
}
- if(date){ dateObject.setDate(date); }
}
-
- return dateObject; // Date
+ return dateObject;
};
-
-dojo.date.fromIso8601Date = function(/*String*/formattedString){
- // summary: returns a Date object based on an ISO 8601 formatted string (date only)
+dojo.date.fromIso8601Date = function (formattedString) {
return dojo.date.setIso8601Date(new Date(0, 0), formattedString);
};
-
-dojo.date.setIso8601Time = function(/*Date*/dateObject, /*String*/formattedString){
- // summary: sets a Date object based on an ISO 8601 formatted string (time only)
-
- // first strip timezone info from the end
+dojo.date.setIso8601Time = function (dateObject, formattedString) {
var timezone = "Z|(([-+])([0-9]{2})(:?([0-9]{2}))?)$";
var d = formattedString.match(new RegExp(timezone));
-
- var offset = 0; // local time if no tz info
- if(d){
- if(d[0] != 'Z'){
+ var offset = 0;
+ if (d) {
+ if (d[0] != "Z") {
offset = (Number(d[3]) * 60) + Number(d[5]);
- offset *= ((d[2] == '-') ? 1 : -1);
+ offset *= ((d[2] == "-") ? 1 : -1);
}
offset -= dateObject.getTimezoneOffset();
formattedString = formattedString.substr(0, formattedString.length - d[0].length);
}
-
- // then work out the time
- var regexp = "^([0-9]{2})(:?([0-9]{2})(:?([0-9]{2})(\.([0-9]+))?)?)?$";
+ var regexp = "^([0-9]{2})(:?([0-9]{2})(:?([0-9]{2})(.([0-9]+))?)?)?$";
d = formattedString.match(new RegExp(regexp));
- if(!d){
+ if (!d) {
dojo.debug("invalid time string: " + formattedString);
- return null; // null
+ return null;
}
var hours = d[1];
var mins = Number((d[3]) ? d[3] : 0);
var secs = (d[5]) ? d[5] : 0;
var ms = d[7] ? (Number("0." + d[7]) * 1000) : 0;
-
dateObject.setHours(hours);
dateObject.setMinutes(mins);
dateObject.setSeconds(secs);
dateObject.setMilliseconds(ms);
-
- if(offset !== 0){
+ if (offset !== 0) {
dateObject.setTime(dateObject.getTime() + offset * 60000);
- }
- return dateObject; // Date
+ }
+ return dateObject;
};
-
-dojo.date.fromIso8601Time = function(/*String*/formattedString){
- // summary: returns a Date object based on an ISO 8601 formatted string (date only)
+dojo.date.fromIso8601Time = function (formattedString) {
return dojo.date.setIso8601Time(new Date(0, 0), formattedString);
};
-
-
-/* RFC-3339 Date Functions
- *************************/
-
-dojo.date.toRfc3339 = function(/*Date?*/dateObject, /*String?*/selector){
-// summary:
-// Format a JavaScript Date object as a string according to RFC 3339
-//
-// dateObject:
-// A JavaScript date, or the current date and time, by default
-//
-// selector:
-// "dateOnly" or "timeOnly" to format selected portions of the Date object.
-// Date and time will be formatted by default.
-
-//FIXME: tolerate Number, string input?
- if(!dateObject){
+dojo.date.toRfc3339 = function (dateObject, selector) {
+ if (!dateObject) {
dateObject = new Date();
}
-
var _ = dojo.string.pad;
var formattedDate = [];
- if(selector != "timeOnly"){
- var date = [_(dateObject.getFullYear(),4), _(dateObject.getMonth()+1,2), _(dateObject.getDate(),2)].join('-');
+ if (selector != "timeOnly") {
+ var date = [_(dateObject.getFullYear(), 4), _(dateObject.getMonth() + 1, 2), _(dateObject.getDate(), 2)].join("-");
formattedDate.push(date);
}
- if(selector != "dateOnly"){
- var time = [_(dateObject.getHours(),2), _(dateObject.getMinutes(),2), _(dateObject.getSeconds(),2)].join(':');
+ if (selector != "dateOnly") {
+ var time = [_(dateObject.getHours(), 2), _(dateObject.getMinutes(), 2), _(dateObject.getSeconds(), 2)].join(":");
var timezoneOffset = dateObject.getTimezoneOffset();
- time += (timezoneOffset > 0 ? "-" : "+") +
- _(Math.floor(Math.abs(timezoneOffset)/60),2) + ":" +
- _(Math.abs(timezoneOffset)%60,2);
+ time += (timezoneOffset > 0 ? "-" : "+") + _(Math.floor(Math.abs(timezoneOffset) / 60), 2) + ":" + _(Math.abs(timezoneOffset) % 60, 2);
formattedDate.push(time);
}
- return formattedDate.join('T'); // String
+ return formattedDate.join("T");
};
-
-dojo.date.fromRfc3339 = function(/*String*/rfcDate){
-// summary:
-// Create a JavaScript Date object from a string formatted according to RFC 3339
-//
-// rfcDate:
-// A string such as 2005-06-30T08:05:00-07:00
-// "any" is also supported in place of a time.
-
- // backwards compatible support for use of "any" instead of just not
- // including the time
- if(rfcDate.indexOf("Tany")!=-1){
- rfcDate = rfcDate.replace("Tany","");
+dojo.date.fromRfc3339 = function (rfcDate) {
+ if (rfcDate.indexOf("Tany") != -1) {
+ rfcDate = rfcDate.replace("Tany", "");
}
var dateObject = new Date();
- return dojo.date.setIso8601(dateObject, rfcDate); // Date or null
+ return dojo.date.setIso8601(dateObject, rfcDate);
};
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/supplemental.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/supplemental.js
index 898c7f3df..e0bcd0771 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/supplemental.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/date/supplemental.js
@@ -9,68 +9,37 @@
*/
dojo.provide("dojo.date.supplemental");
-
-dojo.date.getFirstDayOfWeek = function(/*String?*/locale){
-// summary: Returns a zero-based index for first day of the week
-// description:
-// Returns a zero-based index for first day of the week, as used by the local (Gregorian) calendar.
-// e.g. Sunday (returns 0), or Monday (returns 1)
-
- // from http://www.unicode.org/cldr/data/common/supplemental/supplementalData.xml:supplementalData/weekData/firstDay
- var firstDay = {/*default is 1=Monday*/
- mv:5,
- ae:6,af:6,bh:6,dj:6,dz:6,eg:6,er:6,et:6,iq:6,ir:6,jo:6,ke:6,kw:6,lb:6,ly:6,ma:6,om:6,qa:6,sa:6,
- sd:6,so:6,tn:6,ye:6,
- as:0,au:0,az:0,bw:0,ca:0,cn:0,fo:0,ge:0,gl:0,gu:0,hk:0,ie:0,il:0,is:0,jm:0,jp:0,kg:0,kr:0,la:0,
- mh:0,mo:0,mp:0,mt:0,nz:0,ph:0,pk:0,sg:0,th:0,tt:0,tw:0,um:0,us:0,uz:0,vi:0,za:0,zw:0,
- et:0,mw:0,ng:0,tj:0,
- gb:0,
- sy:4
- };
-
+dojo.date.getFirstDayOfWeek = function (locale) {
+ var firstDay = {mv:5, ae:6, af:6, bh:6, dj:6, dz:6, eg:6, er:6, et:6, iq:6, ir:6, jo:6, ke:6, kw:6, lb:6, ly:6, ma:6, om:6, qa:6, sa:6, sd:6, so:6, tn:6, ye:6, as:0, au:0, az:0, bw:0, ca:0, cn:0, fo:0, ge:0, gl:0, gu:0, hk:0, ie:0, il:0, is:0, jm:0, jp:0, kg:0, kr:0, la:0, mh:0, mo:0, mp:0, mt:0, nz:0, ph:0, pk:0, sg:0, th:0, tt:0, tw:0, um:0, us:0, uz:0, vi:0, za:0, zw:0, et:0, mw:0, ng:0, tj:0, gb:0, sy:4};
locale = dojo.hostenv.normalizeLocale(locale);
var country = locale.split("-")[1];
var dow = firstDay[country];
- return (typeof dow == 'undefined') ? 1 : dow; /*Number*/
+ return (typeof dow == "undefined") ? 1 : dow;
};
-
-dojo.date.getWeekend = function(/*String?*/locale){
-// summary: Returns a hash containing the start and end days of the weekend
-// description:
-// Returns a hash containing the start and end days of the weekend according to local custom using locale,
-// or by default in the user's locale.
-// e.g. {start:6, end:0}
-
- // from http://www.unicode.org/cldr/data/common/supplemental/supplementalData.xml:supplementalData/weekData/weekend{Start,End}
- var weekendStart = {/*default is 6=Saturday*/
- eg:5,il:5,sy:5,
- 'in':0,
- ae:4,bh:4,dz:4,iq:4,jo:4,kw:4,lb:4,ly:4,ma:4,om:4,qa:4,sa:4,sd:4,tn:4,ye:4
- };
-
- var weekendEnd = {/*default is 0=Sunday*/
- ae:5,bh:5,dz:5,iq:5,jo:5,kw:5,lb:5,ly:5,ma:5,om:5,qa:5,sa:5,sd:5,tn:5,ye:5,af:5,ir:5,
- eg:6,il:6,sy:6
- };
-
+dojo.date.getWeekend = function (locale) {
+ var weekendStart = {eg:5, il:5, sy:5, "in":0, ae:4, bh:4, dz:4, iq:4, jo:4, kw:4, lb:4, ly:4, ma:4, om:4, qa:4, sa:4, sd:4, tn:4, ye:4};
+ var weekendEnd = {ae:5, bh:5, dz:5, iq:5, jo:5, kw:5, lb:5, ly:5, ma:5, om:5, qa:5, sa:5, sd:5, tn:5, ye:5, af:5, ir:5, eg:6, il:6, sy:6};
locale = dojo.hostenv.normalizeLocale(locale);
var country = locale.split("-")[1];
var start = weekendStart[country];
var end = weekendEnd[country];
- if(typeof start == 'undefined'){start=6;}
- if(typeof end == 'undefined'){end=0;}
- return {start:start, end:end}; /*Object {start,end}*/
+ if (typeof start == "undefined") {
+ start = 6;
+ }
+ if (typeof end == "undefined") {
+ end = 0;
+ }
+ return {start:start, end:end};
};
-
-dojo.date.isWeekend = function(/*Date?*/dateObj, /*String?*/locale){
-// summary:
-// Determines if the date falls on a weekend, according to local custom.
-
+dojo.date.isWeekend = function (dateObj, locale) {
var weekend = dojo.date.getWeekend(locale);
var day = (dateObj || new Date()).getDay();
- if(weekend.end= weekend.start && day <= weekend.end; // Boolean
+ return day >= weekend.start && day <= weekend.end;
};
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/debug.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/debug.js
index d68706e37..3c9c9a59a 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/debug.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/debug.js
@@ -8,29 +8,26 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-dojo.debug = function(/*...*/){
- // summary:
- // Produce a line of debug output. Does nothing unless
- // djConfig.isDebug is true. Accepts any nubmer of args, joined with
- // '' to produce a single line of debugging output. Caller should not
- // supply a trailing "\n".
- if (!djConfig.isDebug) { return; }
+dojo.provide("dojo.debug");
+dojo.debug = function () {
+ if (!djConfig.isDebug) {
+ return;
+ }
var args = arguments;
- if(dj_undef("println", dojo.hostenv)){
+ if (dj_undef("println", dojo.hostenv)) {
dojo.raise("dojo.debug not available (yet?)");
}
var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser;
- var s = [(isJUM ? "": "DEBUG: ")];
- for(var i=0;i 0.4");
}
}
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/debug/console.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/debug/console.js
index 99bf32b3d..729dde565 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/debug/console.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/debug/console.js
@@ -10,106 +10,86 @@
dojo.provide("dojo.debug.console");
dojo.require("dojo.logging.ConsoleLogger");
-
-// summary:
-// Console logger, for use with FireFox Firebug, Safari and Opera's consoles.
-// description:
-// This package redirects the normal dojo debugging output to the console log in modern browsers.
-// When using Firebug, it does this by sending the entire object to the console,
-// rather than just overriding dojo.hostenv.println, so that Firebug's interactive
-// object inspector is available.
-// see: http://www.joehewitt.com/software/firebug/docs.php
-
if (window.console) {
if (console.info != null) {
- // using a later version of Firebug -- lots of fun stuff!
-
- dojo.hostenv.println = function() {
- // summary: Write all of the arguments to the Firebug console
- // description: Uses console.info() so that the (i) icon prints next to the debug line
- // rather than munging the arguments by adding "DEBUG:" in front of them.
- // This allows us to use Firebug's string handling to do interesting things
- if (!djConfig.isDebug) { return; }
+ dojo.hostenv.println = function () {
+ if (!djConfig.isDebug) {
+ return;
+ }
console.info.apply(console, arguments);
- }
- dojo.debug=dojo.hostenv.println;
+ };
+ dojo.debug = dojo.hostenv.println;
dojo.debugDeep = dojo.debug;
-
- dojo.debugShallow = function(/*Object*/ obj, /*Boolean?*/showMethods, /*Boolean?*/sort) {
- // summary: Write first-level properties of obj to the console.
- // obj: Object or Array to debug
- // showMethods: Pass false to skip outputing methods of object, any other value will output them.
- // sort: Pass false to skip sorting properties, any other value will sort.
- if (!djConfig.isDebug) { return; }
-
+ dojo.debugShallow = function (obj, showMethods, sort) {
+ if (!djConfig.isDebug) {
+ return;
+ }
showMethods = (showMethods != false);
sort = (sort != false);
-
- // handle null or something without a constructor (in which case we don't know the type)
if (obj == null || obj.constructor == null) {
return dojo.debug(obj);
}
-
- // figure out type via a standard constructor (Object, String, Date, etc)
var type = obj.declaredClass;
if (type == null) {
type = obj.constructor.toString().match(/function\s*(.*)\(/);
- if (type) { type = type[1] };
+ if (type) {
+ type = type[1];
+ }
}
- // if we got a viable type, use Firebug's interactive property dump feature
if (type) {
if (type == "String" || type == "Number") {
- return dojo.debug(type+": ", obj);
+ return dojo.debug(type + ": ", obj);
}
if (showMethods && !sort) {
var sortedObj = obj;
} else {
var propNames = [];
if (showMethods) {
- for (var prop in obj) {
+ for (var prop in obj) {
propNames.push(prop);
}
} else {
- for (var prop in obj) {
- if (typeof obj[prop] != "function") { propNames.push(prop); }
- else dojo.debug(prop);
- }
+ for (var prop in obj) {
+ if (typeof obj[prop] != "function") {
+ propNames.push(prop);
+ } else {
+ dojo.debug(prop);
+ }
+ }
+ }
+ if (sort) {
+ propNames.sort();
}
- if (sort) propNames.sort();
var sortedObj = {};
- dojo.lang.forEach(propNames, function(prop) {
+ dojo.lang.forEach(propNames, function (prop) {
sortedObj[prop] = obj[prop];
});
}
-
- return dojo.debug(type+": %o\n%2.o",obj,sortedObj);
+ return dojo.debug(type + ": %o\n%2.o", obj, sortedObj);
}
-
- // otherwise just output the constructor + object,
- // which is nice for a DOM element, etc
return dojo.debug(obj.constructor + ": ", obj);
- }
-
- } else if (console.log != null) {
- // using Safari or an old version of Firebug
- dojo.hostenv.println=function() {
- if (!djConfig.isDebug) { return ; }
- // make sure we're only writing a single string to Safari's console
- var args = dojo.lang.toArray(arguments);
- console.log("DEBUG: " + args.join(" "));
- }
- dojo.debug=dojo.hostenv.println;
+ };
} else {
- // not supported
- dojo.debug("dojo.debug.console requires Firebug > 0.4");
+ if (console.log != null) {
+ dojo.hostenv.println = function () {
+ if (!djConfig.isDebug) {
+ return;
+ }
+ var args = dojo.lang.toArray(arguments);
+ console.log("DEBUG: " + args.join(" "));
+ };
+ dojo.debug = dojo.hostenv.println;
+ } else {
+ dojo.debug("dojo.debug.console requires Firebug > 0.4");
+ }
}
-} else if (dojo.render.html.opera) {
- // using Opera 8.0 or later
- if (opera && opera.postError) {
- dojo.hostenv.println=opera.postError;
- // summary: hook debugging up to Opera's postError routine
- } else {
- dojo.debug("dojo.debug.Opera requires Opera > 8.0");
+} else {
+ if (dojo.render.html.opera) {
+ if (opera && opera.postError) {
+ dojo.hostenv.println = opera.postError;
+ } else {
+ dojo.debug("dojo.debug.Opera requires Opera > 8.0");
+ }
}
}
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/DragAndDrop.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/DragAndDrop.js
index 19d38f588..911d43339 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/DragAndDrop.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/DragAndDrop.js
@@ -9,165 +9,66 @@
*/
dojo.require("dojo.lang.common");
+dojo.require("dojo.lang.func");
dojo.require("dojo.lang.declare");
dojo.provide("dojo.dnd.DragAndDrop");
-
-dojo.declare("dojo.dnd.DragSource", null, {
- type: "",
-
- onDragEnd: function(){
- },
-
- onDragStart: function(){
- },
-
- /*
- * This function gets called when the DOM element was
- * selected for dragging by the HtmlDragAndDropManager.
- */
- onSelected: function(){
- },
-
- unregister: function(){
- dojo.dnd.dragManager.unregisterDragSource(this);
- },
-
- reregister: function(){
- dojo.dnd.dragManager.registerDragSource(this);
- }
-}, function(){
-
- //dojo.profile.start("DragSource");
-
+dojo.declare("dojo.dnd.DragSource", null, {type:"", onDragEnd:function (evt) {
+}, onDragStart:function (evt) {
+}, onSelected:function (evt) {
+}, unregister:function () {
+ dojo.dnd.dragManager.unregisterDragSource(this);
+}, reregister:function () {
+ dojo.dnd.dragManager.registerDragSource(this);
+}});
+dojo.declare("dojo.dnd.DragObject", null, {type:"", register:function () {
var dm = dojo.dnd.dragManager;
- if(dm["registerDragSource"]){ // side-effect prevention
- dm.registerDragSource(this);
- }
-
- //dojo.profile.end("DragSource");
-
-});
-
-dojo.declare("dojo.dnd.DragObject", null, {
- type: "",
-
- onDragStart: function(){
- // gets called directly after being created by the DragSource
- // default action is to clone self as icon
- },
-
- onDragMove: function(){
- // this changes the UI for the drag icon
- // "it moves itself"
- },
-
- onDragOver: function(){
- },
-
- onDragOut: function(){
- },
-
- onDragEnd: function(){
- },
-
- // normal aliases
- onDragLeave: this.onDragOut,
- onDragEnter: this.onDragOver,
-
- // non-camel aliases
- ondragout: this.onDragOut,
- ondragover: this.onDragOver
-}, function(){
- var dm = dojo.dnd.dragManager;
- if(dm["registerDragObject"]){ // side-effect prevention
+ if (dm["registerDragObject"]) {
dm.registerDragObject(this);
}
-});
-
-dojo.declare("dojo.dnd.DropTarget", null, {
-
- acceptsType: function(type){
- if(!dojo.lang.inArray(this.acceptedTypes, "*")){ // wildcard
- if(!dojo.lang.inArray(this.acceptedTypes, type)) { return false; }
+}, onDragStart:function (evt) {
+}, onDragMove:function (evt) {
+}, onDragOver:function (evt) {
+}, onDragOut:function (evt) {
+}, onDragEnd:function (evt) {
+}, onDragLeave:dojo.lang.forward("onDragOut"), onDragEnter:dojo.lang.forward("onDragOver"), ondragout:dojo.lang.forward("onDragOut"), ondragover:dojo.lang.forward("onDragOver")});
+dojo.declare("dojo.dnd.DropTarget", null, {acceptsType:function (type) {
+ if (!dojo.lang.inArray(this.acceptedTypes, "*")) {
+ if (!dojo.lang.inArray(this.acceptedTypes, type)) {
+ return false;
}
- return true;
- },
-
- accepts: function(dragObjects){
- if(!dojo.lang.inArray(this.acceptedTypes, "*")){ // wildcard
- for (var i = 0; i < dragObjects.length; i++) {
- if (!dojo.lang.inArray(this.acceptedTypes,
- dragObjects[i].type)) { return false; }
+ }
+ return true;
+}, accepts:function (dragObjects) {
+ if (!dojo.lang.inArray(this.acceptedTypes, "*")) {
+ for (var i = 0; i < dragObjects.length; i++) {
+ if (!dojo.lang.inArray(this.acceptedTypes, dragObjects[i].type)) {
+ return false;
}
}
- return true;
- },
-
- unregister: function(){
- dojo.dnd.dragManager.unregisterDropTarget(this);
- },
-
- onDragOver: function(){
- },
-
- onDragOut: function(){
- },
-
- onDragMove: function(){
- },
-
- onDropStart: function(){
- },
-
- onDrop: function(){
- },
-
- onDropEnd: function(){
}
-}, function(){
- if (this.constructor == dojo.dnd.DropTarget) { return; } // need to be subclassed
+ return true;
+}, unregister:function () {
+ dojo.dnd.dragManager.unregisterDropTarget(this);
+}, onDragOver:function (evt) {
+}, onDragOut:function (evt) {
+}, onDragMove:function (evt) {
+}, onDropStart:function (evt) {
+}, onDrop:function (evt) {
+}, onDropEnd:function () {
+}}, function () {
this.acceptedTypes = [];
- dojo.dnd.dragManager.registerDropTarget(this);
});
-
-// NOTE: this interface is defined here for the convenience of the DragManager
-// implementor. It is expected that in most cases it will be satisfied by
-// extending a native event (DOM event in HTML and SVG).
-dojo.dnd.DragEvent = function(){
+dojo.dnd.DragEvent = function () {
this.dragSource = null;
this.dragObject = null;
this.target = null;
this.eventStatus = "success";
- //
- // can be one of:
- // [ "dropSuccess", "dropFailure", "dragMove",
- // "dragStart", "dragEnter", "dragLeave"]
- //
-}
-/*
- * The DragManager handles listening for low-level events and dispatching
- * them to higher-level primitives like drag sources and drop targets. In
- * order to do this, it must keep a list of the items.
- */
-dojo.declare("dojo.dnd.DragManager", null, {
- selectedSources: [],
- dragObjects: [],
- dragSources: [],
- registerDragSource: function(){},
- dropTargets: [],
- registerDropTarget: function(){},
- lastDragTarget: null,
- currentDragTarget: null,
- onKeyDown: function(){},
- onMouseOut: function(){},
- onMouseMove: function(){},
- onMouseUp: function(){}
-});
+};
+dojo.declare("dojo.dnd.DragManager", null, {selectedSources:[], dragObjects:[], dragSources:[], registerDragSource:function (source) {
+}, dropTargets:[], registerDropTarget:function (target) {
+}, lastDragTarget:null, currentDragTarget:null, onKeyDown:function () {
+}, onMouseOut:function () {
+}, onMouseMove:function () {
+}, onMouseUp:function () {
+}});
-// NOTE: despite the existance of the DragManager class, there will be a
-// singleton drag manager provided by the renderer-specific D&D support code.
-// It is therefore sane for us to assign instance variables to the DragManager
-// prototype
-
-// The renderer-specific file will define the following object:
-// dojo.dnd.dragManager = null;
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragAndDrop.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragAndDrop.js
index a761e73c9..636b30997 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragAndDrop.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragAndDrop.js
@@ -9,10 +9,8 @@
*/
dojo.provide("dojo.dnd.HtmlDragAndDrop");
-
dojo.require("dojo.dnd.HtmlDragManager");
dojo.require("dojo.dnd.DragAndDrop");
-
dojo.require("dojo.html.*");
dojo.require("dojo.html.display");
dojo.require("dojo.html.util");
@@ -21,488 +19,349 @@ dojo.require("dojo.html.iframe");
dojo.require("dojo.lang.extras");
dojo.require("dojo.lfx.*");
dojo.require("dojo.event.*");
-
-dojo.declare("dojo.dnd.HtmlDragSource", dojo.dnd.DragSource, {
- dragClass: "", // CSS classname(s) applied to node when it is being dragged
-
- onDragStart: function(){
- var dragObj = new dojo.dnd.HtmlDragObject(this.dragObject, this.type);
- if(this.dragClass) { dragObj.dragClass = this.dragClass; }
-
- if (this.constrainToContainer) {
- dragObj.constrainTo(this.constrainingContainer || this.domNode.parentNode);
- }
-
- return dragObj;
- },
-
- setDragHandle: function(node){
- node = dojo.byId(node);
- dojo.dnd.dragManager.unregisterDragSource(this);
- this.domNode = node;
- dojo.dnd.dragManager.registerDragSource(this);
- },
-
- setDragTarget: function(node){
- this.dragObject = node;
- },
-
- constrainTo: function(container) {
- this.constrainToContainer = true;
- if (container) {
- this.constrainingContainer = container;
- }
- },
-
- /*
- *
- * see dojo.dnd.DragSource.onSelected
- */
- onSelected: function() {
- for (var i=0; i this.constraints.maxX) { x = this.constraints.maxX; }
- if (y > this.constraints.maxY) { y = this.constraints.maxY; }
+ if (x > this.constraints.maxX) {
+ x = this.constraints.maxX;
}
-
- this.setAbsolutePosition(x, y);
-
- dojo.event.topic.publish('dragMove', { source: this } );
- },
-
- /**
- * Set the position of the drag clone. (x,y) is relative to .
- */
- setAbsolutePosition: function(x, y){
- // The drag clone is attached to document.body so this is trivial
- if(!this.disableY) { this.dragClone.style.top = y + "px"; }
- if(!this.disableX) { this.dragClone.style.left = x + "px"; }
- },
-
-
- /**
- * If the drag operation returned a success we reomve the clone of
- * ourself from the original position. If the drag operation returned
- * failure we slide back over to where we came from and end the operation
- * with a little grace.
- */
- onDragEnd: function(e){
- switch(e.dragStatus){
-
- case "dropSuccess":
- dojo.html.removeNode(this.dragClone);
- this.dragClone = null;
- break;
-
- case "dropFailure": // slide back to the start
- var startCoords = dojo.html.getAbsolutePosition(this.dragClone, true);
- // offset the end so the effect can be seen
- var endCoords = { left: this.dragStartPosition.x + 1,
- top: this.dragStartPosition.y + 1};
-
- // animate
- var anim = dojo.lfx.slideTo(this.dragClone, endCoords, 500, dojo.lfx.easeOut);
- var dragObject = this;
- dojo.event.connect(anim, "onEnd", function (e) {
- // pause for a second (not literally) and disappear
- dojo.lang.setTimeout(function() {
- dojo.html.removeNode(dragObject.dragClone);
- // Allow drag clone to be gc'ed
- dragObject.dragClone = null;
- },
- 200);
- });
- anim.play();
- break;
- }
-
- dojo.event.topic.publish('dragEnd', { source: this } );
- },
-
- squelchOnClick: function(e){
- // squelch this onClick() event because it's the result of a drag (it's not a real click)
- dojo.event.browser.stopEvent(e);
-
- // disconnect after a short delay to prevent "Null argument to unrollAdvice()" warning
- dojo.lang.setTimeout(function() {
- dojo.event.disconnect(this.domNode, "onclick", this, "squelchOnClick");
- },50);
- },
-
- constrainTo: function(container) {
- this.constrainToContainer=true;
- if (container) {
- this.constrainingContainer = container;
- } else {
- this.constrainingContainer = this.domNode.parentNode;
+ if (y > this.constraints.maxY) {
+ y = this.constraints.maxY;
}
}
-}, function(node, type){
+ this.setAbsolutePosition(x, y);
+ dojo.event.topic.publish("dragMove", {source:this});
+}, setAbsolutePosition:function (x, y) {
+ if (!this.disableY) {
+ this.dragClone.style.top = y + "px";
+ }
+ if (!this.disableX) {
+ this.dragClone.style.left = x + "px";
+ }
+}, onDragEnd:function (e) {
+ switch (e.dragStatus) {
+ case "dropSuccess":
+ dojo.html.removeNode(this.dragClone);
+ this.dragClone = null;
+ break;
+ case "dropFailure":
+ var startCoords = dojo.html.getAbsolutePosition(this.dragClone, true);
+ var endCoords = {left:this.dragStartPosition.x + 1, top:this.dragStartPosition.y + 1};
+ var anim = dojo.lfx.slideTo(this.dragClone, endCoords, 300);
+ var dragObject = this;
+ dojo.event.connect(anim, "onEnd", function (e) {
+ dojo.html.removeNode(dragObject.dragClone);
+ dragObject.dragClone = null;
+ });
+ anim.play();
+ break;
+ }
+ dojo.event.topic.publish("dragEnd", {source:this});
+}, constrainTo:function (container) {
+ this.constrainToContainer = true;
+ if (container) {
+ this.constrainingContainer = container;
+ } else {
+ this.constrainingContainer = this.domNode.parentNode;
+ }
+}}, function (node, type) {
this.domNode = dojo.byId(node);
this.type = type;
this.constrainToContainer = false;
this.dragSource = null;
+ dojo.dnd.DragObject.prototype.register.call(this);
});
-
-dojo.declare("dojo.dnd.HtmlDropTarget", dojo.dnd.DropTarget, {
- vertical: false,
- onDragOver: function(e){
- if(!this.accepts(e.dragObjects)){ return false; }
-
- // cache the positions of the child nodes
- this.childBoxes = [];
- for (var i = 0, child; i < this.domNode.childNodes.length; i++) {
- child = this.domNode.childNodes[i];
- if (child.nodeType != dojo.html.ELEMENT_NODE) { continue; }
- var pos = dojo.html.getAbsolutePosition(child, true);
- var inner = dojo.html.getBorderBox(child);
- this.childBoxes.push({top: pos.y, bottom: pos.y+inner.height,
- left: pos.x, right: pos.x+inner.width, height: inner.height,
- width: inner.width, node: child});
- }
-
- // TODO: use dummy node
-
- return true;
- },
-
- _getNodeUnderMouse: function(e){
- // find the child
- for (var i = 0, child; i < this.childBoxes.length; i++) {
- with (this.childBoxes[i]) {
- if (e.pageX >= left && e.pageX <= right &&
- e.pageY >= top && e.pageY <= bottom) { return i; }
- }
- }
-
- return -1;
- },
-
- createDropIndicator: function() {
- this.dropIndicator = document.createElement("div");
- with (this.dropIndicator.style) {
- position = "absolute";
- zIndex = 999;
- if(this.vertical){
- borderLeftWidth = "1px";
- borderLeftColor = "black";
- borderLeftStyle = "solid";
- height = dojo.html.getBorderBox(this.domNode).height + "px";
- top = dojo.html.getAbsolutePosition(this.domNode, true).y + "px";
- }else{
- borderTopWidth = "1px";
- borderTopColor = "black";
- borderTopStyle = "solid";
- width = dojo.html.getBorderBox(this.domNode).width + "px";
- left = dojo.html.getAbsolutePosition(this.domNode, true).x + "px";
- }
- }
- },
-
- onDragMove: function(e, dragObjects){
- var i = this._getNodeUnderMouse(e);
-
- if(!this.dropIndicator){
- this.createDropIndicator();
- }
-
- var gravity = this.vertical ? dojo.html.gravity.WEST : dojo.html.gravity.NORTH;
- var hide = false;
- if(i < 0) {
- if(this.childBoxes.length) {
- var before = (dojo.html.gravity(this.childBoxes[0].node, e) & gravity);
- if(before){ hide = true; }
- } else {
- var before = true;
- }
- } else {
- var child = this.childBoxes[i];
- var before = (dojo.html.gravity(child.node, e) & gravity);
- if(child.node === dragObjects[0].dragSource.domNode){
- hide = true;
- }else{
- var currentPosChild = before ?
- (i>0?this.childBoxes[i-1]:child) :
- (i= left && e.pageX <= right && e.pageY >= top && e.pageY <= bottom) {
+ return i;
+ }
+ }
+ }
+ return -1;
+}, createDropIndicator:function () {
+ this.dropIndicator = document.createElement("div");
+ with (this.dropIndicator.style) {
+ position = "absolute";
+ zIndex = 999;
+ if (this.vertical) {
+ borderLeftWidth = "1px";
+ borderLeftColor = "black";
+ borderLeftStyle = "solid";
+ height = dojo.html.getBorderBox(this.domNode).height + "px";
+ top = dojo.html.getAbsolutePosition(this.domNode, true).y + "px";
+ } else {
+ borderTopWidth = "1px";
+ borderTopColor = "black";
+ borderTopStyle = "solid";
+ width = dojo.html.getBorderBox(this.domNode).width + "px";
+ left = dojo.html.getAbsolutePosition(this.domNode, true).x + "px";
+ }
+ }
+}, onDragMove:function (e, dragObjects) {
+ var i = this._getNodeUnderMouse(e);
+ if (!this.dropIndicator) {
+ this.createDropIndicator();
+ }
+ var gravity = this.vertical ? dojo.html.gravity.WEST : dojo.html.gravity.NORTH;
+ var hide = false;
+ if (i < 0) {
+ if (this.childBoxes.length) {
+ var before = (dojo.html.gravity(this.childBoxes[0].node, e) & gravity);
+ if (before) {
+ hide = true;
+ }
+ } else {
+ var before = true;
+ }
+ } else {
+ var child = this.childBoxes[i];
+ var before = (dojo.html.gravity(child.node, e) & gravity);
+ if (child.node === dragObjects[0].dragSource.domNode) {
+ hide = true;
+ } else {
+ var currentPosChild = before ? (i > 0 ? this.childBoxes[i - 1] : child) : (i < this.childBoxes.length - 1 ? this.childBoxes[i + 1] : child);
+ if (currentPosChild.node === dragObjects[0].dragSource.domNode) {
+ hide = true;
+ }
+ }
+ }
+ if (hide) {
+ this.dropIndicator.style.display = "none";
+ return;
+ } else {
+ this.dropIndicator.style.display = "";
+ }
+ this.placeIndicator(e, dragObjects, i, before);
+ if (!dojo.html.hasParent(this.dropIndicator)) {
+ dojo.body().appendChild(this.dropIndicator);
+ }
+}, placeIndicator:function (e, dragObjects, boxIndex, before) {
+ var targetProperty = this.vertical ? "left" : "top";
+ var child;
+ if (boxIndex < 0) {
+ if (this.childBoxes.length) {
+ child = before ? this.childBoxes[0] : this.childBoxes[this.childBoxes.length - 1];
+ } else {
+ this.dropIndicator.style[targetProperty] = dojo.html.getAbsolutePosition(this.domNode, true)[this.vertical ? "x" : "y"] + "px";
+ }
+ } else {
+ child = this.childBoxes[boxIndex];
+ }
+ if (child) {
+ this.dropIndicator.style[targetProperty] = (before ? child[targetProperty] : child[this.vertical ? "right" : "bottom"]) + "px";
+ if (this.vertical) {
+ this.dropIndicator.style.height = child.height + "px";
+ this.dropIndicator.style.top = child.top + "px";
+ } else {
+ this.dropIndicator.style.width = child.width + "px";
+ this.dropIndicator.style.left = child.left + "px";
+ }
+ }
+}, onDragOut:function (e) {
+ if (this.dropIndicator) {
+ dojo.html.removeNode(this.dropIndicator);
+ delete this.dropIndicator;
+ }
+}, onDrop:function (e) {
+ this.onDragOut(e);
+ var i = this._getNodeUnderMouse(e);
+ var gravity = this.vertical ? dojo.html.gravity.WEST : dojo.html.gravity.NORTH;
+ if (i < 0) {
+ if (this.childBoxes.length) {
+ if (dojo.html.gravity(this.childBoxes[0].node, e) & gravity) {
+ return this.insert(e, this.childBoxes[0].node, "before");
+ } else {
+ return this.insert(e, this.childBoxes[this.childBoxes.length - 1].node, "after");
+ }
+ }
+ return this.insert(e, this.domNode, "append");
+ }
+ var child = this.childBoxes[i];
+ if (dojo.html.gravity(child.node, e) & gravity) {
+ return this.insert(e, child.node, "before");
+ } else {
+ return this.insert(e, child.node, "after");
+ }
+}, insert:function (e, refNode, position) {
+ var node = e.dragObject.domNode;
+ if (position == "before") {
+ return dojo.html.insertBefore(node, refNode);
+ } else {
+ if (position == "after") {
+ return dojo.html.insertAfter(node, refNode);
+ } else {
+ if (position == "append") {
+ refNode.appendChild(node);
+ return true;
+ }
+ }
+ }
+ return false;
+}}, function (node, types) {
+ if (arguments.length == 0) {
+ return;
+ }
this.domNode = dojo.byId(node);
dojo.dnd.DropTarget.call(this);
- if(types && dojo.lang.isString(types)) {
+ if (types && dojo.lang.isString(types)) {
types = [types];
}
this.acceptedTypes = types || [];
+ dojo.dnd.dragManager.registerDropTarget(this);
});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragCopy.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragCopy.js
index c589d5e85..192fd2e76 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragCopy.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragCopy.js
@@ -10,76 +10,59 @@
dojo.provide("dojo.dnd.HtmlDragCopy");
dojo.require("dojo.dnd.*");
-
-dojo.declare("dojo.dnd.HtmlDragCopySource", dojo.dnd.HtmlDragSource,
-function(node, type, copyOnce){
- this.copyOnce = copyOnce;
- this.makeCopy = true;
-},
-{
- onDragStart: function(){
- var dragObj = new dojo.dnd.HtmlDragCopyObject(this.dragObject, this.type, this);
- if(this.dragClass) { dragObj.dragClass = this.dragClass; }
-
- if (this.constrainToContainer) {
- dragObj.constrainTo(this.constrainingContainer || this.domNode.parentNode);
- }
-
- return dragObj;
- },
- onSelected: function() {
- for (var i=0; i
- * (draggable selection)
- * (dragObject generation)
- * mouse-move ->
- * (draggable movement)
- * (droppable detection)
- * (inform droppable)
- * (inform dragObject)
- * mouse-up
- * (inform/destroy dragObject)
- * (inform draggable)
- * (inform droppable)
- * 2.) mouse-down -> mouse-down
- * (click-hold context menu)
- * 3.) mouse-click ->
- * (draggable selection)
- * shift-mouse-click ->
- * (augment draggable selection)
- * mouse-down ->
- * (dragObject generation)
- * mouse-move ->
- * (draggable movement)
- * (droppable detection)
- * (inform droppable)
- * (inform dragObject)
- * mouse-up
- * (inform draggable)
- * (inform droppable)
- * 4.) mouse-up
- * (clobber draggable selection)
- */
- disabled: false, // to kill all dragging!
- nestedTargets: false,
- mouseDownTimer: null, // used for click-hold operations
- dsCounter: 0,
- dsPrefix: "dojoDragSource",
-
- // dimension calculation cache for use durring drag
- dropTargetDimensions: [],
-
- currentDropTarget: null,
- // currentDropTargetPoints: null,
- previousDropTarget: null,
- _dragTriggered: false,
-
- selectedSources: [],
- dragObjects: [],
-
- // mouse position properties
- currentX: null,
- currentY: null,
- lastX: null,
- lastY: null,
- mouseDownX: null,
- mouseDownY: null,
- threshold: 7,
-
- dropAcceptable: false,
-
- cancelEvent: function(e){ e.stopPropagation(); e.preventDefault();},
-
- // method over-rides
- registerDragSource: function(ds){
- //dojo.profile.start("register DragSource");
-
- if(ds["domNode"]){
- // FIXME: dragSource objects SHOULD have some sort of property that
- // references their DOM node, we shouldn't just be passing nodes and
- // expecting it to work.
- //dojo.profile.start("register DragSource 1");
- var dp = this.dsPrefix;
- var dpIdx = dp+"Idx_"+(this.dsCounter++);
- ds.dragSourceId = dpIdx;
- this.dragSources[dpIdx] = ds;
- ds.domNode.setAttribute(dp, dpIdx);
- //dojo.profile.end("register DragSource 1");
-
- //dojo.profile.start("register DragSource 2");
-
- // so we can drag links
- if(dojo.render.html.ie){
- //dojo.profile.start("register DragSource IE");
-
- dojo.event.browser.addListener(ds.domNode, "ondragstart", this.cancelEvent);
- // terribly slow
- //dojo.event.connect(ds.domNode, "ondragstart", this.cancelEvent);
- //dojo.profile.end("register DragSource IE");
-
- }
- //dojo.profile.end("register DragSource 2");
-
+dojo.declare("dojo.dnd.HtmlDragManager", dojo.dnd.DragManager, {disabled:false, nestedTargets:false, mouseDownTimer:null, dsCounter:0, dsPrefix:"dojoDragSource", dropTargetDimensions:[], currentDropTarget:null, previousDropTarget:null, _dragTriggered:false, selectedSources:[], dragObjects:[], dragSources:[], dropTargets:[], currentX:null, currentY:null, lastX:null, lastY:null, mouseDownX:null, mouseDownY:null, threshold:7, dropAcceptable:false, cancelEvent:function (e) {
+ e.stopPropagation();
+ e.preventDefault();
+}, registerDragSource:function (ds) {
+ if (ds["domNode"]) {
+ var dp = this.dsPrefix;
+ var dpIdx = dp + "Idx_" + (this.dsCounter++);
+ ds.dragSourceId = dpIdx;
+ this.dragSources[dpIdx] = ds;
+ ds.domNode.setAttribute(dp, dpIdx);
+ if (dojo.render.html.ie) {
+ dojo.event.browser.addListener(ds.domNode, "ondragstart", this.cancelEvent);
}
- //dojo.profile.end("register DragSource");
- },
-
- unregisterDragSource: function(ds){
- if (ds["domNode"]){
- var dp = this.dsPrefix;
- var dpIdx = ds.dragSourceId;
- delete ds.dragSourceId;
- delete this.dragSources[dpIdx];
- ds.domNode.setAttribute(dp, null);
- if(dojo.render.html.ie){
- dojo.event.browser.removeListener(ds.domNode, "ondragstart", this.cancelEvent);
- }
+ }
+}, unregisterDragSource:function (ds) {
+ if (ds["domNode"]) {
+ var dp = this.dsPrefix;
+ var dpIdx = ds.dragSourceId;
+ delete ds.dragSourceId;
+ delete this.dragSources[dpIdx];
+ ds.domNode.setAttribute(dp, null);
+ if (dojo.render.html.ie) {
+ dojo.event.browser.removeListener(ds.domNode, "ondragstart", this.cancelEvent);
}
- },
-
- registerDropTarget: function(dt){
- this.dropTargets.push(dt);
- },
-
- unregisterDropTarget: function(dt){
- var index = dojo.lang.find(this.dropTargets, dt, true);
- if (index>=0) {
- this.dropTargets.splice(index, 1);
- }
- },
-
- /**
- * Get the DOM element that is meant to drag.
- * Loop through the parent nodes of the event target until
- * the element is found that was created as a DragSource and
- * return it.
- *
- * @param event object The event for which to get the drag source.
- */
- getDragSource: function(e){
- var tn = e.target;
- if(tn === dojo.body()){ return; }
- var ta = dojo.html.getAttribute(tn, this.dsPrefix);
- while((!ta)&&(tn)){
- tn = tn.parentNode;
- if((!tn)||(tn === dojo.body())){ return; }
- ta = dojo.html.getAttribute(tn, this.dsPrefix);
- }
- return this.dragSources[ta];
- },
-
- onKeyDown: function(e){
- },
-
- onMouseDown: function(e){
- if(this.disabled) { return; }
-
- // only begin on left click
- if(dojo.render.html.ie) {
- if(e.button != 1) { return; }
- } else if(e.which != 1) {
+ }
+}, registerDropTarget:function (dt) {
+ this.dropTargets.push(dt);
+}, unregisterDropTarget:function (dt) {
+ var index = dojo.lang.find(this.dropTargets, dt, true);
+ if (index >= 0) {
+ this.dropTargets.splice(index, 1);
+ }
+}, getDragSource:function (e) {
+ var tn = e.target;
+ if (tn === dojo.body()) {
+ return;
+ }
+ var ta = dojo.html.getAttribute(tn, this.dsPrefix);
+ while ((!ta) && (tn)) {
+ tn = tn.parentNode;
+ if ((!tn) || (tn === dojo.body())) {
return;
}
-
- var target = e.target.nodeType == dojo.html.TEXT_NODE ?
- e.target.parentNode : e.target;
-
- // do not start drag involvement if the user is interacting with
- // a form element.
- if(dojo.html.isTag(target, "button", "textarea", "input", "select", "option")) {
+ ta = dojo.html.getAttribute(tn, this.dsPrefix);
+ }
+ return this.dragSources[ta];
+}, onKeyDown:function (e) {
+}, onMouseDown:function (e) {
+ if (this.disabled) {
+ return;
+ }
+ if (dojo.render.html.ie) {
+ if (e.button != 1) {
return;
}
-
- // find a selection object, if one is a parent of the source node
- var ds = this.getDragSource(e);
-
- // this line is important. if we aren't selecting anything then
- // we need to return now, so preventDefault() isn't called, and thus
- // the event is propogated to other handling code
- if(!ds){ return; }
-
- if(!dojo.lang.inArray(this.selectedSources, ds)){
- this.selectedSources.push(ds);
- ds.onSelected();
- }
-
- this.mouseDownX = e.pageX;
- this.mouseDownY = e.pageY;
-
- // Must stop the mouse down from being propogated, or otherwise can't
- // drag links in firefox.
- // WARNING: preventing the default action on all mousedown events
- // prevents user interaction with the contents.
- e.preventDefault();
-
- dojo.event.connect(document, "onmousemove", this, "onMouseMove");
- },
-
- onMouseUp: function(e, cancel){
- // if we aren't dragging then ignore the mouse-up
- // (in particular, don't call preventDefault(), because other
- // code may need to process this event)
- if(this.selectedSources.length==0){
+ } else {
+ if (e.which != 1) {
return;
}
-
- this.mouseDownX = null;
- this.mouseDownY = null;
- this._dragTriggered = false;
- // e.preventDefault();
- e.dragSource = this.dragSource;
- // let ctrl be used for multiselect or another action
- // if I use same key to trigger treeV3 node selection and here,
- // I have bugs with drag'n'drop. why ?? no idea..
- if((!e.shiftKey)&&(!e.ctrlKey)){
- //if(!e.shiftKey){
- if(this.currentDropTarget) {
- this.currentDropTarget.onDropStart();
- }
- dojo.lang.forEach(this.dragObjects, function(tempDragObj){
- var ret = null;
- if(!tempDragObj){ return; }
- if(this.currentDropTarget) {
- e.dragObject = tempDragObj;
-
- // NOTE: we can't get anything but the current drop target
- // here since the drag shadow blocks mouse-over events.
- // This is probelematic for dropping "in" something
- var ce = this.currentDropTarget.domNode.childNodes;
- if(ce.length > 0){
- e.dropTarget = ce[0];
- while(e.dropTarget == tempDragObj.domNode){
- e.dropTarget = e.dropTarget.nextSibling;
- }
- }else{
- e.dropTarget = this.currentDropTarget.domNode;
- }
- if(this.dropAcceptable){
- ret = this.currentDropTarget.onDrop(e);
- }else{
- this.currentDropTarget.onDragOut(e);
- }
- }
-
- e.dragStatus = this.dropAcceptable && ret ? "dropSuccess" : "dropFailure";
- // decouple the calls for onDragEnd, so they don't block the execution here
- // ie. if the onDragEnd would call an alert, the execution here is blocked until the
- // user has confirmed the alert box and then the rest of the dnd code is executed
- // while the mouse doesnt "hold" the dragged object anymore ... and so on
- dojo.lang.delayThese([
- function() {
- // in FF1.5 this throws an exception, see
- // http://dojotoolkit.org/pipermail/dojo-interest/2006-April/006751.html
- try{
- tempDragObj.dragSource.onDragEnd(e)
- } catch(err) {
- // since the problem seems passing e, we just copy all
- // properties and try the copy ...
- var ecopy = {};
- for (var i in e) {
- if (i=="type") { // the type property contains the exception, no idea why...
- ecopy.type = "mouseup";
- continue;
- }
- ecopy[i] = e[i];
- }
- tempDragObj.dragSource.onDragEnd(ecopy);
- }
- }
- , function() {tempDragObj.onDragEnd(e)}]);
- }, this);
-
- this.selectedSources = [];
- this.dragObjects = [];
- this.dragSource = null;
- if(this.currentDropTarget) {
- this.currentDropTarget.onDropEnd();
- }
- } else {
- //dojo.debug("special click");
+ }
+ var target = e.target.nodeType == dojo.html.TEXT_NODE ? e.target.parentNode : e.target;
+ if (dojo.html.isTag(target, "button", "textarea", "input", "select", "option")) {
+ return;
+ }
+ var ds = this.getDragSource(e);
+ if (!ds) {
+ return;
+ }
+ if (!dojo.lang.inArray(this.selectedSources, ds)) {
+ this.selectedSources.push(ds);
+ ds.onSelected();
+ }
+ this.mouseDownX = e.pageX;
+ this.mouseDownY = e.pageY;
+ e.preventDefault();
+ dojo.event.connect(document, "onmousemove", this, "onMouseMove");
+}, onMouseUp:function (e, cancel) {
+ if (this.selectedSources.length == 0) {
+ return;
+ }
+ this.mouseDownX = null;
+ this.mouseDownY = null;
+ this._dragTriggered = false;
+ e.dragSource = this.dragSource;
+ if ((!e.shiftKey) && (!e.ctrlKey)) {
+ if (this.currentDropTarget) {
+ this.currentDropTarget.onDropStart();
}
-
- dojo.event.disconnect(document, "onmousemove", this, "onMouseMove");
- this.currentDropTarget = null;
- },
-
- onScroll: function(){
- //dojo.profile.start("DNDManager updateoffset");
- for(var i = 0; i < this.dragObjects.length; i++) {
- if(this.dragObjects[i].updateDragOffset) {
- this.dragObjects[i].updateDragOffset();
- }
- }
- //dojo.profile.end("DNDManager updateoffset");
-
- // TODO: do not recalculate, only adjust coordinates
- if (this.dragObjects.length) {
- this.cacheTargetLocations();
- }
- },
-
- _dragStartDistance: function(x, y){
- if((!this.mouseDownX)||(!this.mouseDownX)){
- return;
- }
- var dx = Math.abs(x-this.mouseDownX);
- var dx2 = dx*dx;
- var dy = Math.abs(y-this.mouseDownY);
- var dy2 = dy*dy;
- return parseInt(Math.sqrt(dx2+dy2), 10);
- },
-
- cacheTargetLocations: function(){
- dojo.profile.start("cacheTargetLocations");
-
- this.dropTargetDimensions = [];
- dojo.lang.forEach(this.dropTargets, function(tempTarget){
- var tn = tempTarget.domNode;
- //only cache dropTarget which can accept current dragSource
- if(!tn || dojo.lang.find(tempTarget.acceptedTypes, this.dragSource.type) < 0){ return; }
- var abs = dojo.html.getAbsolutePosition(tn, true);
- var bb = dojo.html.getBorderBox(tn);
- this.dropTargetDimensions.push([
- [abs.x, abs.y], // upper-left
- // lower-right
- [ abs.x+bb.width, abs.y+bb.height ],
- tempTarget
- ]);
- //dojo.debug("Cached for "+tempTarget)
- }, this);
-
- dojo.profile.end("cacheTargetLocations");
-
- //dojo.debug("Cache locations")
- },
-
- onMouseMove: function(e){
- if((dojo.render.html.ie)&&(e.button != 1)){
- // Oooops - mouse up occurred - e.g. when mouse was not over the
- // window. I don't think we can detect this for FF - but at least
- // we can be nice in IE.
- this.currentDropTarget = null;
- this.onMouseUp(e, true);
- return;
- }
-
- // if we've got some sources, but no drag objects, we need to send
- // onDragStart to all the right parties and get things lined up for
- // drop target detection
-
- if( (this.selectedSources.length)&&
- (!this.dragObjects.length) ){
- var dx;
- var dy;
- if(!this._dragTriggered){
- this._dragTriggered = (this._dragStartDistance(e.pageX, e.pageY) > this.threshold);
- if(!this._dragTriggered){ return; }
- dx = e.pageX - this.mouseDownX;
- dy = e.pageY - this.mouseDownY;
- }
-
- // the first element is always our dragSource, if there are multiple
- // selectedSources (elements that move along) then the first one is the master
- // and for it the events will be fired etc.
- this.dragSource = this.selectedSources[0];
-
- dojo.lang.forEach(this.selectedSources, function(tempSource){
- if(!tempSource){ return; }
- var tdo = tempSource.onDragStart(e);
- if(tdo){
- tdo.onDragStart(e);
-
- // "bump" the drag object to account for the drag threshold
- tdo.dragOffset.y += dy;
- tdo.dragOffset.x += dx;
- tdo.dragSource = tempSource;
-
- this.dragObjects.push(tdo);
- }
- }, this);
-
- /* clean previous drop target in dragStart */
- this.previousDropTarget = null;
-
- this.cacheTargetLocations();
- }
-
- // FIXME: we need to add dragSources and dragObjects to e
- dojo.lang.forEach(this.dragObjects, function(dragObj){
- if(dragObj){ dragObj.onDragMove(e); }
- });
-
- // if we have a current drop target, check to see if we're outside of
- // it. If so, do all the actions that need doing.
- if(this.currentDropTarget){
- //dojo.debug(dojo.html.hasParent(this.currentDropTarget.domNode))
- var c = dojo.html.toCoordinateObject(this.currentDropTarget.domNode, true);
- // var dtp = this.currentDropTargetPoints;
- var dtp = [
- [c.x,c.y], [c.x+c.width, c.y+c.height]
- ];
- }
-
- if((!this.nestedTargets)&&(dtp)&&(this.isInsideBox(e, dtp))){
- if(this.dropAcceptable){
- this.currentDropTarget.onDragMove(e, this.dragObjects);
- }
- }else{
- // FIXME: need to fix the event object!
- // see if we can find a better drop target
- var bestBox = this.findBestTarget(e);
-
- if(bestBox.target === null){
- if(this.currentDropTarget){
- this.currentDropTarget.onDragOut(e);
- this.previousDropTarget = this.currentDropTarget;
- this.currentDropTarget = null;
- // this.currentDropTargetPoints = null;
- }
- this.dropAcceptable = false;
+ dojo.lang.forEach(this.dragObjects, function (tempDragObj) {
+ var ret = null;
+ if (!tempDragObj) {
return;
}
-
- if(this.currentDropTarget !== bestBox.target){
- if(this.currentDropTarget){
- this.previousDropTarget = this.currentDropTarget;
+ if (this.currentDropTarget) {
+ e.dragObject = tempDragObj;
+ var ce = this.currentDropTarget.domNode.childNodes;
+ if (ce.length > 0) {
+ e.dropTarget = ce[0];
+ while (e.dropTarget == tempDragObj.domNode) {
+ e.dropTarget = e.dropTarget.nextSibling;
+ }
+ } else {
+ e.dropTarget = this.currentDropTarget.domNode;
+ }
+ if (this.dropAcceptable) {
+ ret = this.currentDropTarget.onDrop(e);
+ } else {
this.currentDropTarget.onDragOut(e);
}
- this.currentDropTarget = bestBox.target;
- // this.currentDropTargetPoints = bestBox.points;
- e.dragObjects = this.dragObjects;
- this.dropAcceptable = this.currentDropTarget.onDragOver(e);
-
- }else{
- if(this.dropAcceptable){
- this.currentDropTarget.onDragMove(e, this.dragObjects);
+ }
+ e.dragStatus = this.dropAcceptable && ret ? "dropSuccess" : "dropFailure";
+ dojo.lang.delayThese([function () {
+ try {
+ tempDragObj.dragSource.onDragEnd(e);
}
+ catch (err) {
+ var ecopy = {};
+ for (var i in e) {
+ if (i == "type") {
+ ecopy.type = "mouseup";
+ continue;
+ }
+ ecopy[i] = e[i];
+ }
+ tempDragObj.dragSource.onDragEnd(ecopy);
+ }
+ }, function () {
+ tempDragObj.onDragEnd(e);
+ }]);
+ }, this);
+ this.selectedSources = [];
+ this.dragObjects = [];
+ this.dragSource = null;
+ if (this.currentDropTarget) {
+ this.currentDropTarget.onDropEnd();
+ }
+ } else {
+ }
+ dojo.event.disconnect(document, "onmousemove", this, "onMouseMove");
+ this.currentDropTarget = null;
+}, onScroll:function () {
+ for (var i = 0; i < this.dragObjects.length; i++) {
+ if (this.dragObjects[i].updateDragOffset) {
+ this.dragObjects[i].updateDragOffset();
+ }
+ }
+ if (this.dragObjects.length) {
+ this.cacheTargetLocations();
+ }
+}, _dragStartDistance:function (x, y) {
+ if ((!this.mouseDownX) || (!this.mouseDownX)) {
+ return;
+ }
+ var dx = Math.abs(x - this.mouseDownX);
+ var dx2 = dx * dx;
+ var dy = Math.abs(y - this.mouseDownY);
+ var dy2 = dy * dy;
+ return parseInt(Math.sqrt(dx2 + dy2), 10);
+}, cacheTargetLocations:function () {
+ dojo.profile.start("cacheTargetLocations");
+ this.dropTargetDimensions = [];
+ dojo.lang.forEach(this.dropTargets, function (tempTarget) {
+ var tn = tempTarget.domNode;
+ if (!tn || !tempTarget.accepts([this.dragSource])) {
+ return;
+ }
+ var abs = dojo.html.getAbsolutePosition(tn, true);
+ var bb = dojo.html.getBorderBox(tn);
+ this.dropTargetDimensions.push([[abs.x, abs.y], [abs.x + bb.width, abs.y + bb.height], tempTarget]);
+ }, this);
+ dojo.profile.end("cacheTargetLocations");
+}, onMouseMove:function (e) {
+ if ((dojo.render.html.ie) && (e.button != 1)) {
+ this.currentDropTarget = null;
+ this.onMouseUp(e, true);
+ return;
+ }
+ if ((this.selectedSources.length) && (!this.dragObjects.length)) {
+ var dx;
+ var dy;
+ if (!this._dragTriggered) {
+ this._dragTriggered = (this._dragStartDistance(e.pageX, e.pageY) > this.threshold);
+ if (!this._dragTriggered) {
+ return;
+ }
+ dx = e.pageX - this.mouseDownX;
+ dy = e.pageY - this.mouseDownY;
+ }
+ this.dragSource = this.selectedSources[0];
+ dojo.lang.forEach(this.selectedSources, function (tempSource) {
+ if (!tempSource) {
+ return;
+ }
+ var tdo = tempSource.onDragStart(e);
+ if (tdo) {
+ tdo.onDragStart(e);
+ tdo.dragOffset.y += dy;
+ tdo.dragOffset.x += dx;
+ tdo.dragSource = tempSource;
+ this.dragObjects.push(tdo);
+ }
+ }, this);
+ this.previousDropTarget = null;
+ this.cacheTargetLocations();
+ }
+ dojo.lang.forEach(this.dragObjects, function (dragObj) {
+ if (dragObj) {
+ dragObj.onDragMove(e);
+ }
+ });
+ if (this.currentDropTarget) {
+ var c = dojo.html.toCoordinateObject(this.currentDropTarget.domNode, true);
+ var dtp = [[c.x, c.y], [c.x + c.width, c.y + c.height]];
+ }
+ if ((!this.nestedTargets) && (dtp) && (this.isInsideBox(e, dtp))) {
+ if (this.dropAcceptable) {
+ this.currentDropTarget.onDragMove(e, this.dragObjects);
+ }
+ } else {
+ var bestBox = this.findBestTarget(e);
+ if (bestBox.target === null) {
+ if (this.currentDropTarget) {
+ this.currentDropTarget.onDragOut(e);
+ this.previousDropTarget = this.currentDropTarget;
+ this.currentDropTarget = null;
+ }
+ this.dropAcceptable = false;
+ return;
+ }
+ if (this.currentDropTarget !== bestBox.target) {
+ if (this.currentDropTarget) {
+ this.previousDropTarget = this.currentDropTarget;
+ this.currentDropTarget.onDragOut(e);
+ }
+ this.currentDropTarget = bestBox.target;
+ e.dragObjects = this.dragObjects;
+ this.dropAcceptable = this.currentDropTarget.onDragOver(e);
+ } else {
+ if (this.dropAcceptable) {
+ this.currentDropTarget.onDragMove(e, this.dragObjects);
}
}
- },
-
- findBestTarget: function(e) {
- var _this = this;
- var bestBox = new Object();
- bestBox.target = null;
- bestBox.points = null;
- dojo.lang.every(this.dropTargetDimensions, function(tmpDA) {
- if(!_this.isInsideBox(e, tmpDA)){
- return true;
- }
-
- bestBox.target = tmpDA[2];
- bestBox.points = tmpDA;
- // continue iterating only if _this.nestedTargets == true
- return Boolean(_this.nestedTargets);
- });
-
- return bestBox;
- },
-
- isInsideBox: function(e, coords){
- if( (e.pageX > coords[0][0])&&
- (e.pageX < coords[1][0])&&
- (e.pageY > coords[0][1])&&
- (e.pageY < coords[1][1]) ){
+ }
+}, findBestTarget:function (e) {
+ var _this = this;
+ var bestBox = new Object();
+ bestBox.target = null;
+ bestBox.points = null;
+ dojo.lang.every(this.dropTargetDimensions, function (tmpDA) {
+ if (!_this.isInsideBox(e, tmpDA)) {
return true;
}
- return false;
- },
-
- onMouseOver: function(e){
- },
-
- onMouseOut: function(e){
+ bestBox.target = tmpDA[2];
+ bestBox.points = tmpDA;
+ return Boolean(_this.nestedTargets);
+ });
+ return bestBox;
+}, isInsideBox:function (e, coords) {
+ if ((e.pageX > coords[0][0]) && (e.pageX < coords[1][0]) && (e.pageY > coords[0][1]) && (e.pageY < coords[1][1])) {
+ return true;
}
-});
-
+ return false;
+}, onMouseOver:function (e) {
+}, onMouseOut:function (e) {
+}});
dojo.dnd.dragManager = new dojo.dnd.HtmlDragManager();
-
-// global namespace protection closure
-(function(){
+(function () {
var d = document;
var dm = dojo.dnd.dragManager;
- //TODO: when focus manager is ready, dragManager should be rewritten to use it
- // set up event handlers on the document (or no?)
dojo.event.connect(d, "onkeydown", dm, "onKeyDown");
dojo.event.connect(d, "onmouseover", dm, "onMouseOver");
dojo.event.connect(d, "onmouseout", dm, "onMouseOut");
dojo.event.connect(d, "onmousedown", dm, "onMouseDown");
dojo.event.connect(d, "onmouseup", dm, "onMouseUp");
- // TODO: process scrolling of elements, not only window (focus manager would
- // probably come to rescue here as well)
dojo.event.connect(window, "onscroll", dm, "onScroll");
})();
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragMove.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragMove.js
index 3fa31704c..40356f573 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragMove.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragMove.js
@@ -10,57 +10,43 @@
dojo.provide("dojo.dnd.HtmlDragMove");
dojo.require("dojo.dnd.*");
-
-dojo.declare("dojo.dnd.HtmlDragMoveSource", dojo.dnd.HtmlDragSource, {
- onDragStart: function(){
- var dragObj = new dojo.dnd.HtmlDragMoveObject(this.dragObject, this.type);
- if (this.constrainToContainer) {
- dragObj.constrainTo(this.constrainingContainer);
- }
- return dragObj;
- },
- /*
- * see dojo.dnd.HtmlDragSource.onSelected
- */
- onSelected: function() {
- for (var i=0; i.
- */
- setAbsolutePosition: function(x, y){
- // The drag clone is attached to it's constraining container so offset for that
- if(!this.disableY) { this.domNode.style.top = (y-this.containingBlockPosition.y) + "px"; }
- if(!this.disableX) { this.domNode.style.left = (x-this.containingBlockPosition.x) + "px"; }
+ return dragObj;
+}, onSelected:function () {
+ for (var i = 0; i < this.dragObjects.length; i++) {
+ dojo.dnd.dragManager.selectedSources.push(new dojo.dnd.HtmlDragMoveSource(this.dragObjects[i]));
}
-});
+}});
+dojo.declare("dojo.dnd.HtmlDragMoveObject", dojo.dnd.HtmlDragObject, {onDragStart:function (e) {
+ dojo.html.clearSelection();
+ this.dragClone = this.domNode;
+ if (dojo.html.getComputedStyle(this.domNode, "position") != "absolute") {
+ this.domNode.style.position = "relative";
+ }
+ var left = parseInt(dojo.html.getComputedStyle(this.domNode, "left"));
+ var top = parseInt(dojo.html.getComputedStyle(this.domNode, "top"));
+ this.dragStartPosition = {x:isNaN(left) ? 0 : left, y:isNaN(top) ? 0 : top};
+ this.scrollOffset = dojo.html.getScroll().offset;
+ this.dragOffset = {y:this.dragStartPosition.y - e.pageY, x:this.dragStartPosition.x - e.pageX};
+ this.containingBlockPosition = {x:0, y:0};
+ if (this.constrainToContainer) {
+ this.constraints = this.getConstraints();
+ }
+ dojo.event.connect(this.domNode, "onclick", this, "_squelchOnClick");
+}, onDragEnd:function (e) {
+}, setAbsolutePosition:function (x, y) {
+ if (!this.disableY) {
+ this.domNode.style.top = y + "px";
+ }
+ if (!this.disableX) {
+ this.domNode.style.left = x + "px";
+ }
+}, _squelchOnClick:function (e) {
+ dojo.event.browser.stopEvent(e);
+ dojo.event.disconnect(this.domNode, "onclick", this, "_squelchOnClick");
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/Sortable.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/Sortable.js
index 21ab4ca07..a537a4ae4 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/Sortable.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/Sortable.js
@@ -10,19 +10,13 @@
dojo.provide("dojo.dnd.Sortable");
dojo.require("dojo.dnd.*");
-
-dojo.dnd.Sortable = function () {}
-
-dojo.lang.extend(dojo.dnd.Sortable, {
-
- ondragstart: function (e) {
- var dragObject = e.target;
- while (dragObject.parentNode && dragObject.parentNode != this) {
- dragObject = dragObject.parentNode;
- }
- // TODO: should apply HtmlDropTarget interface to self
- // TODO: should apply HtmlDragObject interface?
- return dragObject;
+dojo.dnd.Sortable = function () {
+};
+dojo.lang.extend(dojo.dnd.Sortable, {ondragstart:function (e) {
+ var dragObject = e.target;
+ while (dragObject.parentNode && dragObject.parentNode != this) {
+ dragObject = dragObject.parentNode;
}
+ return dragObject;
+}});
-});
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDrop.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDrop.js
index b5f47ac6e..3f94eb84a 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDrop.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDrop.js
@@ -8,468 +8,244 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-/**
- * TreeDrag* specialized on managing subtree drags
- * It selects nodes and visualises what's going on,
- * but delegates real actions upon tree to the controller
- *
- * This code is considered a part of controller
-*/
-
dojo.provide("dojo.dnd.TreeDragAndDrop");
-
dojo.require("dojo.dnd.HtmlDragAndDrop");
dojo.require("dojo.lang.func");
dojo.require("dojo.lang.array");
dojo.require("dojo.lang.extras");
dojo.require("dojo.html.layout");
-
-dojo.dnd.TreeDragSource = function(node, syncController, type, treeNode){
+dojo.dnd.TreeDragSource = function (node, syncController, type, treeNode) {
this.controller = syncController;
this.treeNode = treeNode;
-
dojo.dnd.HtmlDragSource.call(this, node, type);
-}
-
+};
dojo.inherits(dojo.dnd.TreeDragSource, dojo.dnd.HtmlDragSource);
-
-dojo.lang.extend(dojo.dnd.TreeDragSource, {
- onDragStart: function(){
- /* extend adds functions to prototype */
- var dragObject = dojo.dnd.HtmlDragSource.prototype.onDragStart.call(this);
- //dojo.debugShallow(dragObject)
-
- dragObject.treeNode = this.treeNode;
-
- dragObject.onDragStart = dojo.lang.hitch(dragObject, function(e) {
-
- /* save selection */
- this.savedSelectedNode = this.treeNode.tree.selector.selectedNode;
- if (this.savedSelectedNode) {
- this.savedSelectedNode.unMarkSelected();
- }
-
- var result = dojo.dnd.HtmlDragObject.prototype.onDragStart.apply(this, arguments);
-
-
- /* remove background grid from cloned object */
- var cloneGrid = this.dragClone.getElementsByTagName('img');
- for(var i=0; i it was allowed before, no accept check is needed
- if (position=="onto" ||
- (!this.isAdjacentNode(sourceTreeNode, position)
- && this.controller.canMove(sourceTreeNode, this.treeNode.parent)
- )
- ) {
- return position;
- } else {
- return false;
- }
-
- },
-
- onDragOut: function(e) {
- this.clearAutoExpandTimer();
-
- this.hideIndicator();
- },
-
-
- clearAutoExpandTimer: function() {
- if (this.autoExpandTimer) {
- clearTimeout(this.autoExpandTimer);
- this.autoExpandTimer = null;
- }
- },
-
-
-
- onDragMove: function(e, dragObjects){
-
- var sourceTreeNode = dragObjects[0].treeNode;
-
- var position = this.getAcceptPosition(e, sourceTreeNode);
-
- if (position) {
- this.showIndicator(position);
- }
-
- },
-
- isAdjacentNode: function(sourceNode, position) {
-
- if (sourceNode === this.treeNode) return true;
- if (sourceNode.getNextSibling() === this.treeNode && position=="before") return true;
- if (sourceNode.getPreviousSibling() === this.treeNode && position=="after") return true;
-
+ }
+}, hideIndicator:function () {
+ this.treeNode.labelNode.style.borderBottom = "";
+ this.treeNode.labelNode.style.borderTop = "";
+ this.treeNode.unMarkSelected();
+ this.position = null;
+}, onDragOver:function (e) {
+ var accepts = dojo.dnd.HtmlDropTarget.prototype.onDragOver.apply(this, arguments);
+ if (accepts && this.treeNode.isFolder && !this.treeNode.isExpanded) {
+ this.setAutoExpandTimer();
+ }
+ return accepts;
+}, accepts:function (dragObjects) {
+ var accepts = dojo.dnd.HtmlDropTarget.prototype.accepts.apply(this, arguments);
+ if (!accepts) {
return false;
- },
-
-
- /* get DNDMode and see which position e fits */
- getPosition: function(e, DNDMode) {
- var node = dojo.byId(this.treeNode.labelNode);
- var mousey = e.pageY || e.clientY + dojo.body().scrollTop;
- var nodey = dojo.html.getAbsolutePosition(node).y;
- var height = dojo.html.getBorderBox(node).height;
-
- var relY = mousey - nodey;
- var p = relY / height;
-
- var position = ""; // "" <=> forbidden
- if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO
- && DNDMode & dojo.widget.Tree.prototype.DNDModes.BETWEEN) {
- if (p<=0.3) {
- position = "before";
- } else if (p<=0.7) {
+ }
+ var sourceTreeNode = dragObjects[0].treeNode;
+ if (dojo.lang.isUndefined(sourceTreeNode) || !sourceTreeNode || !sourceTreeNode.isTreeNode) {
+ dojo.raise("Source is not TreeNode or not found");
+ }
+ if (sourceTreeNode === this.treeNode) {
+ return false;
+ }
+ return true;
+}, setAutoExpandTimer:function () {
+ var _this = this;
+ var autoExpand = function () {
+ if (dojo.dnd.dragManager.currentDropTarget === _this) {
+ _this.controller.expand(_this.treeNode);
+ }
+ };
+ this.autoExpandTimer = dojo.lang.setTimeout(autoExpand, _this.autoExpandDelay);
+}, getDNDMode:function () {
+ return this.treeNode.tree.DNDMode;
+}, getAcceptPosition:function (e, sourceTreeNode) {
+ var DNDMode = this.getDNDMode();
+ if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO && !(!this.treeNode.actionIsDisabled(dojo.widget.TreeNode.prototype.actions.ADDCHILD) && sourceTreeNode.parent !== this.treeNode && this.controller.canMove(sourceTreeNode, this.treeNode))) {
+ DNDMode &= ~dojo.widget.Tree.prototype.DNDModes.ONTO;
+ }
+ var position = this.getPosition(e, DNDMode);
+ if (position == "onto" || (!this.isAdjacentNode(sourceTreeNode, position) && this.controller.canMove(sourceTreeNode, this.treeNode.parent))) {
+ return position;
+ } else {
+ return false;
+ }
+}, onDragOut:function (e) {
+ this.clearAutoExpandTimer();
+ this.hideIndicator();
+}, clearAutoExpandTimer:function () {
+ if (this.autoExpandTimer) {
+ clearTimeout(this.autoExpandTimer);
+ this.autoExpandTimer = null;
+ }
+}, onDragMove:function (e, dragObjects) {
+ var sourceTreeNode = dragObjects[0].treeNode;
+ var position = this.getAcceptPosition(e, sourceTreeNode);
+ if (position) {
+ this.showIndicator(position);
+ }
+}, isAdjacentNode:function (sourceNode, position) {
+ if (sourceNode === this.treeNode) {
+ return true;
+ }
+ if (sourceNode.getNextSibling() === this.treeNode && position == "before") {
+ return true;
+ }
+ if (sourceNode.getPreviousSibling() === this.treeNode && position == "after") {
+ return true;
+ }
+ return false;
+}, getPosition:function (e, DNDMode) {
+ var node = dojo.byId(this.treeNode.labelNode);
+ var mousey = e.pageY || e.clientY + dojo.body().scrollTop;
+ var nodey = dojo.html.getAbsolutePosition(node).y;
+ var height = dojo.html.getBorderBox(node).height;
+ var relY = mousey - nodey;
+ var p = relY / height;
+ var position = "";
+ if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO && DNDMode & dojo.widget.Tree.prototype.DNDModes.BETWEEN) {
+ if (p <= 0.3) {
+ position = "before";
+ } else {
+ if (p <= 0.7) {
position = "onto";
} else {
position = "after";
}
- } else if (DNDMode & dojo.widget.Tree.prototype.DNDModes.BETWEEN) {
- if (p<=0.5) {
+ }
+ } else {
+ if (DNDMode & dojo.widget.Tree.prototype.DNDModes.BETWEEN) {
+ if (p <= 0.5) {
position = "before";
} else {
position = "after";
}
- }
- else if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO) {
- position = "onto";
- }
-
-
- return position;
- },
-
-
-
- getTargetParentIndex: function(sourceTreeNode, position) {
-
- var index = position == "before" ? this.treeNode.getParentIndex() : this.treeNode.getParentIndex()+1;
- if (this.treeNode.parent === sourceTreeNode.parent
- && this.treeNode.getParentIndex() > sourceTreeNode.getParentIndex()) {
- index--; // dragging a node is different for simple move bacause of before-after issues
- }
-
- return index;
- },
-
-
- onDrop: function(e){
- // onDragOut will clean position
-
-
- var position = this.position;
-
-//dojo.debug(position);
-
- this.onDragOut(e);
-
- var sourceTreeNode = e.dragObject.treeNode;
-
- if (!dojo.lang.isObject(sourceTreeNode)) {
- dojo.raise("TreeNode not found in dragObject")
- }
-
- if (position == "onto") {
- return this.controller.move(sourceTreeNode, this.treeNode, 0);
} else {
- var index = this.getTargetParentIndex(sourceTreeNode, position);
- return this.controller.move(sourceTreeNode, this.treeNode.parent, index);
+ if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO) {
+ position = "onto";
+ }
}
-
- //dojo.debug('drop2');
-
-
-
}
-
-
-});
-
-
-
-dojo.dnd.TreeDNDController = function(treeController) {
-
- // I use this controller to perform actions
+ return position;
+}, getTargetParentIndex:function (sourceTreeNode, position) {
+ var index = position == "before" ? this.treeNode.getParentIndex() : this.treeNode.getParentIndex() + 1;
+ if (this.treeNode.parent === sourceTreeNode.parent && this.treeNode.getParentIndex() > sourceTreeNode.getParentIndex()) {
+ index--;
+ }
+ return index;
+}, onDrop:function (e) {
+ var position = this.position;
+ this.onDragOut(e);
+ var sourceTreeNode = e.dragObject.treeNode;
+ if (!dojo.lang.isObject(sourceTreeNode)) {
+ dojo.raise("TreeNode not found in dragObject");
+ }
+ if (position == "onto") {
+ return this.controller.move(sourceTreeNode, this.treeNode, 0);
+ } else {
+ var index = this.getTargetParentIndex(sourceTreeNode, position);
+ return this.controller.move(sourceTreeNode, this.treeNode.parent, index);
+ }
+}});
+dojo.dnd.TreeDNDController = function (treeController) {
this.treeController = treeController;
-
this.dragSources = {};
-
this.dropTargets = {};
-
-}
-
-dojo.lang.extend(dojo.dnd.TreeDNDController, {
-
-
- listenTree: function(tree) {
- //dojo.debug("Listen tree "+tree);
- dojo.event.topic.subscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
- dojo.event.topic.subscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
- dojo.event.topic.subscribe(tree.eventNames.moveTo, this, "onMoveTo");
- dojo.event.topic.subscribe(tree.eventNames.addChild, this, "onAddChild");
- dojo.event.topic.subscribe(tree.eventNames.removeNode, this, "onRemoveNode");
- dojo.event.topic.subscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
- },
-
-
- unlistenTree: function(tree) {
- //dojo.debug("Listen tree "+tree);
- dojo.event.topic.unsubscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
- dojo.event.topic.unsubscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
- dojo.event.topic.unsubscribe(tree.eventNames.moveTo, this, "onMoveTo");
- dojo.event.topic.unsubscribe(tree.eventNames.addChild, this, "onAddChild");
- dojo.event.topic.unsubscribe(tree.eventNames.removeNode, this, "onRemoveNode");
- dojo.event.topic.unsubscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
- },
-
- onTreeDestroy: function(message) {
- this.unlistenTree(message.source);
- // I'm not widget so don't use destroy() call and dieWithTree
- },
-
- onCreateDOMNode: function(message) {
- this.registerDNDNode(message.source);
- },
-
- onAddChild: function(message) {
- this.registerDNDNode(message.child);
- },
-
- onMoveFrom: function(message) {
- var _this = this;
- dojo.lang.forEach(
- message.child.getDescendants(),
- function(node) { _this.unregisterDNDNode(node); }
- );
- },
-
- onMoveTo: function(message) {
- var _this = this;
- dojo.lang.forEach(
- message.child.getDescendants(),
- function(node) { _this.registerDNDNode(node); }
- );
- },
-
- /**
- * Controller(node model) creates DNDNodes because it passes itself to node for synchroneous drops processing
- * I can't process DnD with events cause an event can't return result success/false
- */
- registerDNDNode: function(node) {
- if (!node.tree.DNDMode) return;
-
-//dojo.debug("registerDNDNode "+node);
-
- /* I drag label, not domNode, because large domNodes are very slow to copy and large to drag */
-
- var source = null;
- var target = null;
-
- if (!node.actionIsDisabled(node.actions.MOVE)) {
- //dojo.debug("reg source")
- var source = new dojo.dnd.TreeDragSource(node.labelNode, this, node.tree.widgetId, node);
- this.dragSources[node.widgetId] = source;
- }
-
- var target = new dojo.dnd.TreeDropTarget(node.labelNode, this.treeController, node.tree.DNDAcceptTypes, node);
-
- this.dropTargets[node.widgetId] = target;
-
- },
-
-
- unregisterDNDNode: function(node) {
-
- if (this.dragSources[node.widgetId]) {
- dojo.dnd.dragManager.unregisterDragSource(this.dragSources[node.widgetId]);
- delete this.dragSources[node.widgetId];
- }
-
- if (this.dropTargets[node.widgetId]) {
- dojo.dnd.dragManager.unregisterDropTarget(this.dropTargets[node.widgetId]);
- delete this.dropTargets[node.widgetId];
- }
+};
+dojo.lang.extend(dojo.dnd.TreeDNDController, {listenTree:function (tree) {
+ dojo.event.topic.subscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
+ dojo.event.topic.subscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
+ dojo.event.topic.subscribe(tree.eventNames.moveTo, this, "onMoveTo");
+ dojo.event.topic.subscribe(tree.eventNames.addChild, this, "onAddChild");
+ dojo.event.topic.subscribe(tree.eventNames.removeNode, this, "onRemoveNode");
+ dojo.event.topic.subscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+}, unlistenTree:function (tree) {
+ dojo.event.topic.unsubscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
+ dojo.event.topic.unsubscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
+ dojo.event.topic.unsubscribe(tree.eventNames.moveTo, this, "onMoveTo");
+ dojo.event.topic.unsubscribe(tree.eventNames.addChild, this, "onAddChild");
+ dojo.event.topic.unsubscribe(tree.eventNames.removeNode, this, "onRemoveNode");
+ dojo.event.topic.unsubscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+}, onTreeDestroy:function (message) {
+ this.unlistenTree(message.source);
+}, onCreateDOMNode:function (message) {
+ this.registerDNDNode(message.source);
+}, onAddChild:function (message) {
+ this.registerDNDNode(message.child);
+}, onMoveFrom:function (message) {
+ var _this = this;
+ dojo.lang.forEach(message.child.getDescendants(), function (node) {
+ _this.unregisterDNDNode(node);
+ });
+}, onMoveTo:function (message) {
+ var _this = this;
+ dojo.lang.forEach(message.child.getDescendants(), function (node) {
+ _this.registerDNDNode(node);
+ });
+}, registerDNDNode:function (node) {
+ if (!node.tree.DNDMode) {
+ return;
}
+ var source = null;
+ var target = null;
+ if (!node.actionIsDisabled(node.actions.MOVE)) {
+ var source = new dojo.dnd.TreeDragSource(node.labelNode, this, node.tree.widgetId, node);
+ this.dragSources[node.widgetId] = source;
+ }
+ var target = new dojo.dnd.TreeDropTarget(node.labelNode, this.treeController, node.tree.DNDAcceptTypes, node);
+ this.dropTargets[node.widgetId] = target;
+}, unregisterDNDNode:function (node) {
+ if (this.dragSources[node.widgetId]) {
+ dojo.dnd.dragManager.unregisterDragSource(this.dragSources[node.widgetId]);
+ delete this.dragSources[node.widgetId];
+ }
+ if (this.dropTargets[node.widgetId]) {
+ dojo.dnd.dragManager.unregisterDropTarget(this.dropTargets[node.widgetId]);
+ delete this.dropTargets[node.widgetId];
+ }
+}});
-
-
-
-
-});
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDropV3.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDropV3.js
index 1904b1890..cbeceef96 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDropV3.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDropV3.js
@@ -8,397 +8,209 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-/**
- * TreeDrag* specialized on managing subtree drags
- * It selects nodes and visualises what's going on,
- * but delegates real actions upon tree to the controller
- *
- * This code is considered a part of controller
-*/
-
dojo.provide("dojo.dnd.TreeDragAndDropV3");
-
dojo.require("dojo.dnd.HtmlDragAndDrop");
dojo.require("dojo.lang.func");
dojo.require("dojo.lang.array");
dojo.require("dojo.lang.extras");
dojo.require("dojo.Deferred");
dojo.require("dojo.html.layout");
-
-// FIXME: if controller can't move then skip node on move start
-dojo.dnd.TreeDragSourceV3 = function(node, syncController, type, treeNode){
- //dojo.profile.start("TreeDragSourceV3 "+treeNode);
+dojo.dnd.TreeDragSourceV3 = function (node, syncController, type, treeNode) {
this.controller = syncController;
this.treeNode = treeNode;
-
dojo.dnd.HtmlDragSource.call(this, node, type);
- //dojo.profile.end("TreeDragSourceV3 "+treeNode);
-
-}
-
+};
dojo.inherits(dojo.dnd.TreeDragSourceV3, dojo.dnd.HtmlDragSource);
-
-
-// .......................................
-
-dojo.dnd.TreeDropTargetV3 = function(domNode, controller, type, treeNode){
-
+dojo.dnd.TreeDropTargetV3 = function (domNode, controller, type, treeNode) {
this.treeNode = treeNode;
- this.controller = controller; // I will sync-ly process drops
-
+ this.controller = controller;
dojo.dnd.HtmlDropTarget.call(this, domNode, type);
-}
-
+};
dojo.inherits(dojo.dnd.TreeDropTargetV3, dojo.dnd.HtmlDropTarget);
-
-dojo.lang.extend(dojo.dnd.TreeDropTargetV3, {
-
- autoExpandDelay: 1500,
- autoExpandTimer: null,
-
-
- position: null,
-
- indicatorStyle: "2px black groove",
-
- showIndicator: function(position) {
-
- // do not change style too often, cause of blinking possible
- if (this.position == position) {
- return;
- }
-
- //dojo.debug("set position for "+this.treeNode)
-
- this.hideIndicator();
-
- this.position = position;
-
- var node = this.treeNode;
-
-
- node.contentNode.style.width = dojo.html.getBorderBox(node.labelNode).width + "px";
-
- if (position == "onto") {
- node.contentNode.style.border = this.indicatorStyle;
+dojo.lang.extend(dojo.dnd.TreeDropTargetV3, {autoExpandDelay:1500, autoExpandTimer:null, position:null, indicatorStyle:"2px black groove", showIndicator:function (position) {
+ if (this.position == position) {
+ return;
+ }
+ this.hideIndicator();
+ this.position = position;
+ var node = this.treeNode;
+ node.contentNode.style.width = dojo.html.getBorderBox(node.labelNode).width + "px";
+ if (position == "onto") {
+ node.contentNode.style.border = this.indicatorStyle;
+ } else {
+ if (position == "before") {
+ node.contentNode.style.borderTop = this.indicatorStyle;
} else {
- // FIXME: bottom-top or highlight should cover ONLY top/bottom or div itself,
- // not span whole line (try Dnd)
- // FAILURE: Can't put span inside div: multiline bottom-top will span multiple lines
- if (position == "before") {
- node.contentNode.style.borderTop = this.indicatorStyle;
- } else if (position == "after") {
+ if (position == "after") {
node.contentNode.style.borderBottom = this.indicatorStyle;
- }
- }
- },
-
- hideIndicator: function() {
- this.treeNode.contentNode.style.borderBottom = "";
- this.treeNode.contentNode.style.borderTop = "";
- this.treeNode.contentNode.style.border = "";
- this.treeNode.contentNode.style.width=""
- this.position = null;
- },
-
-
-
- // is the target possibly ok ?
- // This function is run on dragOver, but drop possibility is also determined by position over node
- // that's why acceptsWithPosition is called
- // doesnt take index into account ( can change while moving mouse w/o changing target )
- /**
- * Coarse (tree-level) access check.
- * We can't determine real accepts status w/o position
- */
- onDragOver: function(e){
- //dojo.debug("onDragOver for "+e);
-
- var accepts = dojo.dnd.HtmlDropTarget.prototype.onDragOver.apply(this, arguments);
-
- //dojo.debug("TreeDropTarget.onDragOver accepts:"+accepts)
-
- if (accepts && this.treeNode.isFolder && !this.treeNode.isExpanded) {
- this.setAutoExpandTimer();
- }
-
- if (accepts) {
- this.cacheNodeCoords();
- }
-
-
- return accepts;
- },
-
- /* Parent.onDragOver calls this function to get accepts status */
- accepts: function(dragObjects) {
-
- var accepts = dojo.dnd.HtmlDropTarget.prototype.accepts.apply(this, arguments);
-
- //dojo.debug("accepts "+accepts);
-
- if (!accepts) return false;
-
- for(var i=0; i it was allowed before, no accept check is needed
- if (position=="onto") {
- return position;
- }
-
- for(var i=0; i forbidden
- if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO
- && DndMode & dojo.widget.TreeV3.prototype.DndModes.BETWEEN) {
- //dojo.debug("BOTH");
- if (p<=0.33) {
- position = "before";
- // if children are expanded then I ignore understrike, cause it is confusing with firstChild
- // but for last nodes I put understrike there
- } else if (p<=0.66 || this.treeNode.isExpanded && this.treeNode.children.length && !this.treeNode.isLastChild()) {
+ }
+ for (var i = 0; i < dragObjects.length; i++) {
+ var sourceTreeNode = dragObjects[i].treeNode;
+ if (sourceTreeNode === this.treeNode) {
+ return false;
+ }
+ }
+ return true;
+}, setAutoExpandTimer:function () {
+ var _this = this;
+ var autoExpand = function () {
+ if (dojo.dnd.dragManager.currentDropTarget === _this) {
+ _this.controller.expand(_this.treeNode);
+ dojo.dnd.dragManager.cacheTargetLocations();
+ }
+ };
+ this.autoExpandTimer = dojo.lang.setTimeout(autoExpand, _this.autoExpandDelay);
+}, getAcceptPosition:function (e, dragObjects) {
+ var DndMode = this.treeNode.tree.DndMode;
+ if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO && this.treeNode.actionIsDisabledNow(this.treeNode.actions.ADDCHILD)) {
+ DndMode &= ~dojo.widget.TreeV3.prototype.DndModes.ONTO;
+ }
+ var position = this.getPosition(e, DndMode);
+ if (position == "onto") {
+ return position;
+ }
+ for (var i = 0; i < dragObjects.length; i++) {
+ var source = dragObjects[i].dragSource;
+ if (source.treeNode && this.isAdjacentNode(source.treeNode, position)) {
+ continue;
+ }
+ if (!this.controller.canMove(source.treeNode ? source.treeNode : source, this.treeNode.parent)) {
+ return false;
+ }
+ }
+ return position;
+}, onDropEnd:function (e) {
+ this.clearAutoExpandTimer();
+ this.hideIndicator();
+}, onDragOut:function (e) {
+ this.clearAutoExpandTimer();
+ this.hideIndicator();
+}, clearAutoExpandTimer:function () {
+ if (this.autoExpandTimer) {
+ clearTimeout(this.autoExpandTimer);
+ this.autoExpandTimer = null;
+ }
+}, onDragMove:function (e, dragObjects) {
+ var position = this.getAcceptPosition(e, dragObjects);
+ if (position) {
+ this.showIndicator(position);
+ }
+}, isAdjacentNode:function (sourceNode, position) {
+ if (sourceNode === this.treeNode) {
+ return true;
+ }
+ if (sourceNode.getNextSibling() === this.treeNode && position == "before") {
+ return true;
+ }
+ if (sourceNode.getPreviousSibling() === this.treeNode && position == "after") {
+ return true;
+ }
+ return false;
+}, cacheNodeCoords:function () {
+ var node = this.treeNode.contentNode;
+ this.cachedNodeY = dojo.html.getAbsolutePosition(node).y;
+ this.cachedNodeHeight = dojo.html.getBorderBox(node).height;
+}, getPosition:function (e, DndMode) {
+ var mousey = e.pageY || e.clientY + dojo.body().scrollTop;
+ var relY = mousey - this.cachedNodeY;
+ var p = relY / this.cachedNodeHeight;
+ var position = "";
+ if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO && DndMode & dojo.widget.TreeV3.prototype.DndModes.BETWEEN) {
+ if (p <= 0.33) {
+ position = "before";
+ } else {
+ if (p <= 0.66 || this.treeNode.isExpanded && this.treeNode.children.length && !this.treeNode.isLastChild()) {
position = "onto";
} else {
position = "after";
}
- } else if (DndMode & dojo.widget.TreeV3.prototype.DndModes.BETWEEN) {
- //dojo.debug("BETWEEN");
- if (p<=0.5 || this.treeNode.isExpanded && this.treeNode.children.length && !this.treeNode.isLastChild()) {
+ }
+ } else {
+ if (DndMode & dojo.widget.TreeV3.prototype.DndModes.BETWEEN) {
+ if (p <= 0.5 || this.treeNode.isExpanded && this.treeNode.children.length && !this.treeNode.isLastChild()) {
position = "before";
} else {
position = "after";
}
- }
- else if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO) {
- //dojo.debug("ONTO");
- position = "onto";
- }
-
- //dojo.debug(position);
-
- return position;
- },
-
-
-
- getTargetParentIndex: function(source, position) {
-
- var index = position == "before" ? this.treeNode.getParentIndex() : this.treeNode.getParentIndex()+1;
- if (source.treeNode
- && this.treeNode.parent === source.treeNode.parent
- && this.treeNode.getParentIndex() > source.treeNode.getParentIndex()) {
- index--; // dragging a node is different for simple move bacause of before-after issues
- }
-
- return index;
- },
-
-
- onDrop: function(e) {
- // onDropEnd will clean position
-
-
- var position = this.position;
-
-//dojo.debug(position);
- var source = e.dragObject.dragSource;
-
- //dojo.debug("onDrop "+source.treeNode+" " + position + " "+this.treeNode);
-
-
- var targetParent, targetIndex;
- if (position == "onto") {
- targetParent = this.treeNode;
- targetIndex = 0;
} else {
- targetIndex = this.getTargetParentIndex(source, position);
- targetParent = this.treeNode.parent;
- }
-
- //dojo.profile.start("onDrop "+sourceTreeNode);
- var r = this.getDropHandler(e, source, targetParent, targetIndex)();
-
- //dojo.profile.end("onDrop "+sourceTreeNode);
-
- return r;
-
- },
-
- /**
- * determine, which action I should perform with nodes
- * e.g move, clone..
- */
- getDropHandler: function(e, source, targetParent, targetIndex) {
- var handler;
- var _this = this;
- handler = function () {
- var result;
-
- //dojo.debug("Move "+source.treeNode+" to parent "+targetParent+":"+targetIndex);
- if (source.treeNode) {
- result = _this.controller.move(source.treeNode, targetParent, targetIndex, true);
- //dojo.debug("moved "+result);
- } else {
- if (dojo.lang.isFunction(source.onDrop)) {
- source.onDrop(targetParent, targetIndex);
- }
-
- var treeNode = source.getTreeNode();
- if (treeNode) {
- result = _this.controller.createChild(targetParent, targetIndex, treeNode, true);
- } else {
- result = true;
- }
- }
-
- if (result instanceof dojo.Deferred) {
- // this Deferred is always sync
- var isSuccess = result.fired == 0;
- if (!isSuccess) {
- _this.handleDropError(source, targetParent, targetIndex, result);
- }
-
- return isSuccess;
-
- } else {
- return result;
+ if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO) {
+ position = "onto";
}
}
-
- return handler;
- },
-
-
- handleDropError: function(source, parent, index, result) {
- dojo.debug("TreeDropTargetV3.handleDropError: DND error occured");
- dojo.debugShallow(result);
}
-
-
-});
+ return position;
+}, getTargetParentIndex:function (source, position) {
+ var index = position == "before" ? this.treeNode.getParentIndex() : this.treeNode.getParentIndex() + 1;
+ if (source.treeNode && this.treeNode.parent === source.treeNode.parent && this.treeNode.getParentIndex() > source.treeNode.getParentIndex()) {
+ index--;
+ }
+ return index;
+}, onDrop:function (e) {
+ var position = this.position;
+ var source = e.dragObject.dragSource;
+ var targetParent, targetIndex;
+ if (position == "onto") {
+ targetParent = this.treeNode;
+ targetIndex = 0;
+ } else {
+ targetIndex = this.getTargetParentIndex(source, position);
+ targetParent = this.treeNode.parent;
+ }
+ var r = this.getDropHandler(e, source, targetParent, targetIndex)();
+ return r;
+}, getDropHandler:function (e, source, targetParent, targetIndex) {
+ var handler;
+ var _this = this;
+ handler = function () {
+ var result;
+ if (source.treeNode) {
+ result = _this.controller.move(source.treeNode, targetParent, targetIndex, true);
+ } else {
+ if (dojo.lang.isFunction(source.onDrop)) {
+ source.onDrop(targetParent, targetIndex);
+ }
+ var treeNode = source.getTreeNode();
+ if (treeNode) {
+ result = _this.controller.createChild(targetParent, targetIndex, treeNode, true);
+ } else {
+ result = true;
+ }
+ }
+ if (result instanceof dojo.Deferred) {
+ var isSuccess = result.fired == 0;
+ if (!isSuccess) {
+ _this.handleDropError(source, targetParent, targetIndex, result);
+ }
+ return isSuccess;
+ } else {
+ return result;
+ }
+ };
+ return handler;
+}, handleDropError:function (source, parent, index, result) {
+ dojo.debug("TreeDropTargetV3.handleDropError: DND error occured");
+ dojo.debugShallow(result);
+}});
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/__package__.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/__package__.js
index 0a93fd2bb..8af2fbec8 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/__package__.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dnd/__package__.js
@@ -8,9 +8,6 @@
http://dojotoolkit.org/community/licensing.shtml
*/
-dojo.kwCompoundRequire({
- common: ["dojo.dnd.DragAndDrop"],
- browser: ["dojo.dnd.HtmlDragAndDrop"],
- dashboard: ["dojo.dnd.HtmlDragAndDrop"]
-});
+dojo.kwCompoundRequire({common:["dojo.dnd.DragAndDrop"], browser:["dojo.dnd.HtmlDragAndDrop"], dashboard:["dojo.dnd.HtmlDragAndDrop"]});
dojo.provide("dojo.dnd.*");
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/docs.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/docs.js
index fe2a1944c..7f872bfa6 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/docs.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/docs.js
@@ -40,12 +40,13 @@ dojo.lang.mixin(dojo.docs, {
require: function(/*String*/ require, /*bool*/ sync) {
dojo.debug("require(): " + require);
var parts = require.split("/");
+
var size = parts.length;
var deferred = new dojo.Deferred;
var args = {
mimetype: "text/json",
load: function(type, data){
- dojo.debug("require(): loaded");
+ dojo.debug("require(): loaded for " + require);
if(parts[0] != "function_names") {
for(var i = 0, part; part = parts[i]; i++){
@@ -58,13 +59,13 @@ dojo.lang.mixin(dojo.docs, {
deferred.errback();
}
};
-
- if (sync) {
- args.sync = true;
- }
if(location.protocol == "file:"){
if(size){
+ if(parts[parts.length - 1] == "documentation"){
+ parts[parts.length - 1] = "meta";
+ }
+
if(parts[0] == "function_names"){
args.url = [this._url, "local_json", "function_names"].join("/");
}else{
@@ -90,7 +91,7 @@ dojo.lang.mixin(dojo.docs, {
}
return fString;
},
- getMeta: function(/*mixed*/ selectKey, /*String*/ pkg, /*String*/ name, /*Function*/ callback, /*String?*/ id){
+ getMeta: function(/*String*/ pkg, /*String*/ name, /*Function*/ callback, /*String?*/ id){
// summary: Gets information about a function in regards to its meta data
if(typeof name == "function"){
// pId: a
@@ -107,35 +108,12 @@ dojo.lang.mixin(dojo.docs, {
if(!id){
id = "_";
}
-
- if(!selectKey){
- selectKey = ++dojo.docs._count;
- }
-
- var input;
- if(typeof selectKey == "object" && selectKey.selectKey){
- input = selectKey;
- selectKey = selectKey.selectKey;
- }else{
- input = {};
- }
-
- dojo.docs._buildCache({
- type: "meta",
- callbacks: [dojo.docs._gotMeta, callback],
- pkg: pkg,
- name: name,
- id: id,
- selectKey: selectKey,
- input: input
- });
},
_withPkg: function(/*String*/ type, /*Object*/ data, /*Object*/ evt, /*Object*/ input, /*String*/ newType){
dojo.debug("_withPkg(" + evt.name + ") has package: " + data[0]);
evt.pkg = data[0];
if("load" == type && evt.pkg){
evt.type = newType;
- dojo.docs._buildCache(evt);
}else{
if(evt.callbacks && evt.callbacks.length){
evt.callbacks.shift()("error", {}, evt, evt.input);
@@ -153,34 +131,14 @@ dojo.lang.mixin(dojo.docs, {
evt.callbacks.shift()(type, data, evt, evt.input);
}
},
- getSrc: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback, /*String?*/ id){
+ getSrc: function(/*String*/ name, /*Function*/ callback, /*String?*/ id){
// summary: Gets src file (created by the doc parser)
dojo.debug("getSrc(" + name + ")");
if(!id){
id = "_";
}
- if(!selectKey){
- selectKey = ++dojo.docs._count;
- }
-
- var input;
- if(typeof selectKey == "object" && selectKey.selectKey){
- input = selectKey;
- selectKey = selectKey.selectKey;
- }else{
- input = {};
- }
-
- dojo.docs._buildCache({
- type: "src",
- callbacks: [callback],
- name: name,
- id: id,
- input: input,
- selectKey: selectKey
- });
},
- getDoc: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback, /*String?*/ id){
+ getDoc: function(/*String*/ name, /*Function*/ callback, /*String?*/ id){
// summary: Gets external documentation stored on Jot for a given function
dojo.debug("getDoc(" + name + ")");
@@ -188,23 +146,11 @@ dojo.lang.mixin(dojo.docs, {
id = "_";
}
- if(!selectKey){
- selectKey = ++dojo.docs._count;
- }
-
var input = {};
- if(typeof selectKey == "object" && selectKey.selectKey){
- input.input = selectKey;
- selectKey = selectKey.selectKey;
- }
input.type = "doc";
input.name = name;
- input.selectKey = selectKey;
input.callbacks = [callback];
- input.selectKey = selectKey;
-
- dojo.docs._buildCache(input);
},
_gotDoc: function(/*String*/ type, /*Array*/ data, /*Object*/ evt, /*Object*/ input){
dojo.debug("_gotDoc(" + evt.type + ")");
@@ -226,8 +172,7 @@ dojo.lang.mixin(dojo.docs, {
data = {
returns: evt.fn.returns,
id: evt.id,
- variables: [],
- selectKey: evt.selectKey
+ variables: []
}
if(!cache.parameters){
cache.parameters = {};
@@ -249,34 +194,16 @@ dojo.lang.mixin(dojo.docs, {
evt.callbacks.shift()("load", data, evt, input);
}
},
- getPkgDoc: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback){
+ getPkgDoc: function(/*String*/ name, /*Function*/ callback){
// summary: Gets external documentation stored on Jot for a given package
dojo.debug("getPkgDoc(" + name + ")");
var input = {};
- if(typeof selectKey == "object" && selectKey.selectKey){
- input = selectKey;
- selectKey = selectKey.selectKey;
- }
- if(!selectKey){
- selectKey = ++dojo.docs._count;
- }
- dojo.docs._buildCache({
- type: "pkgdoc",
- callbacks: [callback],
- name: name,
- selectKey: selectKey,
- input: input
- });
},
- getPkgInfo: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback){
+ getPkgInfo: function(/*String*/ name, /*Function*/ callback){
// summary: Gets a combination of the metadata and external documentation for a given package
dojo.debug("getPkgInfo(" + name + ")");
- if(!selectKey){
- selectKey = ++dojo.docs._count;
- }
var input = {
- selectKey: selectKey,
expects: {
pkginfo: ["pkgmeta", "pkgdoc"]
},
@@ -287,12 +214,10 @@ dojo.lang.mixin(dojo.docs, {
},
_getPkgInfo: function(/*String*/ type, /*Object*/ data, /*Object*/ evt){
dojo.debug("_getPkgInfo() for " + evt.type);
- var key = evt.selectKey;
var input = {};
var results = {};
if(typeof key == "object"){
input = key;
- key = key.selectKey;
input[evt.type] = data;
if(input.expects && input.expects.pkginfo){
for(var i = 0, expect; expect = input.expects.pkginfo[i]; i++){
@@ -310,13 +235,12 @@ dojo.lang.mixin(dojo.docs, {
input.callback("load", results, evt);
}
},
- getInfo: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback){
+ getInfo: function(/*String*/ name, /*Function*/ callback){
dojo.debug("getInfo(" + name + ")");
var input = {
expects: {
"info": ["meta", "doc"]
},
- selectKey: selectKey,
callback: callback
}
dojo.docs.getMeta(input, name, dojo.docs._getInfo);
@@ -344,30 +268,34 @@ dojo.lang.mixin(dojo.docs, {
return text.replace(/^/, "").replace(/<\/html>$/, "").replace(/<\w+\s*\/>/g, "");
},
getPackageMeta: function(/*Object*/ input){
- dojo.debug("getPackageMeta(): " + input.pkg);
- return this.require(input.pkg + "/meta", input.sync);
+ dojo.debug("getPackageMeta(): " + input.package);
+ return this.require(input.package + "/meta", input.sync);
},
- OLDgetPkgMeta: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback){
- dojo.debug("getPkgMeta(" + name + ")");
- var input = {};
- if(typeof selectKey == "object" && selectKey.selectKey){
- input = selectKey;
- selectKey = selectKey.selectKey;
- }else if(!selectKey){
- selectKey = ++dojo.docs._count;
+ getFunctionMeta: function(/*Object*/ input){
+ var package = input.package || "";
+ var name = input.name;
+ var id = input.id || "_";
+ dojo.debug("getFunctionMeta(): " + name);
+
+ if(!name) return;
+
+ if(package){
+ return this.require(package + "/meta/functions/" + name + "/" + id + "/meta");
+ }else{
+ this.getFunctionNames();
}
- dojo.docs._buildCache({
- type: "pkgmeta",
- callbacks: [callback],
- name: name,
- selectKey: selectKey,
- input: input
- });
},
- OLD_getPkgMeta: function(/*Object*/ input){
- dojo.debug("_getPkgMeta(" + input.name + ")");
- input.type = "pkgmeta";
- dojo.docs._buildCache(input);
+ getFunctionDocumentation: function(/*Object*/ input){
+ var package = input.package || "";
+ var name = input.name;
+ var id = input.id || "_";
+ dojo.debug("getFunctionDocumentation(): " + name);
+
+ if(!name) return;
+
+ if(package){
+ return this.require(package + "/meta/functions/" + name + "/" + id + "/documentation");
+ }
},
_onDocSearch: function(/*Object*/ input){
var _this = this;
@@ -414,7 +342,7 @@ dojo.lang.mixin(dojo.docs, {
for(var i = 0, fn; fn = data[pkg][i]; i++){
if(fn.toLowerCase().indexOf(name) != -1){
dojo.debug("_onDocSearch(): Search matched " + fn);
- var meta = _this.getPackageMeta({pkg: pkg});
+ var meta = _this.getPackageMeta({package: pkg});
meta.addCallback(closure(pkg, fn));
list.push(meta);
@@ -473,7 +401,6 @@ dojo.lang.mixin(dojo.docs, {
size: 0,
methods: [],
pkg: pkg,
- selectKey: evt.selectKey,
requires: requires
}
var rePrivate = /_[^.]+$/;
@@ -499,7 +426,7 @@ dojo.lang.mixin(dojo.docs, {
if(input.loaded == input.pkgs.length){
var pkgs = input.pkgs;
var name = input.pkg;
- var results = {selectKey: evt.selectKey, methods: []};
+ var results = {methods: []};
var rePrivate = /_[^.]+$/;
data = dojo.docs._cache;
@@ -540,28 +467,30 @@ dojo.lang.mixin(dojo.docs, {
_onDocSelectFunction: function(/*Object*/ input){
// summary: Get doc, meta, and src
var name = input.name;
- var pkg = input.pkg;
+ var package = input.package || "";
+ var id = input.id || "_";
dojo.debug("_onDocSelectFunction(" + name + ")");
- if(!name){
- return false;
- }
- if(!input.selectKey){
- input.selectKey = ++dojo.docs._count;
- }
- input.expects = {
- "docresults": ["meta", "doc", "pkgmeta"]
- }
- dojo.docs.getMeta(input, pkg, name, dojo.docs._onDocSelectResults);
- dojo.docs.getDoc(input, pkg, name, dojo.docs._onDocSelectResults);
+ if(!name || !package) return false;
+
+ var pkgMeta = this.getPackageMeta({package: package});
+ var meta = this.getFunctionMeta({package: package, name: name, id: id});
+ var doc = this.getFunctionDocumentation({package: package, name: name, id: id});
+
+ var list = new dojo.DeferredList([pkgMeta, meta, doc]);
+ list.addCallback(function(results){
+ dojo.debug("_onDocSelectFunction() loaded");
+ for(var i = 0, result; result = results[i]; i++){
+ dojo.debugShallow(result[1]);
+ }
+ });
+
+ return list;
},
_onDocSelectPackage: function(/*Object*/ input){
dojo.debug("_onDocSelectPackage(" + input.name + ")")
input.expects = {
"pkgresults": ["pkgmeta", "pkgdoc"]
};
- if(!input.selectKey){
- input.selectKey = ++dojo.docs._count;
- }
dojo.docs.getPkgMeta(input, input.name, dojo.docs._onPkgResults);
dojo.docs.getPkgDoc(input, input.name, dojo.docs._onPkgResults);
},
@@ -589,311 +518,6 @@ dojo.lang.mixin(dojo.docs, {
// summary: Call this function to send the /docs/function/detail topic event
},
- _buildCache: function(/*Object*/ input){
- dojo.debug("_buildCache(" + input.type + ", " + input.name + ")");
- // Get stuff from the input object
- var type = input.type;
- var pkg = input.pkg;
- var callbacks = input.callbacks;
- var id = input.id;
- if(!id){
- id = input.id = "_";
- }
- var name = input.name;
- var selectKey = input.selectKey;
-
- var META = "meta";
- var METHODS = "methods";
- var SRC = "src";
- var DESCRIPTION = "description";
- var INPUT = "input";
- var LOAD = "load";
- var ERROR = "error";
-
- var docs = dojo.docs;
- var getCache = docs._getCache;
-
- // Stuff to pass to RPC
- var search = [];
-
- if(type == "doc"){
- if(!pkg){
- docs.functionPackages(selectKey, name, function(){ var a = arguments; docs._withPkg.call(this, a[0], a[1], a[2], a[3], "doc"); }, input);
- return;
- }else{
- var cached = getCache(pkg, META, METHODS, name, id, META);
-
- if(cached[DESCRIPTION]){
- callbacks.shift()(LOAD, cached[DESCRIPTION], input, input[INPUT]);
- return;
- }
-
- var obj = {};
- obj.forFormName = "DocFnForm";
- obj.limit = 1;
-
- obj.filter = "it/DocFnForm/require = '" + pkg + "' and it/DocFnForm/name = '" + name + "' and ";
- if(id == "_"){
- obj.filter += " not(it/DocFnForm/id)";
- }else{
- obj.filter += " it/DocFnForm/id = '" + id + "'";
- }
-
- obj.load = function(data){
- var cached = getCache(pkg, META, METHODS, name, id, META);
-
- var description = "";
- var returns = "";
- if(data.list && data.list.length){
- description = docs._getMainText(data.list[0]["main/text"]);
- returns = data.list[0]["DocFnForm/returns"];
- }
-
- cached[DESCRIPTION] = description;
- if(!cached.returns){
- cached.returns = {};
- }
- cached.returns.summary = returns;
-
- input.type = "fn";
- docs._gotDoc(LOAD, cached, input, input[INPUT]);
- }
- obj.error = function(data){
- input.type = "fn";
- docs._gotDoc(ERROR, {}, input, input[INPUT]);
- }
- search.push(obj);
-
- obj = {};
- obj.forFormName = "DocParamForm";
-
- obj.filter = "it/DocParamForm/fns = '" + pkg + "=>" + name;
- if(id != "_"){
- obj.filter += "=>" + id;
- }
- obj.filter += "'";
-
- obj.load = function(data){
- var cache = getCache(pkg, META, METHODS, name, id, META);
- for(var i = 0, param; param = data.list[i]; i++){
- var pName = param["DocParamForm/name"];
- if(!cache.parameters[pName]){
- cache.parameters[pName] = {};
- }
- cache.parameters[pName].summary = param["DocParamForm/desc"];
- }
- input.type = "param";
- docs._gotDoc(LOAD, cache.parameters, input);
- }
- obj.error = function(data){
- input.type = "param";
- docs._gotDoc(ERROR, {}, input);
- }
- search.push(obj);
- }
- }else if(type == "pkgdoc"){
- var cached = getCache(name, META);
-
- if(cached[DESCRIPTION]){
- callbacks.shift()(LOAD, {description: cached[DESCRIPTION], path: cached.path}, input, input.input);
- return;
- }
-
- var obj = {};
- obj.forFormName = "DocPkgForm";
- obj.limit = 1;
- obj.filter = "it/DocPkgForm/require = '" + name + "'";
-
- obj.load = function(data){
- var description = "";
- var list = data.list;
- if(list && list.length && list[0]["main/text"]){
- description = docs._getMainText(list[0]["main/text"]);
- cached[DESCRIPTION] = description;
- cached.path = list[0].name;
- }
-
- if(callbacks && callbacks.length){
- callbacks.shift()(LOAD, {description: description, path: cached.path}, input, input.input);
- }
- }
- obj.error = function(data){
- if(callbacks && callbacks.length){
- callbacks.shift()(ERROR, "", input, input.input);
- }
- }
- search.push(obj);
- }else if(type == "function_names"){
- var cached = getCache();
- if(!cached.function_names){
- dojo.debug("_buildCache() new cache");
- if(callbacks && callbacks.length){
- docs._callbacks.function_names.push([input, callbacks.shift()]);
- }
- cached.function_names = {loading: true};
-
- var obj = {};
- obj.url = "function_names";
- obj.load = function(type, data, evt){
- cached.function_names = data;
- while(docs._callbacks.function_names.length){
- var parts = docs._callbacks.function_names.pop();
- parts[1](LOAD, data, parts[0]);
- }
- }
- obj.error = function(type, data, evt){
- while(docs._callbacks.function_names.length){
- var parts = docs._callbacks.function_names.pop();
- parts[1](LOAD, {}, parts[0]);
- }
- }
- search.push(obj);
- }else if(cached.function_names.loading){
- dojo.debug("_buildCache() loading cache, adding to callback list");
- if(callbacks && callbacks.length){
- docs._callbacks.function_names.push([input, callbacks.shift()]);
- }
- return;
- }else{
- dojo.debug("_buildCache() loading from cache");
- if(callbacks && callbacks.length){
- callbacks.shift()(LOAD, cached.function_names, input);
- }
- return;
- }
- }else if(type == META || type == SRC){
- if(!pkg){
- if(type == META){
- docs.functionPackages(selectKey, name, function(){ var a = arguments; docs._withPkg.call(this, a[0], a[1], a[2], a[3], META); }, input);
- return;
- }else{
- docs.functionPackages(selectKey, name, function(){ var a = arguments; docs._withPkg.call(this, a[0], a[1], a[2], a[3], SRC); }, input);
- return;
- }
- }else{
- var cached = getCache(pkg, META, METHODS, name, id);
-
- if(cached[type] && cached[type].returns){
- if(callbacks && callbacks.length){
- callbacks.shift()(LOAD, cached[type], input);
- return;
- }
- }
-
- dojo.debug("Finding " + type + " for: " + pkg + ", function: " + name + ", id: " + id);
-
- var obj = {};
-
- if(type == SRC){
- obj.mimetype = "text/plain"
- }
- obj.url = pkg + "/" + name + "/" + id + "/" + type;
- obj.load = function(type, data, evt){
- dojo.debug("_buildCache() loaded " + input.type);
-
- if(input.type == SRC){
- getCache(pkg, META, METHODS, name, id).src = data;
- if(callbacks && callbacks.length){
- callbacks.shift()(LOAD, data, input, input[INPUT]);
- }
- }else{
- var cache = getCache(pkg, META, METHODS, name, id, META);
- if(!cache.parameters){
- cache.parameters = {};
- }
- for(var i = 0, param; param = data.parameters[i]; i++){
- if(!cache.parameters[param[1]]){
- cache.parameters[param[1]] = {};
- }
- cache.parameters[param[1]].type = param[0];
- }
- if(!cache.returns){
- cache.returns = {};
- }
- cache.returns.type = data.returns;
- }
-
- if(callbacks && callbacks.length){
- callbacks.shift()(LOAD, cache, input, input[INPUT]);
- }
- }
- obj.error = function(type, data, evt){
- if(callbacks && callbacks.length){
- callbacks.shift()(ERROR, {}, input, input[INPUT]);
- }
- }
- }
-
- search.push(obj);
- }else if(type == "pkgmeta"){
- var cached = getCache(name, "meta");
-
- if(cached.requires){
- if(callbacks && callbacks.length){
- callbacks.shift()(LOAD, cached, input, input[INPUT]);
- return;
- }
- }
-
- dojo.debug("Finding package meta for: " + name);
-
- var obj = {};
-
- obj.url = name + "/meta";
- obj.load = function(type, data, evt){
- dojo.debug("_buildCache() loaded for: " + name);
-
- var methods = data.methods;
- if(methods){
- for(var method in methods){
- if (method == "is") {
- continue;
- }
- for(var pId in methods[method]){
- getCache(name, META, METHODS, method, pId, META).summary = methods[method][pId];
- }
- }
- }
-
- var requires = data.requires;
- var cache = getCache(name, META);
- if(requires){
- cache.requires = requires;
- }
- if(callbacks && callbacks.length){
- callbacks.shift()(LOAD, cache, input, input[INPUT]);
- }
- }
- obj.error = function(type, data, evt){
- if(callbacks && callbacks.length){
- callbacks.shift()(ERROR, {}, input, input[INPUT]);
- }
- }
- search.push(obj);
- }
-
- for(var i = 0, obj; obj = search[i]; i++){
- var load = obj.load;
- var error = obj.error;
- delete obj.load;
- delete obj.error;
- var mimetype = obj.mimetype;
- if(!mimetype){
- mimetype = "text/json"
- }
- if(obj.url){
- dojo.io.bind({
- url: new dojo.uri.Uri(docs._url, obj.url),
- input: input,
- mimetype: mimetype,
- error: error,
- load: load
- });
- }else{
- docs._rpc.callRemote("search", obj).addCallbacks(load, error);
- }
- }
- },
selectFunction: function(/*String*/ name, /*String?*/ id){
// summary: The combined information
},
@@ -939,7 +563,7 @@ dojo.lang.mixin(dojo.docs, {
},
_savedPkgRpc: function(type){
},
- functionPackages: function(/*mixed*/ selectKey, /*String*/ name, /*Function*/ callback, /*Object*/ input){
+ functionPackages: function(/*String*/ name, /*Function*/ callback, /*Object*/ input){
// summary: Gets the package associated with a function and stores it in the .pkg value of input
dojo.debug("functionPackages() name: " + name);
@@ -954,7 +578,6 @@ dojo.lang.mixin(dojo.docs, {
input.name = name;
input.callbacks.unshift(callback);
input.callbacks.unshift(dojo.docs._functionPackages);
- dojo.docs._buildCache(input);
},
_functionPackages: function(/*String*/ type, /*Array*/ data, /*Object*/ evt){
dojo.debug("_functionPackages() name: " + evt.name);
@@ -1045,4 +668,4 @@ dojo.event.topic.subscribe("/docs/package/select", dojo.docs, "_onDocSelectPacka
dojo.event.topic.registerPublisher("/docs/function/results", dojo.docs, "_printFunctionResults");
dojo.event.topic.registerPublisher("/docs/function/detail", dojo.docs, "_printFunctionDetail");
-dojo.event.topic.registerPublisher("/docs/package/detail", dojo.docs, "_printPkgResult");
\ No newline at end of file
+dojo.event.topic.registerPublisher("/docs/package/detail", dojo.docs, "_printPkgResult");
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dom.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dom.js
index 7e3230eb8..2fa11d1e4 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dom.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/dom.js
@@ -9,514 +9,371 @@
*/
dojo.provide("dojo.dom");
-
-dojo.dom.ELEMENT_NODE = 1;
-dojo.dom.ATTRIBUTE_NODE = 2;
-dojo.dom.TEXT_NODE = 3;
-dojo.dom.CDATA_SECTION_NODE = 4;
-dojo.dom.ENTITY_REFERENCE_NODE = 5;
-dojo.dom.ENTITY_NODE = 6;
-dojo.dom.PROCESSING_INSTRUCTION_NODE = 7;
-dojo.dom.COMMENT_NODE = 8;
-dojo.dom.DOCUMENT_NODE = 9;
-dojo.dom.DOCUMENT_TYPE_NODE = 10;
-dojo.dom.DOCUMENT_FRAGMENT_NODE = 11;
-dojo.dom.NOTATION_NODE = 12;
-
+dojo.dom.ELEMENT_NODE = 1;
+dojo.dom.ATTRIBUTE_NODE = 2;
+dojo.dom.TEXT_NODE = 3;
+dojo.dom.CDATA_SECTION_NODE = 4;
+dojo.dom.ENTITY_REFERENCE_NODE = 5;
+dojo.dom.ENTITY_NODE = 6;
+dojo.dom.PROCESSING_INSTRUCTION_NODE = 7;
+dojo.dom.COMMENT_NODE = 8;
+dojo.dom.DOCUMENT_NODE = 9;
+dojo.dom.DOCUMENT_TYPE_NODE = 10;
+dojo.dom.DOCUMENT_FRAGMENT_NODE = 11;
+dojo.dom.NOTATION_NODE = 12;
dojo.dom.dojoml = "http://www.dojotoolkit.org/2004/dojoml";
-
-/**
- * comprehensive list of XML namespaces
-**/
-dojo.dom.xmlns = {
- // summary
- // aliases for various common XML namespaces
- svg : "http://www.w3.org/2000/svg",
- smil : "http://www.w3.org/2001/SMIL20/",
- mml : "http://www.w3.org/1998/Math/MathML",
- cml : "http://www.xml-cml.org",
- xlink : "http://www.w3.org/1999/xlink",
- xhtml : "http://www.w3.org/1999/xhtml",
- xul : "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- xbl : "http://www.mozilla.org/xbl",
- fo : "http://www.w3.org/1999/XSL/Format",
- xsl : "http://www.w3.org/1999/XSL/Transform",
- xslt : "http://www.w3.org/1999/XSL/Transform",
- xi : "http://www.w3.org/2001/XInclude",
- xforms : "http://www.w3.org/2002/01/xforms",
- saxon : "http://icl.com/saxon",
- xalan : "http://xml.apache.org/xslt",
- xsd : "http://www.w3.org/2001/XMLSchema",
- dt: "http://www.w3.org/2001/XMLSchema-datatypes",
- xsi : "http://www.w3.org/2001/XMLSchema-instance",
- rdf : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
- rdfs : "http://www.w3.org/2000/01/rdf-schema#",
- dc : "http://purl.org/dc/elements/1.1/",
- dcq: "http://purl.org/dc/qualifiers/1.0",
- "soap-env" : "http://schemas.xmlsoap.org/soap/envelope/",
- wsdl : "http://schemas.xmlsoap.org/wsdl/",
- AdobeExtensions : "http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
-};
-
-dojo.dom.isNode = function(/* object */wh){
- // summary
- // checks to see if wh is actually a node.
- if(typeof Element == "function") {
+dojo.dom.xmlns = {svg:"http://www.w3.org/2000/svg", smil:"http://www.w3.org/2001/SMIL20/", mml:"http://www.w3.org/1998/Math/MathML", cml:"http://www.xml-cml.org", xlink:"http://www.w3.org/1999/xlink", xhtml:"http://www.w3.org/1999/xhtml", xul:"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", xbl:"http://www.mozilla.org/xbl", fo:"http://www.w3.org/1999/XSL/Format", xsl:"http://www.w3.org/1999/XSL/Transform", xslt:"http://www.w3.org/1999/XSL/Transform", xi:"http://www.w3.org/2001/XInclude", xforms:"http://www.w3.org/2002/01/xforms", saxon:"http://icl.com/saxon", xalan:"http://xml.apache.org/xslt", xsd:"http://www.w3.org/2001/XMLSchema", dt:"http://www.w3.org/2001/XMLSchema-datatypes", xsi:"http://www.w3.org/2001/XMLSchema-instance", rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#", rdfs:"http://www.w3.org/2000/01/rdf-schema#", dc:"http://purl.org/dc/elements/1.1/", dcq:"http://purl.org/dc/qualifiers/1.0", "soap-env":"http://schemas.xmlsoap.org/soap/envelope/", wsdl:"http://schemas.xmlsoap.org/wsdl/", AdobeExtensions:"http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"};
+dojo.dom.isNode = function (wh) {
+ if (typeof Element == "function") {
try {
- return wh instanceof Element; // boolean
- } catch(E) {}
+ return wh instanceof Element;
+ }
+ catch (e) {
+ }
} else {
- // best-guess
- return wh && !isNaN(wh.nodeType); // boolean
+ return wh && !isNaN(wh.nodeType);
}
-}
-
-dojo.dom.getUniqueId = function(){
- // summary
- // returns a unique string for use with any DOM element
+};
+dojo.dom.getUniqueId = function () {
var _document = dojo.doc();
do {
var id = "dj_unique_" + (++arguments.callee._idIncrement);
- }while(_document.getElementById(id));
- return id; // string
-}
+ } while (_document.getElementById(id));
+ return id;
+};
dojo.dom.getUniqueId._idIncrement = 0;
-
-dojo.dom.firstElement = dojo.dom.getFirstChildElement = function(/* Element */parentNode, /* string? */tagName){
- // summary
- // returns the first child element matching tagName
+dojo.dom.firstElement = dojo.dom.getFirstChildElement = function (parentNode, tagName) {
var node = parentNode.firstChild;
- while(node && node.nodeType != dojo.dom.ELEMENT_NODE){
+ while (node && node.nodeType != dojo.dom.ELEMENT_NODE) {
node = node.nextSibling;
}
- if(tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
+ if (tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
node = dojo.dom.nextElement(node, tagName);
}
- return node; // Element
-}
-
-dojo.dom.lastElement = dojo.dom.getLastChildElement = function(/* Element */parentNode, /* string? */tagName){
- // summary
- // returns the last child element matching tagName
+ return node;
+};
+dojo.dom.lastElement = dojo.dom.getLastChildElement = function (parentNode, tagName) {
var node = parentNode.lastChild;
- while(node && node.nodeType != dojo.dom.ELEMENT_NODE) {
+ while (node && node.nodeType != dojo.dom.ELEMENT_NODE) {
node = node.previousSibling;
}
- if(tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
+ if (tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
node = dojo.dom.prevElement(node, tagName);
}
- return node; // Element
-}
-
-dojo.dom.nextElement = dojo.dom.getNextSiblingElement = function(/* Node */node, /* string? */tagName){
- // summary
- // returns the next sibling element matching tagName
- if(!node) { return null; }
+ return node;
+};
+dojo.dom.nextElement = dojo.dom.getNextSiblingElement = function (node, tagName) {
+ if (!node) {
+ return null;
+ }
do {
node = node.nextSibling;
- } while(node && node.nodeType != dojo.dom.ELEMENT_NODE);
-
- if(node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
+ } while (node && node.nodeType != dojo.dom.ELEMENT_NODE);
+ if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
return dojo.dom.nextElement(node, tagName);
}
- return node; // Element
-}
-
-dojo.dom.prevElement = dojo.dom.getPreviousSiblingElement = function(/* Node */node, /* string? */tagName){
- // summary
- // returns the previous sibling element matching tagName
- if(!node) { return null; }
- if(tagName) { tagName = tagName.toLowerCase(); }
+ return node;
+};
+dojo.dom.prevElement = dojo.dom.getPreviousSiblingElement = function (node, tagName) {
+ if (!node) {
+ return null;
+ }
+ if (tagName) {
+ tagName = tagName.toLowerCase();
+ }
do {
node = node.previousSibling;
- } while(node && node.nodeType != dojo.dom.ELEMENT_NODE);
-
- if(node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
+ } while (node && node.nodeType != dojo.dom.ELEMENT_NODE);
+ if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
return dojo.dom.prevElement(node, tagName);
}
- return node; // Element
-}
-
-// TODO: hmph
-/*this.forEachChildTag = function(node, unaryFunc) {
- var child = this.getFirstChildTag(node);
- while(child) {
- if(unaryFunc(child) == "break") { break; }
- child = this.getNextSiblingTag(child);
- }
-}*/
-
-dojo.dom.moveChildren = function(/* Element */srcNode, /* Element */destNode, /* boolean? */trim){
- // summary
- // Moves children from srcNode to destNode and returns the count of children moved;
- // will trim off text nodes if trim == true
+ return node;
+};
+dojo.dom.moveChildren = function (srcNode, destNode, trim) {
var count = 0;
- if(trim) {
- while(srcNode.hasChildNodes() &&
- srcNode.firstChild.nodeType == dojo.dom.TEXT_NODE) {
+ if (trim) {
+ while (srcNode.hasChildNodes() && srcNode.firstChild.nodeType == dojo.dom.TEXT_NODE) {
srcNode.removeChild(srcNode.firstChild);
}
- while(srcNode.hasChildNodes() &&
- srcNode.lastChild.nodeType == dojo.dom.TEXT_NODE) {
+ while (srcNode.hasChildNodes() && srcNode.lastChild.nodeType == dojo.dom.TEXT_NODE) {
srcNode.removeChild(srcNode.lastChild);
}
}
- while(srcNode.hasChildNodes()){
+ while (srcNode.hasChildNodes()) {
destNode.appendChild(srcNode.firstChild);
count++;
}
- return count; // number
-}
-
-dojo.dom.copyChildren = function(/* Element */srcNode, /* Element */destNode, /* boolean? */trim){
- // summary
- // Copies children from srcNde to destNode and returns the count of children copied;
- // will trim off text nodes if trim == true
+ return count;
+};
+dojo.dom.copyChildren = function (srcNode, destNode, trim) {
var clonedNode = srcNode.cloneNode(true);
- return this.moveChildren(clonedNode, destNode, trim); // number
-}
-
-dojo.dom.removeChildren = function(/* Element */node){
- // summary
- // removes all children from node and returns the count of children removed.
- var count = node.childNodes.length;
- while(node.hasChildNodes()){ node.removeChild(node.firstChild); }
- return count; // number
-}
-
-dojo.dom.replaceChildren = function(/* Element */node, /* Node */newChild){
- // summary
- // Removes all children of node and appends newChild
- // FIXME: what if newChild is an array-like object?
+ return this.moveChildren(clonedNode, destNode, trim);
+};
+dojo.dom.replaceChildren = function (node, newChild) {
+ var nodes = [];
+ if (dojo.render.html.ie) {
+ for (var i = 0; i < node.childNodes.length; i++) {
+ nodes.push(node.childNodes[i]);
+ }
+ }
dojo.dom.removeChildren(node);
node.appendChild(newChild);
-}
-
-dojo.dom.removeNode = function(/* Node */node){
- // summary
- // if node has a parent, removes node from parent and returns a reference to the removed child.
- if(node && node.parentNode){
- // return a ref to the removed child
- return node.parentNode.removeChild(node); // Node
+ for (var i = 0; i < nodes.length; i++) {
+ dojo.dom.destroyNode(nodes[i]);
}
-}
-
-dojo.dom.getAncestors = function(/* Node */node, /* function? */filterFunction, /* boolean? */returnFirstHit) {
- // summary
- // returns all ancestors matching optional filterFunction; will return only the first if returnFirstHit
+};
+dojo.dom.removeChildren = function (node) {
+ var count = node.childNodes.length;
+ while (node.hasChildNodes()) {
+ dojo.dom.removeNode(node.firstChild);
+ }
+ return count;
+};
+dojo.dom.replaceNode = function (node, newNode) {
+ return node.parentNode.replaceChild(newNode, node);
+};
+dojo.dom.destroyNode = function (node) {
+ if (node.parentNode) {
+ node = dojo.dom.removeNode(node);
+ }
+ if (node.nodeType != 3) {
+ if (dojo.evalObjPath("dojo.event.browser.clean", false)) {
+ dojo.event.browser.clean(node);
+ }
+ if (dojo.render.html.ie) {
+ node.outerHTML = "";
+ }
+ }
+};
+dojo.dom.removeNode = function (node) {
+ if (node && node.parentNode) {
+ return node.parentNode.removeChild(node);
+ }
+};
+dojo.dom.getAncestors = function (node, filterFunction, returnFirstHit) {
var ancestors = [];
var isFunction = (filterFunction && (filterFunction instanceof Function || typeof filterFunction == "function"));
- while(node) {
+ while (node) {
if (!isFunction || filterFunction(node)) {
ancestors.push(node);
}
- if (returnFirstHit && ancestors.length > 0) {
- return ancestors[0]; // Node
+ if (returnFirstHit && ancestors.length > 0) {
+ return ancestors[0];
}
-
node = node.parentNode;
}
- if (returnFirstHit) { return null; }
- return ancestors; // array
-}
-
-dojo.dom.getAncestorsByTag = function(/* Node */node, /* string */tag, /* boolean? */returnFirstHit) {
- // summary
- // returns all ancestors matching tag (as tagName), will only return first one if returnFirstHit
+ if (returnFirstHit) {
+ return null;
+ }
+ return ancestors;
+};
+dojo.dom.getAncestorsByTag = function (node, tag, returnFirstHit) {
tag = tag.toLowerCase();
- return dojo.dom.getAncestors(node, function(el){
- return ((el.tagName)&&(el.tagName.toLowerCase() == tag));
- }, returnFirstHit); // Node || array
-}
-
-dojo.dom.getFirstAncestorByTag = function(/* Node */node, /* string */tag) {
- // summary
- // Returns first ancestor of node with tag tagName
- return dojo.dom.getAncestorsByTag(node, tag, true); // Node
-}
-
-dojo.dom.isDescendantOf = function(/* Node */node, /* Node */ancestor, /* boolean? */guaranteeDescendant){
- // summary
- // Returns boolean if node is a descendant of ancestor
- // guaranteeDescendant allows us to be a "true" isDescendantOf function
- if(guaranteeDescendant && node) { node = node.parentNode; }
- while(node) {
- if(node == ancestor){
- return true; // boolean
+ return dojo.dom.getAncestors(node, function (el) {
+ return ((el.tagName) && (el.tagName.toLowerCase() == tag));
+ }, returnFirstHit);
+};
+dojo.dom.getFirstAncestorByTag = function (node, tag) {
+ return dojo.dom.getAncestorsByTag(node, tag, true);
+};
+dojo.dom.isDescendantOf = function (node, ancestor, guaranteeDescendant) {
+ if (guaranteeDescendant && node) {
+ node = node.parentNode;
+ }
+ while (node) {
+ if (node == ancestor) {
+ return true;
}
node = node.parentNode;
}
- return false; // boolean
-}
-
-dojo.dom.innerXML = function(/* Node */node){
- // summary
- // Implementation of MS's innerXML function.
- if(node.innerXML){
- return node.innerXML; // string
- }else if (node.xml){
- return node.xml; // string
- }else if(typeof XMLSerializer != "undefined"){
- return (new XMLSerializer()).serializeToString(node); // string
+ return false;
+};
+dojo.dom.innerXML = function (node) {
+ if (node.innerXML) {
+ return node.innerXML;
+ } else {
+ if (node.xml) {
+ return node.xml;
+ } else {
+ if (typeof XMLSerializer != "undefined") {
+ return (new XMLSerializer()).serializeToString(node);
+ }
+ }
}
-}
-
-dojo.dom.createDocument = function(){
- // summary
- // cross-browser implementation of creating an XML document object.
+};
+dojo.dom.createDocument = function () {
var doc = null;
var _document = dojo.doc();
-
- if(!dj_undef("ActiveXObject")){
- var prefixes = [ "MSXML2", "Microsoft", "MSXML", "MSXML3" ];
- for(var i = 0; i1) {
+ if (insertionIndex == 0) {
+ return dojo.dom.prependChild(node, containingNode);
+ }
+ return dojo.dom.insertAfter(node, siblingNodes[insertionIndex - 1]);
+};
+dojo.dom.textContent = function (node, text) {
+ if (arguments.length > 1) {
var _document = dojo.doc();
dojo.dom.replaceChildren(node, _document.createTextNode(text));
- return text; // string
+ return text;
} else {
- if(node.textContent != undefined){ //FF 1.5
- return node.textContent; // string
+ if (node.textContent != undefined) {
+ return node.textContent;
}
var _result = "";
- if (node == null) { return _result; }
+ if (node == null) {
+ return _result;
+ }
for (var i = 0; i < node.childNodes.length; i++) {
switch (node.childNodes[i].nodeType) {
- case 1: // ELEMENT_NODE
- case 5: // ENTITY_REFERENCE_NODE
- _result += dojo.dom.textContent(node.childNodes[i]);
- break;
- case 3: // TEXT_NODE
- case 2: // ATTRIBUTE_NODE
- case 4: // CDATA_SECTION_NODE
- _result += node.childNodes[i].nodeValue;
- break;
- default:
- break;
+ case 1:
+ case 5:
+ _result += dojo.dom.textContent(node.childNodes[i]);
+ break;
+ case 3:
+ case 2:
+ case 4:
+ _result += node.childNodes[i].nodeValue;
+ break;
+ default:
+ break;
}
}
- return _result; // string
+ return _result;
}
-}
-
-dojo.dom.hasParent = function (/* Node */node) {
- // summary
- // returns whether or not node is a child of another node.
- return node && node.parentNode && dojo.dom.isNode(node.parentNode); // boolean
-}
-
-/**
- * Examples:
- *
- * myFooNode =
- * isTag(myFooNode, "foo"); // returns "foo"
- * isTag(myFooNode, "bar"); // returns ""
- * isTag(myFooNode, "FOO"); // returns ""
- * isTag(myFooNode, "hey", "foo", "bar"); // returns "foo"
-**/
-dojo.dom.isTag = function(/* Node */node /* ... */) {
- // summary
- // determines if node has any of the provided tag names and returns the tag name that matches, empty string otherwise.
- if(node && node.tagName) {
- for(var i=1; i=0; i=i-1){
+ for (var i = na.length - 1; i >= 0; i = i - 1) {
var el = na[i];
- try{
- if(el && el["__clobberAttrs__"]){
- for(var j=0; j= 65 && unifiedCharCode <= 90 && evt.shiftKey == false){
- unifiedCharCode += 32;
- }
- if(unifiedCharCode >= 1 && unifiedCharCode <= 26 && evt.ctrlKey){
- unifiedCharCode += 96; // 001-032 = ctrl+[a-z]
- }
- evt.key = String.fromCharCode(unifiedCharCode);
+ if (evt["type"] == "keydown" && dojo.render.html.ie) {
+ switch (evt.keyCode) {
+ case evt.KEY_SHIFT:
+ case evt.KEY_CTRL:
+ case evt.KEY_ALT:
+ case evt.KEY_CAPS_LOCK:
+ case evt.KEY_LEFT_WINDOW:
+ case evt.KEY_RIGHT_WINDOW:
+ case evt.KEY_SELECT:
+ case evt.KEY_NUM_LOCK:
+ case evt.KEY_SCROLL_LOCK:
+ case evt.KEY_NUMPAD_0:
+ case evt.KEY_NUMPAD_1:
+ case evt.KEY_NUMPAD_2:
+ case evt.KEY_NUMPAD_3:
+ case evt.KEY_NUMPAD_4:
+ case evt.KEY_NUMPAD_5:
+ case evt.KEY_NUMPAD_6:
+ case evt.KEY_NUMPAD_7:
+ case evt.KEY_NUMPAD_8:
+ case evt.KEY_NUMPAD_9:
+ case evt.KEY_NUMPAD_PERIOD:
+ break;
+ case evt.KEY_NUMPAD_MULTIPLY:
+ case evt.KEY_NUMPAD_PLUS:
+ case evt.KEY_NUMPAD_ENTER:
+ case evt.KEY_NUMPAD_MINUS:
+ case evt.KEY_NUMPAD_DIVIDE:
+ break;
+ case evt.KEY_PAUSE:
+ case evt.KEY_TAB:
+ case evt.KEY_BACKSPACE:
+ case evt.KEY_ENTER:
+ case evt.KEY_ESCAPE:
+ case evt.KEY_PAGE_UP:
+ case evt.KEY_PAGE_DOWN:
+ case evt.KEY_END:
+ case evt.KEY_HOME:
+ case evt.KEY_LEFT_ARROW:
+ case evt.KEY_UP_ARROW:
+ case evt.KEY_RIGHT_ARROW:
+ case evt.KEY_DOWN_ARROW:
+ case evt.KEY_INSERT:
+ case evt.KEY_DELETE:
+ case evt.KEY_F1:
+ case evt.KEY_F2:
+ case evt.KEY_F3:
+ case evt.KEY_F4:
+ case evt.KEY_F5:
+ case evt.KEY_F6:
+ case evt.KEY_F7:
+ case evt.KEY_F8:
+ case evt.KEY_F9:
+ case evt.KEY_F10:
+ case evt.KEY_F11:
+ case evt.KEY_F12:
+ case evt.KEY_F12:
+ case evt.KEY_F13:
+ case evt.KEY_F14:
+ case evt.KEY_F15:
+ case evt.KEY_CLEAR:
+ case evt.KEY_HELP:
+ evt.key = evt.keyCode;
+ break;
+ default:
+ if (evt.ctrlKey || evt.altKey) {
+ var unifiedCharCode = evt.keyCode;
+ if (unifiedCharCode >= 65 && unifiedCharCode <= 90 && evt.shiftKey == false) {
+ unifiedCharCode += 32;
}
+ if (unifiedCharCode >= 1 && unifiedCharCode <= 26 && evt.ctrlKey) {
+ unifiedCharCode += 96;
+ }
+ evt.key = String.fromCharCode(unifiedCharCode);
+ }
}
- } else if(evt["type"] == "keypress"){
- if(dojo.render.html.opera){
- if(evt.which == 0){
- evt.key = evt.keyCode;
- }else if(evt.which > 0){
- switch(evt.which){
- case evt.KEY_SHIFT:
- case evt.KEY_CTRL:
- case evt.KEY_ALT:
- case evt.KEY_CAPS_LOCK:
- case evt.KEY_NUM_LOCK:
- case evt.KEY_SCROLL_LOCK:
- break;
- case evt.KEY_PAUSE:
- case evt.KEY_TAB:
- case evt.KEY_BACKSPACE:
- case evt.KEY_ENTER:
- case evt.KEY_ESCAPE:
- evt.key = evt.which;
- break;
- default:
- var unifiedCharCode = evt.which;
- if((evt.ctrlKey || evt.altKey || evt.metaKey) && (evt.which >= 65 && evt.which <= 90 && evt.shiftKey == false)){
- unifiedCharCode += 32;
+ } else {
+ if (evt["type"] == "keypress") {
+ if (dojo.render.html.opera) {
+ if (evt.which == 0) {
+ evt.key = evt.keyCode;
+ } else {
+ if (evt.which > 0) {
+ switch (evt.which) {
+ case evt.KEY_SHIFT:
+ case evt.KEY_CTRL:
+ case evt.KEY_ALT:
+ case evt.KEY_CAPS_LOCK:
+ case evt.KEY_NUM_LOCK:
+ case evt.KEY_SCROLL_LOCK:
+ break;
+ case evt.KEY_PAUSE:
+ case evt.KEY_TAB:
+ case evt.KEY_BACKSPACE:
+ case evt.KEY_ENTER:
+ case evt.KEY_ESCAPE:
+ evt.key = evt.which;
+ break;
+ default:
+ var unifiedCharCode = evt.which;
+ if ((evt.ctrlKey || evt.altKey || evt.metaKey) && (evt.which >= 65 && evt.which <= 90 && evt.shiftKey == false)) {
+ unifiedCharCode += 32;
+ }
+ evt.key = String.fromCharCode(unifiedCharCode);
}
- evt.key = String.fromCharCode(unifiedCharCode);
+ }
+ }
+ } else {
+ if (dojo.render.html.ie) {
+ if (!evt.ctrlKey && !evt.altKey && evt.keyCode >= evt.KEY_SPACE) {
+ evt.key = String.fromCharCode(evt.keyCode);
+ }
+ } else {
+ if (dojo.render.html.safari) {
+ switch (evt.keyCode) {
+ case 25:
+ evt.key = evt.KEY_TAB;
+ evt.shift = true;
+ break;
+ case 63232:
+ evt.key = evt.KEY_UP_ARROW;
+ break;
+ case 63233:
+ evt.key = evt.KEY_DOWN_ARROW;
+ break;
+ case 63234:
+ evt.key = evt.KEY_LEFT_ARROW;
+ break;
+ case 63235:
+ evt.key = evt.KEY_RIGHT_ARROW;
+ break;
+ case 63236:
+ evt.key = evt.KEY_F1;
+ break;
+ case 63237:
+ evt.key = evt.KEY_F2;
+ break;
+ case 63238:
+ evt.key = evt.KEY_F3;
+ break;
+ case 63239:
+ evt.key = evt.KEY_F4;
+ break;
+ case 63240:
+ evt.key = evt.KEY_F5;
+ break;
+ case 63241:
+ evt.key = evt.KEY_F6;
+ break;
+ case 63242:
+ evt.key = evt.KEY_F7;
+ break;
+ case 63243:
+ evt.key = evt.KEY_F8;
+ break;
+ case 63244:
+ evt.key = evt.KEY_F9;
+ break;
+ case 63245:
+ evt.key = evt.KEY_F10;
+ break;
+ case 63246:
+ evt.key = evt.KEY_F11;
+ break;
+ case 63247:
+ evt.key = evt.KEY_F12;
+ break;
+ case 63250:
+ evt.key = evt.KEY_PAUSE;
+ break;
+ case 63272:
+ evt.key = evt.KEY_DELETE;
+ break;
+ case 63273:
+ evt.key = evt.KEY_HOME;
+ break;
+ case 63275:
+ evt.key = evt.KEY_END;
+ break;
+ case 63276:
+ evt.key = evt.KEY_PAGE_UP;
+ break;
+ case 63277:
+ evt.key = evt.KEY_PAGE_DOWN;
+ break;
+ case 63302:
+ evt.key = evt.KEY_INSERT;
+ break;
+ case 63248:
+ case 63249:
+ case 63289:
+ break;
+ default:
+ evt.key = evt.charCode >= evt.KEY_SPACE ? String.fromCharCode(evt.charCode) : evt.keyCode;
+ }
+ } else {
+ evt.key = evt.charCode > 0 ? String.fromCharCode(evt.charCode) : evt.keyCode;
+ }
}
}
- }else if(dojo.render.html.ie){ // catch some IE keys that are hard to get in keyDown
- // key combinations were handled in onKeyDown
- if(!evt.ctrlKey && !evt.altKey && evt.keyCode >= evt.KEY_SPACE){
- evt.key = String.fromCharCode(evt.keyCode);
- }
- }else if(dojo.render.html.safari){
- switch(evt.keyCode){
- case 63232: evt.key = evt.KEY_UP_ARROW; break;
- case 63233: evt.key = evt.KEY_DOWN_ARROW; break;
- case 63234: evt.key = evt.KEY_LEFT_ARROW; break;
- case 63235: evt.key = evt.KEY_RIGHT_ARROW; break;
- default:
- evt.key = evt.charCode > 0 ? String.fromCharCode(evt.charCode) : evt.keyCode;
- }
- }else{
- evt.key = evt.charCode > 0 ? String.fromCharCode(evt.charCode) : evt.keyCode;
}
}
}
- if(dojo.render.html.ie){
- if(!evt.target){ evt.target = evt.srcElement; }
- if(!evt.currentTarget){ evt.currentTarget = (sender ? sender : evt.srcElement); }
- if(!evt.layerX){ evt.layerX = evt.offsetX; }
- if(!evt.layerY){ evt.layerY = evt.offsetY; }
- // FIXME: scroll position query is duped from dojo.html to avoid dependency on that entire module
- // DONOT replace the following to use dojo.body(), in IE, document.documentElement should be used
- // here rather than document.body
+ if (dojo.render.html.ie) {
+ if (!evt.target) {
+ evt.target = evt.srcElement;
+ }
+ if (!evt.currentTarget) {
+ evt.currentTarget = (sender ? sender : evt.srcElement);
+ }
+ if (!evt.layerX) {
+ evt.layerX = evt.offsetX;
+ }
+ if (!evt.layerY) {
+ evt.layerY = evt.offsetY;
+ }
var doc = (evt.srcElement && evt.srcElement.ownerDocument) ? evt.srcElement.ownerDocument : document;
- var docBody = ((dojo.render.html.ie55)||(doc["compatMode"] == "BackCompat")) ? doc.body : doc.documentElement;
- if(!evt.pageX){ evt.pageX = evt.clientX + (docBody.scrollLeft || 0) }
- if(!evt.pageY){ evt.pageY = evt.clientY + (docBody.scrollTop || 0) }
- // mouseover
- if(evt.type == "mouseover"){ evt.relatedTarget = evt.fromElement; }
- // mouseout
- if(evt.type == "mouseout"){ evt.relatedTarget = evt.toElement; }
+ var docBody = ((dojo.render.html.ie55) || (doc["compatMode"] == "BackCompat")) ? doc.body : doc.documentElement;
+ if (!evt.pageX) {
+ evt.pageX = evt.clientX + (docBody.scrollLeft || 0);
+ }
+ if (!evt.pageY) {
+ evt.pageY = evt.clientY + (docBody.scrollTop || 0);
+ }
+ if (evt.type == "mouseover") {
+ evt.relatedTarget = evt.fromElement;
+ }
+ if (evt.type == "mouseout") {
+ evt.relatedTarget = evt.toElement;
+ }
this.currentEvent = evt;
evt.callListener = this.callListener;
evt.stopPropagation = this._stopPropagation;
evt.preventDefault = this._preventDefault;
}
- return evt; // Event
- }
-
- this.stopEvent = function(/*Event*/evt){
- // summary:
- // prevents propigation and clobbers the default action of the
- // passed event
- // evt: Optional for IE. The native event object.
- if(window.event){
- evt.returnValue = false;
+ return evt;
+ };
+ this.stopEvent = function (evt) {
+ if (window.event) {
evt.cancelBubble = true;
- }else{
+ evt.returnValue = false;
+ } else {
evt.preventDefault();
evt.stopPropagation();
}
- }
-}
+ };
+};
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/event/common.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/event/common.js
index 6a3a65716..db9df5a73 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/event/common.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/event/common.js
@@ -9,870 +9,543 @@
*/
dojo.provide("dojo.event.common");
-
dojo.require("dojo.lang.array");
dojo.require("dojo.lang.extras");
dojo.require("dojo.lang.func");
-
-// TODO: connection filter functions
-// these are functions that accept a method invocation (like around
-// advice) and return a boolean based on it. That value determines
-// whether or not the connection proceeds. It could "feel" like around
-// advice for those who know what it is (calling proceed() or not),
-// but I think presenting it as a "filter" and/or calling it with the
-// function args and not the MethodInvocation might make it more
-// palletable to "normal" users than around-advice currently is
-// TODO: execution scope mangling
-// YUI's event facility by default executes listeners in the context
-// of the source object. This is very odd, but should probably be
-// supported as an option (both for the source and for the dest). It
-// can be thought of as a connection-specific hitch().
-// TODO: more resiliency for 4+ arguments to connect()
-
-dojo.event = new function(){
- this._canTimeout = dojo.lang.isFunction(dj_global["setTimeout"])||dojo.lang.isAlien(dj_global["setTimeout"]);
-
- // FIXME: where should we put this method (not here!)?
- function interpolateArgs(args, searchForNames){
+dojo.event = new function () {
+ this._canTimeout = dojo.lang.isFunction(dj_global["setTimeout"]) || dojo.lang.isAlien(dj_global["setTimeout"]);
+ function interpolateArgs(args, searchForNames) {
var dl = dojo.lang;
- var ao = {
- srcObj: dj_global,
- srcFunc: null,
- adviceObj: dj_global,
- adviceFunc: null,
- aroundObj: null,
- aroundFunc: null,
- adviceType: (args.length>2) ? args[0] : "after",
- precedence: "last",
- once: false,
- delay: null,
- rate: 0,
- adviceMsg: false
- };
-
- switch(args.length){
- case 0: return;
- case 1: return;
- case 2:
- ao.srcFunc = args[0];
- ao.adviceFunc = args[1];
- break;
- case 3:
- if((dl.isObject(args[0]))&&(dl.isString(args[1]))&&(dl.isString(args[2]))){
- ao.adviceType = "after";
- ao.srcObj = args[0];
+ var ao = {srcObj:dj_global, srcFunc:null, adviceObj:dj_global, adviceFunc:null, aroundObj:null, aroundFunc:null, adviceType:(args.length > 2) ? args[0] : "after", precedence:"last", once:false, delay:null, rate:0, adviceMsg:false, maxCalls:-1};
+ switch (args.length) {
+ case 0:
+ return;
+ case 1:
+ return;
+ case 2:
+ ao.srcFunc = args[0];
+ ao.adviceFunc = args[1];
+ break;
+ case 3:
+ if ((dl.isObject(args[0])) && (dl.isString(args[1])) && (dl.isString(args[2]))) {
+ ao.adviceType = "after";
+ ao.srcObj = args[0];
+ ao.srcFunc = args[1];
+ ao.adviceFunc = args[2];
+ } else {
+ if ((dl.isString(args[1])) && (dl.isString(args[2]))) {
ao.srcFunc = args[1];
ao.adviceFunc = args[2];
- }else if((dl.isString(args[1]))&&(dl.isString(args[2]))){
- ao.srcFunc = args[1];
- ao.adviceFunc = args[2];
- }else if((dl.isObject(args[0]))&&(dl.isString(args[1]))&&(dl.isFunction(args[2]))){
- ao.adviceType = "after";
- ao.srcObj = args[0];
- ao.srcFunc = args[1];
- var tmpName = dl.nameAnonFunc(args[2], ao.adviceObj, searchForNames);
- ao.adviceFunc = tmpName;
- }else if((dl.isFunction(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))){
- ao.adviceType = "after";
- ao.srcObj = dj_global;
- var tmpName = dl.nameAnonFunc(args[0], ao.srcObj, searchForNames);
- ao.srcFunc = tmpName;
- ao.adviceObj = args[1];
- ao.adviceFunc = args[2];
+ } else {
+ if ((dl.isObject(args[0])) && (dl.isString(args[1])) && (dl.isFunction(args[2]))) {
+ ao.adviceType = "after";
+ ao.srcObj = args[0];
+ ao.srcFunc = args[1];
+ var tmpName = dl.nameAnonFunc(args[2], ao.adviceObj, searchForNames);
+ ao.adviceFunc = tmpName;
+ } else {
+ if ((dl.isFunction(args[0])) && (dl.isObject(args[1])) && (dl.isString(args[2]))) {
+ ao.adviceType = "after";
+ ao.srcObj = dj_global;
+ var tmpName = dl.nameAnonFunc(args[0], ao.srcObj, searchForNames);
+ ao.srcFunc = tmpName;
+ ao.adviceObj = args[1];
+ ao.adviceFunc = args[2];
+ }
+ }
}
- break;
- case 4:
- if((dl.isObject(args[0]))&&(dl.isObject(args[2]))){
- // we can assume that we've got an old-style "connect" from
- // the sigslot school of event attachment. We therefore
- // assume after-advice.
- ao.adviceType = "after";
- ao.srcObj = args[0];
- ao.srcFunc = args[1];
- ao.adviceObj = args[2];
- ao.adviceFunc = args[3];
- }else if((dl.isString(args[0]))&&(dl.isString(args[1]))&&(dl.isObject(args[2]))){
+ }
+ break;
+ case 4:
+ if ((dl.isObject(args[0])) && (dl.isObject(args[2]))) {
+ ao.adviceType = "after";
+ ao.srcObj = args[0];
+ ao.srcFunc = args[1];
+ ao.adviceObj = args[2];
+ ao.adviceFunc = args[3];
+ } else {
+ if ((dl.isString(args[0])) && (dl.isString(args[1])) && (dl.isObject(args[2]))) {
ao.adviceType = args[0];
ao.srcObj = dj_global;
ao.srcFunc = args[1];
ao.adviceObj = args[2];
ao.adviceFunc = args[3];
- }else if((dl.isString(args[0]))&&(dl.isFunction(args[1]))&&(dl.isObject(args[2]))){
- ao.adviceType = args[0];
- ao.srcObj = dj_global;
- var tmpName = dl.nameAnonFunc(args[1], dj_global, searchForNames);
- ao.srcFunc = tmpName;
- ao.adviceObj = args[2];
- ao.adviceFunc = args[3];
- }else if((dl.isString(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))&&(dl.isFunction(args[3]))){
- ao.srcObj = args[1];
- ao.srcFunc = args[2];
- var tmpName = dl.nameAnonFunc(args[3], dj_global, searchForNames);
- ao.adviceObj = dj_global;
- ao.adviceFunc = tmpName;
- }else if(dl.isObject(args[1])){
- ao.srcObj = args[1];
- ao.srcFunc = args[2];
- ao.adviceObj = dj_global;
- ao.adviceFunc = args[3];
- }else if(dl.isObject(args[2])){
- ao.srcObj = dj_global;
- ao.srcFunc = args[1];
- ao.adviceObj = args[2];
- ao.adviceFunc = args[3];
- }else{
- ao.srcObj = ao.adviceObj = ao.aroundObj = dj_global;
- ao.srcFunc = args[1];
- ao.adviceFunc = args[2];
- ao.aroundFunc = args[3];
+ } else {
+ if ((dl.isString(args[0])) && (dl.isFunction(args[1])) && (dl.isObject(args[2]))) {
+ ao.adviceType = args[0];
+ ao.srcObj = dj_global;
+ var tmpName = dl.nameAnonFunc(args[1], dj_global, searchForNames);
+ ao.srcFunc = tmpName;
+ ao.adviceObj = args[2];
+ ao.adviceFunc = args[3];
+ } else {
+ if ((dl.isString(args[0])) && (dl.isObject(args[1])) && (dl.isString(args[2])) && (dl.isFunction(args[3]))) {
+ ao.srcObj = args[1];
+ ao.srcFunc = args[2];
+ var tmpName = dl.nameAnonFunc(args[3], dj_global, searchForNames);
+ ao.adviceObj = dj_global;
+ ao.adviceFunc = tmpName;
+ } else {
+ if (dl.isObject(args[1])) {
+ ao.srcObj = args[1];
+ ao.srcFunc = args[2];
+ ao.adviceObj = dj_global;
+ ao.adviceFunc = args[3];
+ } else {
+ if (dl.isObject(args[2])) {
+ ao.srcObj = dj_global;
+ ao.srcFunc = args[1];
+ ao.adviceObj = args[2];
+ ao.adviceFunc = args[3];
+ } else {
+ ao.srcObj = ao.adviceObj = ao.aroundObj = dj_global;
+ ao.srcFunc = args[1];
+ ao.adviceFunc = args[2];
+ ao.aroundFunc = args[3];
+ }
+ }
+ }
+ }
}
- break;
- case 6:
- ao.srcObj = args[1];
- ao.srcFunc = args[2];
- ao.adviceObj = args[3]
- ao.adviceFunc = args[4];
- ao.aroundFunc = args[5];
- ao.aroundObj = dj_global;
- break;
- default:
- ao.srcObj = args[1];
- ao.srcFunc = args[2];
- ao.adviceObj = args[3]
- ao.adviceFunc = args[4];
- ao.aroundObj = args[5];
- ao.aroundFunc = args[6];
- ao.once = args[7];
- ao.delay = args[8];
- ao.rate = args[9];
- ao.adviceMsg = args[10];
- break;
+ }
+ break;
+ case 6:
+ ao.srcObj = args[1];
+ ao.srcFunc = args[2];
+ ao.adviceObj = args[3];
+ ao.adviceFunc = args[4];
+ ao.aroundFunc = args[5];
+ ao.aroundObj = dj_global;
+ break;
+ default:
+ ao.srcObj = args[1];
+ ao.srcFunc = args[2];
+ ao.adviceObj = args[3];
+ ao.adviceFunc = args[4];
+ ao.aroundObj = args[5];
+ ao.aroundFunc = args[6];
+ ao.once = args[7];
+ ao.delay = args[8];
+ ao.rate = args[9];
+ ao.adviceMsg = args[10];
+ ao.maxCalls = (!isNaN(parseInt(args[11]))) ? args[11] : -1;
+ break;
}
-
- if(dl.isFunction(ao.aroundFunc)){
- var tmpName = dl.nameAnonFunc(ao.aroundFunc, ao.aroundObj, searchForNames);
+ if (dl.isFunction(ao.aroundFunc)) {
+ var tmpName = dl.nameAnonFunc(ao.aroundFunc, ao.aroundObj, searchForNames);
ao.aroundFunc = tmpName;
}
-
- if(dl.isFunction(ao.srcFunc)){
+ if (dl.isFunction(ao.srcFunc)) {
ao.srcFunc = dl.getNameInObj(ao.srcObj, ao.srcFunc);
}
-
- if(dl.isFunction(ao.adviceFunc)){
+ if (dl.isFunction(ao.adviceFunc)) {
ao.adviceFunc = dl.getNameInObj(ao.adviceObj, ao.adviceFunc);
}
-
- if((ao.aroundObj)&&(dl.isFunction(ao.aroundFunc))){
+ if ((ao.aroundObj) && (dl.isFunction(ao.aroundFunc))) {
ao.aroundFunc = dl.getNameInObj(ao.aroundObj, ao.aroundFunc);
}
-
- if(!ao.srcObj){
- dojo.raise("bad srcObj for srcFunc: "+ao.srcFunc);
+ if (!ao.srcObj) {
+ dojo.raise("bad srcObj for srcFunc: " + ao.srcFunc);
}
- if(!ao.adviceObj){
- dojo.raise("bad adviceObj for adviceFunc: "+ao.adviceFunc);
+ if (!ao.adviceObj) {
+ dojo.raise("bad adviceObj for adviceFunc: " + ao.adviceFunc);
}
-
- if(!ao.adviceFunc){
- dojo.debug("bad adviceFunc for srcFunc: "+ao.srcFunc);
+ if (!ao.adviceFunc) {
+ dojo.debug("bad adviceFunc for srcFunc: " + ao.srcFunc);
dojo.debugShallow(ao);
- }
-
+ }
return ao;
}
-
- this.connect = function(/*...*/){
- // summary:
- // dojo.event.connect is the glue that holds most Dojo-based
- // applications together. Most combinations of arguments are
- // supported, with the connect() method attempting to disambiguate
- // the implied types of positional parameters. The following will
- // all work:
- // dojo.event.connect("globalFunctionName1", "globalFunctionName2");
- // dojo.event.connect(functionReference1, functionReference2);
- // dojo.event.connect("globalFunctionName1", functionReference2);
- // dojo.event.connect(functionReference1, "globalFunctionName2");
- // dojo.event.connect(scope1, "functionName1", "globalFunctionName2");
- // dojo.event.connect("globalFunctionName1", scope2, "functionName2");
- // dojo.event.connect(scope1, "functionName1", scope2, "functionName2");
- // dojo.event.connect("after", scope1, "functionName1", scope2, "functionName2");
- // dojo.event.connect("before", scope1, "functionName1", scope2, "functionName2");
- // dojo.event.connect("around", scope1, "functionName1",
- // scope2, "functionName2",
- // aroundFunctionReference);
- // dojo.event.connect("around", scope1, "functionName1",
- // scope2, "functionName2",
- // scope3, "aroundFunctionName");
- // dojo.event.connect("before-around", scope1, "functionName1",
- // scope2, "functionName2",
- // aroundFunctionReference);
- // dojo.event.connect("after-around", scope1, "functionName1",
- // scope2, "functionName2",
- // aroundFunctionReference);
- // dojo.event.connect("after-around", scope1, "functionName1",
- // scope2, "functionName2",
- // scope3, "aroundFunctionName");
- // dojo.event.connect("around", scope1, "functionName1",
- // scope2, "functionName2",
- // scope3, "aroundFunctionName", true, 30);
- // dojo.event.connect("around", scope1, "functionName1",
- // scope2, "functionName2",
- // scope3, "aroundFunctionName", null, null, 10);
- // adviceType:
- // Optional. String. One of "before", "after", "around",
- // "before-around", or "after-around". FIXME
- // srcObj:
- // the scope in which to locate/execute the named srcFunc. Along
- // with srcFunc, this creates a way to dereference the function to
- // call. So if the function in question is "foo.bar", the
- // srcObj/srcFunc pair would be foo and "bar", where "bar" is a
- // string and foo is an object reference.
- // srcFunc:
- // the name of the function to connect to. When it is executed,
- // the listener being registered with this call will be called.
- // The adviceType defines the call order between the source and
- // the target functions.
- // adviceObj:
- // the scope in which to locate/execute the named adviceFunc.
- // adviceFunc:
- // the name of the function being conected to srcObj.srcFunc
- // aroundObj:
- // the scope in which to locate/execute the named aroundFunc.
- // aroundFunc:
- // the name of, or a reference to, the function that will be used
- // to mediate the advice call. Around advice requires a special
- // unary function that will be passed a "MethodInvocation" object.
- // These objects have several important properties, namely:
- // - args
- // a mutable array of arguments to be passed into the
- // wrapped function
- // - proceed
- // a function that "continues" the invocation. The result
- // of this function is the return of the wrapped function.
- // You can then manipulate this return before passing it
- // back out (or take further action based on it).
- // once:
- // boolean that determines whether or not this connect() will
- // create a new connection if an identical connect() has already
- // been made. Defaults to "false".
- // delay:
- // an optional delay (in ms), as an integer, for dispatch of a
- // listener after the source has been fired.
- // rate:
- // an optional rate throttling parameter (integer, in ms). When
- // specified, this particular connection will not fire more than
- // once in the interval specified by the rate
- // adviceMsg:
- // boolean. Should the listener have all the parameters passed in
- // as a single argument?
-
- /*
- ao.adviceType = args[0];
- ao.srcObj = args[1];
- ao.srcFunc = args[2];
- ao.adviceObj = args[3]
- ao.adviceFunc = args[4];
- ao.aroundObj = args[5];
- ao.aroundFunc = args[6];
- ao.once = args[7];
- ao.delay = args[8];
- ao.rate = args[9];
- ao.adviceMsg = args[10];
- */
- if(arguments.length == 1){
+ this.connect = function () {
+ if (arguments.length == 1) {
var ao = arguments[0];
- }else{
+ } else {
var ao = interpolateArgs(arguments, true);
}
- if(dojo.lang.isString(ao.srcFunc) && (ao.srcFunc.toLowerCase() == "onkey") ){
- if(dojo.render.html.ie){
- ao.srcFunc = "onkeydown";
- this.connect(ao);
- }
- ao.srcFunc = "onkeypress";
- }
-
-
- if(dojo.lang.isArray(ao.srcObj) && ao.srcObj!=""){
+ if (dojo.lang.isArray(ao.srcObj) && ao.srcObj != "") {
var tmpAO = {};
- for(var x in ao){
+ for (var x in ao) {
tmpAO[x] = ao[x];
}
var mjps = [];
- dojo.lang.forEach(ao.srcObj, function(src){
- if((dojo.render.html.capable)&&(dojo.lang.isString(src))){
+ dojo.lang.forEach(ao.srcObj, function (src) {
+ if ((dojo.render.html.capable) && (dojo.lang.isString(src))) {
src = dojo.byId(src);
- // dojo.debug(src);
}
tmpAO.srcObj = src;
- // dojo.debug(tmpAO.srcObj, tmpAO.srcFunc);
- // dojo.debug(tmpAO.adviceObj, tmpAO.adviceFunc);
mjps.push(dojo.event.connect.call(dojo.event, tmpAO));
});
return mjps;
}
-
- // FIXME: just doing a "getForMethod()" seems to be enough to put this into infinite recursion!!
var mjp = dojo.event.MethodJoinPoint.getForMethod(ao.srcObj, ao.srcFunc);
- if(ao.adviceFunc){
+ if (ao.adviceFunc) {
var mjp2 = dojo.event.MethodJoinPoint.getForMethod(ao.adviceObj, ao.adviceFunc);
}
-
mjp.kwAddAdvice(ao);
-
- // advanced users might want to fsck w/ the join point manually
- return mjp; // a MethodJoinPoint object
- }
-
- this.log = function(/*object or funcName*/ a1, /*funcName*/ a2){
- // summary:
- // a function that will wrap and log all calls to the specified
- // a1.a2() function. If only a1 is passed, it'll be used as a
- // function or function name on the global context. Logging will
- // be sent to dojo.debug
- // a1:
- // if a2 is passed, this should be an object. If not, it can be a
- // function or function name.
- // a2:
- // a function name
+ return mjp;
+ };
+ this.log = function (a1, a2) {
var kwArgs;
- if((arguments.length == 1)&&(typeof a1 == "object")){
+ if ((arguments.length == 1) && (typeof a1 == "object")) {
kwArgs = a1;
- }else{
- kwArgs = {
- srcObj: a1,
- srcFunc: a2
- };
+ } else {
+ kwArgs = {srcObj:a1, srcFunc:a2};
}
- kwArgs.adviceFunc = function(){
+ kwArgs.adviceFunc = function () {
var argsStr = [];
- for(var x=0; x= this.jp_.around.length){
+ if (this.around_index >= this.jp_.around.length) {
return this.jp_.object[this.jp_.methodname].apply(this.jp_.object, this.args);
- // return this.jp_.run_before_after(this.object, this.args);
- }else{
+ } else {
var ti = this.jp_.around[this.around_index];
- var mobj = ti[0]||dj_global;
+ var mobj = ti[0] || dj_global;
var meth = ti[1];
return mobj[meth].call(mobj, this);
}
-}
-
-
-dojo.event.MethodJoinPoint = function(/*Object*/obj, /*String*/funcName){
- this.object = obj||dj_global;
+};
+dojo.event.MethodJoinPoint = function (obj, funcName) {
+ this.object = obj || dj_global;
this.methodname = funcName;
this.methodfunc = this.object[funcName];
this.squelch = false;
- // this.before = [];
- // this.after = [];
- // this.around = [];
-}
-
-dojo.event.MethodJoinPoint.getForMethod = function(/*Object*/obj, /*String*/funcName){
- // summary:
- // "static" class function for returning a MethodJoinPoint from a
- // scoped function. If one doesn't exist, one is created.
- // obj:
- // the scope to search for the function in
- // funcName:
- // the name of the function to return a MethodJoinPoint for
- if(!obj){ obj = dj_global; }
- if(!obj[funcName]){
- // supply a do-nothing method implementation
- obj[funcName] = function(){};
- if(!obj[funcName]){
- // e.g. cannot add to inbuilt objects in IE6
- dojo.raise("Cannot set do-nothing method on that object "+funcName);
- }
- }else if((!dojo.lang.isFunction(obj[funcName]))&&(!dojo.lang.isAlien(obj[funcName]))){
- // FIXME: should we throw an exception here instead?
- return null;
+};
+dojo.event.MethodJoinPoint.getForMethod = function (obj, funcName) {
+ if (!obj) {
+ obj = dj_global;
+ }
+ var ofn = obj[funcName];
+ if (!ofn) {
+ ofn = obj[funcName] = function () {
+ };
+ if (!obj[funcName]) {
+ dojo.raise("Cannot set do-nothing method on that object " + funcName);
+ }
+ } else {
+ if ((typeof ofn != "function") && (!dojo.lang.isFunction(ofn)) && (!dojo.lang.isAlien(ofn))) {
+ return null;
+ }
}
- // we hide our joinpoint instance in obj[funcName + '$joinpoint']
var jpname = funcName + "$joinpoint";
var jpfuncname = funcName + "$joinpoint$method";
var joinpoint = obj[jpname];
- if(!joinpoint){
+ if (!joinpoint) {
var isNode = false;
- if(dojo.event["browser"]){
- if( (obj["attachEvent"])||
- (obj["nodeType"])||
- (obj["addEventListener"]) ){
+ if (dojo.event["browser"]) {
+ if ((obj["attachEvent"]) || (obj["nodeType"]) || (obj["addEventListener"])) {
isNode = true;
dojo.event.browser.addClobberNodeAttrs(obj, [jpname, jpfuncname, funcName]);
}
}
- var origArity = obj[funcName].length;
- obj[jpfuncname] = obj[funcName];
- // joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, funcName);
+ var origArity = ofn.length;
+ obj[jpfuncname] = ofn;
joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, jpfuncname);
- obj[funcName] = function(){
- var args = [];
-
- if((isNode)&&(!arguments.length)){
- var evt = null;
- try{
- if(obj.ownerDocument){
- evt = obj.ownerDocument.parentWindow.event;
- }else if(obj.documentElement){
- evt = obj.documentElement.ownerDocument.parentWindow.event;
- }else if(obj.event){ //obj is a window
- evt = obj.event;
- }else{
+ if (!isNode) {
+ obj[funcName] = function () {
+ return joinpoint.run.apply(joinpoint, arguments);
+ };
+ } else {
+ obj[funcName] = function () {
+ var args = [];
+ if (!arguments.length) {
+ var evt = null;
+ try {
+ if (obj.ownerDocument) {
+ evt = obj.ownerDocument.parentWindow.event;
+ } else {
+ if (obj.documentElement) {
+ evt = obj.documentElement.ownerDocument.parentWindow.event;
+ } else {
+ if (obj.event) {
+ evt = obj.event;
+ } else {
+ evt = window.event;
+ }
+ }
+ }
+ }
+ catch (e) {
evt = window.event;
}
- }catch(e){
- evt = window.event;
- }
-
- if(evt){
- args.push(dojo.event.browser.fixEvent(evt, this));
- }
- }else{
- for(var x=0; x -1) {
+ if (maxCount == 0) {
return;
}
-
- var callObj = marr[0]||dj_global;
- var callFunc = marr[1];
-
- if(!callObj[callFunc]){
- dojo.raise("function \"" + callFunc + "\" does not exist on \"" + callObj + "\"");
- }
-
- var aroundObj = marr[2]||dj_global;
- var aroundFunc = marr[3];
- var msg = marr[6];
- var undef;
-
- var to = {
- args: [],
- jp_: this,
- object: obj,
- proceed: function(){
- return callObj[callFunc].apply(callObj, to.args);
- }
- };
- to.args = aargs;
-
- var delay = parseInt(marr[4]);
- var hasDelay = ((!isNaN(delay))&&(marr[4]!==null)&&(typeof marr[4] != "undefined"));
- if(marr[5]){
- var rate = parseInt(marr[5]);
- var cur = new Date();
- var timerSet = false;
- if((marr["last"])&&((cur-marr.last)<=rate)){
- if(dojo.event._canTimeout){
- if(marr["delayTimer"]){
- clearTimeout(marr.delayTimer);
- }
- var tod = parseInt(rate*2); // is rate*2 naive?
- var mcpy = dojo.lang.shallowCopy(marr);
- marr.delayTimer = setTimeout(function(){
- // FIXME: on IE at least, event objects from the
- // browser can go out of scope. How (or should?) we
- // deal with it?
- mcpy[5] = 0;
- unrollAdvice(mcpy);
- }, tod);
+ marr[7]--;
+ }
+ var undef;
+ var to = {args:[], jp_:this, object:obj, proceed:function () {
+ return callObj[callFunc].apply(callObj, to.args);
+ }};
+ to.args = aargs;
+ var delay = parseInt(marr[4]);
+ var hasDelay = ((!isNaN(delay)) && (marr[4] !== null) && (typeof marr[4] != "undefined"));
+ if (marr[5]) {
+ var rate = parseInt(marr[5]);
+ var cur = new Date();
+ var timerSet = false;
+ if ((marr["last"]) && ((cur - marr.last) <= rate)) {
+ if (dojo.event._canTimeout) {
+ if (marr["delayTimer"]) {
+ clearTimeout(marr.delayTimer);
}
- return;
- }else{
- marr.last = cur;
+ var tod = parseInt(rate * 2);
+ var mcpy = dojo.lang.shallowCopy(marr);
+ marr.delayTimer = setTimeout(function () {
+ mcpy[5] = 0;
+ unrollAdvice(mcpy);
+ }, tod);
}
+ return;
+ } else {
+ marr.last = cur;
}
-
- // FIXME: need to enforce rates for a connection here!
-
- if(aroundFunc){
- // NOTE: around advice can't delay since we might otherwise depend
- // on execution order!
- aroundObj[aroundFunc].call(aroundObj, to);
- }else{
- // var tmjp = dojo.event.MethodJoinPoint.getForMethod(obj, methname);
- if((hasDelay)&&((dojo.render.html)||(dojo.render.svg))){ // FIXME: the render checks are grotty!
- dj_global["setTimeout"](function(){
- if(msg){
- callObj[callFunc].call(callObj, to);
- }else{
- callObj[callFunc].apply(callObj, args);
- }
- }, delay);
- }else{ // many environments can't support delay!
- if(msg){
- callObj[callFunc].call(callObj, to);
- }else{
- callObj[callFunc].apply(callObj, args);
+ }
+ if (aroundFunc) {
+ aroundObj[aroundFunc].call(aroundObj, to);
+ } else {
+ if ((hasDelay) && ((dojo.render.html) || (dojo.render.svg))) {
+ dj_global["setTimeout"](function () {
+ if (msg) {
+ callObj[callFunc].call(callObj, to);
+ } else {
+ callObj[callFunc].apply(callObj, args);
}
+ }, delay);
+ } else {
+ if (msg) {
+ callObj[callFunc].call(callObj, to);
+ } else {
+ callObj[callFunc].apply(callObj, args);
}
}
}
-
- var unRollSquelch = function(){
- if(this.squelch){
- try{
- return unrollAdvice.apply(this, arguments);
- }catch(e){
- dojo.debug(e);
- }
- }else{
+ };
+ var unRollSquelch = function () {
+ if (this.squelch) {
+ try {
return unrollAdvice.apply(this, arguments);
}
+ catch (e) {
+ dojo.debug(e);
+ }
+ } else {
+ return unrollAdvice.apply(this, arguments);
}
-
- if((this["before"])&&(this.before.length>0)){
- // pass a cloned array, if this event disconnects this event forEach on this.before wont work
- dojo.lang.forEach(this.before.concat(new Array()), unRollSquelch);
- }
-
- var result;
- try{
- if((this["around"])&&(this.around.length>0)){
- var mi = new dojo.event.MethodInvocation(this, obj, args);
- result = mi.proceed();
- }else if(this.methodfunc){
+ };
+ if ((this["before"]) && (this.before.length > 0)) {
+ dojo.lang.forEach(this.before.concat(new Array()), unRollSquelch);
+ }
+ var result;
+ try {
+ if ((this["around"]) && (this.around.length > 0)) {
+ var mi = new dojo.event.MethodInvocation(this, obj, args);
+ result = mi.proceed();
+ } else {
+ if (this.methodfunc) {
result = this.object[this.methodname].apply(this.object, args);
}
- }catch(e){ if(!this.squelch){ dojo.raise(e); } }
-
- if((this["after"])&&(this.after.length>0)){
- // see comment on this.before above
- dojo.lang.forEach(this.after.concat(new Array()), unRollSquelch);
}
-
- return (this.methodfunc) ? result : null;
- },
-
- getArr: function(/*String*/kind){
- // summary: return a list of listeners of the past "kind"
- // kind:
- // can be one of: "before", "after", "around", "before-around", or
- // "after-around"
- var type = "after";
- // FIXME: we should be able to do this through props or Array.in()
- if((typeof kind == "string")&&(kind.indexOf("before")!=-1)){
- type = "before";
- }else if(kind=="around"){
+ }
+ catch (e) {
+ if (!this.squelch) {
+ dojo.debug(e, "when calling", this.methodname, "on", this.object, "with arguments", args);
+ dojo.raise(e);
+ }
+ }
+ if ((this["after"]) && (this.after.length > 0)) {
+ dojo.lang.forEach(this.after.concat(new Array()), unRollSquelch);
+ }
+ return (this.methodfunc) ? result : null;
+}, getArr:function (kind) {
+ var type = "after";
+ if ((typeof kind == "string") && (kind.indexOf("before") != -1)) {
+ type = "before";
+ } else {
+ if (kind == "around") {
type = "around";
}
- if(!this[type]){ this[type] = []; }
- return this[type]; // Array
- },
-
- kwAddAdvice: function(/*Object*/args){
- // summary:
- // adds advice to the joinpoint with arguments in a map
- // args:
- // An object that can have the following properties:
- // - adviceType
- // - adviceObj
- // - adviceFunc
- // - aroundObj
- // - aroundFunc
- // - once
- // - delay
- // - rate
- // - adviceMsg
- this.addAdvice( args["adviceObj"], args["adviceFunc"],
- args["aroundObj"], args["aroundFunc"],
- args["adviceType"], args["precedence"],
- args["once"], args["delay"], args["rate"],
- args["adviceMsg"]);
- },
-
- addAdvice: function( thisAdviceObj, thisAdvice,
- thisAroundObj, thisAround,
- adviceType, precedence,
- once, delay, rate, asMessage){
- // summary:
- // add advice to this joinpoint using positional parameters
- // thisAdviceObj:
- // the scope in which to locate/execute the named adviceFunc.
- // thisAdviceFunc:
- // the name of the function being conected
- // thisAroundObj:
- // the scope in which to locate/execute the named aroundFunc.
- // thisAroundFunc:
- // the name of the function that will be used to mediate the
- // advice call.
- // adviceType:
- // Optional. String. One of "before", "after", "around",
- // "before-around", or "after-around". FIXME
- // once:
- // boolean that determines whether or not this advice will create
- // a new connection if an identical advice set has already been
- // provided. Defaults to "false".
- // delay:
- // an optional delay (in ms), as an integer, for dispatch of a
- // listener after the source has been fired.
- // rate:
- // an optional rate throttling parameter (integer, in ms). When
- // specified, this particular connection will not fire more than
- // once in the interval specified by the rate
- // adviceMsg:
- // boolean. Should the listener have all the parameters passed in
- // as a single argument?
- var arr = this.getArr(adviceType);
- if(!arr){
- dojo.raise("bad this: " + this);
- }
-
- var ao = [thisAdviceObj, thisAdvice, thisAroundObj, thisAround, delay, rate, asMessage];
-
- if(once){
- if(this.hasAdvice(thisAdviceObj, thisAdvice, adviceType, arr) >= 0){
- return;
- }
- }
-
- if(precedence == "first"){
- arr.unshift(ao);
- }else{
- arr.push(ao);
- }
- },
-
- hasAdvice: function(thisAdviceObj, thisAdvice, adviceType, arr){
- // summary:
- // returns the array index of the first existing connection
- // betweened the passed advice and this joinpoint. Will be -1 if
- // none exists.
- // thisAdviceObj:
- // the scope in which to locate/execute the named adviceFunc.
- // thisAdviceFunc:
- // the name of the function being conected
- // adviceType:
- // Optional. String. One of "before", "after", "around",
- // "before-around", or "after-around". FIXME
- // arr:
- // Optional. The list of advices to search. Will be found via
- // adviceType if not passed
- if(!arr){ arr = this.getArr(adviceType); }
- var ind = -1;
- for(var x=0; x= 0) {
+ return;
+ }
+ }
+ if (precedence == "first") {
+ arr.unshift(ao);
+ } else {
+ arr.push(ao);
+ }
+}, hasAdvice:function (thisAdviceObj, thisAdvice, adviceType, arr) {
+ if (!arr) {
+ arr = this.getArr(adviceType);
+ }
+ var ind = -1;
+ for (var x = 0; x < arr.length; x++) {
+ var aao = (typeof thisAdvice == "object") ? (new String(thisAdvice)).toString() : thisAdvice;
+ var a1o = (typeof arr[x][1] == "object") ? (new String(arr[x][1])).toString() : arr[x][1];
+ if ((arr[x][0] == thisAdviceObj) && (a1o == aao)) {
+ ind = x;
+ }
+ }
+ return ind;
+}, removeAdvice:function (thisAdviceObj, thisAdvice, adviceType, once) {
+ var arr = this.getArr(adviceType);
+ var ind = this.hasAdvice(thisAdviceObj, thisAdvice, adviceType, arr);
+ if (ind == -1) {
+ return false;
+ }
+ while (ind != -1) {
+ arr.splice(ind, 1);
+ if (once) {
+ break;
+ }
+ ind = this.hasAdvice(thisAdviceObj, thisAdvice, adviceType, arr);
+ }
+ return true;
+}});
+
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/event/topic.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/event/topic.js
index 597f1cf96..562f08231 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/event/topic.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/src/event/topic.js
@@ -10,192 +10,68 @@
dojo.require("dojo.event.common");
dojo.provide("dojo.event.topic");
-
-dojo.event.topic = new function(){
+dojo.event.topic = new function () {
this.topics = {};
-
- this.getTopic = function(/*String*/topic){
- // summary:
- // returns a topic implementation object of type
- // dojo.event.topic.TopicImpl
- // topic:
- // a unique, opaque string that names the topic
- if(!this.topics[topic]){
+ this.getTopic = function (topic) {
+ if (!this.topics[topic]) {
this.topics[topic] = new this.TopicImpl(topic);
}
- return this.topics[topic]; // a dojo.event.topic.TopicImpl object
- }
-
- this.registerPublisher = function(/*String*/topic, /*Object*/obj, /*String*/funcName){
- // summary:
- // registers a function as a publisher on a topic. Subsequent
- // calls to the function will cause a publish event on the topic
- // with the arguments passed to the function passed to registered
- // listeners.
- // topic:
- // a unique, opaque string that names the topic
- // obj:
- // the scope to locate the function in
- // funcName:
- // the name of the function to register
+ return this.topics[topic];
+ };
+ this.registerPublisher = function (topic, obj, funcName) {
var topic = this.getTopic(topic);
topic.registerPublisher(obj, funcName);
- }
-
- this.subscribe = function(/*String*/topic, /*Object*/obj, /*String*/funcName){
- // summary:
- // susbscribes the function to the topic. Subsequent events
- // dispached to the topic will create a function call for the
- // obj.funcName() function.
- // topic:
- // a unique, opaque string that names the topic
- // obj:
- // the scope to locate the function in
- // funcName:
- // the name of the function to being registered as a listener
+ };
+ this.subscribe = function (topic, obj, funcName) {
var topic = this.getTopic(topic);
topic.subscribe(obj, funcName);
- }
-
- this.unsubscribe = function(/*String*/topic, /*Object*/obj, /*String*/funcName){
- // summary:
- // unsubscribes the obj.funcName() from the topic
- // topic:
- // a unique, opaque string that names the topic
- // obj:
- // the scope to locate the function in
- // funcName:
- // the name of the function to being unregistered as a listener
+ };
+ this.unsubscribe = function (topic, obj, funcName) {
var topic = this.getTopic(topic);
topic.unsubscribe(obj, funcName);
- }
-
- this.destroy = function(/*String*/topic){
- // summary:
- // destroys the topic and unregisters all listeners
- // topic:
- // a unique, opaque string that names the topic
+ };
+ this.destroy = function (topic) {
this.getTopic(topic).destroy();
delete this.topics[topic];
- }
-
- this.publishApply = function(/*String*/topic, /*Array*/args){
- // summary:
- // dispatches an event to the topic using the args array as the
- // source for the call arguments to each listener. This is similar
- // to JavaScript's built-in Function.apply()
- // topic:
- // a unique, opaque string that names the topic
- // args:
- // the arguments to be passed into listeners of the topic
+ };
+ this.publishApply = function (topic, args) {
var topic = this.getTopic(topic);
topic.sendMessage.apply(topic, args);
- }
-
- this.publish = function(/*String*/topic, /*Object*/message){
- // summary:
- // manually "publish" to the passed topic
- // topic:
- // a unique, opaque string that names the topic
- // message:
- // can be an array of parameters (similar to publishApply), or
- // will be treated as one of many arguments to be passed along in
- // a "flat" unrolling
+ };
+ this.publish = function (topic, message) {
var topic = this.getTopic(topic);
- // if message is an array, we treat it as a set of arguments,
- // otherwise, we just pass on the arguments passed in as-is
var args = [];
- // could we use concat instead here?
- for(var x=1; x 0){
- for(var i = 0;i < dojo.flash._loadedListeners.length; i++){
- dojo.flash._loadedListeners[i].call(null);
- }
- }
- },
-
- /**
- A callback to know if Flash is currently being installed or
- having its version revved. To be notified if Flash is installing, connect
- your callback to this method using the following:
-
- dojo.event.connect(dojo.flash, "installing", myInstance, "myCallback");
- */
- installing: function(){
- //dojo.debug("installing");
- if(dojo.flash._installingListeners.length > 0){
- for(var i = 0; i < dojo.flash._installingListeners.length; i++){
- dojo.flash._installingListeners[i].call(null);
- }
- }
- },
-
- /** Initializes dojo.flash. */
- _initialize: function(){
- //dojo.debug("dojo.flash._initialize");
- // see if we need to rev or install Flash on this platform
- var installer = new dojo.flash.Install();
- dojo.flash.installer = installer;
-
- if(installer.needed() == true){
- installer.install();
- }else{
- //dojo.debug("Writing object out");
- // write the flash object into the page
- dojo.flash.obj = new dojo.flash.Embed(this._visible);
- dojo.flash.obj.write(dojo.flash.info.commVersion);
-
- // initialize the way we do Flash/JavaScript communication
- dojo.flash.comm = new dojo.flash.Communicator();
- }
- }
+dojo.flash = function () {
};
-
-
-/**
- A class that helps us determine whether Flash is available,
- it's major and minor versions, and what Flash version features should
- be used for Flash/JavaScript communication. Parts of this code
- are adapted from the automatic Flash plugin detection code autogenerated
- by the Macromedia Flash 8 authoring environment.
-
- An instance of this class can be accessed on dojo.flash.info after
- the page is finished loading.
-
- This constructor must be called before the page is finished loading.
-*/
-dojo.flash.Info = function(){
- // Visual basic helper required to detect Flash Player ActiveX control
- // version information on Internet Explorer
- if(dojo.render.html.ie){
- document.writeln('');
+dojo.flash = {flash6_version:null, flash8_version:null, ready:false, _visible:true, _loadedListeners:new Array(), _installingListeners:new Array(), setSwf:function (fileInfo) {
+ if (fileInfo == null || dojo.lang.isUndefined(fileInfo)) {
+ return;
+ }
+ if (fileInfo.flash6 != null && !dojo.lang.isUndefined(fileInfo.flash6)) {
+ this.flash6_version = fileInfo.flash6;
+ }
+ if (fileInfo.flash8 != null && !dojo.lang.isUndefined(fileInfo.flash8)) {
+ this.flash8_version = fileInfo.flash8;
+ }
+ if (!dojo.lang.isUndefined(fileInfo.visible)) {
+ this._visible = fileInfo.visible;
+ }
+ this._initialize();
+}, useFlash6:function () {
+ if (this.flash6_version == null) {
+ return false;
+ } else {
+ if (this.flash6_version != null && dojo.flash.info.commVersion == 6) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}, useFlash8:function () {
+ if (this.flash8_version == null) {
+ return false;
+ } else {
+ if (this.flash8_version != null && dojo.flash.info.commVersion == 8) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}, addLoadedListener:function (listener) {
+ this._loadedListeners.push(listener);
+}, addInstallingListener:function (listener) {
+ this._installingListeners.push(listener);
+}, loaded:function () {
+ dojo.flash.ready = true;
+ if (dojo.flash._loadedListeners.length > 0) {
+ for (var i = 0; i < dojo.flash._loadedListeners.length; i++) {
+ dojo.flash._loadedListeners[i].call(null);
+ }
+ }
+}, installing:function () {
+ if (dojo.flash._installingListeners.length > 0) {
+ for (var i = 0; i < dojo.flash._installingListeners.length; i++) {
+ dojo.flash._installingListeners[i].call(null);
+ }
+ }
+}, _initialize:function () {
+ var installer = new dojo.flash.Install();
+ dojo.flash.installer = installer;
+ if (installer.needed() == true) {
+ installer.install();
+ } else {
+ dojo.flash.obj = new dojo.flash.Embed(this._visible);
+ dojo.flash.obj.write(dojo.flash.info.commVersion);
+ dojo.flash.comm = new dojo.flash.Communicator();
+ }
+}};
+dojo.flash.Info = function () {
+ if (dojo.render.html.ie) {
+ document.writeln("");
}
-
this._detectVersion();
this._detectCommunicationVersion();
-}
-
-dojo.flash.Info.prototype = {
- /** The full version string, such as "8r22". */
- version: -1,
-
- /**
- The major, minor, and revisions of the plugin. For example, if the
- plugin is 8r22, then the major version is 8, the minor version is 0,
- and the revision is 22.
- */
- versionMajor: -1,
- versionMinor: -1,
- versionRevision: -1,
-
- /** Whether this platform has Flash already installed. */
- capable: false,
-
- /**
- The major version number for how our Flash and JavaScript communicate.
- This can currently be the following values:
- 6 - We use a combination of the Flash plugin methods, such as SetVariable
- and TCallLabel, along with fscommands, to do communication.
- 8 - We use the ExternalInterface API.
- -1 - For some reason neither method is supported, and no communication
- is possible.
- */
- commVersion: 6,
-
- /** Set if we are in the middle of a Flash installation session. */
- installing: false,
-
- /**
- Asserts that this environment has the given major, minor, and revision
- numbers for the Flash player. Returns true if the player is equal
- or above the given version, false otherwise.
-
- Example: To test for Flash Player 7r14:
-
- dojo.flash.info.isVersionOrAbove(7, 0, 14)
- */
- isVersionOrAbove: function(reqMajorVer, reqMinorVer, reqVer){
- // make the revision a decimal (i.e. transform revision 14 into
- // 0.14
- reqVer = parseFloat("." + reqVer);
-
- if(this.versionMajor >= reqMajorVer && this.versionMinor >= reqMinorVer
- && this.versionRevision >= reqVer){
- return true;
- }else{
- return false;
+};
+dojo.flash.Info.prototype = {version:-1, versionMajor:-1, versionMinor:-1, versionRevision:-1, capable:false, commVersion:6, installing:false, isVersionOrAbove:function (reqMajorVer, reqMinorVer, reqVer) {
+ reqVer = parseFloat("." + reqVer);
+ if (this.versionMajor >= reqMajorVer && this.versionMinor >= reqMinorVer && this.versionRevision >= reqVer) {
+ return true;
+ } else {
+ return false;
+ }
+}, _detectVersion:function () {
+ var versionStr;
+ for (var testVersion = 25; testVersion > 0; testVersion--) {
+ if (dojo.render.html.ie) {
+ versionStr = VBGetSwfVer(testVersion);
+ } else {
+ versionStr = this._JSFlashInfo(testVersion);
}
- },
-
- _detectVersion: function(){
- var versionStr;
-
- // loop backwards through the versions until we find the newest version
- for(var testVersion = 25; testVersion > 0; testVersion--){
- if(dojo.render.html.ie){
- versionStr = VBGetSwfVer(testVersion);
- }else{
- versionStr = this._JSFlashInfo(testVersion);
- }
-
- if(versionStr == -1 ){
- this.capable = false;
- return;
- }else if(versionStr != 0){
+ if (versionStr == -1) {
+ this.capable = false;
+ return;
+ } else {
+ if (versionStr != 0) {
var versionArray;
- if(dojo.render.html.ie){
+ if (dojo.render.html.ie) {
var tempArray = versionStr.split(" ");
var tempString = tempArray[1];
versionArray = tempString.split(",");
- }else{
+ } else {
versionArray = versionStr.split(".");
}
-
this.versionMajor = versionArray[0];
this.versionMinor = versionArray[1];
this.versionRevision = versionArray[2];
-
- // 7.0r24 == 7.24
var versionString = this.versionMajor + "." + this.versionRevision;
this.version = parseFloat(versionString);
-
this.capable = true;
-
break;
}
}
- },
-
- /**
- JavaScript helper required to detect Flash Player PlugIn version
- information. Internet Explorer uses a corresponding Visual Basic
- version to interact with the Flash ActiveX control.
- */
- _JSFlashInfo: function(testVersion){
- // NS/Opera version >= 3 check for Flash plugin in plugin array
- if(navigator.plugins != null && navigator.plugins.length > 0){
- if(navigator.plugins["Shockwave Flash 2.0"] ||
- navigator.plugins["Shockwave Flash"]){
- var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
- var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
- var descArray = flashDescription.split(" ");
- var tempArrayMajor = descArray[2].split(".");
- var versionMajor = tempArrayMajor[0];
- var versionMinor = tempArrayMajor[1];
- if(descArray[3] != ""){
- var tempArrayMinor = descArray[3].split("r");
- }else{
- var tempArrayMinor = descArray[4].split("r");
- }
- var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
- var version = versionMajor + "." + versionMinor + "."
- + versionRevision;
-
- return version;
+ }
+}, _JSFlashInfo:function (testVersion) {
+ if (navigator.plugins != null && navigator.plugins.length > 0) {
+ if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
+ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+ var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+ var descArray = flashDescription.split(" ");
+ var tempArrayMajor = descArray[2].split(".");
+ var versionMajor = tempArrayMajor[0];
+ var versionMinor = tempArrayMajor[1];
+ if (descArray[3] != "") {
+ var tempArrayMinor = descArray[3].split("r");
+ } else {
+ var tempArrayMinor = descArray[4].split("r");
}
- }
-
- return -1;
- },
-
- /**
- Detects the mechanisms that should be used for Flash/JavaScript
- communication, setting 'commVersion' to either 6 or 8. If the value is
- 6, we use Flash Plugin 6+ features, such as GetVariable, TCallLabel,
- and fscommand, to do Flash/JavaScript communication; if the value is
- 8, we use the ExternalInterface API for communication.
- */
- _detectCommunicationVersion: function(){
- if(this.capable == false){
- this.commVersion = null;
- return;
- }
-
- // detect if the user has over-ridden the default flash version
- if (typeof djConfig["forceFlashComm"] != "undefined" &&
- typeof djConfig["forceFlashComm"] != null){
- this.commVersion = djConfig["forceFlashComm"];
- return;
- }
-
- // we prefer Flash 6 features over Flash 8, because they are much faster
- // and much less buggy
-
- // at this point, we don't have a flash file to detect features on,
- // so we need to instead look at the browser environment we are in
- if(dojo.render.html.safari == true || dojo.render.html.opera == true){
- this.commVersion = 8;
- }else{
- this.commVersion = 6;
+ var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
+ var version = versionMajor + "." + versionMinor + "." + versionRevision;
+ return version;
}
}
-};
-
-/** A class that is used to write out the Flash object into the page. */
-dojo.flash.Embed = function(visible){
+ return -1;
+}, _detectCommunicationVersion:function () {
+ if (this.capable == false) {
+ this.commVersion = null;
+ return;
+ }
+ if (typeof djConfig["forceFlashComm"] != "undefined" && typeof djConfig["forceFlashComm"] != null) {
+ this.commVersion = djConfig["forceFlashComm"];
+ return;
+ }
+ if (dojo.render.html.safari == true || dojo.render.html.opera == true) {
+ this.commVersion = 8;
+ } else {
+ this.commVersion = 6;
+ }
+}};
+dojo.flash.Embed = function (visible) {
this._visible = visible;
-}
-
-dojo.flash.Embed.prototype = {
- /**
- The width of this Flash applet. The default is the minimal width
- necessary to show the Flash settings dialog.
- */
- width: 215,
-
- /**
- The height of this Flash applet. The default is the minimal height
- necessary to show the Flash settings dialog.
- */
- height: 138,
-
- /** The id of the Flash object. */
- id: "flashObject",
-
- /** Controls whether this is a visible Flash applet or not. */
- _visible: true,
-
- protocol: function(){
- switch(window.location.protocol){
- case "https:":
- return "https";
- break;
- default:
- return "http";
- break;
+};
+dojo.flash.Embed.prototype = {width:215, height:138, id:"flashObject", _visible:true, protocol:function () {
+ switch (window.location.protocol) {
+ case "https:":
+ return "https";
+ break;
+ default:
+ return "http";
+ break;
+ }
+}, write:function (flashVer, doExpressInstall) {
+ if (dojo.lang.isUndefined(doExpressInstall)) {
+ doExpressInstall = false;
+ }
+ var containerStyle = new dojo.string.Builder();
+ containerStyle.append("width: " + this.width + "px; ");
+ containerStyle.append("height: " + this.height + "px; ");
+ if (this._visible == false) {
+ containerStyle.append("position: absolute; ");
+ containerStyle.append("z-index: 10000; ");
+ containerStyle.append("top: -1000px; ");
+ containerStyle.append("left: -1000px; ");
+ }
+ containerStyle = containerStyle.toString();
+ var objectHTML;
+ var swfloc;
+ if (flashVer == 6) {
+ swfloc = dojo.flash.flash6_version;
+ var dojoPath = djConfig.baseRelativePath;
+ swfloc = swfloc + "?baseRelativePath=" + escape(dojoPath);
+ objectHTML = "