UNPKG

ngx-bootstrap-ci

Version:
2 lines 3.59 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/forms"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-bootstrap/rating",["exports","@angular/core","@angular/forms","@angular/common"],t):t((e["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].rating={}),e.ng.core,e.ng.forms,e.ng.common)}(this,function(e,t,n,o){"use strict";var r={provide:n.NG_VALUE_ACCESSOR,useExisting:t.forwardRef(function(){return i}),multi:!0},i=function(){function e(e){this.changeDetection=e,this.max=5,this.onHover=new t.EventEmitter,this.onLeave=new t.EventEmitter,this.onChange=Function.prototype,this.onTouched=Function.prototype}return e.prototype.onKeydown=function(e){if(-1!==[37,38,39,40].indexOf(e.which)){e.preventDefault(),e.stopPropagation();var t=38===e.which||39===e.which?1:-1;this.rate(this.value+t)}},e.prototype.ngOnInit=function(){this.max="undefined"!=typeof this.max?this.max:5,this.titles="undefined"!=typeof this.titles&&0<this.titles.length?this.titles:[],this.range=this.buildTemplateObjects(this.max)},e.prototype.writeValue=function(e){if(e%1!==e)return this.value=Math.round(e),this.preValue=e,void this.changeDetection.markForCheck();this.preValue=e,this.value=e,this.changeDetection.markForCheck()},e.prototype.enter=function(e){this.readonly||(this.value=e,this.changeDetection.markForCheck(),this.onHover.emit(e))},e.prototype.reset=function(){this.value=this.preValue,this.changeDetection.markForCheck(),this.onLeave.emit(this.value)},e.prototype.registerOnChange=function(e){this.onChange=e},e.prototype.registerOnTouched=function(e){this.onTouched=e},e.prototype.rate=function(e){!this.readonly&&0<=e&&e<=this.range.length&&(this.writeValue(e),this.onChange(e))},e.prototype.buildTemplateObjects=function(e){for(var t=[],n=0;n<e;n++)t.push({index:n,title:this.titles[n]||n+1});return t},e.decorators=[{type:t.Component,args:[{selector:"rating",template:'<span (mouseleave)="reset()" (keydown)="onKeydown($event)" tabindex="0"\n role="slider" aria-valuemin="0" [attr.aria-valuemax]="range.length"\n [attr.aria-valuenow]="value">\n <ng-template #star let-value="value" let-index="index">{{ index < value ? \'&#9733;\' : \'&#9734;\' }}</ng-template>\n <ng-template ngFor let-r [ngForOf]="range" let-index="index">\n <span class="sr-only">({{ index < value ? \'*\' : \' \' }})</span>\n <span class="bs-rating-star"\n (mouseenter)="enter(index + 1)"\n (click)="rate(index + 1)"\n [title]="r.title"\n [style.cursor]="readonly ? \'default\' : \'pointer\'"\n [class.active]="index < value">\n <ng-template [ngTemplateOutlet]="customTemplate || star"\n [ngTemplateOutletContext]="{index: index, value: value}">\n </ng-template>\n </span>\n </ng-template>\n</span>\n',providers:[r],changeDetection:t.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:t.ChangeDetectorRef}]},e.propDecorators={max:[{type:t.Input}],readonly:[{type:t.Input}],titles:[{type:t.Input}],customTemplate:[{type:t.Input}],onHover:[{type:t.Output}],onLeave:[{type:t.Output}],onKeydown:[{type:t.HostListener,args:["keydown",["$event"]]}]},e}(),a=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[]}},e.decorators=[{type:t.NgModule,args:[{imports:[o.CommonModule],declarations:[i],exports:[i]}]}],e}();e.RatingComponent=i,e.RatingModule=a,e.ɵa=r,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ngx-bootstrap-rating.umd.min.js.map