1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
9 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
10 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
11 | 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;
|
12 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
13 | };
|
14 | var __metadata = (this && this.__metadata) || function (k, v) {
|
15 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
16 | };
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | var context_1 = require("../context/context");
|
19 | var filterManager_1 = require("../filter/filterManager");
|
20 | var utils_1 = require("../utils");
|
21 | var popupService_1 = require("../widgets/popupService");
|
22 | var gridOptionsWrapper_1 = require("../gridOptionsWrapper");
|
23 | var eventService_1 = require("../eventService");
|
24 | var StandardMenuFactory = (function () {
|
25 | function StandardMenuFactory() {
|
26 | }
|
27 | StandardMenuFactory.prototype.hideActiveMenu = function () {
|
28 | if (this.hidePopup) {
|
29 | this.hidePopup();
|
30 | }
|
31 | };
|
32 | StandardMenuFactory.prototype.showMenuAfterMouseEvent = function (column, mouseEvent) {
|
33 | var _this = this;
|
34 | this.showPopup(column, function (eMenu) {
|
35 | _this.popupService.positionPopupUnderMouseEvent({
|
36 | column: column,
|
37 | type: 'columnMenu',
|
38 | mouseEvent: mouseEvent,
|
39 | ePopup: eMenu
|
40 | });
|
41 | });
|
42 | };
|
43 | StandardMenuFactory.prototype.showMenuAfterButtonClick = function (column, eventSource) {
|
44 | var _this = this;
|
45 | this.showPopup(column, function (eMenu) {
|
46 | _this.popupService.positionPopupUnderComponent({ type: 'columnMenu', eventSource: eventSource,
|
47 | ePopup: eMenu, keepWithinBounds: true, column: column });
|
48 | });
|
49 | };
|
50 | StandardMenuFactory.prototype.showPopup = function (column, positionCallback) {
|
51 | var _this = this;
|
52 | var filterWrapper = this.filterManager.getOrCreateFilterWrapper(column);
|
53 | var eMenu = document.createElement('div');
|
54 | utils_1.Utils.addCssClass(eMenu, 'ag-menu');
|
55 | filterWrapper.guiPromise.promise.then(function (gui) {
|
56 | eMenu.appendChild(gui);
|
57 | });
|
58 | var hidePopup;
|
59 | var bodyScrollListener = function (event) {
|
60 |
|
61 | if (event.direction === 'horizontal') {
|
62 | hidePopup();
|
63 | }
|
64 | };
|
65 | this.eventService.addEventListener('bodyScroll', bodyScrollListener);
|
66 | var closedCallback = function () {
|
67 | _this.eventService.removeEventListener('bodyScroll', bodyScrollListener);
|
68 | column.setMenuVisible(false, "contextMenu");
|
69 | };
|
70 |
|
71 |
|
72 | hidePopup = this.popupService.addAsModalPopup(eMenu, true, closedCallback);
|
73 | positionCallback(eMenu);
|
74 | filterWrapper.filterPromise.then(function (filter) {
|
75 | if (filter.afterGuiAttached) {
|
76 | var params = {
|
77 | hidePopup: hidePopup
|
78 | };
|
79 | filter.afterGuiAttached(params);
|
80 | }
|
81 | });
|
82 | this.hidePopup = hidePopup;
|
83 | column.setMenuVisible(true, "contextMenu");
|
84 | };
|
85 | StandardMenuFactory.prototype.isMenuEnabled = function (column) {
|
86 |
|
87 | return this.gridOptionsWrapper.isEnableFilter() && column.isFilterAllowed();
|
88 | };
|
89 | __decorate([
|
90 | context_1.Autowired('eventService'),
|
91 | __metadata("design:type", eventService_1.EventService)
|
92 | ], StandardMenuFactory.prototype, "eventService", void 0);
|
93 | __decorate([
|
94 | context_1.Autowired('filterManager'),
|
95 | __metadata("design:type", filterManager_1.FilterManager)
|
96 | ], StandardMenuFactory.prototype, "filterManager", void 0);
|
97 | __decorate([
|
98 | context_1.Autowired('popupService'),
|
99 | __metadata("design:type", popupService_1.PopupService)
|
100 | ], StandardMenuFactory.prototype, "popupService", void 0);
|
101 | __decorate([
|
102 | context_1.Autowired('gridOptionsWrapper'),
|
103 | __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
|
104 | ], StandardMenuFactory.prototype, "gridOptionsWrapper", void 0);
|
105 | StandardMenuFactory = __decorate([
|
106 | context_1.Bean('menuFactory')
|
107 | ], StandardMenuFactory);
|
108 | return StandardMenuFactory;
|
109 | }());
|
110 | exports.StandardMenuFactory = StandardMenuFactory;
|