diff options
author | wei <> | 2007-03-27 02:23:20 +0000 |
---|---|---|
committer | wei <> | 2007-03-27 02:23:20 +0000 |
commit | 1b9b64637fe08848f610bbd19b80c031cb7dba63 (patch) | |
tree | 52f7486e911f60c9a91904c91e3944f4f4f27bca /framework/Web/Javascripts/js/compressed/prado.js | |
parent | c5d0cd2824e3c3bb2f6f3834177a71c1d7b78519 (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/compressed/prado.js')
-rw-r--r-- | framework/Web/Javascripts/js/compressed/prado.js | 109 |
1 files changed, 79 insertions, 30 deletions
diff --git a/framework/Web/Javascripts/js/compressed/prado.js b/framework/Web/Javascripts/js/compressed/prado.js index 4a718d25..74c50356 100644 --- a/framework/Web/Javascripts/js/compressed/prado.js +++ b/framework/Web/Javascripts/js/compressed/prado.js @@ -235,7 +235,7 @@ if(Element.getStyle(element,'position')=='absolute')break;element=element.offset Element.addMethods();var Builder={NODEMAP:{AREA:'map',CAPTION:'table',COL:'table',COLGROUP:'table',LEGEND:'fieldset',OPTGROUP:'select',OPTION:'select',PARAM:'object',TBODY:'table',TD:'table',TFOOT:'table',TH:'table',THEAD:'table',TR:'table'},node:function(elementName){elementName=elementName.toUpperCase();var parentTag=this.NODEMAP[elementName]||'div';var parentElement=document.createElement(parentTag);try{parentElement.innerHTML="<"+elementName+"></"+elementName+">";}catch(e){} var element=parentElement.firstChild||null;if(element&&(element.tagName.toUpperCase()!=elementName)) element=element.getElementsByTagName(elementName)[0];if(!element)element=document.createElement(elementName);if(!element)return;if(arguments[1]) -if(this._isStringOrNumber(arguments[1])||(arguments[1]instanceof Array)){this._children(element,arguments[1]);}else{var attrs=this._attributes(arguments[1]);if(attrs.length){try{parentElement.innerHTML="<"+elementName+" "+ +if(this._isStringOrNumber(arguments[1])||(arguments[1]instanceof Array)||arguments[1].tagName){this._children(element,arguments[1]);}else{var attrs=this._attributes(arguments[1]);if(attrs.length){try{parentElement.innerHTML="<"+elementName+" "+ attrs+"></"+elementName+">";}catch(e){} element=parentElement.firstChild||null;if(!element){element=document.createElement(elementName);for(attr in arguments[1]) element[attr=='class'?'className':attr]=arguments[1][attr];} @@ -243,7 +243,8 @@ if(element.tagName.toUpperCase()!=elementName) element=parentElement.getElementsByTagName(elementName)[0];}} if(arguments[2]) this._children(element,arguments[2]);return element;},_text:function(text){return document.createTextNode(text);},ATTR_MAP:{'className':'class','htmlFor':'for'},_attributes:function(attributes){var attrs=[];for(attribute in attributes) -attrs.push((attribute in this.ATTR_MAP?this.ATTR_MAP[attribute]:attribute)+'="'+attributes[attribute].toString().escapeHTML()+'"');return attrs.join(" ");},_children:function(element,children){if(typeof children=='object'){children.flatten().each(function(e){if(typeof e=='object') +attrs.push((attribute in this.ATTR_MAP?this.ATTR_MAP[attribute]:attribute)+'="'+attributes[attribute].toString().escapeHTML()+'"');return attrs.join(" ");},_children:function(element,children){if(children.tagName){element.appendChild(children);return;} +if(typeof children=='object'){children.flatten().each(function(e){if(typeof e=='object') element.appendChild(e) else if(Builder._isStringOrNumber(e)) @@ -277,46 +278,94 @@ lastFocus.value=options['EventTarget'];}} $('PRADO_POSTBACK_TARGET').value=options['EventTarget'];$('PRADO_POSTBACK_PARAMETER').value=options['EventParameter'];Event.stop(event);Event.fireEvent(form,"submit");} Prado.Element={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) +el.value=value;},select:function(element,method,value,total) +{var el=$(element);if(!el)return;var selection=Prado.Element.Selection;if(typeof(selection[method])=="function") +{control=selection.isSelectable(el)?[el]:selection.getListElements(element,total);selection[method](control,value);}},click:function(element) {var el=$(element);if(el) Event.fireEvent(el,'click');},setAttribute:function(element,attribute,value) -{var el=$(element);if(attribute=="disabled"&&value==false) -el.removeAttribute(attribute);else +{var el=$(element);if(!el)return;if((attribute=="disabled"||attribute=="multiple")&&value==false) +el.removeAttribute(attribute);else if(attribute.match(/^on/i)) +{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);},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]);}},focus:function(element) +{var el=$(element);if(!el)return;if(el&&el.tagName.toLowerCase()=="select") +{el.options.length=options.length;for(var i=0;i<options.length;i++) +el.options[i]=new Option(options[i][0],options[i][1]);}},focus:function(element) {var obj=$(element);if(typeof(obj)!="undefined"&&typeof(obj.focus)!="undefined") -setTimeout(function(){obj.focus();},100);return false;}} -Prado.Element.Selection={inputValue:function(el,value) +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();}} +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()) -{case'checkbox':case'radio':return el.checked=value;}},selectValue:function(el,value) +{case'checkbox':case'radio':return el.checked=value;}},selectValue:function(elements,value) +{elements.each(function(el) {$A(el.options).each(function(option) -{option.selected=option.value==value;});},selectIndex:function(el,index) -{if(el.type=='select-one') +{if(typeof(value)=="boolean") +options.selected=value;else if(option.value==value) +option.selected=true;});})},selectValues:function(elements,values) +{selection=this;values.each(function(value) +{selection.selectValue(elements,value);})},selectIndex:function(elements,index) +{elements.each(function(el) +{if(el.type.toLowerCase()=='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) +el.options[i].selected=true;}}})},selectAll:function(elements) +{elements.each(function(el) +{if(el.type.toLowerCase()!='select-one') {$A(el.options).each(function(option) -{option.selected=true;Logger.warn(option.value);});},selectInvert:function(el) +{option.selected=true;})}})},selectInvert:function(elements) +{elements.each(function(el) +{if(el.type.toLowerCase()!='select-one') {$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++) +{option.selected=!options.selected;})}})},selectIndices:function(elements,indices) +{selection=this;indices.each(function(index) +{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(elements,value) +{elements.each(function(el) +{if(typeof(value)=="boolean") +el.checked=value;else if(el.value==value) +el.checked=true;});},checkValues:function(elements,values) +{selection=this;values.each(function(value) +{selection.checkValue(elements,value);})},checkIndex:function(elements,index) +{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;});}};Object.extend(Builder,{exportTags:function() +elements[i].checked=true;}},checkIndices:function(elements,indices) +{selection=this;indices.each(function(index) +{selection.checkIndex(elements,index);})},checkClear:function(elements) +{elements.each(function(el) +{el.checked=false;});},checkAll:function(elements) +{elements.each(function(el) +{el.checked=true;})},checkInvert:function(elements) +{elements.each(function(el) +{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);}} +Object.extend(Builder,{exportTags:function() {var tags=["BUTTON","TT","PRE","H1","H2","H3","BR","CANVAS","HR","LABEL","TEXTAREA","FORM","STRONG","SELECT","OPTION","OPTGROUP","LEGEND","FIELDSET","P","UL","OL","LI","TD","TR","THEAD","TBODY","TFOOT","TABLE","TH","INPUT","SPAN","A","DIV","IMG","CAPTION"];tags.each(function(tag) {window[tag]=function() {var args=$A(arguments);if(args.length==0) |