summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/ratings
diff options
context:
space:
mode:
authorwei <>2006-10-08 05:11:23 +0000
committerwei <>2006-10-08 05:11:23 +0000
commit9e2820e98640f4ca262db7279a514826341df3e0 (patch)
tree82184c36e9b82ae57303b7841266cbec23151c5c /framework/Web/Javascripts/ratings
parentfe60cc221f922ea362826e2d00431c5df28fe85f (diff)
Fixed #414, #411, #415
Diffstat (limited to 'framework/Web/Javascripts/ratings')
-rw-r--r--framework/Web/Javascripts/ratings/blocks.css12
-rw-r--r--framework/Web/Javascripts/ratings/blocks.pngbin27953 -> 28700 bytes
-rw-r--r--framework/Web/Javascripts/ratings/blocks_combined.gifbin237 -> 289 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default.css10
-rw-r--r--framework/Web/Javascripts/ratings/default.pngbin52075 -> 51492 bytes
-rw-r--r--framework/Web/Javascripts/ratings/default_combined.gifbin1001 -> 1201 bytes
-rw-r--r--framework/Web/Javascripts/ratings/ratings.js85
7 files changed, 90 insertions, 17 deletions
diff --git a/framework/Web/Javascripts/ratings/blocks.css b/framework/Web/Javascripts/ratings/blocks.css
index 5d13a859..b05d9eb6 100644
--- a/framework/Web/Javascripts/ratings/blocks.css
+++ b/framework/Web/Javascripts/ratings/blocks.css
@@ -26,7 +26,17 @@
background-position: 1px -100px;
}
+.TRatingList_blocks td.rating_half
+{
+ background-position: 1px -200px;
+}
+
+.TRatingList_blocks td.rating_hover
+{
+ background-position: 1px -300px;
+}
+
.TRatingList_blocks td.rating_disabled
{
cursor: default !important;
-} \ No newline at end of file
+}
diff --git a/framework/Web/Javascripts/ratings/blocks.png b/framework/Web/Javascripts/ratings/blocks.png
index 0da75b19..93a5333e 100644
--- a/framework/Web/Javascripts/ratings/blocks.png
+++ b/framework/Web/Javascripts/ratings/blocks.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/blocks_combined.gif b/framework/Web/Javascripts/ratings/blocks_combined.gif
index 04e8f7b8..dfe9da8d 100644
--- a/framework/Web/Javascripts/ratings/blocks_combined.gif
+++ b/framework/Web/Javascripts/ratings/blocks_combined.gif
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default.css b/framework/Web/Javascripts/ratings/default.css
index aa7913bf..d404f843 100644
--- a/framework/Web/Javascripts/ratings/default.css
+++ b/framework/Web/Javascripts/ratings/default.css
@@ -27,6 +27,16 @@
background-position: 0px -100px;
}
+.TRatingList_default td.rating_half
+{
+ background-position: 0px -200px;
+}
+
+.TRatingList_default td.rating_hover
+{
+ background-position: 0px -300px;
+}
+
.TRatingList_default td.rating_disabled
{
cursor: default !important;
diff --git a/framework/Web/Javascripts/ratings/default.png b/framework/Web/Javascripts/ratings/default.png
index 17bc39a1..a3148ff4 100644
--- a/framework/Web/Javascripts/ratings/default.png
+++ b/framework/Web/Javascripts/ratings/default.png
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/default_combined.gif b/framework/Web/Javascripts/ratings/default_combined.gif
index fe02b446..ddab2e8b 100644
--- a/framework/Web/Javascripts/ratings/default_combined.gif
+++ b/framework/Web/Javascripts/ratings/default_combined.gif
Binary files differ
diff --git a/framework/Web/Javascripts/ratings/ratings.js b/framework/Web/Javascripts/ratings/ratings.js
index 9299d8d8..c8b19511 100644
--- a/framework/Web/Javascripts/ratings/ratings.js
+++ b/framework/Web/Javascripts/ratings/ratings.js
@@ -1,6 +1,7 @@
Prado.WebUI.TRatingList = Base.extend(
{
selectedIndex : -1,
+ rating: -1,
enabled : true,
readOnly : false,
@@ -15,7 +16,10 @@ Prado.WebUI.TRatingList = Base.extend(
Prado.WebUI.TRatingList.register(this);
this._init();
this.selectedIndex = options.SelectedIndex;
- this.setRating(this.selectedIndex);
+ this.rating = options.Rating;
+ if(options.Rating <= 0 && options.SelectedIndex >= 0)
+ this.rating = options.SelectedIndex+1;
+ this.showRating(this.rating);
},
_init: function(options)
@@ -44,18 +48,20 @@ Prado.WebUI.TRatingList = Base.extend(
if(this.enabled==false) return;
for(var i = 0; i<this.radios.length; i++)
{
+ var node = this.radios[i].parentNode;
var action = i <= index ? 'addClassName' : 'removeClassName'
- Element[action](this.radios[i].parentNode,"rating_selected");
+ Element[action](node,"rating_hover");
+ Element.removeClassName(node,"rating_selected");
+ Element.removeClassName(node,"rating_half");
}
- this.setCaption(index);
+ this.showCaption(this.getIndexCaption(index));
},
recover : function(ev,index)
{
if(this.enabled==false) return;
- for(var i = 0; i<=index; i++)
- Element.removeClassName(this.radios[i].parentNode, "rating_selected");
- this.setRating(this.selectedIndex);
+ this.showRating(this.rating);
+ this.showCaption(this.options.caption);
},
click : function(ev, index)
@@ -63,38 +69,81 @@ Prado.WebUI.TRatingList = Base.extend(
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);
+ this.setRating(index+1);
+
+ this.dispatchRequest(ev);
+ },
+
+ dispatchRequest : function(ev)
+ {
var requestOptions = Object.extend(
{
- ID : this.options.ListID+"_c"+index,
- EventTarget : this.options.ListID+"$c"+index
+ ID : this.options.ListID+"_c"+this.selectedIndex,
+ EventTarget : this.options.ListName+"$c"+this.selectedIndex
},this.options);
var request = new Prado.CallbackRequest(requestOptions.EventTarget, requestOptions);
if(request.dispatch()==false)
Event.stop(ev);
},
- setRating: function(index)
+ setRating : function(value)
{
+ this.rating = value;
+ var base = Math.floor(value-1);
+ var remainder = value - base-1;
+ var halfMax = this.options.HalfRating["1"];
+ var index = remainder > halfMax ? base+1 : base;
+ for(var i = 0; i<this.radios.length; i++)
+ this.radios[i].checked = (i == index);
+
+ var caption = this.getIndexCaption(index);
+ this.setCaption(caption);
+ this.showCaption(caption);
+
+ this.showRating(value);
+ },
+ showRating: function(value)
+ {
+ var base = Math.floor(value-1);
+ var remainder = value - base-1;
+ var halfMin = this.options.HalfRating["0"];
+ var halfMax = this.options.HalfRating["1"];
+ var index = remainder > halfMax ? base+1 : base;
+ var hasHalf = remainder >= halfMin && remainder <= halfMax;
for(var i = 0; i<this.radios.length; i++)
{
var node = this.radios[i].parentNode;
- var action = i > index ? 'removeClassName' : 'addClassName'
- Element[action](this.radios[i].parentNode, "rating_selected");
+ var action = i > index ? 'removeClassName' : 'addClassName';
+ Element[action](node, "rating_selected");
+ if(i==index+1 && hasHalf)
+ Element.addClassName(node, "rating_half");
+ else
+ Element.removeClassName(node, "rating_half");
+ Element.removeClassName(node,"rating_hover");
}
- this.setCaption(index);
},
- setCaption : function(index)
+ getIndexCaption : function(index)
+ {
+ return index > -1 ? this.radios[index].value : this.options.caption;
+ },
+
+ showCaption : function(value)
{
- var value = index > -1 ? this.radios[index].value : this.options.caption;
var caption = $(this.options.CaptionID);
if(caption) caption.innerHTML = value;
$(this.options.ListID).title = value;
},
+ setCaption : function(value)
+ {
+ this.options.caption = value;
+ this.showCaption(value);
+ },
+
setEnabled : function(value)
{
this.enabled = value;
@@ -120,6 +169,10 @@ setEnabled : function(id,value)
setRating : function(id,value)
{
Prado.WebUI.TRatingList.ratings[id].setRating(value);
- Prado.WebUI.TRatingList.ratings[id].selectedIndex = value;
+},
+
+setCaption : function(id,value)
+{
+ Prado.WebUI.TRatingList.ratings[id].setCaption(value);
}
}); \ No newline at end of file