Author: nei_rauni
Date: 2010-09-21 22:41:01 +0200 (Tue, 21 Sep 2010)
New Revision: 30949

Added:
   plugins/mpStarRatingPlugin/trunk/LICENSE
   plugins/mpStarRatingPlugin/trunk/README
   plugins/mpStarRatingPlugin/trunk/lib/
   plugins/mpStarRatingPlugin/trunk/lib/mpWidgetFormChoiceRating.class.php
   plugins/mpStarRatingPlugin/trunk/package.xml
   plugins/mpStarRatingPlugin/trunk/web/
   plugins/mpStarRatingPlugin/trunk/web/css/
   plugins/mpStarRatingPlugin/trunk/web/css/jquery.ui.stars.css
   plugins/mpStarRatingPlugin/trunk/web/css/jquery.ui.stars.min.css
   plugins/mpStarRatingPlugin/trunk/web/images/
   plugins/mpStarRatingPlugin/trunk/web/images/crystal-stars.png
   plugins/mpStarRatingPlugin/trunk/web/images/jquery.ui.stars.gif
   plugins/mpStarRatingPlugin/trunk/web/js/
   plugins/mpStarRatingPlugin/trunk/web/js/jquery.ui.stars.js
   plugins/mpStarRatingPlugin/trunk/web/js/jquery.ui.stars.min.js
Log:
add the plugin on version control

Added: plugins/mpStarRatingPlugin/trunk/LICENSE
===================================================================
--- plugins/mpStarRatingPlugin/trunk/LICENSE                            (rev 0)
+++ plugins/mpStarRatingPlugin/trunk/LICENSE    2010-09-21 20:41:01 UTC (rev 
30949)
@@ -0,0 +1,19 @@
+Copyright (c) 2010 Nei Rauni Santos
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

Added: plugins/mpStarRatingPlugin/trunk/README
===================================================================
--- plugins/mpStarRatingPlugin/trunk/README                             (rev 0)
+++ plugins/mpStarRatingPlugin/trunk/README     2010-09-21 20:41:01 UTC (rev 
30949)
@@ -0,0 +1,50 @@
+mpWidgetFormChoiceRatingPlugin
+=================
+
+The `mpWidgetFormChoiceRatingPlugin` is a widget created to show radio butons 
of rating like stars.
+
+This collection starts with only a widget and have external dependencies of 
jquery.
+
+Installation
+------------
+
+  * Install the plugin
+
+        $ symfony plugin:install mpWidgetFormChoiceRatingPlugin
+
+  * Clear the cache
+
+        $ symfony cache:clear
+        $ symfony plugin:publish-assets
+
+  * Use the widget overriting your form widget generated by doctrine or your 
custom form
+  
+  <pre><code>
+  $options = array(0 => 'Não sei', 1 => 'Péssimo', 2 => 'Aceitável', 3 => 
'Mediano', 4 => 'Muito bom', 5 => 'Excelente');
+  $widgets = $this->getWidgetSchema();
+  $widgets['rating_comfort'] = new mpWidgetFormChoiceRating( array('choices' 
=> $options ) );
+  $widgets['rating_room'] = new mpWidgetFormChoiceRating( array('choices' => 
$options ) );
+  $widgets['rating_service'] = new mpWidgetFormChoiceRating( array('choices' 
=> $options ) );
+  </code></pre>
+  
+  * make sure you already have the jquery js in the page, so download the ui 
files from jquery website and put in 
+  web/jquery/jquery.ui/ui/ui.core.js
+  web/jquery/jquery.ui/ui/jquery.ui.widget.js
+      
+  * that's all folks.
+  
+Documentation
+-------------
+
+All classes have full API and usage documentation. The best way to learn each 
widget or validator
+is to read the API.
+
+Widgets
+-------
+
+  * mpWidgetFormChoiceRating: Change the default radio options by starts using 
javascript (extends sfWidgetFormChoice)
+  
+As no third party libraries is bundled in the plugin, you need to install and 
load the required
+dependencies like JQuery and JQuery UI.
+
+It's based on Star Rating widget ( 
http://plugins.jquery.com/project/Star_Rating_widget )

Added: plugins/mpStarRatingPlugin/trunk/lib/mpWidgetFormChoiceRating.class.php
===================================================================
--- plugins/mpStarRatingPlugin/trunk/lib/mpWidgetFormChoiceRating.class.php     
                        (rev 0)
