KeymailSpecials2/wwwroot/js/components/star-rating.js

19 lines
14 KiB
JavaScript
Raw Normal View History

2024-02-19 12:54:56 +00:00
/*!
* bootstrap-star-rating v4.1.0
* http://plugins.krajee.com/star-rating
*
* Author: Kartik Visweswaran
* Copyright: 2013 - 2021, Kartik Visweswaran, Krajee.com
*
* Licensed under the BSD 3-Clause
* https://github.com/kartik-v/bootstrap-star-rating/blob/master/LICENSE.md
*/
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(window.jQuery)}(function(t){"use strict";t.fn.ratingLocales={},t.fn.ratingThemes={};var e,a;e={NAMESPACE:".rating",DEFAULT_MIN:0,DEFAULT_MAX:5,DEFAULT_STEP:.5,isEmpty:function(e,a){return null===e||void 0===e||0===e.length||a&&""===t.trim(e)},getCss:function(t,e){return t?" "+e:""},addCss:function(t,e){t.removeClass(e).addClass(e)},getDecimalPlaces:function(t){var e=(""+t).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return e?Math.max(0,(e[1]?e[1].length:0)-(e[2]?+e[2]:0)):0},applyPrecision:function(t,e){return parseFloat(t.toFixed(e))},handler:function(a,n,i,r,s){var o=s?n:n.split(" ").join(e.NAMESPACE+" ")+e.NAMESPACE;r||a.off(o),a.on(o,function(e){var a=t.proxy(i,self);a(e)})}},a=function(e,a){var n=this;n.$element=t(e),n._init(a)},a.prototype={constructor:a,_parseAttr:function(t,a){var n,i,r,s,o=this,l=o.$element,c=l.attr("type");if("range"===c||"number"===c){switch(i=a[t]||l.data(t)||l.attr(t),t){case"min":r=e.DEFAULT_MIN;break;case"max":r=e.DEFAULT_MAX;break;default:r=e.DEFAULT_STEP}n=e.isEmpty(i)?r:i,s=parseFloat(n)}else s=parseFloat(a[t]);return isNaN(s)?r:s},_parseValue:function(t){var e=this,a=parseFloat(t);return isNaN(a)&&(a=e.clearValue),!e.zeroAsNull||0!==a&&"0"!==a?a:null},_setDefault:function(t,a){var n=this;e.isEmpty(n[t])&&(n[t]=a)},_initSlider:function(t){var a=this,n=a.$element.val();a.initialValue=e.isEmpty(n)?0:n,a._setDefault("min",a._parseAttr("min",t)),a._setDefault("max",a._parseAttr("max",t)),a._setDefault("step",a._parseAttr("step",t)),(isNaN(a.min)||e.isEmpty(a.min))&&(a.min=e.DEFAULT_MIN),(isNaN(a.max)||e.isEmpty(a.max))&&(a.max=e.DEFAULT_MAX),(isNaN(a.step)||e.isEmpty(a.step)||0===a.step)&&(a.step=e.DEFAULT_STEP),a.diff=a.max-a.min,a._setDefault("minThreshold",a.min),a.minThreshold<a.min&&(a.minThreshold=a.min),a.minThreshold>a.max&&(a.minThreshold=a.max)},_initHighlight:function(t){var e,a=this,n=a._getCaption();t||(t=a.$element.val()),e=a.getWidthFromValue(t)+"%",a.$filledStars.width(e),a.cache={caption:n,width:e,val:t}},_getContainerCss:function(){var t=this;return"rating-container"+e.getCss(t.theme,"theme-"+t.theme)+e.getCss(t.rtl,"rating-rtl")+e.getCss(t.size,"rating-"+t.size)+e.getCss(t.animate,"rating-animate")+e.getCss(t.disabled||t.readonly,"rating-disabled")+e.getCss(t.containerClass,t.containerClass)+(t.displayOnly?" is-display-only":"")},_checkDisabled:function(){var t=this,e=t.$element,a=t.options;t.disabled=void 0===a.disabled?e.attr("disabled")||!1:a.disabled,t.readonly=void 0===a.readonly?e.attr("readonly")||!1:a.readonly,t.inactive=t.disabled||t.readonly,e.attr({disabled:t.disabled,readonly:t.readonly})},_addContent:function(t,e){var a=this,n=a.$container,i="clear"===t;return a.rtl?i?n.append(e):n.prepend(e):i?n.prepend(e):n.append(e)},_generateRating:function(){var a,n,i,r=this,s=r.$element;n=r.$container=t(document.createElement("div")).insertBefore(s),e.addCss(n,r._getContainerCss()),r.$rating=a=t(document.createElement("div")).attr("class","rating-stars").appendTo(n).append(r._getStars("empty")).append(r._getStars("filled")),r.keyboardEnabled&&r.$rating.attr("tabindex",r.tabindex),r.$emptyStars=a.find(".empty-stars"),r.$filledStars=a.find(".filled-stars"),r._renderCaption(),r._renderClear(),r._initHighlight(),r._initStarTitles();r.rtl&&(i=Math.max(r.$emptyStars.outerWidth(),r.$filledStars.outerWidth()),r.$emptyStars.width(i)),n.insertBefore(s)},_getCaption:function(){var t=this;return t.$caption&&t.$caption.length?t.$caption.html():t.defaultCaption},_setCaption:function(t){var e=this;e.$caption&&e.$caption.length&&e.$caption.html(t)},_renderCaption:function(){var a,n=this,i=n.$element.val(),r=n.captionElement?t(n.captionElement):"";if(n.showCaption){if(a=n.fetchCaption(i),r&&r.length)return e.addCss(r,"caption"),r.html(a),void(n.$caption=r);n._addContent("caption",'<div class="caption">'+a+"</div>"),n.$caption=n.$container.find(".caption")}},_renderClear:function(){var a,n=this,i=n.clearElement?t(n.clearElement)
/*!
* Krajee SVG Theme Configuration for bootstrap-star-rating.
* This file must be loaded after 'star-rating.js'.
*
* @see http://github.com/kartik-v/bootstrap-star-rating
* @author Kartik Visweswaran <kartikv2@gmail.com>
*/!function(a){"use strict";a.fn.ratingThemes["krajee-svg"]={filledStar:'<span class="krajee-icon krajee-icon-star"></span>',emptyStar:'<span class="krajee-icon krajee-icon-star"></span>',clearButton:'<span class="krajee-icon-clear"></span>'}}(window.jQuery);