Comparing version 2.7.1 to 2.8.0
{ | ||
"authors" : ["Washington Botelho <wbotelhos@gmail.com> (http://wbotelhos.com)"], | ||
"description" : "jQuery Raty - A Star Rating Plugin", | ||
"authors": ["Washington Botelho <wbotelhos@gmail.com> (http://wbotelhos.com)"], | ||
"description": "jQuery Raty - A Star Rating Plugin", | ||
"dependencies" : { | ||
"jquery": "2" | ||
"dependencies": { | ||
"jquery": "^3.2.1" | ||
}, | ||
"homepage" : "https://github.com/wbotelhos/raty", | ||
"ignore" : ["**/.*", "node_modules", "spec", "vendor"], | ||
"keywords" : ["classificacao", "classificar", "javascript", "jquery", "library", "plugin", "rating", "raty", "star", "staring", "votar", "voto"], | ||
"license" : "MIT", | ||
"main" : "lib/jquery.raty.js", | ||
"name" : "raty", | ||
"version" : "2.7.1" | ||
"homepage": "https://github.com/wbotelhos/raty", | ||
"ignore": ["**/.*", "node_modules", "spec", "vendor"], | ||
"keywords": ["classificacao", "classificar", "javascript", "jquery", "library", "plugin", "rating", "raty", "star", "staring", "votar", "voto"], | ||
"license": "MIT", | ||
"main": "lib/jquery.raty.js", | ||
"name": "raty", | ||
"version": "2.8.0" | ||
} |
# jQuery Raty - A Star Rating Plugin - http://wbotelhos.com/raty | ||
## 2.8.0 | ||
### News | ||
+ Add support to configure options via `$.data()`; | ||
## 2.7.1 | ||
@@ -4,0 +10,0 @@ |
@@ -8,3 +8,3 @@ /*! | ||
* @doc : http://wbotelhos.com/raty | ||
* @version : 2.7.1 | ||
* @version : 2.8.0 | ||
* | ||
@@ -24,3 +24,3 @@ */ | ||
this.opt = $.extend(true, {}, $.fn.raty.defaults, options); | ||
this.opt = $.extend(true, {}, $.fn.raty.defaults, options, this.self.data()); | ||
@@ -240,4 +240,5 @@ methods._adjustCallback.call(this); | ||
_bindOver: function() { | ||
var that = this, | ||
action = that.opt.half ? 'mousemove.raty' : 'mouseover.raty'; | ||
var | ||
that = this, | ||
action = that.opt.half ? 'mousemove.raty' : 'mouseover.raty'; | ||
@@ -294,4 +295,5 @@ that.stars.on(action, function(evt) { | ||
_createCancel: function() { | ||
var icon = this.opt.path + this.opt.cancelOff, | ||
cancel = $('<' + this.opt.starType + ' />', { title: this.opt.cancelHint, 'class': this.opt.cancelClass }); | ||
var | ||
icon = this.opt.path + this.opt.cancelOff, | ||
cancel = $('<' + this.opt.starType + ' />', { title: this.opt.cancelHint, 'class': this.opt.cancelClass }); | ||
@@ -474,5 +476,6 @@ if (this.opt.starType === 'img') { | ||
_roundHalfScore: function(score) { | ||
var integer = parseInt(score, 10), | ||
decimal = methods._getFirstDecimal.call(this, score); | ||
_roundHalfScore: function(score) { | ||
var | ||
integer = parseInt(score, 10), | ||
decimal = methods._getFirstDecimal.call(this, score); | ||
@@ -489,7 +492,7 @@ if (decimal !== 0) { | ||
decimal = (score % 1).toFixed(2), | ||
name ; | ||
name ; | ||
if (evt || this.move) { | ||
name = decimal > 0.5 ? 'starOn' : 'starHalf'; | ||
} else if (decimal > this.opt.round.down) { // Up: [x.76 .. x.99] | ||
} else if (decimal > this.opt.round.down) { // Up: [x.76 .. x.99] | ||
name = 'starOn'; | ||
@@ -499,3 +502,3 @@ | ||
name = 'starHalf'; | ||
} else if (decimal < this.opt.round.full) { // Down: [x.00 .. x.5] | ||
} else if (decimal < this.opt.round.full) { // Down: [x.00 .. x.5] | ||
name = 'starOff'; | ||
@@ -511,3 +514,3 @@ } | ||
methods._setIcon.call(this, star, icon); | ||
} // Full down: [x.00 .. x.25] | ||
} // Full down: [x.00 .. x.25] | ||
}, | ||
@@ -624,4 +627,5 @@ | ||
return this.each(function() { | ||
var self = $(this), | ||
raw = self.data('raw'); | ||
var | ||
self = $(this), | ||
raw = self.data('raw'); | ||
@@ -637,4 +641,5 @@ if (raw) { | ||
getScore: function() { | ||
var score = [], | ||
value ; | ||
var | ||
score = [], | ||
value ; | ||
@@ -734,38 +739,37 @@ this.each(function() { | ||
$.fn.raty.defaults = { | ||
cancel : false, | ||
cancelClass : 'raty-cancel', | ||
cancelHint : 'Cancel this rating!', | ||
cancelOff : 'cancel-off.png', | ||
cancelOn : 'cancel-on.png', | ||
cancelPlace : 'left', | ||
click : undefined, | ||
half : false, | ||
halfShow : true, | ||
hints : ['bad', 'poor', 'regular', 'good', 'gorgeous'], | ||
iconRange : undefined, | ||
mouseout : undefined, | ||
mouseover : undefined, | ||
noRatedMsg : 'Not rated yet!', | ||
number : 5, | ||
numberMax : 20, | ||
path : undefined, | ||
precision : false, | ||
readOnly : false, | ||
round : { down: 0.25, full: 0.6, up: 0.76 }, | ||
score : undefined, | ||
scoreName : 'score', | ||
single : false, | ||
space : true, | ||
starHalf : 'star-half.png', | ||
starOff : 'star-off.png', | ||
starOn : 'star-on.png', | ||
starType : 'img', | ||
target : undefined, | ||
targetFormat : '{score}', | ||
targetKeep : false, | ||
targetScore : undefined, | ||
targetText : '', | ||
targetType : 'hint' | ||
cancel: false, | ||
cancelClass: 'raty-cancel', | ||
cancelHint: 'Cancel this rating!', | ||
cancelOff: 'cancel-off.png', | ||
cancelOn: 'cancel-on.png', | ||
cancelPlace: 'left', | ||
click: undefined, | ||
half: false, | ||
halfShow: true, | ||
hints: ['bad', 'poor', 'regular', 'good', 'gorgeous'], | ||
iconRange: undefined, | ||
mouseout: undefined, | ||
mouseover: undefined, | ||
noRatedMsg: 'Not rated yet!', | ||
number: 5, | ||
numberMax: 20, | ||
path: undefined, | ||
precision: false, | ||
readOnly: false, | ||
round: { down: 0.25, full: 0.6, up: 0.76 }, | ||
score: undefined, | ||
scoreName: 'score', | ||
single: false, | ||
space: true, | ||
starHalf: 'star-half.png', | ||
starOff: 'star-off.png', | ||
starOn: 'star-on.png', | ||
starType: 'img', | ||
target: undefined, | ||
targetFormat: '{score}', | ||
targetKeep: false, | ||
targetScore: undefined, | ||
targetText: '', | ||
targetType: 'hint' | ||
}; | ||
})(jQuery); |
{ | ||
"author": "Washington Botelho", | ||
"bugs": { | ||
"url": "https://github.com/wbotelhos/raty/issues" | ||
}, | ||
"contributors" : ["Washington Botelho <wbotelhos@gmail.com> (http://wbotelhos.com)"], | ||
"demos" : ["demo.html"], | ||
"dependencies" : { | ||
"jquery": "2" | ||
"contributors": [ | ||
"Washington Botelho <wbotelhos@gmail.com> (http://wbotelhos.com)" | ||
], | ||
"demos": [ | ||
"demo/index.html" | ||
], | ||
"dependencies": { | ||
"jquery": "^3.2.1" | ||
}, | ||
"description": "jQuery Raty - A Star Rating Plugin", | ||
"devDependencies": { | ||
"karma": "0.12", | ||
"karma-chrome-launcher": "0.1", | ||
"karma-firefox-launcher": "0.1", | ||
"karma-ie-launcher": "0.1", | ||
"karma-opera-launcher": "0.1", | ||
"karma-phantomjs-launcher": "0.1", | ||
"karma-safari-launcher": "0.1", | ||
"karma-jasmine": "0.2" | ||
"jasmine-core": "^2.8.0", | ||
"karma": "^1.7.1", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-firefox-launcher": "^1.0.1", | ||
"karma-ie-launcher": "^1.0.0", | ||
"karma-jasmine": "^1.1.0", | ||
"karma-opera-launcher": "^1.0.0", | ||
"karma-phantomjs-launcher": "^1.0.4", | ||
"karma-safari-launcher": "^1.0.0" | ||
}, | ||
"directories": { | ||
"lib" : "lib", | ||
"test" : "spec" | ||
"lib": "lib", | ||
"test": "spec" | ||
}, | ||
"engines" : { "node" : "0.10" }, | ||
"homepage" : "https://github.com/wbotelhos/raty", | ||
"keywords" : ["classificacao", "classificar", "javascript", "jquery", "library", "plugin", "rating", "raty", "star", "staring", "votar", "voto"], | ||
"license" : "MIT", | ||
"main" : "lib/jquery.raty.js", | ||
"maintainers" : ["Washington Botelho <wbotelhos@gmail.com> (http://wbotelhos.com)"], | ||
"name" : "raty-js", | ||
"engines": { | ||
"node": "^8", | ||
"npm": "^5" | ||
}, | ||
"homepage": "https://github.com/wbotelhos/raty", | ||
"keywords": [ | ||
"classificacao", | ||
"classificar", | ||
"javascript", | ||
"jquery", | ||
"library", | ||
"plugin", | ||
"rating", | ||
"raty", | ||
"star", | ||
"staring", | ||
"votar", | ||
"voto" | ||
], | ||
"license": "MIT", | ||
"main": "lib/jquery.raty.js", | ||
"maintainers": [ | ||
"Washington Botelho <wbotelhos@gmail.com> (http://wbotelhos.com)" | ||
], | ||
"name": "raty-js", | ||
"repository": { | ||
"type" : "git", | ||
"url" : "https://github.com/wbotelhos/raty" | ||
"type": "git", | ||
"url": "https://github.com/wbotelhos/raty" | ||
}, | ||
"scripts": { | ||
"test": "node_modules/karma/bin/karma start spec/karma.conf.js" | ||
}, | ||
"version": "2.7.1" | ||
"version": "2.8.0" | ||
} |
104
README.md
# jQuery Raty - A Star Rating Plugin | ||
[![Build Status](https://img.shields.io/travis/wbotelhos/raty/master.svg)](https://travis-ci.org/wbotelhos/raty "Travis CI") | ||
[![Dependency Status](https://david-dm.org/wbotelhos/raty.svg)](https://david-dm.org/wbotelhos/raty "Dependency Status") | ||
[![Dev Dependency Status](https://david-dm.org/wbotelhos/raty/dev-status.svg)](https://david-dm.org/wbotelhos/raty#info=devDependencies "Dev Dependency Status") | ||
[![Code Climate](https://codeclimate.com/github/wbotelhos/raty.png)](https://codeclimate.com/github/wbotelhos/raty "Code Climate") | ||
[![Support jQuery Raty](http://img.shields.io/gittip/wbotelhos.svg)](https://www.gittip.com/wbotelhos "Git Tip") | ||
[![NPM Version](https://badge.fury.io/js/raty-js.svg)](https://badge.fury.io/js/raty-js) | ||
[![Dependency](https://david-dm.org/wbotelhos/raty.svg)](https://david-dm.org/wbotelhos/raty "Dependency Status") | ||
[![Dev Dependency](https://david-dm.org/wbotelhos/raty/dev-status.svg)](https://david-dm.org/wbotelhos/raty#info=devDependencies "Dev Dependency Status") | ||
[![Code Climate](https://codeclimate.com/github/wbotelhos/raty.png)](https://codeclimate.com/github/wbotelhos/raty) | ||
[![Support jQuery Raty](http://img.shields.io/gittip/wbotelhos.svg)](https://gratipay.com/~wbotelhos) | ||
## Version | ||
``` | ||
@version 2.7.1 | ||
@since 2010.06.11 | ||
@author Washington Botelho | ||
@doc wbotelhos.com/raty | ||
``` | ||
## Dependencies | ||
+ jquery.js | ||
## Usage with Image | ||
@@ -55,47 +43,39 @@ | ||
## Bower Install | ||
```js | ||
bower install raty | ||
``` | ||
See [bower.io](http://bower.io) for more information. | ||
## Options | ||
```js | ||
cancel : false // Creates a cancel button to cancel the rating. | ||
cancelClass : 'raty-cancel' // Name of cancel's class. | ||
cancelHint : 'Cancel this rating!' // The cancel's button hint. | ||
cancelOff : 'cancel-off.png' // Icon used on active cancel. | ||
cancelOn : 'cancel-on.png' // Icon used inactive cancel. | ||
cancelPlace : 'left' // Cancel's button position. | ||
click : undefined // Callback executed on rating click. | ||
half : false // Enables half star selection. | ||
halfShow : true // Enables half star display. | ||
hints : ['bad', 'poor', 'regular', 'good', 'gorgeous'] // Hints used on each star. | ||
iconRange : undefined // Object list with position and icon on and off to do a mixed icons. | ||
mouseout : undefined // Callback executed on mouseout. | ||
mouseover : undefined // Callback executed on mouseover. | ||
noRatedMsg : 'Not rated yet!' // Hint for no rated elements when it's readOnly. | ||
number : 5 // Number of stars that will be presented. | ||
numberMax : 20 // Max of star the option number can creates. | ||
path : undefined // A global locate where the icon will be looked. | ||
precision : false // Enables the selection of a precision score. | ||
readOnly : false // Turns the rating read-only. | ||
round : { down: .25, full: .6, up: .76 } // Included values attributes to do the score round math. | ||
score : undefined // Initial rating. | ||
scoreName : 'score' // Name of the hidden field that holds the score value. | ||
single : false // Enables just a single star selection. | ||
space : true // Puts space between the icons. | ||
starHalf : 'star-half.png' // The name of the half star image. | ||
starOff : 'star-off.png' // Name of the star image off. | ||
starOn : 'star-on.png' // Name of the star image on. | ||
target : undefined // Element selector where the score will be displayed. | ||
targetFormat: '{score}' // Template to interpolate the score in. | ||
targetKeep : false // If the last rating value will be keeped after mouseout. | ||
targetScore : undefined // Element selector where the score will be filled, instead of creating a new hidden field (scoreName option). | ||
targetText : '' // Default text setted on target. | ||
targetType : 'hint' // Option to choose if target will receive hint o 'score' type. | ||
starType : 'img' // Element used to represent a star. | ||
cancel: false // Creates a cancel button to cancel the rating. | ||
cancelClass: 'raty-cancel' // Name of cancel's class. | ||
cancelHint: 'Cancel this rating!' // The cancel's button hint. | ||
cancelOff: 'cancel-off.png' // Icon used on active cancel. | ||
cancelOn: 'cancel-on.png' // Icon used inactive cancel. | ||
cancelPlace: 'left' // Cancel's button position. | ||
click: undefined // Callback executed on rating click. | ||
half: false // Enables half star selection. | ||
halfShow: true // Enables half star display. | ||
hints: ['bad', 'poor', 'regular', 'good', 'gorgeous'] // Hints used on each star. | ||
iconRange: undefined // Object list with position and icon on and off to do a mixed icons. | ||
mouseout: undefined // Callback executed on mouseout. | ||
mouseover: undefined // Callback executed on mouseover. | ||
noRatedMsg: 'Not rated yet!' // Hint for no rated elements when it's readOnly. | ||
number: 5 // Number of stars that will be presented. | ||
numberMax: 20 // Max of star the option number can creates. | ||
path: undefined // A global locate where the icon will be looked. | ||
precision: false // Enables the selection of a precision score. | ||
readOnly: false // Turns the rating read-only. | ||
round: { down: .25, full: .6, up: .76 } // Included values attributes to do the score round math. | ||
score: undefined // Initial rating. | ||
scoreName: 'score' // Name of the hidden field that holds the score value. | ||
single: false // Enables just a single star selection. | ||
space: true // Puts space between the icons. | ||
starHalf: 'star-half.png' // The name of the half star image. | ||
starOff: 'star-off.png' // Name of the star image off. | ||
starOn: 'star-on.png' // Name of the star image on. | ||
target: undefined // Element selector where the score will be displayed. | ||
targetForma: '{score}' // Template to interpolate the score in. | ||
targetKeep: false // If the last rating value will be keeped after mouseout. | ||
targetScore: undefined // Element selector where the score will be filled, instead of creating a new hidden field (scoreName option). | ||
targetText: '' // Default text setted on target. | ||
targetType: 'hint' // Option to choose if target will receive hint o 'score' type. | ||
starType: 'img' // Element used to represent a star. | ||
``` | ||
@@ -129,8 +109,4 @@ | ||
## Licence | ||
[The MIT License](http://opensource.org/licenses/MIT) | ||
## Love it! | ||
Via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X8HEP2878NDEG&item_name=jQuery%20Raty) or [Gittip](http://www.gittip.com/wbotelhos). Thanks! (: | ||
Via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X8HEP2878NDEG&item_name=raty) or [Gratipay](https://gratipay.com/raty). Thanks! (: |
@@ -27,2 +27,13 @@ describe('#cancel', function() { | ||
it ('accepts data attribute', function() { | ||
// given | ||
this.el = Helper._append('div', { 'data-cancel': true }); | ||
// when | ||
this.el.raty(); | ||
// then | ||
expect(this.el[0].opt.cancel).toEqual(true); | ||
}); | ||
context('on mouseover', function() { | ||
@@ -29,0 +40,0 @@ it ('turns on', function() { |
@@ -12,2 +12,13 @@ describe('#half', function() { | ||
it ('accepts data attribute', function() { | ||
// given | ||
var el = Helper._append('div', { 'data-cancel-class': true }); | ||
// when | ||
el.raty(); | ||
// then | ||
expect(el[0].opt.cancelClass).toEqual(true); | ||
}); | ||
context('as *false', function() { | ||
@@ -14,0 +25,0 @@ context('and :halfShow', function() { |
@@ -41,2 +41,13 @@ describe('#number', function() { | ||
}); | ||
it ('accepts data attribute', function() { | ||
// given | ||
var el = Helper._append('div', { 'data-number': 3 }); | ||
// when | ||
el.raty(); | ||
// then | ||
expect(el[0].opt.number).toEqual(3); | ||
}); | ||
}); |
@@ -22,2 +22,13 @@ describe('#path', function() { | ||
it ('accepts data attribute', function() { | ||
// given | ||
var el = Helper._append('div', { 'data-path': 'custom' }); | ||
// when | ||
el.raty(); | ||
// then | ||
expect(el[0].opt.path).toEqual('custom/'); | ||
}); | ||
context('without slash on the final', function() { | ||
@@ -24,0 +35,0 @@ it ('receives the slash', function() { |
@@ -23,2 +23,13 @@ describe('#precision', function() { | ||
it ('accepts data attribute', function() { | ||
// given | ||
var el = Helper._append('div', { 'data-precision': true }); | ||
// when | ||
el.raty(); | ||
// then | ||
expect(el[0].opt.precision).toEqual(true); | ||
}); | ||
context('with :target', function() { | ||
@@ -25,0 +36,0 @@ context('and :targetKeep', function() { |
@@ -12,2 +12,13 @@ describe('#readOnly', function() { | ||
it ('accepts data attribute', function() { | ||
// given | ||
var el = Helper._append('div', { 'data-readonly': true }); | ||
// when | ||
el.raty(); | ||
// then | ||
expect(el[0].opt.readonly).toEqual(true); | ||
}); | ||
context('on true', function() { | ||
@@ -14,0 +25,0 @@ it ('sets score as readonly', function() { |
@@ -42,2 +42,13 @@ describe('#score', function() { | ||
it ('accepts data attribute', function() { | ||
// given | ||
var el = Helper._append('div', { 'data-score': 3 }); | ||
// when | ||
el.raty(); | ||
// then | ||
expect(el[0].opt.score).toEqual(3); | ||
}); | ||
context('with negative number', function() { | ||
@@ -44,0 +55,0 @@ it ('does not set the score', function() { |
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 too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
667791
84
10888
9
111
+ Addedjquery@3.7.1(transitive)
- Removedjquery@2.2.4(transitive)
Updatedjquery@^3.2.1