UNPKG

ng2-encrm-components

Version:
69 lines 3.12 kB
"use strict"; var core_1 = require('@angular/core'); var bs4_breakpoints_enum_1 = require('./bs4-breakpoints.enum'); var Bs4BreakpointsComponent = (function () { function Bs4BreakpointsComponent(e, ngZone) { var _this = this; this.e = e; this.changed = new core_1.EventEmitter(); this.resize = new core_1.EventEmitter(); this.current = bs4_breakpoints_enum_1.Bs4BreakPoint.xl; this.changed.next(this.current); window.onresize = function () { ngZone.run(function () { _this.width = window.innerWidth; _this.height = window.innerHeight; if (_this.check()) { _this.changed.next(_this.current); } _this.resize.next({ width: _this.width, height: _this.height }); }); }; } Bs4BreakpointsComponent.prototype.isVisible = function (obj) { var style = window.getComputedStyle(obj, undefined); return style.display === 'block'; }; Bs4BreakpointsComponent.prototype.check = function () { var t; if (this.isVisible(this.e.nativeElement.children[0])) { t = bs4_breakpoints_enum_1.Bs4BreakPoint.xs; } if (this.isVisible(this.e.nativeElement.children[1])) { t = bs4_breakpoints_enum_1.Bs4BreakPoint.sm; } if (this.isVisible(this.e.nativeElement.children[2])) { t = bs4_breakpoints_enum_1.Bs4BreakPoint.md; } if (this.isVisible(this.e.nativeElement.children[3])) { t = bs4_breakpoints_enum_1.Bs4BreakPoint.lg; } if (this.isVisible(this.e.nativeElement.children[4])) { t = bs4_breakpoints_enum_1.Bs4BreakPoint.xl; } if (t !== this.current) { this.current = t; return true; } return false; }; Bs4BreakpointsComponent.prototype.ngOnInit = function () { }; __decorate([ core_1.Output(), __metadata('design:type', core_1.EventEmitter) ], Bs4BreakpointsComponent.prototype, "changed", void 0); __decorate([ core_1.Output(), __metadata('design:type', core_1.EventEmitter) ], Bs4BreakpointsComponent.prototype, "resize", void 0); Bs4BreakpointsComponent = __decorate([ core_1.Component({ selector: 'bs4-breakpoints', template: "\n <div class=\"device-xs hidden-sm-up\"></div>\n <div class=\"device-sm hidden-md-up hidden-xs-down\"></div>\n <div class=\"device-md hidden-lg-up hidden-sm-down\"></div>\n <div class=\"device-lg hidden-xl-up hidden-md-down\"></div>\n <div class=\"device-xl hidden-lg-down\"></div>\n ", styles: [':host { display:none; } '] }), __metadata('design:paramtypes', [core_1.ElementRef, core_1.NgZone]) ], Bs4BreakpointsComponent); return Bs4BreakpointsComponent; }()); exports.Bs4BreakpointsComponent = Bs4BreakpointsComponent; //# sourceMappingURL=bs4-breakpoints.component.js.map