click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r786123 - in /incubator/click/trunk/click/examples: src/org/apache/click/examples/page/general/ControlHeadDemo.java webapp/assets/rating/jquery.rating.js
Date Thu, 18 Jun 2009 15:26:15 GMT
Author: sabob
Date: Thu Jun 18 15:26:15 2009
New Revision: 786123

URL: http://svn.apache.org/viewvc?rev=786123&view=rev
Log:
fixed rating control to properly close end tag, also updated to latest rating JS version

Modified:
    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java
    incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js

Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java?rev=786123&r1=786122&r2=786123&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java
(original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/general/ControlHeadDemo.java
Thu Jun 18 15:26:15 2009
@@ -98,6 +98,7 @@
                 if (strValue.equals(getValue())) {
                     buffer.appendAttribute("checked", "checked");
                 }
+                buffer.elementEnd();
                 buffer.append("\n");
             }
         }

Modified: incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js?rev=786123&r1=786122&r2=786123&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js (original)
+++ incubator/click/trunk/click/examples/webapp/assets/rating/jquery.rating.js Thu Jun 18
15:26:15 2009
@@ -1,5 +1,5 @@
 /*
- ### jQuery Star Rating Plugin v3.10 - 2009-03-23 ###
+ ### jQuery Star Rating Plugin v3.12 - 2009-04-16 ###
  * Home: http://www.fyneworks.com/jquery/star-rating/
  * Code: http://code.google.com/p/jquery-star-rating-plugin/
  *
@@ -12,15 +12,15 @@
 /*# AVOID COLLISIONS #*/
 ;if(window.jQuery) (function($){
 /*# AVOID COLLISIONS #*/
-	
+
 	// IE6 Background Image Fix
-	if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e)
{ }
+	if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e)
{ };
 	// Thanks to http://www.visualjquery.com/rating/rating_redux.html
-	
+
 	// plugin initialization
 	$.fn.rating = function(options){
 		if(this.length==0) return this; // quick fail
-		
+
 		// Handle API methods
 		if(typeof arguments[0]=='string'){
 			// Perform API methods on individual elements
@@ -35,39 +35,44 @@
 			// Quick exit...
 			return this;
 		};
-		
+
 		// Initialize options for this call
 		var options = $.extend(
 			{}/* new object */,
 			$.fn.rating.options/* default options */,
 			options || {} /* just-in-time options */
 		);
-		
+
+		// Allow multiple controls with the same name by making each call unique
+		$.fn.rating.calls++;
+
 		// loop through each matched element
 		this
 		 .not('.star-rating-applied')
 			.addClass('star-rating-applied')
 		.each(function(){
-			
+
 			// Load control parameters / find context / etc
-			var eid = (this.name || 'unnamed-rating').replace(/\[|\]+/g, "_");
+			var control, input = $(this);
+			var eid = (this.name || 'unnamed-rating').replace(/\[|\]/g, '_').replace(/^\_+|\_+$/g,'');
 			var context = $(this.form || document.body);
-			var input = $(this);
-			var raters = context.data('rating') || { count:0 };
+
+			// FIX: http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=23
+			var raters = context.data('rating');
+			if(!raters || raters.call!=$.fn.rating.calls) raters = { count:0, call:$.fn.rating.calls
};
 			var rater = raters[eid];
-			var control;
-			
+
 			// if rater is available, verify that the control still exists
 			if(rater) control = rater.data('rating');
-			
-			if(rater && control){
+
+			if(rater && control)//{// save a byte!
 				// add star to control if rater is available and the same control still exists
 				control.count++;
-				
-			}
+
+			//}// save a byte!
 			else{
 				// create new control if first star or control element was removed/replaced
-				
+
 				// Initialize options for this raters
 				control = $.extend(
 					{}/* new object */,
@@ -75,20 +80,20 @@
 					($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options
*/
 					{ count:0, stars: [], inputs: [] }
 				);
-				
+
 				// increment number of rating controls
 				control.serial = raters.count++;
-				
+
 				// create rating element
 				rater = $('<span class="star-rating-control"/>');
 				input.before(rater);
-				
+
 				// Mark element for initialization (once all stars are ready)
 				rater.addClass('rating-to-be-drawn');
-				
+
 				// Accept readOnly setting from 'disabled' property
 				if(input.attr('disabled')) control.readOnly = true;
-				
+
 				// Create 'cancel' button
 				rater.append(
 					control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel
+ '">' + control.cancelValue + '</a></div>')
@@ -107,20 +112,20 @@
 					})
 					.data('rating', control)
 				);
-				
+
 			}; // first element of group
-			
+
 			// insert rating star
 			var star = $('<div class="star-rating rater-'+ control.serial +'"><a title="'
+ (this.title || this.value) + '">' + this.value + '</a></div>');
 			rater.append(star);
-			
+
 			// inherit attributes from input element
 			if(this.id) star.attr('id', this.id);
 			if(this.className) star.addClass(this.className);
-			
+
 			// Half-stars?
 			if(control.half) control.split = 2;
-			
+
 			// Prepare division control
 			if(typeof control.split=='number' && control.split>0){
 				var stw = ($.fn.width ? star.width() : 0) || control.starWidth;
@@ -132,7 +137,7 @@
 				// this is work-around to IE's stupid box model (position:relative doesn't work)
 				.find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' })
 			};
-			
+
 			// readOnly?
 			if(control.readOnly)//{ //save a byte!
 				// Mark star as readOnly so user can customize display
@@ -155,46 +160,49 @@
 					})
 				;
 			//}; //save a byte!
-			
+
 			// set current selection
 			if(this.checked)	control.current = star;
