|
|
/*! * # Semantic UI 2.0.3 - Rating * http://github.com/semantic-org/semantic-ui/
* * * Copyright 2015 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT
* */ !function(e,n,t,i){"use strict";e.fn.rating=function(n){var t,a=e(this),o=a.selector||"",r=(new Date).getTime(),s=[],l=arguments[0],c="string"==typeof l,u=[].slice.call(arguments,1);return a.each(function(){var g,m=e.isPlainObject(n)?e.extend(!0,{},e.fn.rating.settings,n):e.extend({},e.fn.rating.settings),d=m.namespace,f=m.className,v=m.metadata,p=m.selector,b=(m.error,"."+d),h="module-"+d,y=this,x=e(this).data(h),R=e(this),C=R.find(p.icon);g={initialize:function(){g.verbose("Initializing rating module",m),0===C.length&&g.setup.layout(),m.interactive?g.enable():g.disable(),g.set.rating(g.get.initialRating()),g.instantiate()},instantiate:function(){g.verbose("Instantiating module",m),x=g,R.data(h,g)},destroy:function(){g.verbose("Destroying previous instance",x),g.remove.events(),R.removeData(h)},refresh:function(){C=R.find(p.icon)},setup:{layout:function(){var n=g.get.maxRating(),t=e.fn.rating.settings.templates.icon(n);g.debug("Generating icon html dynamically"),R.html(t),g.refresh()}},event:{mouseenter:function(){var n=e(this);n.nextAll().removeClass(f.selected),R.addClass(f.selected),n.addClass(f.selected).prevAll().addClass(f.selected)},mouseleave:function(){R.removeClass(f.selected),C.removeClass(f.selected)},click:function(){var n=e(this),t=g.get.rating(),i=C.index(n)+1,a="auto"==m.clearable?1===C.length:m.clearable;a&&t==i?g.clearRating():g.set.rating(i)}},clearRating:function(){g.debug("Clearing current rating"),g.set.rating(0)},bind:{events:function(){g.verbose("Binding events"),R.on("mouseenter"+b,p.icon,g.event.mouseenter).on("mouseleave"+b,p.icon,g.event.mouseleave).on("click"+b,p.icon,g.event.click)}},remove:{events:function(){g.verbose("Removing events"),R.off(b)}},enable:function(){g.debug("Setting rating to interactive mode"),g.bind.events(),R.removeClass(f.disabled)},disable:function(){g.debug("Setting rating to read-only mode"),g.remove.events(),R.addClass(f.disabled)},get:{initialRating:function(){return R.data(v.rating)!==i?(R.removeData(v.rating),R.data(v.rating)):m.initialRating},maxRating:function(){return R.data(v.maxRating)!==i?(R.removeData(v.maxRating),R.data(v.maxRating)):m.maxRating},rating:function(){var e=C.filter("."+f.active).length;return g.verbose("Current rating retrieved",e),e}},set:{rating:function(e){var n=e-1>=0?e-1:0,t=C.eq(n);R.removeClass(f.selected),C.removeClass(f.selected).removeClass(f.active),e>0&&(g.verbose("Setting current rating to",e),t.prevAll().andSelf().addClass(f.active)),m.onRate.call(y,e)}},setting:function(n,t){if(g.debug("Changing setting",n,t),e.isPlainObject(n))e.extend(!0,m,n);else{if(t===i)return m[n];m[n]=t}},internal:function(n,t){if(e.isPlainObject(n))e.extend(!0,g,n);else{if(t===i)return g[n];g[n]=t}},debug:function(){m.debug&&(m.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,m.name+":"),g.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),g.verbose.apply(console,arguments)))},error:function(){g.error=Function.prototype.bind.call(console.error,console,m.name+":"),g.error.apply(console,arguments)},performance:{log:function(e){var n,t,i;m.performance&&(n=(new Date).getTime(),i=r||n,t=n-i,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,500)},display:function(){var n=m.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+"'"),a.length>1&&(n+=" ("+a.length+")"),(console.group!==i||console.table!==i)&&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,a,o){var r,s,l,c=x;return a=a||u,o=y||o,"string"==typeof n&&c!==i&&(n=n.split(/[\. ]/),r=n.length-1,e.each(n,function(t,a){var o=t!=r?a+n[t+1].charAt(0).toUpperCase()+n[t+1].slice(1):n;if(e
|