Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jquery-bar-rating

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-bar-rating - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

examples/less/mixins.less

2

bower.json
{
"name": "jquery-bar-rating",
"version": "1.1.2",
"version": "1.1.3",
"homepage": "http://antenna.io/demo/jquery-bar-rating/examples/",

@@ -5,0 +5,0 @@ "repository": {

@@ -0,1 +1,20 @@

1.1.3
-----
- new option added: `silent`
- `readonly` method added
- namespaced events
- rating widget - redundant span elements dropped
- `wrapperClass` option deprecated
- pass event object to onSelect callback
- print styles added
- new option added: `hoverState`
1.1.2

@@ -2,0 +21,0 @@ -----

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

!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e=function(){function e(){var e=this,a=function(){var a=[e.options.wrapperClass];""!==e.options.theme&&a.push("br-theme-"+e.options.theme),e.$elem.wrap(t("<div />",{"class":a.join(" ")}))},n=function(){e.$elem.unwrap()},r=function(){var a;return a=e.options.initialRating?t('option[value="'+e.options.initialRating+'"]',e.$elem):t("option:selected",e.$elem)},i=function(){var t=r();e.$elem.data("barrating",{userOptions:e.options,currentRatingValue:t.val(),currentRatingText:t.data("html")?t.data("html"):t.text(),originalRatingValue:t.val(),originalRatingText:t.data("html")?t.data("html"):t.text()}),e.$elem.data("barrating").deselectable=e.$elem.find("option:first").val()?!1:!0},s=function(){e.$elem.removeData("barrating")},l=function(){var a=t("<div />",{"class":"br-widget"});return e.$elem.find("option").each(function(){var n,r,i,s,l;n=t(this).val(),n&&(r=t(this).text(),i=t(this).data("html"),i&&(r=i),s=t("<a />",{href:"#","data-rating-value":n,"data-rating-text":r}),l=t("<span />",{html:e.options.showValues?r:""}),a.append(s.append(l)))}),e.options.showSelectedRating&&a.append(t("<div />",{text:"","class":"br-current-rating"})),e.options.reverse&&a.addClass("br-reverse"),e.options.readonly&&a.addClass("br-readonly"),a},o=function(){return e.options.reverse?"nextAll":"prevAll"},u=function(t){e.$elem.find('option[value="'+t+'"]').prop("selected",!0),e.$elem.change()},c=function(t){t=t?t:e.$elem.data("barrating").currentRatingText,e.options.showSelectedRating&&e.$elem.parent().find(".br-current-rating").text(t)},d=function(t){t.find("a").removeClass("br-selected br-current"),t.find('a[data-rating-value="'+e.$elem.data("barrating").currentRatingValue+'"]').addClass("br-selected br-current")[o()]().addClass("br-selected")},g=function(a){a.on("click",function(n){var r,i,s=t(this);return n.preventDefault(),a.removeClass("br-active br-selected"),s.addClass("br-selected")[o()]().addClass("br-selected"),r=s.attr("data-rating-value"),i=s.attr("data-rating-text"),s.hasClass("br-current")&&e.$elem.data("barrating").deselectable?(s.removeClass("br-selected br-current")[o()]().removeClass("br-selected br-current"),r="",i=""):(a.removeClass("br-current"),s.addClass("br-current")),e.$elem.data("barrating").currentRatingValue=r,e.$elem.data("barrating").currentRatingText=i,u(r),c(i),e.options.onSelect.call(this,e.$elem.data("barrating").currentRatingValue,e.$elem.data("barrating").currentRatingText),!1})},h=function(e){e.on({mouseenter:function(){var a=t(this);e.removeClass("br-active br-selected"),a.addClass("br-active")[o()]().addClass("br-active"),c(a.attr("data-rating-text"))}})},f=function(t,e){e.on({mouseleave:function(){t.removeClass("br-active"),c(),d(e)}})},m=function(e){e.on("touchstart",function(e){e.preventDefault(),e.stopPropagation(),t(this).click()})},b=function(t){t.on("click",function(t){t.preventDefault()})};this.show=function(){var t,n;e.$elem.data("barrating")||(a(),i(),t=l(),t.insertAfter(e.$elem),d(t),c(),n=t.find("a"),e.options.fastClicks&&m(n),e.options.readonly?b(n):(g(n),h(n),f(n,t)),e.$elem.hide())},this.set=function(t){this.$elem.find('option[value="'+t+'"]').val()&&(this.$elem.data("barrating").currentRatingValue=t,this.$elem.data("barrating").currentRatingText=this.$elem.find('option[value="'+t+'"]').text(),u(this.$elem.data("barrating").currentRatingValue),c(this.$elem.data("barrating").currentRatingText),d(this.$widget),this.$elem.data("barrating").userOptions.onSelect.call(this,this.$elem.data("barrating").currentRatingValue,this.$elem.data("barrating").currentRatingText))},this.clear=function(){this.$elem.data("barrating").currentRatingValue=this.$elem.data("barrating").originalRatingValue,this.$elem.data("barrating").currentRatingText=this.$elem.data("barrating").originalRatingText,u(this.$elem.data("barrating").currentRatingValue),c(this.$elem.data("barrating").currentRatingText),d(this.$widget),this.$elem.data("barrating").userOptions.onClear.call(this,this.$elem.data("barrating").currentRatingValue,this.$elem.data("barrating").currentRatingText)},this.destroy=function(){var t=this.$elem.data("barrating").currentRatingValue,e=this.$elem.data("barrating").currentRatingText,a=this.$elem.data("barrating").userOptions;this.$widget.off().remove(),s(),n(),this.$elem.show(),a.onDestroy.call(this,t,e)}}return e.prototype.init=function(e,a){return this.$elem=t(a),this.options=t.extend({},t.fn.barrating.defaults,e),this.options},e}();t.fn.barrating=function(a,n){return this.each(function(){var r=new e;if(t(this).is("select")||t.error("Sorry, this plugin only works with select fields."),r.hasOwnProperty(a)){if(r.init(n,this),"show"===a)return r.show(n);if(r.$elem.data("barrating"))return r.$widget=t(this).next(".br-widget"),r[a](n)}else{if("object"==typeof a||!a)return n=a,r.init(n,this),r.show();t.error("Method "+a+" does not exist on jQuery.barrating")}})},t.fn.barrating.defaults={theme:"",initialRating:null,showValues:!1,showSelectedRating:!0,reverse:!1,readonly:!1,fastClicks:!0,wrapperClass:"br-wrapper",onSelect:function(t,e){},onClear:function(t,e){},onDestroy:function(t,e){}},t.fn.barrating.BarRating=e});
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){var t=function(){function t(){var t=this,n=function(){var n=[t.options.wrapperClass];""!==t.options.theme&&n.push("br-theme-"+t.options.theme),t.$elem.wrap(e("<div />",{"class":n.join(" ")}))},r=function(){t.$elem.unwrap()},a=function(){var n;return n=t.options.initialRating?e('option[value="'+t.options.initialRating+'"]',t.$elem):e("option:selected",t.$elem)},i=function(e){var n=t.$elem.data("barrating");return"undefined"!=typeof e?n[e]:n},o=function(e,n){null!==n&&"object"==typeof n?t.$elem.data("barrating",n):t.$elem.data("barrating")[e]=n},s=function(){var e=a();o(null,{userOptions:t.options,ratingValue:e.val(),ratingText:e.data("html")?e.data("html"):e.text(),originalRatingValue:e.val(),originalRatingText:e.data("html")?e.data("html"):e.text(),readOnly:t.options.readonly,deselectable:t.$elem.find("option:first").val()?!1:!0})},l=function(){t.$elem.removeData("barrating")},u=function(){return i("ratingText")},d=function(){return i("ratingValue")},c=function(){var n=e("<div />",{"class":"br-widget"});return t.$elem.find("option").each(function(){var r,a,i,o;r=e(this).val(),r&&(a=e(this).text(),i=e(this).data("html"),i&&(a=i),o=e("<a />",{href:"#","data-rating-value":r,"data-rating-text":a,html:t.options.showValues?a:""}),n.append(o))}),t.options.showSelectedRating&&n.append(e("<div />",{text:"","class":"br-current-rating"})),t.options.reverse&&n.addClass("br-reverse"),t.options.readonly&&n.addClass("br-readonly"),n},f=function(){return t.options.reverse?"nextAll":"prevAll"},g=function(e){t.$elem.find('option[value="'+e+'"]').prop("selected",!0),t.$elem.change()},p=function(e){e=e?e:u(),t.options.showSelectedRating&&t.$elem.parent().find(".br-current-rating").text(e)},h=function(){t.$widget.find("a").removeClass("br-selected br-current"),t.$widget.find('a[data-rating-value="'+d()+'"]').addClass("br-selected br-current")[f()]().addClass("br-selected")},v=function(e){return e.hasClass("br-current")&&i("deselectable")},b=function(n){n.on("click.barrating",function(r){var a,i,s=e(this);return r.preventDefault(),n.removeClass("br-active br-selected"),s.addClass("br-selected")[f()]().addClass("br-selected"),a=s.attr("data-rating-value"),i=s.attr("data-rating-text"),v(s)?(s.removeClass("br-selected br-current")[f()]().removeClass("br-selected br-current"),a="",i=""):(n.removeClass("br-current"),s.addClass("br-current")),o("ratingValue",a),o("ratingText",i),g(a),p(i),t.options.onSelect.call(t,d(),u(),r),!1})},m=function(t){t.on("mouseenter.barrating",function(){var n=e(this);t.removeClass("br-active br-selected"),n.addClass("br-active")[f()]().addClass("br-active"),p(n.attr("data-rating-text"))})},$=function(e){t.$widget.on("mouseleave.barrating",function(){e.removeClass("br-active"),p(),h()})},w=function(t){t.on("touchstart.barrating",function(t){t.preventDefault(),t.stopPropagation(),e(this).click()})},y=function(e){e.on("click.barrating",function(e){e.preventDefault()})},C=function(e){b(e),t.options.hoverState&&(m(e),$(e))},x=function(e){e.off(".barrating")},R=function(e){$elements=t.$widget.find("a"),w&&w($elements),e?(x($elements),y($elements)):C($elements)};this.show=function(){i()||(n(),s(),t.$widget=c(),t.$widget.insertAfter(t.$elem),h(),p(),R(t.options.readonly),t.$elem.hide())},this.readonly=function(e){"boolean"==typeof e&&i("readOnly")!=e&&(R(e),o("readOnly",e),t.$widget.toggleClass("br-readonly"))},this.set=function(e){var n=i("userOptions");t.$elem.find('option[value="'+e+'"]').val()&&(o("ratingValue",e),o("ratingText",t.$elem.find('option[value="'+e+'"]').text()),g(d()),p(u()),h(),n.silent||n.onSelect.call(this,d(),u()))},this.clear=function(){var e=i("userOptions");o("ratingValue",i("originalRatingValue")),o("ratingText",i("originalRatingText")),g(d()),p(u()),h(),e.onClear.call(this,d(),u())},this.destroy=function(){var e=d(),n=u(),a=i("userOptions");x(t.$widget.find("a")),t.$widget.remove(),l(),r(),t.$elem.show(),a.onDestroy.call(this,e,n)}}return t.prototype.init=function(t,n){return this.$elem=e(n),this.options=e.extend({},e.fn.barrating.defaults,t),this.options},t}();e.fn.barrating=function(n,r){return this.each(function(){var a=new t;if(e(this).is("select")||e.error("Sorry, this plugin only works with select fields."),a.hasOwnProperty(n)){if(a.init(r,this),"show"===n)return a.show(r);if(a.$elem.data("barrating"))return a.$widget=e(this).next(".br-widget"),a[n](r)}else{if("object"==typeof n||!n)return r=n,a.init(r,this),a.show();e.error("Method "+n+" does not exist on jQuery.barrating")}})},e.fn.barrating.defaults={theme:"",initialRating:null,showValues:!1,showSelectedRating:!0,reverse:!1,readonly:!1,fastClicks:!0,hoverState:!0,silent:!1,wrapperClass:"br-wrapper",onSelect:function(e,t,n){},onClear:function(e,t){},onDestroy:function(e,t){}},e.fn.barrating.BarRating=t});
//# sourceMappingURL=jquery.barrating.min.js.map