-			
+
 			// hide input element
 			input.hide();
-			
+
 			// backward compatibility, form element to plugin
 			input.change(function(){
     $(this).rating('select');
    });
-			
+
 			// attach reference to star to input element and vice-versa
 			star.data('rating.input', input.data('rating.star', star));
-			
+
 			// store control information in form (or body when form not available)
 			control.stars[control.stars.length] = star[0];
 			control.inputs[control.inputs.length] = input[0];
 			control.rater = raters[eid] = rater;
 			control.context = context;
-			
+
 			input.data('rating', control);
 			rater.data('rating', control);
 			star.data('rating', control);
 			context.data('rating', raters);
   }); // each element
-		
+
 		// Initialize ratings (first draw)
 		$('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');
-		
+
 		return this; // don't break the chain...
 	};
-	
+
 	/*--------------------------------------------------------*/
-	
+
 	/*
 		### Core functionality and API ###
 	*/
 	$.extend($.fn.rating, {
-		
+		// Used to append a unique serial number to internal control ID
+		// each time the plugin is invoked so same name controls can co-exist
+		calls: 0,
+
 		focus: function(){
 			var control = this.data('rating'); if(!control) return this;
 			if(!control.focus) return this; // quick fail if not required
@@ -203,7 +211,7 @@
    // focus handler, as requested by focusdigital.co.uk
 			if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
 		}, // $.fn.rating.focus
-		
+
 		blur: function(){
 			var control = this.data('rating'); if(!control) return this;
 			if(!control.blur) return this; // quick fail if not required
@@ -212,7 +220,7 @@
    // blur handler, as requested by focusdigital.co.uk
 			if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
 		}, // $.fn.rating.blur
-		
+
 		fill: function(){ // fill to the current mouse position.
 			var control = this.data('rating'); if(!control) return this;
 			// do not execute when control is in read-only mode
@@ -221,7 +229,7 @@
 			this.rating('drain');
 			this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover');
 		},// $.fn.rating.fill
-		
+
 		drain: function() { // drain all the stars.
 			var control = this.data('rating'); if(!control) return this;
 			// do not execute when control is in read-only mode
@@ -229,7 +237,7 @@
 			// Reset all stars
 			control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover');
 		},// $.fn.rating.drain
-		
+
 		draw: function(){ // set value and stars to reflect current selection
 			var control = this.data('rating'); if(!control) return this;
 			// Clear all stars
@@ -246,7 +254,7 @@
 			// Add/remove read-only classes to remove hand pointer
 			this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly');
 		},// $.fn.rating.draw
-		
+
 		select: function(value){ // select a value
 			var control = this.data('rating'); if(!control) return this;
 			// do not execute when control is in read-only mode
@@ -260,16 +268,16 @@
  			 return $(control.stars[value]).rating('select');
 				// select by literal value (must be passed as a string
 				if(typeof value=='string')
-					//return 
+					//return
 					$.each(control.stars, function(){
 						if($(this).data('rating.input').val()==value) $(this).rating('select');
 					});
 			}
 			else
-				control.current = this[0].tagName=='INPUT' ? 
-				 this.data('rating.star') : 
+				control.current = this[0].tagName=='INPUT' ?
+				 this.data('rating.star') :
 					(this.is('.rater-'+ control.serial) ? this : null);
-			
+
 			// Update rating control state
 			this.data('rating', control);
 			// Update display
@@ -279,7 +287,7 @@
 			// click callback, as requested here: http://plugins.jquery.com/node/1655
 			if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);//
callback event
 		},// $.fn.rating.select
-		
+
 		readOnly: function(toggle, disable){ // make the control read-only (still submits value)
 			var control = this.data('rating'); if(!control) return this;
 			// setread-only status
@@ -292,19 +300,19 @@
 			// Update display
 			this.rating('draw');
 		},// $.fn.rating.readOnly
-		
+
 		disable: function(){ // make read-only and never submit value
 			this.rating('readOnly', true, true);
 		},// $.fn.rating.disable
-		
+
 		enable: function(){ // make read/write and submit value
 			this.rating('readOnly', false, false);
 		}// $.fn.rating.select
-		
+
  });
-	
+
 	/*--------------------------------------------------------*/
-	
+
 	/*
 		### Default Settings ###
 		eg.: You can override default control like this:
@@ -314,11 +322,11 @@
 			cancel: 'Cancel Rating',   // advisory title for the 'cancel' link
 			cancelValue: '',           // value to submit when user click the 'cancel' link
 			split: 0,                  // split the star into how many parts?
-			
+
 			// Width of star image in case the plugin can't work it out. This can happen if
 			// the jQuery.dimensions plugin is not available OR the image is hidden at installation
 			starWidth: 16//,
-			
+
 			//NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code!
 			//half:     false,         // just a shortcut to control.split = 2
 			//required: false,         // disables the 'cancel' button so user can only select one
of the specified values
@@ -327,18 +335,20 @@
 			//blur:     function(){},  // executed when stars are focused
 			//callback: function(){},  // executed when a star is clicked
  }; //} });
-	
+
 	/*--------------------------------------------------------*/
-	
+
 	/*
 		### Default implementation ###
 		The plugin will attach itself to file inputs
 		with the class 'multi' when the page loads
 	*/
-	$(function(){ $('input[type=radio].star').rating(); });
-	
-	
-	
+	$(function(){
+	 $('input[type=radio].star').rating();
+	});
+
+
+
 /*# AVOID COLLISIONS #*/
 })(jQuery);
 /*# AVOID COLLISIONS #*/



Mime
View raw message