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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/accessibility.js +218 -0
  3. package/dist/cjs/binder.js +172 -0
  4. package/dist/cjs/command.js +32 -0
  5. package/dist/cjs/commandSet.js +167 -0
  6. package/dist/cjs/controller.js +1207 -0
  7. package/dist/cjs/documentMapArea.js +168 -0
  8. package/dist/cjs/domUtils.js +50 -0
  9. package/dist/cjs/enums.js +52 -0
  10. package/dist/cjs/event-emitter.js +17 -0
  11. package/dist/cjs/events.js +23 -0
  12. package/dist/cjs/globalSettings.js +9 -0
  13. package/dist/cjs/history.js +131 -0
  14. package/dist/cjs/index.js +58 -0
  15. package/dist/cjs/jqueryThrottleDebounce.js +48 -0
  16. package/dist/cjs/kendo-jquery.js +4 -0
  17. package/dist/cjs/mainMenu.js +332 -0
  18. package/dist/cjs/mem-storage.js +44 -0
  19. package/dist/cjs/pagesArea.js +641 -0
  20. package/dist/cjs/parameterValidators.js +167 -0
  21. package/dist/cjs/parameters.js +921 -0
  22. package/dist/cjs/parametersArea.js +502 -0
  23. package/dist/cjs/perspectives.js +138 -0
  24. package/dist/cjs/print.js +166 -0
  25. package/dist/cjs/report-viewer/report-viewer-settings.js +138 -0
  26. package/dist/cjs/reportViewer.js +654 -0
  27. package/dist/cjs/scroll.js +537 -0
  28. package/dist/cjs/search.js +634 -0
  29. package/dist/cjs/sendEmail.js +435 -0
  30. package/dist/cjs/service-client-sentinel.js +52 -0
  31. package/dist/cjs/serviceClient.js +405 -0
  32. package/dist/cjs/sideMenu.js +225 -0
  33. package/dist/cjs/sr.js +164 -0
  34. package/dist/cjs/stringResources.js +11 -0
  35. package/dist/cjs/telerikReportViewer.kendo.js +60196 -0
  36. package/dist/cjs/telerikReportViewer.kendo.min.js +19776 -0
  37. package/dist/cjs/template-cache.js +39 -0
  38. package/dist/cjs/touch.js +86 -0
  39. package/dist/cjs/uiController.js +142 -0
  40. package/dist/cjs/uiFreezeCoordinator.js +281 -0
  41. package/dist/cjs/utils.js +492 -0
  42. package/dist/es/accessibility.js +214 -0
  43. package/dist/es/binder.js +168 -0
  44. package/dist/es/command.js +28 -0
  45. package/dist/es/commandSet.js +163 -0
  46. package/dist/es/controller.js +1203 -0
  47. package/dist/es/documentMapArea.js +164 -0
  48. package/dist/es/domUtils.js +43 -0
  49. package/dist/es/enums.js +41 -0
  50. package/dist/es/event-emitter.js +13 -0
  51. package/dist/es/events.js +19 -0
  52. package/dist/es/globalSettings.js +5 -0
  53. package/dist/es/history.js +127 -0
  54. package/dist/es/index.js +24 -0
  55. package/dist/es/jqueryThrottleDebounce.js +46 -0
  56. package/dist/es/kendo-jquery.js +1 -0
  57. package/dist/es/mainMenu.js +328 -0
  58. package/dist/es/mem-storage.js +40 -0
  59. package/dist/es/pagesArea.js +637 -0
  60. package/dist/es/parameterValidators.js +163 -0
  61. package/dist/es/parameters.js +916 -0
  62. package/dist/es/parametersArea.js +498 -0
  63. package/dist/es/perspectives.js +134 -0
  64. package/dist/es/print.js +162 -0
  65. package/dist/es/report-viewer/report-viewer-settings.js +134 -0
  66. package/dist/es/reportViewer.js +650 -0
  67. package/dist/es/scroll.js +533 -0
  68. package/dist/es/search.js +630 -0
  69. package/dist/es/sendEmail.js +431 -0
  70. package/dist/es/service-client-sentinel.js +48 -0
  71. package/dist/es/serviceClient.js +401 -0
  72. package/dist/es/sideMenu.js +221 -0
  73. package/dist/es/sr.js +162 -0
  74. package/dist/es/stringResources.js +7 -0
  75. package/dist/es/telerikReportViewer.kendo.js +60194 -0
  76. package/dist/es/telerikReportViewer.kendo.min.js +19774 -0
  77. package/dist/es/template-cache.js +35 -0
  78. package/dist/es/touch.js +82 -0
  79. package/dist/es/uiController.js +138 -0
  80. package/dist/es/uiFreezeCoordinator.js +277 -0
  81. package/dist/es/utils.js +447 -0
  82. package/dist/font/font-icons.css +4 -4
  83. package/dist/font/font-icons.min.css +3 -3
  84. package/dist/js/telerikReportViewer.js +8574 -8249
  85. package/dist/js/telerikReportViewer.min.js +1 -17
  86. package/dist/js/telerikReportViewer.stringResources.js +166 -173
  87. package/dist/styles/telerikReportViewer.css +1 -1
  88. package/dist/styles/telerikReportViewer.min.css +1 -1
  89. package/dist/templates/telerikReportViewerTemplate-FA.html +3 -3
  90. package/dist/templates/telerikReportViewerTemplate.html +3 -3
  91. package/package.json +13 -7
  92. /package/dist/font/{ReportingIcons-18.0.24.130.ttf → ReportingIcons-18.1.24.514.ttf} +0 -0
