UNPKG

ws-form-builder

Version:
81 lines 4.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var form_builder_1 = require("../../providers/form-builder/form-builder"); var WsSingleRangeSliderComponent = (function () { function WsSingleRangeSliderComponent(formBuilder) { this.formBuilder = formBuilder; this.answerGiven = new core_1.EventEmitter(); this.step = 1; this.minValue = 0; this.maxValue = 100; this.snaps = false; this.fieldValue = 20; this.isFieldValid = false; this.showError = false; this.iconLeft = ''; this.iconRight = ''; this.showNumber = true; this.fieldClass = ''; } WsSingleRangeSliderComponent.prototype.ngOnInit = function () { if (typeof this.question.step !== 'undefined') { this.step = this.question.step; } if (typeof this.question.maxNumber !== 'undefined') { this.maxValue = this.question.maxNumber; } if (typeof this.question.minNumber !== 'undefined') { this.minValue = this.question.minNumber; } if (typeof this.question.snaps !== 'undefined') { this.snaps = this.question.snaps; } if (typeof this.question.iconLeft !== 'undefined' && this.question.iconLeft !== '') { this.iconLeft = this.question.iconLeft; } if (typeof this.question.iconRight !== 'undefined' && this.question.iconRight !== '') { this.iconRight = this.question.iconRight; } if (typeof this.question.showNumber !== 'undefined') { this.showNumber = this.question.showNumber; } if (typeof this.question.defaultNumber !== 'undefined' && this.question.defaultNumber !== '') { this.fieldValue = this.question.defaultNumber; } if (typeof this.question.value !== 'undefined' && this.question.value !== '') { this.fieldValue = this.question.value; } if (typeof this.question.inputClass !== 'undefined') { this.fieldClass = this.question.inputClass; } }; WsSingleRangeSliderComponent.prototype.setAnswer = function (event) { if (this.fieldValue) { this.question.value = this.fieldValue; this.question.valid = true; this.answerGiven.emit(this.question); } }; WsSingleRangeSliderComponent.prototype.validateAnswer = function (question, string) { return this.formBuilder.validateAnswer(question, string); }; WsSingleRangeSliderComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'ws-single-range-slider', template: "\n <div class=\"ranger-slider-container {{fieldClass}}\">\n <ion-item detail-push class=\"range-slider-label\" *ngIf=\"!question.hideQuestion\">\n {{question.question}}\n </ion-item>\n <ion-item>\n <ion-label class=\"range-slider\">\n \t<ion-icon name=\"{{iconLeft}}\" *ngIf='iconLeft !== \"\"' class=\"icon--left\"></ion-icon>\n\n \t<ion-badge *ngIf='showNumber'>{{fieldValue}}</ion-badge>\n\n \t<ion-icon name=\"{{iconRight}}\" *ngIf='iconRight !== \"\"' class=\"icon--right\"></ion-icon>\n </ion-label>\n <ion-range min=\"{{minValue}}\" max=\"{{maxValue}}\" step=\"{{step}}\" [(ngModel)]='fieldValue' debounce=\"700\" (ionChange)=\"setAnswer($event)\" snaps=\"{{snaps}}\"></ion-range>\n </ion-item>\n\n </div>\n ", styles: ["\n .ranger-slider-container .range-slider{width:100%;margin:8px 8px 0 0;min-height:40px;text-align:center}.ranger-slider-container .range-slider .badge{margin:15px auto 0}.ranger-slider-container .range-slider .icon{font-size:40px;position:relative;top:3px}.ranger-slider-container .icon--right{float:right}.ranger-slider-container .icon--left{float:left}\n "] },] }, ]; /** @nocollapse */ WsSingleRangeSliderComponent.ctorParameters = function () { return [ { type: form_builder_1.FormBuilderProvider, }, ]; }; WsSingleRangeSliderComponent.propDecorators = { "question": [{ type: core_1.Input, args: ['question',] },], "answerGiven": [{ type: core_1.Output },], }; return WsSingleRangeSliderComponent; }()); exports.WsSingleRangeSliderComponent = WsSingleRangeSliderComponent; //# sourceMappingURL=ws-single-range-slider.js.map