+++ plugins/mpStarRatingPlugin/trunk/lib/mpWidgetFormChoiceRating.class.php     
2010-09-21 20:41:01 UTC (rev 30949)
@@ -0,0 +1,121 @@
+<?php
+
+/*
+ * This file is extra widget used for our symfony projects.
+ * (c) Nei Rauni Santos <[email protected]>
+ * 
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ * 
+ * To see more about the star reting documentation see 
http://orkans-tmp.22web.net/star_rating/
+ */
+
+/**
+ * mpWidgetFormChoiceRating represents a choice widget with javascript code to 
present as stars options.
+ *
+ * @package    symfony
+ * @subpackage widget
+ * @author     Nei Rauni Santos <[email protected]>
+ * @version    SVN: $Id: mpWidgetFormChoiceRating.class.php 11539 2010-05-10 
15:23:48Z nrauni $
+ */
+class mpWidgetFormChoiceRating extends sfWidgetFormChoice
+{
+  /**
+   * @param array $options     An array of options
+   * @param array $attributes  An array of default HTML attributes
+   *
+   * @see sfWidgetFormChoice
+   */
+  protected function configure($options = array(), $attributes = array())
+  {
+    parent::configure($options, $attributes);
+
+    $this->setOption('multiple', false);
+    $this->setOption('expanded', true);
+  }
+  
+
+  /**
+    * @param  string $name        The element name
+    * @param  string $value       The value selected in this widget
+    * @param  array  $attributes  An array of HTML attributes to be merged 
with the default HTML attributes
+    * @param  array  $errors      An array of errors for the field
+    *
+    * @return string An HTML tag string
+    *
+    * @see sfWidgetForm
+    */
+
+  public function render($name, $value = null, $attributes = array(), $errors 
= array())
+  {
+    if ($this->getOption('multiple'))
+    {
+      $attributes['multiple'] = 'multiple';
+
+      if ('[]' != substr($name, -2))
+      {
+        $name .= '[]';
+      }
+    }
+
+    if (!$this->getOption('renderer') && !$this->getOption('renderer_class') 
&& $this->getOption('expanded'))
+    {
+      unset($attributes['multiple']);
+    }
+    
+    $output = '<div id="wrapper_'.$this->generateId( $name ).'" 
class="starify">';
+    $output .= $this->getRenderer()->render($name, $value, $attributes, 
$errors);
+     
+$output .= <<<CODESJAVASCRIPT
+    </div>
+    
+    <script type="text/javascript">
+    jQuery(document).ready(function() {
+      
+      // get the table text and put in the title attribute on radios
+      jQuery("#wrapper_{$this->generateId( $name )} > ul.radio_list > 
li").each( function(){
+        jQuery( this ).find('input').attr('title', jQuery( this 
).find('label').text());
+      });
+      
+      // Create caption element
+      var caption_{$this->generateId( $name )} = jQuery('<div 
id="caption_{$this->generateId( $name )}" class="caption"></div>');
+      jQuery("#wrapper_{$this->generateId( $name 
)}").children().not(":radio").hide();
+      jQuery("#wrapper_{$this->generateId( $name )}").stars({
+        inputType: 'radio',
+        cancelShow: false,
+        captionEl: caption_{$this->generateId( $name )},
+      }).append(caption_{$this->generateId( $name )});
+
+    });
+    </script>
+CODESJAVASCRIPT;
+
+    return $output;
+  }
+
+
+
+   /**
+   * Gets the stylesheet paths associated with the widget.
+   *
+   * @return array An array of stylesheet paths
+   */
+  public function getStylesheets()
+  {
+    return array('/mpStarRatingPlugin/css/jquery.ui.stars.min.css' => 'all');
+  }
+
+  /**
+   * Gets the JavaScript paths associated with the widget.
+   *
+   * @return array An array of JavaScript paths
+   */
+  public function getJavascripts()
+  {
+    return array(
+      'jquery/jquery.ui/ui/ui.core.js', 
+      'jquery/jquery.ui/ui/jquery.ui.widget.js', 
+      '/mpStarRatingPlugin/js/jquery.ui.stars.min.js'
+    );
+  }
+}

