UNPKG

2.61 kBJavaScriptView Raw
1var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 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;
5 return c > 3 && r && Object.defineProperty(target, key, r), r;
6};
7var __metadata = (this && this.__metadata) || function (k, v) {
8 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9};
10import { NgModule, Directive } from '@angular/core';
11/**
12 * Shared directive to count lines inside a text area, such as a list item.
13 * Line elements can be extracted with a @ContentChildren(MdLine) query, then
14 * counted by checking the query list's length.
15 */
16export var MdLine = (function () {
17 function MdLine() {
18 }
19 MdLine = __decorate([
20 Directive({ selector: '[md-line]' }),
21 __metadata('design:paramtypes', [])
22 ], MdLine);
23 return MdLine;
24}());
25/* Helper that takes a query list of lines and sets the correct class on the host */
26export var MdLineSetter = (function () {
27 function MdLineSetter(_lines, _renderer, _element) {
28 var _this = this;
29 this._lines = _lines;
30 this._renderer = _renderer;
31 this._element = _element;
32 this._setLineClass(this._lines.length);
33 this._lines.changes.subscribe(function () {
34 _this._setLineClass(_this._lines.length);
35 });
36 }
37 MdLineSetter.prototype._setLineClass = function (count) {
38 this._resetClasses();
39 if (count === 2 || count === 3) {
40 this._setClass("md-" + count + "-line", true);
41 }
42 };
43 MdLineSetter.prototype._resetClasses = function () {
44 this._setClass('md-2-line', false);
45 this._setClass('md-3-line', false);
46 };
47 MdLineSetter.prototype._setClass = function (className, bool) {
48 this._renderer.setElementClass(this._element.nativeElement, className, bool);
49 };
50 return MdLineSetter;
51}());
52export var MdLineModule = (function () {
53 function MdLineModule() {
54 }
55 MdLineModule = __decorate([
56 NgModule({
57 exports: [MdLine],
58 declarations: [MdLine],
59 }),
60 __metadata('design:paramtypes', [])
61 ], MdLineModule);
62 return MdLineModule;
63}());
64
65//# sourceMappingURL=line.js.map