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 | 1×
1×
1×
1×
159×
159×
159×
159×
159×
159×
159×
159×
8×
8×
159×
2×
159×
1×
159×
1×
1×
159×
1×
14468×
1×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
1×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
1×
1×
1×
1×
1×
1×
1×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
12×
1×
1×
12×
1×
2×
2×
2×
2×
1×
2×
2×
2×
2×
2×
1×
1×
1×
219×
219×
219×
9×
9×
219×
9×
9×
219×
1×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
219×
9×
9×
1×
219×
9×
219×
9×
9×
219×
9×
219×
9×
219×
9×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-lists", "@syncfusion/ej2-buttons", "@syncfusion/ej2-base", "@syncfusion/ej2-base"], function (require, exports, ej2_lists_1, ej2_buttons_1, ej2_base_1, ej2_base_2) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var BookmarkDialog = (function () {
function BookmarkDialog(documentHelper) {
var _this = this;
this.listViewInstanceClickHandler = this.onListInstanceClicked.bind(this);
this.onKeyUpOnTextBoxClickHandler = this.onKeyUpOnTextBoxClicked.bind(this);
this.addBookmarkClickHandler = this.onAddBookmarkClicked.bind(this);
this.deleteBookmarkClickHandler = this.onDeleteBookmarkClicked.bind(this);
this.gotoBookmarkClickHandler = this.onGotoBookmarkClicked.bind(this);
this.onKeyUpOnTextBox = function () {
_this.enableOrDisableButton();
};
this.addBookmark = function () {
_this.documentHelper.owner.editorModule.insertBookmark(ej2_base_2.SanitizeHtmlHelper.sanitize(_this.textBoxInput.value));
_this.documentHelper.hideDialog();
};
this.selectHandler = function (args) {
_this.focusTextBox(args.text);
};
this.gotoBookmark = function () {
_this.documentHelper.selection.selectBookmark(_this.textBoxInput.value);
};
this.deleteBookmark = function () {
_this.documentHelper.owner.editorModule.deleteBookmark(_this.textBoxInput.value);
_this.show();
};
this.documentHelper = documentHelper;
}
BookmarkDialog.prototype.getModuleName = function () {
return 'BookmarkDialog';
};
BookmarkDialog.prototype.initBookmarkDialog = function (localValue, bookmarks, isRtl) {
var id = this.documentHelper.owner.containerId + '_insert_bookmark';
this.target = ej2_base_1.createElement('div', { id: id, className: 'e-de-bookmark' });
var headerValue = localValue.getConstant('Bookmark name') + ':';
this.dlgFields = ej2_base_1.createElement('div', { innerHTML: headerValue, className: 'e-bookmark-dlgfields' });
this.target.appendChild(this.dlgFields);
this.commonDiv = ej2_base_1.createElement('div', { className: 'e-bookmark-common' });
this.target.appendChild(this.commonDiv);
this.searchDiv = ej2_base_1.createElement('div', { className: 'e-bookmark-list' });
this.commonDiv.appendChild(this.searchDiv);
if (isRtl) {
this.searchDiv.classList.add('e-de-rtl');
}
this.textBoxDiv = ej2_base_1.createElement('div', { className: 'e-bookmark-textboxdiv' });
this.searchDiv.appendChild(this.textBoxDiv);
this.textBoxInput = ej2_base_1.createElement('input', { className: 'e-input e-bookmark-textbox-input', id: 'bookmark_text_box', attrs: { autofocus: 'true' } });
this.textBoxInput.setAttribute('type', 'text');
this.textBoxInput.setAttribute('aria-label', localValue.getConstant('Bookmark name'));
this.textBoxDiv.appendChild(this.textBoxInput);
this.listviewDiv = ej2_base_1.createElement('div', { className: 'e-bookmark-listViewDiv', id: 'bookmark_listview', attrs: { tabindex: '-1', role: 'listbox' } });
this.listviewDiv.setAttribute('aria-label', localValue.getConstant('BookMarkList'));
this.searchDiv.appendChild(this.listviewDiv);
this.listviewInstance = new ej2_lists_1.ListView({
dataSource: bookmarks,
cssClass: 'e-bookmark-listview'
});
var hasNoBookmark = (bookmarks === undefined || bookmarks.length === 0);
this.listviewInstance.appendTo(this.listviewDiv);
this.listviewInstance.addEventListener('select', this.listViewInstanceClickHandler);
this.buttonDiv = ej2_base_1.createElement('div', { className: 'e-bookmark-button' });
this.commonDiv.appendChild(this.buttonDiv);
this.addbuttonDiv = ej2_base_1.createElement('div', { className: 'e-bookmark-addbutton' });
this.buttonDiv.appendChild(this.addbuttonDiv);
this.addButtonElement = ej2_base_1.createElement('button', {
innerHTML: localValue.getConstant('Add'), id: 'add',
attrs: { type: 'button' }
});
this.addButtonElement.setAttribute('aria-label', localValue.getConstant('Add'));
this.addbuttonDiv.appendChild(this.addButtonElement);
this.addButton = new ej2_buttons_1.Button({ cssClass: 'e-button-custom' });
this.addButton.disabled = true;
this.addButton.appendTo(this.addButtonElement);
this.textBoxInput.addEventListener('input', this.onKeyUpOnTextBoxClickHandler);
this.textBoxInput.addEventListener('keyup', this.onKeyUpOnTextBoxClickHandler);
this.addButtonElement.addEventListener('click', this.addBookmarkClickHandler);
this.deleteButtonDiv = ej2_base_1.createElement('div', { className: 'e-bookmark-deletebutton' });
this.buttonDiv.appendChild(this.deleteButtonDiv);
this.deleteButtonElement = ej2_base_1.createElement('button', {
innerHTML: localValue.getConstant('Delete'), id: 'delete',
attrs: { type: 'button' }
});
this.deleteButtonElement.setAttribute('aria-label', localValue.getConstant('Delete'));
this.deleteButtonDiv.appendChild(this.deleteButtonElement);
this.deleteButton = new ej2_buttons_1.Button({ cssClass: 'e-button-custom' });
this.deleteButton.disabled = hasNoBookmark;
this.deleteButton.appendTo(this.deleteButtonElement);
this.deleteButtonElement.addEventListener('click', this.deleteBookmarkClickHandler);
this.gotoButtonDiv = ej2_base_1.createElement('div', { className: 'e-bookmark-gotobutton' });
this.buttonDiv.appendChild(this.gotoButtonDiv);
this.gotoButtonElement = ej2_base_1.createElement('button', {
innerHTML: localValue.getConstant('Go To'), id: 'goto',
attrs: { type: 'button' }
});
this.gotoButtonElement.setAttribute('aria-label', localValue.getConstant('Go To'));
this.gotoButtonDiv.appendChild(this.gotoButtonElement);
this.gotoButton = new ej2_buttons_1.Button({ cssClass: 'e-button-custom' });
this.gotoButton.disabled = hasNoBookmark;
this.gotoButton.appendTo(this.gotoButtonElement);
this.gotoButtonElement.addEventListener('click', this.gotoBookmarkClickHandler);
};
BookmarkDialog.prototype.onListInstanceClicked = function (args) {
this.selectHandler(args);
};
BookmarkDialog.prototype.onKeyUpOnTextBoxClicked = function () {
this.onKeyUpOnTextBox();
};
BookmarkDialog.prototype.onAddBookmarkClicked = function () {
this.addBookmark();
};
BookmarkDialog.prototype.onDeleteBookmarkClicked = function () {
this.deleteBookmark();
};
BookmarkDialog.prototype.onGotoBookmarkClicked = function () {
this.gotoBookmark();
};
BookmarkDialog.prototype.show = function () {
var bookmarks = this.documentHelper.getBookmarks();
var localObj = new ej2_base_1.L10n('documenteditor', this.documentHelper.owner.defaultLocale);
localObj.setLocale(this.documentHelper.owner.locale);
this.initBookmarkDialog(localObj, bookmarks, this.documentHelper.owner.enableRtl);
this.documentHelper.dialog.header = localObj.getConstant('Bookmark');
this.documentHelper.dialog.height = 'auto';
this.documentHelper.dialog.width = 'auto';
this.documentHelper.dialog.content = this.target;
this.documentHelper.dialog.beforeOpen = this.documentHelper.updateFocus;
this.documentHelper.dialog.close = this.documentHelper.updateFocus;
this.documentHelper.dialog.buttons = [{
click: this.removeObjects.bind(this),
buttonModel: { content: localObj.getConstant('Cancel'), cssClass: 'e-flat e-hyper-insert', isPrimary: true }
}];
this.documentHelper.dialog.dataBind();
var hasNoBookmark = (bookmarks === undefined || bookmarks.length === 0);
if (!hasNoBookmark) {
var firstItem = bookmarks[0];
this.listviewInstance.selectItem(firstItem);
}
this.documentHelper.dialog.show();
};
BookmarkDialog.prototype.enableOrDisableButton = function () {
var validRegex = /^[_a-zA-Z0-9]+$/;
var text = this.textBoxInput.value.trim();
Eif (!ej2_base_1.isNullOrUndefined(this.addButton)) {
this.addButton.disabled = !validRegex.test(text);
}
};
BookmarkDialog.prototype.focusTextBox = function (text) {
this.textBoxInput.value = text;
var value = document.getElementById('bookmark_text_box');
value.setSelectionRange(0, text.length);
value.focus();
this.enableOrDisableButton();
};
BookmarkDialog.prototype.removeObjects = function () {
this.documentHelper.hideDialog();
};
BookmarkDialog.prototype.destroy = function () {
this.removeEvents();
this.removeElements();
if (this.textBoxInput) {
this.textBoxInput.remove();
this.textBoxInput = undefined;
}
if (this.listviewInstance) {
this.listviewInstance.destroy();
this.listviewInstance = undefined;
}
this.documentHelper = undefined;
};
BookmarkDialog.prototype.removeElements = function () {
if (this.dlgFields) {
this.dlgFields.remove();
this.dlgFields = undefined;
}
if (this.commonDiv) {
this.commonDiv.remove();
this.commonDiv = undefined;
}
if (this.target) {
this.target.remove();
this.target = undefined;
}
if (this.textBoxDiv) {
this.textBoxDiv.remove();
this.textBoxDiv = undefined;
}
if (this.searchDiv) {
this.searchDiv.remove();
this.searchDiv = undefined;
}
if (this.listviewDiv) {
this.listviewDiv.remove();
this.listviewDiv = undefined;
}
if (this.buttonDiv) {
this.buttonDiv.remove();
this.buttonDiv = undefined;
}
if (this.addbuttonDiv) {
this.addbuttonDiv.remove();
this.addbuttonDiv = undefined;
}
if (this.deleteButtonDiv) {
this.deleteButtonDiv.remove();
this.deleteButtonDiv = undefined;
}
if (this.gotoButtonDiv) {
this.gotoButtonDiv.remove();
this.gotoButtonDiv = undefined;
}
if (this.addButtonElement) {
this.addButtonElement.remove();
this.addButtonElement = undefined;
}
if (this.deleteButtonElement) {
this.deleteButtonElement.remove();
this.deleteButtonElement = undefined;
}
if (this.gotoButtonElement) {
this.gotoButtonElement.remove();
this.gotoButtonElement = undefined;
}
if (this.addButton) {
this.addButton.destroy();
this.addButton = undefined;
}
if (this.deleteButton) {
this.deleteButton.destroy();
this.deleteButton = undefined;
}
if (this.gotoButton) {
this.gotoButton.destroy();
this.gotoButton = undefined;
}
};
BookmarkDialog.prototype.removeEvents = function () {
if (this.listviewInstance) {
this.listviewInstance.removeEventListener('select', this.listViewInstanceClickHandler);
}
if (this.textBoxInput) {
this.textBoxInput.removeEventListener('input', this.onKeyUpOnTextBoxClickHandler);
this.textBoxInput.removeEventListener('keyup', this.onKeyUpOnTextBoxClickHandler);
}
if (this.addButtonElement) {
this.addButtonElement.removeEventListener('click', this.addBookmarkClickHandler);
}
if (this.deleteButtonElement) {
this.deleteButtonElement.removeEventListener('click', this.deleteBookmarkClickHandler);
}
if (this.gotoButtonElement) {
this.gotoButtonElement.removeEventListener('click', this.gotoBookmarkClickHandler);
}
};
return BookmarkDialog;
}());
exports.BookmarkDialog = BookmarkDialog;
});
|