ng-star-rate
Version:
A simple star rating library
2 lines • 2.54 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/platform-browser"),require("@angular/common")):"function"==typeof define&&define.amd?define("ng-star-rate",["exports","@angular/core","@angular/platform-browser","@angular/common"],e):e(t["ng-star-rate"]={},t.ng.core,t.ng.platformBrowser,t.ng.common)}(this,function(t,e,n,r){"use strict";var a=function(){function t(t){this.el=t,this.ratingSelection=new e.EventEmitter}return t.prototype.ngOnInit=function(){var t="\n .active {color :"+this.selctedColor+"; }\n .list:hover .star {color: "+this.selctedColor+"; }\n ";this.createStyle(t),this.generateRating()},t.prototype.createStyle=function(t){var e=document.createElement("style");e.appendChild(document.createTextNode(t)),this.el.nativeElement.appendChild(e)},t.prototype.generateRating=function(){this.stars=Array.from({length:this.maxRating},function(t,e){return e+1})},t.prototype.rate=function(t){this.star=t<=this.maxRating&&0<=t?this.star=this.star===t?t-1:t:this.star,this.ratingSelection.emit(this.star)},t.decorators=[{type:e.Component,args:[{selector:"lib-star-rate",template:'\n <div class="rating">\n <ul class="list">\n <li\n id="starId"\n class="star"\n *ngFor="let item of stars"\n [ngClass]="{\'active\': item <= star}"\n (click)="rate(item)">\n <i class="fa" [ngClass]="item <= star ? \'fa-star\' : \'fa-star-o\'" aria-hidden="true"></i>\n </li>\n </ul>\n <span *ngIf="showRatingCounter">{{ star }} of {{ maxRating }}</span>\n </div>\n ',styles:['\n .rating {\n font-family: "Avenir", Helvetica, Arial, sans-serif;\n font-size: 22px;\n color: #a7a8a8;\n }\n .list {\n margin: 0 0 5px 0;\n padding: 0;\n list-style-type: none;\n }\n .star {\n display: inline-block;\n cursor: pointer;\n }\n .star:hover ~ .star:not(.active) {\n color: inherit;\n }\n ']}]}],t.ctorParameters=function(){return[{type:e.ElementRef}]},t.propDecorators={selctedColor:[{type:e.Input}],star:[{type:e.Input}],maxRating:[{type:e.Input}],showRatingCounter:[{type:e.Input}],ratingSelection:[{type:e.Output}]},t}(),o=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[a],imports:[n.BrowserModule,r.CommonModule],exports:[a]}]}],t}();t.StarRateModule=o,t.RatingComponent=a,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ng-star-rate.umd.min.js.map