PageSourceSearch

https://www.ghsproducts.com/content/vendors/jquery/rater/jquery.rater-custom.js?387r3=2

js ghsproducts.com collected 2026-10-06 15:19:23 UTC 5,261 bytes, 126 lines download raw bytes

1/**�
2 * jQuery Ajax Rater Plugin�
3 *�
4 * This rater is based on the code Ritesh Agrawal did. Unfortunatly his CSS and the hover technique breaks in some browsers.�
5 * So i thought, why not use the best CSS star-rater known to man kind and throw it in the mix.�
6 * I have used the CSS and technique from Komodo Media since it is stable and tested on many, many browsers.�
7 *�
8 * This rater compared, has no cancel button. But i think we can live with that :)�
9 * To avoid conflicts i have changed the function name.�
10 * �
11 * Licensed under The MIT License�
12 * �
13 * @version     1.0�
14 * @mod         Customized by DDM�
15 * @since       03.01.2007�
16 * @author      Kjell Bublitz <[email protected]�
17 * @link        http://www.m3nt0r.de/devel/raterDemo/ Demonstration and Documentation�
18 * @link        http://php.scripts.psu.edu/rja171/widgets/rating.php Based on Ritesh Agrawal Star Rating System�
19 * @link        http://komodomedia.com/blog/index.php/2007/01/20/css-star-rating-redux/ The Komodo Media CSS Rater Blogpost�
20 * @license     http://www.opensource.org/licenses/mit-license.php MIT �
21 * @package     jQuery Plugins�
22 * @subpackage  Rater�
23 */ �
24�
25/**�
26 * Usage: $('#rating').rater('your_servlet', {style:'basic', maxvalue:5, curvalue:0});�
27 *  �
28 * @param url The address you want to post the result to. �
29 * @param options The style and value attributes�
30 *�
31 * Valid options:s�
32 * ---------------------------------------�
33 *       style:       'basic', 'inline' OR 'small'�
34 *       maxvalue:    the maximum value / number of stars�
35 *       curvalue:    the initial value / selected stars�
36 *       sticky:      boolean true/false�
37 *       disable:     boolean true/false disable selection�
38 */ �
39jQuery.fn.rater = function(options)�
40{�
41	var settings = {�
42		url            : null,  // post changes to �
43		maxvalue       : 5,    // max number of stars�
44		starwidth      : 25,�
45		smallstarwidth : 10,�
46		curvalue       : 0,    // number of selected stars�
47		disable        : false,  // disable selection�
48		callback       : function(){},�
49		result         : 'star-rating-result' // selector to display result�
50	};�
51	�
52	if (options) { jQuery.extend(settings, options); };�
53	jQuery.extend(settings, {cancel: (settings.maxvalue > 1) ? true : false});�
54	�
55	var container = jQuery(this);�
56	jQuery.extend(container, { averageRating: settings.curvalue, url: settings.url });�
57�
58	if(!settings.style || settings.style == null || settings.style == 'basic') {�
59		var raterwidth = settings.maxvalue * settings.starwidth;�
60		var ratingparent = '<ul class="star-rating" style="width:'+raterwidth+'px">';�
61	}�
62	if(settings.style == 'small') {�
63		var raterwidth = settings.maxvalue * settings.smallstarwidth;�
64		var ratingparent = '<ul class="star-rating small-star" style="width:'+raterwidth+'px">';�
65	}�
66	if(settings.style == 'inline') {�
67		var raterwidth = settings.maxvalue * settings.smallstarwidth;�
68		var ratingparent = '<span class="inline-rating"><ul class="star-rating small-star" style="width:'+raterwidth+'px">';�
69	}�
70	container.append(ratingparent);�
71	�
72	// create rater�
73	var starWidth, starIndex, listitems = '';�
74	var curvalueWidth = Math.floor(100 / settings.maxvalue * settings.curvalue);�
75	for(var i = 0; i <= settings.maxvalue ; i++) {�
76		if (i == 0) {�
77			listitems+='<li class="current-rating" style="width:'+curvalueWidth+'%;">'+settings.curvalue+'/'+settings.maxvalue+'</li>';�
78		} else {�
79			starWidth = Math.floor(100 / settings.maxvalue * i);�
80			starIndex = (settings.maxvalue - i) + 2;�
81			if (settings.disable)�
82			{�
83				listitems+='<li class="star"></li>';�
84			} else {�
85				listitems+='<li class="star"><a href="#'+i+'" title="'+i+'/'+settings.maxvalue +'" style="width:'+starWidth+'%;z-index:'+starIndex+'">'+i+'</a></li>';�
86			}�
87		}�
88	}�
89	container.find('.star-rating').append(listitems); // i am using find here, because the span wrapped in the small style would break children()�
90�
91	if(settings.maxvalue > 1) // add a container for the ajax result�
92	{�
93		container.append('<span class="'+settings.result+'"></span>'); �
94	}�
95	var stars = jQuery(container).find('.star-rating').children('.star');�
96	stars.click(function()�
97	{�
98		if(settings.maxvalue == 1) // on / off�
99		{�
100			settings.curvalue = (settings.curvalue == 0) ? 1 : 0;�
101			jQuery(container).find('.star-rating').children('.current-rating').css({width:(settings.curvalue*100)+'%'});�
102			jQuery.post(container.url, { "rating": settings.curvalue });�
103			return false;�
104		}�
105		else�
106		{�
107			settings.curvalue = stars.index(this) + 1;�
108			raterValue = jQuery(this).children('a')[0].href.split('#')[1];�
109			settings.callback(raterValue);�
110			if (settings.sticky)�
111			{�
112				jQuery(container).find('.star-rating').children('.current-rating').css({width:(Math.floor(100 / settings.maxvalue * raterValue))+'%'});�
113			}�
114			if (container.url != null)�
115			{�
116				jQuery.post(container.url, { "rating": raterValue }, function(response){�
117					container.children('.'+settings.result).html(response);�
118				});�
119			}�
120			return false;�
121		}�
122		return true;�
123	});�
124�
125	return this; // strict warning: anonymous function does not always return a value. fix?�
126}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.