@@ -0,0 +1,630 @@
1
+ import { each, stringFormat } from './utils.js';
2
+ import { stringResources } from './stringResources.js';
3
+ import { Binder } from './binder.js';
4
+ import { PageModes } from './enums.js';
5
+
6
+ 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) {
59
+ return;
60
+ }
61
+ toggle(false);
62
+ searchMetadataLoaded = false;
63
+ }
64
+ function toggleSearchDialog(show) {
65
+ dialogVisible = show;
66
+ 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;
74
+ }
75
+ });
76
+ controller.refreshReport(true);
77
+ return;
78
+ }
79
+ }
80
+ toggle(show);
81
+ }
82
+ function toggle(show) {
83
+ dialogVisible = show;
84
+ if (show) {
85
+ searchMetadataLoaded = true;
86
+ ensureInitialized();
87
+ kendoSearchDialog.open();
88
+ kendoComboBox.value("");
89
+ updateResultsUI(null);
90
+ toggleErrorLabel(false, null);
91
+ } else {
92
+ clearColoredItems();
93
+ if (kendoSearchDialog && kendoSearchDialog.options.visible) {
94
+ kendoSearchDialog.close();
95
+ }
96
+ }
97
+ }
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);
106
+ 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;
113
+ }
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");
121
+ try {
122
+ kendoComboBox = $inputBox.kendoComboBox({
123
+ dataTextField: "value",
124
+ dataValueField: "value",
125
+ dataSource: mruList,
126
+ contentElement: "",
127
+ change: kendoComboBoxSelect,
128
+ ignoreCase: false,
129
+ filtering: onInputFiltering,
130
+ //the actual search-when-typing performs on this event.
131
+ filter: "startswith",
132
+ delay: 1e3,
133
+ open: function(e) {
134
+ if (inputComboRebinding) {
135
+ e.preventDefault();
136
+ }
137
+ },
138
+ select: processComboBoxEvent
139
+ }).data("kendoComboBox");
140
+ } catch (e) {
141
+ console.error("Instantiation of Kendo ComboBox as search input threw an exception", e);
142
+ throw e;
143
+ }
144
+ try {
145
+ kendoSearchDialog = reportViewerWrapper.find(".trv-search-window").kendoWindow({
146
+ title: stringResources.searchDialogTitle,
147
+ height: 390,
148
+ width: 310,
149
+ minWidth: 310,
150
+ minHeight: 390,
151
+ maxHeight: 700,
152
+ scrollable: false,
153
+ close: function() {
154
+ storeDialogPosition();
155
+ lastSearch = "";
156
+ },
157
+ open: function() {
158
+ adjustDialogPosition();
159
+ },
160
+ deactivate: function() {
161
+ controller.setSearchDialogVisible({
162
+ visible: false
163
+ });
164
+ },
165
+ activate: function() {
166
+ kendoComboBox.input.focus();
167
+ }
168
+ }).data("kendoWindow");
169
+ } catch (e) {
170
+ console.error("Instantiation of Kendo Window for Search dialog threw an exception", e);
171
+ throw e;
172
+ }
173
+ kendoSearchDialog.wrapper.addClass("trv-search");
174
+ initCommands();
175
+ initialized = true;
176
+ }
177
+ }
178
+ function overrideDefaultMenuStyling(kendoMenuSelector) {
179
+ var menuItems = $(kendoMenuSelector).find(".k-menu-item");
180
+ for (var i = 0; i < menuItems.length; i++) {
181
+ $(menuItems[i]).removeClass("k-item");
182
+ }
183
+ }
184
+ function onKeyDown(event) {
185
+ var item = $(event.target).find(".k-focus");
186
+ if (event.keyCode === 13 && item && item.length > 0) {
187
+ var anchor = item.children("a");
188
+ if (anchor.length > 0) {
189
+ anchor.click();
190
+ }
191
+ }
192
+ }
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();
202
+ }
203
+ function adjustDialogPosition() {
204
+ var windowWidth = $(window).innerWidth();
205
+ var windowHeight = $(window).innerHeight();
206
+ var kendoWindow = kendoSearchDialog.wrapper;
207
+ var width = kendoWindow.outerWidth(true);
208
+ var height = kendoWindow.outerHeight(true);
209
+ var padding = 10;
210
+ if (!windowLocation) {
211
+ var reportViewerCoords = reportViewerWrapper[0].getBoundingClientRect();
212
+ kendoWindow.css({
213
+ top: reportViewerCoords.top + padding,
214
+ left: reportViewerCoords.right - width - padding
215
+ });
216
+ kendoSearchDialog.setOptions({
217
+ position: {
218
+ top: reportViewerCoords.top + padding,
219
+ left: reportViewerCoords.right - width - padding
220
+ }
221
+ });
222
+ } else {
223
+ var left = windowLocation.left;
224
+ var top = windowLocation.top;
225
+ var right = left + width;
226
+ var bottom = top + height;
227
+ if (right > windowWidth - padding) {
228
+ left = Math.max(padding, windowWidth - width - padding);
229
+ kendoWindow.css({ left });
230
+ kendoSearchDialog.setOptions({
231
+ position: {
232
+ left
233
+ }
234
+ });
235
+ }
236
+ if (bottom > windowHeight - padding) {
237
+ top = Math.max(padding, windowHeight - height - padding);
238
+ kendoWindow.css({ top });
239
+ kendoSearchDialog.setOptions({
240
+ position: {
241
+ top
242
+ }
243
+ });
244
+ }
245
+ }
246
+ }
247
+ function processComboBoxEvent(e) {
248
+ if (!(window.event || window.event.type)) {
249
+ return;
250
+ }
251
+ var evt = window.event;
252
+ if (evt.type === "keydown") {
253
+ e.preventDefault();
254
+ if (evt.keyCode === 40) {
255
+ moveListSelection(1);
256
+ } else if (evt.keyCode === 38) {
257
+ moveListSelection(-1);
258
+ }
259
+ }
260
+ }
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
+ })
273
+ };
274
+ Binder.bind(
275
+ $searchOptionsPlaceholder,
276
+ {
277
+ controller,
278
+ commands: optionsCommandSet
279
+ },
280
+ viewerOptions
281
+ );
282
+ stopSearchCommand = new command(function() {
283
+ stopSearch();
284
+ });
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);
296
+ }),
297
+ "searchDialog_NavigateDown": new command(function() {
298
+ moveListSelection(1);
299
+ })
300
+ };
301
+ Binder.bind(
302
+ $navigationPlaceholder,
303
+ {
304
+ controller,
305
+ commands: navigationCommandSet
306
+ },
307
+ viewerOptions
308
+ );
309
+ }
310
+ function initResultsArea() {
311
+ try {
312
+ $resultsPlaceholder.kendoListView({
313
+ selectable: true,
314
+ navigatable: true,
315
+ dataSource: {},
316
+ contentElement: "",
317
+ 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();
321
+ var dataItem = view[index];
322
+ onSelectedItem(dataItem);
323
+ updateUI(index, view.length);
324
+ }
325
+ });
326
+ } catch (e) {
327
+ console.error("Instantiation of Kendo ListView as search result area threw an exception", e);
328
+ throw e;
329
+ }
330
+ }
331
+ function stopSearch() {
332
+ setStopButtonEnabledState(false);
333
+ }
334
+ function toggleCommand(cmd) {
335
+ cmd.checked(!cmd.checked());
336
+ searchForCurrentToken();
337
+ }
338
+ function setStopButtonEnabledState(enabledState) {
339
+ stopSearchCommand.enabled(enabledState);
340
+ }
341
+ function onPageReady(args, page) {
342
+ if (dialogVisible) {
343
+ colorPageElements(searchResults);
344
+ }
345
+ }
346
+ function onInputFiltering(e) {
347
+ e.preventDefault();
348
+ if (e.filter && e.filter.value !== lastSearch) {
349
+ lastSearch = e.filter.value;
350
+ searchForToken(lastSearch);
351
+ }
352
+ }
353
+ function kendoComboBoxSelect(e) {
354
+ var newValue = e.sender.value();
355
+ if (newValue && lastSearch !== newValue) {
356
+ lastSearch = newValue;
357
+ searchForToken(lastSearch);
358
+ }
359
+ }
360
+ function searchForCurrentToken() {
361
+ if (kendoComboBox) {
362
+ searchForToken(kendoComboBox.value());
363
+ }
364
+ }
365
+ function searchForToken(token) {
366
+ onSearchStarted();
367
+ addToMRU(token);
368
+ controller.getSearchResults(
369
+ {
370
+ searchToken: token,
371
+ matchCase: optionsCommandSet.searchDialog_MatchCase.checked(),
372
+ matchWholeWord: optionsCommandSet.searchDialog_MatchWholeWord.checked(),
373
+ useRegex: optionsCommandSet.searchDialog_UseRegex.checked()
374
+ }
375
+ ).then(function(results) {
376
+ updateResultsUI(results, null);
377
+ }).catch(function(errorMessage) {
378
+ if (errorMessage) {
379
+ updateResultsUI(null, errorMessage);
380
+ }
381
+ });
382
+ }
383
+ function onSearchStarted() {
384
+ $resultsLabel.text(stringResources.searchDialogSearchInProgress);
385
+ clearColoredItems();
386
+ searchResults = null;
387
+ setStopButtonEnabledState(true);
388
+ toggleErrorLabel(false, null);
389
+ }
390
+ function updateResultsUI(results, error) {
391
+ setStopButtonEnabledState(false);
392
+ if (error) {
393
+ toggleErrorLabel(true, error);
394
+ }
395
+ displayResultsList(results);
396
+ searchResults = results;
397
+ if (results && results.length > 0) {
398
+ colorPageElements(results);
399
+ selectFirstElement();
400
+ } else {
401
+ updateUI(-1, 0);
402
+ }
403
+ }
404
+ function addToMRU(token) {
405
+ if (!token || token === "") {
406
+ return;
407
+ }
408
+ var exists = mruList.filter(function(mru) {
409
+ return mru.value === token;
410
+ });
411
+ if (exists && exists.length > 0) {
412
+ return;
413
+ }
414
+ mruList.unshift({ value: token });
415
+ if (mruList.length > 10) {
416
+ mruList.pop();
417
+ }
418
+ inputComboRebinding = true;
419
+ kendoComboBox.dataSource.data(mruList);
420
+ kendoComboBox.select(function(item) {
421
+ return item.value === token;
422
+ });
423
+ inputComboRebinding = false;
424
+ }
425
+ function displayResultsList(results) {
426
+ var $listView = $resultsPlaceholder.data("kendoListView");
427
+ if (!results) {
428
+ results = [];
429
+ }
430
+ $listView.dataSource.data(results);
431
+ }
432
+ function colorPageElements(results) {
433
+ if (!results || results.length === 0) {
434
+ return;
435
+ }
436
+ var $parent = $placeholder.parent();
437
+ var $pageContainer = $parent.find(".trv-page-container");
438
+ var elements = $pageContainer.find("[data-search-id]");
439
+ each(results, function() {
440
+ var $searchElement = elements.filter("[data-search-id=" + this.id + "]");
441
+ if ($searchElement) {
442
+ $searchElement.addClass(highlightManager.shadedClassName);
443
+ highlightManager.elements.push($searchElement);
444
+ }
445
+ });
446
+ highlightItem(pendingHighlightItem);
447
+ pendingHighlightItem = null;
448
+ }
449
+ function highlightItem(item) {
450
+ if (item) {
451
+ var currentItemId = item.id;
452
+ var newHighlighted = $(highlightManager.elements.filter(function(i) {
453
+ return i.attr("data-search-id") === currentItemId;
454
+ })).first();
455
+ if (newHighlighted) {
456
+ highlightManager.current = newHighlighted[0];
457
+ if (highlightManager.current) {
458
+ var current = $("[data-search-id='" + currentItemId + "']");
459
+ current.removeClass(highlightManager.shadedClassName);
460
+ current.addClass(highlightManager.highlightedClassName);
461
+ }
462
+ }
463
+ }
464
+ }
465
+ function selectFirstElement() {
466
+ var $listView = $resultsPlaceholder.data("kendoListView");
467
+ var first = $listView.element.children().first();
468
+ $listView.select(first);
469
+ $listView.trigger("change");
470
+ }
471
+ function onSelectedItem(item) {
472
+ if (!item) {
473
+ return;
474
+ }
475
+ if (highlightManager.current) {
476
+ highlightManager.current.removeClass(highlightManager.highlightedClassName);
477
+ highlightManager.current.addClass(highlightManager.shadedClassName);
478
+ }
479
+ if (item.page === controller.getCurrentPageNumber()) {
480
+ highlightItem(item);
481
+ } else {
482
+ if (controller.getPageMode() !== PageModes.CONTINUOUS_SCROLL) {
483
+ clearColoredItems();
484
+ } else {
485
+ highlightItem(item);
486
+ }
487
+ }
488
+ pendingHighlightItem = item;
489
+ controller.navigateToPage(item.page, { type: "search", id: item.id });
490
+ }
491
+ function updateUI(index, count) {
492
+ var str = count === 0 ? stringResources.searchDialogNoResultsLabel : stringFormat(stringResources.searchDialogResultsFormatLabel, [index + 1, count]);
493
+ $resultsLabel.text(str);
494
+ var allowMoveUp = index > 0;
495
+ var allowMoveDown = index < count - 1;
496
+ navigationCommandSet.searchDialog_NavigateUp.enabled(allowMoveUp);
497
+ navigationCommandSet.searchDialog_NavigateDown.enabled(allowMoveDown);
498
+ }
499
+ function clearColoredItems() {
500
+ if (highlightManager.elements && highlightManager.elements.length > 0) {
501
+ each(highlightManager.elements, function() {
502
+ this.removeClass(highlightManager.shadedClassName);
503
+ });
504
+ }
505
+ if (highlightManager.current) {
506
+ highlightManager.current.removeClass(highlightManager.highlightedClassName);
507
+ }
508
+ highlightManager.elements = [];
509
+ highlightManager.current = null;
510
+ }
511
+ function moveListSelection(offset) {
512
+ var $listView = $resultsPlaceholder.data("kendoListView");
513
+ var $selected = $listView.select();
514
+ if (!$selected) {
515
+ $selected = $listView.element.children().first();
516
+ $listView.select($selected);
517
+ $listView.trigger("change");
518
+ } else {
519
+ var index = $listView.select().trigger("change").index();
520
+ var view = $listView.dataSource.view();
521
+ var newIndex = Math.min(view.length - 1, Math.max(0, index + offset));
522
+ if (newIndex !== index) {
523
+ var dataItem = view[newIndex];
524
+ var element = $listView.element.find('[data-uid="' + dataItem.uid + '"]');
525
+ if (element) {
526
+ $listView.select(element);
527
+ $listView.trigger("change");
528
+ scrollIfNeeded(element[0], $listView.element[0]);
529
+ }
530
+ }
531
+ }
532
+ }
533
+ function scrollIfNeeded(element, container) {
534
+ if (element.offsetTop - element.clientHeight < container.scrollTop) {
535
+ element.scrollIntoView();
536
+ } else {
537
+ var offsetBottom = element.offsetTop + element.offsetHeight;
538
+ var scrollBottom = container.scrollTop + container.offsetHeight;
539
+ if (offsetBottom > scrollBottom) {
540
+ container.scrollTop = offsetBottom - container.offsetHeight;
541
+ }
542
+ }
543
+ }
544
+ function toggleErrorLabel(show, message) {
545
+ var $errorIcon = $searchOptionsPlaceholder.find("i[data-role='telerik_ReportViewer_SearchDialog_Error']");
546
+ if (!$errorIcon || $errorIcon.length === 0) {
547
+ console.log(message);
548
+ return;
549
+ }
550
+ var menuItem = $searchOptionsPlaceholder.data("kendoMenu").element.find("li").last();
551
+ if (show) {
552
+ $errorIcon[0].title = message;
553
+ menuItem.show();
554
+ } else {
555
+ menuItem.hide();
556
+ }
557
+ }
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
+ }
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
+
630
+ export { Search };