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

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