wishthis/node_modules/fomantic-ui/dist/components/rating.min.js

11 lines
6.1 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
2022-05-29 09:24:36 +00:00
* # Fomantic UI - 2.8.8
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
2022-05-29 09:24:36 +00:00
* Copyright 2021 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-05-29 09:24:36 +00:00
!function(A,e,n,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,o,r=A.isPlainObject(f)?A.extend(!0,{},A.fn.rating.settings,f):A.extend({},A.fn.rating.settings),n=r.namespace,s=r.className,t=r.metadata,i=r.selector,l=r.cssVars,a="."+n,c="module-"+n,u=this,d=A(this).data(c),g=A(this),m=g.find(i.icon);o={initialize:function(){o.verbose("Initializing rating module",r),0===m.length&&o.setup.layout(),r.interactive&&!o.is.disabled()?o.enable():o.disable(),o.set.initialLoad(),o.set.rating(o.get.initialRating()),o.remove.initialLoad(),o.instantiate()},instantiate:function(){o.verbose("Instantiating module",r),d=o,g.data(c,o)},destroy:function(){o.verbose("Destroying previous instance",d),o.remove.events(),g.removeData(c)},refresh:function(){m=g.find(i.icon)},setup:{layout:function(){var e=o.get.maxRating(),n=o.get.icon(),t=A.fn.rating.settings.templates.icon(e,n);o.debug("Generating icon html dynamically"),g.html(t),o.refresh()}},event:{mouseenter:function(){var e=A(this);e.nextAll().removeClass(s.selected),g.addClass(s.selected),e.addClass(s.selected).prevAll().addClass(s.selected)},mouseleave:function(){g.removeClass(s.selected),m.removeClass(s.selected)},click:function(){var e=A(this),n=o.get.rating(),t=m.index(e)+1;("auto"==r.clearable?1===m.length:r.clearable)&&n==t?o.clearRating():o.set.rating(t)}},clearRating:function(){o.debug("Clearing current rating"),o.set.rating(0)},bind:{events:function(){o.verbose("Binding events"),g.on("mouseenter"+a,i.icon,o.event.mouseenter).on("mouseleave"+a,i.icon,o.event.mouseleave).on("click"+a,i.icon,o.event.click)}},remove:{events:function(){o.verbose("Removing events"),g.off(a)},initialLoad:function(){e=!1}},enable:function(){o.debug("Setting rating to interactive mode"),o.bind.events(),g.removeClass(s.disabled)},disable:function(){o.debug("Setting rating to read-only mode"),o.remove.events(),g.addClass(s.disabled)},is:{initialLoad:function(){return e},disabled:function(){return g.hasClass(s.disabled)}},get:{icon:function(){var e=g.data(t.icon);return e&&g.removeData(t.icon),e||r.icon},initialRating:function(){return g.data(t.rating)!==T?(g.removeData(t.rating),g.data(t.rating)):r.initialRating},maxRating:function(){return g.data(t.maxRating)!==T?(g.removeData(t.maxRating),g.data(t.maxRating)):r.maxRating},rating:function(){var e=m.filter("."+s.active).length;return o.verbose("Current rating retrieved",e),e}},set:{rating:function(e){var n=Math.floor(0<=e-1?e-1:0),t=m.eq(n),i=e<=1?t:t.next(),a=e%1*100;g.removeClass(s.selected),m.removeClass(s.selected).removeClass(s.active).removeClass(s.partiallyActive),0<e&&(o.verbose("Setting current rating to",e),t.prevAll().addBack().addClass(s.active),t.next()&&e%1!=0&&(i.addClass(s.partiallyActive).addClass(s.active),i.css(l.filledCustomPropName,a+"%"),"transparent"===i.css("backgroundColor")&&i.removeClass(s.partiallyActive).removeClass(s.active))),o.is.initialLoad()||r.onRate.call(u,e)},initialLoad:function(){e=!0}},setting:function(e,n){if(o.debug("Changing setting",e,n),A.isPlainObject(e))A.extend(!0,r,e);else{if(n===T)return r[e];A.isPlainObject(r[e])?A.extend(!0,r[e],n):r[e]=n}},internal:function(e,n){if(A.isPlainObject(e))A.extend(!0,o,e);else{if(n===T)return o[e];o[e]=n}},debug:function(){!r.silent&&r.debug&&(r.performance?o.performance.log(arguments):(o.debug=Function.prototype.bind.call(console.info,console,r.name+":"),o.debug.apply(console,arguments)))},verbose:function(){!r.silent&&r.verbose&&r.debug&&(r.performance?o.performance.log(arguments):(o.verbose=Function.prototype.bind.call(console.info,console,r.name+":"),o.verbose.apply(console,arguments)))},error:function(){r.silent||(o.error=Function.prototype.bind.call(console.error,console,r.name+":"),o.error.apply(console,arguments))},performance:{log:functi