Added: plugins/mpStarRatingPlugin/trunk/package.xml
===================================================================
--- plugins/mpStarRatingPlugin/trunk/package.xml                                
(rev 0)
+++ plugins/mpStarRatingPlugin/trunk/package.xml        2010-09-21 20:41:01 UTC 
(rev 30949)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package xmlns="http://pear.php.net/dtd/package-2.0"; 
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; packagerversion="1.9.0" 
version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0    
http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0    
http://pear.php.net/dtd/package-2.0.xsd";>
+ <name>mpStarRatingPlugin</name>
+ <channel>pear.symfony-project.com</channel>
+ <summary>Use Stars in your rating forms.</summary>
+ <description>This script overrite the radios from the form by a nice 
javascript star rating system.</description>
+ <lead>
+  <name>Nei Rauni Santos</name>
+  <user>nei_rauni</user>
+  <email>[email protected]</email>
+  <active>yes</active>
+ </lead>
+ <date>2010-05-21</date>
+ <time>16:38:25</time>
+ <version>
+  <release>1.0.0</release>
+  <api>1.0.0</api>
+ </version>
+ <stability>
+  <release>stable</release>
+  <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license";>MIT license</license>
+ <notes>
+You have to have the jquery on page.
+ </notes>
+ <contents>
+  <dir name="/">
+   <file md5sum="1265248721db3e4803b5af1b261dce44" 
name="/lib/mpWidgetFormChoiceRating.class.php" role="data"/>
+   <file md5sum="56fedb1a442de32b59532fff20c8f57c" 
name="/web/css/jquery.ui.stars.css" role="data"/>
+   <file md5sum="83c66f072a98656d1a1a7fb5bdee7a0f" 
name="/web/css/jquery.ui.stars.min.css" role="data"/>
+   <file md5sum="932a1563642a0d44d04d780da0003136" 
name="/web/images/crystal-stars.png" role="data"/>
+   <file md5sum="a5b7be4b54ebc5a8b2fe522d93118fc4" 
name="/web/images/jquery.ui.stars.gif" role="data"/>
+   <file md5sum="0d508146f1304cc50c021aaf3f74aaff" 
name="/web/js/jquery.ui.stars.js" role="data"/>
+   <file md5sum="141d69538369b19ba5b9bfd592dc1935" 
name="/web/js/jquery.ui.stars.min.js" role="data"/>
+   <file md5sum="67d60abf132f2595e900fc3a6afb434a" name="README" role="data"/>
+   <file md5sum="c615e5164ed7ade6ad3c64743e435180" name="LICENSE" role="data"/>
+  </dir>
+ </contents>
+ <dependencies>
+  <required>
+   <php>
+    <min>5.2.4</min>
+   </php>
+   <pearinstaller>
+    <min>1.4.1</min>
+   </pearinstaller>
+   
+  </required>
+ </dependencies>
+ <phprelease/>
+ <changelog>
+  <release>
+   <version>
+    <release>1.0.0</release>
+    <api>1.0.0</api>
+   </version>
+   <stability>
+    <release>stable</release>
+    <api>stable</api>
+   </stability>
+   <license uri="http://www.symfony-project.com/license";>MIT license</license>
+   <license>MIT</license>
+   <date>2008-11-08</date>
+   <notes>
+* Initial widget for choices
+   </notes>
+  </release>
+ </changelog>
+</package>

Added: plugins/mpStarRatingPlugin/trunk/web/css/jquery.ui.stars.css
===================================================================
--- plugins/mpStarRatingPlugin/trunk/web/css/jquery.ui.stars.css                
                (rev 0)
+++ plugins/mpStarRatingPlugin/trunk/web/css/jquery.ui.stars.css        
2010-09-21 20:41:01 UTC (rev 30949)
@@ -0,0 +1,112 @@
+ /*!
+ * jQuery UI Stars v2.0.3
+ * http://plugins.jquery.com/project/Star_Rating_widget
+ *
+ * Copyright (c) 2009 Orkan ([email protected])
+ * Dual licensed under the MIT and GPL licenses.
+ * http://docs.jquery.com/License
+ *
+ * $Rev: 102 $
+ * $Date:: 2009-06-07 #$
+ * $Build: 23 (2009-06-07)
+ *
+ * Theme: Crystal
+ *
+ */
+.ui-stars-star,
+.ui-stars-cancel {
+  float: left;
+  display: block;
+  overflow: hidden;
+  text-indent: -999em;
+  cursor: pointer;
+}
+.ui-stars-star a,
+.ui-stars-cancel a {
+  width: 28px;
+  height: 26px;
+  display: block;
+  position: relative;
+  background: url(/mpStarRatingPlugin/images/crystal-stars.png) no-repeat 0 0;
+}
+.ui-stars-star a {
+  background-position: 0 -56px;
+}
+.ui-stars-star-on a {
+  background-position: 0 -84px;
+}
+.ui-stars-star-hover a {
+  background-position: 0 -112px;
+}
+.ui-stars-cancel-hover a {
+  background-position: 0 -28px;
+}
+.ui-stars-star-disabled,
+.ui-stars-star-disabled a,
+.ui-stars-cancel-disabled a {
+  cursor: default !important;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /*!
+ * jQuery UI Stars v2.0.3
+ * http://plugins.jquery.com/project/Star_Rating_widget
+ *
+ * Copyright (c) 2009 Orkan ([email protected])
+ * Dual licensed under the MIT and GPL licenses.
+ * http://docs.jquery.com/License
+ *
+ * $Rev: 102 $
+ * $Date:: 2009-06-07 #$
+ * $Build: 23 (2009-06-07)
+ *
+ * Theme: Crystal
+ *
+ */
+.ui-stars-star,
+.ui-stars-cancel {
+  float: left;
+  display: block;
+  overflow: hidden;
+  text-indent: -999em;
+  cursor: pointer;
+}
+.ui-stars-star a,
+.ui-stars-cancel a {
+  width: 28px;
+  height: 26px;
+  display: block;
+  position: relative;
+  background: url(crystal-stars.png) no-repeat 0 0;
+}
+.ui-stars-star a {
+  background-position: 0 -56px;
+}
+.ui-stars-star-on a {
+  background-position: 0 -84px;
+}
+.ui-stars-star-hover a {
+  background-position: 0 -112px;
+}
+.ui-stars-cancel-hover a {
+  background-position: 0 -28px;
+}
+.ui-stars-star-disabled,
+.ui-stars-star-disabled a,
+.ui-stars-cancel-disabled a {
+  cursor: default !important;
+}

Added: plugins/mpStarRatingPlugin/trunk/web/css/jquery.ui.stars.min.css
===================================================================
--- plugins/mpStarRatingPlugin/trunk/web/css/jquery.ui.stars.min.css            
                (rev 0)
+++ plugins/mpStarRatingPlugin/trunk/web/css/jquery.ui.stars.min.css    
2010-09-21 20:41:01 UTC (rev 30949)
@@ -0,0 +1 @@
+.ui-stars-star,.ui-stars-cancel{float:left;display:block;overflow:hidden;text-indent:-999em;cursor:pointer;}.ui-stars-star
 a,.ui-stars-cancel 
a{width:16px;height:15px;display:block;background:url("/mpStarRatingPlugin/images/jquery.ui.stars.gif")
 no-repeat 0 0;}.ui-stars-star a{background-position:0 -32px;}.ui-stars-star-on 
a{background-position:0 -48px;}.ui-stars-star-hover a{background-position:0 
-64px;}.ui-stars-cancel-hover a{background-position:0 
-16px;}.ui-stars-star-disabled,.ui-stars-star-disabled 
a,.ui-stars-cancel-disabled a{cursor:default!important;}

Added: plugins/mpStarRatingPlugin/trunk/web/images/crystal-stars.png
===================================================================
(Binary files differ)


Property changes on: 
plugins/mpStarRatingPlugin/trunk/web/images/crystal-stars.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: plugins/mpStarRatingPlugin/trunk/web/images/jquery.ui.stars.gif
===================================================================
(Binary files differ)


Property changes on: 
plugins/mpStarRatingPlugin/trunk/web/images/jquery.ui.stars.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: plugins/mpStarRatingPlugin/trunk/web/js/jquery.ui.stars.js
===================================================================
--- plugins/mpStarRatingPlugin/trunk/web/js/jquery.ui.stars.js                  
        (rev 0)
+++ plugins/mpStarRatingPlugin/trunk/web/js/jquery.ui.stars.js  2010-09-21 
20:41:01 UTC (rev 30949)
@@ -0,0 +1,316 @@
+/*!
+ * jQuery UI Stars v3.0.1
+ * http://plugins.jquery.com/project/Star_Rating_widget
+ *
+ * Copyright (c) 2010 Marek "Orkan" Zajac ([email protected])
+ * Dual licensed under the MIT and GPL licenses.
+ * http://docs.jquery.com/License
+ *
+ * $Rev: 164 $
+ * $Date:: 2010-05-01 #$
+ * $Build: 35 (2010-05-01)
+ *
+ * Depends:
+ *     jquery.ui.core.js
+ *     jquery.ui.widget.js
+ *
+ */
+(function($) {
+
+$.widget('ui.stars', {
+       options: {
+               inputType: 'radio', // [radio|select]
+               split: 0, // decrease number of stars by splitting each star 
into pieces [2|3|4|...]
+               disabled: false, // set to [true] to make the stars initially 
disabled
+               cancelTitle: 'Cancel Rating',
+               cancelValue: 0, // default value of Cancel btn.
+               cancelShow: true,
+               disableValue: true, // set to [false] to not disable the hidden 
input when Cancel btn is clicked, so the value will present in POST data.
+               oneVoteOnly: false,
+               showTitles: false,
+               captionEl: null, // jQuery object - target for text captions 
+               callback: null, // function(ui, type, value, event)
+
+               /*
+                * CSS classes
+                */
+               starWidth: 16, // width of the star image
+               cancelClass: 'ui-stars-cancel',
+               starClass: 'ui-stars-star',
+               starOnClass: 'ui-stars-star-on',
+               starHoverClass: 'ui-stars-star-hover',
+               starDisabledClass: 'ui-stars-star-disabled',
+               cancelHoverClass: 'ui-stars-cancel-hover',
+               cancelDisabledClass: 'ui-stars-cancel-disabled'
+       },
+       
+       _create: function() {
+               var self = this, o = this.options, starId = 0;
+               this.element.data('former.stars', this.element.html());
+
+               o.isSelect = o.inputType == 'select';
+               this.$form = $(this.element).closest('form');
+               this.$selec = o.isSelect ? $('select', this.element)  : null;
+               this.$rboxs = o.isSelect ? $('option', this.$selec)   : 
$(':radio', this.element);
+
+               /*
+                * Map all inputs from $rboxs array to Stars elements
+                */
+               this.$stars = this.$rboxs.map(function(i)
+               {
+                       var el = {
+                               value:      this.value,
+                               title:      (o.isSelect ? this.text : 
this.title) || this.value,
+                               isDefault:  (o.isSelect && 
this.defaultSelected) || this.defaultChecked
+                       };
+
+                       if(i==0) {
+                               o.split = typeof o.split != 'number' ? 0 : 
o.split;
+                               o.val2id = [];
+                               o.id2val = [];
+                               o.id2title = [];
+                               o.name = o.isSelect ? self.$selec.get(0).name : 
this.name;
+                               o.disabled = o.disabled || (o.isSelect ? 
$(self.$selec).attr('disabled') : $(this).attr('disabled'));
+                       }
+
+                       /*
+                        * Consider it as a Cancel button?
+                        */
+                       if(el.value == o.cancelValue) {
+                               o.cancelTitle = el.title;
+                               return null;
+                       }
+
+                       o.val2id[el.value] = starId;
+                       o.id2val[starId] = el.value;
+                       o.id2title[starId] = el.title;
+
+                       if(el.isDefault) {
+                               o.checked = starId;
+                               o.value = o.defaultValue = el.value;
+                               o.title = el.title;
+                       }
+
+                       var $s = $('<div/>').addClass(o.starClass);
+                       var $a = $('<a/>').attr('title', o.showTitles ? 
el.title : '').text(el.value);
+
+                       /*
+                        * Prepare division settings
+                        */
+                       if(o.split) {
+                               var oddeven = (starId % o.split);
+                               var stwidth = Math.floor(o.starWidth / o.split);
+                               $s.width(stwidth);
+                               $a.css('margin-left', '-' + (oddeven * stwidth) 
+ 'px');
+                       }
+
+                       starId++;
+                       return $s.append($a).get(0);
+               });
+
+               /*
+                * How many Stars?
+                */
+               o.items = starId;
+
+               /*
+                * Remove old content
+                */
+               o.isSelect ? this.$selec.remove() : this.$rboxs.remove();
+
+               /*
+                * Append Stars interface
+                */
+               this.$cancel = $('<div/>').addClass(o.cancelClass).append( 
$('<a/>').attr('title', o.showTitles ? o.cancelTitle : '').text(o.cancelValue) 
);
+               o.cancelShow &= !o.disabled && !o.oneVoteOnly;
+               o.cancelShow && this.element.append(this.$cancel);
+               this.element.append(this.$stars);
+
+               /*
+                * Initial selection
+                */
+               if(o.checked === undefined) {
+                       o.checked = -1;
+                       o.value = o.defaultValue = o.cancelValue;
+                       o.title = '';
+               }
+               
+               /*
+                * The only FORM element, that has been linked to the stars 
control. The value field is updated on each Star click event
+                */
+               this.$value = $("<input type='hidden' name='"+o.name+"' 
value='"+o.value+"' />");
+               this.element.append(this.$value);
+
+
+               /*
+                * Attach stars event handler
+                */
+               this.$stars.bind('click.stars', function(e) {
+                       if(!o.forceSelect && o.disabled) return false;
+
+                       var i = self.$stars.index(this);
+                       o.checked = i;
+                       o.value = o.id2val[i];
+                       o.title = o.id2title[i];
+                       self.$value.attr({disabled: o.disabled ? 'disabled' : 
'', value: o.value});
+
+                       fillTo(i, false);
+                       self._disableCancel();
+
+                       !o.forceSelect && self.callback(e, 'star');
+               })
+               .bind('mouseover.stars', function() {
+                       if(o.disabled) return false;
+                       var i = self.$stars.index(this);
+                       fillTo(i, true);
+               })
+               .bind('mouseout.stars', function() {
+                       if(o.disabled) return false;
+                       fillTo(self.options.checked, false);
+               });
+
+
+               /*
+                * Attach cancel event handler
+                */
+               this.$cancel.bind('click.stars', function(e) {
+                       if(!o.forceSelect && (o.disabled || o.value == 
o.cancelValue)) return false;
+
+                       o.checked = -1;
+                       o.value = o.cancelValue;
+                       o.title = '';
+                       
+                       self.$value.val(o.value);
+                       o.disableValue && self.$value.attr({disabled: 
'disabled'});
+
+                       fillNone();
+                       self._disableCancel();
+
+                       !o.forceSelect && self.callback(e, 'cancel');
+               })
+               .bind('mouseover.stars', function() {
+                       if(self._disableCancel()) return false;
+                       self.$cancel.addClass(o.cancelHoverClass);
+                       fillNone();
+                       self._showCap(o.cancelTitle);
+               })
+               .bind('mouseout.stars', function() {
+                       if(self._disableCancel()) return false;
+                       self.$cancel.removeClass(o.cancelHoverClass);
+                       self.$stars.triggerHandler('mouseout.stars');
+               });
+
+
+               /*
+                * Attach onReset event handler to the parent FORM
+                */
+               this.$form.bind('reset.stars', function(){
+                       !o.disabled && self.select(o.defaultValue);
+               });
+
+
+               /*
+                * Clean up to avoid memory leaks in certain versions of IE 6
+                */
+               $(window).unload(function(){
+                       self.$cancel.unbind('.stars');
+                       self.$stars.unbind('.stars');
+                       self.$form.unbind('.stars');
+                       self.$selec = self.$rboxs = self.$stars = self.$value = 
self.$cancel = self.$form = null;
+               });
+
+
+               /*
+                * Star selection helpers
+                */
+               function fillTo(index, hover) {
+                       if(index != -1) {
+                               var addClass = hover ? o.starHoverClass : 
o.starOnClass;
+                               var remClass = hover ? o.starOnClass    : 
o.starHoverClass;
+                               self.$stars.eq(index).prevAll('.' + 
o.starClass).andSelf().removeClass(remClass).addClass(addClass);
+                               self.$stars.eq(index).nextAll('.' + 
o.starClass).removeClass(o.starHoverClass + ' ' + o.starOnClass);
+                               self._showCap(o.id2title[index]);
+                       }
+                       else fillNone();
+               };
+               function fillNone() {
+                       self.$stars.removeClass(o.starOnClass + ' ' + 
o.starHoverClass);
+                       self._showCap('');
+               };
+
+
+               /*
+                * Finally, set up the Stars
+                */
+               this.select(o.value);
+               o.disabled && this.disable();
+
+       },
+
+       /*
+        * Private functions
+        */
+       _disableCancel: function() {
+               var o = this.options, disabled = o.disabled || o.oneVoteOnly || 
(o.value == o.cancelValue);
+               if(disabled)  
this.$cancel.removeClass(o.cancelHoverClass).addClass(o.cancelDisabledClass);
+               else          this.$cancel.removeClass(o.cancelDisabledClass);
+               this.$cancel.css('opacity', disabled ? 0.5 : 1);
+               return disabled;
+       },
+       _disableAll: function() {
+               var o = this.options;
+               this._disableCancel();
+               if(o.disabled)  
this.$stars.filter('div').addClass(o.starDisabledClass);
+               else            
this.$stars.filter('div').removeClass(o.starDisabledClass);
+       },
+       _showCap: function(s) {
+               var o = this.options;
+               if(o.captionEl) o.captionEl.text(s);
+       },
+
+       /*
+        * Public functions
+        */
+       value: function() {
+               return this.options.value;
+       },
+       select: function(val) {
+               var o = this.options, e = (val == o.cancelValue) ? this.$cancel 
: this.$stars.eq(o.val2id[val]);
+               o.forceSelect = true;
+               e.triggerHandler('click.stars');
+               o.forceSelect = false;
+       },
+       selectID: function(id) {
+               var o = this.options, e = (id == -1) ? this.$cancel : 
this.$stars.eq(id);
+               o.forceSelect = true;
+               e.triggerHandler('click.stars');
+               o.forceSelect = false;
+       },
+       enable: function() {
+               this.options.disabled = false;
+               this._disableAll();
+       },
+       disable: function() {
+               this.options.disabled = true;
+               this._disableAll();
+       },
+       destroy: function() {
+               this.$form.unbind('.stars');
+               this.$cancel.unbind('.stars').remove();
+               this.$stars.unbind('.stars').remove();
+               this.$value.remove();
+               
this.element.unbind('.stars').html(this.element.data('former.stars')).removeData('stars');
+               return this;
+       },
+       callback: function(e, type) {
+               var o = this.options;
+               o.callback && o.callback(this, type, o.value, e);
+               o.oneVoteOnly && !o.disabled && this.disable();
+       }
+});
+
+$.extend($.ui.stars, {
+       version: '3.0.1'
+});
+
+})(jQuery);

Added: plugins/mpStarRatingPlugin/trunk/web/js/jquery.ui.stars.min.js
===================================================================
--- plugins/mpStarRatingPlugin/trunk/web/js/jquery.ui.stars.min.js              
                (rev 0)
+++ plugins/mpStarRatingPlugin/trunk/web/js/jquery.ui.stars.min.js      
2010-09-21 20:41:01 UTC (rev 30949)
@@ -0,0 +1,18 @@
+/*
+ * jQuery UI Stars v3.0.1
+ * http://plugins.jquery.com/project/Star_Rating_widget
+ *
+ * Copyright (c) 2010 Marek "Orkan" Zajac ([email protected])
+ * Dual licensed under the MIT and GPL licenses.
+ * http://docs.jquery.com/License
+ *
+ * $Rev: 164 $
+ * $Date:: 2010-05-01 #$
+ * $Build: 35 (2010-05-01)
+ *
+ * Depends:
+ *     jquery.ui.core.js
+ *     jquery.ui.widget.js
+ *
+ */
+(function(A){A.widget("ui.stars",{options:{inputType:"radio",split:0,disabled:false,cancelTitle:"Cancel
 
Rating",cancelValue:0,cancelShow:true,disableValue:true,oneVoteOnly:false,showTitles:false,captionEl:null,callback:null,starWidth:16,cancelClass:"ui-stars-cancel",starClass:"ui-stars-star",starOnClass:"ui-stars-star-on",starHoverClass:"ui-stars-star-hover",starDisabledClass:"ui-stars-star-disabled",cancelHoverClass:"ui-stars-cancel-hover",cancelDisabledClass:"ui-stars-cancel-disabled"},_create:function(){var
 
C=this,F=this.options,B=0;this.element.data("former.stars",this.element.html());F.isSelect=F.inputType=="select";this.$form=A(this.element).closest("form");this.$selec=F.isSelect?A("select",this.element):null;this.$rboxs=F.isSelect?A("option",this.$selec):A(":radio",this.element);this.$stars=this.$rboxs.map(function(I){var
 
J={value:this.value,title:(F.isSelect?this.text:this.title)||this.value,isDefault:(F.isSelect&&this.defaultSelected)||this.defaultChecked};if(I==0){F.split=typeof
 
F.split!="number"?0:F.split;F.val2id=[];F.id2val=[];F.id2title=[];F.name=F.isSelect?C.$selec.get(0).name:this.name;F.disabled=F.disabled||(F.isSelect?A(C.$selec).attr("disabled"):A(this).attr("disabled"))}if(J.value==F.cancelValue){F.cancelTitle=J.title;return
 
null}F.val2id[J.value]=B;F.id2val[B]=J.value;F.id2title[B]=J.title;if(J.isDefault){F.checked=B;F.value=F.defaultValue=J.value;F.title=J.title}var
 H=A("<div/>").addClass(F.starClass);var 
K=A("<a/>").attr("title",F.showTitles?J.title:"").text(J.value);if(F.split){var 
G=(B%F.split);var 
L=Math.floor(F.starWidth/F.split);H.width(L);K.css("margin-left","-"+(G*L)+"px")}B++;return
 
H.append(K).get(0)});F.items=B;F.isSelect?this.$selec.remove():this.$rboxs.remove();this.$cancel=A("<div/>").addClass(F.cancelClass).append(A("<a/>").attr("title",F.showTitles?F.cancelTitle:"").text(F.cancelValue));F.cancelShow&=!F.disabled&&!F.oneVoteOnly;F.cancelShow&&this.element.append(this.$cancel);this.element.append(this.$stars);if(F.checked===undefined){F.checked=-1;F.value=F.defaultValue=F.cancelValue;F.title=""}this.$value=A("<input
 type='hidden' name='"+F.name+"' value='"+F.value+"' 
/>");this.element.append(this.$value);this.$stars.bind("click.stars",function(H){if(!F.forceSelect&&F.disabled){return
 false}var 
G=C.$stars.index(this);F.checked=G;F.value=F.id2val[G];F.title=F.id2title[G];C.$value.attr({disabled:F.disabled?"disabled":"",value:F.value});D(G,false);C._disableCancel();!F.forceSelect&&C.callback(H,"star")}).bind("mouseover.stars",function(){if(F.disabled){return
 false}var 
G=C.$stars.index(this);D(G,true)}).bind("mouseout.stars",function(){if(F.disabled){return
 
false}D(C.options.checked,false)});this.$cancel.bind("click.stars",function(G){if(!F.forceSelect&&(F.disabled||F.value==F.cancelValue)){return
 
false}F.checked=-1;F.value=F.cancelValue;F.title="";C.$value.val(F.value);F.disableValue&&C.$value.attr({disabled:"disabled"});E();C._disableCancel();!F.forceSelect&&C.callback(G,"cancel")}).bind("mouseover.stars",function(){if(C._disableCancel()){return
 
false}C.$cancel.addClass(F.cancelHoverClass);E();C._showCap(F.cancelTitle)}).bind("mouseout.stars",function(){if(C._disableCancel()){return
 
false}C.$cancel.removeClass(F.cancelHoverClass);C.$stars.triggerHandler("mouseout.stars")});this.$form.bind("reset.stars",function(){!F.disabled&&C.select(F.defaultValue)});A(window).unload(function(){C.$cancel.unbind(".stars");C.$stars.unbind(".stars");C.$form.unbind(".stars");C.$selec=C.$rboxs=C.$stars=C.$value=C.$cancel=C.$form=null});function
 D(G,I){if(G!=-1){var J=I?F.starHoverClass:F.starOnClass;var 
H=I?F.starOnClass:F.starHoverClass;C.$stars.eq(G).prevAll("."+F.starClass).andSelf().removeClass(H).addClass(J);C.$stars.eq(G).nextAll("."+F.starClass).removeClass(F.starHoverClass+"
 "+F.starOnClass);C._showCap(F.id2title[G])}else{E()}}function 
E(){C.$stars.removeClass(F.starOnClass+" 
"+F.starHoverClass);C._showCap("")}this.select(F.value);F.disabled&&this.disable()},_disableCancel:function(){var
 
C=this.options,B=C.disabled||C.oneVoteOnly||(C.value==C.cancelValue);if(B){this.$cancel.removeClass(C.cancelHoverClass).addClass(C.cancelDisabledClass)}else{this.$cancel.removeClass(C.cancelDisabledClass)}this.$cancel.css("opacity",B?0.5:1);return
 B},_disableAll:function(){var 
B=this.options;this._disableCancel();if(B.disabled){this.$stars.filter("div").addClass(B.starDisabledClass)}else{this.$stars.filter("div").removeClass(B.starDisabledClass)}},_showCap:function(B){var
 C=this.options;if(C.captionEl){C.captionEl.text(B)}},value:function(){return 
this.options.value},select:function(D){var 
C=this.options,B=(D==C.cancelValue)?this.$cancel:this.$stars.eq(C.val2id[D]);C.forceSelect=true;B.triggerHandler("click.stars");C.forceSelect=false},selectID:function(D){var
 
C=this.options,B=(D==-1)?this.$cancel:this.$stars.eq(D);C.forceSelect=true;B.triggerHandler("click.stars");C.forceSelect=false},enable:function(){this.options.disabled=false;this._disableAll()},disable:function(){this.options.disabled=true;this._disableAll()},destroy:function(){this.$form.unbind(".stars");this.$cancel.unbind(".stars").remove();this.$stars.unbind(".stars").remove();this.$value.remove();this.element.unbind(".stars").html(this.element.data("former.stars")).removeData("stars");return
 this},callback:function(C,B){var 
D=this.options;D.callback&&D.callback(this,B,D.value,C);D.oneVoteOnly&&!D.disabled&&this.disable()}});A.extend(A.ui.stars,{version:"3.0.1"})})(jQuery);
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to