@progress/telerik-jquery-report-viewer 21.24.305 → 22.24.709
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/cjs/accessibility.js +208 -0
- package/dist/cjs/base-component.js +26 -0
- package/dist/cjs/binder.js +79 -0
- package/dist/cjs/command.js +32 -0
- package/dist/cjs/commandSet.js +167 -0
- package/dist/cjs/controller.js +1204 -0
- package/dist/cjs/documentMapArea.js +159 -0
- package/dist/cjs/domUtils.js +50 -0
- package/dist/cjs/enums.js +52 -0
- package/dist/cjs/event-emitter.js +131 -0
- package/dist/cjs/events.js +23 -0
- package/dist/cjs/globalSettings.js +9 -0
- package/dist/cjs/history.js +131 -0
- package/dist/cjs/index.js +58 -0
- package/dist/cjs/jqueryThrottleDebounce.js +48 -0
- package/dist/cjs/kendo-jquery.js +4 -0
- package/dist/cjs/mainMenu.js +323 -0
- package/dist/cjs/mem-storage.js +44 -0
- package/dist/cjs/pagesArea.js +622 -0
- package/dist/cjs/parameterValidators.js +164 -0
- package/dist/cjs/parameters.js +921 -0
- package/dist/cjs/parametersArea.js +486 -0
- package/dist/cjs/perspectives.js +138 -0
- package/dist/cjs/print.js +165 -0
- package/dist/cjs/report-viewer/report-viewer-settings.js +138 -0
- package/dist/cjs/reportViewer.js +665 -0
- package/dist/cjs/scroll.js +535 -0
- package/dist/cjs/search.js +584 -0
- package/dist/cjs/sendEmail.js +392 -0
- package/dist/cjs/service-client-sentinel.js +52 -0
- package/dist/cjs/serviceClient.js +311 -0
- package/dist/cjs/sideMenu.js +216 -0
- package/dist/cjs/sr.js +164 -0
- package/dist/cjs/stringResources.js +11 -0
- package/dist/cjs/telerikReportViewer.kendo.js +60196 -0
- package/dist/cjs/telerikReportViewer.kendo.min.js +19776 -0
- package/dist/cjs/template-cache.js +39 -0
- package/dist/cjs/toolbar/link-button.js +42 -0
- package/dist/cjs/toolbar/page-count-label.js +18 -0
- package/dist/cjs/toolbar/page-number-input.js +64 -0
- package/dist/cjs/touch.js +86 -0
- package/dist/cjs/uiController.js +142 -0
- package/dist/cjs/uiFreezeCoordinator.js +282 -0
- package/dist/cjs/utils.js +489 -0
- package/dist/es/accessibility.js +204 -0
- package/dist/es/base-component.js +22 -0
- package/dist/es/binder.js +75 -0
- package/dist/es/command.js +28 -0
- package/dist/es/commandSet.js +163 -0
- package/dist/es/controller.js +1200 -0
- package/dist/es/documentMapArea.js +155 -0
- package/dist/es/domUtils.js +43 -0
- package/dist/es/enums.js +41 -0
- package/dist/es/event-emitter.js +127 -0
- package/dist/es/events.js +19 -0
- package/dist/es/globalSettings.js +5 -0
- package/dist/es/history.js +127 -0
- package/dist/es/index.js +24 -0
- package/dist/es/jqueryThrottleDebounce.js +46 -0
- package/dist/es/kendo-jquery.js +1 -0
- package/dist/es/mainMenu.js +319 -0
- package/dist/es/mem-storage.js +40 -0
- package/dist/es/pagesArea.js +618 -0
- package/dist/es/parameterValidators.js +160 -0
- package/dist/es/parameters.js +916 -0
- package/dist/es/parametersArea.js +482 -0
- package/dist/es/perspectives.js +134 -0
- package/dist/es/print.js +161 -0
- package/dist/es/report-viewer/report-viewer-settings.js +134 -0
- package/dist/es/reportViewer.js +661 -0
- package/dist/es/scroll.js +531 -0
- package/dist/es/search.js +580 -0
- package/dist/es/sendEmail.js +388 -0
- package/dist/es/service-client-sentinel.js +48 -0
- package/dist/es/serviceClient.js +307 -0
- package/dist/es/sideMenu.js +212 -0
- package/dist/es/sr.js +162 -0
- package/dist/es/stringResources.js +7 -0
- package/dist/es/telerikReportViewer.kendo.js +60194 -0
- package/dist/es/telerikReportViewer.kendo.min.js +19774 -0
- package/dist/es/template-cache.js +35 -0
- package/dist/es/toolbar/link-button.js +38 -0
- package/dist/es/toolbar/page-count-label.js +14 -0
- package/dist/es/toolbar/page-number-input.js +60 -0
- package/dist/es/touch.js +82 -0
- package/dist/es/uiController.js +138 -0
- package/dist/es/uiFreezeCoordinator.js +278 -0
- package/dist/es/utils.js +444 -0
- package/dist/font/font-icons.css +4 -4
- package/dist/font/font-icons.min.css +3 -3
- package/dist/js/telerikReportViewer.js +8346 -8507
- package/dist/js/telerikReportViewer.min.js +1 -17
- package/dist/js/telerikReportViewer.stringResources.js +166 -173
- package/dist/styles/telerikReportViewer.css +3 -3
- package/dist/styles/telerikReportViewer.min.css +3 -3
- package/dist/templates/telerikReportViewerTemplate-FA.html +4 -4
- package/dist/templates/telerikReportViewerTemplate.html +6 -6
- package/package.json +14 -7
- /package/dist/font/{ReportingIcons-18.0.24.305.ttf → ReportingIcons-18.1.24.709.ttf} +0 -0
@@ -0,0 +1,584 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
var utils = require('./utils.js');
|
6
|
+
var stringResources = require('./stringResources.js');
|
7
|
+
var binder = require('./binder.js');
|
8
|
+
var enums = require('./enums.js');
|
9
|
+
var command = require('./command.js');
|
10
|
+
|
11
|
+
var defaultOptions = {};
|
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) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
this.toggle(false);
|
113
|
+
this.searchMetadataLoaded = false;
|
114
|
+
}
|
115
|
+
toggleSearchDialog(show) {
|
116
|
+
this.dialogVisible = show;
|
117
|
+
if (show) {
|
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;
|
125
|
+
}
|
126
|
+
});
|
127
|
+
this.controller.refreshReport(true);
|
128
|
+
return;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
this.toggle(show);
|
132
|
+
}
|
133
|
+
toggle(show) {
|
134
|
+
this.dialogVisible = show;
|
135
|
+
if (show) {
|
136
|
+
this.searchMetadataLoaded = true;
|
137
|
+
this.ensureInitialized();
|
138
|
+
this.kendoSearchDialog.open();
|
139
|
+
this.kendoComboBox.value("");
|
140
|
+
this.updateResultsUI(null);
|
141
|
+
this.toggleErrorLabel(false, null);
|
142
|
+
} else {
|
143
|
+
this.clearColoredItems();
|
144
|
+
if (this.kendoSearchDialog && this.kendoSearchDialog.options.visible) {
|
145
|
+
this.kendoSearchDialog.close();
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
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);
|
157
|
+
try {
|
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;
|
164
|
+
}
|
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");
|
172
|
+
try {
|
173
|
+
this.kendoComboBox = this.$inputBox.kendoComboBox({
|
174
|
+
dataTextField: "value",
|
175
|
+
dataValueField: "value",
|
176
|
+
dataSource: this.mruList,
|
177
|
+
contentElement: "",
|
178
|
+
change: this.kendoComboBoxSelect.bind(this),
|
179
|
+
ignoreCase: false,
|
180
|
+
// the actual search-when-typing performs on this event.
|
181
|
+
filtering: this.onInputFiltering.bind(this),
|
182
|
+
filter: "startswith",
|
183
|
+
delay: 1e3,
|
184
|
+
open: (event) => {
|
185
|
+
if (this.inputComboRebinding) {
|
186
|
+
event.preventDefault();
|
187
|
+
}
|
188
|
+
},
|
189
|
+
select: this.processComboBoxEvent.bind(this)
|
190
|
+
}).data("kendoComboBox");
|
191
|
+
} catch (error) {
|
192
|
+
console.error("Instantiation of Kendo ComboBox as search input threw an exception", error);
|
193
|
+
throw error;
|
194
|
+
}
|
195
|
+
try {
|
196
|
+
this.kendoSearchDialog = this.reportViewerWrapper.find(".trv-search-window").kendoWindow({
|
197
|
+
title: stringResources.stringResources.searchDialogTitle,
|
198
|
+
height: 390,
|
199
|
+
width: 310,
|
200
|
+
minWidth: 310,
|
201
|
+
minHeight: 390,
|
202
|
+
maxHeight: 700,
|
203
|
+
scrollable: false,
|
204
|
+
close: () => {
|
205
|
+
this.storeDialogPosition();
|
206
|
+
this.lastSearch = "";
|
207
|
+
},
|
208
|
+
open: () => {
|
209
|
+
this.adjustDialogPosition();
|
210
|
+
},
|
211
|
+
deactivate: () => {
|
212
|
+
this.controller.setSearchDialogVisible({
|
213
|
+
visible: false
|
214
|
+
});
|
215
|
+
},
|
216
|
+
activate: () => {
|
217
|
+
this.kendoComboBox.input.focus();
|
218
|
+
}
|
219
|
+
}).data("kendoWindow");
|
220
|
+
} catch (error) {
|
221
|
+
console.error("Instantiation of Kendo Window for Search dialog threw an exception", error);
|
222
|
+
throw error;
|
223
|
+
}
|
224
|
+
this.kendoSearchDialog.wrapper.addClass("trv-search");
|
225
|
+
this.initCommands();
|
226
|
+
this.initialized = true;
|
227
|
+
}
|
228
|
+
}
|
229
|
+
overrideDefaultMenuStyling(kendoMenuSelector) {
|
230
|
+
var menuItems = $(kendoMenuSelector).find(".k-menu-item");
|
231
|
+
for (var i = 0; i < menuItems.length; i++) {
|
232
|
+
$(menuItems[i]).removeClass("k-item");
|
233
|
+
}
|
234
|
+
}
|
235
|
+
onKeyDown(event) {
|
236
|
+
var item = $(event.target).find(".k-focus");
|
237
|
+
if (event.keyCode === 13 && item && item.length > 0) {
|
238
|
+
var anchor = item.children("a");
|
239
|
+
if (anchor.length > 0) {
|
240
|
+
anchor.click();
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
storeDialogPosition() {
|
245
|
+
var kendoWindow = this.kendoSearchDialog.element.parent(".k-window");
|
246
|
+
this.windowLocation = kendoWindow.offset();
|
247
|
+
}
|
248
|
+
adjustDialogPosition() {
|
249
|
+
var windowWidth = $(window).innerWidth();
|
250
|
+
var windowHeight = $(window).innerHeight();
|
251
|
+
var kendoWindow = this.kendoSearchDialog.wrapper;
|
252
|
+
var width = kendoWindow.outerWidth(true);
|
253
|
+
var height = kendoWindow.outerHeight(true);
|
254
|
+
var padding = 10;
|
255
|
+
if (!this.windowLocation) {
|
256
|
+
var reportViewerCoords = this.reportViewerWrapper[0].getBoundingClientRect();
|
257
|
+
kendoWindow.css({
|
258
|
+
top: reportViewerCoords.top + padding,
|
259
|
+
left: reportViewerCoords.right - width - padding
|
260
|
+
});
|
261
|
+
this.kendoSearchDialog.setOptions({
|
262
|
+
position: {
|
263
|
+
top: reportViewerCoords.top + padding,
|
264
|
+
left: reportViewerCoords.right - width - padding
|
265
|
+
}
|
266
|
+
});
|
267
|
+
} else {
|
268
|
+
var left = this.windowLocation.left;
|
269
|
+
var top = this.windowLocation.top;
|
270
|
+
var right = left + width;
|
271
|
+
var bottom = top + height;
|
272
|
+
if (right > windowWidth - padding) {
|
273
|
+
left = Math.max(padding, windowWidth - width - padding);
|
274
|
+
kendoWindow.css({ left });
|
275
|
+
this.kendoSearchDialog.setOptions({
|
276
|
+
position: {
|
277
|
+
left
|
278
|
+
}
|
279
|
+
});
|
280
|
+
}
|
281
|
+
if (bottom > windowHeight - padding) {
|
282
|
+
top = Math.max(padding, windowHeight - height - padding);
|
283
|
+
kendoWindow.css({ top });
|
284
|
+
this.kendoSearchDialog.setOptions({
|
285
|
+
position: {
|
286
|
+
top
|
287
|
+
}
|
288
|
+
});
|
289
|
+
}
|
290
|
+
}
|
291
|
+
}
|
292
|
+
processComboBoxEvent(event) {
|
293
|
+
if (!(window.event || window.event.type)) {
|
294
|
+
return;
|
295
|
+
}
|
296
|
+
var evt = window.event;
|
297
|
+
if (evt.type === "keydown") {
|
298
|
+
event.preventDefault();
|
299
|
+
if (evt.keyCode === 40) {
|
300
|
+
this.moveListSelection(1);
|
301
|
+
}
|
302
|
+
if (evt.keyCode === 38) {
|
303
|
+
this.moveListSelection(-1);
|
304
|
+
}
|
305
|
+
}
|
306
|
+
}
|
307
|
+
initCommands() {
|
308
|
+
this.optionsCommandSet = {
|
309
|
+
"searchDialog_MatchCase": new command.Command(),
|
310
|
+
"searchDialog_MatchWholeWord": new command.Command(),
|
311
|
+
"searchDialog_UseRegex": new command.Command()
|
312
|
+
};
|
313
|
+
Object.entries(this.optionsCommandSet).forEach(([commandName, command]) => {
|
314
|
+
command.exec = () => {
|
315
|
+
this.toggleCommand(command);
|
316
|
+
};
|
317
|
+
});
|
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);
|
326
|
+
}),
|
327
|
+
"searchDialog_NavigateDown": new command.Command(() => {
|
328
|
+
this.moveListSelection(1);
|
329
|
+
})
|
330
|
+
};
|
331
|
+
binder.Binder.attachCommands(this.$navigationPlaceholder, this.navigationCommandSet, this.viewerOptions);
|
332
|
+
}
|
333
|
+
initResultsArea() {
|
334
|
+
try {
|
335
|
+
this.$resultsPlaceholder.kendoListView({
|
336
|
+
selectable: true,
|
337
|
+
navigatable: true,
|
338
|
+
dataSource: {},
|
339
|
+
contentElement: "",
|
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>",
|
341
|
+
change: (event) => {
|
342
|
+
var listView = event.sender;
|
343
|
+
var index = listView.select().index();
|
344
|
+
var view = listView.dataSource.view();
|
345
|
+
var dataItem = view[index];
|
346
|
+
this.onSelectedItem(dataItem);
|
347
|
+
this.updateUI(index, view.length);
|
348
|
+
}
|
349
|
+
});
|
350
|
+
} catch (error) {
|
351
|
+
console.error("Instantiation of Kendo ListView as search result area threw an exception", error);
|
352
|
+
throw error;
|
353
|
+
}
|
354
|
+
}
|
355
|
+
stopSearch() {
|
356
|
+
this.setStopButtonEnabledState(false);
|
357
|
+
}
|
358
|
+
toggleCommand(cmd) {
|
359
|
+
cmd.checked(!cmd.checked());
|
360
|
+
this.searchForCurrentToken();
|
361
|
+
}
|
362
|
+
setStopButtonEnabledState(enabledState) {
|
363
|
+
this.stopSearchCommand.enabled(enabledState);
|
364
|
+
}
|
365
|
+
onPageReady(args, page) {
|
366
|
+
if (this.dialogVisible) {
|
367
|
+
this.colorPageElements(this.searchResults);
|
368
|
+
}
|
369
|
+
}
|
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);
|
375
|
+
}
|
376
|
+
}
|
377
|
+
kendoComboBoxSelect(event) {
|
378
|
+
var newValue = event.sender.value();
|
379
|
+
if (newValue && this.lastSearch !== newValue) {
|
380
|
+
this.lastSearch = newValue;
|
381
|
+
this.searchForToken(this.lastSearch);
|
382
|
+
}
|
383
|
+
}
|
384
|
+
searchForCurrentToken() {
|
385
|
+
if (this.kendoComboBox) {
|
386
|
+
this.searchForToken(this.kendoComboBox.value());
|
387
|
+
}
|
388
|
+
}
|
389
|
+
searchForToken(token) {
|
390
|
+
this.onSearchStarted();
|
391
|
+
this.addToMRU(token);
|
392
|
+
this.controller.getSearchResults(
|
393
|
+
{
|
394
|
+
searchToken: token,
|
395
|
+
matchCase: this.optionsCommandSet.searchDialog_MatchCase.checked(),
|
396
|
+
matchWholeWord: this.optionsCommandSet.searchDialog_MatchWholeWord.checked(),
|
397
|
+
useRegex: this.optionsCommandSet.searchDialog_UseRegex.checked()
|
398
|
+
}
|
399
|
+
).then((results) => {
|
400
|
+
this.updateResultsUI(results, null);
|
401
|
+
}).catch((errorMessage) => {
|
402
|
+
if (errorMessage) {
|
403
|
+
this.updateResultsUI(null, errorMessage);
|
404
|
+
}
|
405
|
+
});
|
406
|
+
}
|
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);
|
413
|
+
}
|
414
|
+
updateResultsUI(results, error) {
|
415
|
+
this.setStopButtonEnabledState(false);
|
416
|
+
if (error) {
|
417
|
+
this.toggleErrorLabel(true, error);
|
418
|
+
}
|
419
|
+
this.displayResultsList(results);
|
420
|
+
this.searchResults = results;
|
421
|
+
if (results && results.length > 0) {
|
422
|
+
this.colorPageElements(results);
|
423
|
+
this.selectFirstElement();
|
424
|
+
} else {
|
425
|
+
this.updateUI(-1, 0);
|
426
|
+
}
|
427
|
+
}
|
428
|
+
addToMRU(token) {
|
429
|
+
if (!token || token === "") {
|
430
|
+
return;
|
431
|
+
}
|
432
|
+
var exists = this.mruList.filter((mru) => {
|
433
|
+
return mru.value === token;
|
434
|
+
});
|
435
|
+
if (exists && exists.length > 0) {
|
436
|
+
return;
|
437
|
+
}
|
438
|
+
this.mruList.unshift({ value: token });
|
439
|
+
if (this.mruList.length > 10) {
|
440
|
+
this.mruList.pop();
|
441
|
+
}
|
442
|
+
this.inputComboRebinding = true;
|
443
|
+
this.kendoComboBox.dataSource.data(this.mruList);
|
444
|
+
this.kendoComboBox.select((item) => {
|
445
|
+
return item.value === token;
|
446
|
+
});
|
447
|
+
this.inputComboRebinding = false;
|
448
|
+
}
|
449
|
+
displayResultsList(results) {
|
450
|
+
var $listView = this.$resultsPlaceholder.data("kendoListView");
|
451
|
+
if (!results) {
|
452
|
+
results = [];
|
453
|
+
}
|
454
|
+
$listView.dataSource.data(results);
|
455
|
+
}
|
456
|
+
colorPageElements(results) {
|
457
|
+
if (!results || results.length === 0) {
|
458
|
+
return;
|
459
|
+
}
|
460
|
+
var $parent = this.$element.parent();
|
461
|
+
var $pageContainer = $parent.find(".trv-page-container");
|
462
|
+
var elements = $pageContainer.find("[data-search-id]");
|
463
|
+
Array.from(results).forEach((result) => {
|
464
|
+
var $searchElement = elements.filter("[data-search-id=" + result.id + "]");
|
465
|
+
if ($searchElement) {
|
466
|
+
$searchElement.addClass(this.highlightManager.shadedClassName);
|
467
|
+
this.highlightManager.elements.push($searchElement);
|
468
|
+
}
|
469
|
+
});
|
470
|
+
this.highlightItem(this.pendingHighlightItem);
|
471
|
+
this.pendingHighlightItem = null;
|
472
|
+
}
|
473
|
+
highlightItem(item) {
|
474
|
+
if (item) {
|
475
|
+
var currentItemId = item.id;
|
476
|
+
var newHighlighted = $(this.highlightManager.elements.filter((i) => {
|
477
|
+
return i.attr("data-search-id") === currentItemId;
|
478
|
+
})).first();
|
479
|
+
if (newHighlighted) {
|
480
|
+
this.highlightManager.current = newHighlighted[0];
|
481
|
+
if (this.highlightManager.current) {
|
482
|
+
var current = $("[data-search-id='" + currentItemId + "']");
|
483
|
+
current.removeClass(this.highlightManager.shadedClassName);
|
484
|
+
current.addClass(this.highlightManager.highlightedClassName);
|
485
|
+
}
|
486
|
+
}
|
487
|
+
}
|
488
|
+
}
|
489
|
+
selectFirstElement() {
|
490
|
+
var $listView = this.$resultsPlaceholder.data("kendoListView");
|
491
|
+
var first = $listView.element.children().first();
|
492
|
+
$listView.select(first);
|
493
|
+
$listView.trigger("change");
|
494
|
+
}
|
495
|
+
onSelectedItem(item) {
|
496
|
+
if (!item) {
|
497
|
+
return;
|
498
|
+
}
|
499
|
+
if (this.highlightManager.current) {
|
500
|
+
this.highlightManager.current.removeClass(this.highlightManager.highlightedClassName);
|
501
|
+
this.highlightManager.current.addClass(this.highlightManager.shadedClassName);
|
502
|
+
}
|
503
|
+
if (item.page === this.controller.getCurrentPageNumber()) {
|
504
|
+
this.highlightItem(item);
|
505
|
+
} else {
|
506
|
+
if (this.controller.getPageMode() !== enums.PageModes.CONTINUOUS_SCROLL) {
|
507
|
+
this.clearColoredItems();
|
508
|
+
} else {
|
509
|
+
this.highlightItem(item);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
this.pendingHighlightItem = item;
|
513
|
+
this.controller.navigateToPage(item.page, { type: "search", id: item.id });
|
514
|
+
}
|
515
|
+
updateUI(index, count) {
|
516
|
+
var str = count === 0 ? stringResources.stringResources.searchDialogNoResultsLabel : utils.stringFormat(stringResources.stringResources.searchDialogResultsFormatLabel, [index + 1, count]);
|
517
|
+
this.$resultsLabel.text(str);
|
518
|
+
var allowMoveUp = index > 0;
|
519
|
+
var allowMoveDown = index < count - 1;
|
520
|
+
this.navigationCommandSet.searchDialog_NavigateUp.enabled(allowMoveUp);
|
521
|
+
this.navigationCommandSet.searchDialog_NavigateDown.enabled(allowMoveDown);
|
522
|
+
}
|
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);
|
527
|
+
});
|
528
|
+
}
|
529
|
+
if (this.highlightManager.current) {
|
530
|
+
this.highlightManager.current.removeClass(this.highlightManager.highlightedClassName);
|
531
|
+
}
|
532
|
+
this.highlightManager.elements = [];
|
533
|
+
this.highlightManager.current = null;
|
534
|
+
}
|
535
|
+
moveListSelection(offset) {
|
536
|
+
var $listView = this.$resultsPlaceholder.data("kendoListView");
|
537
|
+
var $selected = $listView.select();
|
538
|
+
if (!$selected) {
|
539
|
+
$selected = $listView.element.children().first();
|
540
|
+
$listView.select($selected);
|
541
|
+
$listView.trigger("change");
|
542
|
+
} else {
|
543
|
+
var index = $listView.select().trigger("change").index();
|
544
|
+
var view = $listView.dataSource.view();
|
545
|
+
var newIndex = Math.min(view.length - 1, Math.max(0, index + offset));
|
546
|
+
if (newIndex !== index) {
|
547
|
+
var dataItem = view[newIndex];
|
548
|
+
var element = $listView.element.find('[data-uid="' + dataItem.uid + '"]');
|
549
|
+
if (element) {
|
550
|
+
$listView.select(element);
|
551
|
+
$listView.trigger("change");
|
552
|
+
this.scrollIfNeeded(element[0], $listView.element[0]);
|
553
|
+
}
|
554
|
+
}
|
555
|
+
}
|
556
|
+
}
|
557
|
+
scrollIfNeeded(element, container) {
|
558
|
+
if (element.offsetTop - element.clientHeight < container.scrollTop) {
|
559
|
+
element.scrollIntoView();
|
560
|
+
} else {
|
561
|
+
var offsetBottom = element.offsetTop + element.offsetHeight;
|
562
|
+
var scrollBottom = container.scrollTop + container.offsetHeight;
|
563
|
+
if (offsetBottom > scrollBottom) {
|
564
|
+
container.scrollTop = offsetBottom - container.offsetHeight;
|
565
|
+
}
|
566
|
+
}
|
567
|
+
}
|
568
|
+
toggleErrorLabel(show, message) {
|
569
|
+
var $errorIcon = this.$searchOptionsPlaceholder.find("i[data-role='telerik_ReportViewer_SearchDialog_Error']");
|
570
|
+
if (!$errorIcon || $errorIcon.length === 0) {
|
571
|
+
console.log(message);
|
572
|
+
return;
|
573
|
+
}
|
574
|
+
var menuItem = this.$searchOptionsPlaceholder.data("kendoMenu").element.find("li").last();
|
575
|
+
if (show) {
|
576
|
+
$errorIcon[0].title = message;
|
577
|
+
menuItem.show();
|
578
|
+
} else {
|
579
|
+
menuItem.hide();
|
580
|
+
}
|
581
|
+
}
|
582
|
+
}
|
583
|
+
|
584
|
+
exports.Search = Search;
|