summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorwei <>2007-03-30 00:38:41 +0000
committerwei <>2007-03-30 00:38:41 +0000
commit3fb25eec92c0c72760c4bf8040efd4b86c446bc6 (patch)
treea7c76d761f432b29dfa567c4e46acb62a7abf18b /framework
parenteddf47f3e36a30f6b905e4d667514eb34968ff8a (diff)
Fixed #579
Diffstat (limited to 'framework')
-rw-r--r--framework/I18N/core/MessageSource_XLIFF.php8
-rw-r--r--framework/Web/Javascripts/js/compressed/ajax.js32
-rw-r--r--framework/Web/Javascripts/js/compressed/prado.js15
-rw-r--r--framework/Web/Javascripts/js/debug/ajax.js179
-rw-r--r--framework/Web/Javascripts/js/debug/prado.js61
-rw-r--r--framework/Web/Javascripts/prado/activeratings/blocks.css42
-rw-r--r--framework/Web/Javascripts/prado/activeratings/blocks.pngbin0 -> 28700 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/blocks_blank.gifbin0 -> 72 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/blocks_combined.gifbin0 -> 289 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/blocks_half.gifbin0 -> 94 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/blocks_selected.gifbin0 -> 75 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/default.css43
-rw-r--r--framework/Web/Javascripts/prado/activeratings/default.pngbin0 -> 51492 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/default_blank.gifbin0 -> 158 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/default_combined.gifbin0 -> 1201 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/default_half.gifbin0 -> 610 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/default_selected.gifbin0 -> 603 bytes
-rw-r--r--framework/Web/Javascripts/prado/activeratings/ratings.js178
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRatingList.php16
19 files changed, 563 insertions, 11 deletions
diff --git a/framework/I18N/core/MessageSource_XLIFF.php b/framework/I18N/core/MessageSource_XLIFF.php
index eafc0983..64277e7b 100644
--- a/framework/I18N/core/MessageSource_XLIFF.php
+++ b/framework/I18N/core/MessageSource_XLIFF.php
@@ -150,7 +150,13 @@ class MessageSource_XLIFF extends MessageSource
$byDir = $this->getCatalogueByDir($catalogue);
$catalogues = array_merge($byDir,array_reverse($catalogues));
- return $catalogues;
+ $files = array();
+ foreach($catalogues as $file)
+ {
+ $files[] = $file;
+ $files[] = preg_replace('/\.xml$/', '.xlf', $file);
+ }
+ return $files;
}
/**
diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js
index 7f08d38c..d67d6adb 100644
--- a/framework/Web/Javascripts/js/compressed/ajax.js
+++ b/framework/Web/Javascripts/js/compressed/ajax.js
@@ -315,4 +315,34 @@ this.options.onFailure(sender,parameter);}},{textboxes:{},register:function(obj)
{var textbox=Prado.WebUI.TInPlaceTextBox.textboxes[id];if(textbox)
{if(value)
textbox.enterEditMode(null);else
-{textbox.exitEditMode(null);}}}}); \ No newline at end of file
+{textbox.exitEditMode(null);}}}});Prado.WebUI.TActiveRatingList=Base.extend({selectedIndex:-1,rating:-1,enabled:true,readOnly:false,constructor:function(options)
+{var cap=$(options.CaptionID);this.options=Object.extend({caption:cap?cap.innerHTML:''},options||{});Prado.WebUI.TActiveRatingList.register(this);this._init();this.selectedIndex=options.SelectedIndex;this.rating=options.Rating;if(options.Rating<=0&&options.SelectedIndex>=0)
+this.rating=options.SelectedIndex+1;this.showRating(this.rating);},_init:function(options)
+{Element.addClassName($(this.options.ListID),this.options.Style);this.radios=new Array();var index=0;for(var i=0;i<this.options.ItemCount;i++)
+{var radio=$(this.options.ListID+'_c'+i);var td=radio.parentNode;if(radio&&td.tagName.toLowerCase()=='td')
+{this.radios.push(radio);Event.observe(td,"mouseover",this.hover.bindEvent(this,index));Event.observe(td,"mouseout",this.recover.bindEvent(this,index));Event.observe(td,"click",this.click.bindEvent(this,index));index++;Element.addClassName(td,"rating");}}},hover:function(ev,index)
+{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](node,"rating_hover");Element.removeClassName(node,"rating_selected");Element.removeClassName(node,"rating_half");}
+this.showCaption(this.getIndexCaption(index));},recover:function(ev,index)
+{if(this.enabled==false)return;this.showRating(this.rating);this.showCaption(this.options.caption);},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+1);this.dispatchRequest(ev);},dispatchRequest:function(ev)
+{var requestOptions=Object.extend({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(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](node,"rating_selected");if(i==index+1&&hasHalf)
+Element.addClassName(node,"rating_half");else
+Element.removeClassName(node,"rating_half");Element.removeClassName(node,"rating_hover");}},getIndexCaption:function(index)
+{return index>-1?this.radios[index].value:this.options.caption;},showCaption:function(value)
+{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;for(var i=0;i<this.radios.length;i++)
+{var action=value?'removeClassName':'addClassName'
+Element[action](this.radios[i].parentNode,"rating_disabled");}}},{ratings:{},register:function(rating)
+{Prado.WebUI.TActiveRatingList.ratings[rating.options.ListID]=rating;},setEnabled:function(id,value)
+{Prado.WebUI.TActiveRatingList.ratings[id].setEnabled(value);},setRating:function(id,value)
+{Prado.WebUI.TActiveRatingList.ratings[id].setRating(value);},setCaption:function(id,value)
+{Prado.WebUI.TActiveRatingList.ratings[id].setCaption(value);}}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/js/compressed/prado.js b/framework/Web/Javascripts/js/compressed/prado.js
index 74c50356..9912b1fc 100644
--- a/framework/Web/Javascripts/js/compressed/prado.js
+++ b/framework/Web/Javascripts/js/compressed/prado.js
@@ -502,4 +502,17 @@ window.clipboardData.setData("Text",text);},hover:function(obj)
{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.TCheckBox(checkBoxOptions);}}});Prado.WebUI.TRadioButtonList=Base.extend({constructor:function(options)
{for(var i=0;i<options.ItemCount;i++)
-{var radioButtonOptions=Object.extend({ID:options.ListID+"_c"+i,EventTarget:options.ListName+"$c"+i},options);new Prado.WebUI.TRadioButton(radioButtonOptions);}}}); \ No newline at end of file
+{var radioButtonOptions=Object.extend({ID:options.ListID+"_c"+i,EventTarget:options.ListName+"$c"+i},options);new Prado.WebUI.TRadioButton(radioButtonOptions);}}});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);this.radios=document.getElementsByName(options.field);for(var i=0;i<this.radios.length;i++)
+{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;this.setRating(this.selectedIndex);},hover:function(ev,index)
+{for(var i=0;i<this.radios.length;i++)
+this.radios[i].parentNode.className=(i<=index)?"rating_hover":"";this.setCaption(index);},recover:function(ev,index)
+{for(var i=0;i<=index;i++)
+Element.removeClassName(this.radios[i].parentNode,"rating_hover");this.setRating(this.selectedIndex);},click:function(ev,index)
+{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);},setRating:function(index)
+{for(var i=0;i<=index;i++)
+this.radios[i].parentNode.className="rating_selected";this.setCaption(index);},setCaption:function(index)
+{this.caption.innerHTML=index>-1?this.radios[index].value:this.options.caption;}} \ No newline at end of file
diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js
index 60956194..6ae0ab40 100644
--- a/framework/Web/Javascripts/js/debug/ajax.js
+++ b/framework/Web/Javascripts/js/debug/ajax.js
@@ -2472,3 +2472,182 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
}
});
+Prado.WebUI.TActiveRatingList = Base.extend(
+{
+ selectedIndex : -1,
+ rating: -1,
+ enabled : true,
+ readOnly : false,
+
+ constructor : function(options)
+ {
+ var cap = $(options.CaptionID);
+ this.options = Object.extend(
+ {
+ caption : cap ? cap.innerHTML : ''
+ }, options || {});
+
+ Prado.WebUI.TActiveRatingList.register(this);
+ this._init();
+ this.selectedIndex = options.SelectedIndex;
+ this.rating = options.Rating;
+ if(options.Rating <= 0 && options.SelectedIndex >= 0)
+ this.rating = options.SelectedIndex+1;
+ this.showRating(this.rating);
+ },
+
+ _init: function(options)
+ {
+ Element.addClassName($(this.options.ListID),this.options.Style);
+ this.radios = new Array();
+ var index=0;
+ for(var i = 0; i<this.options.ItemCount; i++)
+ {
+ var radio = $(this.options.ListID+'_c'+i);
+ var td = radio.parentNode;
+ if(radio && td.tagName.toLowerCase()=='td')
+ {
+ this.radios.push(radio);
+ Event.observe(td, "mouseover", this.hover.bindEvent(this,index));
+ Event.observe(td, "mouseout", this.recover.bindEvent(this,index));
+ Event.observe(td, "click", this.click.bindEvent(this, index));
+ index++;
+ Element.addClassName(td,"rating");
+ }
+ }
+ },
+
+ hover : function(ev,index)
+ {
+ 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](node,"rating_hover");
+ Element.removeClassName(node,"rating_selected");
+ Element.removeClassName(node,"rating_half");
+ }
+ this.showCaption(this.getIndexCaption(index));
+ },
+
+ recover : function(ev,index)
+ {
+ if(this.enabled==false) return;
+ this.showRating(this.rating);
+ this.showCaption(this.options.caption);
+ },
+
+ 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+1);
+
+ this.dispatchRequest(ev);
+ },
+
+ dispatchRequest : function(ev)
+ {
+ var requestOptions = Object.extend(
+ {
+ 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(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](node, "rating_selected");
+ if(i==index+1 && hasHalf)
+ Element.addClassName(node, "rating_half");
+ else
+ Element.removeClassName(node, "rating_half");
+ Element.removeClassName(node,"rating_hover");
+ }
+ },
+
+ getIndexCaption : function(index)
+ {
+ return index > -1 ? this.radios[index].value : this.options.caption;
+ },
+
+ showCaption : function(value)
+ {
+ 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;
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = value ? 'removeClassName' : 'addClassName'
+ Element[action](this.radios[i].parentNode, "rating_disabled");
+ }
+ }
+},
+{
+ratings : {},
+register : function(rating)
+{
+ Prado.WebUI.TActiveRatingList.ratings[rating.options.ListID] = rating;
+},
+
+setEnabled : function(id,value)
+{
+ Prado.WebUI.TActiveRatingList.ratings[id].setEnabled(value);
+},
+
+setRating : function(id,value)
+{
+ Prado.WebUI.TActiveRatingList.ratings[id].setRating(value);
+},
+
+setCaption : function(id,value)
+{
+ Prado.WebUI.TActiveRatingList.ratings[id].setCaption(value);
+}
+});
+
diff --git a/framework/Web/Javascripts/js/debug/prado.js b/framework/Web/Javascripts/js/debug/prado.js
index 1388135d..0e815b99 100644
--- a/framework/Web/Javascripts/js/debug/prado.js
+++ b/framework/Web/Javascripts/js/debug/prado.js
@@ -4670,3 +4670,64 @@ Prado.WebUI.TRadioButtonList = Base.extend(
}
});
+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);
+ this.radios = document.getElementsByName(options.field);
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ 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;
+ this.setRating(this.selectedIndex);
+ },
+
+ hover : function(ev,index)
+ {
+ for(var i = 0; i<this.radios.length; i++)
+ this.radios[i].parentNode.className = (i<=index) ? "rating_hover" : "";
+ this.setCaption(index);
+ },
+
+ recover : function(ev,index)
+ {
+ for(var i = 0; i<=index; i++)
+ Element.removeClassName(this.radios[i].parentNode, "rating_hover");
+ this.setRating(this.selectedIndex);
+ },
+
+ click : function(ev, index)
+ {
+ 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);
+ },
+
+ setRating: function(index)
+ {
+ for(var i = 0; i<=index; i++)
+ this.radios[i].parentNode.className = "rating_selected";
+ this.setCaption(index);
+ },
+
+ setCaption : function(index)
+ {
+ this.caption.innerHTML = index > -1 ?
+ this.radios[index].value : this.options.caption;
+ }
+}
+
diff --git a/framework/Web/Javascripts/prado/activeratings/blocks.css b/framework/Web/Javascripts/prado/activeratings/blocks.css
new file mode 100644
index 00000000..bb846094
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/blocks.css
@@ -0,0 +1,42 @@
+.TActiveRatingList_blocks
+{
+ border-collapse: collapse;
+}
+.TActiveRatingList_blocks input, .TActiveRatingList_blocks label
+{
+ display: none;
+}
+
+.TActiveRatingList_blocks td
+{
+ width: 18px;
+ height: 9px;
+ padding: 1px;
+}
+
+.TActiveRatingList_blocks td.rating
+{
+ background-image: url(blocks_combined.gif);
+ background-repeat: no-repeat;
+ cursor: pointer;
+ background-position: 1px 0px;
+}
+.TActiveRatingList_blocks td.rating_selected
+{
+ background-position: 1px -100px;
+}
+
+.TActiveRatingList_blocks td.rating_half
+{
+ background-position: 1px -200px;
+}
+
+.TActiveRatingList_blocks td.rating_hover
+{
+ background-position: 1px -300px;
+}
+
+.TActiveRatingList_blocks td.rating_disabled
+{
+ cursor: default !important;
+}
diff --git a/framework/Web/Javascripts/prado/activeratings/blocks.png b/framework/Web/Javascripts/prado/activeratings/blocks.png
new file mode 100644
index 00000000..93a5333e
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/blocks.png
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/blocks_blank.gif b/framework/Web/Javascripts/prado/activeratings/blocks_blank.gif
new file mode 100644
index 00000000..c0db17c2
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/blocks_blank.gif
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/blocks_combined.gif b/framework/Web/Javascripts/prado/activeratings/blocks_combined.gif
new file mode 100644
index 00000000..dfe9da8d
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/blocks_combined.gif
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/blocks_half.gif b/framework/Web/Javascripts/prado/activeratings/blocks_half.gif
new file mode 100644
index 00000000..a9e23d7c
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/blocks_half.gif
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/blocks_selected.gif b/framework/Web/Javascripts/prado/activeratings/blocks_selected.gif
new file mode 100644
index 00000000..f743d27e
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/blocks_selected.gif
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/default.css b/framework/Web/Javascripts/prado/activeratings/default.css
new file mode 100644
index 00000000..ba90eb27
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/default.css
@@ -0,0 +1,43 @@
+.TActiveRatingList_default
+{
+ border-collapse: collapse;
+}
+.TActiveRatingList_default input, .TActiveRatingList_default label
+{
+ display: none;
+}
+
+.TActiveRatingList_default td
+{
+ width: 18px;
+ height: 18px;
+ padding: 0;
+}
+
+.TActiveRatingList_default td.rating
+{
+ background-image: url(default_combined.gif);
+ background-repeat: no-repeat;
+ cursor: pointer;
+ background-position: 0px 0px;
+}
+
+.TActiveRatingList_default td.rating_selected
+{
+ background-position: 0px -100px;
+}
+
+.TActiveRatingList_default td.rating_half
+{
+ background-position: 0px -200px;
+}
+
+.TActiveRatingList_default td.rating_hover
+{
+ background-position: 0px -300px;
+}
+
+.TActiveRatingList_default td.rating_disabled
+{
+ cursor: default !important;
+} \ No newline at end of file
diff --git a/framework/Web/Javascripts/prado/activeratings/default.png b/framework/Web/Javascripts/prado/activeratings/default.png
new file mode 100644
index 00000000..a3148ff4
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/default.png
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/default_blank.gif b/framework/Web/Javascripts/prado/activeratings/default_blank.gif
new file mode 100644
index 00000000..0337ad16
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/default_blank.gif
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/default_combined.gif b/framework/Web/Javascripts/prado/activeratings/default_combined.gif
new file mode 100644
index 00000000..ddab2e8b
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/default_combined.gif
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/default_half.gif b/framework/Web/Javascripts/prado/activeratings/default_half.gif
new file mode 100644
index 00000000..ed214acd
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/default_half.gif
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/default_selected.gif b/framework/Web/Javascripts/prado/activeratings/default_selected.gif
new file mode 100644
index 00000000..98704fad
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/default_selected.gif
Binary files differ
diff --git a/framework/Web/Javascripts/prado/activeratings/ratings.js b/framework/Web/Javascripts/prado/activeratings/ratings.js
new file mode 100644
index 00000000..884a695a
--- /dev/null
+++ b/framework/Web/Javascripts/prado/activeratings/ratings.js
@@ -0,0 +1,178 @@
+Prado.WebUI.TActiveRatingList = Base.extend(
+{
+ selectedIndex : -1,
+ rating: -1,
+ enabled : true,
+ readOnly : false,
+
+ constructor : function(options)
+ {
+ var cap = $(options.CaptionID);
+ this.options = Object.extend(
+ {
+ caption : cap ? cap.innerHTML : ''
+ }, options || {});
+
+ Prado.WebUI.TActiveRatingList.register(this);
+ this._init();
+ this.selectedIndex = options.SelectedIndex;
+ this.rating = options.Rating;
+ if(options.Rating <= 0 && options.SelectedIndex >= 0)
+ this.rating = options.SelectedIndex+1;
+ this.showRating(this.rating);
+ },
+
+ _init: function(options)
+ {
+ Element.addClassName($(this.options.ListID),this.options.Style);
+ this.radios = new Array();
+ var index=0;
+ for(var i = 0; i<this.options.ItemCount; i++)
+ {
+ var radio = $(this.options.ListID+'_c'+i);
+ var td = radio.parentNode;
+ if(radio && td.tagName.toLowerCase()=='td')
+ {
+ this.radios.push(radio);
+ Event.observe(td, "mouseover", this.hover.bindEvent(this,index));
+ Event.observe(td, "mouseout", this.recover.bindEvent(this,index));
+ Event.observe(td, "click", this.click.bindEvent(this, index));
+ index++;
+ Element.addClassName(td,"rating");
+ }
+ }
+ },
+
+ hover : function(ev,index)
+ {
+ 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](node,"rating_hover");
+ Element.removeClassName(node,"rating_selected");
+ Element.removeClassName(node,"rating_half");
+ }
+ this.showCaption(this.getIndexCaption(index));
+ },
+
+ recover : function(ev,index)
+ {
+ if(this.enabled==false) return;
+ this.showRating(this.rating);
+ this.showCaption(this.options.caption);
+ },
+
+ 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+1);
+
+ this.dispatchRequest(ev);
+ },
+
+ dispatchRequest : function(ev)
+ {
+ var requestOptions = Object.extend(
+ {
+ 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(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](node, "rating_selected");
+ if(i==index+1 && hasHalf)
+ Element.addClassName(node, "rating_half");
+ else
+ Element.removeClassName(node, "rating_half");
+ Element.removeClassName(node,"rating_hover");
+ }
+ },
+
+ getIndexCaption : function(index)
+ {
+ return index > -1 ? this.radios[index].value : this.options.caption;
+ },
+
+ showCaption : function(value)
+ {
+ 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;
+ for(var i = 0; i<this.radios.length; i++)
+ {
+ var action = value ? 'removeClassName' : 'addClassName'
+ Element[action](this.radios[i].parentNode, "rating_disabled");
+ }
+ }
+},
+{
+ratings : {},
+register : function(rating)
+{
+ Prado.WebUI.TActiveRatingList.ratings[rating.options.ListID] = rating;
+},
+
+setEnabled : function(id,value)
+{
+ Prado.WebUI.TActiveRatingList.ratings[id].setEnabled(value);
+},
+
+setRating : function(id,value)
+{
+ Prado.WebUI.TActiveRatingList.ratings[id].setRating(value);
+},
+
+setCaption : function(id,value)
+{
+ Prado.WebUI.TActiveRatingList.ratings[id].setCaption(value);
+}
+}); \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TActiveRatingList.php b/framework/Web/UI/ActiveControls/TActiveRatingList.php
index f6070151..5f0a24ff 100644
--- a/framework/Web/UI/ActiveControls/TActiveRatingList.php
+++ b/framework/Web/UI/ActiveControls/TActiveRatingList.php
@@ -185,7 +185,7 @@ class TActiveRatingList extends TActiveRadioButtonList
}
/**
- * @return TRatingListStyle current rating style
+ * @return TActiveRatingListStyle current rating style
*/
public function getRatingStyle()
{
@@ -216,7 +216,7 @@ class TActiveRatingList extends TActiveRadioButtonList
*/
protected function getRatingStyleCssClass()
{
- return 'TRatingList_'.$this->getRatingStyle();
+ return 'TActiveRatingList_'.$this->getRatingStyle();
}
/**
@@ -268,7 +268,7 @@ class TActiveRatingList extends TActiveRadioButtonList
protected function publishRatingListStyle($style)
{
$cs = $this->getPage()->getClientScript();
- $stylesheet = 'System.Web.Javascripts.ratings.'.$style;
+ $stylesheet = 'System.Web.Javascripts.prado.activeratings.'.$style;
if(($cssFile=Prado::getPathOfNamespace($stylesheet,'.css'))===null)
throw new TConfigurationException('ratinglist_stylesheet_not_found',$style);
$url = $this->publishFilePath($cssFile);
@@ -284,10 +284,10 @@ class TActiveRatingList extends TActiveRadioButtonList
*/
protected function publishRatingListImages($style, $fileExt='.gif')
{
- $images['blank'] = "System.Web.Javascripts.ratings.{$style}_blank";
- $images['selected'] = "System.Web.Javascripts.ratings.{$style}_selected";
- $images['half'] = "System.Web.Javascripts.ratings.{$style}_half";
- $images['combined'] = "System.Web.Javascripts.ratings.{$style}_combined";
+ $images['blank'] = "System.Web.Javascripts.prado.activeratings.{$style}_blank";
+ $images['selected'] = "System.Web.Javascripts.prado.activeratings.{$style}_selected";
+ $images['half'] = "System.Web.Javascripts.prado.activeratings.{$style}_half";
+ $images['combined'] = "System.Web.Javascripts.prado.activeratings.{$style}_combined";
$files = array();
foreach($images as $type => $image)
{
@@ -368,7 +368,7 @@ class TActiveRatingList extends TActiveRadioButtonList
*/
protected function getClientClassName()
{
- return 'Prado.WebUI.TRatingList';
+ return 'Prado.WebUI.TActiveRatingList';
}
}