diff options
author | wei <> | 2006-10-01 03:09:18 +0000 |
---|---|---|
committer | wei <> | 2006-10-01 03:09:18 +0000 |
commit | 36f2ce766bde98c11d57b889fd9e1a7f8dff6010 (patch) | |
tree | 87c33c9e4447e20159932824b4de6167da495d49 /framework/Web/Javascripts/js/debug/ajax.js | |
parent | 1c32172efb18e8d08ea483e2460813670ebfe1a5 (diff) |
Fixed #350 and #148, Add TActiveRatingList, should remove TRatingList from WebControls.
Diffstat (limited to 'framework/Web/Javascripts/js/debug/ajax.js')
-rw-r--r-- | framework/Web/Javascripts/js/debug/ajax.js | 157 |
1 files changed, 148 insertions, 9 deletions
diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js index 5acdfb63..dc35043d 100644 --- a/framework/Web/Javascripts/js/debug/ajax.js +++ b/framework/Web/Javascripts/js/debug/ajax.js @@ -2065,6 +2065,24 @@ Prado.WebUI.TActiveCheckBox = Class.extend(Prado.WebUI.CallbackControl, Prado.WebUI.TActiveRadioButton = Class.extend(Prado.WebUI.TActiveCheckBox);
+Prado.WebUI.TActiveCheckBoxList = Base.extend(
+{
+ constructor : function(options)
+ {
+ for(var i = 0; i<options.ItemCount; i++)
+ {
+ var checkBoxOptions = Object.extend(
+ {
+ ID : options.ListID+"_c"+i,
+ EventTarget : options.ListName+"$c"+i
+ }, options);
+ new Prado.WebUI.TActiveCheckBox(checkBoxOptions);
+ }
+ }
+});
+
+Prado.WebUI.TActiveRadioButtonList = Prado.WebUI.TActiveCheckBoxList;
+
/**
* TActiveTextBox control, handles onchange event.
*/
@@ -2161,7 +2179,7 @@ Prado.WebUI.TTimeTriggeredCallback = Base.extend( startTimer : function()
{
this.options.onComplete = this.onRequestComplete.bind(this);
- setTimeout(this.onTimerEvent.bind(this), 200);
+ this.timer = setTimeout(this.onTimerEvent.bind(this), 200);
},
stopTimer : function()
@@ -2215,19 +2233,17 @@ Prado.WebUI.TTimeTriggeredCallback = Base.extend( register : function(timer)
{
- this.timers[timer.options.ID] = timer;
+ Prado.WebUI.TTimeTriggeredCallback.timers[timer.options.ID] = timer;
},
start : function(id)
{
- if(this.timers[id])
- this.timers[id].startTimer();
+ Prado.WebUI.TTimeTriggeredCallback.timers[id].startTimer();
},
stop : function(id)
{
- if(this.timers[id])
- this.timers[id].stopTimer();
+ Prado.WebUI.TTimeTriggeredCallback.timers[id].stopTimer();
}
});
@@ -2355,13 +2371,12 @@ Prado.WebUI.TValueTriggeredCallback = Base.extend( register : function(timer)
{
- this.timers[timer.options.ID] = timer;
+ Prado.WebUI.TValueTriggeredCallback.timers[timer.options.ID] = timer;
},
stop : function(id)
{
- if(this.timers[id])
- this.timers[id].stopObserving();
+ Prado.WebUI.TValueTriggeredCallback.timers[id].stopObserving();
}
});
@@ -2595,3 +2610,127 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( }
}); +Prado.WebUI.TRatingList = Base.extend(
+{
+ selectedIndex : -1,
+ enabled : true,
+
+ constructor : function(options)
+ {
+ var cap = $(options.CaptionID);
+ this.options = Object.extend(
+ {
+ caption : cap ? cap.innerHTML : ''
+ }, options || {});
+
+ Prado.WebUI.TRatingList.register(this);
+ this._init();
+ this.selectedIndex = options.SelectedIndex;
+ this.setRating(this.selectedIndex);
+ },
+
+ _init: function(options)
+ {
+ Element.addClassName($(this.options.ListID),this.options.Style);
+ var radios = document.getElementsByName(this.options.ListName);
+ this.radios = new Array();
+ var index=0;
+ for(var i = 0; i<radios.length; i++)
+ {
+ var node = radios[i].parentNode;
+ if(node.tagName.toLowerCase()=='td')
+ {
+ this.radios.push(radios[i]);
+ Event.observe(node, "mouseover", this.hover.bindEvent(this,index));
+ Event.observe(node, "mouseout", this.recover.bindEvent(this,index));
+ Event.observe(node, "click", this.click.bindEvent(this, index));
+ index++;
+ Element.addClassName(node,"rating");
+ }
+ }
+ },
+
+ hover : function(ev,index)
+ {
+ if(this.enabled==false) return;
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = i <= index ? 'addClassName' : 'removeClassName'
+ Element[action](this.radios[i].parentNode,"rating_hover");
+ }
+ this.setCaption(index);
+ },
+
+ recover : function(ev,index)
+ {
+ if(this.enabled==false) return;
+ for(var i = 0; i<=index; i++)
+ Element.removeClassName(this.radios[i].parentNode, "rating_hover");
+ this.setRating(this.selectedIndex);
+ },
+
+ click : function(ev, index)
+ {
+ if(this.enabled==false) return;
+ for(var i = 0; i<this.radios.length; i++)
+ this.radios[i].checked = (i == index);
+ this.selectedIndex = index;
+ this.setRating(index);
+ var requestOptions = Object.extend(
+ {
+ ID : this.options.ListID+"_c"+index,
+ EventTarget : this.options.ListName+"$c"+index
+ },this.options);
+ var request = new Prado.CallbackRequest(requestOptions.EventTarget, requestOptions);
+ if(request.dispatch()==false)
+ Event.stop(ev);
+ },
+
+ setRating: function(index)
+ {
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = i <= index ? 'addClassName' : 'removeClassName'
+ Element[action](this.radios[i].parentNode, "rating_selected");
+ }
+ this.setCaption(index);
+ },
+
+ setCaption : function(index)
+ {
+ var value = index > -1 ? this.radios[index].value : this.options.caption;
+ var caption = $(this.options.CaptionID);
+ if(caption) caption.innerHTML = value;
+ $(this.options.ListName).title = value;
+ },
+
+ setEnabled : function(value)
+ {
+ this.enabled = value;
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = value ? 'removeClassName' : 'addClassName'
+ Element[action](this.radios[i].parentNode, "rating_disabled");
+ Element.removeClassName(this.radios[i].parentNode, "rating_hover");
+ }
+ }
+},
+{
+ratings : {},
+register : function(rating)
+{
+ Prado.WebUI.TRatingList.ratings[rating.options.ListID] = rating;
+},
+
+setEnabled : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setEnabled(value);
+},
+
+setRating : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setRating(value);
+ Prado.WebUI.TRatingList.ratings[id].selectedIndex = value;
+}
+}); + |