1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264 | 1×
1×
1×
1×
150×
150×
2×
2×
2×
2×
2×
2×
150×
2×
2×
2×
150×
150×
2×
2×
150×
1×
4×
2×
2×
1×
14486×
1×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
5×
1×
7×
7×
7×
7×
7×
7×
7×
1×
1×
6×
6×
1×
2×
2×
2×
2×
1×
2×
1×
2×
2×
1×
4×
4×
4×
4×
4×
4×
4×
4×
4×
4×
4×
4×
1×
3×
3×
3×
3×
3×
1×
6×
6×
6×
4×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
6×
1×
207×
5×
3×
5×
15×
15×
5×
207×
2×
2×
207×
207×
207×
207×
207×
207×
1×
207×
5×
5×
207×
5×
5×
207×
5×
5×
207×
5×
5×
207×
5×
5×
207×
5×
5×
207×
5×
5×
207×
5×
5×
207×
5×
5×
207×
5×
5×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-buttons", "@syncfusion/ej2-inputs", "../index", "@syncfusion/ej2-base", "./index"], function (require, exports, ej2_buttons_1, ej2_inputs_1, index_1, ej2_base_1, index_2) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TableOptionsDialog = (function () {
function TableOptionsDialog(documentHelper) {
var _this = this;
this.applyTableCellProperties = function () {
var tableFormat = _this.documentHelper.selection.tableFormat;
Eif (!ej2_base_1.isNullOrUndefined(_this.bottomMarginBox.value || _this.leftMarginBox.value
|| _this.rightMarginBox.value || _this.topMarginBox.value || _this.cellSpaceTextBox.value)
&& (tableFormat.bottomMargin !== _this.bottomMarginBox.value
|| tableFormat.leftMargin !== _this.leftMarginBox.value
|| tableFormat.rightMargin !== _this.rightMarginBox.value
|| tableFormat.topMargin !== _this.topMarginBox.value
|| tableFormat.cellSpacing !== _this.cellSpaceTextBox.value)) {
_this.documentHelper.owner.tablePropertiesDialogModule.isTableOptionsUpdated = true;
_this.applyTableOptions(_this.tableFormat);
_this.documentHelper.owner.tablePropertiesDialogModule.applyTableSubProperties();
}
_this.closeCellMarginsDialog();
};
this.closeCellMarginsDialog = function () {
_this.documentHelper.dialog.hide();
_this.documentHelper.dialog.element.style.pointerEvents = '';
_this.documentHelper.updateFocus();
};
this.changeAllowSpaceCheckBox = function () {
if (_this.allowSpaceCheckBox.checked) {
_this.cellSpaceTextBox.enabled = true;
}
else {
_this.cellSpaceTextBox.enabled = false;
_this.cellSpaceTextBox.value = 0;
}
};
this.removeEvents = function () {
_this.documentHelper.dialog2.element.style.pointerEvents = '';
_this.documentHelper.updateFocus();
};
this.documentHelper = documentHelper;
}
Object.defineProperty(TableOptionsDialog.prototype, "tableFormat", {
get: function () {
if (ej2_base_1.isNullOrUndefined(this.tableFormatIn)) {
return this.tableFormatIn = new index_1.WTableFormat();
}
return this.tableFormatIn;
},
enumerable: true,
configurable: true
});
TableOptionsDialog.prototype.getModuleName = function () {
return 'TableOptionsDialog';
};
TableOptionsDialog.prototype.initTableOptionsDialog = function (localValue, isRtl) {
this.target = ej2_base_1.createElement('div', {
id: this.documentHelper.owner.containerId + '_insertCellMarginsDialog', className: 'e-de-table-options-dlg'
});
this.innerDiv = ej2_base_1.createElement('div');
this.innerDivLabel = ej2_base_1.createElement('Label', {
id: this.target.id + '_innerDivLabel', className: 'e-de-para-dlg-heading',
innerHTML: localValue.getConstant('Default cell margins')
});
this.innerDiv.appendChild(this.innerDivLabel);
index_2.CellOptionsDialog.getCellMarginDialogElements(this, this.innerDiv, localValue, false);
this.div = ej2_base_1.createElement('div');
this.cellSpaceLabel = ej2_base_1.createElement('Label', {
className: 'e-de-para-dlg-heading',
id: this.target.id + '_cellSpaceLabel'
});
this.cellSpaceLabel.innerHTML = localValue.getConstant('Default cell spacing');
this.div.appendChild(this.cellSpaceLabel);
this.table2 = ej2_base_1.createElement('TABLE', {
styles: 'height: 30px;'
});
this.tr3 = ej2_base_1.createElement('tr');
this.td5 = ej2_base_1.createElement('td');
this.allowSpaceCheckBox1 = ej2_base_1.createElement('input', {
attrs: { 'type': 'checkbox' }, id: this.target.id + '_cellcheck'
});
var td6Padding;
Iif (isRtl) {
td6Padding = 'padding-right:25px;';
}
else {
td6Padding = 'padding-left:25px;';
}
this.td6 = ej2_base_1.createElement('td', { styles: td6Padding });
this.cellspacingTextBox = ej2_base_1.createElement('input', {
attrs: { 'type': 'text' }, id: this.target.id + '_cellspacing'
});
this.td5.appendChild(this.allowSpaceCheckBox1);
this.td6.appendChild(this.cellspacingTextBox);
this.tr3.appendChild(this.td5);
this.tr3.appendChild(this.td6);
this.table2.appendChild(this.tr3);
this.div.appendChild(this.table2);
this.divBtn = document.createElement('div');
this.target.appendChild(this.div);
this.target.appendChild(this.divBtn);
this.cellSpaceTextBox = new ej2_inputs_1.NumericTextBox({
value: 0, min: 0, max: 264.5, width: 174,
decimals: 2, enablePersistence: false
});
this.cellSpaceTextBox.appendTo(this.cellspacingTextBox);
this.allowSpaceCheckBox = new ej2_buttons_1.CheckBox({
label: localValue.getConstant('Allow spacing between cells'),
change: this.changeAllowSpaceCheckBox,
enableRtl: isRtl,
cssClass: 'e-de-tbl-margin-sub-header'
});
this.allowSpaceCheckBox.appendTo(this.allowSpaceCheckBox1);
this.allowSpaceCheckBox1.setAttribute('aria-label', localValue.getConstant('Allow spacing between cells'));
this.cellspacingTextBox.setAttribute('aria-label', 'cell spacing');
};
TableOptionsDialog.prototype.loadCellMarginsDialog = function () {
var tableFormat = this.documentHelper.selection.tableFormat;
this.cellSpaceTextBox.value = tableFormat.cellSpacing;
this.bottomMarginBox.value = tableFormat.bottomMargin;
this.topMarginBox.value = tableFormat.topMargin;
this.rightMarginBox.value = tableFormat.rightMargin;
this.leftMarginBox.value = tableFormat.leftMargin;
if (tableFormat.cellSpacing > 0) {
this.allowSpaceCheckBox.checked = true;
this.cellSpaceTextBox.enabled = true;
}
else {
this.allowSpaceCheckBox.checked = false;
this.cellSpaceTextBox.enabled = false;
}
};
TableOptionsDialog.prototype.applySubTableOptions = function (tableFormat, sourceTable) {
this.documentHelper.owner.editorHistoryModule.initComplexHistory(this.documentHelper.selection, 'TableMarginsSelection');
this.applyTableOptionsHistory(tableFormat, sourceTable);
Eif (!ej2_base_1.isNullOrUndefined(this.documentHelper.owner.editorHistoryModule.currentHistoryInfo)) {
this.documentHelper.owner.editorHistoryModule.updateComplexHistory();
}
};
TableOptionsDialog.prototype.applyTableOptionsHelper = function (tableFormat) {
this.applySubTableOptionsHelper(tableFormat, undefined);
};
TableOptionsDialog.prototype.applyTableOptionsHistory = function (tableFormat, sourceTable) {
this.documentHelper.owner.editorModule.initHistory('TableOptions');
this.applySubTableOptionsHelper(tableFormat, sourceTable);
};
TableOptionsDialog.prototype.applySubTableOptionsHelper = function (tableFormat, ownerTable) {
Eif (ej2_base_1.isNullOrUndefined(ownerTable)) {
ownerTable = this.documentHelper.selection.start.currentWidget.paragraph.associatedCell.ownerTable;
ownerTable = ownerTable.combineWidget(this.documentHelper.owner.viewer);
}
var currentTableFormat = ownerTable.tableFormat;
Eif (!ej2_base_1.isNullOrUndefined(this.documentHelper.owner.editorHistoryModule.currentBaseHistoryInfo)) {
this.documentHelper.owner.editorHistoryModule.currentBaseHistoryInfo.addModifiedTableOptions(currentTableFormat);
}
currentTableFormat.cellSpacing = tableFormat.cellSpacing;
currentTableFormat.leftMargin = tableFormat.leftMargin;
currentTableFormat.topMargin = tableFormat.topMargin;
currentTableFormat.rightMargin = tableFormat.rightMargin;
currentTableFormat.bottomMargin = tableFormat.bottomMargin;
this.documentHelper.owner.tablePropertiesDialogModule.calculateGridValue(ownerTable);
};
TableOptionsDialog.prototype.applyTableOptions = function (tableFormat) {
tableFormat.leftMargin = this.leftMarginBox.value;
tableFormat.topMargin = this.topMarginBox.value;
tableFormat.bottomMargin = this.bottomMarginBox.value;
tableFormat.rightMargin = this.rightMarginBox.value;
tableFormat.cellSpacing = this.cellSpaceTextBox.value;
};
TableOptionsDialog.prototype.show = function () {
var documentLocale = new ej2_base_1.L10n('documenteditor', this.documentHelper.owner.defaultLocale);
documentLocale.setLocale(this.documentHelper.owner.locale);
if (!this.target) {
this.initTableOptionsDialog(documentLocale, this.documentHelper.owner.enableRtl);
}
this.loadCellMarginsDialog();
this.documentHelper.dialog.header = documentLocale.getConstant('Table Options');
this.documentHelper.dialog.content = this.target;
this.documentHelper.dialog.beforeOpen = undefined;
this.documentHelper.dialog.position = { X: 'center', Y: 'center' };
this.documentHelper.dialog.height = 'auto';
this.documentHelper.dialog.width = 'auto';
this.documentHelper.dialog.open = undefined;
this.documentHelper.dialog.beforeOpen = this.documentHelper.updateFocus;
this.documentHelper.dialog.close = this.removeEvents;
this.documentHelper.dialog.buttons = [{
click: this.applyTableCellProperties,
buttonModel: { content: documentLocale.getConstant('Ok'), cssClass: 'e-flat e-table-cell-okay', isPrimary: true }
},
{
click: this.closeCellMarginsDialog,
buttonModel: { content: documentLocale.getConstant('Cancel'), cssClass: 'e-flat e-table-cell-cancel' }
}];
this.documentHelper.dialog.dataBind();
this.documentHelper.dialog.show();
};
TableOptionsDialog.prototype.destroy = function () {
if (!ej2_base_1.isNullOrUndefined(this.target)) {
if (this.target.parentElement) {
this.target.parentElement.removeChild(this.target);
}
for (var p = 0; p < this.target.childNodes.length; p++) {
this.target.removeChild(this.target.childNodes[p]);
p--;
}
this.target = undefined;
}
if (this.tableFormatIn) {
this.tableFormatIn.destroy();
this.tableFormatIn = undefined;
}
this.removeElements();
this.dialog = undefined;
this.target = undefined;
this.documentHelper = undefined;
this.cellspacingTextBox = undefined;
this.allowSpaceCheckBox = undefined;
};
TableOptionsDialog.prototype.removeElements = function () {
if (this.innerDiv) {
this.innerDiv.remove();
this.innerDiv = undefined;
}
if (this.innerDivLabel) {
this.innerDivLabel.remove();
this.innerDivLabel = undefined;
}
if (this.div) {
this.div.remove();
this.div = undefined;
}
if (this.cellSpaceLabel) {
this.cellSpaceLabel.remove();
this.cellSpaceLabel = undefined;
}
if (this.table2) {
this.table2.remove();
this.table2 = undefined;
}
if (this.tr3) {
this.tr3.remove();
this.tr3 = undefined;
}
if (this.td5) {
this.td5.remove();
this.td5 = undefined;
}
if (this.allowSpaceCheckBox1) {
this.allowSpaceCheckBox1.remove();
this.allowSpaceCheckBox1 = undefined;
}
if (this.td6) {
this.td6.remove();
this.td6 = undefined;
}
if (this.divBtn) {
this.divBtn.remove();
this.divBtn = undefined;
}
};
return TableOptionsDialog;
}());
exports.TableOptionsDialog = TableOptionsDialog;
});
|