@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,618 @@
1
+ import { stringFormat, tryParseInt, escapeHtml } from './utils.js';
2
+ import { getMargins, getBorderWidth, getPadding, scale } from './domUtils.js';
3
+ import { stringResources } from './stringResources.js';
4
+ import { TouchBehavior } from './touch.js';
5
+ import { Scroll } from './scroll.js';
6
+ import { UIFreezeCoordinator } from './uiFreezeCoordinator.js';
7
+ import { PageModes, ViewModes, ScaleModes } from './enums.js';
8
+
9
+ var defaultOptions = {};
10
+ function PagesArea(placeholder, options, otherOptions) {
11
+ options = $.extend({}, defaultOptions, options, otherOptions);
12
+ var controller = options.controller;
13
+ if (!controller)
14
+ throw "No controller (telerikReportViewer.reportViewerController) has been specified.";
15
+ var $placeholder = $(placeholder);
16
+ var $pageContainer = $placeholder.find(".trv-page-container");
17
+ var pageContainer = $pageContainer[0];
18
+ var $pageWrapper = $placeholder.find(".trv-page-wrapper");
19
+ var pageWrapper = $pageWrapper[0];
20
+ var $errorMessage = $placeholder.find(".trv-error-message");
21
+ var actions;
22
+ var pendingElement;
23
+ var pageScaleMode = controller.getScaleMode();
24
+ var pageScale = controller.getScale();
25
+ var minPageScale = 0.1;
26
+ var maxPageScale = 8;
27
+ var documentReady = true;
28
+ var navigateToPageOnDocReady;
29
+ var navigateToElementOnDocReady;
30
+ var isNewReportSource;
31
+ var showErrorTimeoutId;
32
+ var showPageAreaImage = false;
33
+ var reportPageIsLoaded = false;
34
+ var pageAreaImageStyle = '.trv-page-container {background: #ffffff url("{0}") no-repeat center 50px}';
35
+ var pageAreaImageID = "trv-initial-image-styles";
36
+ var scroll = $.extend({}, Scroll);
37
+ var uiFreezeCoordinator = null;
38
+ init();
39
+ if (scroll) {
40
+ scroll.init(placeholder, options);
41
+ }
42
+ function init() {
43
+ replaceStringResources($placeholder);
44
+ }
45
+ function replaceStringResources($pagesArea) {
46
+ $pagesArea.attr("aria-label", stringResources[$pagesArea.attr("aria-label")]);
47
+ }
48
+ $(window).on("resize", function(event, args) {
49
+ if (shouldAutosizePage()) {
50
+ updatePageDimensions();
51
+ }
52
+ });
53
+ enableTouch($placeholder);
54
+ function clearPendingTimeoutIds() {
55
+ if (showErrorTimeoutId) {
56
+ window.clearTimeout(showErrorTimeoutId);
57
+ }
58
+ }
59
+ function invalidateCurrentlyLoadedPage() {
60
+ var page = findPage(navigateToPageOnDocReady);
61
+ if (page) {
62
+ pageNo(page, -1);
63
+ }
64
+ }
65
+ function navigateWhenPageAvailable(pageNumber, pageCount) {
66
+ if (pageNumber && pageNumber <= pageCount) {
67
+ navigateToPage(pageNumber, navigateToElementOnDocReady);
68
+ }
69
+ }
70
+ function navigateOnLoadComplete(pageNumber, pageCount) {
71
+ if (pageNumber) {
72
+ pageNumber = Math.min(pageNumber, pageCount);
73
+ navigateToPage(pageNumber, navigateToElementOnDocReady);
74
+ }
75
+ }
76
+ function clearPage() {
77
+ clear(isNewReportSource);
78
+ isNewReportSource = false;
79
+ }
80
+ controller.pageModeChanged(function() {
81
+ if (controller.getPageMode() === PageModes.CONTINUOUS_SCROLL) {
82
+ scroll.enable();
83
+ } else {
84
+ scroll.disable();
85
+ }
86
+ controller.refreshReport(true);
87
+ }).reportSourceChanged(function() {
88
+ isNewReportSource = true;
89
+ navigateToPageOnDocReady = null;
90
+ navigateToElementOnDocReady = null;
91
+ documentReady = false;
92
+ }).beforeLoadParameters(function(event, initial) {
93
+ if (initial) {
94
+ showError(stringResources.loadingReport);
95
+ }
96
+ }).beforeLoadReport(function() {
97
+ documentReady = false;
98
+ if (!navigateToPageOnDocReady) {
99
+ navigateToPageOnDocReady = 1;
100
+ }
101
+ clearPendingTimeoutIds();
102
+ clear();
103
+ disablePagesArea(true);
104
+ showError(stringResources.loadingReport);
105
+ }).beginLoadReport(function(event, args) {
106
+ documentReady = true;
107
+ invalidateCurrentlyLoadedPage();
108
+ }).reportLoadProgress(function(event, args) {
109
+ navigateWhenPageAvailable(navigateToPageOnDocReady, args.pageCount);
110
+ showError(stringFormat(stringResources.loadingReportPagesInProgress, [args.pageCount]));
111
+ }).reportLoadComplete(function(event, args) {
112
+ if (0 === args.pageCount) {
113
+ clearPage();
114
+ showError(stringResources.noPageToDisplay);
115
+ } else {
116
+ navigateOnLoadComplete(navigateToPageOnDocReady, args.pageCount);
117
+ showError(stringFormat(stringResources.loadedReportPagesComplete, [args.pageCount]));
118
+ showErrorTimeoutId = window.setTimeout(showError, 2e3);
119
+ enableInteractivity();
120
+ }
121
+ if (args.containsFrozenContent && !uiFreezeCoordinator) {
122
+ uiFreezeCoordinator = $.extend({}, UIFreezeCoordinator);
123
+ if (controller.getViewMode() === ViewModes.INTERACTIVE) {
124
+ uiFreezeCoordinator.init($placeholder);
125
+ }
126
+ }
127
+ }).navigateToPage(function(event, pageNumber, targetElement) {
128
+ navigateToPage(pageNumber, targetElement);
129
+ }).pageReady(function(event, page) {
130
+ if (controller.getPageMode() === PageModes.SINGLE_PAGE) {
131
+ if (scroll.isEnabled()) {
132
+ scroll.disable();
133
+ }
134
+ setPageContent(page);
135
+ } else {
136
+ scroll.renderPage(page);
137
+ }
138
+ if (!reportPageIsLoaded) {
139
+ reportPageIsLoaded = true;
140
+ }
141
+ if (showPageAreaImage) {
142
+ clearPageAreaImage();
143
+ }
144
+ if (controller.getViewMode() === ViewModes.INTERACTIVE && uiFreezeCoordinator) {
145
+ uiFreezeCoordinator.init($placeholder);
146
+ }
147
+ disablePagesArea(false);
148
+ }).error(function(event, error) {
149
+ disablePagesArea(false);
150
+ clearPage();
151
+ showError(error);
152
+ }).showNotification(function(event, args) {
153
+ showError(stringResources[args.stringResources]);
154
+ }).hideNotification(function(event, args) {
155
+ showError();
156
+ }).scaleChanged(function(event, scale) {
157
+ setPageScale({
158
+ scale,
159
+ scaleMode: controller.getScaleMode()
160
+ });
161
+ }).scaleModeChanged(function(event, scaleMode) {
162
+ setPageScale({
163
+ scale: controller.getScale(),
164
+ scaleMode
165
+ });
166
+ }).serverActionStarted(function() {
167
+ disablePagesArea(true);
168
+ showError(stringResources.loadingReport);
169
+ }).scrollPageReady(function(event, args) {
170
+ setScrollablePage(args);
171
+ }).missingOrInvalidParameters(function(event, args) {
172
+ if (options.initialPageAreaImageUrl && !reportPageIsLoaded) {
173
+ clearPage();
174
+ setPageAreaImage();
175
+ }
176
+ }).renderingStopped(function() {
177
+ clear(true);
178
+ showError(stringResources.renderingCanceled);
179
+ });
180
+ controller.setDocumentMapVisible(function() {
181
+ if (shouldAutosizePage()) {
182
+ setTimeout(function() {
183
+ updatePageDimensions();
184
+ });
185
+ }
186
+ }).setParametersAreaVisible(function() {
187
+ if (shouldAutosizePage()) {
188
+ setTimeout(function() {
189
+ updatePageDimensions();
190
+ });
191
+ }
192
+ });
193
+ function enableTouch(dom) {
194
+ var allowSwipeLeft;
195
+ var allowSwipeRight;
196
+ TouchBehavior(
197
+ dom,
198
+ {
199
+ swipe: function(e) {
200
+ var pageNumber = controller.getCurrentPageNumber();
201
+ if (allowSwipeLeft && e.direction === "left") {
202
+ if (pageNumber < controller.getPageCount()) {
203
+ controller.navigateToPage(pageNumber + 1);
204
+ }
205
+ } else if (allowSwipeRight && e.direction === "right") {
206
+ if (pageNumber > 1) {
207
+ controller.navigateToPage(pageNumber - 1);
208
+ }
209
+ }
210
+ },
211
+ pinch: function(e) {
212
+ var page = getCurrentPage();
213
+ var scale = $(page).data("pageScale") || pageScale;
214
+ var f = e.distance / e.lastDistance;
215
+ setPageScale({
216
+ scale: scale * f,
217
+ scaleMode: ScaleModes.SPECIFIC
218
+ });
219
+ },
220
+ doubletap: function(e) {
221
+ options.commands.toggleZoomMode.exec();
222
+ },
223
+ touchstart: function(e) {
224
+ var el = pageWrapper;
225
+ allowSwipeRight = 0 === el.scrollLeft;
226
+ allowSwipeLeft = el.scrollWidth - el.offsetWidth === el.scrollLeft;
227
+ }
228
+ }
229
+ );
230
+ }
231
+ function shouldAutosizePage() {
232
+ return -1 !== [ScaleModes.FIT_PAGE, ScaleModes.FIT_PAGE_WIDTH].indexOf(pageScaleMode);
233
+ }
234
+ function updatePageDimensions() {
235
+ for (var i = 0, children = $pageContainer.find(".trv-report-page"), len = children.length; i < len; i++) {
236
+ var pageNumber = parseInt($(children[i]).attr("data-page"));
237
+ setPageDimensions(children[i], pageScaleMode, pageScale, pageNumber);
238
+ }
239
+ controller.updatePageDimensionsReady();
240
+ }
241
+ function setPageScale({ scale, scaleMode }) {
242
+ pageScale = scale || pageScale;
243
+ pageScaleMode = scaleMode || pageScaleMode;
244
+ pageScale = Math.max(minPageScale, Math.min(maxPageScale, pageScale));
245
+ updatePageDimensions();
246
+ }
247
+ function clear(clearPageWrapper) {
248
+ disableInteractivity();
249
+ pendingElement = void 0;
250
+ if (clearPageWrapper) {
251
+ $pageWrapper.empty();
252
+ }
253
+ showError();
254
+ }
255
+ function getCurrentPage() {
256
+ return findPage(controller.getCurrentPageNumber());
257
+ }
258
+ function findPage(pageNumber) {
259
+ var result;
260
+ var allPages = $pageContainer.find(".trv-report-page");
261
+ if (controller.getPageMode() === PageModes.SINGLE_PAGE) {
262
+ result = Array.from(allPages).find((page) => {
263
+ return pageNo(page) === pageNumber;
264
+ });
265
+ } else {
266
+ result = Array.from(allPages).find((page) => {
267
+ var dataPageNumber = parseInt($(page).attr("data-page"));
268
+ return dataPageNumber === pageNumber;
269
+ });
270
+ }
271
+ return result;
272
+ }
273
+ function navigateToPage(pageNumber, targetElement) {
274
+ if (documentReady) {
275
+ navigateToPageCore(pageNumber, targetElement);
276
+ } else {
277
+ navigateToPageOnDocumentReady(pageNumber, targetElement);
278
+ }
279
+ }
280
+ function navigateToPageOnDocumentReady(pageNumber, targetElement) {
281
+ navigateToPageOnDocReady = pageNumber;
282
+ navigateToElementOnDocReady = targetElement;
283
+ }
284
+ function navigateToPageCore(pageNumber, targetElement) {
285
+ var page = findPage(pageNumber);
286
+ if (page) {
287
+ if (targetElement) {
288
+ navigateToElement(targetElement, pageNumber);
289
+ }
290
+ if (scroll.isEnabled() && !targetElement) {
291
+ scroll.navigateToElement(page.offsetTop, pageNumber);
292
+ }
293
+ } else {
294
+ pendingElement = targetElement;
295
+ beginLoadPage(pageNumber);
296
+ }
297
+ }
298
+ function navigateToElement(targetElement, pageNumber) {
299
+ if (targetElement) {
300
+ var el = $pageContainer.find("[data-" + targetElement.type + "-id=" + targetElement.id + "]")[0];
301
+ if (el) {
302
+ if (options.enableAccessibility) {
303
+ var $nextFocusable = findNextFocusableElement($(el));
304
+ if ($nextFocusable) {
305
+ $nextFocusable.focus();
306
+ }
307
+ }
308
+ var container = $pageContainer[0];
309
+ var offsetTop = 0;
310
+ var offsetLeft = 0;
311
+ while (el && el !== container) {
312
+ if ($(el).is(".trv-page-wrapper")) {
313
+ var scale = $(el).data("pageScale");
314
+ if (typeof scale === "number") {
315
+ offsetTop *= scale;
316
+ offsetLeft *= scale;
317
+ }
318
+ }
319
+ offsetTop += el.offsetTop;
320
+ offsetLeft += el.offsetLeft;
321
+ el = el.offsetParent;
322
+ }
323
+ if (scroll.isEnabled() && pageNumber) {
324
+ scroll.navigateToElement(offsetTop, pageNumber);
325
+ } else {
326
+ container.scrollTop = offsetTop;
327
+ container.scrollLeft = offsetLeft;
328
+ }
329
+ } else {
330
+ if (scroll.isEnabled() && pageNumber) {
331
+ scroll.navigateToElement($placeholder.find('[data-page="' + pageNumber + '"]')[0].offsetTop, pageNumber);
332
+ }
333
+ }
334
+ }
335
+ }
336
+ function findNextFocusableElement(element) {
337
+ if (!element || element.length === 0) {
338
+ return null;
339
+ }
340
+ var num = tryParseInt(element.attr("tabindex"));
341
+ if (!isNaN(num) && num > -1) {
342
+ return element;
343
+ }
344
+ return findNextFocusableElement(element.next());
345
+ }
346
+ function disablePagesArea(disable) {
347
+ (disable ? $.fn.addClass : $.fn.removeClass).call($placeholder, "trv-loading");
348
+ }
349
+ function showError(error) {
350
+ $errorMessage.text(error);
351
+ (error ? $.fn.addClass : $.fn.removeClass).call($placeholder, "trv-error");
352
+ }
353
+ function pageNo(page, no) {
354
+ var $page = page.$ ? page : $(page);
355
+ var dataKey = "pageNumber";
356
+ if (no === void 0) {
357
+ return $page.data(dataKey);
358
+ }
359
+ $page.data(dataKey, no);
360
+ return page;
361
+ }
362
+ function beginLoadPage(pageNumber) {
363
+ disablePagesArea(true);
364
+ window.setTimeout(controller.getReportPage.bind(controller, pageNumber), 1);
365
+ navigateToPageOnDocReady = null;
366
+ }
367
+ function setPageDimensions(page, scaleMode, scale$1, pageNumber) {
368
+ var $target = $(page);
369
+ var $page = pageNumber ? $target : $target.find("div.trv-report-page");
370
+ var $pageContent = $page.find("div.sheet");
371
+ var $pageSkeletonContent = $page.find("div.trv-skeleton-wrapper");
372
+ var pageContent = $pageContent[0] || $pageSkeletonContent[0];
373
+ var pageSkeletonContent = $pageSkeletonContent[0];
374
+ if (!pageContent) {
375
+ return;
376
+ }
377
+ var pageWidth;
378
+ var pageHeight;
379
+ var box = $target.data("box");
380
+ if (!box) {
381
+ var margins = getMargins($target);
382
+ var borders = getBorderWidth($page);
383
+ var padding = getPadding($page);
384
+ box = {
385
+ padLeft: margins.left + borders.left + padding.left,
386
+ padRight: margins.right + borders.right + padding.right,
387
+ padTop: margins.top + borders.top + padding.top,
388
+ padBottom: margins.bottom + borders.bottom + padding.bottom
389
+ };
390
+ $target.data("box", box);
391
+ }
392
+ if ($target.data("pageWidth") === void 0) {
393
+ pageWidth = pageContent.offsetWidth;
394
+ pageHeight = pageContent.offsetHeight;
395
+ $target.data("pageWidth", pageWidth);
396
+ $target.data("pageHeight", pageHeight);
397
+ } else {
398
+ pageWidth = $target.data("pageWidth");
399
+ pageHeight = $target.data("pageHeight");
400
+ }
401
+ var scrollBarV = pageHeight > pageWidth && scaleMode === ScaleModes.FIT_PAGE_WIDTH ? 20 : 0;
402
+ var scaleW = (pageContainer.clientWidth - scrollBarV - box.padLeft - box.padRight) / pageWidth;
403
+ var scaleH = (pageContainer.clientHeight - 1 - box.padTop - box.padBottom) / pageHeight;
404
+ if (scaleMode === ScaleModes.FIT_PAGE_WIDTH) {
405
+ scale$1 = scaleW;
406
+ } else if (!scale$1 || scaleMode === ScaleModes.FIT_PAGE) {
407
+ scale$1 = Math.min(scaleW, scaleH);
408
+ }
409
+ if (uiFreezeCoordinator) {
410
+ uiFreezeCoordinator.setScaleFactor(scale$1);
411
+ }
412
+ $target.data("pageScale", scale$1);
413
+ $page.data("pageScale", scale$1);
414
+ if (!pageSkeletonContent) {
415
+ scale($pageContent, scale$1, scale$1);
416
+ }
417
+ $page.css({
418
+ "height": scale$1 * pageHeight,
419
+ "width": scale$1 * pageWidth
420
+ });
421
+ }
422
+ function enableInteractivity() {
423
+ $pageContainer.on("click", "[data-reporting-action]", onInteractiveItemClick);
424
+ $pageContainer.on("mouseenter", "[data-reporting-action]", onInteractiveItemEnter);
425
+ $pageContainer.on("mouseleave", "[data-reporting-action]", onInteractiveItemLeave);
426
+ $pageContainer.on("mouseenter", "[data-tooltip-title],[data-tooltip-text]", onToolTipItemEnter);
427
+ $pageContainer.on("mouseleave", "[data-tooltip-title],[data-tooltip-text]", onToolTipItemLeave);
428
+ }
429
+ function disableInteractivity() {
430
+ $pageContainer.off("click", "[data-reporting-action]", onInteractiveItemClick);
431
+ $pageContainer.off("mouseenter", "[data-reporting-action]", onInteractiveItemEnter);
432
+ $pageContainer.off("mouseleave", "[data-reporting-action]", onInteractiveItemLeave);
433
+ $pageContainer.off("mouseenter", "[data-tooltip-title],[data-tooltip-text]", onToolTipItemEnter);
434
+ $pageContainer.off("mouseleave", "[data-tooltip-title],[data-tooltip-text]", onToolTipItemLeave);
435
+ }
436
+ function onInteractiveItemClick(event) {
437
+ var $eventTarget = $(this);
438
+ var actionId = $eventTarget.attr("data-reporting-action");
439
+ var action = getAction(actionId);
440
+ if (action) {
441
+ navigateToPageOnDocReady = getNavigateToPageOnDocReady(event, action.Type);
442
+ controller.executeReportAction({
443
+ element: event.currentTarget,
444
+ action,
445
+ cancel: false
446
+ });
447
+ }
448
+ event.stopPropagation();
449
+ }
450
+ function getNavigateToPageOnDocReady(event, actionType) {
451
+ if (scroll.isEnabled() && (actionType === "sorting" || actionType === "toggleVisibility")) {
452
+ return $(event.target).closest(".trv-report-page").attr("data-page") || controller.getCurrentPageNumber();
453
+ }
454
+ return controller.getCurrentPageNumber();
455
+ }
456
+ function onInteractiveItemEnter(args) {
457
+ var $t = $(this);
458
+ var actionId = $t.attr("data-reporting-action");
459
+ var a = getAction(actionId);
460
+ if (a !== null && args.currentTarget === this) {
461
+ controller.reportActionEnter({
462
+ element: args.currentTarget,
463
+ action: a
464
+ });
465
+ }
466
+ }
467
+ function onInteractiveItemLeave(args) {
468
+ var $t = $(this);
469
+ var actionId = $t.attr("data-reporting-action");
470
+ var a = getAction(actionId);
471
+ if (a !== null && args.currentTarget === this) {
472
+ controller.reportActionLeave({
473
+ element: args.currentTarget,
474
+ action: a
475
+ });
476
+ }
477
+ }
478
+ function getAction(actionId) {
479
+ if (actions) {
480
+ return Array.from(actions).find(function(action) {
481
+ return action.Id === actionId;
482
+ });
483
+ }
484
+ return null;
485
+ }
486
+ function onToolTipItemEnter(args) {
487
+ var $t = $(this);
488
+ var title = $t.attr("data-tooltip-title");
489
+ var text = $t.attr("data-tooltip-text");
490
+ if (!title && !text) {
491
+ return;
492
+ }
493
+ var toolTipArgs = {
494
+ element: args.currentTarget,
495
+ toolTip: {
496
+ title: title || "",
497
+ text: text || ""
498
+ },
499
+ cancel: false
500
+ };
501
+ controller.reportToolTipOpening(toolTipArgs);
502
+ if (toolTipArgs.cancel) {
503
+ return;
504
+ }
505
+ var content = applyToolTipTemplate(toolTipArgs);
506
+ var viewportElement = args.currentTarget.viewportElement;
507
+ var ktt = getToolTip($t, content);
508
+ ktt.show($t);
509
+ if (viewportElement && viewportElement.nodeName === "svg") {
510
+ positionToolTip(ktt, args);
511
+ }
512
+ }
513
+ function applyToolTipTemplate(toolTipArgs) {
514
+ var toolTipTemplate = options.templates["trv-pages-area-kendo-tooltip"];
515
+ var $container = $(toolTipTemplate);
516
+ var $titleSpan = $container.find(".trv-pages-area-kendo-tooltip-title");
517
+ var $textSpan = $container.find(".trv-pages-area-kendo-tooltip-text");
518
+ $titleSpan.html(replaceNewLineSymbols(toolTipArgs.toolTip.title));
519
+ $textSpan.html(replaceNewLineSymbols(toolTipArgs.toolTip.text));
520
+ return $container.clone().wrap("<p>").parent().html();
521
+ }
522
+ function replaceNewLineSymbols(tooltipText) {
523
+ tooltipText = escapeHtml(tooltipText);
524
+ tooltipText = tooltipText.replaceAll("\r\n", "<br>");
525
+ tooltipText = tooltipText.replaceAll("\n", "<br>");
526
+ return tooltipText;
527
+ }
528
+ function positionToolTip(toolTip, e) {
529
+ var x = e.pageX;
530
+ var y = e.pageY;
531
+ var container = toolTip.popup.element.closest("[role=region]");
532
+ container.css({
533
+ left: x + 10,
534
+ top: y + 5
535
+ });
536
+ }
537
+ function getToolTip(target, toolTipContent) {
538
+ var ktt = target.data("kendoTooltip");
539
+ if (!ktt) {
540
+ try {
541
+ ktt = target.kendoTooltip({
542
+ content: toolTipContent,
543
+ autohide: true,
544
+ callout: false
545
+ }).data("kendoTooltip");
546
+ } catch (e) {
547
+ console.error("Instantiation of Kendo Tooltip threw an exception", e);
548
+ throw e;
549
+ }
550
+ }
551
+ return ktt;
552
+ }
553
+ function onToolTipItemLeave(args) {
554
+ var $t = $(this);
555
+ var toolTip = $t.data("kendoTooltip");
556
+ if (toolTip) {
557
+ toolTip.hide();
558
+ }
559
+ }
560
+ function updatePageStyle(page) {
561
+ var styleId = "trv-" + controller.clientId() + "-styles";
562
+ $("#" + styleId).remove();
563
+ var pageStyles = $("<style id=" + styleId + "></style>");
564
+ pageStyles.append(page.pageStyles);
565
+ pageStyles.appendTo("head");
566
+ }
567
+ function setPageContent(page) {
568
+ actions = JSON.parse(page.pageActions);
569
+ updatePageStyle(page);
570
+ var pageNumber = page.pageNumber;
571
+ var wrapper = $($.parseHTML(page.pageContent));
572
+ var $pageContent = wrapper.find("div.sheet");
573
+ var $page = $('<div class="trv-report-page" data-page="' + pageNumber + '"></div>');
574
+ $pageContent.css("margin", 0);
575
+ $page.append($pageContent).append($('<div class="trv-page-overlay"></div>'));
576
+ var $target = $pageWrapper.empty().removeData().data("pageNumber", pageNumber).append($page);
577
+ controller.setCurrentPageNumber(pageNumber);
578
+ if (controller.getViewMode() === ViewModes.INTERACTIVE) {
579
+ $placeholder.removeClass("printpreview");
580
+ $placeholder.addClass("interactive");
581
+ } else {
582
+ $placeholder.removeClass("interactive");
583
+ $placeholder.addClass("printpreview");
584
+ }
585
+ setPageDimensions($target, pageScaleMode, pageScale);
586
+ $pageContainer.scrollTop(0);
587
+ $pageContainer.scrollLeft(0);
588
+ navigateToElement(pendingElement);
589
+ }
590
+ function setScrollablePage(args) {
591
+ var pageActions = JSON.parse(args.page.pageActions);
592
+ if (!actions) {
593
+ actions = pageActions;
594
+ } else {
595
+ actions = actions.concat(pageActions);
596
+ }
597
+ if (controller.getViewMode() === ViewModes.INTERACTIVE) {
598
+ $placeholder.removeClass("printpreview");
599
+ $placeholder.addClass("interactive");
600
+ } else {
601
+ $placeholder.removeClass("interactive");
602
+ $placeholder.addClass("printpreview");
603
+ }
604
+ setPageDimensions(args.target, pageScaleMode, pageScale, args.page.pageNumber);
605
+ }
606
+ function setPageAreaImage() {
607
+ var pageStyles = $("<style id=" + pageAreaImageID + "></style>");
608
+ clearPageAreaImage();
609
+ pageStyles.append(stringFormat(pageAreaImageStyle, [options.initialPageAreaImageUrl]));
610
+ pageStyles.appendTo("head");
611
+ showPageAreaImage = true;
612
+ }
613
+ function clearPageAreaImage() {
614
+ $("#" + pageAreaImageID).remove();
615
+ }
616
+ }
617
+
618
+ export { PagesArea };