From f4f45b442eebc20c5baa859bd67b875bc1f6f1f7 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 23 Jun 2013 17:43:54 -0700 Subject: [PATCH] Updated rating class --- e107_handlers/rate_class.php | 35 +- e107_web/css/e107.css | 3 + e107_web/js/core/all.jquery.css | 4 +- e107_web/js/core/all.jquery.js | 49 +- e107_web/js/rate/js/jquery.raty.js | 936 +++++++++++++++-------------- 5 files changed, 552 insertions(+), 475 deletions(-) diff --git a/e107_handlers/rate_class.php b/e107_handlers/rate_class.php index 892597eef..5453cec2f 100644 --- a/e107_handlers/rate_class.php +++ b/e107_handlers/rate_class.php @@ -19,7 +19,11 @@ class rater { function render($table,$id,$options=array()) { + list($votes,$score,$uvoted) = $this->getrating($table, $id); + + // return "Table=".$table." itmeId=".$id." Votes=".$votes." score=".$score; + parse_str($options,$options); // $label = varset($options['label'],RATELAN_5); @@ -34,6 +38,7 @@ class rater { $score = ($score / 2); // var_dump($readonly); + if(!$votes) { $voteDiz = RATELAN_4; @@ -54,11 +59,11 @@ class rater { $readonly = '1'; } - $template = vartrue($options['template'], "STATUS|RATE|VOTES"); + $template = vartrue($options['template'], " STATUS |RATE|VOTES"); - $TEMPLATE['STATUS'] = "
".$label."
"; + $TEMPLATE['STATUS'] = " ".$label.""; $TEMPLATE['RATE'] = "
"; - $TEMPLATE['VOTES'] = "
".$this->renderVotes($votes,$score)."
"; + $TEMPLATE['VOTES'] = "
".$this->renderVotes($votes,$score)."
"; $tmp = explode("|",$template); @@ -185,11 +190,16 @@ class rater { $sep = chr(1); $sql = new db; - if (!$sql->db_Select("rate", "*", "rate_table = '{$table}' AND rate_itemid = '{$id}' ")) { + if (!$sql->select("rate", "*", "rate_table = '{$table}' AND rate_itemid = '{$id}' ")) + { return FALSE; - } else { - $rowgr = $sql->db_Fetch(); - if($userid==TRUE){ + } + else + { + $rowgr = $sql->fetch(); + + if($userid==TRUE) + { $rating = ""; $rateusers = explode(".", $rowgr['rate_voters']); for($i=0;$i - * - */ - -;(function($) { - - var methods = { - init: function(settings) { - return this.each(function() { - var self = this, - $this = $(self).empty(); - - self.opt = $.extend(true, {}, $.fn.raty.defaults, settings); - - $this.data('settings', self.opt); - - self.opt.number = methods.between(self.opt.number, 0, 20); - - if (self.opt.path.substring(self.opt.path.length - 1, self.opt.path.length) != '/') { - self.opt.path += '/'; - } - - if (typeof self.opt.score == 'function') { - self.opt.score = self.opt.score.call(self); - } - - if (self.opt.score) { - self.opt.score = methods.between(self.opt.score, 0, self.opt.number); - } - - for (var i = 1; i <= self.opt.number; i++) { - $('', { - src : self.opt.path + ((!self.opt.score || self.opt.score < i) ? self.opt.starOff : self.opt.starOn), - alt : i, - 'class' : self.opt.css, - title : (i <= self.opt.hints.length && self.opt.hints[i - 1] !== null) ? self.opt.hints[i - 1] : i - }).appendTo(self); - - if (self.opt.space) { - $this.append((i < self.opt.number) ? ' ' : ''); - } - } - - self.stars = $this.children('img:not(".raty-cancel")'); - self.score = $('', { type: 'hidden', name: self.opt.scoreName }).appendTo(self); - - if (self.opt.score && self.opt.score > 0) { - self.score.val(self.opt.score); - methods.roundStar.call(self, self.opt.score); - } - - if (self.opt.iconRange) { - methods.fill.call(self, self.opt.score); - } - - methods.setTarget.call(self, self.opt.score, self.opt.targetKeep); - - var space = self.opt.space ? 4 : 0, - width = self.opt.width || (self.opt.number * self.opt.size + self.opt.number * space); - - if (self.opt.cancel) { - self.cancel = $('', { src: self.opt.path + self.opt.cancelOff, alt: 'x', title: self.opt.cancelHint, 'class': 'raty-cancel' }); - - if (self.opt.cancelPlace == 'left') { - $this.prepend(' ').prepend(self.cancel); - } else { - $this.append(' ').append(self.cancel); - } - - width += (self.opt.size + space); - } - - if (self.opt.readOnly) { - methods.fixHint.call(self); - - if (self.cancel) { - self.cancel.hide(); - } - } else { - $this.css('cursor', 'pointer'); - - methods.bindAction.call(self); - } - - // $this.css('width', width); - }); - }, between: function(value, min, max) { - return Math.min(Math.max(parseFloat(value), min), max); - }, bindAction: function() { - var self = this, - $this = $(self); - - $this.mouseleave(function() { - var score = self.score.val() || undefined; - - methods.initialize.call(self, score); - methods.setTarget.call(self, score, self.opt.targetKeep); - - if (self.opt.mouseover) { - self.opt.mouseover.call(self, score); - } - }); - - var action = self.opt.half ? 'mousemove' : 'mouseover'; - - if (self.opt.cancel) { - self.cancel.mouseenter(function() { - $(this).attr('src', self.opt.path + self.opt.cancelOn); - - self.stars.attr('src', self.opt.path + self.opt.starOff); - - methods.setTarget.call(self, null, true); - - if (self.opt.mouseover) { - self.opt.mouseover.call(self, null); - } - }).mouseleave(function() { - $(this).attr('src', self.opt.path + self.opt.cancelOff); - - if (self.opt.mouseover) { - self.opt.mouseover.call(self, self.score.val() || null); - } - }).click(function(evt) { - self.score.removeAttr('value'); - - if (self.opt.click) { - self.opt.click.call(self, null, evt); - } - }); - } - - self.stars.bind(action, function(evt) { - var value = parseInt(this.alt, 10); - - if (self.opt.half) { - var position = parseFloat((evt.pageX - $(this).offset().left) / self.opt.size), - diff = (position > .5) ? 1 : .5; - - value = parseFloat(this.alt) - 1 + diff; - - methods.fill.call(self, value); - - if (self.opt.precision) { - value = value - diff + position; - } - - methods.showHalf.call(self, value); - } else { - methods.fill.call(self, value); - } - - $this.data('score', value); - - methods.setTarget.call(self, value, true); - - if (self.opt.mouseover) { - self.opt.mouseover.call(self, value, evt); - } - }).click(function(evt) { - self.score.val((self.opt.half || self.opt.precision) ? $this.data('score') : this.alt); - - if (self.opt.click) { - self.opt.click.call(self, self.score.val(), evt); - } - }); - }, cancel: function(isClick) { - return $(this).each(function() { - var self = this, - $this = $(self); - - if ($this.data('readonly') === true) { - return this; - } - - if (isClick) { - methods.click.call(self, null); - } else { - methods.score.call(self, null); - } - - self.score.removeAttr('value'); - }); - }, click: function(score) { - return $(this).each(function() { - if ($(this).data('readonly') === true) { - return this; - } - - methods.initialize.call(this, score); - - if (this.opt.click) { - this.opt.click.call(this, score); - } else { - methods.error.call(this, 'you must add the "click: function(score, evt) { }" callback.'); - } - - methods.setTarget.call(this, score, true); - }); - }, error: function(message) { - $(this).html(message); - - $.error(message); - }, fill: function(score) { - var self = this, - number = self.stars.length, - count = 0, - $star , - star , - icon ; - - for (var i = 1; i <= number; i++) { - $star = self.stars.eq(i - 1); - - if (self.opt.iconRange && self.opt.iconRange.length > count) { - star = self.opt.iconRange[count]; - - if (self.opt.single) { - icon = (i == score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff); - } else { - icon = (i <= score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff); - } - - if (i <= star.range) { - $star.attr('src', self.opt.path + icon); - } - - if (i == star.range) { - count++; - } - } else { - if (self.opt.single) { - icon = (i == score) ? self.opt.starOn : self.opt.starOff; - } else { - icon = (i <= score) ? self.opt.starOn : self.opt.starOff; - } - - $star.attr('src', self.opt.path + icon); - } - } - }, fixHint: function() { - var $this = $(this), - score = parseInt(this.score.val(), 10), - hint = this.opt.noRatedMsg; - - if (!isNaN(score) && score > 0) { - hint = (score <= this.opt.hints.length && this.opt.hints[score - 1] !== null) ? this.opt.hints[score - 1] : score; - } - - $this.data('readonly', true).css('cursor', 'default').attr('title', hint); - - this.score.attr('readonly', 'readonly'); - this.stars.attr('title', hint); - }, getScore: function() { - var score = [], - value ; - - $(this).each(function() { - value = this.score.val(); - - score.push(value ? parseFloat(value) : undefined); - }); - - return (score.length > 1) ? score : score[0]; - }, readOnly: function(isReadOnly) { - return this.each(function() { - var $this = $(this); - - if ($this.data('readonly') === isReadOnly) { - return this; - } - - if (this.cancel) { - if (isReadOnly) { - this.cancel.hide(); - } else { - this.cancel.show(); - } - } - - if (isReadOnly) { - $this.unbind(); - - $this.children('img').unbind(); - - methods.fixHint.call(this); - } else { - methods.bindAction.call(this); - methods.unfixHint.call(this); - } - - $this.data('readonly', isReadOnly); - }); - }, reload: function() { - return methods.set.call(this, {}); - }, roundStar: function(score) { - var diff = (score - Math.floor(score)).toFixed(2); - - if (diff > this.opt.round.down) { - var icon = this.opt.starOn; // Full up: [x.76 .. x.99] - - if (diff < this.opt.round.up && this.opt.halfShow) { // Half: [x.26 .. x.75] - icon = this.opt.starHalf; - } else if (diff < this.opt.round.full) { // Full down: [x.00 .. x.5] - icon = this.opt.starOff; - } - - this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + icon); - } // Full down: [x.00 .. x.25] - }, score: function() { - return arguments.length ? methods.setScore.apply(this, arguments) : methods.getScore.call(this); - }, set: function(settings) { - this.each(function() { - var $this = $(this), - actual = $this.data('settings'), - clone = $this.clone().removeAttr('style').insertBefore($this); - - $this.remove(); - - clone.raty($.extend(actual, settings)); - }); - - return $(this.selector); - }, setScore: function(score) { - return $(this).each(function() { - if ($(this).data('readonly') === true) { - return this; - } - - methods.initialize.call(this, score); - methods.setTarget.call(this, score, true); - }); - }, setTarget: function(value, isKeep) { - if (this.opt.target) { - var $target = $(this.opt.target); - - if ($target.length == 0) { - methods.error.call(this, 'target selector invalid or missing!'); - } - - var score = value; - - if (!isKeep || score === undefined) { - score = this.opt.targetText; - } else { - if (this.opt.targetType == 'hint') { - score = (score === null && this.opt.cancel) - ? this.opt.cancelHint - : this.opt.hints[Math.ceil(score - 1)]; - } else { - score = this.opt.precision - ? parseFloat(score).toFixed(1) - : parseInt(score, 10); - } - } - - if (this.opt.targetFormat.indexOf('{score}') < 0) { - methods.error.call(this, 'template "{score}" missing!'); - } - - if (value !== null) { - score = this.opt.targetFormat.toString().replace('{score}', score); - } - - if ($target.is(':input')) { - $target.val(score); - } else { - $target.html(score); - } - } - }, showHalf: function(score) { - var diff = (score - Math.floor(score)).toFixed(1); - - if (diff > 0 && diff < .6) { - this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + this.opt.starHalf); - } - }, initialize: function(score) { - score = !score ? 0 : methods.between(score, 0, this.opt.number); - - methods.fill.call(this, score); - - if (score > 0) { - if (this.opt.halfShow) { - methods.roundStar.call(this, score); - } - - this.score.val(score); - } - }, unfixHint: function() { - for (var i = 0; i < this.opt.number; i++) { - this.stars.eq(i).attr('title', (i < this.opt.hints.length && this.opt.hints[i] !== null) ? this.opt.hints[i] : i); - } - - $(this).data('readonly', false).css('cursor', 'pointer').removeAttr('title'); - - this.score.attr('readonly', 'readonly'); - } - }; - - $.fn.raty = function(method) { - if (methods[method]) { - return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === 'object' || !method) { - return methods.init.apply(this, arguments); - } else { - $.error('Method ' + method + ' does not exist!'); - } - }; - - $.fn.raty.defaults = { - cancel : false, - cancelHint : 'cancel this rating!', - cancelOff : 'cancel-off.png', - cancelOn : 'cancel-on.png', - cancelPlace : 'left', - click : undefined, - half : false, - halfShow : true, - hints : ['bad', 'poor', 'regular', 'good', 'gorgeous'], - iconRange : undefined, - mouseover : undefined, - noRatedMsg : 'not rated yet', - number : 5, - path : 'img/', - precision : false, - round : { down: .25, full: .6, up: .76 }, - readOnly : false, - score : undefined, - scoreName : 'score', - single : false, - size : 16, - space : true, - starHalf : 'star-half.png', - starOff : 'star-off.png', - starOn : 'star-on.png', - target : undefined, - targetFormat : '{score}', - targetKeep : false, - targetText : '', - targetType : 'hint', - width : undefined, - css : 'raty' - }; - -})(jQuery); +/*! + * jQuery Raty - A Star Rating Plugin + * ------------------------------------------------------------------ + * + * jQuery Raty is a plugin that generates a customizable star rating. + * + * Licensed under The MIT License + * + * @version 2.5.2 + * @since 2010.06.11 + * @author Washington Botelho + * @documentation wbotelhos.com/raty + * + * ------------------------------------------------------------------ + * + *
+ * + * $('#star').raty(); + * + */ + +;(function($) { + + var methods = { + init: function(settings) { + return this.each(function() { + methods.destroy.call(this); + + this.opt = $.extend(true, {}, $.fn.raty.defaults, settings); + + var that = $(this), + inits = ['number', 'readOnly', 'score', 'scoreName']; + + methods._callback.call(this, inits); + + if (this.opt.precision) { + methods._adjustPrecision.call(this); + } + + this.opt.number = methods._between(this.opt.number, 0, this.opt.numberMax); + + this.opt.path = this.opt.path || ''; + + if (this.opt.path && this.opt.path.charAt( this.opt.path.length - 1 ) !== '/') { + this.opt.path += '/'; + } + + this.stars = methods._createStars.call(this); + this.score = methods._createScore.call(this); + + methods._apply.call(this, this.opt.score); + + var space = this.opt.space ? 4 : 0, + width = this.opt.width || (this.opt.number * this.opt.size + this.opt.number * space); + + if (this.opt.cancel) { + this.cancel = methods._createCancel.call(this); + + width += (this.opt.size + space); + } + + if (this.opt.readOnly) { + methods._lock.call(this); + } else { + that.css('cursor', 'pointer'); + methods._binds.call(this); + } + + if (this.opt.width !== false) { + that.css('width', width); + } + + methods._target.call(this, this.opt.score); + + that.data({ 'settings': this.opt, 'raty': true }); + }); + }, _adjustPrecision: function() { + this.opt.targetType = 'score'; + this.opt.half = true; + }, _apply: function(score) { + if (score && score > 0) { + score = methods._between(score, 0, this.opt.number); + this.score.val(score); + } + + methods._fill.call(this, score); + + if (score) { + methods._roundStars.call(this, score); + } + }, _between: function(value, min, max) { + return Math.min(Math.max(parseFloat(value), min), max); + }, _binds: function() { + if (this.cancel) { + methods._bindCancel.call(this); + } + + methods._bindClick.call(this); + methods._bindOut.call(this); + methods._bindOver.call(this); + }, _bindCancel: function() { + methods._bindClickCancel.call(this); + methods._bindOutCancel.call(this); + methods._bindOverCancel.call(this); + }, _bindClick: function() { + var self = this, + that = $(self); + + self.stars.on('click.raty', function(evt) { + self.score.val((self.opt.half || self.opt.precision) ? that.data('score') : this.alt); + + if (self.opt.click) { + self.opt.click.call(self, parseFloat(self.score.val()), evt); + } + }); + }, _bindClickCancel: function() { + var self = this; + + self.cancel.on('click.raty', function(evt) { + self.score.removeAttr('value'); + + if (self.opt.click) { + self.opt.click.call(self, null, evt); + } + }); + }, _bindOut: function() { + var self = this; + + $(this).on('mouseleave.raty', function(evt) { + var score = parseFloat(self.score.val()) || undefined; + + methods._apply.call(self, score); + methods._target.call(self, score, evt); + + if (self.opt.mouseout) { + self.opt.mouseout.call(self, score, evt); + } + }); + }, _bindOutCancel: function() { + var self = this; + + self.cancel.on('mouseleave.raty', function(evt) { + $(this).attr('src', self.opt.path + self.opt.cancelOff); + + if (self.opt.mouseout) { + self.opt.mouseout.call(self, self.score.val() || null, evt); + } + }); + }, _bindOverCancel: function() { + var self = this; + + self.cancel.on('mouseover.raty', function(evt) { + $(this).attr('src', self.opt.path + self.opt.cancelOn); + + self.stars.attr('src', self.opt.path + self.opt.starOff); + + methods._target.call(self, null, evt); + + if (self.opt.mouseover) { + self.opt.mouseover.call(self, null); + } + }); + }, _bindOver: function() { + var self = this, + that = $(self), + action = self.opt.half ? 'mousemove.raty' : 'mouseover.raty'; + + self.stars.on(action, function(evt) { + var score = parseInt(this.alt, 10); + + if (self.opt.half) { + var position = parseFloat((evt.pageX - $(this).offset().left) / self.opt.size), + plus = (position > .5) ? 1 : .5; + + score = score - 1 + plus; + + methods._fill.call(self, score); + + if (self.opt.precision) { + score = score - plus + position; + } + + methods._roundStars.call(self, score); + + that.data('score', score); + } else { + methods._fill.call(self, score); + } + + methods._target.call(self, score, evt); + + if (self.opt.mouseover) { + self.opt.mouseover.call(self, score, evt); + } + }); + }, _callback: function(options) { + for (i in options) { + if (typeof this.opt[options[i]] === 'function') { + this.opt[options[i]] = this.opt[options[i]].call(this); + } + } + }, _createCancel: function() { + var that = $(this), + icon = this.opt.path + this.opt.cancelOff, + cancel = $('', { src: icon, alt: 'x', title: this.opt.cancelHint, 'class': 'raty-cancel' }); + + if (this.opt.cancelPlace == 'left') { + that.prepend(' ').prepend(cancel); + } else { + that.append(' ').append(cancel); + } + + return cancel; + }, _createScore: function() { + return $('', { type: 'hidden', name: this.opt.scoreName }).appendTo(this); + }, _createStars: function() { + var that = $(this); + + for (var i = 1; i <= this.opt.number; i++) { + var title = methods._getHint.call(this, i), + icon = (this.opt.score && this.opt.score >= i) ? 'starOn' : 'starOff'; + + icon = this.opt.path + this.opt[icon]; + + $('', { src : icon, alt: i, title: title }).appendTo(this); + + if (this.opt.space) { + that.append((i < this.opt.number) ? ' ' : ''); + } + } + + return that.children('img'); + }, _error: function(message) { + $(this).html(message); + + $.error(message); + }, _fill: function(score) { + var self = this, + hash = 0; + + for (var i = 1; i <= self.stars.length; i++) { + var star = self.stars.eq(i - 1), + select = self.opt.single ? (i == score) : (i <= score); + + if (self.opt.iconRange && self.opt.iconRange.length > hash) { + var irange = self.opt.iconRange[hash], + on = irange.on || self.opt.starOn, + off = irange.off || self.opt.starOff, + icon = select ? on : off; + + if (i <= irange.range) { + star.attr('src', self.opt.path + icon); + } + + if (i == irange.range) { + hash++; + } + } else { + var icon = select ? 'starOn' : 'starOff'; + + star.attr('src', this.opt.path + this.opt[icon]); + } + } + }, _getHint: function(score) { + var hint = this.opt.hints[score - 1]; + return (hint === '') ? '' : (hint || score); + }, _lock: function() { + var score = parseInt(this.score.val(), 10), // TODO: 3.1 >> [['1'], ['2'], ['3', '.1', '.2']] + hint = score ? methods._getHint.call(this, score) : this.opt.noRatedMsg; + + $(this).data('readonly', true).css('cursor', '').attr('title', hint); + + this.score.attr('readonly', 'readonly'); + this.stars.attr('title', hint); + + if (this.cancel) { + this.cancel.hide(); + } + }, _roundStars: function(score) { + var rest = (score - Math.floor(score)).toFixed(2); + + if (rest > this.opt.round.down) { + var icon = 'starOn'; // Up: [x.76 .. x.99] + + if (this.opt.halfShow && rest < this.opt.round.up) { // Half: [x.26 .. x.75] + icon = 'starHalf'; + } else if (rest < this.opt.round.full) { // Down: [x.00 .. x.5] + icon = 'starOff'; + } + + this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + this.opt[icon]); + } // Full down: [x.00 .. x.25] + }, _target: function(score, evt) { + if (this.opt.target) { + var target = $(this.opt.target); + + if (target.length === 0) { + methods._error.call(this, 'Target selector invalid or missing!'); + } + + if (this.opt.targetFormat.indexOf('{score}') < 0) { + methods._error.call(this, 'Template "{score}" missing!'); + } + + var mouseover = evt && evt.type == 'mouseover'; + + if (score === undefined) { + score = this.opt.targetText; + } else if (score === null) { + score = mouseover ? this.opt.cancelHint : this.opt.targetText; + } else { + if (this.opt.targetType == 'hint') { + score = methods._getHint.call(this, Math.ceil(score)); + } else if (this.opt.precision) { + score = parseFloat(score).toFixed(1); + } + + if (!mouseover && !this.opt.targetKeep) { + score = this.opt.targetText; + } + } + + if (score) { + score = this.opt.targetFormat.toString().replace('{score}', score); + } + + if (target.is(':input')) { + target.val(score); + } else { + target.html(score); + } + } + }, _unlock: function() { + $(this).data('readonly', false).css('cursor', 'pointer').removeAttr('title'); + + this.score.removeAttr('readonly', 'readonly'); + + for (var i = 0; i < this.opt.number; i++) { + this.stars.eq(i).attr('title', methods._getHint.call(this, i + 1)); + } + + if (this.cancel) { + this.cancel.css('display', ''); + } + }, cancel: function(click) { + return this.each(function() { + if ($(this).data('readonly') !== true) { + methods[click ? 'click' : 'score'].call(this, null); + this.score.removeAttr('value'); + } + }); + }, click: function(score) { + return $(this).each(function() { + if ($(this).data('readonly') !== true) { + methods._apply.call(this, score); + + if (!this.opt.click) { + methods._error.call(this, 'You must add the "click: function(score, evt) { }" callback.'); + } + + + this.opt.click.call(this, score, $.Event('click')); + + methods._target.call(this, score); + } + }); + }, destroy: function() { + return $(this).each(function() { + var that = $(this), + raw = that.data('raw'); + + if (raw) { + that.off('.raty').empty().css({ cursor: raw.style.cursor, width: raw.style.width }).removeData('readonly'); + } else { + that.data('raw', that.clone()[0]); + } + }); + }, getScore: function() { + var score = [], + value ; + + $(this).each(function() { + value = this.score.val(); + + score.push(value ? parseFloat(value) : undefined); + }); + + return (score.length > 1) ? score : score[0]; + }, readOnly: function(readonly) { + return this.each(function() { + var that = $(this); + + if (that.data('readonly') !== readonly) { + if (readonly) { + that.off('.raty').children('img').off('.raty'); + + methods._lock.call(this); + } else { + methods._binds.call(this); + methods._unlock.call(this); + } + + that.data('readonly', readonly); + } + }); + }, reload: function() { + return methods.set.call(this, {}); + }, score: function() { + return arguments.length ? methods.setScore.apply(this, arguments) : methods.getScore.call(this); + }, set: function(settings) { + return this.each(function() { + var that = $(this), + actual = that.data('settings'), + news = $.extend({}, actual, settings); + + that.raty(news); + }); + }, setScore: function(score) { + return $(this).each(function() { + if ($(this).data('readonly') !== true) { + methods._apply.call(this, score); + methods._target.call(this, score); + } + }); + } + }; + + $.fn.raty = function(method) { + if (methods[method]) { + return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (typeof method === 'object' || !method) { + return methods.init.apply(this, arguments); + } else { + $.error('Method ' + method + ' does not exist!'); + } + }; + + $.fn.raty.defaults = { + cancel : false, + cancelHint : 'Cancel this rating!', + cancelOff : 'cancel-off.png', + cancelOn : 'cancel-on.png', + cancelPlace : 'left', + click : undefined, + half : false, + halfShow : true, + hints : ['bad', 'poor', 'regular', 'good', 'gorgeous'], + iconRange : undefined, + mouseout : undefined, + mouseover : undefined, + noRatedMsg : 'Not rated yet!', + number : 5, + numberMax : 20, + path : '', + precision : false, + readOnly : false, + round : { down: .25, full: .6, up: .76 }, + score : undefined, + scoreName : 'score', + single : false, + size : 16, + space : true, + starHalf : 'star-half.png', + starOff : 'star-off.png', + starOn : 'star-on.png', + target : undefined, + targetFormat : '{score}', + targetKeep : false, + targetText : '', + targetType : 'hint', + width : undefined + }; + +})(jQuery);