/*! * jQuery UI 1.8.4 * * Copyright 2010, 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 */ (function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.4",plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a=0)&&c(a).is(":focusable")}})}})(jQuery); /*! * jQuery UI Widget 1.8.4 * * Copyright 2010, 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/Widget */ (function(b,j){var k=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return k.call(b(this),a,c)})};b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options); b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.substring(0,1)==="_")return h;e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}): this.each(function(){var g=b.data(this,a);if(g){d&&g.option(d);g._init()}else b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,b.metadata&&b.metadata.get(c)[this.widgetName],a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()}); this._create();this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(a,c){var d=a,e=this;if(arguments.length===0)return b.extend({},e.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}b.each(d,function(f, h){e._setOption(f,h)});return e},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a= b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery); /*! * jQuery UI Stars v3.0.1 * http://plugins.jquery.com/project/Star_Rating_widget * * Copyright (c) 2010 Marek "Orkan" Zajac (orkans@gmail.com) * 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' }, oldCaption: '', // initialize default caption _create: function() { var self = this, o = this.options, starId = 0; this.element.data('former.stars', this.element.html()); // set default caption self.oldCaption = o.captionEl.text(); 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 = $('
').addClass(o.starClass); var $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 = $('
').addClass(o.cancelClass).append( $('').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 = $(""); 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); fillNoneNone(); }); /* * 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); // do not hide the default caption //self._showCap(''); self._showCap(self.oldCaption); }; function fillNoneNone() { self._showCap(self.oldCaption); }; /* * Finally, set up the Stars */ this.select(o.value); o.disabled && this.disable(); fillNoneNone(); }, /* * 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); }, _setCaption: function(s) { if (s.length > 0) { self.oldCaption = 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);