This repository has been archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rating): add support for custom icons per instance
- Loading branch information
1 parent
e55d906
commit 20ab01a
Showing
6 changed files
with
135 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
<div ng-controller="RatingDemoCtrl"> | ||
<div ng-controller="RatingDemoCtrl" class="well well-small"> | ||
<h4>Default</h4> | ||
<rating value="rate" max="max" readonly="isReadonly" on-hover="hoveringOver(value)" on-leave="overStar = null"></rating> | ||
<span class="badge" ng-class="{'badge-warning': percent<30, 'badge-info': percent>=30 && percent<70, 'badge-success': percent>=70}" ng-show="overStar && !isReadonly">{{percent}}%</span> | ||
|
||
<hr/> | ||
<pre>Rate: <b>{{rate}}</b> - Readonly is: <i>{{isReadonly}}</i> - Hovering over: <b>{{overStar || "none"}}</b></pre> | ||
<pre style="margin:15px 0;">Rate: <b>{{rate}}</b> - Readonly is: <i>{{isReadonly}}</i> - Hovering over: <b>{{overStar || "none"}}</b></pre> | ||
|
||
<hr/> | ||
<button class="btn btn-small btn-danger" ng-click="rate = 0" ng-disabled="isReadonly">Clear</button> | ||
<button class="btn btn-small" ng-click="isReadonly = ! isReadonly">Toggle Readonly</button> | ||
<hr /> | ||
|
||
<h4>Custom icons</h4> | ||
<div ng-init="x = 5"><rating value="x" max="15" state-on="'icon-ok-sign'" state-off="'icon-ok-circle'"></rating> <b>(<i>Rate:</i> {{x}})</b></div> | ||
<div ng-init="y = 2"><rating value="y" rating-states="ratingStates"></rating> <b>(<i>Rate:</i> {{y}})</b></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,37 @@ | ||
Rating directive that will take care of visualising a star rating bar. | ||
|
||
It also provides optional attributes: `max` to vary the number of stars, `readonly` to disable user's interaction, `on-hover` to signal when the user's mouse is over a particular star, and `on-leave` to signal when the mouse leaves the control altogether. | ||
### Settings ### | ||
|
||
#### `<rating>` #### | ||
|
||
* `value` <i class="icon-eye-open"></i> | ||
: | ||
The current rate. | ||
|
||
* `max` | ||
_(Defaults: 5)_ : | ||
Changes the number of icons. | ||
|
||
* `readonly` | ||
_(Defaults: false)_ : | ||
Prevent user's interaction. | ||
|
||
* `on-hover(value)` | ||
: | ||
An optional expression called when user's mouse is over a particular icon. | ||
|
||
* `on-leave()` | ||
: | ||
An optional expression called when user's mouse leaves the control altogether. | ||
|
||
* `state-on` | ||
_(Defaults: 'icon-star')_ : | ||
A variable used in default template to specify the class for selected icons. | ||
|
||
* `state-off` | ||
_(Defaults: 'icon-star-empty')_ : | ||
A variable used in default template to specify the class for unselected icons. | ||
|
||
* `rating-states` | ||
_(Defaults: null)_ : | ||
An array of objects defining properties for all icons. In default template, `stateOn` & `stateOff` property is used to specify the icon's class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<span ng-mouseleave="reset()"> | ||
<i ng-repeat="number in range" ng-mouseenter="enter(number)" ng-click="rate(number)" ng-class="{'icon-star': number <= val, 'icon-star-empty': number > val}"></i> | ||
<i ng-repeat="r in range" ng-mouseenter="enter($index + 1)" ng-click="rate($index + 1)" ng-class="$index < val && r.stateOn || r.stateOff"></i> | ||
</span> |