/* * # Semantic UI - 1.7.0 * https://github.com/Semantic-Org/Semantic-UI * http://www.semantic-ui.com/ * * Copyright 2014 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * */ !function(e,n,t,a){"use strict";e.fn.rating=function(n){var t,i=e(this),o=i.selector||"",r=(new Date).getTime(),s=[],l=arguments[0],c="string"==typeof l,u=[].slice.call(arguments,1);return i.each(function(){var g,d=e.isPlainObject(n)?e.extend(!0,{},e.fn.rating.settings,n):e.extend({},e.fn.rating.settings),m=d.namespace,f=d.className,v=d.metadata,p=d.selector,b=(d.error,"."+m),h="module-"+m,y=this,R=e(this).data(h),C=e(this),x=C.find(p.icon);g={initialize:function(){g.verbose("Initializing rating module",d),0===x.length&&g.setup.layout(),d.interactive?g.enable():g.disable(),d.initialRating&&(g.debug("Setting initial rating"),g.setRating(d.initialRating)),C.data(v.rating)&&(g.debug("Rating found in metadata"),g.setRating(C.data(v.rating))),g.instantiate()},instantiate:function(){g.verbose("Instantiating module",d),R=g,C.data(h,g)},destroy:function(){g.verbose("Destroying previous instance",R),C.removeData(h),x.off(b)},refresh:function(){x=C.find(p.icon)},setup:{layout:function(){var n=C.data(v.maxRating)||d.maxRating;g.debug("Generating icon html dynamically"),C.html(e.fn.rating.settings.templates.icon(n)),g.refresh()}},event:{mouseenter:function(){var n=e(this);n.nextAll().removeClass(f.selected),C.addClass(f.selected),n.addClass(f.selected).prevAll().addClass(f.selected)},mouseleave:function(){C.removeClass(f.selected),x.removeClass(f.selected)},click:function(){var n=e(this),t=g.getRating(),a=x.index(n)+1,i="auto"==d.clearable?1===x.length:d.clearable;i&&t==a?g.clearRating():g.setRating(a)}},clearRating:function(){g.debug("Clearing current rating"),g.setRating(0)},getRating:function(){var e=x.filter("."+f.active).length;return g.verbose("Current rating retrieved",e),e},enable:function(){g.debug("Setting rating to interactive mode"),x.on("mouseenter"+b,g.event.mouseenter).on("mouseleave"+b,g.event.mouseleave).on("click"+b,g.event.click),C.removeClass(f.disabled)},disable:function(){g.debug("Setting rating to read-only mode"),x.off(b),C.addClass(f.disabled)},setRating:function(e){var n=e-1>=0?e-1:0,t=x.eq(n);C.removeClass(f.selected),x.removeClass(f.selected).removeClass(f.active),e>0&&(g.verbose("Setting current rating to",e),t.prevAll().andSelf().addClass(f.active)),d.onRate.call(y,e)},setting:function(n,t){if(g.debug("Changing setting",n,t),e.isPlainObject(n))e.extend(!0,d,n);else{if(t===a)return d[n];d[n]=t}},internal:function(n,t){if(e.isPlainObject(n))e.extend(!0,g,n);else{if(t===a)return g[n];g[n]=t}},debug:function(){d.debug&&(d.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,d.name+":"),g.debug.apply(console,arguments)))},verbose:function(){d.verbose&&d.debug&&(d.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,d.name+":"),g.verbose.apply(console,arguments)))},error:function(){g.error=Function.prototype.bind.call(console.error,console,d.name+":"),g.error.apply(console,arguments)},performance:{log:function(e){var n,t,a;d.performance&&(n=(new Date).getTime(),a=r||n,t=n-a,r=n,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:y,"Execution Time":t})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,100)},display:function(){var n=d.name+":",t=0;r=!1,clearTimeout(g.performance.timer),e.each(s,function(e,n){t+=n["Execution Time"]}),n+=" "+t+"ms",o&&(n+=" '"+o+"'"),i.length>1&&(n+=" ("+i.length+")"),(console.group!==a||console.table!==a)&&s.length>0&&(console.groupCollapsed(n),console.table?console.table(s):e.each(s,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(n,i,o){var r,s,l,c=R;return i=i||u,o=y||o,"string"==typeof n&&c!==a&&(n=n.split(/[\. ]/),r=n.length-1,e.each(n,function(t,i){var o=t!=r?i+n[t+1].charAt(0).toUpperCase()+n[t+1].slice(1):n;if(e.isPlainObject(c[o])&&t!=r)c=c[o];else{if(c[o]!==a)return s=c[o],!1;if(!e.isPlainObject(c[i])||t==r)return c[i]!==a?(s=c[i],!1):!1;c=c[i]}})),e.isFunction(s)?l=s.apply(o,i):s!==a&&(l=s),e.isArray(t)?t.push(l):t!==a?t=[t,l]:l!==a&&(t=l),s}},c?(R===a&&g.initialize(),g.invoke(l)):(R!==a&&g.destroy(),g.initialize())}),t!==a?t:this},e.fn.rating.settings={name:"Rating",namespace:"rating",debug:!1,verbose:!0,performance:!0,initialRating:0,interactive:!0,maxRating:4,clearable:"auto",onRate:function(){},error:{method:"The method you called is not defined",noMaximum:"No maximum rating specified. Cannot generate HTML automatically"},metadata:{rating:"rating",maxRating:"maxRating"},className:{active:"active",disabled:"disabled",selected:"selected",loading:"loading"},selector:{icon:".icon"},templates:{icon:function(e){for(var n=1,t="";e>=n;)t+='',n++;return t}}}}(jQuery,window,document);