{"version":3,"sources":["../../src/app/components/slider/slider.ts"],"names":["SLIDER_VALUE_ACCESSOR","provide","NG_VALUE_ACCESSOR","useExisting","forwardRef","Slider","multi","el","renderer","ngZone","cd","this","min","max","orientation","tabindex","onChange","EventEmitter","onSlideEnd","handleValues","onModelChange","onModelTouched","handleIndex","prototype","onMouseDown","event","index","disabled","dragging","updateDomData","sliderHandleClick","range","bindDragListeners","target","focus","preventDefault","animate","DomHandler","removeClass","nativeElement","children","onTouchStart","touchobj","changedTouches","startHandleValue","handleValue","startx","parseInt","clientX","barWidth","offsetWidth","starty","clientY","barHeight","offsetHeight","onTouchMove","Math","floor","setValueFromHandle","onTouchEnd","emit","originalEvent","values","value","addClass","onBarClick","handleChange","onHandleKeydown","which","spin","dir","step","updateValue","updateHandleValue","calculateHandleValue","_this","runOutsideAngular","documentTarget","ownerDocument","dragListener","listen","run","mouseupListener","unbindDragListeners","newValue","getValueFromHandle","handleStepChange","markForCheck","oldValue","diff","val","ceil","writeValue","registerOnChange","fn","registerOnTouched","setDisabledState","Object","defineProperty","isVertical","rect","getBoundingClientRect","initX","left","getWindowScrollLeft","initY","top","getWindowScrollTop","pageX","pageY","sliderHandleStart","sliderHandleEnd","getNormalizedValue","slice","sliderHandle","getDecimalsCount","toString","split","length","decimalsCount","toFixed","ngOnDestroy","Component","args","selector","template","providers","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","Renderer2","NgZone","ChangeDetectorRef","Input","Output","ViewChild","NgModule","imports","CommonModule","exports","declarations"],"mappings":"kgBAKaA,EAA6B,CACxCC,QAASC,EAAAA,kBACTC,YAAaC,EAAAA,YAAW,WAAM,OAAAC,KAC9BC,OAAO,gBAmGL,SAAAD,EAAmBE,EAAuBC,EAA6BC,EAAuBC,GAA3EC,KAAAJ,GAAAA,EAAuBI,KAAAH,SAAAA,EAA6BG,KAAAF,OAAAA,EAAuBE,KAAAD,GAAAA,EAhErFC,KAAAC,IAAc,EAEdD,KAAAE,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QiC,EAAc,KAAOlC,KAAKC,KAGjEP,EAAAkB,UAAA4F,iBAAA,SAAiBpD,GAChB,OAAIA,GAASP,KAAKC,MAAMM,KAAWA,GAC3BA,EAAMqD,WAAWC,MAAM,KAAK,GAAGC,QAChC,GAGRjH,EAAAkB,UAAAyF,mBAAA,SAAmBtB,GAClB,IAAI6B,EAAgB5G,KAAKwG,iBAAiBxG,KAAK4D,MAC/C,OAAIgD,EAAgB,GACX7B,EAAI8B,QAAQD,GAGb/D,KAAKC,MAAMiC,IAIjBrF,EAAAkB,UAAAkG,YAAA,WACI9G,KAAKwE,gDApdZuC,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,WACVC,SAAU,y5FAmBVC,UAAW,CAAC9H,GACZ+H,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,qdAlCRC,EAAAA,kBAAgEC,EAAAA,iBAAUC,EAAAA,cAAOC,EAAAA,sDAuCzGC,EAAAA,wBAEAA,EAAAA,mBAEAA,EAAAA,mBAEAA,EAAAA,2BAEAA,EAAAA,oBAEAA,EAAAA,qBAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,8BAEAA,EAAAA,wBAEAA,EAAAA,wBAEAC,EAAAA,2BAEAA,EAAAA,6BAEAC,EAAAA,UAAShB,KAAA,CAAC,2CAEVgB,EAAAA,UAAShB,KAAA,CAAC,8CAEVgB,EAAAA,UAAShB,KAAA,CAAC,4BAmaf,iCALCiB,EAAAA,SAAQjB,KAAA,CAAC,CACNkB,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAC1I,GACV2I,aAAc,CAAC3I","sourcesContent":["import {NgModule, Component, ElementRef, OnDestroy, Input, Output, EventEmitter, forwardRef, Renderer2,NgZone,ChangeDetectorRef, ViewChild, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\nimport {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';\n\nexport const SLIDER_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => Slider),\n multi: true\n};\n\n@Component({\n selector: 'p-slider',\n template: `\n
\n \n \n \n \n \n \n \n
\n `,\n providers: [SLIDER_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./slider.css']\n})\nexport class Slider implements OnDestroy,ControlValueAccessor {\n\n @Input() animate: boolean;\n\n @Input() disabled: boolean;\n\n @Input() min: number = 0;\n\n @Input() max: number = 100;\n\n @Input() orientation: string = 'horizontal';\n\n @Input() step: number;\n\n @Input() range: boolean;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() ariaLabelledBy: string;\n\n @Input() tabindex: number = 0;\n\n @Output() onChange: EventEmitter = new EventEmitter();\n \n @Output() onSlideEnd: EventEmitter = new EventEmitter();\n \n @ViewChild(\"sliderHandle\") sliderHandle: ElementRef;\n\n @ViewChild(\"sliderHandleStart\") sliderHandleStart: ElementRef;\n\n @ViewChild(\"sliderHandleEnd\") sliderHandleEnd: ElementRef;\n\n public value: number;\n \n public values: number[];\n \n public handleValue: number;\n \n public handleValues: number[] = [];\n \n public onModelChange: Function = () => {};\n \n public onModelTouched: Function = () => {};\n \n public dragging: boolean;\n \n public dragListener: any;\n \n public mouseupListener: any;\n \n public initX: number;\n \n public initY: number;\n \n public barWidth: number;\n \n public barHeight: number;\n \n public sliderHandleClick: boolean;\n \n public handleIndex: number = 0;\n\n public startHandleValue: any;\n\n public startx: number;\n\n public starty: number;\n \n constructor(public el: ElementRef, public renderer: Renderer2, private ngZone: NgZone, public cd: ChangeDetectorRef) {}\n \n onMouseDown(event, index?:number) {\n if (this.disabled) {\n return;\n }\n \n this.dragging = true;\n this.updateDomData();\n this.sliderHandleClick = true;\n if (this.range && this.handleValues && this.handleValues[0] === this.max) {\n this.handleIndex = 0;\n }\n else {\n this.handleIndex = index;\n }\n\n this.bindDragListeners();\n event.target.focus();\n event.preventDefault();\n\n if (this.animate) {\n DomHandler.removeClass(this.el.nativeElement.children[0], 'p-slider-animate');\n }\n }\n\n onTouchStart(event, index?:number) {\n if (this.disabled) {\n return;\n }\n\n var touchobj = event.changedTouches[0];\n this.startHandleValue = (this.range) ? this.handleValues[index] : this.handleValue;\n this.dragging = true;\n if (this.range && this.handleValues && this.handleValues[0] === this.max) {\n this.handleIndex = 0;\n }\n else {\n this.handleIndex = index;\n }\n\n if (this.orientation === 'horizontal') {\n this.startx = parseInt(touchobj.clientX, 10);\n this.barWidth = this.el.nativeElement.children[0].offsetWidth;\n }\n else {\n this.starty = parseInt(touchobj.clientY, 10);\n this.barHeight = this.el.nativeElement.children[0].offsetHeight;\n }\n\n if (this.animate) {\n DomHandler.removeClass(this.el.nativeElement.children[0], 'p-slider-animate');\n }\n\n event.preventDefault();\n }\n\n onTouchMove(event, index?:number) {\n if (this.disabled) {\n return;\n }\n \n var touchobj = event.changedTouches[0],\n handleValue = 0;\n\n if (this.orientation === 'horizontal') {\n handleValue = Math.floor(((parseInt(touchobj.clientX, 10) - this.startx) * 100) / (this.barWidth)) + this.startHandleValue;\n }\n else {\n handleValue = Math.floor(((this.starty - parseInt(touchobj.clientY, 10)) * 100) / (this.barHeight)) + this.startHandleValue;\n }\n\n this.setValueFromHandle(event, handleValue);\n\n event.preventDefault();\n }\n\n onTouchEnd(event, index?:number) {\n if (this.disabled) {\n return;\n }\n\n this.dragging = false;\n \n if (this.range)\n this.onSlideEnd.emit({originalEvent: event, values: this.values});\n else\n this.onSlideEnd.emit({originalEvent: event, value: this.value});\n\n if (this.animate) {\n DomHandler.addClass(this.el.nativeElement.children[0], 'p-slider-animate');\n }\n \n event.preventDefault();\n }\n \n onBarClick(event) {\n if (this.disabled) {\n return;\n }\n \n if (!this.sliderHandleClick) {\n this.updateDomData();\n this.handleChange(event);\n }\n \n this.sliderHandleClick = false;\n }\n\n onHandleKeydown(event, handleIndex?:number) {\n if (this.disabled) {\n return;\n }\n if (event.which == 38 || event.which == 39) {\n this.spin(event, 1, handleIndex);\n }\n else if (event.which == 37 || event.which == 40) {\n this.spin(event, -1, handleIndex);\n }\n }\n \n spin(event, dir: number, handleIndex?:number) {\n let step = (this.step || 1) * dir;\n\n if (this.range) {\n this.handleIndex = handleIndex;\n this.updateValue(this.values[this.handleIndex] + step);\n this.updateHandleValue();\n }\n else {\n this.updateValue(this.value + step);\n this.updateHandleValue();\n }\n\n event.preventDefault();\n }\n\n handleChange(event: Event) {\n let handleValue = this.calculateHandleValue(event);\n this.setValueFromHandle(event, handleValue);\n }\n \n bindDragListeners() {\n this.ngZone.runOutsideAngular(() => {\n const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document';\n\n if (!this.dragListener) {\n this.dragListener = this.renderer.listen(documentTarget, 'mousemove', (event) => {\n if (this.dragging) {\n this.ngZone.run(() => {\n this.handleChange(event);\n });\n }\n });\n }\n\n if (!this.mouseupListener) {\n this.mouseupListener = this.renderer.listen(documentTarget, 'mouseup', (event) => {\n if (this.dragging) {\n this.dragging = false;\n this.ngZone.run(() => {\n if (this.range)\n this.onSlideEnd.emit({originalEvent: event, values: this.values});\n else\n this.onSlideEnd.emit({originalEvent: event, value: this.value});\n\n if (this.animate) {\n DomHandler.addClass(this.el.nativeElement.children[0], 'p-slider-animate');\n }\n });\n }\n });\n }\n });\n }\n \n unbindDragListeners() {\n if (this.dragListener) {\n this.dragListener();\n }\n \n if (this.mouseupListener) {\n this.mouseupListener();\n }\n }\n\n setValueFromHandle(event: Event, handleValue: any) {\n let newValue = this.getValueFromHandle(handleValue);\n\n if (this.range) {\n if (this.step) {\n this.handleStepChange(newValue, this.values[this.handleIndex]);\n }\n else {\n this.handleValues[this.handleIndex] = handleValue; \n this.updateValue(newValue, event);\n }\n }\n else { \n if (this.step) {\n this.handleStepChange(newValue, this.value);\n } \n else {\n this.handleValue = handleValue;\n this.updateValue(newValue, event);\n } \n }\n\n this.cd.markForCheck();\n }\n \n handleStepChange(newValue: number, oldValue: number) {\n let diff = (newValue - oldValue);\n let val = oldValue;\n \n if (diff < 0) {\n val = oldValue + Math.ceil(newValue / this.step - oldValue / this.step) * this.step;\n }\n else if (diff > 0) {\n val = oldValue + Math.floor(newValue / this.step - oldValue / this.step) * this.step;\n }\n \n this.updateValue(val);\n this.updateHandleValue();\n }\n \n writeValue(value: any) : void {\n if (this.range)\n this.values = value||[0,0];\n else\n this.value = value||0;\n \n this.updateHandleValue();\n this.cd.markForCheck();\n }\n \n registerOnChange(fn: Function): void {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: Function): void {\n this.onModelTouched = fn;\n }\n \n setDisabledState(val: boolean): void {\n this.disabled = val;\n this.cd.markForCheck();\n }\n \n get rangeStartLeft() {\n return this.isVertical() ? 'auto' : this.handleValues[0] + '%';\n }\n \n get rangeStartBottom() {\n return this.isVertical() ? this.handleValues[0] + '%' : 'auto';\n }\n \n get rangeEndLeft() {\n return this.isVertical() ? 'auto' : this.handleValues[1] + '%';\n }\n \n get rangeEndBottom() {\n return this.isVertical() ? this.handleValues[1] + '%' : 'auto';\n }\n \n isVertical(): boolean {\n return this.orientation === 'vertical';\n }\n \n updateDomData(): void {\n let rect = this.el.nativeElement.children[0].getBoundingClientRect();\n this.initX = rect.left + DomHandler.getWindowScrollLeft();\n this.initY = rect.top + DomHandler.getWindowScrollTop();\n this.barWidth = this.el.nativeElement.children[0].offsetWidth;\n this.barHeight = this.el.nativeElement.children[0].offsetHeight;\n }\n \n calculateHandleValue(event): number {\n if (this.orientation === 'horizontal')\n return ((event.pageX - this.initX) * 100) / (this.barWidth);\n else\n return(((this.initY + this.barHeight) - event.pageY) * 100) / (this.barHeight);\n }\n \n updateHandleValue(): void {\n if (this.range) {\n this.handleValues[0] = (this.values[0] < this.min ? 0 : this.values[0] - this.min) * 100 / (this.max - this.min);\n this.handleValues[1] = (this.values[1] > this.max ? 100 : this.values[1] - this.min) * 100 / (this.max - this.min);\n }\n else {\n if (this.value < this.min)\n this.handleValue = 0;\n else if (this.value > this.max)\n this.handleValue = 100;\n else\n this.handleValue = (this.value - this.min) * 100 / (this.max - this.min);\n }\n }\n \n updateValue(val: number, event?: Event): void {\n if (this.range) {\n let value = val;\n \n if (this.handleIndex == 0) {\n if (value < this.min) {\n value = this.min;\n this.handleValues[0] = 0;\n }\n else if (value > this.values[1]) {\n value = this.values[1];\n this.handleValues[0] = this.handleValues[1];\n }\n\n this.sliderHandleStart.nativeElement.focus();\n }\n else {\n if (value > this.max) {\n value = this.max;\n this.handleValues[1] = 100;\n }\n else if (value < this.values[0]) {\n value = this.values[0];\n this.handleValues[1] = this.handleValues[0];\n }\n\n this.sliderHandleEnd.nativeElement.focus();\n }\n \n this.values[this.handleIndex] = this.getNormalizedValue(value);\n this.values = this.values.slice();\n this.onModelChange(this.values);\n this.onChange.emit({event: event, values: this.values});\n }\n else {\n if (val < this.min) {\n val = this.min;\n this.handleValue = 0;\n }\n else if (val > this.max) {\n val = this.max;\n this.handleValue = 100;\n }\n \n\t\t\tthis.value = this.getNormalizedValue(val);\n \n this.onModelChange(this.value);\n this.onChange.emit({event: event, value: this.value});\n this.sliderHandle.nativeElement.focus();\n }\n }\n \n getValueFromHandle(handleValue: number): number {\n return (this.max - this.min) * (handleValue / 100) + this.min;\n }\n\t\n\tgetDecimalsCount(value: number): number {\n\t\tif (value && Math.floor(value) !== value)\n\t\t\treturn value.toString().split(\".\")[1].length || 0;\n\t\treturn 0;\n\t}\n\t\n\tgetNormalizedValue(val: number): number {\n\t\tlet decimalsCount = this.getDecimalsCount(this.step);\n\t\tif (decimalsCount > 0) {\n\t\t\treturn +val.toFixed(decimalsCount);\n\t\t} \n\t\telse {\n\t\t\treturn Math.floor(val);\n\t\t}\n\t}\n \n ngOnDestroy() {\n this.unbindDragListeners();\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Slider],\n declarations: [Slider]\n})\nexport class SliderModule { }\n"]}