UNPKG

@angular2-material/core

Version:
66 lines (64 loc) 2.61 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { NgModule, Directive } from '@angular/core'; /** * Shared directive to count lines inside a text area, such as a list item. * Line elements can be extracted with a @ContentChildren(MdLine) query, then * counted by checking the query list's length. */ export var MdLine = (function () { function MdLine() { } MdLine = __decorate([ Directive({ selector: '[md-line]' }), __metadata('design:paramtypes', []) ], MdLine); return MdLine; }()); /* Helper that takes a query list of lines and sets the correct class on the host */ export var MdLineSetter = (function () { function MdLineSetter(_lines, _renderer, _element) { var _this = this; this._lines = _lines; this._renderer = _renderer; this._element = _element; this._setLineClass(this._lines.length); this._lines.changes.subscribe(function () { _this._setLineClass(_this._lines.length); }); } MdLineSetter.prototype._setLineClass = function (count) { this._resetClasses(); if (count === 2 || count === 3) { this._setClass("md-" + count + "-line", true); } }; MdLineSetter.prototype._resetClasses = function () { this._setClass('md-2-line', false); this._setClass('md-3-line', false); }; MdLineSetter.prototype._setClass = function (className, bool) { this._renderer.setElementClass(this._element.nativeElement, className, bool); }; return MdLineSetter; }()); export var MdLineModule = (function () { function MdLineModule() { } MdLineModule = __decorate([ NgModule({ exports: [MdLine], declarations: [MdLine], }), __metadata('design:paramtypes', []) ], MdLineModule); return MdLineModule; }()); //# sourceMappingURL=line.js.map