UNPKG

ng2-materialize

Version:

An Angular 2+ wrap around Materialize library

44 lines (43 loc) 1.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var MzSwitchDirective = (function () { function MzSwitchDirective(elementRef, renderer) { this.elementRef = elementRef; this.renderer = renderer; } MzSwitchDirective.prototype.ngOnInit = function () { this.initElements(); this.handleInputType(); }; MzSwitchDirective.prototype.initElements = function () { this.switchElement = $(this.elementRef.nativeElement); this.switchContainerElement = $(this.elementRef.nativeElement).parent('label').parent('.switch'); if (this.switchContainerElement.length === 0) { console.error('Input with mz-switch directive must be placed inside an [mz-switch-container] tag', this.switchElement); return; } }; MzSwitchDirective.prototype.handleInputType = function () { var type = this.switchElement.attr('type'); if (type !== 'checkbox') { this.renderer.setElementAttribute(this.switchElement[0], 'type', 'checkbox'); } }; return MzSwitchDirective; }()); MzSwitchDirective.decorators = [ { type: core_1.Directive, args: [{ selector: '[mzSwitch], [mz-switch]', },] }, ]; /** @nocollapse */ MzSwitchDirective.ctorParameters = function () { return [ { type: core_1.ElementRef, }, { type: core_1.Renderer, }, ]; }; MzSwitchDirective.propDecorators = { 'off': [{ type: core_1.Input },], 'on': [{ type: core_1.Input },], }; exports.MzSwitchDirective = MzSwitchDirective;