@progress/telerik-jquery-report-viewer 22.24.514 → 23.24.806

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/accessibility.js +28 -38
  3. package/dist/cjs/base-component.js +26 -0
  4. package/dist/cjs/binder.js +45 -138
  5. package/dist/cjs/controller.js +25 -25
  6. package/dist/cjs/documentMapArea.js +4 -13
  7. package/dist/cjs/event-emitter.js +124 -10
  8. package/dist/cjs/index.js +2 -0
  9. package/dist/cjs/mainMenu.js +22 -31
  10. package/dist/cjs/pagesArea.js +8 -27
  11. package/dist/cjs/parameterValidators.js +4 -7
  12. package/dist/cjs/parameters.js +13 -13
  13. package/dist/cjs/parametersArea.js +36 -49
  14. package/dist/cjs/print.js +3 -4
  15. package/dist/cjs/reportViewer.js +38 -27
  16. package/dist/cjs/scroll.js +4 -6
  17. package/dist/cjs/search.js +327 -377
  18. package/dist/cjs/sendEmail.js +52 -95
  19. package/dist/cjs/serviceClient.js +163 -257
  20. package/dist/cjs/sideMenu.js +15 -24
  21. package/dist/cjs/sr.js +4 -4
  22. package/dist/cjs/template-cache.js +6 -6
  23. package/dist/cjs/toolbar/link-button.js +42 -0
  24. package/dist/cjs/toolbar/page-count-label.js +18 -0
  25. package/dist/cjs/toolbar/page-number-input.js +64 -0
  26. package/dist/cjs/uiFreezeCoordinator.js +17 -16
  27. package/dist/cjs/utils.js +11 -14
  28. package/dist/es/accessibility.js +29 -39
  29. package/dist/es/base-component.js +22 -0
  30. package/dist/es/binder.js +45 -138
  31. package/dist/es/controller.js +26 -26
  32. package/dist/es/documentMapArea.js +4 -13
  33. package/dist/es/event-emitter.js +124 -10
  34. package/dist/es/index.js +1 -0
  35. package/dist/es/mainMenu.js +23 -32
  36. package/dist/es/pagesArea.js +9 -28
  37. package/dist/es/parameterValidators.js +5 -8
  38. package/dist/es/parameters.js +14 -14
  39. package/dist/es/parametersArea.js +37 -50
  40. package/dist/es/print.js +4 -5
  41. package/dist/es/reportViewer.js +39 -28
  42. package/dist/es/scroll.js +4 -6
  43. package/dist/es/search.js +328 -378
  44. package/dist/es/sendEmail.js +52 -95
  45. package/dist/es/serviceClient.js +164 -258
  46. package/dist/es/sideMenu.js +16 -25
  47. package/dist/es/sr.js +4 -4
  48. package/dist/es/template-cache.js +7 -7
  49. package/dist/es/toolbar/link-button.js +38 -0
  50. package/dist/es/toolbar/page-count-label.js +14 -0
  51. package/dist/es/toolbar/page-number-input.js +60 -0
  52. package/dist/es/uiFreezeCoordinator.js +17 -16
  53. package/dist/es/utils.js +11 -14
  54. package/dist/font/font-icons.css +4 -4
  55. package/dist/font/font-icons.min.css +3 -3
  56. package/dist/js/telerikReportViewer.js +1080 -1190
  57. package/dist/js/telerikReportViewer.min.js +1 -1
  58. package/dist/js/telerikReportViewer.stringResources.js +4 -4
  59. package/dist/styles/telerikReportViewer.css +3 -3
  60. package/dist/styles/telerikReportViewer.min.css +3 -3
  61. package/dist/templates/telerikReportViewerTemplate-FA.html +4 -4
  62. package/dist/templates/telerikReportViewerTemplate.html +6 -6
  63. package/package.json +3 -2
  64. /package/dist/font/{ReportingIcons-18.1.24.514.ttf → ReportingIcons-18.2.24.806.ttf} +0 -0
package/dist/es/search.js CHANGED
@@ -1,148 +1,195 @@
1
- import { each, stringFormat } from './utils.js';
1
+ import { stringFormat } from './utils.js';
2
2
  import { stringResources } from './stringResources.js';
3
3
  import { Binder } from './binder.js';
4
4
  import { PageModes } from './enums.js';
5
+ import { Command } from './command.js';
5
6
 
6
7
  var defaultOptions = {};
