2022-02-23 21:46:34 +00:00
|
|
|
!function(A,e,T){"use strict";A.isFunction=A.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},e=void 0!==e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),A.fn.rating=function(f){var v,p=A(this),b=p.selector||"",h=(new Date).getTime(),y=[],C=f,x="string"==typeof C,R=[].slice.call(arguments,1);return p.each(function(){var e,a=A.isPlainObject(f)?A.extend(!0,{},A.fn.rating.settings,f):A.extend({},A.fn.rating.settings),u=a.namespace,o=a.className,n=a.metadata,t=a.selector,d=a.cssVars,i="."+u,g="module-"+u,m=this,s=A(this).data(g),r=A(this),l=r.find(t.icon),c={initialize:function(){c.verbose("Initializing rating module",a),0===l.length&&c.setup.layout(),a.interactive&&!c.is.disabled()?c.enable():c.disable(),c.set.initialLoad(),c.set.rating(c.get.initialRating()),c.remove.initialLoad(),c.instantiate()},instantiate:function(){c.verbose("Instantiating module",a),s=c,r.data(g,c)},destroy:function(){c.verbose("Destroying previous instance",s),c.remove.events(),r.removeData(g)},refresh:function(){l=r.find(t.icon)},setup:{layout:function(){var e=c.get.maxRating(),n=c.get.icon(),e=A.fn.rating.settings.templates.icon(e,n);c.debug("Generating icon html dynamically"),r.html(e),c.refresh()}},event:{mouseenter:function(){var e=A(this);e.nextAll().removeClass(o.selected),r.addClass(o.selected),e.addClass(o.selected).prevAll().addClass(o.selected)},mouseleave:function(){r.removeClass(o.selected),l.removeClass(o.selected)},click:function(){var e=A(this),n=c.get.rating(),e=l.index(e)+1;("auto"==a.clearable?1===l.length:a.clearable)&&n==e?c.clearRating():c.set.rating(e)}},clearRating:function(){c.debug("Clearing current rating"),c.set.rating(0)},bind:{events:function(){c.verbose("Binding events"),r.on("mouseenter"+i,t.icon,c.event.mouseenter).on("mouseleave"+i,t.icon,c.event.mouseleave).on("click"+i,t.icon,c.event.click)}},remove:{events:function(){c.verbose("Removing events"),r.off(i)},initialLoad:function(){e=!1}},enable:function(){c.debug("Setting rating to interactive mode"),c.bind.events(),r.removeClass(o.disabled)},disable:function(){c.debug("Setting rating to read-only mode"),c.remove.events(),r.addClass(o.disabled)},is:{initialLoad:function(){return e},disabled:function(){return r.hasClass(o.disabled)}},get:{icon:function(){var e=r.data(n.icon);return e&&r.removeData(n.icon),e||a.icon},initialRating:function(){return r.data(n.rating)!==T?(r.removeData(n.rating),r.data(n.rating)):a.initialRating},maxRating:function(){return r.data(n.maxRating)!==T?(r.removeData(n.maxRating),r.data(n.maxRating)):a.maxRating},rating:function(){var e=l.filter("."+o.active).length;return c.verbose("Current rating retrieved",e),e}},set:{rating:function(e){var n=Math.floor(0<=e-1?e-1:0),n=l.eq(n),t=e<=1?n:n.next(),i=e%1*100;r.removeClass(o.selected),l.removeClass(o.selected).removeClass(o.active).removeClass(o.partiallyActive),0<e&&(c.verbose("Setting current rating to",e),n.prevAll().addBack().addClass(o.active),n.next()&&e%1!=0&&(t.addClass(o.partiallyActive).addClass(o.active),t.css(d.filledCustomPropName,i+"%"),"transparent"===t.css("backgroundColor")&&t.removeClass(o.partiallyActive).removeClass(o.active))),c.is.initialLoad()||a.onRate.call(m,e)},initialLoad:function(){e=!0}},setting:function(e,n){if(c.debug("Changing setting",e,n),A.isPlainObject(e))A.extend(!0,a,e);else{if(n===T)return a[e];A.isPlainObject(a[e])?A.extend(!0,a[e],n):a[e]=n}},internal:function(e,n){if(A.isPlainObject(e))A.extend(!0,c,e);else{if(n===T)return c[e];c[e]=n}},debug:function(){!a.silent&&a.debug&&(a.performance?c.performance.log(arguments):(c.debug=Function.prototype.bind.call(console.info,console,a.name+":"),c.debug.apply(console,arguments)))},verbose:function(){!a.silent&&a.verbose&&a.debug&&(a.performance?c.performance.log(arguments):(c.verbose=Function.prototype.bind.call(console.info,console,a.name+":"),c.verbose.apply(console,arguments)))},error:function(){a.silent||(c.error=Function.prototype.bind.call(console.error,console,a.name+":"),c.error.apply(console,arguments))},performance:{log:function(e
|