summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorwei <>2006-01-16 02:59:04 +0000
committerwei <>2006-01-16 02:59:04 +0000
commitce2b2803b78379a2bfca2849a5d5f8933a1634ea (patch)
treecc79e490dcdec6bc14e5c703f273f299fcfc2982 /framework
parentca47a8c7fd5eb9f34ac00a2f1a843859d6123dd8 (diff)
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/Javascripts/extended/base.js1
-rw-r--r--framework/Web/Javascripts/extended/date.js147
-rw-r--r--framework/Web/Javascripts/extended/dom.js232
-rw-r--r--framework/Web/Javascripts/extended/string.js63
-rw-r--r--framework/Web/Javascripts/extended/util.js94
-rw-r--r--framework/Web/Javascripts/extra/json.js340
-rw-r--r--framework/Web/Javascripts/prado/activecontrols.js196
-rw-r--r--framework/Web/Javascripts/prado/effects.js22
-rw-r--r--framework/Web/Javascripts/prado/element.js232
-rw-r--r--framework/Web/Javascripts/rico/extension.js175
-rw-r--r--framework/Web/Javascripts/rico/rico.js (renamed from framework/Web/Javascripts/effects/rico.js)0
11 files changed, 1175 insertions, 327 deletions
diff --git a/framework/Web/Javascripts/extended/base.js b/framework/Web/Javascripts/extended/base.js
index 59a3c3a0..d3d8fb63 100644
--- a/framework/Web/Javascripts/extended/base.js
+++ b/framework/Web/Javascripts/extended/base.js
@@ -32,3 +32,4 @@ Function.prototype.bindEvent = function() {
return __method.call(object, [event || window.event].concat(args));
}
}
+
diff --git a/framework/Web/Javascripts/extended/date.js b/framework/Web/Javascripts/extended/date.js
new file mode 100644
index 00000000..375c59df
--- /dev/null
+++ b/framework/Web/Javascripts/extended/date.js
@@ -0,0 +1,147 @@
+
+Object.extend(Date.prototype,
+{
+ SimpleFormat: function(format)
+ {
+ var bits = new Array();
+ bits['d'] = this.getDate();
+ bits['dd'] = Prado.Util.pad(this.getDate(),2);
+
+ bits['M'] = this.getMonth()+1;
+ bits['MM'] = Prado.Util.pad(this.getMonth()+1,2);
+
+ var yearStr = "" + this.getFullYear();
+ yearStr = (yearStr.length == 2) ? '19' + yearStr: yearStr;
+ bits['yyyy'] = yearStr;
+ bits['yy'] = bits['yyyy'].toString().substr(2,2);
+
+ // do some funky regexs to replace the format string
+ // with the real values
+ var frm = new String(format);
+ for (var sect in bits)
+ {
+ var reg = new RegExp("\\b"+sect+"\\b" ,"g");
+ frm = frm.replace(reg, bits[sect]);
+ }
+ return frm;
+ },
+
+ toISODate : function()
+ {
+ var y = this.getFullYear();
+ var m = Prado.Util.pad(this.getMonth() + 1);
+ var d = Prado.Util.pad(this.getDate());
+ return String(y) + String(m) + String(d);
+ }
+});
+
+Object.extend(Date,
+{
+ SimpleParse: function(value, format)
+ {
+ val=String(value);
+ format=String(format);
+
+ if(val.length <= 0) return null;
+
+ if(format.length <= 0) return new Date(value);
+
+ var isInteger = function (val)
+ {
+ var digits="1234567890";
+ for (var i=0; i < val.length; i++)
+ {
+ if (digits.indexOf(val.charAt(i))==-1) { return false; }
+ }
+ return true;
+ };
+
+ var getInt = function(str,i,minlength,maxlength)
+ {
+ for (var x=maxlength; x>=minlength; x--)
+ {
+ var token=str.substring(i,i+x);
+ if (token.length < minlength) { return null; }
+ if (isInteger(token)) { return token; }
+ }
+ return null;
+ };
+
+ var i_val=0;
+ var i_format=0;
+ var c="";
+ var token="";
+ var token2="";
+ var x,y;
+ var now=new Date();
+ var year=now.getFullYear();
+ var month=now.getMonth()+1;
+ var date=1;
+
+ while (i_format < format.length)
+ {
+ // Get next token from format string
+ c=format.charAt(i_format);
+ token="";
+ while ((format.charAt(i_format)==c) && (i_format < format.length))
+ {
+ token += format.charAt(i_format++);
+ }
+
+ // Extract contents of value based on format token
+ if (token=="yyyy" || token=="yy" || token=="y")
+ {
+ if (token=="yyyy") { x=4;y=4; }
+ if (token=="yy") { x=2;y=2; }
+ if (token=="y") { x=2;y=4; }
+ year=getInt(val,i_val,x,y);
+ if (year==null) { return null; }
+ i_val += year.length;
+ if (year.length==2)
+ {
+ if (year > 70) { year=1900+(year-0); }
+ else { year=2000+(year-0); }
+ }
+ }
+
+ else if (token=="MM"||token=="M")
+ {
+ month=getInt(val,i_val,token.length,2);
+ if(month==null||(month<1)||(month>12)){return null;}
+ i_val+=month.length;
+ }
+ else if (token=="dd"||token=="d")
+ {
+ date=getInt(val,i_val,token.length,2);
+ if(date==null||(date<1)||(date>31)){return null;}
+ i_val+=date.length;
+ }
+ else
+ {
+ if (val.substring(i_val,i_val+token.length)!=token) {return null;}
+ else {i_val+=token.length;}
+ }
+ }
+
+ // If there are any trailing characters left in the value, it doesn't match
+ if (i_val != val.length) { return null; }
+
+ // Is date valid for month?
+ if (month==2)
+ {
+ // Check for leap year
+ if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
+ if (date > 29){ return null; }
+ }
+ else { if (date > 28) { return null; } }
+ }
+
+ if ((month==4)||(month==6)||(month==9)||(month==11))
+ {
+ if (date > 30) { return null; }
+ }
+
+ var newdate=new Date(year,month-1,date, 0, 0, 0);
+ return newdate;
+ }
+}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/extended/dom.js b/framework/Web/Javascripts/extended/dom.js
index f29cf37d..21016b03 100644
--- a/framework/Web/Javascripts/extended/dom.js
+++ b/framework/Web/Javascripts/extended/dom.js
@@ -5,235 +5,3 @@ Object.extend(Element, {
}
});
-Prado.Element =
-{
- /**
- * Set the value of a particular element.
- * @param string element id
- * @param string new element value.
- */
- setValue : function(element, value)
- {
- var el = $(element);
- if(el && typeof(el.value) != "undefined")
- el.value = value;
- },
-
- select : function(element, method, value)
- {
- var el = $(element);
- var isList = element.indexOf('[]') > -1;
- if(!el && !isList) return;
- method = isList ? 'check'+method : el.tagName.toLowerCase()+method;
- var selection = Prado.Element.Selection;
- if(isFunction(selection[method]))
- selection[method](isList ? element : el,value);
- },
-
- click : function(element)
- {
- var el = $(element);
- //Logger.info(el);
- if(!el) return;
- if(document.createEvent)
- {
- var evt = document.createEvent('HTMLEvents');
- evt.initEvent('click', true, true);
- el.dispatchEvent(evt);
- //Logger.warn("dispatching click for "+el.id);
- }
- else if(el.fireEvent)
- {
- el.fireEvent('onclick');
- if(isFunction(el.onclick))
- el.onclick();
- }
- },
-
- setAttribute : function(element, attribute, value)
- {
- var el = $(element);
- if(attribute == "disabled" && value==false)
- el.removeAttribute(attribute);
- else
- el.setAttribute(attribute, value);
- },
-
- setOptions : function(element, options)
- {
- var el = $(element);
- if(el && el.tagName.toLowerCase() == "select")
- {
- while(el.length > 0)
- el.remove(0);
- for(var i = 0; i<options.length; i++)
- el.options[el.options.length] = new Option(options[i][0],options[i][1]);
- }
- },
-/**
- * A delayed focus on a particular element
- * @param {element} element to apply focus()
- */
- focus : function(element)
- {
- var obj = $(element);
- if(isObject(obj) && isdef(obj.focus))
- setTimeout(function(){ obj.focus(); }, 100);
- return false;
- }
-}
-
-Prado.Element.Selection =
-{
- inputValue : function(el, value)
- {
- switch(el.type.toLowerCase())
- {
- case 'checkbox':
- case 'radio':
- return el.checked = value;
- }
- },
-
- selectValue : function(el, value)
- {
- $A(el.options).each(function(option)
- {
- option.selected = option.value == value;
- });
- },
-
- selectIndex : function(el, index)
- {
- if(el.type == 'select-one')
- el.selectedIndex = index;
- else
- {
- for(var i = 0; i<el.length; i++)
- {
- if(i == index)
- el.options[i].selected = true;
- }
- }
- },
-
- selectClear : function(el)
- {
- el.selectedIndex = -1;
- },
-
- selectAll : function(el)
- {
- $A(el.options).each(function(option)
- {
- option.selected = true;
- Logger.warn(option.value);
- });
- },
-
- selectInvert : function(el)
- {
- $A(el.options).each(function(option)
- {
- option.selected = !option.selected;
- });
- },
-
- checkValue : function(name, value)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = el.value == value
- });
- },
-
- checkIndex : function(name, index)
- {
- var elements = $A(document.getElementsByName(name));
- for(var i = 0; i<elements.length; i++)
- {
- if(i == index)
- elements[i].checked = true;
- }
- },
-
- checkClear : function(name)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = false;
- });
- },
-
- checkAll : function(name)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = true;
- });
- },
- checkInvert : function(name)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = !el.checked;
- });
- }
-};
-
-
-/**
- * Alias some of the prototype functions.
- * Insert a html fragment relative to an element.
- */
-Object.extend(Prado.Element,
-{
- /**
- *
- */
- Insert :
- {
- /**
- * Insert directly after the element.
- */
- After : function(element, innerHTML)
- {
- new Insertion.After(element, innerHTML);
- },
-
- /**
- * Insert directly after the element
- */
- Before : function(element, innerHTML)
- {
- new Insertion.Before(element. innerHTML);
- },
-
- /**
- * Insert below the element container.
- */
- Below : function(element, innerHTML)
- {
- new Insertion.Bottom(element, innerHTML);
- },
-
- /**
- * Insert above the element container.
- */
- Above : function(element, innerHTML)
- {
- new Insertion.Top(element, innerHTML);
- }
- },
- CssClass :
- {
- /**
- * Set the css class name of an element.
- */
- set : function(element, cssClass)
- {
- element = new Element.ClassNames(element);
- element.set(cssClass);
- }
- }
-}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/extended/string.js b/framework/Web/Javascripts/extended/string.js
index fe586cfb..9b4c501b 100644
--- a/framework/Web/Javascripts/extended/string.js
+++ b/framework/Web/Javascripts/extended/string.js
@@ -57,6 +57,67 @@ Object.extend(String.prototype, {
Logger.error("Missing function", this);
return Prototype.emptyFunction;
}
- }
+ },
+
+ /**
+ * Convert a string into integer, returns null if not integer.
+ * @return {integer|null} null if string does not represent an integer.
+ */
+ toInteger : function()
+ {
+ var exp = /^\s*[-\+]?\d+\s*$/;
+ if (this.match(exp) == null)
+ return null;
+ var num = parseInt(this, 10);
+ return (isNaN(num) ? null : num);
+ },
+ /**
+ * Convert a string into a double/float value. <b>Internationalization
+ * is not supported</b>
+ * @param {string} the decimal character
+ * @return {float|null} null if string does not represent a float value
+ */
+ toDouble : function(decimalchar)
+ {
+ decimalchar = decimalchar || ".";
+ var exp = new RegExp("^\\s*([-\\+])?(\\d+)?(\\" + decimalchar + "(\\d+))?\\s*$");
+ var m = this.match(exp);
+ if (m == null)
+ return null;
+ var cleanInput = m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4];
+ var num = parseFloat(cleanInput);
+ return (isNaN(num) ? null : num);
+ },
+
+ /**
+ * Convert strings that represent a currency value (e.g. a float with grouping
+ * characters) to float. E.g. "10,000.50" will become "10000.50". The number
+ * of dicimal digits, grouping and decimal characters can be specified.
+ * <i>The currency input format is <b>very</b> strict, null will be returned if
+ * the pattern does not match</i>.
+ * @param {string} the grouping character, default is ","
+ * @param {int} number of decimal digits
+ * @param {string} the decimal character, default is "."
+ * @type {float|null} the currency value as float.
+ */
+ toCurrency : function(groupchar, digits, decimalchar)
+ {
+ groupchar = groupchar || ",";
+ decimalchar = decimalchar || ".";
+ digits = typeof(digits) == "undefined" ? 2 : digits;
+
+ var exp = new RegExp("^\\s*([-\\+])?(((\\d+)\\" + groupchar + ")*)(\\d+)"
+ + ((digits > 0) ? "(\\" + decimalchar + "(\\d{1," + digits + "}))?" : "")
+ + "\\s*$");
+ var m = this.match(exp);
+ if (m == null)
+ return null;
+ var intermed = m[2] + m[5] ;
+ var cleanInput = m[1] + intermed.replace(
+ new RegExp("(\\" + groupchar + ")", "g"), "")
+ + ((digits > 0) ? "." + m[7] : "");
+ var num = parseFloat(cleanInput);
+ return (isNaN(num) ? null : num);
+ }
});
diff --git a/framework/Web/Javascripts/extended/util.js b/framework/Web/Javascripts/extended/util.js
index 7cc836f4..73a27992 100644
--- a/framework/Web/Javascripts/extended/util.js
+++ b/framework/Web/Javascripts/extended/util.js
@@ -89,97 +89,3 @@ function isElement(o, strict) {
function isList(o) { return o && isObject(o) && (isArray(o) || o.item) }
-if(!Prado) var Prado = {};
-
-Prado.Util = {}
-
-/**
- * Pad a number with zeros from the left.
- * @param integer number
- * @param integer total string length
- * @return string zero padded number
- */
-Prado.Util.pad = function(number, X)
-{
- X = (!X ? 2 : X);
- number = ""+number;
- while (number.length < X)
- number = "0" + number;
- return number;
-}
-
-/**
- * Convert a string into integer, returns null if not integer.
- * @param {string} the string to convert to integer
- * @type {integer|null} null if string does not represent an integer.
- */
-Prado.Util.toInteger = function(value)
-{
- var exp = /^\s*[-\+]?\d+\s*$/;
- if (value.match(exp) == null)
- return null;
- var num = parseInt(value, 10);
- return (isNaN(num) ? null : num);
-}
-
-/**
- * Convert a string into a double/float value. <b>Internationalization
- * is not supported</b>
- * @param {string} the string to convert to double/float
- * @param {string} the decimal character
- * @return {float|null} null if string does not represent a float value
- */
-Prado.Util.toDouble = function(value, decimalchar)
-{
- decimalchar = undef(decimalchar) ? "." : decimalchar;
- var exp = new RegExp("^\\s*([-\\+])?(\\d+)?(\\" + decimalchar + "(\\d+))?\\s*$");
- var m = value.match(exp);
- if (m == null)
- return null;
- var cleanInput = m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4];
- var num = parseFloat(cleanInput);
- return (isNaN(num) ? null : num);
-}
-
-/**
- * Convert strings that represent a currency value (e.g. a float with grouping
- * characters) to float. E.g. "10,000.50" will become "10000.50". The number
- * of dicimal digits, grouping and decimal characters can be specified.
- * <i>The currency input format is <b>very</b> strict, null will be returned if
- * the pattern does not match</i>.
- * @param {string} the currency value
- * @param {string} the grouping character, default is ","
- * @param {int} number of decimal digits
- * @param {string} the decimal character, default is "."
- * @type {float|null} the currency value as float.
- */
-Prado.Util.toCurrency = function(value, groupchar, digits, decimalchar)
-{
- groupchar = undef(groupchar) ? "," : groupchar;
- decimalchar = undef(decimalchar) ? "." : decimalchar;
- digits = undef(digits) ? 2 : digits;
-
- var exp = new RegExp("^\\s*([-\\+])?(((\\d+)\\" + groupchar + ")*)(\\d+)"
- + ((digits > 0) ? "(\\" + decimalchar + "(\\d{1," + digits + "}))?" : "")
- + "\\s*$");
- var m = value.match(exp);
- if (m == null)
- return null;
- var intermed = m[2] + m[5] ;
- var cleanInput = m[1] + intermed.replace(
- new RegExp("(\\" + groupchar + ")", "g"), "")
- + ((digits > 0) ? "." + m[7] : "");
- var num = parseFloat(cleanInput);
- return (isNaN(num) ? null : num);
-}
-
-/**
- * Trim the value, if the value is undefined, empty string is return.
- * @param {string} string to be trimmed.
- * @type {string} trimmed string.
- */
-Prado.Util.trim = function(value)
-{
- if(!isString(value)) return "";
- return value.replace(/^\s+|\s+$/g, "");
-}
diff --git a/framework/Web/Javascripts/extra/json.js b/framework/Web/Javascripts/extra/json.js
new file mode 100644
index 00000000..0981169d
--- /dev/null
+++ b/framework/Web/Javascripts/extra/json.js
@@ -0,0 +1,340 @@
+/*
+Copyright (c) 2005 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+Array.prototype.______array = '______array';
+
+Prado.AJAX.JSON = {
+ org: 'http://www.JSON.org',
+ copyright: '(c)2005 JSON.org',
+ license: 'http://www.crockford.com/JSON/license.html',
+
+ stringify: function (arg) {
+ var c, i, l, s = '', v;
+
+ switch (typeof arg) {
+ case 'object':
+ if (arg) {
+ if (arg.______array == '______array') {
+ for (i = 0; i < arg.length; ++i) {
+ v = this.stringify(arg[i]);
+ if (s) {
+ s += ',';
+ }
+ s += v;
+ }
+ return '[' + s + ']';
+ } else if (typeof arg.toString != 'undefined') {
+ for (i in arg) {
+ v = arg[i];
+ if (typeof v != 'undefined' && typeof v != 'function') {
+ v = this.stringify(v);
+ if (s) {
+ s += ',';
+ }
+ s += this.stringify(i) + ':' + v;
+ }
+ }
+ return '{' + s + '}';
+ }
+ }
+ return 'null';
+ case 'number':
+ return isFinite(arg) ? String(arg) : 'null';
+ case 'string':
+ l = arg.length;
+ s = '"';
+ for (i = 0; i < l; i += 1) {
+ c = arg.charAt(i);
+ if (c >= ' ') {
+ if (c == '\\' || c == '"') {
+ s += '\\';
+ }
+ s += c;
+ } else {
+ switch (c) {
+ case '\b':
+ s += '\\b';
+ break;
+ case '\f':
+ s += '\\f';
+ break;
+ case '\n':
+ s += '\\n';
+ break;
+ case '\r':
+ s += '\\r';
+ break;
+ case '\t':
+ s += '\\t';
+ break;
+ default:
+ c = c.charCodeAt();
+ s += '\\u00' + Math.floor(c / 16).toString(16) +
+ (c % 16).toString(16);
+ }
+ }
+ }
+ return s + '"';
+ case 'boolean':
+ return String(arg);
+ default:
+ return 'null';
+ }
+ },
+ parse: function (text) {
+ var at = 0;
+ var ch = ' ';
+
+ function error(m) {
+ throw {
+ name: 'JSONError',
+ message: m,
+ at: at - 1,
+ text: text
+ };
+ }
+
+ function next() {
+ ch = text.charAt(at);
+ at += 1;
+ return ch;
+ }
+
+ function white() {
+ while (ch) {
+ if (ch <= ' ') {
+ next();
+ } else if (ch == '/') {
+ switch (next()) {
+ case '/':
+ while (next() && ch != '\n' && ch != '\r') {}
+ break;
+ case '*':
+ next();
+ for (;;) {
+ if (ch) {
+ if (ch == '*') {
+ if (next() == '/') {
+ next();
+ break;
+ }
+ } else {
+ next();
+ }
+ } else {
+ error("Unterminated comment");
+ }
+ }
+ break;
+ default:
+ error("Syntax error");
+ }
+ } else {
+ break;
+ }
+ }
+ }
+
+ function string() {
+ var i, s = '', t, u;
+
+ if (ch == '"') {
+outer: while (next()) {
+ if (ch == '"') {
+ next();
+ return s;
+ } else if (ch == '\\') {
+ switch (next()) {
+ case 'b':
+ s += '\b';
+ break;
+ case 'f':
+ s += '\f';
+ break;
+ case 'n':
+ s += '\n';
+ break;
+ case 'r':
+ s += '\r';
+ break;
+ case 't':
+ s += '\t';
+ break;
+ case 'u':
+ u = 0;
+ for (i = 0; i < 4; i += 1) {
+ t = parseInt(next(), 16);
+ if (!isFinite(t)) {
+ break outer;
+ }
+ u = u * 16 + t;
+ }
+ s += String.fromCharCode(u);
+ break;
+ default:
+ s += ch;
+ }
+ } else {
+ s += ch;
+ }
+ }
+ }
+ error("Bad string");
+ }
+
+ function array() {
+ var a = [];
+
+ if (ch == '[') {
+ next();
+ white();
+ if (ch == ']') {
+ next();
+ return a;
+ }
+ while (ch) {
+ a.push(value());
+ white();
+ if (ch == ']') {
+ next();
+ return a;
+ } else if (ch != ',') {
+ break;
+ }
+ next();
+ white();
+ }
+ }
+ error("Bad array");
+ }
+
+ function object() {
+ var k, o = {};
+
+ if (ch == '{') {
+ next();
+ white();
+ if (ch == '}') {
+ next();
+ return o;
+ }
+ while (ch) {
+ k = string();
+ white();
+ if (ch != ':') {
+ break;
+ }
+ next();
+ o[k] = value();
+ white();
+ if (ch == '}') {
+ next();
+ return o;
+ } else if (ch != ',') {
+ break;
+ }
+ next();
+ white();
+ }
+ }
+ error("Bad object");
+ }
+
+ function number() {
+ var n = '', v;
+ if (ch == '-') {
+ n = '-';
+ next();
+ }
+ while (ch >= '0' && ch <= '9') {
+ n += ch;
+ next();
+ }
+ if (ch == '.') {
+ n += '.';
+ while (next() && ch >= '0' && ch <= '9') {
+ n += ch;
+ }
+ }
+ if (ch == 'e' || ch == 'E') {
+ n += 'e';
+ next();
+ if (ch == '-' || ch == '+') {
+ n += ch;
+ next();
+ }
+ while (ch >= '0' && ch <= '9') {
+ n += ch;
+ next();
+ }
+ }
+ v = +n;
+ if (!isFinite(v)) {
+ ////error("Bad number");
+ } else {
+ return v;
+ }
+ }
+
+ function word() {
+ switch (ch) {
+ case 't':
+ if (next() == 'r' && next() == 'u' && next() == 'e') {
+ next();
+ return true;
+ }
+ break;
+ case 'f':
+ if (next() == 'a' && next() == 'l' && next() == 's' &&
+ next() == 'e') {
+ next();
+ return false;
+ }
+ break;
+ case 'n':
+ if (next() == 'u' && next() == 'l' && next() == 'l') {
+ next();
+ return null;
+ }
+ break;
+ }
+ error("Syntax error");
+ }
+
+ function value() {
+ white();
+ switch (ch) {
+ case '{':
+ return object();
+ case '[':
+ return array();
+ case '"':
+ return string();
+ case '-':
+ return number();
+ default:
+ return ch >= '0' && ch <= '9' ? number() : word();
+ }
+ }
+
+ return value();
+ }
+}; \ No newline at end of file
diff --git a/framework/Web/Javascripts/prado/activecontrols.js b/framework/Web/Javascripts/prado/activecontrols.js
new file mode 100644
index 00000000..72f97511
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activecontrols.js
@@ -0,0 +1,196 @@
+/**
+ * Auto complete textbox via AJAX.
+ */
+Prado.AutoCompleter = Class.create();
+
+
+/**
+ * Overrides parent implementation of updateElement by trimming the value.
+ */
+Prado.AutoCompleter.Base = function(){};
+Prado.AutoCompleter.Base.prototype = Object.extend(Autocompleter.Base.prototype,
+{
+ updateElement: function(selectedElement)
+ {
+ if (this.options.updateElement) {
+ this.options.updateElement(selectedElement);
+ return;
+ }
+
+ var value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
+ var lastTokenPos = this.findLastToken();
+ if (lastTokenPos != -1) {
+ var newValue = this.element.value.substr(0, lastTokenPos + 1);
+ var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
+ if (whitespace)
+ newValue += whitespace[0];
+ this.element.value = (newValue + value).trim();
+ } else {
+ this.element.value = value.trim();
+ }
+ this.element.focus();
+
+ if (this.options.afterUpdateElement)
+ this.options.afterUpdateElement(this.element, selectedElement);
+ }
+});
+
+/**
+ * Based on the Prototype Autocompleter class.
+ * This client-side component should be instantiated from a Prado component.
+ * Usage: <t>new Prado.AutoCompleter('textboxID', 'updateDivID', {callbackID : '...'});
+ */
+Prado.AutoCompleter.prototype = Object.extend(new Autocompleter.Base(),
+{
+ /**
+ * This component is initialized by
+ * <code>new Prado.AutoCompleter(...)</code>
+ * @param string the ID of the textbox element to observe
+ * @param string the ID of the div to display the auto-complete options
+ * @param array a hash of options, e.g. auto-completion token separator.
+ */
+ initialize : function(element, update, options)
+ {
+ this.baseInitialize(element, update, options);
+ },
+
+ /**
+ * The callback function, i.e., function called on successful AJAX return.
+ * Calls update choices in the Autocompleter.
+ * @param string new auto-complete options for display
+ */
+ onUpdateReturn : function(result)
+ {
+ if(isString(result) && result.length > 0)
+ this.updateChoices(result);
+ },
+
+ /**
+ * Requesting new choices using Prado's client-side callback scheme.
+ */
+ getUpdatedChoices : function()
+ {
+ Prado.Callback(this.element.id, this.getToken(), this.onUpdateReturn.bind(this));
+ }
+});
+
+/**
+ * Prado TActivePanel client javascript. Usage
+ * <code>
+ * Prado.ActivePanel.register("id", options);
+ * Prado.ActivePanel.update("id", "hello");
+ * </code>
+ */
+Prado.ActivePanel =
+{
+ callbacks : {},
+
+ register : function(id, options)
+ {
+ Prado.ActivePanel.callbacks[id] = options;
+ },
+
+ update : function(id, param)
+ {
+ var request = new Prado.ActivePanel.Request(id,
+ Prado.ActivePanel.callbacks[id]);
+ request.callback(param);
+ }
+}
+
+/**
+ * Client-script for TActivePanel. Uses Callback to notify the server
+ * for updates, if update option is set, the innerHTML of the update ID
+ * is set to the returned output.
+ */
+Prado.ActivePanel.Request = Class.create();
+Prado.ActivePanel.Request.prototype =
+{
+ initialize : function(element, options)
+ {
+ this.element = element;
+ this.setOptions(options);
+ },
+
+ /**
+ * Set some options.
+ */
+ setOptions : function(options)
+ {
+ this.options =
+ {
+ onSuccess : this.onSuccess.bind(this)
+ }
+ Object.extend(this.options, options || {});
+ },
+
+ /**
+ * Make the callback request
+ */
+ callback : function(param)
+ {
+ this.options.params = [param];
+ new Prado.AJAX.Callback(this.element, this.options);
+ },
+
+ /**
+ * Callback onSuccess handler, update the element innerHTML if necessary
+ */
+ onSuccess : function(result, output)
+ {
+ if(this.options.update)
+ {
+ if (!this.options.evalScripts)
+ output = output.stripScripts();
+ Element.update(this.options.update, output);
+ }
+ }
+}
+
+/**
+ * Drop container to accept draggable component drops.
+ */
+Prado.DropContainer = Class.create();
+Prado.DropContainer.prototype = Object.extend(new Prado.ActivePanel.Request(),
+{
+ initialize : function(element, options)
+ {
+ this.element = element;
+ this.setOptions(options);
+ Object.extend(this.options,
+ {
+ onDrop : this.onDrop.bind(this),
+ evalScripts : true,
+ onSuccess : options.onSuccess || this.onSuccess.bind(this)
+ });
+ Droppables.add(element, this.options);
+ },
+
+ onDrop : function(draggable, droppable)
+ {
+ this.callback(draggable.id)
+ }
+});
+
+Prado.ActiveImageButton = Class.create();
+Prado.ActiveImageButton.prototype =
+{
+ initialize : function(element, options)
+ {
+ this.element = $(element);
+ this.options = options;
+ Event.observe(this.element, "click", this.click.bind(this));
+ },
+
+ click : function(e)
+ {
+ var el = $('{$this->ClientID}');
+ var imagePos = Position.cumulativeOffset(this.element);
+ var clickedPos = [e.clientX, e.clientY];
+ var param = (clickedPos[0]-imagePos[0]+1)+","+(clickedPos[1]-imagePos[1]+1);
+ Prado.Callback(this.element, param, null, this.options);
+ Event.stop(e);
+ }
+}
+
+
diff --git a/framework/Web/Javascripts/prado/effects.js b/framework/Web/Javascripts/prado/effects.js
new file mode 100644
index 00000000..cc31d00e
--- /dev/null
+++ b/framework/Web/Javascripts/prado/effects.js
@@ -0,0 +1,22 @@
+Prado.Effect =
+{
+ Highlight : function(element, duration)
+ {
+ new Effect.Highlight(element, {'duration':duration});
+ },
+
+ Scale : function(element, percent)
+ {
+ new Effect.Scale(element, percent);
+ },
+
+ MoveBy : function(element, toTop, toLeft)
+ {
+ new Effect.MoveBy(element, toTop, toLeft);
+ },
+
+ ScrollTo : function(element, duration)
+ {
+ new Effect.ScrollTo(element, {'duration':duration});
+ }
+} \ No newline at end of file
diff --git a/framework/Web/Javascripts/prado/element.js b/framework/Web/Javascripts/prado/element.js
new file mode 100644
index 00000000..163a7d6e
--- /dev/null
+++ b/framework/Web/Javascripts/prado/element.js
@@ -0,0 +1,232 @@
+Prado.Element =
+{
+ /**
+ * Set the value of a particular element.
+ * @param string element id
+ * @param string new element value.
+ */
+ setValue : function(element, value)
+ {
+ var el = $(element);
+ if(el && typeof(el.value) != "undefined")
+ el.value = value;
+ },
+
+ select : function(element, method, value)
+ {
+ var el = $(element);
+ var isList = element.indexOf('[]') > -1;
+ if(!el && !isList) return;
+ method = isList ? 'check'+method : el.tagName.toLowerCase()+method;
+ var selection = Prado.Element.Selection;
+ if(isFunction(selection[method]))
+ selection[method](isList ? element : el,value);
+ },
+
+ click : function(element)
+ {
+ var el = $(element);
+ //Logger.info(el);
+ if(!el) return;
+ if(document.createEvent)
+ {
+ var evt = document.createEvent('HTMLEvents');
+ evt.initEvent('click', true, true);
+ el.dispatchEvent(evt);
+ //Logger.warn("dispatching click for "+el.id);
+ }
+ else if(el.fireEvent)
+ {
+ el.fireEvent('onclick');
+ if(isFunction(el.onclick))
+ el.onclick();
+ }
+ },
+
+ setAttribute : function(element, attribute, value)
+ {
+ var el = $(element);
+ if(attribute == "disabled" && value==false)
+ el.removeAttribute(attribute);
+ else
+ el.setAttribute(attribute, value);
+ },
+
+ setOptions : function(element, options)
+ {
+ var el = $(element);
+ if(el && el.tagName.toLowerCase() == "select")
+ {
+ while(el.length > 0)
+ el.remove(0);
+ for(var i = 0; i<options.length; i++)
+ el.options[el.options.length] = new Option(options[i][0],options[i][1]);
+ }
+ },
+/**
+ * A delayed focus on a particular element
+ * @param {element} element to apply focus()
+ */
+ focus : function(element)
+ {
+ var obj = $(element);
+ if(isObject(obj) && isdef(obj.focus))
+ setTimeout(function(){ obj.focus(); }, 100);
+ return false;
+ }
+}
+
+Prado.Element.Selection =
+{
+ inputValue : function(el, value)
+ {
+ switch(el.type.toLowerCase())
+ {
+ case 'checkbox':
+ case 'radio':
+ return el.checked = value;
+ }
+ },
+
+ selectValue : function(el, value)
+ {
+ $A(el.options).each(function(option)
+ {
+ option.selected = option.value == value;
+ });
+ },
+
+ selectIndex : function(el, index)
+ {
+ if(el.type == 'select-one')
+ el.selectedIndex = index;
+ else
+ {
+ for(var i = 0; i<el.length; i++)
+ {
+ if(i == index)
+ el.options[i].selected = true;
+ }
+ }
+ },
+
+ selectClear : function(el)
+ {
+ el.selectedIndex = -1;
+ },
+
+ selectAll : function(el)
+ {
+ $A(el.options).each(function(option)
+ {
+ option.selected = true;
+ Logger.warn(option.value);
+ });
+ },
+
+ selectInvert : function(el)
+ {
+ $A(el.options).each(function(option)
+ {
+ option.selected = !option.selected;
+ });
+ },
+
+ checkValue : function(name, value)
+ {
+ $A(document.getElementsByName(name)).each(function(el)
+ {
+ el.checked = el.value == value
+ });
+ },
+
+ checkIndex : function(name, index)
+ {
+ var elements = $A(document.getElementsByName(name));
+ for(var i = 0; i<elements.length; i++)
+ {
+ if(i == index)
+ elements[i].checked = true;
+ }
+ },
+
+ checkClear : function(name)
+ {
+ $A(document.getElementsByName(name)).each(function(el)
+ {
+ el.checked = false;
+ });
+ },
+
+ checkAll : function(name)
+ {
+ $A(document.getElementsByName(name)).each(function(el)
+ {
+ el.checked = true;
+ });
+ },
+ checkInvert : function(name)
+ {
+ $A(document.getElementsByName(name)).each(function(el)
+ {
+ el.checked = !el.checked;
+ });
+ }
+};
+
+
+/**
+ * Alias some of the prototype functions.
+ * Insert a html fragment relative to an element.
+ */
+Object.extend(Prado.Element,
+{
+ /**
+ *
+ */
+ Insert :
+ {
+ /**
+ * Insert directly after the element.
+ */
+ After : function(element, innerHTML)
+ {
+ new Insertion.After(element, innerHTML);
+ },
+
+ /**
+ * Insert directly after the element
+ */
+ Before : function(element, innerHTML)
+ {
+ new Insertion.Before(element. innerHTML);
+ },
+
+ /**
+ * Insert below the element container.
+ */
+ Below : function(element, innerHTML)
+ {
+ new Insertion.Bottom(element, innerHTML);
+ },
+
+ /**
+ * Insert above the element container.
+ */
+ Above : function(element, innerHTML)
+ {
+ new Insertion.Top(element, innerHTML);
+ }
+ },
+ CssClass :
+ {
+ /**
+ * Set the css class name of an element.
+ */
+ set : function(element, cssClass)
+ {
+ element = new Element.ClassNames(element);
+ element.set(cssClass);
+ }
+ }
+}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/rico/extension.js b/framework/Web/Javascripts/rico/extension.js
new file mode 100644
index 00000000..d3df3a9b
--- /dev/null
+++ b/framework/Web/Javascripts/rico/extension.js
@@ -0,0 +1,175 @@
+Prado.RicoLiveGrid = Class.create();
+Prado.RicoLiveGrid.prototype = Object.extend(Rico.LiveGrid.prototype,
+{
+ initialize : function(tableId, options)
+ {
+ this.options = {
+ tableClass: $(tableId).className || '',
+ loadingClass: $(tableId).className || '',
+ scrollerBorderRight: '1px solid #ababab',
+ bufferTimeout: 20000,
+ sortAscendImg: 'images/sort_asc.gif',
+ sortDescendImg: 'images/sort_desc.gif',
+ sortImageWidth: 9,
+ sortImageHeight: 5,
+ ajaxSortURLParms: [],
+ onRefreshComplete: null,
+ requestParameters: null,
+ inlineStyles: true,
+ visibleRows: 10,
+ totalRows: 0,
+ initialOffset: 0
+ };
+ Object.extend(this.options, options || {});
+
+ //this.ajaxOptions = {parameters: null};
+ //Object.extend(this.ajaxOptions, ajaxOptions || {});
+
+ this.tableId = tableId;
+ this.table = $(tableId);
+
+ this.addLiveGridHtml();
+
+ var columnCount = this.table.rows[0].cells.length;
+ this.metaData = new Rico.LiveGridMetaData(this.options.visibleRows, this.options.totalRows, columnCount, options);
+ this.buffer = new Rico.LiveGridBuffer(this.metaData);
+
+ var rowCount = this.table.rows.length;
+ this.viewPort = new Rico.GridViewPort(this.table,
+ this.table.offsetHeight/rowCount,
+ this.options.visibleRows,
+ this.buffer, this);
+ this.scroller = new Rico.LiveGridScroller(this,this.viewPort);
+ this.options.sortHandler = this.sortHandler.bind(this);
+
+ if ( $(tableId + '_header') )
+ this.sort = new Rico.LiveGridSort(tableId + '_header', this.options)
+
+ this.processingRequest = null;
+ this.unprocessedRequest = null;
+
+ //this.initAjax(url);
+ if (this.options.initialOffset >= 0)
+ {
+ var offset = this.options.initialOffset;
+ this.scroller.moveScroll(offset);
+ this.viewPort.scrollTo(this.scroller.rowToPixel(offset));
+ if (this.options.sortCol) {
+ this.sortCol = options.sortCol;
+ this.sortDir = options.sortDir;
+ }
+ var grid = this;
+ setTimeout(function(){
+ grid.requestContentRefresh(offset);
+ },100);
+ }
+ },
+
+ fetchBuffer: function(offset)
+ {
+ if ( this.buffer.isInRange(offset) &&
+ !this.buffer.isNearingLimit(offset)) {
+ return;
+ }
+ if (this.processingRequest) {
+ this.unprocessedRequest = new Rico.LiveGridRequest(offset);
+ return;
+ }
+ var bufferStartPos = this.buffer.getFetchOffset(offset);
+ this.processingRequest = new Rico.LiveGridRequest(offset);
+ this.processingRequest.bufferOffset = bufferStartPos;
+ var fetchSize = this.buffer.getFetchSize(offset);
+ var partialLoaded = false;
+
+ // var queryString
+ // if (this.options.requestParameters)
+ // queryString = this._createQueryString(this.options.requestParameters, 0);
+ var param =
+ {
+ 'page_size' : fetchSize,
+ 'offset' : bufferStartPos
+ };
+ if(this.sortCol)
+ {
+ Object.extend(param,
+ {
+ 'sort_col': this.sortCol,
+ 'sort_dir': this.sortDir
+ });
+ }
+ /*queryString = (queryString == null) ? '' : queryString+'&';
+ queryString = queryString+'id='+this.tableId+'&page_size='+fetchSize+'&offset='+bufferStartPos;
+ if (this.sortCol)
+ queryString = queryString+'&sort_col='+escape(this.sortCol)+'&sort_dir='+this.sortDir;
+
+ this.ajaxOptions.parameters = queryString;
+
+ ajaxEngine.sendRequest( this.tableId + '_request', this.ajaxOptions );
+ */
+ Prado.Callback(this.tableId, param, this.ajaxUpdate.bind(this), this.options);
+ this.timeoutHandler = setTimeout( this.handleTimedOut.bind(this), this.options.bufferTimeout);
+
+ },
+
+ ajaxUpdate: function(result, output)
+ {
+ try {
+ clearTimeout( this.timeoutHandler );
+ this.buffer.update(result,this.processingRequest.bufferOffset);
+ this.viewPort.bufferChanged();
+ }
+ catch(err) {}
+ finally {this.processingRequest = null; }
+ this.processQueuedRequest();
+ }
+});
+
+Object.extend(Rico.LiveGridBuffer.prototype,
+{
+ update: function(newRows, start)
+ {
+ if (this.rows.length == 0) { // initial load
+ this.rows = newRows;
+ this.size = this.rows.length;
+ this.startPos = start;
+ return;
+ }
+ if (start > this.startPos) { //appending
+ if (this.startPos + this.rows.length < start) {
+ this.rows = newRows;
+ this.startPos = start;//
+ } else {
+ this.rows = this.rows.concat( newRows.slice(0, newRows.length));
+ if (this.rows.length > this.maxBufferSize) {
+ var fullSize = this.rows.length;
+ this.rows = this.rows.slice(this.rows.length - this.maxBufferSize, this.rows.length)
+ this.startPos = this.startPos + (fullSize - this.rows.length);
+ }
+ }
+ } else { //prepending
+ if (start + newRows.length < this.startPos) {
+ this.rows = newRows;
+ } else {
+ this.rows = newRows.slice(0, this.startPos).concat(this.rows);
+ if (this.rows.length > this.maxBufferSize)
+ this.rows = this.rows.slice(0, this.maxBufferSize)
+ }
+ this.startPos = start;
+ }
+ this.size = this.rows.length;
+ }
+});
+
+
+Object.extend(Rico.GridViewPort.prototype,
+{
+ populateRow: function(htmlRow, row)
+ {
+ if(isdef(htmlRow))
+ {
+ for (var j=0; j < row.length; j++) {
+ htmlRow.cells[j].innerHTML = row[j]
+ }
+ }
+ }
+}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/effects/rico.js b/framework/Web/Javascripts/rico/rico.js
index cd8f32e7..cd8f32e7 100644
--- a/framework/Web/Javascripts/effects/rico.js
+++ b/framework/Web/Javascripts/rico/rico.js