diff options
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r-- | framework/Web/Javascripts/js/ajax.js | 4 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/prado.js | 69 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/activecontrols3.js | 17 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/element.js | 176 |
4 files changed, 200 insertions, 66 deletions
diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js index e0e9ae7e..fbbd3ecf 100644 --- a/framework/Web/Javascripts/js/ajax.js +++ b/framework/Web/Javascripts/js/ajax.js @@ -215,4 +215,6 @@ this.timeout=(t+this.options.Interval)*1000;this.count++;return parseInt(this.ti {if(this.timers[id]) this.timers[id].startTimer();},stop:function(id) {if(this.timers[id]) -this.timers[id].stopTimer();}});
\ No newline at end of file +this.timers[id].stopTimer();}});Prado.WebUI.ActiveListControl=Base.extend({constructor:function(options) +{this.element=$(options.ID);this.options=options;Event.observe(this.element,"change",this.doCallback.bind(this));},doCallback:function(event) +{new Prado.CallbackRequest(this.options.EventTarget,this.options);Event.stop(event);}});Prado.WebUI.TActiveDropDownList=Prado.WebUI.ActiveListControl;
\ No newline at end of file diff --git a/framework/Web/Javascripts/js/prado.js b/framework/Web/Javascripts/js/prado.js index c2f2fdfd..0e71f733 100644 --- a/framework/Web/Javascripts/js/prado.js +++ b/framework/Web/Javascripts/js/prado.js @@ -251,9 +251,9 @@ 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(typeof(selection[method])=="function") -selection[method](isList?element:el,value);},click:function(element) +el.value=value;},select:function(element,method,value,total) +{var el=$(element);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) @@ -278,32 +278,59 @@ else return result[2];else return null;},evaluateScript:function(content) {content.evalScripts();}} -Prado.Element.Selection={inputValue:function(el,value) +Prado.Element.Selection={isSelectable:function(el) +{if(el&&el.type) {switch(el.type.toLowerCase()) -{case'checkbox':case'radio':return el.checked=value;}},selectValue:function(el,value) +{case'checkbox':case'radio':case'select':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(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;});}};Prado.WebUI=Class.create();Prado.WebUI.PostBackControl=Class.create();Prado.WebUI.PostBackControl.prototype={_elementOnClick:null,initialize:function(options) +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.WebUI=Class.create();Prado.WebUI.PostBackControl=Class.create();Prado.WebUI.PostBackControl.prototype={_elementOnClick:null,initialize:function(options) {this.element=$(options.ID);if(this.onInit) this.onInit(options);},onInit:function(options) {if(typeof(this.element.onclick)=="function") diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js index 7039feec..760d6e0e 100644 --- a/framework/Web/Javascripts/prado/activecontrols3.js +++ b/framework/Web/Javascripts/prado/activecontrols3.js @@ -189,5 +189,20 @@ Prado.WebUI.TCallbackTimer = Base.extend( }
});
+Prado.WebUI.ActiveListControl = Base.extend(
+{
+ constructor : function(options)
+ {
+ this.element = $(options.ID);
+ this.options = options;
+ Event.observe(this.element, "change", this.doCallback.bind(this));
+ },
+
+ doCallback : function(event)
+ {
+ new Prado.CallbackRequest(this.options.EventTarget, this.options);
+ Event.stop(event);
+ }
+});
-
+Prado.WebUI.TActiveDropDownList = Prado.WebUI.ActiveListControl;
diff --git a/framework/Web/Javascripts/prado/element.js b/framework/Web/Javascripts/prado/element.js index 9d0179dc..51756cd0 100644 --- a/framework/Web/Javascripts/prado/element.js +++ b/framework/Web/Javascripts/prado/element.js @@ -12,15 +12,15 @@ 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;
var selection = Prado.Element.Selection;
if(typeof(selection[method]) == "function")
- selection[method](isList ? element : el,value);
+ {
+ control = selection.isSelectable(el) ? [el] : selection.getListElements(element,total);
+ selection[method](control, value);
+ }
},
click : function(element)
@@ -102,6 +102,22 @@ Prado.Element = Prado.Element.Selection =
{
+ isSelectable : function(el)
+ {
+ if(el && el.type)
+ {
+ switch(el.type.toLowerCase())
+ {
+ case 'checkbox':
+ case 'radio':
+ case 'select':
+ case 'select-one':
+ return true;
+ }
+ }
+ return false;
+ },
+
inputValue : function(el, value)
{
switch(el.type.toLowerCase())
@@ -112,61 +128,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;
+ });
+ })
+ },
+
+ selectValues : function(elements, values)
+ {
+ selection = this;
+ values.each(function(value)
+ {
+ selection.selectValue(elements,value);
+ })
},
- selectIndex : function(el, index)
+ selectIndex : function(elements, index)
{
- if(el.type == 'select-one')
- el.selectedIndex = index;
- else
+ 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;
+ }
}
- }
+ })
+ },
+
+ selectAll : function(elements)
+ {
+ elements.each(function(el)
+ {
+ if(el.type.toLowerCase() != 'select-one')
+ {
+ $A(el.options).each(function(option)
+ {
+ option.selected = true;
+ })
+ }
+ })
},
- selectClear : function(el)
+ selectInvert : function(elements)
{
- el.selectedIndex = -1;
+ elements.each(function(el)
+ {
+ if(el.type.toLowerCase() != 'select-one')
+ {
+ $A(el.options).each(function(option)
+ {
+ option.selected = !options.selected;
+ })
+ }
+ })
+ },
+
+ selectIndices : function(elements, indices)
+ {
+ selection = this;
+ indices.each(function(index)
+ {
+ selection.selectIndex(elements,index);
+ })
},
- selectAll : function(el)
+ selectClear : function(elements)
{
- $A(el.options).each(function(option)
+ elements.each(function(el)
{
- option.selected = true;
- Logger.warn(option.value);
- });
+ el.selectedIndex = -1;
+ })
},
- selectInvert : function(el)
+ 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)
{
- $A(el.options).each(function(option)
+ elements.each(function(el)
{
- option.selected = !option.selected;
+ if(typeof(value) == "boolean")
+ el.checked = value;
+ else if(el.value == value)
+ el.checked = true;
});
},
- checkValue : function(name, value)
+ checkValues : function(elements, values)
{
- $A(document.getElementsByName(name)).each(function(el)
+ selection = this;
+ values.each(function(value)
{
- el.checked = el.value == value
- });
+ selection.checkValue(elements, value);
+ })
},
- checkIndex : function(name, index)
+ checkIndex : function(elements, index)
{
- var elements = $A(document.getElementsByName(name));
for(var i = 0; i<elements.length; i++)
{
if(i == index)
@@ -174,26 +254,36 @@ 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;
+ })
}
};
\ No newline at end of file |