summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts
diff options
context:
space:
mode:
authorwei <>2006-02-15 07:44:51 +0000
committerwei <>2006-02-15 07:44:51 +0000
commit6e29b055b3cbc2a46e29075608c7e82a328d5270 (patch)
tree13a197ad850f360125a96f5de83f1742a12e98ad /framework/Web/Javascripts
parentd653bda6c6217f160a4de77e3f2f0ee62096be67 (diff)
Adding new TRatingList component.
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r--framework/Web/Javascripts/extended/builder.js2
-rw-r--r--framework/Web/Javascripts/js/prado.js87
-rw-r--r--framework/Web/Javascripts/prado/controls.js10
-rw-r--r--framework/Web/Javascripts/ratings/10star_white.gifbin0 -> 25048 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default.css21
-rw-r--r--framework/Web/Javascripts/ratings/ratings.js70
6 files changed, 158 insertions, 32 deletions
diff --git a/framework/Web/Javascripts/extended/builder.js b/framework/Web/Javascripts/extended/builder.js
index 24b565e5..141eab51 100644
--- a/framework/Web/Javascripts/extended/builder.js
+++ b/framework/Web/Javascripts/extended/builder.js
@@ -2,7 +2,7 @@ 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"];
+ 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()
diff --git a/framework/Web/Javascripts/js/prado.js b/framework/Web/Javascripts/js/prado.js
index 0ca9d306..caae1134 100644
--- a/framework/Web/Javascripts/js/prado.js
+++ b/framework/Web/Javascripts/js/prado.js
@@ -1404,7 +1404,7 @@ _328.appendChild(Builder._text(_329));
return (typeof _330=="string"||typeof _330=="number");
}};
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"];
+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);
@@ -1901,24 +1901,19 @@ Event.stop(e);
}
}
}});
-Prado.WebUI.TListControl=Prado.WebUI.createPostBackComponent({onInit:function(_433){
-Event.observe(this.element,"change",Prado.PostBack.bindEvent(this,_433));
-}});
-Prado.WebUI.TListBox=Prado.WebUI.TListControl;
-Prado.WebUI.TDropDownList=Prado.WebUI.TListControl;
Prado.WebUI.DefaultButton=Class.create();
-Object.extend(Prado.WebUI.DefaultButton.prototype,{initialize:function(_434){
-this.options=_434;
+Object.extend(Prado.WebUI.DefaultButton.prototype,{initialize:function(_433){
+this.options=_433;
this._event=this.triggerEvent.bindEvent(this);
-Event.observe(_434["Panel"],"keydown",this._event);
-},triggerEvent:function(ev,_436){
-var _437=Event.keyCode(ev)==Event.KEY_RETURN;
-var _438=Event.element(ev).tagName.toLowerCase()=="textarea";
-if(_437&&!_438){
-var _439=$(this.options["Target"]);
-if(_439){
+Event.observe(_433["Panel"],"keydown",this._event);
+},triggerEvent:function(ev,_435){
+var _436=Event.keyCode(ev)==Event.KEY_RETURN;
+var _437=Event.element(ev).tagName.toLowerCase()=="textarea";
+if(_436&&!_437){
+var _438=$(this.options["Target"]);
+if(_438){
this.triggered=true;
-Event.fireEvent(_439,this.options["Event"]);
+Event.fireEvent(_438,this.options["Event"]);
Event.stop(ev);
}
}
@@ -1928,15 +1923,15 @@ Prado.WebUI.TTextHighlighter.prototype={initialize:function(id){
if(!window.clipboardData){
return;
}
-var _440={href:"javascript:;//copy code to clipboard",onclick:"Prado.WebUI.TTextHighlighter.copy(this)",onmouseover:"Prado.WebUI.TTextHighlighter.hover(this)",onmouseout:"Prado.WebUI.TTextHighlighter.out(this)"};
-var div=DIV({className:"copycode"},A(_440,"Copy Code"));
+var _439={href:"javascript:;//copy code to clipboard",onclick:"Prado.WebUI.TTextHighlighter.copy(this)",onmouseover:"Prado.WebUI.TTextHighlighter.hover(this)",onmouseout:"Prado.WebUI.TTextHighlighter.out(this)"};
+var div=DIV({className:"copycode"},A(_439,"Copy Code"));
document.write(DIV(null,div).innerHTML);
}};
Object.extend(Prado.WebUI.TTextHighlighter,{copy:function(obj){
-var _441=obj.parentNode.parentNode.parentNode;
+var _440=obj.parentNode.parentNode.parentNode;
var text="";
-for(var i=0;i<_441.childNodes.length;i++){
-var node=_441.childNodes[i];
+for(var i=0;i<_440.childNodes.length;i++){
+var node=_440.childNodes[i];
if(node.innerText){
text+=node.innerText=="Copy Code"?"":node.innerText;
}else{
@@ -1951,4 +1946,54 @@ obj.parentNode.className="copycode copycode_hover";
},out:function(obj){
obj.parentNode.className="copycode";
}});
+Prado.WebUI.TRatingList=Class.create();
+Prado.WebUI.TRatingList.prototype={selectedIndex:-1,initialize:function(_441){
+this.options=_441;
+this.element=$(_441["ID"]);
+Element.addClassName(this.element,_441.cssClass);
+var _442=_441.total*_441.dx;
+this.element.style.width=_442+"px";
+Event.observe(this.element,"mouseover",this.hover.bindEvent(this));
+Event.observe(this.element,"mouseout",this.recover.bindEvent(this));
+Event.observe(this.element,"click",this.click.bindEvent(this));
+this._onMouseMoveEvent=this.mousemoved.bindEvent(this);
+this.selectedIndex=_441.pos;
+this.radios=document.getElementsByName(_441.field);
+this.caption=CAPTION();
+this.element.appendChild(this.caption);
+this.showPosition(this.selectedIndex,false);
+},hover:function(){
+Event.observe(this.element,"mousemove",this._onMouseMoveEvent);
+},recover:function(){
+Event.stopObserving(this.element,"mousemove",this._onMouseMoveEvent);
+this.showPosition(this.selectedIndex,false);
+},mousemoved:function(e){
+this.updatePosition(e,true);
+},updatePosition:function(e,_443){
+var obj=Event.element(e);
+var _444=Position.cumulativeOffset(obj);
+var _445=Event.pointerX(e)-_444[0];
+var pos=parseInt(_445/this.options.dx);
+if(!_443||this.options.pos!=pos){
+this.showPosition(pos,_443);
+}
+},click:function(ev){
+this.updatePosition(ev,false);
+this.selectedIndex=this.options.pos;
+for(var i=0;i<this.radios.length;i++){
+this.radios[i].checked=(i==this.selectedIndex);
+}
+if(isFunction(this.options.onChange)){
+this.options.onChange(this,this.selectedIndex);
+}
+},showPosition:function(pos,_446){
+if(pos>=this.options.total){
+return;
+}
+var dy=this.options.dy*(pos+1)+this.options.iy;
+var dx=_446?this.options.hx+this.options.ix:this.options.ix;
+this.element.style.backgroundPosition="-"+dx+"px -"+dy+"px";
+this.options.pos=pos;
+this.caption.innerHTML=pos>=0?this.radios[this.options.pos].value:this.options.caption;
+}};
diff --git a/framework/Web/Javascripts/prado/controls.js b/framework/Web/Javascripts/prado/controls.js
index 7a1a8257..aae3201e 100644
--- a/framework/Web/Javascripts/prado/controls.js
+++ b/framework/Web/Javascripts/prado/controls.js
@@ -112,16 +112,6 @@ Prado.WebUI.TTextBox = Prado.WebUI.createPostBackComponent(
}
});
-Prado.WebUI.TListControl = Prado.WebUI.createPostBackComponent(
-{
- onInit : function(options)
- {
- Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
- }
-});
-
-Prado.WebUI.TListBox = Prado.WebUI.TListControl;
-Prado.WebUI.TDropDownList = Prado.WebUI.TListControl;
Prado.WebUI.DefaultButton = Class.create();
Object.extend(Prado.WebUI.DefaultButton.prototype,
diff --git a/framework/Web/Javascripts/ratings/10star_white.gif b/framework/Web/Javascripts/ratings/10star_white.gif
new file mode 100644
index 00000000..0acdf5c9
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/10star_white.gif
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default.css b/framework/Web/Javascripts/ratings/default.css
new file mode 100644
index 00000000..1609ee05
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/default.css
@@ -0,0 +1,21 @@
+.TRatingList_default tr
+{
+ display: none;
+}
+
+.TRatingList_default
+{
+ width: 120px;
+ height: 20px;
+ background-image: url(10star_white.gif);
+ background-position: -0px -4px;
+ background-repeat: no-repeat;
+ margin: 4px;
+ cursor: pointer;
+}
+
+.TRatingList_default caption
+{
+ padding-left: 4px;
+ text-align: left;
+} \ No newline at end of file
diff --git a/framework/Web/Javascripts/ratings/ratings.js b/framework/Web/Javascripts/ratings/ratings.js
new file mode 100644
index 00000000..c5efc372
--- /dev/null
+++ b/framework/Web/Javascripts/ratings/ratings.js
@@ -0,0 +1,70 @@
+Prado.WebUI.TRatingList = Class.create();
+Prado.WebUI.TRatingList.prototype =
+{
+ selectedIndex : -1,
+
+ initialize : function(options)
+ {
+ this.options = options;
+ this.element = $(options['ID']);
+ Element.addClassName(this.element,options.cssClass);
+ var width = options.total * options.dx;
+ this.element.style.width = width+"px";
+ Event.observe(this.element, 'mouseover', this.hover.bindEvent(this));
+ Event.observe(this.element, 'mouseout', this.recover.bindEvent(this));
+ Event.observe(this.element, 'click', this.click.bindEvent(this));
+ this._onMouseMoveEvent = this.mousemoved.bindEvent(this);
+ this.selectedIndex = options.pos;
+ this.radios = document.getElementsByName(options.field);
+ this.caption = CAPTION();
+ this.element.appendChild(this.caption);
+ this.showPosition(this.selectedIndex,false);
+ },
+
+ hover : function()
+ {
+ Event.observe(this.element, "mousemove", this._onMouseMoveEvent);
+ },
+
+ recover : function()
+ {
+ Event.stopObserving(this.element, "mousemove", this._onMouseMoveEvent);
+ this.showPosition(this.selectedIndex,false);
+ },
+
+ mousemoved : function(e)
+ {
+ this.updatePosition(e,true);
+ },
+
+ updatePosition : function(e, hovering)
+ {
+ var obj = Event.element(e);
+ var elementPos = Position.cumulativeOffset(obj);
+ var clientX = Event.pointerX(e) - elementPos[0];
+ var pos = parseInt(clientX / this.options.dx);
+ if(!hovering || this.options.pos != pos)
+ this.showPosition(pos, hovering)
+ },
+
+ click : function(ev)
+ {
+ this.updatePosition(ev,false);
+ this.selectedIndex = this.options.pos;
+ for(var i = 0; i < this.radios.length; i++)
+ this.radios[i].checked = (i == this.selectedIndex);
+ if(isFunction(this.options.onChange))
+ this.options.onChange(this, this.selectedIndex);
+ },
+
+ showPosition : function(pos, hovering)
+ {
+ if(pos >= this.options.total) return;
+ var dy = this.options.dy * (pos+1) + this.options.iy;
+ var dx = hovering ? this.options.hx + this.options.ix : this.options.ix;
+ this.element.style.backgroundPosition = "-"+dx+"px -"+dy+"px";
+ this.options.pos = pos;
+ this.caption.innerHTML = pos >= 0 ?
+ this.radios[this.options.pos].value : this.options.caption;
+ }
+} \ No newline at end of file