@duoduo-oba/ng-devui
Version:
DevUI components based on Angular
2 lines • 5.36 kB
JavaScript
!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("ng-devui/rate",["exports","@angular/core","@angular/forms","@angular/common"],t):t(((e=e||self)["ng-devui"]=e["ng-devui"]||{},e["ng-devui"].rate={}),e.ng.core,e.ng.forms,e.ng.common)}(this,(function(e,t,o,r){"use strict";var n=function(){function e(){this.read=!1,this.count=5,this.color="",this.icon="",this.character="",this.totalLevel_array=[],this.width="",this.onChange=function(){return null},this.onTouched=function(){return null}}return e.prototype.ngOnInit=function(){for(var e=0;e<this.count;e++)this.totalLevel_array.push({width:"0"})},e.prototype.setStaticRating=function(){var e=this.chooseValue%1,t=Math.floor(this.chooseValue);this.setChange(0,t+1,"100%"),e>0?(this.totalLevel_array[t+1].width=100*e+"%",this.setChange(t+2,this.count,"0")):this.setChange(t+1,this.count,"0")},e.prototype.setDynamicRating=function(){this.setChange(0,this.chooseValue+1,"100%"),this.setChange(this.chooseValue+1,this.count,"0")},e.prototype.hoverToggle=function(e,t,o){void 0===o&&(o=!1),this.read||(o?this.chooseValue>=0?(this.setChange(0,this.chooseValue+1,"100%"),this.setChange(this.chooseValue+1,this.count,"0")):this.setChange(0,this.count,"0"):(this.setChange(0,t+1,"100%"),this.setChange(t+1,this.count,"0")))},e.prototype.setChange=function(e,t,o){for(var r=e;r<t;r++)this.totalLevel_array[r].width=o},e.prototype.selectValue=function(e){this.read||(this.setChange(0,e+1,"100%"),this.setChange(e+1,this.count,"0"),this.chooseValue=e,this.onChange(e+1),this.onTouched())},e.prototype.registerOnChange=function(e){this.onChange=e},e.prototype.registerOnTouched=function(e){this.onTouched=e},e.prototype.writeValue=function(e){this.chooseValue=e-1,this.read?this.setStaticRating():this.setDynamicRating()},e.decorators=[{type:t.Component,args:[{selector:"d-rate",template:'<div class="devui-star-container" (mouseleave)="hoverToggle($event, chooseValue, true)">\r\n <div\r\n *ngFor="let item of totalLevel_array; let i = index"\r\n class="devui-star-align devui-pointer"\r\n [ngClass]="{ \'devui-only-read\': read }"\r\n (mouseover)="hoverToggle($event, i)"\r\n (click)="selectValue(i)"\r\n >\r\n <span class="devui-star-color {{ icon }}">\r\n {{ character }}\r\n <svg\r\n *ngIf="!icon && !character"\r\n width="16px"\r\n height="16px"\r\n viewBox="0 0 16 16"\r\n version="1.1"\r\n xmlns="http://www.w3.org/2000/svg"\r\n xmlns:xlink="http://www.w3.org/1999/xlink"\r\n >\r\n <g id="收藏星标" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\r\n <g fill="#E3E5E9" id="Mask">\r\n <polygon\r\n points="8 12.7603585 3.67376208 14.3147912 3.81523437 9.71994835 1 6.0857977 5.41367261 4.80046131 8 1 10.5863274 4.80046131 15 6.0857977 12.1847656 9.71994835 12.3262379 14.3147912"\r\n ></polygon>\r\n </g>\r\n </g>\r\n </svg>\r\n </span>\r\n <span\r\n class="devui-star-color-active devui-active-star devui-star-color-{{ type }} {{ icon }}"\r\n [style.color]="color"\r\n [style.width]="item.width"\r\n >\r\n {{ character }}\r\n <svg\r\n *ngIf="!icon && !character"\r\n width="16px"\r\n height="16px"\r\n viewBox="0 0 16 16"\r\n version="1.1"\r\n xmlns="http://www.w3.org/2000/svg"\r\n xmlns:xlink="http://www.w3.org/1999/xlink"\r\n >\r\n <g id="收藏星标" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\r\n <g [style.fill]="color" id="Mask">\r\n <polygon\r\n points="8 12.7603585 3.67376208 14.3147912 3.81523437 9.71994835 1 6.0857977 5.41367261 4.80046131 8 1 10.5863274 4.80046131 15 6.0857977 12.1847656 9.71994835 12.3262379 14.3147912"\r\n ></polygon>\r\n </g>\r\n </g>\r\n </svg>\r\n </span>\r\n </div>\r\n <div style="clear:both;"></div>\r\n</div>\r\n',providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:t.forwardRef((function(){return e})),multi:!0}],styles:[".devui-star-align{float:left;font-size:16px;margin-right:5px;position:relative}.devui-pointer{cursor:pointer}.devui-star-container{display:inline-block}.devui-star-color-active{color:#6a81ed}.devui-star-color-active svg g{fill:#6a81ed}.devui-star-color-success{color:#3dcca6}.devui-star-color-success svg g{fill:#3dcca6}.devui-star-color-warning{color:#fac20a}.devui-star-color-warning svg g{fill:#fac20a}.devui-star-color-error{color:#f66f6a}.devui-star-color-error svg g{fill:#f66f6a}.devui-active-star{position:absolute;top:0;left:0;overflow:hidden}.devui-star-color{color:#dfe1e6}.devui-star-color svg g{fill:#dfe1e6}.devui-only-read{cursor:not-allowed}"]}]}],e.propDecorators={read:[{type:t.Input}],count:[{type:t.Input}],color:[{type:t.Input}],icon:[{type:t.Input}],character:[{type:t.Input}],type:[{type:t.Input}]},e}();var i=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[r.CommonModule,o.FormsModule],exports:[n],declarations:[n],providers:[]}]}],e}();e.RateComponent=n,e.RateModule=i,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-devui-rate.umd.min.js.map