From 873c5bbd969d5699a8b40e60f5adc224b2b6d84d Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 10 Jan 2014 17:20:47 +0100 Subject: Ported TRatingList --- framework/Web/Javascripts/packages.php | 27 ++-- .../Javascripts/source/prado/ratings/ratings.js | 153 +++++++++------------ framework/Web/UI/WebControls/TRatingList.php | 2 +- 3 files changed, 77 insertions(+), 105 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/Javascripts/packages.php b/framework/Web/Javascripts/packages.php index dd55729e..19cda98b 100644 --- a/framework/Web/Javascripts/packages.php +++ b/framework/Web/Javascripts/packages.php @@ -64,6 +64,18 @@ $packages = array( 'prado/controls/htmlarea4.js' ), + 'accordion'=>array( + 'prado/controls/accordion.js' + ), + + 'inlineeditor' => array( + 'prado/activecontrols/inlineeditor.js' + ), + + 'ratings' => array( + 'prado/ratings/ratings.js', + ), + // jquery 'jquery' => array( JQUERY_DIR.'/jquery.js', @@ -89,18 +101,6 @@ $packages = array( 'prado/activecontrols/dragdropextra.js', ), - 'accordion'=>array( - 'prado/controls/accordion.js' - ), - - 'ratings' => array( - 'prado/ratings/ratings.js', - ), - - 'inlineeditor' => array( - 'prado/activecontrols/inlineeditor.js' - ), - 'autocomplete' => array( SCRIPTACULOUS_DIR.'/controls.js', 'prado/activecontrols/autocomplete.js' @@ -127,12 +127,11 @@ $dependencies = array( 'slider' => array('jquery', 'prado', 'slider'), 'inlineeditor' => array('jquery', 'prado', 'ajax', 'inlineeditor'), 'accordion' => array('jquery', 'prado', 'accordion'), + 'ratings' => array('jquery', 'prado', 'ajax', 'ratings'), 'jqueryui' => array('jquery', 'jqueryui'), - 'prototype' => array('prototype'), 'dragdrop' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop'), 'dragdropextra' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop','dragdropextra'), - 'ratings' => array('prototype', 'jquery', 'prado', 'ajax', 'ratings'), 'autocomplete' => array('prototype', 'jquery', 'prado', 'ajax', 'autocomplete'), ); diff --git a/framework/Web/Javascripts/source/prado/ratings/ratings.js b/framework/Web/Javascripts/source/prado/ratings/ratings.js index 1369c740..eb541b99 100644 --- a/framework/Web/Javascripts/source/prado/ratings/ratings.js +++ b/framework/Web/Javascripts/source/prado/ratings/ratings.js @@ -1,78 +1,67 @@ -Prado.WebUI.TRatingList = Base.extend( +Prado.WebUI.TRatingList = jQuery.klass(Prado.WebUI.Control, { selectedIndex : -1, rating: -1, readOnly : false, - constructor : function(options) + onInit : function(options) { - var cap = $(options.CaptionID); - this.options = Object.extend( + var cap = $('#'+options.CaptionID).get(0); + this.options = jQuery.extend( { caption : cap ? cap.innerHTML : '' }, options || {}); - Prado.WebUI.TRatingList.register(this); - this._init(); - Prado.Registry.set(options.ListID, this); - this.selectedIndex = options.SelectedIndex; - this.rating = options.Rating; - this.readOnly = options.ReadOnly - if(options.Rating <= 0 && options.SelectedIndex >= 0) - this.rating = options.SelectedIndex+1; - this.setReadOnly(this.readOnly); - }, + this.radios = []; - _init: function(options) - { - Element.addClassName($(this.options.ListID),this.options.Style); - this.radios = new Array(); - this._mouseOvers = new Array(); - this._mouseOuts = new Array(); - this._clicks = new Array(); - var index=0; - for(var i = 0; i= 0) + this.rating = options.SelectedIndex+1; + this.setReadOnly(this.readOnly); }, - hover : function(ev,index) + hover : function(index, ev) { if(this.readOnly==true) return; + for(var i = 0; i index ? 'removeClassName' : 'addClassName'; - Element[action](node, "rating_selected"); + if(i <= index) + $(node).addClass('rating_selected'); + else + $(node).removeClass('rating_selected'); + if(i==index+1 && hasHalf) - Element.addClassName(node, "rating_half"); + $(node).addClass("rating_half"); else - Element.removeClassName(node, "rating_half"); - Element.removeClassName(node,"rating_hover"); + $(node).removeClass("rating_half"); + $(node).removeClass("rating_hover"); } }, - + getIndexCaption : function(index) { return index > -1 ? this.radios[index].value : this.options.caption; @@ -136,9 +128,8 @@ Prado.WebUI.TRatingList = Base.extend( showCaption : function(value) { - var caption = $(this.options.CaptionID); - if(caption) caption.innerHTML = value; - $(this.options.ListID).title = value; + $('#'+this.options.CaptionID).html(value); + $('#'+this.options.ID).attr( "title", value); }, setCaption : function(value) @@ -152,55 +143,37 @@ Prado.WebUI.TRatingList = Base.extend( this.readOnly = value; for(var i = 0; igetCaptionID())!=='') { - if($control=$this->getParent()->findControl($id)) + if($control=$this->getPage()->findControl($id)) return $control; } throw new TInvalidDataValueException( -- cgit v1.2.3