@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.
Files changed (100) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/accessibility.js +208 -0
  3. package/dist/cjs/base-component.js +26 -0
  4. package/dist/cjs/binder.js +79 -0
  5. package/dist/cjs/command.js +32 -0
  6. package/dist/cjs/commandSet.js +167 -0
  7. package/dist/cjs/controller.js +1204 -0
  8. package/dist/cjs/documentMapArea.js +159 -0
  9. package/dist/cjs/domUtils.js +50 -0
  10. package/dist/cjs/enums.js +52 -0
  11. package/dist/cjs/event-emitter.js +131 -0
  12. package/dist/cjs/events.js +23 -0
  13. package/dist/cjs/globalSettings.js +9 -0
  14. package/dist/cjs/history.js +131 -0
  15. package/dist/cjs/index.js +58 -0
  16. package/dist/cjs/jqueryThrottleDebounce.js +48 -0
  17. package/dist/cjs/kendo-jquery.js +4 -0
  18. package/dist/cjs/mainMenu.js +323 -0
  19. package/dist/cjs/mem-storage.js +44 -0
  20. package/dist/cjs/pagesArea.js +622 -0
  21. package/dist/cjs/parameterValidators.js +164 -0
  22. package/dist/cjs/parameters.js +921 -0
  23. package/dist/cjs/parametersArea.js +486 -0
  24. package/dist/cjs/perspectives.js +138 -0
  25. package/dist/cjs/print.js +165 -0
  26. package/dist/cjs/report-viewer/report-viewer-settings.js +138 -0
  27. package/dist/cjs/reportViewer.js +665 -0
  28. package/dist/cjs/scroll.js +535 -0
  29. package/dist/cjs/search.js +584 -0
  30. package/dist/cjs/sendEmail.js +392 -0
  31. package/dist/cjs/service-client-sentinel.js +52 -0
  32. package/dist/cjs/serviceClient.js +311 -0
  33. package/dist/cjs/sideMenu.js +216 -0
  34. package/dist/cjs/sr.js +164 -0
  35. package/dist/cjs/stringResources.js +11 -0
  36. package/dist/cjs/telerikReportViewer.kendo.js +60196 -0
  37. package/dist/cjs/telerikReportViewer.kendo.min.js +19776 -0
  38. package/dist/cjs/template-cache.js +39 -0
  39. package/dist/cjs/toolbar/link-button.js +42 -0
  40. package/dist/cjs/toolbar/page-count-label.js +18 -0
  41. package/dist/cjs/toolbar/page-number-input.js +64 -0
  42. package/dist/cjs/touch.js +86 -0
  43. package/dist/cjs/uiController.js +142 -0
  44. package/dist/cjs/uiFreezeCoordinator.js +282 -0
  45. package/dist/cjs/utils.js +489 -0
  46. package/dist/es/accessibility.js +204 -0
  47. package/dist/es/base-component.js +22 -0
  48. package/dist/es/binder.js +75 -0
  49. package/dist/es/command.js +28 -0
  50. package/dist/es/commandSet.js +163 -0
  51. package/dist/es/controller.js +1200 -0
  52. package/dist/es/documentMapArea.js +155 -0
  53. package/dist/es/domUtils.js +43 -0
  54. package/dist/es/enums.js +41 -0
  55. package/dist/es/event-emitter.js +127 -0
  56. package/dist/es/events.js +19 -0
  57. package/dist/es/globalSettings.js +5 -0
  58. package/dist/es/history.js +127 -0
  59. package/dist/es/index.js +24 -0
  60. package/dist/es/jqueryThrottleDebounce.js +46 -0
  61. package/dist/es/kendo-jquery.js +1 -0
  62. package/dist/es/mainMenu.js +319 -0
  63. package/dist/es/mem-storage.js +40 -0
  64. package/dist/es/pagesArea.js +618 -0
  65. package/dist/es/parameterValidators.js +160 -0
  66. package/dist/es/parameters.js +916 -0
  67. package/dist/es/parametersArea.js +482 -0
  68. package/dist/es/perspectives.js +134 -0
  69. package/dist/es/print.js +161 -0
  70. package/dist/es/report-viewer/report-viewer-settings.js +134 -0
  71. package/dist/es/reportViewer.js +661 -0
  72. package/dist/es/scroll.js +531 -0
  73. package/dist/es/search.js +580 -0
  74. package/dist/es/sendEmail.js +388 -0
  75. package/dist/es/service-client-sentinel.js +48 -0
  76. package/dist/es/serviceClient.js +307 -0
  77. package/dist/es/sideMenu.js +212 -0
  78. package/dist/es/sr.js +162 -0
  79. package/dist/es/stringResources.js +7 -0
  80. package/dist/es/telerikReportViewer.kendo.js +60194 -0
  81. package/dist/es/telerikReportViewer.kendo.min.js +19774 -0
  82. package/dist/es/template-cache.js +35 -0
  83. package/dist/es/toolbar/link-button.js +38 -0
  84. package/dist/es/toolbar/page-count-label.js +14 -0
  85. package/dist/es/toolbar/page-number-input.js +60 -0
  86. package/dist/es/touch.js +82 -0
  87. package/dist/es/uiController.js +138 -0
  88. package/dist/es/uiFreezeCoordinator.js +278 -0
  89. package/dist/es/utils.js +444 -0
  90. package/dist/font/font-icons.css +4 -4
  91. package/dist/font/font-icons.min.css +3 -3
  92. package/dist/js/telerikReportViewer.js +8346 -8507
  93. package/dist/js/telerikReportViewer.min.js +1 -17
  94. package/dist/js/telerikReportViewer.stringResources.js +166 -173
  95. package/dist/styles/telerikReportViewer.css +3 -3
  96. package/dist/styles/telerikReportViewer.min.css +3 -3
  97. package/dist/templates/telerikReportViewerTemplate-FA.html +4 -4
  98. package/dist/templates/telerikReportViewerTemplate.html +6 -6
  99. package/package.json +14 -7
  100. /package/dist/font/{ReportingIcons-18.0.24.305.ttf → ReportingIcons-18.1.24.709.ttf} +0 -0
