summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/js/debug/prado.js
diff options
context:
space:
mode:
authorwei <>2007-03-27 02:23:20 +0000
committerwei <>2007-03-27 02:23:20 +0000
commit1b9b64637fe08848f610bbd19b80c031cb7dba63 (patch)
tree52f7486e911f60c9a91904c91e3944f4f4f27bca /framework/Web/Javascripts/js/debug/prado.js
parentc5d0cd2824e3c3bb2f6f3834177a71c1d7b78519 (diff)
set prado trunk to use prototype.js v1.5.1rc2, script.aculo.us to v1.7.1beta
Diffstat (limited to 'framework/Web/Javascripts/js/debug/prado.js')
-rw-r--r--framework/Web/Javascripts/js/debug/prado.js280
1 files changed, 221 insertions, 59 deletions
diff --git a/framework/Web/Javascripts/js/debug/prado.js b/framework/Web/Javascripts/js/debug/prado.js
index 87622c93..1388135d 100644
--- a/framework/Web/Javascripts/js/debug/prado.js
+++ b/framework/Web/Javascripts/js/debug/prado.js
@@ -3215,9 +3215,9 @@ if (Prototype.Browser.WebKit) {
Element.addMethods();
-// script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
+// script.aculo.us builder.js v1.7.1_beta1, Mon Mar 12 14:40:50 +0100 2007
-// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
@@ -3265,7 +3265,8 @@ var Builder = {
// attributes (or text)
if(arguments[1])
if(this._isStringOrNumber(arguments[1]) ||
- (arguments[1] instanceof Array)) {
+ (arguments[1] instanceof Array) ||
+ arguments[1].tagName) {
this._children(element, arguments[1]);
} else {
var attrs = this._attributes(arguments[1]);
@@ -3283,7 +3284,7 @@ var Builder = {
}
if(element.tagName.toUpperCase() != elementName)
element = parentElement.getElementsByTagName(elementName)[0];
- }
+ }
}
// text, or array of children
@@ -3309,6 +3310,10 @@ var Builder = {
return attrs.join(" ");
},
_children: function(element, children) {
+ if(children.tagName) {
+ element.appendChild(children);
+ return;
+ }
if(typeof children=='object') { // array can hold nodes and text
children.flatten().each( function(e) {
if(typeof e=='object')
@@ -3318,8 +3323,8 @@ var Builder = {
element.appendChild(Builder._text(e));
});
} else
- if(Builder._isStringOrNumber(children))
- element.appendChild(Builder._text(children));
+ if(Builder._isStringOrNumber(children))
+ element.appendChild(Builder._text(children));
},
_isStringOrNumber: function(param) {
return(typeof param=='string' || typeof param=='number');
@@ -3584,9 +3589,6 @@ Prado.PostBack = function(event,options)
Event.fireEvent(form,"submit");
}
-/**
- * Additional element utilities.
- */
Prado.Element =
{
/**
@@ -3601,15 +3603,16 @@ Prado.Element =
el.value = value;
},
- select : function(element, method, value)
+ select : function(element, method, value, total)
{
var el = $(element);
- var isList = element.indexOf('[]') > -1;
- if(!el && !isList) return;
- method = isList ? 'check'+method : el.tagName.toLowerCase()+method;
+ if(!el) return;
var selection = Prado.Element.Selection;
- if(isFunction(selection[method]))
- selection[method](isList ? element : el,value);
+ if(typeof(selection[method]) == "function")
+ {
+ control = selection.isSelectable(el) ? [el] : selection.getListElements(element,total);
+ selection[method](control, value);
+ }
},
click : function(element)
@@ -3622,8 +3625,21 @@ Prado.Element =
setAttribute : function(element, attribute, value)
{
var el = $(element);
- if(attribute == "disabled" && value==false)
+ if(!el) return;
+ if((attribute == "disabled" || attribute == "multiple") && value==false)
el.removeAttribute(attribute);
+ else if(attribute.match(/^on/i)) //event methods
+ {
+ try
+ {
+ eval("(func = function(event){"+value+"})");
+ el[attribute] = func;
+ }
+ catch(e)
+ {
+ throw "Error in evaluating '"+value+"' for attribute "+attribute+" for element "+element.id;
+ }
+ }
else
el.setAttribute(attribute, value);
},
@@ -3631,12 +3647,12 @@ Prado.Element =
setOptions : function(element, options)
{
var el = $(element);
+ if(!el) return;
if(el && el.tagName.toLowerCase() == "select")
{
- while(el.length > 0)
- el.remove(0);
+ el.options.length = options.length;
for(var i = 0; i<options.length; i++)
- el.options[el.options.length] = new Option(options[i][0],options[i][1]);
+ el.options[i] = new Option(options[i][0],options[i][1]);
}
},
@@ -3650,14 +3666,62 @@ Prado.Element =
if(typeof(obj) != "undefined" && typeof(obj.focus) != "undefined")
setTimeout(function(){ obj.focus(); }, 100);
return false;
+ },
+
+ replace : function(element, method, content, boundary)
+ {
+ if(boundary)
+ {
+ result = Prado.Element.extractContent(this.transport.responseText, boundary);
+ if(result != null)
+ content = result;
+ }
+ if(typeof(element) == "string")
+ {
+ if($(element))
+ method.toFunction().apply(this,[element,""+content]);
+ }
+ else
+ {
+ method.toFunction().apply(this,[""+content]);
+ }
+ },
+
+ extractContent : function(text, boundary)
+ {
+ var f = RegExp('(<!--'+boundary+'-->)([\\s\\S\\w\\W]*)(<!--//'+boundary+'-->)',"m");
+ var result = text.match(f);
+ if(result && result.length >= 2)
+ return result[2];
+ else
+ return null;
+ },
+
+ evaluateScript : function(content)
+ {
+ content.evalScripts();
}
}
-/**
- * Selectable element utilities
- */
Prado.Element.Selection =
{
+ isSelectable : function(el)
+ {
+ if(el && el.type)
+ {
+ switch(el.type.toLowerCase())
+ {
+ case 'checkbox':
+ case 'radio':
+ case 'select':
+ case 'select-multiple':
+ case 'select-one':
+ return true;
+ }
+ }
+ return false;
+ },
+
inputValue : function(el, value)
{
switch(el.type.toLowerCase())
@@ -3668,61 +3732,125 @@ Prado.Element.Selection =
}
},
- selectValue : function(el, value)
+ selectValue : function(elements, value)
{
- $A(el.options).each(function(option)
+ elements.each(function(el)
{
- option.selected = option.value == value;
- });
+ $A(el.options).each(function(option)
+ {
+ if(typeof(value) == "boolean")
+ options.selected = value;
+ else if(option.value == value)
+ option.selected = true;
+ });
+ })
},
- selectIndex : function(el, index)
+ selectValues : function(elements, values)
{
- if(el.type == 'select-one')
- el.selectedIndex = index;
- else
+ selection = this;
+ values.each(function(value)
+ {
+ selection.selectValue(elements,value);
+ })
+ },
+
+ selectIndex : function(elements, index)
+ {
+ elements.each(function(el)
{
- for(var i = 0; i<el.length; i++)
+ if(el.type.toLowerCase() == 'select-one')
+ el.selectedIndex = index;
+ else
{
- if(i == index)
- el.options[i].selected = true;
+ for(var i = 0; i<el.length; i++)
+ {
+ if(i == index)
+ el.options[i].selected = true;
+ }
}
- }
+ })
},
- selectClear : function(el)
+ selectAll : function(elements)
{
- el.selectedIndex = -1;
+ elements.each(function(el)
+ {
+ if(el.type.toLowerCase() != 'select-one')
+ {
+ $A(el.options).each(function(option)
+ {
+ option.selected = true;
+ })
+ }
+ })
},
- selectAll : function(el)
+ selectInvert : function(elements)
{
- $A(el.options).each(function(option)
+ elements.each(function(el)
{
- option.selected = true;
- Logger.warn(option.value);
- });
+ if(el.type.toLowerCase() != 'select-one')
+ {
+ $A(el.options).each(function(option)
+ {
+ option.selected = !options.selected;
+ })
+ }
+ })
},
- selectInvert : function(el)
+ selectIndices : function(elements, indices)
{
- $A(el.options).each(function(option)
+ selection = this;
+ indices.each(function(index)
{
- option.selected = !option.selected;
- });
+ selection.selectIndex(elements,index);
+ })
+ },
+
+ selectClear : function(elements)
+ {
+ elements.each(function(el)
+ {
+ el.selectedIndex = -1;
+ })
+ },
+
+ getListElements : function(element, total)
+ {
+ elements = new Array();
+ for(i = 0; i < total; i++)
+ {
+ el = $(element+"_c"+i);
+ if(el)
+ elements.push(el);
+ }
+ return elements;
},
- checkValue : function(name, value)
+ checkValue : function(elements, value)
{
- $A(document.getElementsByName(name)).each(function(el)
+ elements.each(function(el)
{
- el.checked = el.value == value
+ if(typeof(value) == "boolean")
+ el.checked = value;
+ else if(el.value == value)
+ el.checked = true;
});
},
- checkIndex : function(name, index)
+ checkValues : function(elements, values)
+ {
+ selection = this;
+ values.each(function(value)
+ {
+ selection.checkValue(elements, value);
+ })
+ },
+
+ checkIndex : function(elements, index)
{
- var elements = $A(document.getElementsByName(name));
for(var i = 0; i<elements.length; i++)
{
if(i == index)
@@ -3730,31 +3858,65 @@ Prado.Element.Selection =
}
},
- checkClear : function(name)
+ checkIndices : function(elements, indices)
+ {
+ selection = this;
+ indices.each(function(index)
+ {
+ selection.checkIndex(elements, index);
+ })
+ },
+
+ checkClear : function(elements)
{
- $A(document.getElementsByName(name)).each(function(el)
+ elements.each(function(el)
{
el.checked = false;
});
},
- checkAll : function(name)
+ checkAll : function(elements)
{
- $A(document.getElementsByName(name)).each(function(el)
+ elements.each(function(el)
{
el.checked = true;
- });
+ })
},
- checkInvert : function(name)
+
+ checkInvert : function(elements)
{
- $A(document.getElementsByName(name)).each(function(el)
+ elements.each(function(el)
{
- el.checked = !el.checked;
- });
+ el.checked != el.checked;
+ })
}
};
+Prado.Element.Insert =
+{
+ append: function(element, content)
+ {
+ new Insertion.Bottom(element, content);
+ },
+
+ prepend: function(element, content)
+ {
+ new Insertion.Top(element, content);
+ },
+
+ after: function(element, content)
+ {
+ new Insertion.After(element, content);
+ },
+
+ before: function(element, content)
+ {
+ new Insertion.Before(element, content);
+ }
+}
+
+
/**
* Export scripaculous builder utilities as window[functions]
*/