blockui.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. "use strict";
  2. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5. 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;
  6. return c > 3 && r && Object.defineProperty(target, key, r), r;
  7. };
  8. var __metadata = (this && this.__metadata) || function (k, v) {
  9. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var core_1 = require("@angular/core");
  13. var common_1 = require("@angular/common");
  14. var domhandler_1 = require("../dom/domhandler");
  15. var BlockUI = /** @class */ (function () {
  16. function BlockUI(el) {
  17. this.el = el;
  18. this.autoZIndex = true;
  19. this.baseZIndex = 0;
  20. }
  21. Object.defineProperty(BlockUI.prototype, "blocked", {
  22. get: function () {
  23. return this._blocked;
  24. },
  25. set: function (val) {
  26. this._blocked = val;
  27. if (this.mask && this.mask.nativeElement) {
  28. if (this._blocked)
  29. this.block();
  30. else
  31. this.unblock();
  32. }
  33. },
  34. enumerable: true,
  35. configurable: true
  36. });
  37. BlockUI.prototype.ngAfterViewInit = function () {
  38. if (this.target && !this.target.getBlockableElement) {
  39. throw 'Target of BlockUI must implement BlockableUI interface';
  40. }
  41. };
  42. BlockUI.prototype.block = function () {
  43. if (this.target) {
  44. this.target.getBlockableElement().appendChild(this.mask.nativeElement);
  45. var style = this.target.style || {};
  46. style.position = 'relative';
  47. this.target.style = style;
  48. }
  49. else {
  50. document.body.appendChild(this.mask.nativeElement);
  51. }
  52. if (this.autoZIndex) {
  53. this.mask.nativeElement.style.zIndex = String(this.baseZIndex + (++domhandler_1.DomHandler.zindex));
  54. }
  55. };
  56. BlockUI.prototype.unblock = function () {
  57. this.el.nativeElement.appendChild(this.mask.nativeElement);
  58. };
  59. BlockUI.prototype.ngOnDestroy = function () {
  60. this.unblock();
  61. };
  62. __decorate([
  63. core_1.Input(),
  64. __metadata("design:type", Object)
  65. ], BlockUI.prototype, "target", void 0);
  66. __decorate([
  67. core_1.Input(),
  68. __metadata("design:type", Boolean)
  69. ], BlockUI.prototype, "autoZIndex", void 0);
  70. __decorate([
  71. core_1.Input(),
  72. __metadata("design:type", Number)
  73. ], BlockUI.prototype, "baseZIndex", void 0);
  74. __decorate([
  75. core_1.ViewChild('mask', { static: false }),
  76. __metadata("design:type", core_1.ElementRef)
  77. ], BlockUI.prototype, "mask", void 0);
  78. __decorate([
  79. core_1.Input(),
  80. __metadata("design:type", Boolean),
  81. __metadata("design:paramtypes", [Boolean])
  82. ], BlockUI.prototype, "blocked", null);
  83. BlockUI = __decorate([
  84. core_1.Component({
  85. selector: 'p-blockUI',
  86. template: "\n <div #mask class=\"ui-blockui ui-widget-overlay\" [ngClass]=\"{'ui-blockui-document':!target}\" [ngStyle]=\"{display: blocked ? 'block' : 'none'}\">\n <ng-content></ng-content>\n </div>\n "
  87. }),
  88. __metadata("design:paramtypes", [core_1.ElementRef])
  89. ], BlockUI);
  90. return BlockUI;
  91. }());
  92. exports.BlockUI = BlockUI;
  93. var BlockUIModule = /** @class */ (function () {
  94. function BlockUIModule() {
  95. }
  96. BlockUIModule = __decorate([
  97. core_1.NgModule({
  98. imports: [common_1.CommonModule],
  99. exports: [BlockUI],
  100. declarations: [BlockUI]
  101. })
  102. ], BlockUIModule);
  103. return BlockUIModule;
  104. }());
  105. exports.BlockUIModule = BlockUIModule;
  106. //# sourceMappingURL=blockui.js.map