Skip to content

Commit

Permalink
Merge pull request #227 from wbotelhos/prototype-convert
Browse files Browse the repository at this point in the history
Converts plugin style to Prototype
  • Loading branch information
wbotelhos authored Oct 31, 2020
2 parents a829c5b + f365da4 commit 0864d0e
Show file tree
Hide file tree
Showing 88 changed files with 6,508 additions and 5,722 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/demo
/spec/vendor
36 changes: 36 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"env": {
"browser": true,
"es2021": true
},

"extends": "eslint:recommended",

"globals": {
"$": false,
"afterEach": false,
"beforeEach": false,
"context": true,
"define": false,
"describe": false,
"expect": false,
"Helper": true,
"it": false,
"module": false,
"require": false,
"spyOn": false,
"xit": false
},

"parserOptions": {
"ecmaVersion": 12
},

"rules": {
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"one-var": ["error", "never"],
"quotes": ["error", "single"],
"semi": ["error", "always"]
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.DS_Store
/.idea
/bower_components
/node_modules
.idea/
4 changes: 4 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eslint:
config_file: .eslintrc.json
enabled: true
ignore_file: .eslintignore
91 changes: 44 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,50 @@ $('div').raty({ starType: 'i' });

## Options

| Property | Default |Description |
|--------------|------------------------------------------------|------------------------------------------------------------------|
|`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` |Score field target avoiding hidden field creation |
|`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. |
| Property | Default |Description |
|--------------|------------------------------------------------|-----------------------------------------------------------------|
|`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 non rated elements when it's readOnly. |
|`number` |`5` |The number of stars that will be presented. |
|`numberMax` |`20` |Max number of stars star the option number will create. |
|`path` |`undefined` |A global path where the icon will be found. |
|`precision` |`false` |Enables the selection of a precise score. |
|`readOnly` |`false` |Turns the rating read-only. |
|`round` |`{ down: .25, full: .6, up: .76 }` |Includes value attributes to do the score rounding math. |
|`score` |`undefined` |Initial rating. |
|`scoreName` |`'score'` |Name of the hidden field that holds the score value. |
|`single` |`false` |Enables 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 kept on mouseout. |
|`targetScore` |`undefined` |Score field target avoiding hidden field creation |
|`targetText` |`''` |Default text in a target. |
|`targetType` |`'hint'` |Choose if target will receive a hint or the score number |
|`starType` |`'img'` |Element used to represent a star. |

## Functions

| Function | Description |
|------------------------------------------|------------------------------------------------------------|
|`$('div').raty('score');` |Get the current score. |
|`$('div').raty('score', number);` |Set the score. |
|`$('div').raty('click', number);` |Click on some star. |
|`$('div').raty('readOnly', boolean);` |Change the read-only state. |
|`$('div').raty('cancel', boolean);` |Cancel the rating. The last param force the click callback. |
|`$('div').raty('reload');` |Reload the rating with the current configuration. |
|`$('div').raty('set', { option: value} );`|Reset the rating with new configurations. |
|`$('div').raty('destroy');` |Destroy the bind and give you the raw element. |
|`$('div').raty('move', number);` |Move the mouse to the given score point position. |
| Function | Description |
|-----------------------------------------|-----------------------------------------------------------|
|`$('div').data('raty).score();` |Get the current score. |
|`$('div').data('raty).score(number);` |Set a score. |
|`$('div').data('raty).click(number);` |Click on a star. |
|`$('div').data('raty).readOnly(boolean);`|Change the read-only state. |
|`$('div').data('raty).cancel(boolean);` |Cancel the rating. The last param force the click callback.|
|`$('div').data('raty).move(number);` |Move the mouse to the given score point position. |
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"authors": [
"Washington Botelho <[email protected]> (http://wbotelhos.com)"
"Washington Botelho <[email protected]> (https://www.wbotelhos.com)"
],
"description": "Raty - A Star Rating Plugin",
"dependencies": {
"jquery": "^3.3.1"
"jquery": "^3.5.1"
},
"homepage": "https://github.com/wbotelhos/raty",
"ignore": [
Expand Down
36 changes: 22 additions & 14 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
## Unreleased
## 3.0.0

### Changes
### Break Change

### News
- Function `destroy` was removed;
- Function `reload` was removed;
- Function `set` was removed;
- Functions now is accessed via `element.data('raty').FUNCTION_NAME()`;
- Option `cancel` was renamed to `cancelButton`;

### Fixes
### Bugfix

- Grammars fixes; [#217](https://github.com/wbotelhos/raty/pull/217) by [tfantina](https://github.com/tfantina)
- When using `single` options the click was not turning the star on; [#155](https://github.com/wbotelhos/raty/pull/155) by [henrikhannemose](https://github.com/henrikhannemose)

### Update

- Grammars fixes; [#217](https://github.com/wbotelhos/raty/pull/217) by [tfantina](https://github.com/tfantina)
- All the code were migrated to pure Prototype. Vanilla JS coming soon!;

## 2.9.0

### Changes
### Update

+ Drops `engines` from `package.json` for a greater flexibility;

Expand All @@ -23,7 +31,7 @@

## 2.7.1

### Fixes
### Bugfix

+ Fix `readOnly` when using fonts; (Amaia Baigorri)

Expand All @@ -34,14 +42,14 @@

## 2.7.0

### Fixes
### Bugfix

+ Function `move` was losing precision with float with more then one digit;
+ Function `move` was losing the saved `options` data;
+ With `half` enable, mousemove was not changing to full star after 0.5 point;
+ With `half` enable, score field was receiving precision value. (reported by hoangnham01)

### Changes
### Update

+ If you returns `false` into `click` callback, the action will be prevented;
+ When `precision` is on it won't force `targetType` to be `score` anymore.
Expand All @@ -52,14 +60,14 @@

## 2.6.0

### Fixes
### Bugfix

+ Target was not showing the score when `half` was enabled; (andersonba)
+ Fixed some JS Lint warnings; (Qazzian)
+ Cancel button `mouseleave` must yiels no score as `undefined` not `null`;
+ The `numberMax` now sets the stars between 1...`numberMax` instead 0...`numberMax`.

### Changes
### Update

+ `path` now is `undefined` by default;
+ The {score} placeholder on `targetFormat` option is no longer mandatory;
Expand All @@ -78,7 +86,7 @@

## 2.5.2

### Fixes
### Bugfix

The read-only indicator was not removing after the reset of configuration, blocking the `click` and `score` functions.

Expand All @@ -92,7 +100,7 @@ The read-only indicator was not removing after the reset of configuration, block
+ The `readOnly` and `scoreName` option can be setted via callback; (aprimadi)
+ You can avoid the width style setting the option `width` to false.

### Changes
### Update

+ Extracted the limit of stars to the option `numberMax`;
+ The `hints` options can receives three values:
Expand All @@ -106,7 +114,7 @@ The read-only indicator was not removing after the reset of configuration, block
+ When `precision` is enabled, `half` becomes enabled and `targetType` is changed to 'score';
+ When `readOnly` is true, the cursor style will be removed instead to use the default.

### Fixes
### Bugfix

+ The `click` function was not yielding the event.
+ The `path` always was prepend avoiding absolute or different path for each icon;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"authors": [
{
"homepage": "http://wbotelhos.com",
"homepage": "https://www.wbotelhos.com",
"name": "Washington Botelho"
}
],
Expand Down
Binary file added demo/fonts/blogy.eot
Binary file not shown.
Loading

0 comments on commit 0864d0e

Please sign in to comment.