@@ -0,0 +1,661 @@
1
+ import { rTrim, generateGuidString, isApplicationExceptionInstance, stringFormat, escapeHtml, logError, loadScript } from './utils.js';
2
+ import { stringResources } from './stringResources.js';
3
+ import { ServiceClient } from './serviceClient.js';
4
+ import { ReportViewerController } from './controller.js';
5
+ import { HistoryManager } from './history.js';
6
+ import { Binder } from './binder.js';
7
+ import { CommandSet } from './commandSet.js';
8
+ import { UIController } from './uiController.js';
9
+ import { Accessibility } from './accessibility.js';
10
+ import { DocumentMapArea } from './documentMapArea.js';
11
+ import { ParametersArea } from './parametersArea.js';
12
+ import { PagesArea } from './pagesArea.js';
13
+ import { MainMenu } from './mainMenu.js';
14
+ import { Search } from './search.js';
15
+ import { SendEmail } from './sendEmail.js';
16
+ import { SideMenu } from './sideMenu.js';
17
+ import { Events } from './events.js';
18
+ import { PerspectiveManager } from './perspectives.js';
19
+ import { ScaleModes, ViewModes, PageModes, ParametersAreaPositions, DocumentMapAreaPositions, ParameterEditorTypes } from './enums.js';
20
+ import { GlobalSettings } from './globalSettings.js';
21
+ import { MemStorage } from './mem-storage.js';
22
+ import { TemplateCache } from './template-cache.js';
23
+ import { ReportViewerSettings } from './report-viewer/report-viewer-settings.js';
24
+ import { LinkButton } from './toolbar/link-button.js';
25
+ import { PageNumberInput } from './toolbar/page-number-input.js';
26
+ import { PageCountLabel } from './toolbar/page-count-label.js';
27
+
28
+ const Instances = GlobalSettings.viewerInstances;
29
+ function getDefaultOptions(serviceUrl, version) {
30
+ return {
31
+ id: null,
32
+ serviceUrl: null,
33
+ templateUrl: rTrim(serviceUrl, "\\/") + "/resources/templates/telerikReportViewerTemplate-" + version + ".html/",
34
+ reportSource: null,
35
+ reportServer: null,
36
+ authenticationToken: null,
37
+ sendEmail: null,
38
+ scale: 1,
39
+ scaleMode: ScaleModes.FIT_PAGE,
40
+ viewMode: ViewModes.INTERACTIVE,
41
+ pageMode: PageModes.CONTINUOUS_SCROLL,
42
+ parametersAreaPosition: ParametersAreaPositions.RIGHT,
43
+ documentMapAreaPosition: DocumentMapAreaPositions.LEFT,
44
+ parameters: {
45
+ editors: {
46
+ multiSelect: ParameterEditorTypes.LIST_VIEW,
47
+ singleSelect: ParameterEditorTypes.LIST_VIEW
48
+ }
49
+ },
50
+ persistSession: false,
51
+ parameterEditors: [],
52
+ disabledButtonClass: null,
53
+ checkedButtonClass: null,
54
+ parametersAreaVisible: true,
55
+ documentMapVisible: true,
56
+ enableAccessibility: false,
57
+ searchMetadataOnDemand: false,
58
+ initialPageAreaImageUrl: null,
59
+ keepClientAlive: true
60
+ };
61
+ }
62
+ function ReportViewer(dom, options) {
63
+ var svcApiUrl = options.serviceUrl;
64
+ var reportServerUrlSVCApiUrl = "";
65
+ if (options.reportServer) {
66
+ reportServerUrlSVCApiUrl = rTrim(options.reportServer.url, "\\/");
67
+ svcApiUrl = reportServerUrlSVCApiUrl + "/api/reports";
68
+ }
69
+ var $placeholder = $(dom);
70
+ var templates = {};
71
+ var persistanceKey = options.id || `trv_${dom.id}`;
72
+ var accessibility;
73
+ var settings = {};
74
+ var client = {};
75
+ var controller = {};
76
+ var perspectiveManager = {};
77
+ var history = {};
78
+ var commands = {};
79
+ var viewer = {};
80
+ var serviceClientOptions = {};
81
+ var reportServerUrl = "";
82
+ options.viewerSelector = "reportViewer-" + generateGuidString();
83
+ $placeholder.attr("data-selector", options.viewerSelector);
84
+ if (!validateOptions(options)) {
85
+ return;
86
+ }
87
+ var version = "18.1.24.709";
88
+ options = $.extend({}, getDefaultOptions(svcApiUrl, version), options);
89
+ settings = new ReportViewerSettings(
90
+ persistanceKey,
91
+ options.persistSession ? window.sessionStorage : new MemStorage(),
92
+ {
93
+ scale: options.scale,
94
+ scaleMode: options.scaleMode,
95
+ printMode: options.printMode ? options.printMode : options.directPrint,
96
+ enableAccessibility: options.enableAccessibility,
97
+ searchMetadataOnDemand: options.searchMetadataOnDemand,
98
+ sendEmail: options.sendEmail,
99
+ parametersAreaPosition: options.parametersAreaPosition,
100
+ documentMapAreaPosition: options.documentMapAreaPosition,
101
+ keepClientAlive: options.keepClientAlive
102
+ }
103
+ );
104
+ if (options.reportServer) {
105
+ reportServerUrl = rTrim(options.reportServer.url, "\\/");
106
+ serviceClientOptions.serviceUrl = reportServerUrl + "/api/reports";
107
+ serviceClientOptions.loginInfo = {
108
+ url: reportServerUrl + "/Token",
109
+ username: options.reportServer.username,
110
+ password: options.reportServer.password
111
+ };
112
+ } else {
113
+ serviceClientOptions.serviceUrl = options.serviceUrl;
114
+ }
115
+ client = new ServiceClient(serviceClientOptions);
116
+ controller = options.controller;
117
+ if (!controller) {
118
+ controller = new ReportViewerController({
119
+ serviceClient: client,
120
+ settings
121
+ });
122
+ } else {
123
+ controller.updateSettings(settings);
124
+ }
125
+ history = new HistoryManager({
126
+ controller,
127
+ settings
128
+ });
129
+ commands = new CommandSet({
130
+ controller,
131
+ history
132
+ });
133
+ new UIController({
134
+ controller,
135
+ history,
136
+ commands
137
+ });
138
+ viewer = {
139
+ stringResources,
140
+ refreshReport: function(ignoreCache) {
141
+ if (arguments.length === 0) {
142
+ ignoreCache = true;
143
+ }
144
+ controller.refreshReport(ignoreCache);
145
+ return viewer;
146
+ },
147
+ reportSource: function(rs) {
148
+ if (rs || rs === null) {
149
+ controller.setReportSource(rs);
150
+ controller.refreshReport(false);
151
+ return viewer;
152
+ }
153
+ return controller.getReportSource();
154
+ },
155
+ clearReportSource: function() {
156
+ controller.clearReportSource();
157
+ return viewer;
158
+ },
159
+ viewMode: function(vm) {
160
+ if (vm) {
161
+ controller.setViewMode(vm);
162
+ return viewer;
163
+ }
164
+ return controller.getViewMode();
165
+ },
166
+ pageMode: function(psm) {
167
+ if (psm) {
168
+ controller.setPageMode(psm);
169
+ return viewer;
170
+ }
171
+ return controller.getPageMode();
172
+ },
173
+ printMode: function(pm) {
174
+ if (pm) {
175
+ controller.setPrintMode(pm);
176
+ return viewer;
177
+ }
178
+ return controller.getPrintMode();
179
+ },
180
+ scale: function({ scale, scaleMode } = {}) {
181
+ if (scale || scaleMode) {
182
+ controller.setScale(scale || controller.getScale());
183
+ controller.setScaleMode(scaleMode || controller.getScaleMode());
184
+ return viewer;
185
+ }
186
+ return {
187
+ scale: controller.getScale(),
188
+ scaleMode: controller.getScaleMode()
189
+ };
190
+ },
191
+ currentPage: function() {
192
+ return controller.getCurrentPageNumber();
193
+ },
194
+ pageCount: function() {
195
+ return controller.getPageCount();
196
+ },
197
+ parametersAreaVisible: function(visible) {
198
+ controller.setParametersAreaVisible({ visible });
199
+ },
200
+ getReportParameters: function() {
201
+ return controller.getReportParameters();
202
+ },
203
+ authenticationToken: function(token) {
204
+ if (token) {
205
+ controller.setAuthenticationToken(token);
206
+ }
207
+ return viewer;
208
+ },
209
+ bind: function(eventName, eventHandler) {
210
+ eventBinder(eventName, eventHandler, true);
211
+ },
212
+ unbind: function(eventName, eventHandler) {
213
+ eventBinder(eventName, eventHandler, false);
214
+ },
215
+ accessibilityKeyMap: function(keyMap) {
216
+ if (accessibility) {
217
+ if (keyMap) {
218
+ accessibility.setKeyMap(keyMap);
219
+ return viewer;
220
+ }
221
+ return accessibility.getKeyMap();
222
+ }
223
+ return void 0;
224
+ },
225
+ commands,
226
+ dispose: function() {
227
+ controller.dispose();
228
+ if (perspectiveManager) {
229
+ perspectiveManager.dispose();
230
+ }
231
+ }
232
+ };
233
+ function validateOptions(options2) {
234
+ if (!options2) {
235
+ $placeholder.text("The report viewer configuration options are not initialized.");
236
+ return false;
237
+ }
238
+ if (options2.reportServer) {
239
+ if (!options2.reportServer.url) {
240
+ $placeholder.text("The report server URL is not specified.");
241
+ return false;
242
+ }
243
+ } else {
244
+ if (!options2.serviceUrl) {
245
+ $placeholder.text("The serviceUrl is not specified.");
246
+ return false;
247
+ }
248
+ }
249
+ return true;
250
+ }
251
+ function eventBinder(eventName, eventHandler, bind) {
252
+ if (typeof eventHandler === "function") {
253
+ if (bind) {
254
+ $(viewer).on(eventName, { sender: viewer }, eventHandler);
255
+ } else {
256
+ $(viewer).off(eventName, eventHandler);
257
+ }
258
+ } else if (!eventHandler && !bind) {
259
+ $(viewer).off(eventName);
260
+ }
261
+ }
262
+ function attachEvents() {
263
+ var eventMap = {
264
+ EXPORT_BEGIN: controller.Events.EXPORT_STARTED,
265
+ EXPORT_END: controller.Events.EXPORT_DOCUMENT_READY,
266
+ PRINT_BEGIN: controller.Events.PRINT_STARTED,
267
+ PRINT_END: controller.Events.PRINT_DOCUMENT_READY,
268
+ RENDERING_BEGIN: controller.Events.BEFORE_LOAD_REPORT,
269
+ RENDERING_END: controller.Events.REPORT_LOAD_COMPLETE,
270
+ PAGE_READY: controller.Events.PAGE_READY,
271
+ ERROR: controller.Events.ERROR,
272
+ UPDATE_UI: controller.Events.UPDATE_UI,
273
+ INTERACTIVE_ACTION_EXECUTING: controller.Events.INTERACTIVE_ACTION_EXECUTING,
274
+ INTERACTIVE_ACTION_ENTER: controller.Events.INTERACTIVE_ACTION_ENTER,
275
+ INTERACTIVE_ACTION_LEAVE: controller.Events.INTERACTIVE_ACTION_LEAVE,
276
+ VIEWER_TOOLTIP_OPENING: controller.Events.TOOLTIP_OPENING,
277
+ SEND_EMAIL_BEGIN: controller.Events.SEND_EMAIL_STARTED,
278
+ SEND_EMAIL_END: controller.Events.SEND_EMAIL_READY
279
+ };
280
+ var $viewer = $(viewer);
281
+ for (const [viewerEvent, controllerEvent] of Object.entries(eventMap)) {
282
+ controller.on(controllerEvent, function(e, args) {
283
+ $viewer.trigger(viewerEvent, args);
284
+ });
285
+ }
286
+ }
287
+ function attachEventHandlers() {
288
+ eventBinder(Events.EXPORT_BEGIN, options.exportBegin, true);
289
+ eventBinder(Events.EXPORT_END, options.exportEnd, true);
290
+ eventBinder(Events.PRINT_BEGIN, options.printBegin, true);
291
+ eventBinder(Events.PRINT_END, options.printEnd, true);
292
+ eventBinder(Events.RENDERING_BEGIN, options.renderingBegin, true);
293
+ eventBinder(Events.RENDERING_END, options.renderingEnd, true);
294
+ eventBinder(Events.PAGE_READY, options.pageReady, true);
295
+ eventBinder(Events.ERROR, options.error, true);
296
+ eventBinder(Events.UPDATE_UI, options.updateUi, true);
297
+ eventBinder(Events.INTERACTIVE_ACTION_EXECUTING, options.interactiveActionExecuting, true);
298
+ eventBinder(Events.INTERACTIVE_ACTION_ENTER, options.interactiveActionEnter, true);
299
+ eventBinder(Events.INTERACTIVE_ACTION_LEAVE, options.interactiveActionLeave, true);
300
+ eventBinder(Events.VIEWER_TOOLTIP_OPENING, options.viewerToolTipOpening, true);
301
+ eventBinder(Events.SEND_EMAIL_BEGIN, options.sendEmailBegin, true);
302
+ eventBinder(Events.SEND_EMAIL_END, options.sendEmailEnd, true);
303
+ }
304
+ function init() {
305
+ $placeholder.html(templates["trv-report-viewer"]);
306
+ Binder.bind(
307
+ $placeholder,
308
+ {
309
+ controller,
310
+ commands,
311
+ templates
312
+ },
313
+ options
314
+ );
315
+ perspectiveManager = new PerspectiveManager(dom, controller);
316
+ perspectiveManager.attach();
317
+ initSplitter();
318
+ attachEvents();
319
+ attachEventHandlers();
320
+ initFromStorage();
321
+ initAccessibility(options);
322
+ }
323
+ function initSplitter() {
324
+ var parameterAreaPaneOptions = {
325
+ max: "500px",
326
+ min: "50px",
327
+ size: "210px",
328
+ collapsible: true
329
+ };
330
+ var parameterAreaTemplate = $placeholder.find(".trv-parameters-area");
331
+ var parameterAreaPanes = [{}];
332
+ var documentMapPaneOptions = {
333
+ max: "500px",
334
+ min: "50px",
335
+ size: "210px",
336
+ collapsible: true,
337
+ collapsed: true
338
+ };
339
+ var documentMapTemplate = $placeholder.find(".trv-document-map");
340
+ var documentMapPanes = [{}];
341
+ var orientation = "horizontal";
342
+ if (options.documentMapAreaPosition === DocumentMapAreaPositions.RIGHT) {
343
+ documentMapTemplate.insertAfter($placeholder.find(".trv-pages-area"));
344
+ documentMapPanes.push(documentMapPaneOptions);
345
+ } else {
346
+ documentMapPanes.unshift(documentMapPaneOptions);
347
+ }
348
+ if (options.parametersAreaPosition === ParametersAreaPositions.TOP || options.parametersAreaPosition === ParametersAreaPositions.BOTTOM) {
349
+ orientation = "vertical";
350
+ parameterAreaTemplate.addClass("-vertical");
351
+ parameterAreaPaneOptions.size = "130px";
352
+ }
353
+ if (options.parametersAreaPosition === ParametersAreaPositions.LEFT || options.parametersAreaPosition === ParametersAreaPositions.TOP) {
354
+ parameterAreaTemplate.insertBefore($placeholder.find(".trv-document-map-splitter"));
355
+ parameterAreaPanes.unshift(parameterAreaPaneOptions);
356
+ } else {
357
+ parameterAreaPanes.push(parameterAreaPaneOptions);
358
+ }
359
+ try {
360
+ var documentMapSplitter = $placeholder.find(".trv-document-map-splitter").kendoSplitter({
361
+ panes: documentMapPanes,
362
+ expand: function(e) {
363
+ setSplitterPaneVisibility(e.pane, true);
364
+ },
365
+ collapse: function(e) {
366
+ setSplitterPaneVisibility(e.pane, false);
367
+ },
368
+ resize: function(e) {
369
+ }
370
+ }).data("kendoSplitter");
371
+ } catch (e) {
372
+ console.error("Instantiation of Kendo Splitter as Document Map splitter threw an exception", e);
373
+ throw e;
374
+ }
375
+ try {
376
+ var parametersSplitter = $placeholder.find(".trv-parameters-splitter").kendoSplitter({
377
+ panes: parameterAreaPanes,
378
+ orientation,
379
+ expand: function(e) {
380
+ setSplitterPaneVisibility(e.pane, true);
381
+ },
382
+ collapse: function(e) {
383
+ setSplitterPaneVisibility(e.pane, false);
384
+ },
385
+ resize: function(e) {
386
+ }
387
+ }).data("kendoSplitter");
388
+ } catch (e) {
389
+ console.error("Instantiation of Kendo Splitter as Parameters area splitter threw an exception", e);
390
+ throw e;
391
+ }
392
+ var parametersSplitterInstance = {
393
+ id: options.viewerSelector + "-parameters-splitter",
394
+ instance: parametersSplitter
395
+ };
396
+ var documentMapSplitterInstance = {
397
+ id: options.viewerSelector + "-document-map-splitter",
398
+ instance: documentMapSplitter
399
+ };
400
+ Instances.push(parametersSplitterInstance);
401
+ Instances.push(documentMapSplitterInstance);
402
+ }
403
+ function setSplitterPaneVisibility(pane, visible) {
404
+ var paneID = $(pane).attr("data-id");
405
+ switch (paneID) {
406
+ case "trv-document-map":
407
+ controller.setDocumentMapVisible({
408
+ visible
409
+ });
410
+ break;
411
+ case "trv-parameters-area":
412
+ controller.setParametersAreaVisible({
413
+ visible
414
+ });
415
+ break;
416
+ }
417
+ }
418
+ function initFromStorage() {
419
+ var vm = settings.getViewMode();
420
+ var psm = settings.getPageMode();
421
+ var pm = settings.getPrintMode();
422
+ var s = settings.getScale();
423
+ var sm = settings.getScaleMode();
424
+ var dm = settings.getDocumentMapVisible();
425
+ var pa = settings.getParametersAreaVisible();
426
+ settings.getAccessibilityKeyMap();
427
+ controller.setViewMode(vm ? vm : options.viewMode);
428
+ controller.setPageMode(psm ? psm : options.pageMode);
429
+ controller.setPrintMode(pm ? pm : options.printMode);
430
+ controller.setScale(s ? s : options.scale);
431
+ controller.setScaleMode(sm ? sm : options.scaleMode);
432
+ controller.setDocumentMapVisible({
433
+ visible: dm ? dm : options.documentMapVisible
434
+ });
435
+ controller.setParametersAreaVisible({
436
+ visible: pa ? pa : options.parametersAreaVisible
437
+ });
438
+ controller.printModeChanged(function() {
439
+ settings.setPrintMode(controller.getPrintMode());
440
+ });
441
+ controller.viewModeChanged(function() {
442
+ settings.setViewMode(controller.getViewMode());
443
+ });
444
+ controller.pageModeChanged(function() {
445
+ settings.setPageMode(controller.getPageMode());
446
+ });
447
+ controller.scaleChanged(function(event, scale) {
448
+ settings.setScale(scale);
449
+ });
450
+ controller.scaleModeChanged(function(event, scaleMode) {
451
+ settings.setScaleMode(scaleMode);
452
+ });
453
+ controller.setSideMenuVisible(function(event, args) {
454
+ window.setTimeout(function() {
455
+ (args.visible ? $.fn.addClass : $.fn.removeClass).call($placeholder, "trv-side-menu-visible");
456
+ }, 1);
457
+ });
458
+ controller.setDocumentMapVisible(function() {
459
+ var args = {};
460
+ controller.getDocumentMapState(args);
461
+ settings.setDocumentMapVisible(args.visible);
462
+ });
463
+ controller.setParametersAreaVisible(function() {
464
+ var args = {};
465
+ controller.getParametersAreaState(args);
466
+ settings.setParametersAreaVisible(args.visible);
467
+ });
468
+ }
469
+ function initAccessibility(options2) {
470
+ if (options2.enableAccessibility) {
471
+ accessibility = new Accessibility({
472
+ controller,
473
+ templates
474
+ });
475
+ var am = options2.accessibilityKeyMap;
476
+ if (am) {
477
+ accessibility.setKeyMap(am);
478
+ }
479
+ settings.contentTabIndex = getTemplateContentTabIndex();
480
+ }
481
+ }
482
+ function getTemplateContentTabIndex() {
483
+ var pageAreaSelector = "div.trv-pages-area";
484
+ try {
485
+ var $pagesArea = $placeholder.find(pageAreaSelector);
486
+ if ($pagesArea.length === 0) {
487
+ throw "Selector " + pageAreaSelector + " did not return a result.";
488
+ }
489
+ return parseInt($pagesArea.attr("tabindex"));
490
+ } catch (e) {
491
+ if (console)
492
+ console.log(e);
493
+ return 0;
494
+ }
495
+ }
496
+ function start() {
497
+ var pendingRefresh = false;
498
+ init();
499
+ controller.reportLoadComplete(function() {
500
+ if (options.documentMapVisible === false) {
501
+ controller.setDocumentMapVisible({ visible: false });
502
+ }
503
+ });
504
+ var rs = settings.getReportSource();
505
+ if (rs !== void 0) {
506
+ controller.setReportSource(rs);
507
+ var pageNumber = settings.getPageNumber();
508
+ if (pageNumber !== void 0) {
509
+ controller.navigateToPage(pageNumber);
510
+ }
511
+ pendingRefresh = true;
512
+ } else {
513
+ if (options.viewMode) {
514
+ controller.setViewMode(options.viewMode);
515
+ }
516
+ if (options.pageMode) {
517
+ controller.setPageMode(options.pageMode);
518
+ }
519
+ if (options.reportSource) {
520
+ controller.setReportSource(options.reportSource);
521
+ pendingRefresh = true;
522
+ }
523
+ }
524
+ if (typeof options.ready === "function") {
525
+ options.ready.call(viewer);
526
+ }
527
+ if (pendingRefresh) {
528
+ controller.refreshReport(false);
529
+ }
530
+ }
531
+ function loadStyleSheets(styleSheets) {
532
+ if (!styleSheets)
533
+ return Promise.resolve();
534
+ var $head = $("head");
535
+ var currentStyleLinks = $head.find("link").map(function(i, e) {
536
+ return e.outerHTML;
537
+ }).toArray();
538
+ var promises = [];
539
+ Array.from(styleSheets).forEach((element) => {
540
+ if (currentStyleLinks.indexOf(element) === -1) {
541
+ promises.push(
542
+ new Promise(function(resolve, reject) {
543
+ var $link = $(element);
544
+ $link.on("load", resolve);
545
+ $link.on("onerror", function() {
546
+ logError("error loading stylesheet " + element);
547
+ resolve();
548
+ });
549
+ $head.append($link);
550
+ })
551
+ );
552
+ }
553
+ });
554
+ return Promise.all(promises).then(controller.cssLoaded);
555
+ }
556
+ function browserSupportsAllFeatures() {
557
+ return window.Promise;
558
+ }
559
+ function ensureKendo(version2) {
560
+ if (window.kendo) {
561
+ return Promise.resolve();
562
+ }
563
+ var kendoUrl = rTrim(svcApiUrl, "\\/") + "/resources/js/telerikReportViewer.kendo-" + version2 + ".min.js/";
564
+ return loadScript(kendoUrl).catch(function(errorData) {
565
+ logError("Kendo could not be loaded automatically. Make sure 'options.serviceUrl' / 'options.reportServer.url' is correct and accessible. The error is: " + errorData.error);
566
+ });
567
+ }
568
+ function main(version2) {
569
+ ensureKendo(version2).then(function() {
570
+ }).then(function() {
571
+ viewer.authenticationToken(options.authenticationToken);
572
+ controller.getServiceVersion().catch(function(ex) {
573
+ var errorOutput = isApplicationExceptionInstance(ex) ? ex.exceptionMessage : stringFormat(stringResources.errorServiceUrl, [escapeHtml(svcApiUrl)]);
574
+ $placeholder.text(errorOutput);
575
+ return Promise.reject();
576
+ }).then(function(data) {
577
+ if (data !== version2) {
578
+ $placeholder.text(stringFormat(stringResources.errorServiceVersion, [data, version2]));
579
+ return Promise.reject();
580
+ }
581
+ TemplateCache.load(options.templateUrl, svcApiUrl, client).catch(function() {
582
+ $placeholder.text(stringFormat(stringResources.errorLoadingTemplates, [escapeHtml(options.templateUrl)]));
583
+ return Promise.reject();
584
+ }).then(function(result) {
585
+ templates = result.templates;
586
+ return loadStyleSheets(result.styleSheets);
587
+ }).then(start);
588
+ });
589
+ });
590
+ }
591
+ if (browserSupportsAllFeatures()) {
592
+ main(version);
593
+ } else {
594
+ throw "The current browser does not support the Promise feature which is required for using the Report Viewer.";
595
+ }
596
+ return viewer;
597
+ }
598
+ var pluginName = "telerik_ReportViewer";
599
+ $.fn[pluginName] = function(options) {
600
+ if (this.selector && !options.selector) {
601
+ options.selector = this.selector;
602
+ }
603
+ return this.each(function() {
604
+ if (!$.data(this, pluginName)) {
605
+ $.data(this, pluginName, new ReportViewer(this, options));
606
+ }
607
+ });
608
+ };
609
+ const plugins = [
610
+ {
611
+ name: "telerik_ReportViewer_DocumentMapArea",
612
+ constructor: DocumentMapArea
613
+ },
614
+ {
615
+ name: "telerik_ReportViewer_MainMenu",
616
+ constructor: MainMenu
617
+ },
618
+ {
619
+ name: "telerik_ReportViewer_PagesArea",
620
+ constructor: PagesArea
621
+ },
622
+ {
623
+ name: "telerik_ReportViewer_ParametersArea",
624
+ constructor: ParametersArea
625
+ },
626
+ {
627
+ name: "telerik_ReportViewer_SearchDialog",
628
+ constructor: Search
629
+ },
630
+ {
631
+ name: "telerik_ReportViewer_SendEmail",
632
+ constructor: SendEmail
633
+ },
634
+ {
635
+ name: "telerik_ReportViewer_SideMenu",
636
+ constructor: SideMenu
637
+ },
638
+ {
639
+ name: "telerik_ReportViewer_LinkButton",
640
+ constructor: LinkButton
641
+ },
642
+ {
643
+ name: "telerik_ReportViewer_PageNumberInput",
644
+ constructor: PageNumberInput
645
+ },
646
+ {
647
+ name: "telerik_ReportViewer_PageCountLabel",
648
+ constructor: PageCountLabel
649
+ }
650
+ ];
651
+ plugins.forEach((plugin) => {
652
+ $.fn[plugin.name] = function(options, otherOptions) {
653
+ return this.each(function() {
654
+ if (!$.data(this, plugin.name)) {
655
+ $.data(this, plugin.name, new plugin.constructor(this, options, otherOptions));
656
+ }
657
+ });
658
+ };
659
+ });
660
+
661
+ export { ReportViewer };