7
- function Search(placeholder, options, viewerOptions) {
8
- options = $.extend({}, defaultOptions, options);
9
- var controller = options.controller;
10
- var initialized = false;
11
- var dialogVisible = false;
12
- var $placeholder;
13
- var $inputBox;
14
- var $searchOptionsPlaceholder;
15
- var searchOptionsMenu;
16
- var $stopSearchPlaceholder;
17
- var stopSearchMenu;
18
- var $navigationPlaceholder;
19
- var navigationMenu;
20
- var $resultsLabel;
21
- var $resultsPlaceholder;
22
- var kendoComboBox;
23
- var kendoSearchDialog;
24
- var stopSearchCommand;
25
- var optionsCommandSet;
26
- var navigationCommandSet;
27
- var searchResults;
28
- var mruList = [];
29
- var inputComboRebinding;
30
- var searchMetadataRequested;
31
- var searchMetadataLoaded;
32
- var pendingHighlightItem;
33
- var windowLocation;
34
- var reportViewerWrapper = $("[data-selector='" + viewerOptions.viewerSelector + "']").find(".trv-report-viewer");
35
- var lastSearch = "";
36
- var highlightManager = {
37
- shadedClassName: "trv-search-dialog-shaded-result",
38
- //the results that are found, but not selected (highlighted)
39
- highlightedClassName: "trv-search-dialog-highlighted-result",
40
- //the result that is currently selected (highlighted)
41
- current: null,
42
- elements: []
43
- };
44
- if (!controller) {
45
- throw "No controller (telerikReporting.ReportViewerController) has been specified.";
46
- }
47
- controller.pageReady(onPageReady).scrollPageReady(onPageReady).beginLoadReport(closeAndClear).viewModeChanged(closeAndClear);
48
- controller.setSendEmailDialogVisible(function(event, args) {
49
- if (args.visible && dialogVisible) {
50
- toggle(!dialogVisible);
51
- }
52
- }).getSearchDialogState(function(event, args) {
53
- args.visible = dialogVisible;
54
- }).setSearchDialogVisible(function(event, args) {
55
- toggleSearchDialog(args.visible);
56
- });
57
- function closeAndClear() {
58
- if (searchMetadataRequested) {
8
+ function replaceStringResources($search) {
9
+ if (!$search) {
10
+ return;
11
+ }
12
+ var $searchCaption = $search.find(".trv-search-dialog-caption-label");
13
+ var $searchOptions = $search.find(".trv-search-dialog-search-options");
14
+ var $searchStopButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_StopSearch']");
15
+ var $searchMatchCaseButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_MatchCase']");
16
+ var $searchMatchWholeWordButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_MatchWholeWord']");
17
+ var $searchUseRegexButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_UseRegex']");
18
+ var $searchNavigateUpButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_NavigateUp']");
19
+ var $searchNavigateDownButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_NavigateDown']");
20
+ replaceAttribute($search, "aria-label");
21
+ replaceAttribute($searchOptions, "aria-label");
22
+ replaceText($searchCaption);
23
+ replaceTitleAndAriaLabel($searchStopButton);
24
+ replaceTitleAndAriaLabel($searchMatchCaseButton);
25
+ replaceTitleAndAriaLabel($searchMatchWholeWordButton);
26
+ replaceTitleAndAriaLabel($searchUseRegexButton);
27
+ replaceTitleAndAriaLabel($searchNavigateUpButton);
28
+ replaceTitleAndAriaLabel($searchNavigateDownButton);
29
+ }
30
+ function replaceTitleAndAriaLabel($a) {
31
+ replaceAttribute($a, "title");
32
+ replaceAttribute($a, "aria-label");
33
+ }
34
+ function replaceText($el) {
35
+ if ($el) {
36
+ $el.text(stringResources[$el.text()]);
37
+ }
38
+ }
39
+ function replaceAttribute($el, attribute) {
40
+ if ($el) {
41
+ $el.attr(attribute, stringResources[$el.attr(attribute)]);
42
+ }
43
+ }
44
+ class Search {
45
+ constructor(element, options, viewerOptions) {
46
+ this.options = $.extend({}, defaultOptions, options);
47
+ this.viewerOptions = viewerOptions;
48
+ this.element = element;
49
+ this.controller = this.options.controller;
50
+ this.initialized = false;
51
+ this.dialogVisible = false;
52
+ this.$element;
53
+ this.$inputBox;
54
+ this.$searchOptionsPlaceholder;
55
+ this.searchOptionsMenu;
56
+ this.$stopSearchPlaceholder;
57
+ this.stopSearchMenu;
58
+ this.$navigationPlaceholder;
59
+ this.navigationMenu;
60
+ this.$resultsLabel;
61
+ this.$resultsPlaceholder;
62
+ this.kendoComboBox;
63
+ this.kendoSearchDialog;
64
+ this.stopSearchCommand;
65
+ this.optionsCommandSet;
66
+ this.navigationCommandSet;
67
+ this.searchResults;
68
+ this.mruList = [];
69
+ this.inputComboRebinding;
70
+ this.searchMetadataRequested;
71
+ this.searchMetadataLoaded;
72
+ this.pendingHighlightItem;
73
+ this.windowLocation;
74
+ this.reportViewerWrapper = $("[data-selector='" + this.viewerOptions.viewerSelector + "']").find(".trv-report-viewer");
75
+ this.lastSearch = "";
76
+ this.highlightManager = {
77
+ // the results that are found, but not selected (highlighted)
78
+ shadedClassName: "trv-search-dialog-shaded-result",
79
+ // the result that is currently selected (highlighted)
80
+ highlightedClassName: "trv-search-dialog-highlighted-result",
81
+ current: null,
82
+ elements: []
83
+ };
84
+ if (!this.controller) {
85
+ throw "No controller (telerikReporting.ReportViewerController) has been specified.";
86
+ }
87
+ this.controller.pageReady(this.onPageReady.bind(this)).scrollPageReady(this.onPageReady.bind(this)).beginLoadReport(this.closeAndClear.bind(this)).viewModeChanged(this.closeAndClear.bind(this));
88
+ this.controller.setSendEmailDialogVisible((event, args) => {
89
+ if (args.visible && this.dialogVisible) {
90
+ this.toggle(!this.dialogVisible);
91
+ }
92
+ }).getSearchDialogState((event, args) => {
93
+ args.visible = this.dialogVisible;
94
+ }).setSearchDialogVisible((event, args) => {
95
+ this.toggleSearchDialog(args.visible);
96
+ });
97
+ $(window).on("resize", () => {
98
+ if (this.kendoSearchDialog && this.kendoSearchDialog.options.visible) {
99
+ this.storeDialogPosition();
100
+ this.adjustDialogPosition();
101
+ }
102
+ });
103
+ }
104
+ closeAndClear() {
105
+ if (this.searchMetadataRequested) {
59
106
  return;
60
107
  }
61
- toggle(false);
62
- searchMetadataLoaded = false;
108
+ this.toggle(false);
109
+ this.searchMetadataLoaded = false;
63
110
  }
64
- function toggleSearchDialog(show) {
65
- dialogVisible = show;
111
+ toggleSearchDialog(show) {
112
+ this.dialogVisible = show;
66
113
  if (show) {
67
- var searchMetadataOnDemand = viewerOptions.searchMetadataOnDemand;
68
- if (searchMetadataOnDemand && !searchMetadataLoaded) {
69
- searchMetadataRequested = true;
70
- controller.reportLoadComplete(function() {
71
- if (searchMetadataRequested) {
72
- toggle(true);
73
- searchMetadataRequested = false;
114
+ var searchMetadataOnDemand = this.viewerOptions.searchMetadataOnDemand;
115
+ if (searchMetadataOnDemand && !this.searchMetadataLoaded) {
116
+ this.searchMetadataRequested = true;
117
+ this.controller.reportLoadComplete((event, args) => {
118
+ if (this.searchMetadataRequested) {
119
+ this.toggle(true);
120
+ this.searchMetadataRequested = false;
74
121
  }
75
122
  });
76
- controller.refreshReport(true);
123
+ this.controller.refreshReport(true);
77
124
  return;
78
125
  }
79
126
  }
80
- toggle(show);
127
+ this.toggle(show);
81
128
  }
82
- function toggle(show) {
83
- dialogVisible = show;
129
+ toggle(show) {
130
+ this.dialogVisible = show;
84
131
  if (show) {
85
- searchMetadataLoaded = true;
86
- ensureInitialized();
87
- kendoSearchDialog.open();
88
- kendoComboBox.value("");
89
- updateResultsUI(null);
90
- toggleErrorLabel(false, null);
132
+ this.searchMetadataLoaded = true;
133
+ this.ensureInitialized();
134
+ this.kendoSearchDialog.open();
135
+ this.kendoComboBox.value("");
136
+ this.updateResultsUI(null);
137
+ this.toggleErrorLabel(false, null);
91
138
  } else {
92
- clearColoredItems();
93
- if (kendoSearchDialog && kendoSearchDialog.options.visible) {
94
- kendoSearchDialog.close();
139
+ this.clearColoredItems();
140
+ if (this.kendoSearchDialog && this.kendoSearchDialog.options.visible) {
141
+ this.kendoSearchDialog.close();
95
142
  }
96
143
  }
97
144
  }
98
- function ensureInitialized() {
99
- if (!initialized) {
100
- $placeholder = $(placeholder);
101
- $inputBox = $placeholder.find(".trv-search-dialog-input-box");
102
- $resultsLabel = $placeholder.find(".trv-search-dialog-results-label");
103
- $resultsPlaceholder = $placeholder.find(".trv-search-dialog-results-area");
104
- initResultsArea();
105
- replaceStringResources($placeholder);
145
+ ensureInitialized() {
146
+ if (!this.initialized) {
147
+ this.$element = $(this.element);
148
+ this.$inputBox = this.$element.find(".trv-search-dialog-input-box");
149
+ this.$resultsLabel = this.$element.find(".trv-search-dialog-results-label");
150
+ this.$resultsPlaceholder = this.$element.find(".trv-search-dialog-results-area");
151
+ this.initResultsArea();
152
+ replaceStringResources(this.$element);
106
153
  try {
107
- $searchOptionsPlaceholder = $placeholder.find(".trv-search-dialog-search-options").kendoMenu();
108
- $stopSearchPlaceholder = $placeholder.find(".trv-search-dialog-stopsearch-placeholder").kendoMenu();
109
- $navigationPlaceholder = $placeholder.find(".trv-search-dialog-navigational-buttons").kendoMenu();
110
- } catch (e) {
111
- console.error("Instantiation of Kendo Menu for Search Dialog threw an exception", e);
112
- throw e;
154
+ this.$searchOptionsPlaceholder = this.$element.find(".trv-search-dialog-search-options").kendoMenu();
155
+ this.$stopSearchPlaceholder = this.$element.find(".trv-search-dialog-stopsearch-placeholder").kendoMenu();
156
+ this.$navigationPlaceholder = this.$element.find(".trv-search-dialog-navigational-buttons").kendoMenu();
157
+ } catch (error) {
158
+ console.error("Instantiation of Kendo Menu for Search Dialog threw an exception", error);
159
+ throw error;
113
160
  }
114
- searchOptionsMenu = $searchOptionsPlaceholder.data("kendoMenu");
115
- stopSearchMenu = $stopSearchPlaceholder.data("kendoMenu");
116
- navigationMenu = $navigationPlaceholder.data("kendoMenu");
117
- searchOptionsMenu.element.on("keydown", onKeyDown);
118
- stopSearchMenu.element.on("keydown", onKeyDown);
119
- navigationMenu.element.on("keydown", onKeyDown);
120
- overrideDefaultMenuStyling(".trv-search-dialog-search-options");
161
+ this.searchOptionsMenu = this.$searchOptionsPlaceholder.data("kendoMenu");
162
+ this.stopSearchMenu = this.$stopSearchPlaceholder.data("kendoMenu");
163
+ this.navigationMenu = this.$navigationPlaceholder.data("kendoMenu");
164
+ this.searchOptionsMenu.element.on("keydown", this.onKeyDown);
165
+ this.stopSearchMenu.element.on("keydown", this.onKeyDown);
166
+ this.navigationMenu.element.on("keydown", this.onKeyDown);
167
+ this.overrideDefaultMenuStyling(".trv-search-dialog-search-options");
121
168
  try {
122
- kendoComboBox = $inputBox.kendoComboBox({
169
+ this.kendoComboBox = this.$inputBox.kendoComboBox({
123
170
  dataTextField: "value",
124
171
  dataValueField: "value",
125
- dataSource: mruList,
172
+ dataSource: this.mruList,
126
173
  contentElement: "",
127
- change: kendoComboBoxSelect,
174
+ change: this.kendoComboBoxSelect.bind(this),
128
175
  ignoreCase: false,
129
- filtering: onInputFiltering,
130
- //the actual search-when-typing performs on this event.
176
+ // the actual search-when-typing performs on this event.
177
+ filtering: this.onInputFiltering.bind(this),
131
178
  filter: "startswith",
132
179
  delay: 1e3,
133
- open: function(e) {
134
- if (inputComboRebinding) {
135
- e.preventDefault();
180
+ open: (event) => {
181
+ if (this.inputComboRebinding) {
182
+ event.preventDefault();
136
183
  }
137
184
  },
138
- select: processComboBoxEvent
185
+ select: this.processComboBoxEvent.bind(this)
139
186
  }).data("kendoComboBox");
140
- } catch (e) {
141
- console.error("Instantiation of Kendo ComboBox as search input threw an exception", e);
142
- throw e;
187
+ } catch (error) {
188
+ console.error("Instantiation of Kendo ComboBox as search input threw an exception", error);
189
+ throw error;
143
190
  }
144
191
  try {
145
- kendoSearchDialog = reportViewerWrapper.find(".trv-search-window").kendoWindow({
192
+ this.kendoSearchDialog = this.reportViewerWrapper.find(".trv-search-window").kendoWindow({
146
193
  title: stringResources.searchDialogTitle,
147
194
  height: 390,
148
195
  width: 310,
@@ -150,38 +197,38 @@ function Search(placeholder, options, viewerOptions) {
150
197
  minHeight: 390,
151
198
  maxHeight: 700,
152
199
  scrollable: false,
153
- close: function() {
154
- storeDialogPosition();
155
- lastSearch = "";
200
+ close: () => {
201
+ this.storeDialogPosition();
202
+ this.lastSearch = "";
156
203
  },
157
- open: function() {
158
- adjustDialogPosition();
204
+ open: () => {
205
+ this.adjustDialogPosition();
159
206
  },
160
- deactivate: function() {
161
- controller.setSearchDialogVisible({
207
+ deactivate: () => {
208
+ this.controller.setSearchDialogVisible({
162
209
  visible: false
163
210
  });
164
211
  },
165
- activate: function() {
166
- kendoComboBox.input.focus();
212
+ activate: () => {
213
+ this.kendoComboBox.input.focus();
167
214
  }
168
215
  }).data("kendoWindow");
169
- } catch (e) {
170
- console.error("Instantiation of Kendo Window for Search dialog threw an exception", e);
171
- throw e;
216
+ } catch (error) {
217
+ console.error("Instantiation of Kendo Window for Search dialog threw an exception", error);
218
+ throw error;
172
219
  }
173
- kendoSearchDialog.wrapper.addClass("trv-search");
174
- initCommands();
175
- initialized = true;
220
+ this.kendoSearchDialog.wrapper.addClass("trv-search");
221
+ this.initCommands();
222
+ this.initialized = true;
176
223
  }
177
224
  }
178
- function overrideDefaultMenuStyling(kendoMenuSelector) {
225
+ overrideDefaultMenuStyling(kendoMenuSelector) {
179
226
  var menuItems = $(kendoMenuSelector).find(".k-menu-item");
180
227
  for (var i = 0; i < menuItems.length; i++) {
181
228
  $(menuItems[i]).removeClass("k-item");
182
229
  }
183
230
  }
184
- function onKeyDown(event) {
231
+ onKeyDown(event) {
185
232
  var item = $(event.target).find(".k-focus");
186
233
  if (event.keyCode === 13 && item && item.length > 0) {
187
234
  var anchor = item.children("a");
@@ -190,44 +237,38 @@ function Search(placeholder, options, viewerOptions) {
190
237
  }
191
238
  }
192
239
  }
193
- $(window).resize(function() {
194
- if (kendoSearchDialog && kendoSearchDialog.options.visible) {
195
- storeDialogPosition();
196
- adjustDialogPosition();
197
- }
198
- });
199
- function storeDialogPosition() {
200
- var kendoWindow = kendoSearchDialog.element.parent(".k-window");
201
- windowLocation = kendoWindow.offset();
240
+ storeDialogPosition() {
241
+ var kendoWindow = this.kendoSearchDialog.element.parent(".k-window");
242
+ this.windowLocation = kendoWindow.offset();
202
243
  }
203
- function adjustDialogPosition() {
244
+ adjustDialogPosition() {
204
245
  var windowWidth = $(window).innerWidth();
205
246
  var windowHeight = $(window).innerHeight();
206
- var kendoWindow = kendoSearchDialog.wrapper;
247
+ var kendoWindow = this.kendoSearchDialog.wrapper;
207
248
  var width = kendoWindow.outerWidth(true);
208
249
  var height = kendoWindow.outerHeight(true);
209
250
  var padding = 10;
210
- if (!windowLocation) {
211
- var reportViewerCoords = reportViewerWrapper[0].getBoundingClientRect();
251
+ if (!this.windowLocation) {
252
+ var reportViewerCoords = this.reportViewerWrapper[0].getBoundingClientRect();
212
253
  kendoWindow.css({
213
254
  top: reportViewerCoords.top + padding,
214
255
  left: reportViewerCoords.right - width - padding
215
256
  });
216
- kendoSearchDialog.setOptions({
257
+ this.kendoSearchDialog.setOptions({
217
258
  position: {
218
259
  top: reportViewerCoords.top + padding,
219
260
  left: reportViewerCoords.right - width - padding
220
261
  }
221
262
  });
222
263
  } else {
223
- var left = windowLocation.left;
224
- var top = windowLocation.top;
264
+ var left = this.windowLocation.left;
265
+ var top = this.windowLocation.top;
225
266
  var right = left + width;
226
267
  var bottom = top + height;
227
268
  if (right > windowWidth - padding) {
228
269
  left = Math.max(padding, windowWidth - width - padding);
229
270
  kendoWindow.css({ left });
230
- kendoSearchDialog.setOptions({
271
+ this.kendoSearchDialog.setOptions({
231
272
  position: {
232
273
  left
233
274
  }
@@ -236,7 +277,7 @@ function Search(placeholder, options, viewerOptions) {
236
277
  if (bottom > windowHeight - padding) {
237
278
  top = Math.max(padding, windowHeight - height - padding);
238
279
  kendoWindow.css({ top });
239
- kendoSearchDialog.setOptions({
280
+ this.kendoSearchDialog.setOptions({
240
281
  position: {
241
282
  top
242
283
  }
@@ -244,272 +285,251 @@ function Search(placeholder, options, viewerOptions) {
244
285
  }
245
286
  }
246
287
  }
247
- function processComboBoxEvent(e) {
288
+ processComboBoxEvent(event) {
248
289
  if (!(window.event || window.event.type)) {
249
290
  return;
250
291
  }
251
292
  var evt = window.event;
252
293
  if (evt.type === "keydown") {
253
- e.preventDefault();
294
+ event.preventDefault();
254
295
  if (evt.keyCode === 40) {
255
- moveListSelection(1);
256
- } else if (evt.keyCode === 38) {
257
- moveListSelection(-1);
296
+ this.moveListSelection(1);
297
+ }
298
+ if (evt.keyCode === 38) {
299
+ this.moveListSelection(-1);
258
300
  }
259
301
  }
260
302
  }
261
- function initCommands() {
262
- optionsCommandSet = {
263
- //the command names MUST match the commands in the template.html with the "telerik_Reportviewer" prefix so the binder could work.
264
- "searchDialog_MatchCase": new command(function() {
265
- toggleCommand(this);
266
- }),
267
- "searchDialog_MatchWholeWord": new command(function() {
268
- toggleCommand(this);
269
- }),
270
- "searchDialog_UseRegex": new command(function() {
271
- toggleCommand(this);
272
- })
303
+ initCommands() {
304
+ this.optionsCommandSet = {
305
+ "searchDialog_MatchCase": new Command(),
306
+ "searchDialog_MatchWholeWord": new Command(),
307
+ "searchDialog_UseRegex": new Command()
273
308
  };
274
- Binder.bind(
275
- $searchOptionsPlaceholder,
276
- {
277
- controller,
278
- commands: optionsCommandSet
279
- },
280
- viewerOptions
281
- );
282
- stopSearchCommand = new command(function() {
283
- stopSearch();
309
+ Object.entries(this.optionsCommandSet).forEach(([commandName, command]) => {
310
+ command.exec = () => {
311
+ this.toggleCommand(command);
312
+ };
284
313
  });
285
- Binder.bind(
286
- $stopSearchPlaceholder,
287
- {
288
- controller,
289
- commands: { "searchDialog_StopSearch": stopSearchCommand }
290
- },
291
- viewerOptions
292
- );
293
- navigationCommandSet = {
294
- "searchDialog_NavigateUp": new command(function() {
295
- moveListSelection(-1);
314
+ Binder.attachCommands(this.$searchOptionsPlaceholder, this.optionsCommandSet, this.viewerOptions);
315
+ this.stopSearchCommand = new Command(() => {
316
+ this.stopSearch();
317
+ });
318
+ Binder.attachCommands(this.$stopSearchPlaceholder, { "searchDialog_StopSearch": this.stopSearchCommand }, this.viewerOptions);
319
+ this.navigationCommandSet = {
320
+ "searchDialog_NavigateUp": new Command(() => {
321
+ this.moveListSelection(-1);
296
322
  }),
297
- "searchDialog_NavigateDown": new command(function() {
298
- moveListSelection(1);
323
+ "searchDialog_NavigateDown": new Command(() => {
324
+ this.moveListSelection(1);
299
325
  })
300
326
  };
301
- Binder.bind(
302
- $navigationPlaceholder,
303
- {
304
- controller,
305
- commands: navigationCommandSet
306
- },
307
- viewerOptions
308
- );
327
+ Binder.attachCommands(this.$navigationPlaceholder, this.navigationCommandSet, this.viewerOptions);
309
328
  }
310
- function initResultsArea() {
329
+ initResultsArea() {
311
330
  try {
312
- $resultsPlaceholder.kendoListView({
331
+ this.$resultsPlaceholder.kendoListView({
313
332
  selectable: true,
314
333
  navigatable: true,
315
334
  dataSource: {},
316
335
  contentElement: "",
317
336
  template: "<div class='trv-search-dialog-results-row'><span>#: description #</span> <span class='trv-search-dialog-results-pageSpan'>" + stringResources.searchDialogPageText + " #:page#</span></div>",
318
- change: function() {
319
- var index = this.select().index();
320
- var view = this.dataSource.view();
337
+ change: (event) => {
338
+ var listView = event.sender;
339
+ var index = listView.select().index();
340
+ var view = listView.dataSource.view();
321
341
  var dataItem = view[index];
322
- onSelectedItem(dataItem);
323
- updateUI(index, view.length);
342
+ this.onSelectedItem(dataItem);
343
+ this.updateUI(index, view.length);
324
344
  }
325
345
  });
326
- } catch (e) {
327
- console.error("Instantiation of Kendo ListView as search result area threw an exception", e);
328
- throw e;
346
+ } catch (error) {
347
+ console.error("Instantiation of Kendo ListView as search result area threw an exception", error);
348
+ throw error;
329
349
  }
330
350
  }
331
- function stopSearch() {
332
- setStopButtonEnabledState(false);
351
+ stopSearch() {
352
+ this.setStopButtonEnabledState(false);
333
353
  }
334
- function toggleCommand(cmd) {
354
+ toggleCommand(cmd) {
335
355
  cmd.checked(!cmd.checked());
336
- searchForCurrentToken();
356
+ this.searchForCurrentToken();
337
357
  }
338
- function setStopButtonEnabledState(enabledState) {
339
- stopSearchCommand.enabled(enabledState);
358
+ setStopButtonEnabledState(enabledState) {
359
+ this.stopSearchCommand.enabled(enabledState);
340
360
  }
341
- function onPageReady(args, page) {
342
- if (dialogVisible) {
343
- colorPageElements(searchResults);
361
+ onPageReady(args, page) {
362
+ if (this.dialogVisible) {
363
+ this.colorPageElements(this.searchResults);
344
364
  }
345
365
  }
346
- function onInputFiltering(e) {
347
- e.preventDefault();
348
- if (e.filter && e.filter.value !== lastSearch) {
349
- lastSearch = e.filter.value;
350
- searchForToken(lastSearch);
366
+ onInputFiltering(event) {
367
+ event.preventDefault();
368
+ if (event.filter && event.filter.value !== this.lastSearch) {
369
+ this.lastSearch = event.filter.value;
370
+ this.searchForToken(this.lastSearch);
351
371
  }
352
372
  }
353
- function kendoComboBoxSelect(e) {
354
- var newValue = e.sender.value();
355
- if (newValue && lastSearch !== newValue) {
356
- lastSearch = newValue;
357
- searchForToken(lastSearch);
373
+ kendoComboBoxSelect(event) {
374
+ var newValue = event.sender.value();
375
+ if (newValue && this.lastSearch !== newValue) {
376
+ this.lastSearch = newValue;
377
+ this.searchForToken(this.lastSearch);
358
378
  }
359
379
  }
360
- function searchForCurrentToken() {
361
- if (kendoComboBox) {
362
- searchForToken(kendoComboBox.value());
380
+ searchForCurrentToken() {
381
+ if (this.kendoComboBox) {
382
+ this.searchForToken(this.kendoComboBox.value());
363
383
  }
364
384
  }
365
- function searchForToken(token) {
366
- onSearchStarted();
367
- addToMRU(token);
368
- controller.getSearchResults(
385
+ searchForToken(token) {
386
+ this.onSearchStarted();
387
+ this.addToMRU(token);
388
+ this.controller.getSearchResults(
369
389
  {
370
390
  searchToken: token,
371
- matchCase: optionsCommandSet.searchDialog_MatchCase.checked(),
372
- matchWholeWord: optionsCommandSet.searchDialog_MatchWholeWord.checked(),
373
- useRegex: optionsCommandSet.searchDialog_UseRegex.checked()
391
+ matchCase: this.optionsCommandSet.searchDialog_MatchCase.checked(),
392
+ matchWholeWord: this.optionsCommandSet.searchDialog_MatchWholeWord.checked(),
393
+ useRegex: this.optionsCommandSet.searchDialog_UseRegex.checked()
374
394
  }
375
- ).then(function(results) {
376
- updateResultsUI(results, null);
377
- }).catch(function(errorMessage) {
395
+ ).then((results) => {
396
+ this.updateResultsUI(results, null);
397
+ }).catch((errorMessage) => {
378
398
  if (errorMessage) {
379
- updateResultsUI(null, errorMessage);
399
+ this.updateResultsUI(null, errorMessage);
380
400
  }
381
401
  });
382
402
  }
383
- function onSearchStarted() {
384
- $resultsLabel.text(stringResources.searchDialogSearchInProgress);
385
- clearColoredItems();
386
- searchResults = null;
387
- setStopButtonEnabledState(true);
388
- toggleErrorLabel(false, null);
403
+ onSearchStarted() {
404
+ this.$resultsLabel.text(stringResources.searchDialogSearchInProgress);
405
+ this.clearColoredItems();
406
+ this.searchResults = null;
407
+ this.setStopButtonEnabledState(true);
408
+ this.toggleErrorLabel(false, null);
389
409
  }
390
- function updateResultsUI(results, error) {
391
- setStopButtonEnabledState(false);
410
+ updateResultsUI(results, error) {
411
+ this.setStopButtonEnabledState(false);
392
412
  if (error) {
393
- toggleErrorLabel(true, error);
413
+ this.toggleErrorLabel(true, error);
394
414
  }
395
- displayResultsList(results);
396
- searchResults = results;
415
+ this.displayResultsList(results);
416
+ this.searchResults = results;
397
417
  if (results && results.length > 0) {
398
- colorPageElements(results);
399
- selectFirstElement();
418
+ this.colorPageElements(results);
419
+ this.selectFirstElement();
400
420
  } else {
401
- updateUI(-1, 0);
421
+ this.updateUI(-1, 0);
402
422
  }
403
423
  }
404
- function addToMRU(token) {
424
+ addToMRU(token) {
405
425
  if (!token || token === "") {
406
426
  return;
407
427
  }
408
- var exists = mruList.filter(function(mru) {
428
+ var exists = this.mruList.filter((mru) => {
409
429
  return mru.value === token;
410
430
  });
411
431
  if (exists && exists.length > 0) {
412
432
  return;
413
433
  }
414
- mruList.unshift({ value: token });
415
- if (mruList.length > 10) {
416
- mruList.pop();
434
+ this.mruList.unshift({ value: token });
435
+ if (this.mruList.length > 10) {
436
+ this.mruList.pop();
417
437
  }
418
- inputComboRebinding = true;
419
- kendoComboBox.dataSource.data(mruList);
420
- kendoComboBox.select(function(item) {
438
+ this.inputComboRebinding = true;
439
+ this.kendoComboBox.dataSource.data(this.mruList);
440
+ this.kendoComboBox.select((item) => {
421
441
  return item.value === token;
422
442
  });
423
- inputComboRebinding = false;
443
+ this.inputComboRebinding = false;
424
444
  }
425
- function displayResultsList(results) {
426
- var $listView = $resultsPlaceholder.data("kendoListView");
445
+ displayResultsList(results) {
446
+ var $listView = this.$resultsPlaceholder.data("kendoListView");
427
447
  if (!results) {
428
448
  results = [];
429
449
  }
430
450
  $listView.dataSource.data(results);
431
451
  }
432
- function colorPageElements(results) {
452
+ colorPageElements(results) {
433
453
  if (!results || results.length === 0) {
434
454
  return;
435
455
  }
436
- var $parent = $placeholder.parent();
456
+ var $parent = this.$element.parent();
437
457
  var $pageContainer = $parent.find(".trv-page-container");
438
458
  var elements = $pageContainer.find("[data-search-id]");
439
- each(results, function() {
440
- var $searchElement = elements.filter("[data-search-id=" + this.id + "]");
459
+ Array.from(results).forEach((result) => {
460
+ var $searchElement = elements.filter("[data-search-id=" + result.id + "]");
441
461
  if ($searchElement) {
442
- $searchElement.addClass(highlightManager.shadedClassName);
443
- highlightManager.elements.push($searchElement);
462
+ $searchElement.addClass(this.highlightManager.shadedClassName);
463
+ this.highlightManager.elements.push($searchElement);
444
464
  }
445
465
  });
446
- highlightItem(pendingHighlightItem);
447
- pendingHighlightItem = null;
466
+ this.highlightItem(this.pendingHighlightItem);
467
+ this.pendingHighlightItem = null;
448
468
  }
449
- function highlightItem(item) {
469
+ highlightItem(item) {
450
470
  if (item) {
451
471
  var currentItemId = item.id;
452
- var newHighlighted = $(highlightManager.elements.filter(function(i) {
472
+ var newHighlighted = $(this.highlightManager.elements.filter((i) => {
453
473
  return i.attr("data-search-id") === currentItemId;
454
474
  })).first();
455
475
  if (newHighlighted) {
456
- highlightManager.current = newHighlighted[0];
457
- if (highlightManager.current) {
476
+ this.highlightManager.current = newHighlighted[0];
477
+ if (this.highlightManager.current) {
458
478
  var current = $("[data-search-id='" + currentItemId + "']");
459
- current.removeClass(highlightManager.shadedClassName);
460
- current.addClass(highlightManager.highlightedClassName);
479
+ current.removeClass(this.highlightManager.shadedClassName);
480
+ current.addClass(this.highlightManager.highlightedClassName);
461
481
  }
462
482
  }
463
483
  }
464
484
  }
465
- function selectFirstElement() {
466
- var $listView = $resultsPlaceholder.data("kendoListView");
485
+ selectFirstElement() {
486
+ var $listView = this.$resultsPlaceholder.data("kendoListView");
467
487
  var first = $listView.element.children().first();
468
488
  $listView.select(first);
469
489
  $listView.trigger("change");
470
490
  }
471
- function onSelectedItem(item) {
491
+ onSelectedItem(item) {
472
492
  if (!item) {
473
493
  return;
474
494
  }
475
- if (highlightManager.current) {
476
- highlightManager.current.removeClass(highlightManager.highlightedClassName);
477
- highlightManager.current.addClass(highlightManager.shadedClassName);
495
+ if (this.highlightManager.current) {
496
+ this.highlightManager.current.removeClass(this.highlightManager.highlightedClassName);
497
+ this.highlightManager.current.addClass(this.highlightManager.shadedClassName);
478
498
  }
479
- if (item.page === controller.getCurrentPageNumber()) {
480
- highlightItem(item);
499
+ if (item.page === this.controller.getCurrentPageNumber()) {
500
+ this.highlightItem(item);
481
501
  } else {
482
- if (controller.getPageMode() !== PageModes.CONTINUOUS_SCROLL) {
483
- clearColoredItems();
502
+ if (this.controller.getPageMode() !== PageModes.CONTINUOUS_SCROLL) {
503
+ this.clearColoredItems();
484
504
  } else {
485
- highlightItem(item);
505
+ this.highlightItem(item);
486
506
  }
487
507
  }
488
- pendingHighlightItem = item;
489
- controller.navigateToPage(item.page, { type: "search", id: item.id });
508
+ this.pendingHighlightItem = item;
509
+ this.controller.navigateToPage(item.page, { type: "search", id: item.id });
490
510
  }
491
- function updateUI(index, count) {
511
+ updateUI(index, count) {
492
512
  var str = count === 0 ? stringResources.searchDialogNoResultsLabel : stringFormat(stringResources.searchDialogResultsFormatLabel, [index + 1, count]);
493
- $resultsLabel.text(str);
513
+ this.$resultsLabel.text(str);
494
514
  var allowMoveUp = index > 0;
495
515
  var allowMoveDown = index < count - 1;
496
- navigationCommandSet.searchDialog_NavigateUp.enabled(allowMoveUp);
497
- navigationCommandSet.searchDialog_NavigateDown.enabled(allowMoveDown);
516
+ this.navigationCommandSet.searchDialog_NavigateUp.enabled(allowMoveUp);
517
+ this.navigationCommandSet.searchDialog_NavigateDown.enabled(allowMoveDown);
498
518
  }
499
- function clearColoredItems() {
500
- if (highlightManager.elements && highlightManager.elements.length > 0) {
501
- each(highlightManager.elements, function() {
502
- this.removeClass(highlightManager.shadedClassName);
519
+ clearColoredItems() {
520
+ if (this.highlightManager.elements && this.highlightManager.elements.length > 0) {
521
+ Array.from(this.highlightManager.elements).forEach(($element) => {
522
+ $element.removeClass(this.highlightManager.shadedClassName);
503
523
  });
504
524
  }
505
- if (highlightManager.current) {
506
- highlightManager.current.removeClass(highlightManager.highlightedClassName);
525
+ if (this.highlightManager.current) {
526
+ this.highlightManager.current.removeClass(this.highlightManager.highlightedClassName);
507
527
  }
508
- highlightManager.elements = [];
509
- highlightManager.current = null;
528
+ this.highlightManager.elements = [];
529
+ this.highlightManager.current = null;
510
530
  }
511
- function moveListSelection(offset) {
512
- var $listView = $resultsPlaceholder.data("kendoListView");
531
+ moveListSelection(offset) {
532
+ var $listView = this.$resultsPlaceholder.data("kendoListView");
513
533
  var $selected = $listView.select();
514
534
  if (!$selected) {
515
535
  $selected = $listView.element.children().first();
@@ -525,12 +545,12 @@ function Search(placeholder, options, viewerOptions) {
525
545
  if (element) {
526
546
  $listView.select(element);
527
547
  $listView.trigger("change");
528
- scrollIfNeeded(element[0], $listView.element[0]);
548
+ this.scrollIfNeeded(element[0], $listView.element[0]);
529
549
  }
530
550
  }
531
551
  }
532
552
  }
533
- function scrollIfNeeded(element, container) {
553
+ scrollIfNeeded(element, container) {
534
554
  if (element.offsetTop - element.clientHeight < container.scrollTop) {
535
555
  element.scrollIntoView();
536
556
  } else {
@@ -541,13 +561,13 @@ function Search(placeholder, options, viewerOptions) {
541
561
  }
542
562
  }
543
563
  }
544
- function toggleErrorLabel(show, message) {
545
- var $errorIcon = $searchOptionsPlaceholder.find("i[data-role='telerik_ReportViewer_SearchDialog_Error']");
564
+ toggleErrorLabel(show, message) {
565
+ var $errorIcon = this.$searchOptionsPlaceholder.find("i[data-role='telerik_ReportViewer_SearchDialog_Error']");
546
566
  if (!$errorIcon || $errorIcon.length === 0) {
547
567
  console.log(message);
548
568
  return;
549
569
  }
550
- var menuItem = $searchOptionsPlaceholder.data("kendoMenu").element.find("li").last();
570
+ var menuItem = this.$searchOptionsPlaceholder.data("kendoMenu").element.find("li").last();
551
571
  if (show) {
552
572
  $errorIcon[0].title = message;
553
573
  menuItem.show();
@@ -555,76 +575,6 @@ function Search(placeholder, options, viewerOptions) {
555
575
  menuItem.hide();
556
576
  }
557
577
  }
558
- function replaceStringResources($search) {
559
- if (!$search) {
560
- return;
561
- }
562
- var $searchCaption = $search.find(".trv-search-dialog-caption-label");
563
- var $searchOptions = $search.find(".trv-search-dialog-search-options");
564
- var $searchStopButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_StopSearch']");
565
- var $searchMatchCaseButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_MatchCase']");
566
- var $searchMatchWholeWordButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_MatchWholeWord']");
567
- var $searchUseRegexButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_UseRegex']");
568
- var $searchNavigateUpButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_NavigateUp']");
569
- var $searchNavigateDownButton = $search.find("a[data-command='telerik_ReportViewer_searchDialog_NavigateDown']");
570
- replaceAttribute($search, "aria-label");
571
- replaceAttribute($searchOptions, "aria-label");
572
- replaceText($searchCaption);
573
- replaceTitleAndAriaLabel($searchStopButton);
574
- replaceTitleAndAriaLabel($searchMatchCaseButton);
575
- replaceTitleAndAriaLabel($searchMatchWholeWordButton);
576
- replaceTitleAndAriaLabel($searchUseRegexButton);
577
- replaceTitleAndAriaLabel($searchNavigateUpButton);
578
- replaceTitleAndAriaLabel($searchNavigateDownButton);
579
- }
580
- function replaceTitleAndAriaLabel($a) {
581
- replaceAttribute($a, "title");
582
- replaceAttribute($a, "aria-label");
583
- }
584
- function replaceText($el) {
585
- if ($el) {
586
- $el.text(stringResources[$el.text()]);
587
- }
588
- }
589
- function replaceAttribute($el, attribute) {
590
- if ($el) {
591
- $el.attr(attribute, stringResources[$el.attr(attribute)]);
592
- }
593
- }
594
- function command(execCallback) {
595
- var enabledState = true;
596
- var checkedState = false;
597
- var cmd = {
598
- enabled: function(state) {
599
- if (arguments.length === 0) {
600
- return enabledState;
601
- }
602
- var newState = Boolean(state);
603
- enabledState = newState;
604
- $(this).trigger("enabledChanged");
605
- return cmd;
606
- },
607
- checked: function(state) {
608
- if (arguments.length === 0) {
609
- return checkedState;
610
- }
611
- var newState = Boolean(state);
612
- checkedState = newState;
613
- $(this).trigger("checkedChanged");
614
- return cmd;
615
- },
616
- exec: execCallback
617
- };
618
- return cmd;
619
- }
620
578
  }
621
- var pluginName = "telerik_ReportViewer_SearchDialog";
622
- $.fn[pluginName] = function(options, viewerOptions) {
623
- return each(this, function() {
624
- if (!$.data(this, pluginName)) {
625
- $.data(this, pluginName, new Search(this, options, viewerOptions));
626
- }
627
- });
628
- };
629
579
 
630
580
  export { Search };