@@ -37,3 +37,4 @@ $(function() {

theme: 'bars-horizontal',
reverse: true
reverse: true,
hoverState: false
});

@@ -40,0 +41,0 @@

@@ -63,3 +63,3 @@ var gulp = require('gulp'),

gulp.task('themes', function() {
return gulp.src([themeLessFiles, '!themes/variables.less'])
return gulp.src([themeLessFiles, '!themes/variables.less', '!themes/mixins.less'])
.pipe(less())

@@ -66,0 +66,0 @@ .pipe(gulp.dest(themePath));

/**
* jQuery Bar Rating Plugin v1.1.2
* jQuery Bar Rating Plugin v1.1.3
*

@@ -61,2 +61,22 @@ * http://github.com/antennaio/jquery-bar-rating

// get data
var getData = function(key) {
var data = self.$elem.data('barrating');
if (typeof key !== 'undefined') {
return data[key];
}
return data;
};
// set data
var setData = function(key, value) {
if (value !== null && typeof value === 'object') {
self.$elem.data('barrating', value);
} else {
self.$elem.data('barrating')[key] = value;
}
};
// save data on element

@@ -66,19 +86,19 @@ var saveDataOnElement = function() {

self.$elem.data('barrating', {
setData(null, {
userOptions: self.options,
// initial rating based on the OPTION value
currentRatingValue: $opt.val(),
currentRatingText: ($opt.data('html')) ? $opt.data('html') : $opt.text(),
ratingValue: $opt.val(),
ratingText: ($opt.data('html')) ? $opt.data('html') : $opt.text(),
// rating will be restored by calling clear method
originalRatingValue: $opt.val(),
originalRatingText: ($opt.data('html')) ? $opt.data('html') : $opt.text()
originalRatingText: ($opt.data('html')) ? $opt.data('html') : $opt.text(),
// read-only state
readOnly: self.options.readonly,
// first OPTION empty - allow deselecting of ratings
deselectable: (!self.$elem.find('option:first').val()) ? true : false
});
// first OPTION empty - allow deselecting of ratings
self.$elem.data('barrating').deselectable =
(!self.$elem.find('option:first').val()) ? true : false;
};

@@ -91,2 +111,12 @@

// return current rating text
var ratingText = function() {
return getData('ratingText');
};
// return current rating value
var ratingValue = function() {
return getData('ratingValue');
};
// build widget and return jQuery element

@@ -98,3 +128,3 @@ var buildWidget = function() {

self.$elem.find('option').each(function() {
var val, text, html, $a, $span;
var val, text, html, $a;

@@ -109,6 +139,10 @@ val = $(this).val();

$a = $('<a />', { 'href': '#', 'data-rating-value': val, 'data-rating-text': text });
$span = $('<span />', { 'html': (self.options.showValues) ? text : '' });
$a = $('<a />', {
'href': '#',
'data-rating-value': val,
'data-rating-text': text,
'html': (self.options.showValues) ? text : ''
});
$w.append($a.append($span));
$w.append($a);
}

@@ -154,3 +188,3 @@

// text undefined?
text = text ? text : self.$elem.data('barrating').currentRatingText;
text = text ? text : ratingText();

@@ -164,8 +198,8 @@ // update .br-current-rating div

// apply style by setting classes on elements
var applyStyle = function($w) {
var applyStyle = function() {
// remove classes
$w.find('a').removeClass('br-selected br-current');
self.$widget.find('a').removeClass('br-selected br-current');
// add classes
$w.find('a[data-rating-value="' + self.$elem.data('barrating').currentRatingValue + '"]')
self.$widget.find('a[data-rating-value="' + ratingValue() + '"]')
.addClass('br-selected br-current')[nextAllorPreviousAll()]()

@@ -175,5 +209,10 @@ .addClass('br-selected');

// check if the element is deselectable?
var isDeselectable = function($element) {
return ($element.hasClass('br-current') && getData('deselectable'));
};
// handle click events
var attachClickHandler = function($all) {
$all.on('click', function(event) {
var attachClickHandler = function($elements) {
$elements.on('click.barrating', function(event) {
var $a = $(this),

@@ -185,3 +224,3 @@ value,

$all.removeClass('br-active br-selected');
$elements.removeClass('br-active br-selected');
$a.addClass('br-selected')[nextAllorPreviousAll()]()

@@ -194,3 +233,3 @@ .addClass('br-selected');

// is current and deselectable?
if ($a.hasClass('br-current') && self.$elem.data('barrating').deselectable) {
if (isDeselectable($a)) {
$a.removeClass('br-selected br-current')[nextAllorPreviousAll()]()

@@ -200,3 +239,3 @@ .removeClass('br-selected br-current');

} else {
$all.removeClass('br-current');
$elements.removeClass('br-current');
$a.addClass('br-current');

@@ -206,4 +245,4 @@ }

// remember selected rating
self.$elem.data('barrating').currentRatingValue = value;
self.$elem.data('barrating').currentRatingText = text;
setData('ratingValue', value);
setData('ratingText', text);

@@ -215,5 +254,6 @@ setSelectFieldValue(value);

self.options.onSelect.call(
this,
self.$elem.data('barrating').currentRatingValue,
self.$elem.data('barrating').currentRatingText
self,
ratingValue(),
ratingText(),
event
);

@@ -226,13 +266,11 @@

// handle mouseenter events
var attachMouseEnterHandler = function($all) {
$all.on({
mouseenter: function() {
var $a = $(this);
var attachMouseEnterHandler = function($elements) {
$elements.on('mouseenter.barrating', function() {
var $a = $(this);
$all.removeClass('br-active br-selected');
$a.addClass('br-active')[nextAllorPreviousAll()]()
.addClass('br-active');
$elements.removeClass('br-active br-selected');
$a.addClass('br-active')[nextAllorPreviousAll()]()
.addClass('br-active');
showSelectedRating($a.attr('data-rating-text'));
}
showSelectedRating($a.attr('data-rating-text'));
});

@@ -242,9 +280,7 @@ };

// handle mouseleave events
var attachMouseLeaveHandler = function($all, $widget) {
$widget.on({
mouseleave: function() {
$all.removeClass('br-active');
showSelectedRating();
applyStyle($widget);
}
var attachMouseLeaveHandler = function($elements) {
self.$widget.on('mouseleave.barrating', function() {
$elements.removeClass('br-active');
showSelectedRating();
applyStyle();
});

@@ -256,4 +292,4 @@ };

// and using a library such as fastclick (https://github.com/ftlabs/fastclick)
var fastClicks = function($all) {
$all.on('touchstart', function(event) {
var fastClicks = function($elements) {
$elements.on('touchstart.barrating', function(event) {
event.preventDefault();

@@ -267,4 +303,4 @@ event.stopPropagation();

// disable clicks
var disableClicks = function($all) {
$all.on('click', function(event) {
var disableClicks = function($elements) {
$elements.on('click.barrating', function(event) {
event.preventDefault();

@@ -274,44 +310,54 @@ });

this.show = function() {
var $widget, $all;
var attachHandlers = function($elements) {
// attach click event handler
attachClickHandler($elements);
// run only once
if (self.$elem.data('barrating')) return;
if (self.options.hoverState) {
// attach mouseenter event handler
attachMouseEnterHandler($elements);
// wrap element
wrapElement();
// attach mouseleave event handler
attachMouseLeaveHandler($elements);
}
};
// save data
saveDataOnElement();
var detachHandlers = function($elements) {
// remove event handlers in the ".barrating" namespace
$elements.off('.barrating');
};
// build & append widget to the DOM
$widget = buildWidget();
$widget.insertAfter(self.$elem);
applyStyle($widget);
var setupHandlers = function(readonly) {
$elements = self.$widget.find('a');
showSelectedRating();
if (fastClicks) {
fastClicks($elements);
}
$all = $widget.find('a');
if (self.options.fastClicks) {
fastClicks($all);
if (readonly) {
detachHandlers($elements);
disableClicks($elements);
} else {
attachHandlers($elements);
}
};
if (self.options.readonly) {
this.show = function() {
// run only once
if (getData()) return;
// do not react to click events if rating is read-only
disableClicks($all);
// wrap element
wrapElement();
} else {
// save data
saveDataOnElement();
// attach click event handler
attachClickHandler($all);
// build & append widget to the DOM
self.$widget = buildWidget();
self.$widget.insertAfter(self.$elem);
// attach mouseenter event handler
attachMouseEnterHandler($all);
applyStyle();
// attach mouseleave event handler
attachMouseLeaveHandler($all, $widget);
showSelectedRating();
}
setupHandlers(self.options.readonly);

@@ -322,37 +368,51 @@ // hide the select field

this.readonly = function(state) {
if (typeof state !== 'boolean' || getData('readOnly') == state) return;
setupHandlers(state);
setData('readOnly', state);
self.$widget.toggleClass('br-readonly');
};
this.set = function(value) {
if (!this.$elem.find('option[value="' + value + '"]').val()) return;
var options = getData('userOptions');
if (!self.$elem.find('option[value="' + value + '"]').val()) return;
// set data
this.$elem.data('barrating').currentRatingValue = value;
this.$elem.data('barrating').currentRatingText = this.$elem.find('option[value="' + value + '"]').text();
setData('ratingValue', value);
setData('ratingText', self.$elem.find('option[value="' + value + '"]').text());
setSelectFieldValue(this.$elem.data('barrating').currentRatingValue);
showSelectedRating(this.$elem.data('barrating').currentRatingText);
setSelectFieldValue(ratingValue());
showSelectedRating(ratingText());
applyStyle(this.$widget);
applyStyle();
// onSelect callback
this.$elem.data('barrating').userOptions.onSelect.call(
this,
this.$elem.data('barrating').currentRatingValue,
this.$elem.data('barrating').currentRatingText
);
if (!options.silent) {
options.onSelect.call(
this,
ratingValue(),
ratingText()
);
}
};
this.clear = function() {
var options = getData('userOptions');
// restore original data
this.$elem.data('barrating').currentRatingValue = this.$elem.data('barrating').originalRatingValue;
this.$elem.data('barrating').currentRatingText = this.$elem.data('barrating').originalRatingText;
setData('ratingValue', getData('originalRatingValue'));
setData('ratingText', getData('originalRatingText'));
setSelectFieldValue(this.$elem.data('barrating').currentRatingValue);
showSelectedRating(this.$elem.data('barrating').currentRatingText);
setSelectFieldValue(ratingValue());
showSelectedRating(ratingText());
applyStyle(this.$widget);
applyStyle();
// onClear callback
this.$elem.data('barrating').userOptions.onClear.call(
options.onClear.call(
this,
this.$elem.data('barrating').currentRatingValue,
this.$elem.data('barrating').currentRatingText
ratingValue(),
ratingText()
);

@@ -362,8 +422,12 @@ };

this.destroy = function() {
var value = this.$elem.data('barrating').currentRatingValue;
var text = this.$elem.data('barrating').currentRatingText;
var options = this.$elem.data('barrating').userOptions;
var value = ratingValue();
var text = ratingText();
var options = getData('userOptions');
this.$widget.off().remove();
// detach handlers
detachHandlers(self.$widget.find('a'));
// remove widget
self.$widget.remove();
// remove data

@@ -376,3 +440,3 @@ removeDataOnElement();

// show the element
this.$elem.show();
self.$elem.show();

@@ -440,4 +504,6 @@ // onDestroy callback

fastClicks:true, // remove 300ms click delay on touch devices?
hoverState:true, // change state on hover?
silent:false, // supress callbacks when controlling ratings programatically
wrapperClass:'br-wrapper', // class applied to wrapper div
onSelect:function (value, text) {
onSelect:function (value, text, event) {
}, // callback fired when a rating is selected

@@ -444,0 +510,0 @@ onClear:function (value, text) {

{
"name": "jquery-bar-rating",
"description": "Minimal, light-weight jQuery ratings.",
"version": "1.1.2",
"version": "1.1.3",
"main": "jquery.barrating.js",

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

@@ -73,4 +73,4 @@ var expect = window.chai.expect;

it('should read the selected rating from the select field', function () {
expect($('#rating').data('barrating').currentRatingValue).to.equal('5');
expect($('#rating').data('barrating').currentRatingText).to.equal('rating-text-5');
expect($('#rating').data('barrating').ratingValue).to.equal('5');
expect($('#rating').data('barrating').ratingText).to.equal('rating-text-5');
});

@@ -90,3 +90,3 @@

expect($('div.br-current-rating').html()).to.equal(
$('#rating').data('barrating').currentRatingText
$('#rating').data('barrating').ratingText
);

@@ -131,4 +131,4 @@ });

$('#rating').barrating('show', {
onSelect:function (value, text) {
valuesFromCallback.push(value, text);
onSelect:function (value, text, event) {
valuesFromCallback.push(value, text, event);
}

@@ -146,4 +146,4 @@ });

it('should update data', function () {
expect($('#rating').data('barrating').currentRatingValue).to.equal('2');
expect($('#rating').data('barrating').currentRatingText).to.equal('rating-text-2');
expect($('#rating').data('barrating').ratingValue).to.equal('2');
expect($('#rating').data('barrating').ratingText).to.equal('rating-text-2');
});

@@ -159,3 +159,3 @@

expect($('div.br-current-rating').html()).to.equal(
$('#rating').data('barrating').currentRatingText
$('#rating').data('barrating').ratingText
);

@@ -167,2 +167,3 @@ });

expect(valuesFromCallback[1]).to.equal('rating-text-2');
expect(valuesFromCallback[2]).to.be.a('object');
});

@@ -188,2 +189,6 @@

it('should set correct widget class', function () {
expect($('.br-widget').hasClass('br-reverse')).to.equal(true);
});
it('should set correct class', function () {

@@ -222,4 +227,4 @@ expect($('.br-widget a:nth-child(4)').hasClass('br-selected')).to.equal(false);

it('should ignore user input', function () {
expect($('#rating').data('barrating').currentRatingValue).to.equal('5');
expect($('#rating').data('barrating').currentRatingText).to.equal('rating-text-5');
expect($('#rating').data('barrating').ratingValue).to.equal('5');
expect($('#rating').data('barrating').ratingText).to.equal('rating-text-5');
});

@@ -253,4 +258,4 @@

it('should successfully deselect rating', function () {
expect($('#rating').data('barrating').currentRatingValue).to.equal('');
expect($('#rating').data('barrating').currentRatingText).to.equal('');
expect($('#rating').data('barrating').ratingValue).to.equal('');
expect($('#rating').data('barrating').ratingText).to.equal('');
});

@@ -283,4 +288,4 @@

it('should restore original rating', function () {
expect($('#rating').data('barrating').currentRatingValue).to.equal('5');
expect($('#rating').data('barrating').currentRatingText).to.equal('rating-text-5');
expect($('#rating').data('barrating').ratingValue).to.equal('5');
expect($('#rating').data('barrating').ratingText).to.equal('rating-text-5');
});

@@ -331,2 +336,6 @@

it('should remove the widget', function () {
expect($('.br-widget').length).to.equal(0);
});
it('should show the select field back again', function () {

@@ -364,4 +373,4 @@ expect($('#rating').is(":visible")).to.equal(true);

it('should set correct value', function () {
expect($('#rating').data('barrating').currentRatingValue).to.equal(3);
expect($('#rating').data('barrating').currentRatingText).to.equal('rating-text-3');
expect($('#rating').data('barrating').ratingValue).to.equal(3);
expect($('#rating').data('barrating').ratingText).to.equal('rating-text-3');
});

@@ -396,6 +405,37 @@

it('should do nothing', function () {
expect($('#rating').data('barrating').currentRatingValue).to.equal('5');
expect($('#rating').data('barrating').currentRatingText).to.equal('rating-text-5');
expect($('#rating').data('barrating').ratingValue).to.equal('5');
expect($('#rating').data('barrating').ratingText).to.equal('rating-text-5');
});
});
describe('bar rating plugin on change read-only state', function () {
before(function () {
createSelect();
$('#rating')
.barrating('show', { initialRating: 1 })
.barrating('readonly', true);
$('.br-widget a:last-child').trigger('click');
});
after(function () {
destroySelect();
});
it('should ignore user input', function () {
expect($('#rating').data('barrating').ratingValue).to.equal('1');
expect($('#rating').data('barrating').ratingText).to.equal('rating-text-1');
});
it('should update data', function () {
expect($('#rating').data('barrating').readOnly).to.equal(true);
});
it('should set correct widget class', function () {
expect($('.br-widget').hasClass('br-readonly')).to.equal(true);
});
});

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

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc