From 8150794d0461542fef933604c17a9b2803630cba Mon Sep 17 00:00:00 2001
From: Christopher Mitchell
Date: Wed, 5 Oct 2011 18:13:29 -0400
Subject: [PATCH 1/2] Adding initial rating widget with no remove
functionality.
---
demos/rating/default.html | 44 ++++++
demos/rating/index.html | 18 +++
themes/base/images/star.gif | Bin 0 -> 1691 bytes
themes/base/jquery.ui.base.css | 1 +
themes/base/jquery.ui.rating.css | 41 ++++++
ui/jquery.ui.rating.js | 227 +++++++++++++++++++++++++++++++
6 files changed, 331 insertions(+)
create mode 100644 demos/rating/default.html
create mode 100644 demos/rating/index.html
create mode 100644 themes/base/images/star.gif
create mode 100755 themes/base/jquery.ui.rating.css
create mode 100644 ui/jquery.ui.rating.js
diff --git a/demos/rating/default.html b/demos/rating/default.html
new file mode 100644
index 00000000000..e57108222af
--- /dev/null
+++ b/demos/rating/default.html
@@ -0,0 +1,44 @@
+
+
+
+
+ jQuery UI Slider - Default functionality
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The default settings for the rating widget.
+
+
+
+
diff --git a/demos/rating/index.html b/demos/rating/index.html
new file mode 100644
index 00000000000..ba119441243
--- /dev/null
+++ b/demos/rating/index.html
@@ -0,0 +1,18 @@
+
+
+
+
+ jQuery UI Rating Demo
+
+
+
+
+
+
+
+
diff --git a/themes/base/images/star.gif b/themes/base/images/star.gif
new file mode 100644
index 0000000000000000000000000000000000000000..0e5b813e66e1ab0a11e54d849382f1d4a93dd626
GIT binary patch
literal 1691
zcmdth`#X~h0KoBWMkBG)$$m%tNRoh3I&_%_SzcI%-i!MASm%vSh3%y3jn~Orb+8
zTkB*svRWG^hPkweMqx8-v$YMSI_LZw=kwF|ANcwn^l^2IMna+>5*DP|#f9SON%ir0
z1A>q~xk0;Mhq(z3?dONMw}*zZj(d(C@#kT&?5HSlc)*8<;CE3`
z+}Hr|v5?;AFyYBCNyO3l6Jb5^;rzI`j>NEu*yGX|?C6=;o}?uC=@3z3f-w2i5H41p
z5ILC~BS=l<=dAg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{=P6k=eswhZAWNIj{}E)!zXq6yp95<66W6
literal 0
HcmV?d00001
diff --git a/themes/base/jquery.ui.base.css b/themes/base/jquery.ui.base.css
index a359c2ba490..45b95c03dfc 100644
--- a/themes/base/jquery.ui.base.css
+++ b/themes/base/jquery.ui.base.css
@@ -17,6 +17,7 @@
@import url("jquery.ui.menu.css");
@import url("jquery.ui.menubar.css");
@import url("jquery.ui.progressbar.css");
+@import url("jquery.ui.rating.css");
@import url("jquery.ui.resizable.css");
@import url("jquery.ui.selectable.css");
@import url("jquery.ui.slider.css");
diff --git a/themes/base/jquery.ui.rating.css b/themes/base/jquery.ui.rating.css
new file mode 100755
index 00000000000..5c7adf2ba45
--- /dev/null
+++ b/themes/base/jquery.ui.rating.css
@@ -0,0 +1,41 @@
+/*
+ * jQuery UI Rating @VERSION
+ *
+ * Copyright 2011, AUTHORS.txt (http: //jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http: //jquery.org/license
+ *
+ * http: //docs.jquery.com/UI/Rating#theming
+ */
+.ui-rating{
+ height: 16px;
+}
+.ui-rating .ui-rating-star{
+ width: 16px;
+ height: 16px;
+ font-size: 2px;
+ float: left;
+ text-decoration: none;
+ vertical-align: bottom;
+ background-image: url(images/star.gif);
+ background-repeat: no-repeat;
+ background-position: 0 -32px;
+}
+.ui-rating-current .ui-rating-full{
+ background-position: 0 0;
+}
+.ui-rating-current .ui-rating-partial{
+ background-position: 0 -16px;
+}
+.ui-rating .ui-rating-cancel-empty{
+ background-position: 0 -64px;
+}
+.ui-rating .ui-rating-cancel-full{
+ background-position: 0 -80px;
+}
+.ui-rating .ui-rating-hover{
+ background-position: 0 -48px;
+}
+.ui-rating-cancel-empty.ui-rating-hover{
+ background-position: 0 -80px;
+}
\ No newline at end of file
diff --git a/ui/jquery.ui.rating.js b/ui/jquery.ui.rating.js
new file mode 100644
index 00000000000..cc3bcec7087
--- /dev/null
+++ b/ui/jquery.ui.rating.js
@@ -0,0 +1,227 @@
+/*
+ * jQuery UI Rating 1.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Rating
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.widget.js
+ */
+(function( $, undefined ) {
+
+$.widget("ui.rating", {
+ version: "@VERSION",
+
+ options: {
+ value: null,
+ max: null,
+ readOnly: false,
+
+ // callbacks
+ change: null
+ },
+
+ min: 0,
+
+ _create: function() {
+ var self = this;
+
+ var ratingDiv = $( "");
+ var ratingStar = $( "");
+
+ var element = self.element.wrap( ratingDiv ).parent();
+
+ $.extend(self, {
+ originalElement: this.element,
+ element: element
+ });
+
+ if (isNaN(parseFloat(self.options.value)))
+ {
+ self.options.value = parseFloat(self.originalElement.val());
+ }
+
+ if (isNaN(parseInt(self.options.max)))
+ {
+ self.options.max = 0;
+ }
+
+ $.each( $( "option", self.originalElement ), function( index, option ) {
+ var val = parseInt( $( option ).val(), 0 );
+
+ self.options.max = ( val > self.options.max ) ? val : self.options.max;
+ });
+
+ for ( index = 1; index <= self.options.max; index++ ) {
+ ratingStar.clone().attr( 'id', 'rating_star_rating_' + index ).text( "Give it a " + index ).data( "rating", index ).appendTo( self.element );
+ }
+
+ self.originalElement.hide();
+
+ // self.oldValue = self._getValue();
+ self._refreshValue();
+
+ // self.oldReadOnly = self._getReadOnly();
+ self._setReadOnly();
+ },
+
+ _destroy: function() {
+ this.originalElement.siblings().remove().end().show().unwrap( this.element );
+
+ this.element = this.originalElement;
+
+ delete this.originalElement;
+ delete this.oldValue;
+ delete this.oldReadOnly;
+ },
+
+ _events: {
+ 'click .ui-rating-star': function( event ) {
+ event.preventDefault();
+
+ this.options.value = $( event.target ).data( "rating" );
+
+ this._refreshValue();
+ },
+
+ mouseover: function( event ) {
+ var $target = $( event.target );
+
+ if ( $target.is( ".ui-rating-star" ) ) {
+ this.element.removeClass( "ui-rating-current" );
+
+ // create referece object for stars
+ var ratingStars = $( ".ui-rating-star", this.element );
+
+ // add hover class to the current and preceding stars
+ ratingStars.removeClass( "ui-rating-hover" ).filter(function( index ) {
+ return index <= ratingStars.index( $target );
+ }).addClass( "ui-rating-hover" );
+
+ this._trigger( "change", null, this.ui() );
+ }
+ },
+
+ mouseleave: function( event ) {
+ this.element.addClass( "ui-rating-current" ).find( ".ui-rating-hover" ).removeClass( "ui-rating-hover" );
+
+ this._trigger( "change", null, this.ui() );
+ }
+ },
+
+ _eventsReadOnly: {
+ 'click .ui-rating-star': function( event ) {
+ event.preventDefault();
+ }
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "value" ) {
+ this.options.value = value;
+
+ this._refreshValue();
+ }
+
+ if ( key === "readOnly") {
+ this.options.readOnly = value;
+
+ this._setReadOnly( value );
+ }
+
+ this._super( "_setOption", key, value );
+ },
+
+ _getValue: function() {
+ var val = this.options.value;
+
+ // normalize invalid value
+ if ( typeof val !== "number" ) {
+ val = 0;
+ }
+
+ return Math.min( this.options.max, Math.max( this.min, val ) );
+ },
+
+ _refreshValue: function() {
+ var value = this._getValue();
+
+ if ( this.oldValue !== value ) {
+ this.oldValue = value;
+
+ $( ".ui-rating-star", this.element ).removeClass( "ui-rating-full ui-rating-partial" ).each( function( index ) {
+ index++;
+
+ var starClass = "";
+
+ if ( index <= value ) {
+ starClass = "ui-rating-full";
+ } else if ( index - value < 1 ) {
+ starClass = "ui-rating-partial";
+ }
+
+ $( this ).addClass( starClass );
+ });
+
+ this.originalElement.val( value );
+
+ this._trigger( "change", null, this.ui() );
+ }
+ },
+
+ _getReadOnly: function() {
+ var val = this.options.readOnly;
+
+ // normalize invalid boolean
+ if ( typeof val !== "boolean" )
+ {
+ val = false;
+ }
+
+ return val;
+ },
+
+ _setReadOnly: function() {
+ var readOnly = this._getReadOnly();
+
+ if ( this.oldReadOnly !== readOnly ) {
+ this.oldReadOnly = readOnly;
+
+ if (readOnly === true) {
+ // make read only
+ this.element.addClass( "ui-rating-readonly ui-rating-current" ).find( ".ui-rating-hover" ).removeClass( "ui-rating-hover" );
+
+ this.bindings.unbind( "." + this.widgetName );
+
+ this._bind( this.element, this._eventsReadOnly);
+ } else {
+ // make non-read only
+ this.element.removeClass('ui-rating-readonly');
+
+ this.bindings.unbind( "." + this.widgetName );
+
+ this._bind( this.element, this._events );
+ }
+
+ this._trigger( "change", null, this.ui() );
+ }
+ },
+
+ ui: function() {
+ return {
+ element: this.element,
+ originalElement: this.originalElement,
+ value: this.options.value,
+ oldValue: this.oldValue,
+ min: this.min,
+ max: this.options.max,
+ oldReadOnly: this.options.readOnly,
+ readOnly: this.options.readOnly
+ };
+ }
+});
+
+}( jQuery ));
From 34a85ce979161643ff1311ddf117568865c8726d Mon Sep 17 00:00:00 2001
From: "Christopher M. Mitchell"
Date: Sun, 13 Nov 2011 12:10:49 -0500
Subject: [PATCH 2/2] Updating demo file to reference jQuery 1.7.
---
demos/rating/default.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/demos/rating/default.html b/demos/rating/default.html
index e57108222af..a1358074127 100644
--- a/demos/rating/default.html
+++ b/demos/rating/default.html
@@ -4,7 +4,7 @@
jQuery UI Slider - Default functionality
-
+