diff options
Diffstat (limited to 'framework/Web/Javascripts/ratings')
22 files changed, 126 insertions, 39 deletions
diff --git a/framework/Web/Javascripts/ratings/blocks.css b/framework/Web/Javascripts/ratings/blocks.css index 2bf2e904..63cb7c2b 100644 --- a/framework/Web/Javascripts/ratings/blocks.css +++ b/framework/Web/Javascripts/ratings/blocks.css @@ -6,24 +6,36 @@ {
display: none;
}
+
.TRatingList_blocks td
{
- width: 17px;
- height: 18px;
- background-image: url(blocks_blank.gif);
+ width: 18px;
+ height: 9px;
+ padding: 1px;
+}
+
+.TRatingList_blocks td.rating
+{
+ background-image: url(blocks_combined.png);
background-repeat: no-repeat;
cursor: pointer;
+ background-position: 1px 0px;
}
.TRatingList_blocks td.rating_selected
{
- background-image: url(blocks_selected.gif);
+ background-position: 1px -100px;
}
.TRatingList_blocks td.rating_hover
{
- background-image: url(blocks_hover.gif);
+ background-position: 1px -200px;
}
.TRatingList_blocks td.rating_half
{
- background-image: url(blocks_half.gif);
+ 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 Binary files differindex 16a2b249..923cda09 100644 --- a/framework/Web/Javascripts/ratings/blocks.png +++ b/framework/Web/Javascripts/ratings/blocks.png diff --git a/framework/Web/Javascripts/ratings/blocks_blank.gif b/framework/Web/Javascripts/ratings/blocks_blank.gif Binary files differdeleted file mode 100644 index a68d0e94..00000000 --- a/framework/Web/Javascripts/ratings/blocks_blank.gif +++ /dev/null diff --git a/framework/Web/Javascripts/ratings/blocks_blank.png b/framework/Web/Javascripts/ratings/blocks_blank.png Binary files differnew file mode 100644 index 00000000..d5004d2d --- /dev/null +++ b/framework/Web/Javascripts/ratings/blocks_blank.png diff --git a/framework/Web/Javascripts/ratings/blocks_combined.png b/framework/Web/Javascripts/ratings/blocks_combined.png Binary files differnew file mode 100644 index 00000000..57c07672 --- /dev/null +++ b/framework/Web/Javascripts/ratings/blocks_combined.png diff --git a/framework/Web/Javascripts/ratings/blocks_half.gif b/framework/Web/Javascripts/ratings/blocks_half.gif Binary files differdeleted file mode 100644 index 4cff0148..00000000 --- a/framework/Web/Javascripts/ratings/blocks_half.gif +++ /dev/null diff --git a/framework/Web/Javascripts/ratings/blocks_half.png b/framework/Web/Javascripts/ratings/blocks_half.png Binary files differnew file mode 100644 index 00000000..344aa207 --- /dev/null +++ b/framework/Web/Javascripts/ratings/blocks_half.png diff --git a/framework/Web/Javascripts/ratings/blocks_hover.gif b/framework/Web/Javascripts/ratings/blocks_hover.gif Binary files differdeleted file mode 100644 index 58ad7495..00000000 --- a/framework/Web/Javascripts/ratings/blocks_hover.gif +++ /dev/null diff --git a/framework/Web/Javascripts/ratings/blocks_selected.gif b/framework/Web/Javascripts/ratings/blocks_selected.gif Binary files differdeleted file mode 100644 index f91873e2..00000000 --- a/framework/Web/Javascripts/ratings/blocks_selected.gif +++ /dev/null diff --git a/framework/Web/Javascripts/ratings/blocks_selected.png b/framework/Web/Javascripts/ratings/blocks_selected.png Binary files differnew file mode 100644 index 00000000..dfdb6889 --- /dev/null +++ b/framework/Web/Javascripts/ratings/blocks_selected.png diff --git a/framework/Web/Javascripts/ratings/default.css b/framework/Web/Javascripts/ratings/default.css index c15a36bd..cf8f7558 100644 --- a/framework/Web/Javascripts/ratings/default.css +++ b/framework/Web/Javascripts/ratings/default.css @@ -6,24 +6,36 @@ {
display: none;
}
+
.TRatingList_default td
{
- width: 17px;
+ width: 18px;
height: 18px;
- background-image: url(default_blank.gif);
+ padding: 0;
+}
+
+.TRatingList_default td.rating
+{
+ background-image: url(default_combined.png);
background-repeat: no-repeat;
cursor: pointer;
+ background-position: 0px 0px;
}
.TRatingList_default td.rating_selected
{
- background-image: url(default_selected.gif);
+ background-position: 0px -100px;
}
.TRatingList_default td.rating_hover
{
- background-image: url(default_hover.gif);
+ background-position: 0px -200px;
}
.TRatingList_default td.rating_half
{
- background-image: url(default_half.gif);
+ background-position: 0px -300px;
}
+
+.TRatingList_default td.rating_disabled
+{
+ cursor: default !important;
+}
\ No newline at end of file diff --git a/framework/Web/Javascripts/ratings/default.png b/framework/Web/Javascripts/ratings/default.png Binary files differnew file mode 100644 index 00000000..f9f380a9 --- /dev/null +++ b/framework/Web/Javascripts/ratings/default.png diff --git a/framework/Web/Javascripts/ratings/default_blank.gif b/framework/Web/Javascripts/ratings/default_blank.gif Binary files differdeleted file mode 100644 index 4e6fda3c..00000000 --- a/framework/Web/Javascripts/ratings/default_blank.gif +++ /dev/null diff --git a/framework/Web/Javascripts/ratings/default_blank.png b/framework/Web/Javascripts/ratings/default_blank.png Binary files differnew file mode 100644 index 00000000..f857ff17 --- /dev/null +++ b/framework/Web/Javascripts/ratings/default_blank.png diff --git a/framework/Web/Javascripts/ratings/default_combined.png b/framework/Web/Javascripts/ratings/default_combined.png Binary files differnew file mode 100644 index 00000000..1756f912 --- /dev/null +++ b/framework/Web/Javascripts/ratings/default_combined.png diff --git a/framework/Web/Javascripts/ratings/default_half.gif b/framework/Web/Javascripts/ratings/default_half.gif Binary files differdeleted file mode 100644 index 7cecf0ec..00000000 --- a/framework/Web/Javascripts/ratings/default_half.gif +++ /dev/null diff --git a/framework/Web/Javascripts/ratings/default_half.png b/framework/Web/Javascripts/ratings/default_half.png Binary files differnew file mode 100644 index 00000000..6c826054 --- /dev/null +++ b/framework/Web/Javascripts/ratings/default_half.png diff --git a/framework/Web/Javascripts/ratings/default_hover.gif b/framework/Web/Javascripts/ratings/default_hover.gif Binary files differdeleted file mode 100644 index ad0cd28a..00000000 --- a/framework/Web/Javascripts/ratings/default_hover.gif +++ /dev/null diff --git a/framework/Web/Javascripts/ratings/default_selected.gif b/framework/Web/Javascripts/ratings/default_selected.gif Binary files differdeleted file mode 100644 index a19ab39f..00000000 --- a/framework/Web/Javascripts/ratings/default_selected.gif +++ /dev/null diff --git a/framework/Web/Javascripts/ratings/default_selected.png b/framework/Web/Javascripts/ratings/default_selected.png Binary files differnew file mode 100644 index 00000000..e40d6b04 --- /dev/null +++ b/framework/Web/Javascripts/ratings/default_selected.png diff --git a/framework/Web/Javascripts/ratings/ratings.js b/framework/Web/Javascripts/ratings/ratings.js index e6fd97ba..04ebd31d 100644 --- a/framework/Web/Javascripts/ratings/ratings.js +++ b/framework/Web/Javascripts/ratings/ratings.js @@ -1,60 +1,123 @@ -Prado.WebUI.TRatingList = Class.create();
-Prado.WebUI.TRatingList.prototype =
+Prado.WebUI.TRatingList = Base.extend(
{
selectedIndex : -1,
+ enabled : true,
- initialize : function(options)
+ constructor : function(options)
{
- this.options = options;
- this.element = $(options['ID']);
- Element.addClassName(this.element,options.cssClass);
- this.radios = document.getElementsByName(options.field);
- for(var i = 0; i<this.radios.length; i++)
+ var cap = $(options.CaptionID);
+ this.options = Object.extend(
{
- Event.observe(this.radios[i].parentNode, "mouseover", this.hover.bindEvent(this,i));
- Event.observe(this.radios[i].parentNode, "mouseout", this.recover.bindEvent(this,i));
- Event.observe(this.radios[i].parentNode, "click", this.click.bindEvent(this, i));
- }
- this.caption = CAPTION();
- this.element.appendChild(this.caption);
- this.selectedIndex = options.selectedIndex;
+ 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++)
- this.radios[i].parentNode.className = (i<=index) ? "rating_hover" : "";
+ {
+ 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);
- if(isFunction(this.options.onChange))
- this.options.onChange(this,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<=index; i++)
- this.radios[i].parentNode.className = "rating_selected";
+ 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)
{
- this.caption.innerHTML = index > -1 ?
- this.radios[index].value : this.options.caption;
+ 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");
+ }
}
-}
\ No newline at end of file +},
+{
+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;
+}
+});
\ No newline at end of file diff --git a/framework/Web/Javascripts/ratings/stars1.png b/framework/Web/Javascripts/ratings/stars1.png Binary files differdeleted file mode 100644 index e4dd3c25..00000000 --- a/framework/Web/Javascripts/ratings/stars1.png +++ /dev/null |