ng2-materialize
Version:
An Angular 2+ wrap around Materialize library
82 lines (81 loc) • 3.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var MzCardComponent = (function () {
function MzCardComponent(changeDetectorRef) {
this.changeDetectorRef = changeDetectorRef;
this.hasCardAction = true;
this.hasCardTitle = true;
}
MzCardComponent.prototype.ngAfterViewInit = function () {
this.hasCardTitle = this.hasTitleTagAndNotEmpty();
this.hasCardAction = this.hasActionTagAndNotEmpty();
this.changeDetectorRef.detectChanges();
};
MzCardComponent.prototype.hasActionTagAndNotEmpty = function () {
var cardActionElement = this.cardAction.nativeElement.querySelector('mz-card-action');
return this.isElementDisplayed(cardActionElement);
};
MzCardComponent.prototype.hasTitleTagAndNotEmpty = function () {
var cardTitleElement = this.cardTitle.nativeElement.querySelector('mz-card-title');
return this.isElementDisplayed(cardTitleElement);
};
MzCardComponent.prototype.isElementDisplayed = function (element) {
return element && element.innerHTML.trim() !== '';
};
return MzCardComponent;
}());
MzCardComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'mz-card',
template: "<div class=\"card-content\"><div #cardTitle class=\"card-title\" *ngIf=\"hasCardTitle\"><ng-content select=\"mz-card-title\"></ng-content></div><ng-content select=\"mz-card-content\"></ng-content></div><div #cardAction class=\"card-action\" *ngIf=\"hasCardAction\"><ng-content select=\"mz-card-action\"></ng-content></div>",
styles: [":host{display:block}"],
},] },
];
/** @nocollapse */
MzCardComponent.ctorParameters = function () { return [
{ type: core_1.ChangeDetectorRef, },
]; };
MzCardComponent.propDecorators = {
'true': [{ type: core_1.HostBinding, args: ['class.card',] },],
'hoverable': [{ type: core_1.HostBinding, args: ['class.hoverable',] }, { type: core_1.Input },],
'cardTitle': [{ type: core_1.ViewChild, args: ['cardTitle',] },],
'cardAction': [{ type: core_1.ViewChild, args: ['cardAction',] },],
};
exports.MzCardComponent = MzCardComponent;
// Declare the tags to avoid error: '<mz-card-x>' is not a known element
// https://github.com/angular/angular/issues/11251
// tslint:disable: directive-selector
var MzCardTitleDirective = (function () {
function MzCardTitleDirective() {
}
return MzCardTitleDirective;
}());
MzCardTitleDirective.decorators = [
{ type: core_1.Directive, args: [{ selector: 'mz-card-title' },] },
];
/** @nocollapse */
MzCardTitleDirective.ctorParameters = function () { return []; };
exports.MzCardTitleDirective = MzCardTitleDirective;
var MzCardContentDirective = (function () {
function MzCardContentDirective() {
}
return MzCardContentDirective;
}());
MzCardContentDirective.decorators = [
{ type: core_1.Directive, args: [{ selector: 'mz-card-content' },] },
];
/** @nocollapse */
MzCardContentDirective.ctorParameters = function () { return []; };
exports.MzCardContentDirective = MzCardContentDirective;
var MzCardActionDirective = (function () {
function MzCardActionDirective() {
}
return MzCardActionDirective;
}());
MzCardActionDirective.decorators = [
{ type: core_1.Directive, args: [{ selector: 'mz-card-action' },] },
];
/** @nocollapse */
MzCardActionDirective.ctorParameters = function () { return []; };
exports.MzCardActionDirective = MzCardActionDirective;