Socket
Socket
Sign inDemoInstall

bootstrap-star-rating

Package Overview
Dependencies
2
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.2 to 4.0.4

.github/CONTRIBUTING.md

6

bower.json
{
"name": "bootstrap-star-rating",
"version": "4.0.2",
"version": "4.0.4",
"homepage": "https://github.com/kartik-v/bootstrap-star-rating",

@@ -10,4 +10,4 @@ "authors": [

"main": [
"./css/star-rating.min.css",
"./js/star-rating.min.js"
"./css/star-rating.css",
"./js/star-rating.js"
],

@@ -14,0 +14,0 @@ "keywords": [

Change Log: `bootstrap-star-rating`
===================================
## Version 4.0.4
**Date:** 15-Sep-2018
- Enhancements to support Bootstrap v4.x.
- Better styling of stars for the 5 rating sizes and maintain consistency across themes.
- (enh #187): Add Kazakh translations.
- (enh #184): Correct rating-input style to keep it hidden - yet trigger required validation.
- (enh #182): New Krajee Font Awesome 5.x `fas` theme.
- (bug #177, enh #179): New property `showCaptionAsTitle`
- Useful for caption to be displayed as title for readonly ratings.
## Version 4.0.3
**Date:** 03-Nov-2017
- (bug #173): Correct `rating:change` event.
- (enh #171): Rename events to start with `rating:` instead of `rating`.
- (enh #170): Enhancements to support Bootstrap v4.x framework.
## Version 4.0.2
**Date:** 03-Jul-2016
**Date:** 27-Aug-2017
1. (enh #108): Add French Translations.
2. (enh #115): Add Romanian Translations.
3. (enh #122): Add Spanish Translations.
4. (enh #123): Add Italian Translations.
5. (enh #124): Add License Headers.
6. (enh #127): Add Chinese Translations.
7. (enh #130): Better management of themes and locales.
- (enh #170): Enhancements to support Bootstrap v4.x framework.
- Chronological sorting of issues and enhancements in the CHANGE log.
- (enh #164): Add Turkish Translations.
- (enh #163): Add Korean Translations.
- (enh #162): Add Italian Translations.
- (enh #161): Add Farsi Translations.
- (enh #156): More correct form reset event listening.
- (enh #155): Styling enhancements and code optimizations.
- (enh #154): New property `zeroAsNull` to treat zero value rating as null.
- (enh #153): Add ability to configure `required` attribute for input.
- Add github issue and PR contribution templates.
- (enh #142): Enable scroll when rating is readonly or disabled.
- (enh #139): Do not refer to minified files in bower main metadata .
- (enh #132): Add Polish Translations.
- (enh #131): Add Arabic Translations.
- (enh #130): Better management of themes and locales.
- (enh #127): Add Chinese Translations.
- (enh #124): Add License Headers.
- (enh #123): Add Italian Translations.
- (enh #122): Add Spanish Translations.
- (enh #115): Add Romanian Translations.
- (enh #108): Add French Translations.

@@ -20,9 +55,9 @@ ## Version 4.0.1

1. (bug #99): Correct documentation for refresh method.
2. (bug #100): Correct caption and clear rendering methods.
3. (bug #101): Correct caption setting when `showCaption` is `false`.
4. (bug #102): Revamp generation of rating via `refresh` method.
5. (enh #103): Implement method chaining and revamp private methods
- Update package.json to include `peerDependencies` instead of `dependencies`.
- (enh #103): Implement method chaining and revamp private methods
- enhance public methods like `create`, `destroy`, `refresh`, `clear`, `reset` to return the rating element jQuery object
6. Update package.json to include `peerDependencies` instead of `dependencies`.
- (bug #102): Revamp generation of rating via `refresh` method.
- (bug #101): Correct caption setting when `showCaption` is `false`.
- (bug #100): Correct caption and clear rendering methods.
- (bug #99): Correct documentation for refresh method.

@@ -33,4 +68,6 @@ ## Version 4.0.0

1. (enh #91): Add SVG Icon Support
2. (enh #94): Add Theming Functionality.
- (enh #97): Add `animate` property to enable / disable animation of star highlight on hover / change.
- (enh #96): Add support for `bootstrap-sass` official repo via `sass` branch.
- (enh #95): Add display only capability.
- (enh #94): Add Theming Functionality.
- New property `theme` will assign a CSS class with the `rating-<theme-name>` to the rating container.

@@ -54,5 +91,3 @@ - Themes included

- Exclusive support for SVG (and a prebuilt `krajee-svg` theme that contains two different ready to use SVG icons).
3. (enh #95): Add display only capability.
4. (enh #96): Add support for `bootstrap-sass` official repo via `sass` branch.
5. (enh #97): Add `animate` property to enable / disable animation of star highlight on hover / change.
- (enh #91): Add SVG Icon Support

@@ -63,5 +98,5 @@ ## Version 3.5.8

1. (enh #88): Add German Translations.
2. (enh #89): Add Portugese Brazilian Translations.
3. (bug #90): Rename reserved word used as variable.
- (bug #90): Rename reserved word used as variable.
- (enh #89): Add Portugese Brazilian Translations.
- (enh #88): Add German Translations.

@@ -72,4 +107,4 @@ ## Version 3.5.7

1. (enh #84): Add Ukranian Translations.
2. (enh #86): Refactor code for listening events and deep extend options correctly.
- (enh #86): Refactor code for listening events and deep extend options correctly.
- (enh #84): Add Ukranian Translations.

@@ -80,6 +115,6 @@ ## Version 3.5.6

1. (enh #76): Add Russian Translations.
2. (bug #77): Correct `touches` and `changedTouches` validation.
3. (enh #81): Simplify README docs.
4. (enh #82): Added "main" key into NPM package.json.
- (enh #82): Added "main" key into NPM package.json.
- (enh #81): Simplify README docs.
- (bug #77): Correct `touches` and `changedTouches` validation.
- (enh #76): Add Russian Translations.

@@ -90,5 +125,5 @@ ## Version 3.5.5

1. (enh #71): Fix `Error: Cannot read property 'pageX' of undefined` error on touch devices.
2. (enh #74): Universal Module Definition for use with CommonJS, AMD or browser globals.
3. (enh #75): Implement Locales and Translations.
- (enh #75): Implement Locales and Translations.
- (enh #74): Universal Module Definition for use with CommonJS, AMD or browser globals.
- (enh #71): Fix `Error: Cannot read property 'pageX' of undefined` error on touch devices.

@@ -99,6 +134,6 @@ ## Version 3.5.4

1. (enh #47): Styling enhancements for printed output (better star colors and hide clear button).
2. (enh #59): Remove `String.prototype.replaceAll` and implement regex replace.
3. (enh #63): Add `package.json` for npm install.
4. Update bootstrap bower version to support only 3.x variants.
- Update bootstrap bower version to support only 3.x variants.
- (enh #63): Add `package.json` for npm install.
- (enh #59): Remove `String.prototype.replaceAll` and implement regex replace.
- (enh #47): Styling enhancements for printed output (better star colors and hide clear button).

@@ -109,4 +144,4 @@ ## Version 3.5.3

1. (enh #58): Remove redundant tooltip title on hover of caption element.
2. Fixes for composer.json dependencies.
- Fixes for composer.json dependencies.
- (enh #58): Remove redundant tooltip title on hover of caption element.

@@ -117,4 +152,4 @@ ## Version 3.5.2

1. (enh #45): Validate on `touchstart` for devices that do not support `click` event.
2. (enh #46): More correct init of `clear` and `caption` elements.
- (enh #46): More correct init of `clear` and `caption` elements.
- (enh #45): Validate on `touchstart` for devices that do not support `click` event.

@@ -125,5 +160,5 @@ ## Version 3.5.1

1. (enh #44): Ability to integrate with other font icon CSS frameworks like Font Awesome.
- Set copyright year to current.
- (enh #44): Ability to integrate with other font icon CSS frameworks like Font Awesome.
- New property `ratingClass` added to allow configuring other icon framework css classes.
2. Set copyright year to current.

@@ -134,4 +169,4 @@ ## Version 3.5.0

1. (enh #39): Prevent invalid star rating for numStars > 5 with default value & hoverChange enabled.
2. (enh #42): Code cleanup and restructure for JS lint changes (using JSHint Code cleanup library).
- (enh #42): Code cleanup and restructure for JS lint changes (using JSHint Code cleanup library).
- (enh #39): Prevent invalid star rating for numStars > 5 with default value & hoverChange enabled.

@@ -142,4 +177,4 @@ ## Version 3.4.0

1. (enh #35): Added `destroy` method to destroy the rating plugin.
2. (enh #36): Added `create` method to create the rating plugin (typically after a destroy).
- (enh #36): Added `create` method to create the rating plugin (typically after a destroy).
- (enh #35): Added `destroy` method to destroy the rating plugin.

@@ -150,4 +185,4 @@ ## Version 3.3.0

1. (bug #32): Prevent invalid star ratings if cursor is close to left/right edge of star array.
2. (enh #33): Enhance touch methods for compatibility across more wider mobile device browsers.
- (enh #33): Enhance touch methods for compatibility across more wider mobile device browsers.
- (bug #32): Prevent invalid star ratings if cursor is close to left/right edge of star array.

@@ -158,4 +193,4 @@ ## Version 3.2.0

1. Set release to stable in composer.json.
2. Updated CHANGE log to reflect user friendly date time formats.
- Updated CHANGE log to reflect user friendly date time formats.
- Set release to stable in composer.json.

@@ -166,5 +201,5 @@ ## Version 3.1.0

1. enh #26: Add touch device support to enable touch and slide across stars.
2. enh #27: Reset events on the rating element before every refresh.
3. enh #28: Add rating.refresh event.
- enh #28: Add rating.refresh event.
- enh #27: Reset events on the rating element before every refresh.
- enh #26: Add touch device support to enable touch and slide across stars.

@@ -176,4 +211,8 @@

1. enh #20, #21: Included hover validation routine and rating state change on hover. Following new configurable properties added:
- enh #24: Set `clearValue` to default to `min` if not set.
- enh #22: More correct minimum value and clear value validation through new `getWidthFromValue` method.
- enh #21: Following new events are added:
- `rating.hover`
- `rating.hoverleave`
- enh #20, #21: Included hover validation routine and rating state change on hover. Following new configurable properties added:
- `hoverEnabled`: _boolean_ whether hover functionality is enabled. This will dynamically change the stars and caption on mouse hover. Defaults to `true`. This functionality will only work on desktop devices and if the input is not `disabled` or `readonly`.

@@ -183,12 +222,2 @@ - `hoverChangeCaption`: _boolean_ control whether the caption should dynamically change on mouse hover. Defaults to `true`. Will be applicable only if `hoverEnabled` is `true`.

2. enh #21: Following new events are added:
- `rating.hover`
- `rating.hoverleave`
3. enh #22: More correct minimum value and clear value validation through new `getWidthFromValue` method.
4. enh #24: Set `clearValue` to default to `min` if not set.
## Version 2.6.0

@@ -198,3 +227,3 @@

1. enh #17: Dynamic configuration for `starCaptions` and `starCaptionClasses` using a function.
- enh #17: Dynamic configuration for `starCaptions` and `starCaptionClasses` using a function.

@@ -205,8 +234,8 @@ ## Version 2.5.0

1. Change to entire plugin code to eliminate dependency of HTML5 input. Plugin size reduced to 8KB minified.
2. Uses special JQuery routines to trigger star rating changes.
3. Plugin support is now extended to all browsers including pre IE10
4. Plugin support is now extended to all Touch based and mobile devices like iOS, Android.
5. Removed cloning of inputs to allow better refreshing of input across ajax and other scenarios.
6. Caption and Clear elements parameters treated as identifiers rather than JQuery object elements.
- Caption and Clear elements parameters treated as identifiers rather than JQuery object elements.
- Removed cloning of inputs to allow better refreshing of input across ajax and other scenarios.
- Plugin support is now extended to all Touch based and mobile devices like iOS, Android.
- Plugin support is now extended to all browsers including pre IE10
- Uses special JQuery routines to trigger star rating changes.
- Change to entire plugin code to eliminate dependency of HTML5 input. Plugin size reduced to 8KB minified.

@@ -217,3 +246,3 @@ ## Version 2.1.0

1. Bug #8,#9,#10: Correct cloning and con## Version of field to a range slider input.
- Bug #8,#9,#10: Correct cloning and con## Version of field to a range slider input.

@@ -225,12 +254,12 @@ ## Version 2.0.0

1. Revamp of entire plugin code. Cleverly leverages CSS3 styles, animations, and HTML5 input features
- Automatically degrades to a normal SELECT dropdown input for browsers that do not support
HTML 5 range input.
- Uses HTML 5 range input to change ratings. Polyfills for range input in case JQuery/Javascript is disabled.
- Any star symbol (unicode or icon font) can be embedded instead of Glyphicon.
- Bootstrap style is made optional and configurable. Can override CSS to use any style.
- Right to left (RTL) support enhancement. Optimally uses the `dir` attribute of the range input.
- Render and display fractional star ratings. Configure number of stars, min, max, step, and theoretically
support any fractional rating.
- Revamp of entire plugin code. Cleverly leverages CSS3 styles, animations, and HTML5 input features
to render the plugin.
2. Render and display fractional star ratings. Configure number of stars, min, max, step, and theoretically
support any fractional rating.
3. Right to left (RTL) support enhancement. Optimally uses the `dir` attribute of the range input.
4. Bootstrap style is made optional and configurable. Can override CSS to use any style.
5. Any star symbol (unicode or icon font) can be embedded instead of Glyphicon.
6. Uses HTML 5 range input to change ratings. Polyfills for range input in case JQuery/Javascript is disabled.
7. Automatically degrades to a normal SELECT dropdown input for browsers that do not support
HTML 5 range input.

@@ -241,4 +270,4 @@ ## Version 1.2.0

1. Widget is customizable for using any CSS markup to override Bootstrap styles.
2. Clear button class customization added.
- Clear button class customization added.
- Widget is customizable for using any CSS markup to override Bootstrap styles.

@@ -251,4 +280,4 @@ ## Version 1.1.0

1. Included `update` method to set a value of a rating via javascript.
2. Revamped the `refresh` method to enable refreshing all plugin options at runtime via parameters.
- Revamped the `refresh` method to enable refreshing all plugin options at runtime via parameters.
- Included `update` method to set a value of a rating via javascript.

@@ -261,13 +290,13 @@ ## Version 1.0.0

1. Convert any HTML input to a star rating control. Recommended input is of `type = number`, which will help fallback to a number input for browsers not supporting JQuery or Javascript.
2. The plugin automatically converts an input with `type = number` to a star rating control if you set its `class = rating`. All options to the input can be passed as HTML5 `data` attributes.
3. Involves pure CSS3 styling of the stars. Say goodbye to image sprites or playing with image backgrounds. Offers clean scalable vector icons for consistent display across devices.
4. Specifically uses Bootstrap 3.x styles & glyphs. Can be combined to work better for Bootstrap styled projects (or input group addons).
5. Ability to clear values and options for the stars. Control where the clear button element can be shown.
6. Reset star rating to the initial value when the form is reset.
7. Ability to control and display caption of the selected stars. Each rated star can have its own caption. Control where the caption element can be shown.
8. Ability to size the rating control including the stars, caption, and clear button. Five prebuilt size templates are available `xl`, `lg`, `md`, `sm`, and `xs`.
9. Support for RIGHT TO LEFT (RTL) input. Automatically changes star styling for RTL.
10. Triggers JQuery events for advanced development. Events currently available are `rating.change`, `rating.clear`, and `rating.reset`.
11. Disabled and readonly input star rating support.
12. Size of the entire plugin is less than 9KB (about 6KB for the minified JS and 3KB for the minified CSS).
- Convert any HTML input to a star rating control. Recommended input is of `type = number`, which will help fallback to a number input for browsers not supporting JQuery or Javascript.
- The plugin automatically converts an input with `type = number` to a star rating control if you set its `class = rating`. All options to the input can be passed as HTML5 `data` attributes.
- Involves pure CSS3 styling of the stars. Say goodbye to image sprites or playing with image backgrounds. Offers clean scalable vector icons for consistent display across devices.
- Specifically uses Bootstrap 3.x styles & glyphs. Can be combined to work better for Bootstrap styled projects (or input group addons).
- Ability to clear values and options for the stars. Control where the clear button element can be shown.
- Reset star rating to the initial value when the form is reset.
- Ability to control and display caption of the selected stars. Each rated star can have its own caption. Control where the caption element can be shown.
- Ability to size the rating control including the stars, caption, and clear button. Five prebuilt size templates are available `xl`, `lg`, `md`, `sm`, and `xs`.
- Support for RIGHT TO LEFT (RTL) input. Automatically changes star styling for RTL.
- Triggers JQuery events for advanced development. Events currently available are `rating.change`, `rating.clear`, and `rating.reset`.
- Disabled and readonly input star rating support.
- Size of the entire plugin is less than 9KB (about 6KB for the minified JS and 3KB for the minified CSS).

@@ -26,3 +26,3 @@ /*!

4.5: 'Quattro Stelle & Mezzo',
5: 'Five Stars'
5: 'Cinque Stelle'
},

@@ -29,0 +29,0 @@ clearButtonTitle: 'Rimuovi',

/*!
* bootstrap-star-rating v4.0.2
* bootstrap-star-rating v4.0.4
* http://plugins.krajee.com/star-rating
*
* Author: Kartik Visweswaran
* Copyright: 2014 - 2016, Kartik Visweswaran, Krajee.com
* Copyright: 2013 - 2018, Kartik Visweswaran, Krajee.com
*

@@ -33,28 +33,36 @@ * Licensed under the BSD 3-Clause

var NAMESPACE, DEFAULT_MIN, DEFAULT_MAX, DEFAULT_STEP, isEmpty, getCss, addCss, getDecimalPlaces, applyPrecision,
handler, Rating;
NAMESPACE = '.rating';
DEFAULT_MIN = 0;
DEFAULT_MAX = 5;
DEFAULT_STEP = 0.5;
isEmpty = function (value, trim) {
return value === null || value === undefined || value.length === 0 || (trim && $.trim(value) === '');
var $h, Rating;
// global helper methods and constants
$h = {
NAMESPACE: '.rating',
DEFAULT_MIN: 0,
DEFAULT_MAX: 5,
DEFAULT_STEP: 0.5,
isEmpty: function (value, trim) {
return value === null || value === undefined || value.length === 0 || (trim && $.trim(value) === '');
},
getCss: function (condition, css) {
return condition ? ' ' + css : '';
},
addCss: function ($el, css) {
$el.removeClass(css).addClass(css);
},
getDecimalPlaces: function (num) {
var m = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
return !m ? 0 : Math.max(0, (m[1] ? m[1].length : 0) - (m[2] ? +m[2] : 0));
},
applyPrecision: function (val, precision) {
return parseFloat(val.toFixed(precision));
},
handler: function ($el, event, callback, skipOff, skipNS) {
var ev = skipNS ? event : event.split(' ').join($h.NAMESPACE + ' ') + $h.NAMESPACE;
if (!skipOff) {
$el.off(ev);
}
$el.on(ev, callback);
}
};
getCss = function (condition, css) {
return condition ? ' ' + css : '';
};
addCss = function ($el, css) {
$el.removeClass(css).addClass(css);
};
getDecimalPlaces = function (num) {
var match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
return !match ? 0 : Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));
};
applyPrecision = function (val, precision) {
return parseFloat(val.toFixed(precision));
};
handler = function ($el, event, callback, skipNS) {
var ev = skipNS ? event : event.split(' ').join(NAMESPACE + ' ') + NAMESPACE;
$el.off(ev).on(ev, callback);
};
// rating constructor
Rating = function (element, options) {

@@ -73,11 +81,11 @@ var self = this;

case 'min':
chk = DEFAULT_MIN;
chk = $h.DEFAULT_MIN;
break;
case 'max':
chk = DEFAULT_MAX;
chk = $h.DEFAULT_MAX;
break;
default:
chk = DEFAULT_STEP;
chk = $h.DEFAULT_STEP;
}
finalVal = isEmpty(val) ? chk : val;
finalVal = $h.isEmpty(val) ? chk : val;
out = parseFloat(finalVal);

@@ -89,135 +97,29 @@ } else {

},
_parseValue: function (val) {
var self = this, v = parseFloat(val);
if (isNaN(v)) {
v = self.clearValue;
}
return (self.zeroAsNull && (v === 0 || v === '0') ? null : v);
},
_setDefault: function (key, val) {
var self = this;
if (isEmpty(self[key])) {
if ($h.isEmpty(self[key])) {
self[key] = val;
}
},
_listenClick: function (e, callback) {
e.stopPropagation();
e.preventDefault();
if (e.handled !== true) {
callback(e);
e.handled = true;
} else {
return false;
}
},
_starClick: function (e) {
var self = this, pos;
self._listenClick(e, function (ev) {
if (self.inactive) {
return false;
}
pos = self._getTouchPosition(ev);
self._setStars(pos);
self.$element.trigger('change').trigger('rating.change', [self.$element.val(), self._getCaption()]);
self.starClicked = true;
});
},
_starMouseMove: function (e) {
var self = this, pos, out;
if (!self.hoverEnabled || self.inactive || (e && e.isDefaultPrevented())) {
return;
}
self.starClicked = false;
pos = self._getTouchPosition(e);
out = self.calculate(pos);
self._toggleHover(out);
self.$element.trigger('rating.hover', [out.val, out.caption, 'stars']);
},
_starMouseLeave: function (e) {
var self = this, out;
if (!self.hoverEnabled || self.inactive || self.starClicked || (e && e.isDefaultPrevented())) {
return;
}
out = self.cache;
self._toggleHover(out);
self.$element.trigger('rating.hoverleave', ['stars']);
},
_clearClick: function (e) {
var self = this;
self._listenClick(e, function () {
if (!self.inactive) {
self.clear();
self.clearClicked = true;
}
});
},
_clearMouseMove: function (e) {
var self = this, caption, val, width, out;
if (!self.hoverEnabled || self.inactive || !self.hoverOnClear || (e && e.isDefaultPrevented())) {
return;
}
self.clearClicked = false;
caption = '<span class="' + self.clearCaptionClass + '">' + self.clearCaption + '</span>';
val = self.clearValue;
width = self.getWidthFromValue(val) || 0;
out = {caption: caption, width: width, val: val};
self._toggleHover(out);
self.$element.trigger('rating.hover', [val, caption, 'clear']);
},
_clearMouseLeave: function (e) {
var self = this, out;
if (!self.hoverEnabled || self.inactive || self.clearClicked || !self.hoverOnClear || (e && e.isDefaultPrevented())) {
return;
}
out = self.cache;
self._toggleHover(out);
self.$element.trigger('rating.hoverleave', ['clear']);
},
_resetForm: function (e) {
var self = this;
if (e && e.isDefaultPrevented()) {
return;
}
if (!self.inactive) {
self.reset();
}
},
_setTouch: function (e, flag) {
//noinspection JSUnresolvedVariable
var self = this, ev, touches, pos, out, caption, w, width, isTouchCapable = 'ontouchstart' in window ||
(window.DocumentTouch && document instanceof window.DocumentTouch);
if (!isTouchCapable || self.inactive) {
return;
}
ev = e.originalEvent;
//noinspection JSUnresolvedVariable
touches = !isEmpty(ev.touches) ? ev.touches : ev.changedTouches;
pos = self._getTouchPosition(touches[0]);
if (flag) {
self._setStars(pos);
self.$element.trigger('change').trigger('rating.change', [self.$element.val(), self._getCaption()]);
self.starClicked = true;
} else {
out = self.calculate(pos);
caption = out.val <= self.clearValue ? self.fetchCaption(self.clearValue) : out.caption;
w = self.getWidthFromValue(self.clearValue);
width = out.val <= self.clearValue ? w + '%' : out.width;
self._setCaption(caption);
self.$filledStars.css('width', width);
}
},
_initTouch: function (e) {
var self = this, flag = (e.type === "touchend");
self._setTouch(e, flag);
},
_initSlider: function (options) {
var self = this;
if (isEmpty(self.$element.val())) {
self.$element.val(0);
}
self.initialValue = self.$element.val();
var self = this, v = self.$element.val();
self.initialValue = $h.isEmpty(v) ? 0 : v;
self._setDefault('min', self._parseAttr('min', options));
self._setDefault('max', self._parseAttr('max', options));
self._setDefault('step', self._parseAttr('step', options));
if (isNaN(self.min) || isEmpty(self.min)) {
self.min = DEFAULT_MIN;
if (isNaN(self.min) || $h.isEmpty(self.min)) {
self.min = $h.DEFAULT_MIN;
}
if (isNaN(self.max) || isEmpty(self.max)) {
self.max = DEFAULT_MAX;
if (isNaN(self.max) || $h.isEmpty(self.max)) {
self.max = $h.DEFAULT_MAX;
}
if (isNaN(self.step) || isEmpty(self.step) || self.step === 0) {
self.step = DEFAULT_STEP;
if (isNaN(self.step) || $h.isEmpty(self.step) || self.step === 0) {
self.step = $h.DEFAULT_STEP;
}

@@ -238,8 +140,10 @@ self.diff = self.max - self.min;

return 'rating-container' +
getCss(self.theme, 'theme-' + self.theme) +
getCss(self.rtl, 'rating-rtl') +
getCss(self.size, 'rating-' + self.size) +
getCss(self.animate, 'rating-animate') +
getCss(self.disabled || self.readonly, 'rating-disabled') +
getCss(self.containerClass, self.containerClass);
$h.getCss(self.theme, 'theme-' + self.theme) +
$h.getCss(self.rtl, 'rating-rtl') +
$h.getCss(self.size, 'rating-' + self.size) +
$h.getCss(self.animate, 'rating-animate') +
$h.getCss(self.disabled || self.readonly, 'rating-disabled') +
$h.getCss(self.containerClass, self.containerClass) +
(self.displayOnly ? ' is-display-only' : '');
},

@@ -264,4 +168,4 @@ _checkDisabled: function () {

$container = self.$container = $(document.createElement("div")).insertBefore($el);
addCss($container, self._getContainerCss());
self.$rating = $rating = $(document.createElement("div")).attr('class', 'rating').appendTo($container)
$h.addCss($container, self._getContainerCss());
self.$rating = $rating = $(document.createElement("div")).attr('class', 'rating-stars').appendTo($container)
.append(self._getStars('empty')).append(self._getStars('filled'));

@@ -273,2 +177,3 @@ self.$emptyStars = $rating.find('.empty-stars');

self._initHighlight();
self._initCaptionTitle();
$container.append($el);

@@ -279,2 +184,3 @@ if (self.rtl) {

}
$el.appendTo($rating);
},

@@ -298,3 +204,3 @@ _getCaption: function () {

if ($cap && $cap.length) {
addCss($cap, 'caption');
$h.addCss($cap, 'caption');
$cap.html(html);

@@ -314,3 +220,3 @@ self.$caption = $cap;

if ($clr.length) {
addCss($clr, css);
$h.addCss($clr, css);
$clr.attr({"title": self.clearButtonTitle}).html(self.clearButton);

@@ -325,8 +231,5 @@ self.$clear = $clr;

_getClearClass: function () {
return this.clearButtonBaseClass + ' ' + ((this.inactive) ? '' : this.clearButtonActiveClass);
var self = this;
return self.clearButtonBaseClass + ' ' + (self.inactive ? '' : self.clearButtonActiveClass);
},
_getTouchPosition: function (e) {
var pageX = isEmpty(e.pageX) ? e.originalEvent.touches[0].pageX : e.pageX;
return pageX - this.$rating.offset().left;
},
_toggleHover: function (out) {

@@ -350,3 +253,3 @@ var self = this, w, width, caption;

_init: function (options) {
var self = this, $el = self.$element.addClass('hide');
var self = this, $el = self.$element.addClass('rating-input'), v;
self.options = options;

@@ -370,19 +273,153 @@ $.each(options, function (key, value) {

self._generateRating();
self._initEvents();
self._listen();
v = self._parseValue($el.val());
$el.val(v);
return $el.removeClass('rating-loading');
},
_initCaptionTitle: function() {
var self = this, caption;
if (self.showCaptionAsTitle) {
caption = self.fetchCaption(self.$element.val());
self.$rating.attr('title', $(caption).text());
}
},
_trigChange: function(params) {
var self = this;
self._initCaptionTitle();
self.$element.trigger('change').trigger('rating:change', params);
},
_initEvents: function () {
var self = this;
self.events = {
_getTouchPosition: function (e) {
var pageX = $h.isEmpty(e.pageX) ? e.originalEvent.touches[0].pageX : e.pageX;
return pageX - self.$rating.offset().left;
},
_listenClick: function (e, callback) {
e.stopPropagation();
e.preventDefault();
if (e.handled !== true) {
callback(e);
e.handled = true;
} else {
return false;
}
},
_noMouseAction: function (e) {
return !self.hoverEnabled || self.inactive || (e && e.isDefaultPrevented());
},
initTouch: function (e) {
//noinspection JSUnresolvedVariable
var ev, touches, pos, out, caption, w, width, params, clrVal = self.clearValue || 0,
isTouchCapable = 'ontouchstart' in window ||
(window.DocumentTouch && document instanceof window.DocumentTouch);
if (!isTouchCapable || self.inactive) {
return;
}
ev = e.originalEvent;
//noinspection JSUnresolvedVariable
touches = !$h.isEmpty(ev.touches) ? ev.touches : ev.changedTouches;
pos = self.events._getTouchPosition(touches[0]);
if (e.type === "touchend") {
self._setStars(pos);
params = [self.$element.val(), self._getCaption()];
self._trigChange(params);
self.starClicked = true;
} else {
out = self.calculate(pos);
caption = out.val <= clrVal ? self.fetchCaption(clrVal) : out.caption;
w = self.getWidthFromValue(clrVal);
width = out.val <= clrVal ? w + '%' : out.width;
self._setCaption(caption);
self.$filledStars.css('width', width);
}
},
starClick: function (e) {
var pos, params;
self.events._listenClick(e, function (ev) {
if (self.inactive) {
return false;
}
pos = self.events._getTouchPosition(ev);
self._setStars(pos);
params = [self.$element.val(), self._getCaption()];
self._trigChange(params);
self.starClicked = true;
});
},
clearClick: function (e) {
self.events._listenClick(e, function () {
if (!self.inactive) {
self.clear();
self.clearClicked = true;
}
});
},
starMouseMove: function (e) {
var pos, out;
if (self.events._noMouseAction(e)) {
return;
}
self.starClicked = false;
pos = self.events._getTouchPosition(e);
out = self.calculate(pos);
self._toggleHover(out);
self.$element.trigger('rating:hover', [out.val, out.caption, 'stars']);
},
starMouseLeave: function (e) {
var out;
if (self.events._noMouseAction(e) || self.starClicked) {
return;
}
out = self.cache;
self._toggleHover(out);
self.$element.trigger('rating:hoverleave', ['stars']);
},
clearMouseMove: function (e) {
var caption, val, width, out;
if (self.events._noMouseAction(e) || !self.hoverOnClear) {
return;
}
self.clearClicked = false;
caption = '<span class="' + self.clearCaptionClass + '">' + self.clearCaption + '</span>';
val = self.clearValue;
width = self.getWidthFromValue(val) || 0;
out = {caption: caption, width: width, val: val};
self._toggleHover(out);
self.$element.trigger('rating:hover', [val, caption, 'clear']);
},
clearMouseLeave: function (e) {
var out;
if (self.events._noMouseAction(e) || self.clearClicked || !self.hoverOnClear) {
return;
}
out = self.cache;
self._toggleHover(out);
self.$element.trigger('rating:hoverleave', ['clear']);
},
resetForm: function (e) {
if (e && e.isDefaultPrevented()) {
return;
}
if (!self.inactive) {
self.reset();
}
}
};
},
_listen: function () {
var self = this, $el = self.$element, $form = $el.closest('form'), $rating = self.$rating,
$clear = self.$clear;
handler($rating, 'touchstart touchmove touchend', $.proxy(self._initTouch, self));
handler($rating, 'click touchstart', $.proxy(self._starClick, self));
handler($rating, 'mousemove', $.proxy(self._starMouseMove, self));
handler($rating, 'mouseleave', $.proxy(self._starMouseLeave, self));
$clear = self.$clear, events = self.events;
$h.handler($rating, 'touchstart touchmove touchend', $.proxy(events.initTouch, self));
$h.handler($rating, 'click touchstart', $.proxy(events.starClick, self));
$h.handler($rating, 'mousemove', $.proxy(events.starMouseMove, self));
$h.handler($rating, 'mouseleave', $.proxy(events.starMouseLeave, self));
if (self.showClear && $clear.length) {
handler($clear, 'click touchstart', $.proxy(self._clearClick, self));
handler($clear, 'mousemove', $.proxy(self._clearMouseMove, self));
handler($clear, 'mouseleave', $.proxy(self._clearMouseLeave, self));
$h.handler($clear, 'click touchstart', $.proxy(events.clearClick, self));
$h.handler($clear, 'mousemove', $.proxy(events.clearMouseMove, self));
$h.handler($clear, 'mouseleave', $.proxy(events.clearMouseLeave, self));
}
if ($form.length) {
handler($form, 'reset', $.proxy(self._resetForm, self));
$h.handler($form, 'reset', $.proxy(events.resetForm, self), true);
}

@@ -399,4 +436,5 @@ return $el;

_setStars: function (pos) {
var self = this, out = arguments.length ? self.calculate(pos) : self.calculate(), $el = self.$element;
$el.val(out.val);
var self = this, out = arguments.length ? self.calculate(pos) : self.calculate(), $el = self.$element,
v = self._parseValue(out.val);
$el.val(v);
self.$filledStars.css('width', out.width);

@@ -408,8 +446,9 @@ self._setCaption(out.caption);

showStars: function (val) {
var self = this, v = parseFloat(val);
self.$element.val(isNaN(v) ? self.clearValue : v);
var self = this, v = self._parseValue(val);
self.$element.val(v);
self._initCaptionTitle();
return self._setStars();
},
calculate: function (pos) {
var self = this, defaultVal = isEmpty(self.$element.val()) ? 0 : self.$element.val(),
var self = this, defaultVal = $h.isEmpty(self.$element.val()) ? 0 : self.$element.val(),
val = arguments.length ? self.getValueFromPosition(pos) : defaultVal,

@@ -421,6 +460,6 @@ caption = self.fetchCaption(val), width = self.getWidthFromValue(val);

getValueFromPosition: function (pos) {
var self = this, precision = getDecimalPlaces(self.step), val, factor, maxWidth = self.$rating.width();
var self = this, precision = $h.getDecimalPlaces(self.step), val, factor, maxWidth = self.$rating.width();
factor = (self.diff * pos) / (maxWidth * self.step);
factor = self.rtl ? Math.floor(factor) : Math.ceil(factor);
val = applyPrecision(parseFloat(self.min + factor * self.step), precision);
val = $h.applyPrecision(parseFloat(self.min + factor * self.step), precision);
val = Math.max(Math.min(val, self.max), self.min);

@@ -445,8 +484,9 @@ return self.rtl ? (self.max - val) : val;

if (val && val !== self.clearValue) {
val = applyPrecision(val, getDecimalPlaces(self.step));
val = $h.applyPrecision(val, $h.getDecimalPlaces(self.step));
}
cssVal = typeof vCss === "function" ? vCss(val) : vCss[val];
capVal = typeof vCap === "function" ? vCap(val) : vCap[val];
cap = isEmpty(capVal) ? self.defaultCaption.replace(/\{rating}/g, val) : capVal;
css = isEmpty(cssVal) ? self.clearCaptionClass : cssVal;
// noinspection RegExpRedundantEscape
cap = $h.isEmpty(capVal) ? self.defaultCaption.replace(/\{rating}/g, val) : capVal;
css = $h.isEmpty(cssVal) ? self.clearCaptionClass : cssVal;
caption = (val === self.clearValue) ? self.clearCaption : cap;

@@ -457,7 +497,7 @@ return '<span class="' + css + '">' + caption + '</span>';

var self = this, $el = self.$element;
if (!isEmpty(self.$container)) {
if (!$h.isEmpty(self.$container)) {
self.$container.before($el).remove();
}
$.removeData($el.get(0));
return $el.off('rating').removeClass('hide');
return $el.off('rating').removeClass('rating rating-input');
},

@@ -473,7 +513,7 @@ create: function (options) {

}
return self.showStars(self.clearValue).trigger('change').trigger('rating.clear');
return self.showStars(self.clearValue).trigger('change').trigger('rating:clear');
},
reset: function () {
var self = this;
return self.showStars(self.initialValue).trigger('rating.reset');
return self.showStars(self.initialValue).trigger('rating:reset');
},

@@ -489,3 +529,3 @@ update: function (val) {

}
return self.destroy().rating($.extend(true, self.options, options)).trigger('rating.refresh');
return self.destroy().rating($.extend(true, self.options, options)).trigger('rating:refresh');
}

@@ -501,3 +541,2 @@ };

thm = {}, loc = {}, opts;
if (!data) {

@@ -507,3 +546,3 @@ if (theme) {

}
if (lang !== 'en' && !isEmpty($.fn.ratingLocales[lang])) {
if (lang !== 'en' && !$h.isEmpty($.fn.ratingLocales[lang])) {
loc = $.fn.ratingLocales[lang];

@@ -544,12 +583,12 @@ }

starCaptionClasses: {
0.5: 'label label-danger',
1: 'label label-danger',
1.5: 'label label-warning',
2: 'label label-warning',
2.5: 'label label-info',
3: 'label label-info',
3.5: 'label label-primary',
4: 'label label-primary',
4.5: 'label label-success',
5: 'label label-success'
0.5: 'label label-danger badge-danger',
1: 'label label-danger badge-danger',
1.5: 'label label-warning badge-warning',
2: 'label label-warning badge-warning',
2.5: 'label label-info badge-info',
3: 'label label-info badge-info',
3.5: 'label label-primary badge-primary',
4: 'label label-primary badge-primary',
4.5: 'label label-success badge-success',
5: 'label label-success badge-success'
},

@@ -559,10 +598,12 @@ clearButton: '<i class="glyphicon glyphicon-minus-sign"></i>',

clearButtonActiveClass: 'clear-rating-active',
clearCaptionClass: 'label label-default',
clearCaptionClass: 'label label-default badge-secondary',
clearValue: null,
captionElement: null,
clearElement: null,
showCaptionAsTitle: true,
hoverEnabled: true,
hoverChangeCaption: true,
hoverChangeStars: true,
hoverOnClear: true
hoverOnClear: true,
zeroAsNull: true
};

@@ -599,2 +640,2 @@

});
}));
}));
/*!
* bootstrap-star-rating v4.0.2
* bootstrap-star-rating v4.0.4
* http://plugins.krajee.com/star-rating
*
* Author: Kartik Visweswaran
* Copyright: 2014 - 2016, Kartik Visweswaran, Krajee.com
* Copyright: 2013 - 2018, Kartik Visweswaran, Krajee.com
*
* Licensed under the BSD 3-Clause
* https://github.com/kartik-v/bootstrap-star-rating/blob/master/LICENSE.md
*/!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(window.jQuery)}(function(e){"use strict";e.fn.ratingLocales={},e.fn.ratingThemes={};var t,a,n,r,i,l,s,o,c,u,h;t=".rating",a=0,n=5,r=.5,i=function(t,a){return null===t||void 0===t||0===t.length||a&&""===e.trim(t)},l=function(e,t){return e?" "+t:""},s=function(e,t){e.removeClass(t).addClass(t)},o=function(e){var t=(""+e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0},c=function(e,t){return parseFloat(e.toFixed(t))},u=function(e,a,n,r){var i=r?a:a.split(" ").join(t+" ")+t;e.off(i).on(i,n)},h=function(t,a){var n=this;n.$element=e(t),n._init(a)},h.prototype={constructor:h,_parseAttr:function(e,t){var l,s,o,c,u=this,h=u.$element,d=h.attr("type");if("range"===d||"number"===d){switch(s=t[e]||h.data(e)||h.attr(e),e){case"min":o=a;break;case"max":o=n;break;default:o=r}l=i(s)?o:s,c=parseFloat(l)}else c=parseFloat(t[e]);return isNaN(c)?o:c},_setDefault:function(e,t){var a=this;i(a[e])&&(a[e]=t)},_listenClick:function(e,t){return e.stopPropagation(),e.preventDefault(),e.handled===!0?!1:(t(e),void(e.handled=!0))},_starClick:function(e){var t,a=this;a._listenClick(e,function(e){return a.inactive?!1:(t=a._getTouchPosition(e),a._setStars(t),a.$element.trigger("change").trigger("rating.change",[a.$element.val(),a._getCaption()]),void(a.starClicked=!0))})},_starMouseMove:function(e){var t,a,n=this;!n.hoverEnabled||n.inactive||e&&e.isDefaultPrevented()||(n.starClicked=!1,t=n._getTouchPosition(e),a=n.calculate(t),n._toggleHover(a),n.$element.trigger("rating.hover",[a.val,a.caption,"stars"]))},_starMouseLeave:function(e){var t,a=this;!a.hoverEnabled||a.inactive||a.starClicked||e&&e.isDefaultPrevented()||(t=a.cache,a._toggleHover(t),a.$element.trigger("rating.hoverleave",["stars"]))},_clearClick:function(e){var t=this;t._listenClick(e,function(){t.inactive||(t.clear(),t.clearClicked=!0)})},_clearMouseMove:function(e){var t,a,n,r,i=this;!i.hoverEnabled||i.inactive||!i.hoverOnClear||e&&e.isDefaultPrevented()||(i.clearClicked=!1,t='<span class="'+i.clearCaptionClass+'">'+i.clearCaption+"</span>",a=i.clearValue,n=i.getWidthFromValue(a)||0,r={caption:t,width:n,val:a},i._toggleHover(r),i.$element.trigger("rating.hover",[a,t,"clear"]))},_clearMouseLeave:function(e){var t,a=this;!a.hoverEnabled||a.inactive||a.clearClicked||!a.hoverOnClear||e&&e.isDefaultPrevented()||(t=a.cache,a._toggleHover(t),a.$element.trigger("rating.hoverleave",["clear"]))},_resetForm:function(e){var t=this;e&&e.isDefaultPrevented()||t.inactive||t.reset()},_setTouch:function(e,t){var a,n,r,l,s,o,c,u=this,h="ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch;h&&!u.inactive&&(a=e.originalEvent,n=i(a.touches)?a.changedTouches:a.touches,r=u._getTouchPosition(n[0]),t?(u._setStars(r),u.$element.trigger("change").trigger("rating.change",[u.$element.val(),u._getCaption()]),u.starClicked=!0):(l=u.calculate(r),s=l.val<=u.clearValue?u.fetchCaption(u.clearValue):l.caption,o=u.getWidthFromValue(u.clearValue),c=l.val<=u.clearValue?o+"%":l.width,u._setCaption(s),u.$filledStars.css("width",c)))},_initTouch:function(e){var t=this,a="touchend"===e.type;t._setTouch(e,a)},_initSlider:function(e){var t=this;i(t.$element.val())&&t.$element.val(0),t.initialValue=t.$element.val(),t._setDefault("min",t._parseAttr("min",e)),t._setDefault("max",t._parseAttr("max",e)),t._setDefault("step",t._parseAttr("step",e)),(isNaN(t.min)||i(t.min))&&(t.min=a),(isNaN(t.max)||i(t.max))&&(t.max=n),(isNaN(t.step)||i(t.step)||0===t.step)&&(t.step=r),t.diff=t.max-t.min},_initHighlight:function(e){var t,a=this,n=a._getCaption();e||(e=a.$element.val()),t=a.getWidthFromValue(e)+"%",a.$filledStars.width(t),a.cache={caption:n,width:t,val:e}},_getContainerCss:function(){var e=this;return"rating-container"+l(e.theme,"theme-"+e.theme)+l(e.rtl,"rating-rtl")+l(e.size,"rating-"+e.size)+l(e.animate,"rating-animate")+l(e.disabled||e.readonly,"rating-disabled")+l(e.containerClass,e.containerClass)},_checkDisabled:function(){var e=this,t=e.$element,a=e.options;e.disabled=void 0===a.disabled?t.attr("disabled")||!1:a.disabled,e.readonly=void 0===a.readonly?t.attr("readonly")||!1:a.readonly,e.inactive=e.disabled||e.readonly,t.attr({disabled:e.disabled,readonly:e.readonly})},_addContent:function(e,t){var a=this,n=a.$container,r="clear"===e;return a.rtl?r?n.append(t):n.prepend(t):r?n.prepend(t):n.append(t)},_generateRating:function(){var t,a,n,r=this,i=r.$element;a=r.$container=e(document.createElement("div")).insertBefore(i),s(a,r._getContainerCss()),r.$rating=t=e(document.createElement("div")).attr("class","rating").appendTo(a).append(r._getStars("empty")).append(r._getStars("filled")),r.$emptyStars=t.find(".empty-stars"),r.$filledStars=t.find(".filled-stars"),r._renderCaption(),r._renderClear(),r._initHighlight(),a.append(i),r.rtl&&(n=Math.max(r.$emptyStars.outerWidth(),r.$filledStars.outerWidth()),r.$emptyStars.width(n))},_getCaption:function(){var e=this;return e.$caption&&e.$caption.length?e.$caption.html():e.defaultCaption},_setCaption:function(e){var t=this;t.$caption&&t.$caption.length&&t.$caption.html(e)},_renderCaption:function(){var t,a=this,n=a.$element.val(),r=a.captionElement?e(a.captionElement):"";if(a.showCaption){if(t=a.fetchCaption(n),r&&r.length)return s(r,"caption"),r.html(t),void(a.$caption=r);a._addContent("caption",'<div class="caption">'+t+"</div>"),a.$caption=a.$container.find(".caption")}},_renderClear:function(){var t,a=this,n=a.clearElement?e(a.clearElement):"";if(a.showClear){if(t=a._getClearClass(),n.length)return s(n,t),n.attr({title:a.clearButtonTitle}).html(a.clearButton),void(a.$clear=n);a._addContent("clear",'<div class="'+t+'" title="'+a.clearButtonTitle+'">'+a.clearButton+"</div>"),a.$clear=a.$container.find("."+a.clearButtonBaseClass)}},_getClearClass:function(){return this.clearButtonBaseClass+" "+(this.inactive?"":this.clearButtonActiveClass)},_getTouchPosition:function(e){var t=i(e.pageX)?e.originalEvent.touches[0].pageX:e.pageX;return t-this.$rating.offset().left},_toggleHover:function(e){var t,a,n,r=this;e&&(r.hoverChangeStars&&(t=r.getWidthFromValue(r.clearValue),a=e.val<=r.clearValue?t+"%":e.width,r.$filledStars.css("width",a)),r.hoverChangeCaption&&(n=e.val<=r.clearValue?r.fetchCaption(r.clearValue):e.caption,n&&r._setCaption(n+"")))},_init:function(t){var a=this,n=a.$element.addClass("hide");return a.options=t,e.each(t,function(e,t){a[e]=t}),(a.rtl||"rtl"===n.attr("dir"))&&(a.rtl=!0,n.attr("dir","rtl")),a.starClicked=!1,a.clearClicked=!1,a._initSlider(t),a._checkDisabled(),a.displayOnly&&(a.inactive=!0,a.showClear=!1,a.showCaption=!1),a._generateRating(),a._listen(),n.removeClass("rating-loading")},_listen:function(){var t=this,a=t.$element,n=a.closest("form"),r=t.$rating,i=t.$clear;return u(r,"touchstart touchmove touchend",e.proxy(t._initTouch,t)),u(r,"click touchstart",e.proxy(t._starClick,t)),u(r,"mousemove",e.proxy(t._starMouseMove,t)),u(r,"mouseleave",e.proxy(t._starMouseLeave,t)),t.showClear&&i.length&&(u(i,"click touchstart",e.proxy(t._clearClick,t)),u(i,"mousemove",e.proxy(t._clearMouseMove,t)),u(i,"mouseleave",e.proxy(t._clearMouseLeave,t))),n.length&&u(n,"reset",e.proxy(t._resetForm,t)),a},_getStars:function(e){var t,a=this,n='<span class="'+e+'-stars">';for(t=1;t<=a.stars;t++)n+='<span class="star">'+a[e+"Star"]+"</span>";return n+"</span>"},_setStars:function(e){var t=this,a=arguments.length?t.calculate(e):t.calculate(),n=t.$element;return n.val(a.val),t.$filledStars.css("width",a.width),t._setCaption(a.caption),t.cache=a,n},showStars:function(e){var t=this,a=parseFloat(e);return t.$element.val(isNaN(a)?t.clearValue:a),t._setStars()},calculate:function(e){var t=this,a=i(t.$element.val())?0:t.$element.val(),n=arguments.length?t.getValueFromPosition(e):a,r=t.fetchCaption(n),l=t.getWidthFromValue(n);return l+="%",{caption:r,width:l,val:n}},getValueFromPosition:function(e){var t,a,n=this,r=o(n.step),i=n.$rating.width();return a=n.diff*e/(i*n.step),a=n.rtl?Math.floor(a):Math.ceil(a),t=c(parseFloat(n.min+a*n.step),r),t=Math.max(Math.min(t,n.max),n.min),n.rtl?n.max-t:t},getWidthFromValue:function(e){var t,a,n=this,r=n.min,i=n.max,l=n.$emptyStars;return!e||r>=e||r===i?0:(a=l.outerWidth(),t=a?l.width()/a:1,e>=i?100:(e-r)*t*100/(i-r))},fetchCaption:function(e){var t,a,n,r,l,s=this,u=parseFloat(e)||s.clearValue,h=s.starCaptions,d=s.starCaptionClasses;return u&&u!==s.clearValue&&(u=c(u,o(s.step))),r="function"==typeof d?d(u):d[u],n="function"==typeof h?h(u):h[u],a=i(n)?s.defaultCaption.replace(/\{rating}/g,u):n,t=i(r)?s.clearCaptionClass:r,l=u===s.clearValue?s.clearCaption:a,'<span class="'+t+'">'+l+"</span>"},destroy:function(){var t=this,a=t.$element;return i(t.$container)||t.$container.before(a).remove(),e.removeData(a.get(0)),a.off("rating").removeClass("hide")},create:function(e){var t=this,a=e||t.options||{};return t.destroy().rating(a)},clear:function(){var e=this,t='<span class="'+e.clearCaptionClass+'">'+e.clearCaption+"</span>";return e.inactive||e._setCaption(t),e.showStars(e.clearValue).trigger("change").trigger("rating.clear")},reset:function(){var e=this;return e.showStars(e.initialValue).trigger("rating.reset")},update:function(e){var t=this;return arguments.length?t.showStars(e):t.$element},refresh:function(t){var a=this,n=a.$element;return t?a.destroy().rating(e.extend(!0,a.options,t)).trigger("rating.refresh"):n}},e.fn.rating=function(t){var a=Array.apply(null,arguments),n=[];switch(a.shift(),this.each(function(){var r,l=e(this),s=l.data("rating"),o="object"==typeof t&&t,c=o.theme||l.data("theme"),u=o.language||l.data("language")||"en",d={},g={};s||(c&&(d=e.fn.ratingThemes[c]||{}),"en"===u||i(e.fn.ratingLocales[u])||(g=e.fn.ratingLocales[u]),r=e.extend(!0,{},e.fn.rating.defaults,d,e.fn.ratingLocales.en,g,o,l.data()),s=new h(this,r),l.data("rating",s)),"string"==typeof t&&n.push(s[t].apply(s,a))}),n.length){case 0:return this;case 1:return void 0===n[0]?this:n[0];default:return n}},e.fn.rating.defaults={theme:"",language:"en",stars:5,filledStar:'<i class="glyphicon glyphicon-star"></i>',emptyStar:'<i class="glyphicon glyphicon-star-empty"></i>',containerClass:"",size:"md",animate:!0,displayOnly:!1,rtl:!1,showClear:!0,showCaption:!0,starCaptionClasses:{.5:"label label-danger",1:"label label-danger",1.5:"label label-warning",2:"label label-warning",2.5:"label label-info",3:"label label-info",3.5:"label label-primary",4:"label label-primary",4.5:"label label-success",5:"label label-success"},clearButton:'<i class="glyphicon glyphicon-minus-sign"></i>',clearButtonBaseClass:"clear-rating",clearButtonActiveClass:"clear-rating-active",clearCaptionClass:"label label-default",clearValue:null,captionElement:null,clearElement:null,hoverEnabled:!0,hoverChangeCaption:!0,hoverChangeStars:!0,hoverOnClear:!0},e.fn.ratingLocales.en={defaultCaption:"{rating} Stars",starCaptions:{.5:"Half Star",1:"One Star",1.5:"One & Half Star",2:"Two Stars",2.5:"Two & Half Stars",3:"Three Stars",3.5:"Three & Half Stars",4:"Four Stars",4.5:"Four & Half Stars",5:"Five Stars"},clearButtonTitle:"Clear",clearCaption:"Not Rated"},e.fn.rating.Constructor=h,e(document).ready(function(){var t=e("input.rating");t.length&&t.removeClass("rating-loading").addClass("rating-loading").rating()})});
*/
!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";var e,i;t.fn.ratingLocales={},t.fn.ratingThemes={},e={NAMESPACE:".rating",DEFAULT_MIN:0,DEFAULT_MAX:5,DEFAULT_STEP:.5,isEmpty:function(e,i){return null==e||0===e.length||i&&""===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(t,i,a,n,s){var r=s?i:i.split(" ").join(e.NAMESPACE+" ")+e.NAMESPACE;n||t.off(r),t.on(r,a)}},(i=function(e,i){this.$element=t(e),this._init(i)}).prototype={constructor:i,_parseAttr:function(t,i){var a,n,s,r,l=this.$element,o=l.attr("type");if("range"===o||"number"===o){switch(n=i[t]||l.data(t)||l.attr(t),t){case"min":s=e.DEFAULT_MIN;break;case"max":s=e.DEFAULT_MAX;break;default:s=e.DEFAULT_STEP}a=e.isEmpty(n)?s:n,r=parseFloat(a)}else r=parseFloat(i[t]);return isNaN(r)?s:r},_parseValue:function(t){var e=parseFloat(t);return isNaN(e)&&(e=this.clearValue),!this.zeroAsNull||0!==e&&"0"!==e?e:null},_setDefault:function(t,i){e.isEmpty(this[t])&&(this[t]=i)},_initSlider:function(t){var i=this.$element.val();this.initialValue=e.isEmpty(i)?0:i,this._setDefault("min",this._parseAttr("min",t)),this._setDefault("max",this._parseAttr("max",t)),this._setDefault("step",this._parseAttr("step",t)),(isNaN(this.min)||e.isEmpty(this.min))&&(this.min=e.DEFAULT_MIN),(isNaN(this.max)||e.isEmpty(this.max))&&(this.max=e.DEFAULT_MAX),(isNaN(this.step)||e.isEmpty(this.step)||0===this.step)&&(this.step=e.DEFAULT_STEP),this.diff=this.max-this.min},_initHighlight:function(t){var e,i=this._getCaption();t||(t=this.$element.val()),e=this.getWidthFromValue(t)+"%",this.$filledStars.width(e),this.cache={caption:i,width:e,val:t}},_getContainerCss:function(){return"rating-container"+e.getCss(this.theme,"theme-"+this.theme)+e.getCss(this.rtl,"rating-rtl")+e.getCss(this.size,"rating-"+this.size)+e.getCss(this.animate,"rating-animate")+e.getCss(this.disabled||this.readonly,"rating-disabled")+e.getCss(this.containerClass,this.containerClass)+(this.displayOnly?" is-display-only":"")},_checkDisabled:function(){var t=this.$element,e=this.options;this.disabled=void 0===e.disabled?t.attr("disabled")||!1:e.disabled,this.readonly=void 0===e.readonly?t.attr("readonly")||!1:e.readonly,this.inactive=this.disabled||this.readonly,t.attr({disabled:this.disabled,readonly:this.readonly})},_addContent:function(t,e){var i=this.$container,a="clear"===t;return this.rtl?a?i.append(e):i.prepend(e):a?i.prepend(e):i.append(e)},_generateRating:function(){var i,a,n,s=this.$element;a=this.$container=t(document.createElement("div")).insertBefore(s),e.addCss(a,this._getContainerCss()),this.$rating=i=t(document.createElement("div")).attr("class","rating-stars").appendTo(a).append(this._getStars("empty")).append(this._getStars("filled")),this.$emptyStars=i.find(".empty-stars"),this.$filledStars=i.find(".filled-stars"),this._renderCaption(),this._renderClear(),this._initHighlight(),this._initCaptionTitle(),a.append(s),this.rtl&&(n=Math.max(this.$emptyStars.outerWidth(),this.$filledStars.outerWidth()),this.$emptyStars.width(n)),s.appendTo(i)},_getCaption:function(){return this.$caption&&this.$caption.length?this.$caption.html():this.defaultCaption},_setCaption:function(t){this.$caption&&this.$caption.length&&this.$caption.html(t)},_renderCaption:function(){var i,a=this.$element.val(),n=this.captionElement?t(this.captionElement):"";if(this.showCaption){if(i=this.fetchCaption(a),n&&n.length)return e.addCss(n,"caption"),n.html(i),void(this.$caption=n);this._addContent("caption",'<div class="caption">'+i+"</div>"),this.$caption=this.$container.find(".caption")}},_renderClear:function(){var i,a=this.clearElement?t(this.clearElement):"";if(this.showClear){if(i=this._getClearClass(),a.length)return e.addCss(a,i),a.attr({title:this.clearButtonTitle}).html(this.clearButton),void(this.$clear=a);this._addContent("clear",'<div class="'+i+'" title="'+this.clearButtonTitle+'">'+this.clearButton+"</div>"),this.$clear=this.$container.find("."+this.clearButtonBaseClass)}},_getClearClass:function(){return this.clearButtonBaseClass+" "+(this.inactive?"":this.clearButtonActiveClass)},_toggleHover:function(t){var e,i,a;t&&(this.hoverChangeStars&&(e=this.getWidthFromValue(this.clearValue),i=t.val<=this.clearValue?e+"%":t.width,this.$filledStars.css("width",i)),this.hoverChangeCaption&&(a=t.val<=this.clearValue?this.fetchCaption(this.clearValue):t.caption)&&this._setCaption(a+""))},_init:function(e){var i,a=this,n=a.$element.addClass("rating-input");return a.options=e,t.each(e,function(t,e){a[t]=e}),(a.rtl||"rtl"===n.attr("dir"))&&(a.rtl=!0,n.attr("dir","rtl")),a.starClicked=!1,a.clearClicked=!1,a._initSlider(e),a._checkDisabled(),a.displayOnly&&(a.inactive=!0,a.showClear=!1,a.showCaption=!1),a._generateRating(),a._initEvents(),a._listen(),i=a._parseValue(n.val()),n.val(i),n.removeClass("rating-loading")},_initCaptionTitle:function(){var e;this.showCaptionAsTitle&&(e=this.fetchCaption(this.$element.val()),this.$rating.attr("title",t(e).text()))},_trigChange:function(t){this._initCaptionTitle(),this.$element.trigger("change").trigger("rating:change",t)},_initEvents:function(){var t=this;t.events={_getTouchPosition:function(i){return(e.isEmpty(i.pageX)?i.originalEvent.touches[0].pageX:i.pageX)-t.$rating.offset().left},_listenClick:function(t,e){if(t.stopPropagation(),t.preventDefault(),!0===t.handled)return!1;e(t),t.handled=!0},_noMouseAction:function(e){return!t.hoverEnabled||t.inactive||e&&e.isDefaultPrevented()},initTouch:function(i){var a,n,s,r,l,o,h,c,u=t.clearValue||0;("ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch)&&!t.inactive&&(a=i.originalEvent,n=e.isEmpty(a.touches)?a.changedTouches:a.touches,s=t.events._getTouchPosition(n[0]),"touchend"===i.type?(t._setStars(s),c=[t.$element.val(),t._getCaption()],t._trigChange(c),t.starClicked=!0):(l=(r=t.calculate(s)).val<=u?t.fetchCaption(u):r.caption,o=t.getWidthFromValue(u),h=r.val<=u?o+"%":r.width,t._setCaption(l),t.$filledStars.css("width",h)))},starClick:function(e){var i,a;t.events._listenClick(e,function(e){if(t.inactive)return!1;i=t.events._getTouchPosition(e),t._setStars(i),a=[t.$element.val(),t._getCaption()],t._trigChange(a),t.starClicked=!0})},clearClick:function(e){t.events._listenClick(e,function(){t.inactive||(t.clear(),t.clearClicked=!0)})},starMouseMove:function(e){var i,a;t.events._noMouseAction(e)||(t.starClicked=!1,i=t.events._getTouchPosition(e),a=t.calculate(i),t._toggleHover(a),t.$element.trigger("rating:hover",[a.val,a.caption,"stars"]))},starMouseLeave:function(e){var i;t.events._noMouseAction(e)||t.starClicked||(i=t.cache,t._toggleHover(i),t.$element.trigger("rating:hoverleave",["stars"]))},clearMouseMove:function(e){var i,a,n;!t.events._noMouseAction(e)&&t.hoverOnClear&&(t.clearClicked=!1,i='<span class="'+t.clearCaptionClass+'">'+t.clearCaption+"</span>",a=t.clearValue,n={caption:i,width:t.getWidthFromValue(a)||0,val:a},t._toggleHover(n),t.$element.trigger("rating:hover",[a,i,"clear"]))},clearMouseLeave:function(e){var i;t.events._noMouseAction(e)||t.clearClicked||!t.hoverOnClear||(i=t.cache,t._toggleHover(i),t.$element.trigger("rating:hoverleave",["clear"]))},resetForm:function(e){e&&e.isDefaultPrevented()||t.inactive||t.reset()}}},_listen:function(){var i=this.$element,a=i.closest("form"),n=this.$rating,s=this.$clear,r=this.events;return e.handler(n,"touchstart touchmove touchend",t.proxy(r.initTouch,this)),e.handler(n,"click touchstart",t.proxy(r.starClick,this)),e.handler(n,"mousemove",t.proxy(r.starMouseMove,this)),e.handler(n,"mouseleave",t.proxy(r.starMouseLeave,this)),this.showClear&&s.length&&(e.handler(s,"click touchstart",t.proxy(r.clearClick,this)),e.handler(s,"mousemove",t.proxy(r.clearMouseMove,this)),e.handler(s,"mouseleave",t.proxy(r.clearMouseLeave,this))),a.length&&e.handler(a,"reset",t.proxy(r.resetForm,this),!0),i},_getStars:function(t){var e,i='<span class="'+t+'-stars">';for(e=1;e<=this.stars;e++)i+='<span class="star">'+this[t+"Star"]+"</span>";return i+"</span>"},_setStars:function(t){var e=arguments.length?this.calculate(t):this.calculate(),i=this.$element,a=this._parseValue(e.val);return i.val(a),this.$filledStars.css("width",e.width),this._setCaption(e.caption),this.cache=e,i},showStars:function(t){var e=this._parseValue(t);return this.$element.val(e),this._initCaptionTitle(),this._setStars()},calculate:function(t){var i=e.isEmpty(this.$element.val())?0:this.$element.val(),a=arguments.length?this.getValueFromPosition(t):i,n=this.fetchCaption(a),s=this.getWidthFromValue(a);return{caption:n,width:s+="%",val:a}},getValueFromPosition:function(t){var i,a,n=e.getDecimalPlaces(this.step),s=this.$rating.width();return a=this.diff*t/(s*this.step),a=this.rtl?Math.floor(a):Math.ceil(a),i=e.applyPrecision(parseFloat(this.min+a*this.step),n),i=Math.max(Math.min(i,this.max),this.min),this.rtl?this.max-i:i},getWidthFromValue:function(t){var e,i,a=this.min,n=this.max,s=this.$emptyStars;return!t||t<=a||a===n?0:(e=(i=s.outerWidth())?s.width()/i:1,t>=n?100:(t-a)*e*100/(n-a))},fetchCaption:function(t){var i,a,n,s=parseFloat(t)||this.clearValue,r=this.starCaptions,l=this.starCaptionClasses;return s&&s!==this.clearValue&&(s=e.applyPrecision(s,e.getDecimalPlaces(this.step))),n="function"==typeof l?l(s):l[s],a="function"==typeof r?r(s):r[s],i=e.isEmpty(a)?this.defaultCaption.replace(/\{rating}/g,s):a,'<span class="'+(e.isEmpty(n)?this.clearCaptionClass:n)+'">'+(s===this.clearValue?this.clearCaption:i)+"</span>"},destroy:function(){var i=this.$element;return e.isEmpty(this.$container)||this.$container.before(i).remove(),t.removeData(i.get(0)),i.off("rating").removeClass("rating rating-input")},create:function(t){var e=t||this.options||{};return this.destroy().rating(e)},clear:function(){var t='<span class="'+this.clearCaptionClass+'">'+this.clearCaption+"</span>";return this.inactive||this._setCaption(t),this.showStars(this.clearValue).trigger("change").trigger("rating:clear")},reset:function(){return this.showStars(this.initialValue).trigger("rating:reset")},update:function(t){return arguments.length?this.showStars(t):this.$element},refresh:function(e){var i=this.$element;return e?this.destroy().rating(t.extend(!0,this.options,e)).trigger("rating:refresh"):i}},t.fn.rating=function(a){var n=Array.apply(null,arguments),s=[];switch(n.shift(),this.each(function(){var r,l=t(this),o=l.data("rating"),h="object"==typeof a&&a,c=h.theme||l.data("theme"),u=h.language||l.data("language")||"en",d={},p={};o||(c&&(d=t.fn.ratingThemes[c]||{}),"en"===u||e.isEmpty(t.fn.ratingLocales[u])||(p=t.fn.ratingLocales[u]),r=t.extend(!0,{},t.fn.rating.defaults,d,t.fn.ratingLocales.en,p,h,l.data()),o=new i(this,r),l.data("rating",o)),"string"==typeof a&&s.push(o[a].apply(o,n))}),s.length){case 0:return this;case 1:return void 0===s[0]?this:s[0];default:return s}},t.fn.rating.defaults={theme:"",language:"en",stars:5,filledStar:'<i class="glyphicon glyphicon-star"></i>',emptyStar:'<i class="glyphicon glyphicon-star-empty"></i>',containerClass:"",size:"md",animate:!0,displayOnly:!1,rtl:!1,showClear:!0,showCaption:!0,starCaptionClasses:{.5:"label label-danger badge-danger",1:"label label-danger badge-danger",1.5:"label label-warning badge-warning",2:"label label-warning badge-warning",2.5:"label label-info badge-info",3:"label label-info badge-info",3.5:"label label-primary badge-primary",4:"label label-primary badge-primary",4.5:"label label-success badge-success",5:"label label-success badge-success"},clearButton:'<i class="glyphicon glyphicon-minus-sign"></i>',clearButtonBaseClass:"clear-rating",clearButtonActiveClass:"clear-rating-active",clearCaptionClass:"label label-default badge-secondary",clearValue:null,captionElement:null,clearElement:null,showCaptionAsTitle:!0,hoverEnabled:!0,hoverChangeCaption:!0,hoverChangeStars:!0,hoverOnClear:!0,zeroAsNull:!0},t.fn.ratingLocales.en={defaultCaption:"{rating} Stars",starCaptions:{.5:"Half Star",1:"One Star",1.5:"One & Half Star",2:"Two Stars",2.5:"Two & Half Stars",3:"Three Stars",3.5:"Three & Half Stars",4:"Four Stars",4.5:"Four & Half Stars",5:"Five Stars"},clearButtonTitle:"Clear",clearCaption:"Not Rated"},t.fn.rating.Constructor=i,t(document).ready(function(){var e=t("input.rating");e.length&&e.removeClass("rating-loading").addClass("rating-loading").rating()})});

@@ -1,2 +0,2 @@

Copyright (c) 2013 - 2016, Kartik Visweswaran
Copyright (c) 2013 - 2018, Kartik Visweswaran
Krajee.com

@@ -3,0 +3,0 @@ All rights reserved.

{
"name": "bootstrap-star-rating",
"version": "4.0.2",
"version": "4.0.4",
"homepage": "https://github.com/kartik-v/bootstrap-star-rating",

@@ -10,4 +10,4 @@ "author": "Kartik Visweswaran <kartikv2@gmail.com>",

},
"repository" : {
"type": "git",
"repository": {
"type": "git",
"url": "https://github.com/kartik-v/bootstrap-star-rating.git"

@@ -14,0 +14,0 @@ },

@@ -148,2 +148,2 @@ bootstrap-star-rating

**bootstrap-star-rating** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details.
**bootstrap-star-rating** is released under the BSD-3-Clause License. See the bundled `LICENSE.md` for details.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc