[ Index ] |
|
Code source de PRADO 3.0.6 |
1 Prado.WebUI.TRatingList = Class.create(); 2 Prado.WebUI.TRatingList.prototype = 3 { 4 selectedIndex : -1, 5 6 initialize : function(options) 7 { 8 this.options = options; 9 this.element = $(options['ID']); 10 Element.addClassName(this.element,options.cssClass); 11 this.radios = document.getElementsByName(options.field); 12 for(var i = 0; i<this.radios.length; i++) 13 { 14 Event.observe(this.radios[i].parentNode, "mouseover", this.hover.bindEvent(this,i)); 15 Event.observe(this.radios[i].parentNode, "mouseout", this.recover.bindEvent(this,i)); 16 Event.observe(this.radios[i].parentNode, "click", this.click.bindEvent(this, i)); 17 } 18 this.caption = CAPTION(); 19 this.element.appendChild(this.caption); 20 this.selectedIndex = options.selectedIndex; 21 this.setRating(this.selectedIndex); 22 }, 23 24 hover : function(ev,index) 25 { 26 for(var i = 0; i<this.radios.length; i++) 27 this.radios[i].parentNode.className = (i<=index) ? "rating_hover" : ""; 28 this.setCaption(index); 29 }, 30 31 recover : function(ev,index) 32 { 33 for(var i = 0; i<=index; i++) 34 Element.removeClassName(this.radios[i].parentNode, "rating_hover"); 35 this.setRating(this.selectedIndex); 36 }, 37 38 click : function(ev, index) 39 { 40 for(var i = 0; i<this.radios.length; i++) 41 this.radios[i].checked = (i == index); 42 this.selectedIndex = index; 43 this.setRating(index); 44 if(isFunction(this.options.onChange)) 45 this.options.onChange(this,index); 46 }, 47 48 setRating: function(index) 49 { 50 for(var i = 0; i<=index; i++) 51 this.radios[i].parentNode.className = "rating_selected"; 52 this.setCaption(index); 53 }, 54 55 setCaption : function(index) 56 { 57 this.caption.innerHTML = index > -1 ? 58 this.radios[index].value : this.options.caption; 59 } 60 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |