@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,39 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var utils = require('./utils.js');
6
+
7
+ const TemplateCache = function() {
8
+ var cache = {};
9
+ return {
10
+ load: function(url, serviceUrl, client) {
11
+ var p = cache[url];
12
+ if (!p) {
13
+ cache[url] = p = client.get(url).then(function(html) {
14
+ var templates = {};
15
+ var styleSheets = [];
16
+ var baseUri = utils.rTrim(serviceUrl, "\\/") + "/";
17
+ html = utils.replaceAll(html, "{service}/", baseUri);
18
+ html = utils.replaceAll(html, "{service}", baseUri);
19
+ var viewerTemplate = $("<div></div>").html(html);
20
+ Array.from(viewerTemplate.find("template")).forEach((element) => {
21
+ var $element = $(element);
22
+ templates[$element.attr("id")] = utils.trim($element.html(), "\n ");
23
+ });
24
+ Array.from(viewerTemplate.find("link")).forEach((element) => {
25
+ styleSheets.push(utils.trim(element.outerHTML, "\n "));
26
+ });
27
+ styleSheets = utils.filterUniqueLastOccurrence(styleSheets);
28
+ return {
29
+ templates,
30
+ styleSheets
31
+ };
32
+ });
33
+ }
34
+ return p;
35
+ }
36
+ };
37
+ }();
38
+
39
+ exports.TemplateCache = TemplateCache;
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var baseComponent = require('../base-component.js');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __publicField = (obj, key, value) => {
10
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
+ return value;
12
+ };
13
+ class LinkButton extends baseComponent.BaseComponent {
14
+ // #endregion
15
+ // #region constructor
16
+ constructor(element, options) {
17
+ super(element, options);
18
+ // #region fields
19
+ __publicField(this, "cmd");
20
+ var dataCommand = this.$element.attr("data-command");
21
+ if (dataCommand) {
22
+ this.cmd = this.options.commands[dataCommand];
23
+ }
24
+ if (this.cmd) {
25
+ this.$element.on("click", (event) => {
26
+ if (this.cmd.enabled()) {
27
+ this.cmd.exec($(this).attr("data-command-parameter"));
28
+ } else {
29
+ event.preventDefault();
30
+ }
31
+ });
32
+ $(this.cmd).on("enabledChanged", (event) => {
33
+ (this.cmd.enabled() ? $.fn.removeClass : $.fn.addClass).call(this.$element, "disabled");
34
+ }).on("checkedChanged", (event) => {
35
+ (this.cmd.checked() ? $.fn.addClass : $.fn.removeClass).call(this.$element, "checked");
36
+ });
37
+ }
38
+ }
39
+ // #endregion
40
+ }
41
+
42
+ exports.LinkButton = LinkButton;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var baseComponent = require('../base-component.js');
6
+
7
+ class PageCountLabel extends baseComponent.BaseComponent {
8
+ // #region constructor
9
+ constructor(element, options) {
10
+ super(element, options);
11
+ this.options.controller.pageCountChange((event, value) => {
12
+ this.$element.text(value);
13
+ });
14
+ }
15
+ // #endregion
16
+ }
17
+
18
+ exports.PageCountLabel = PageCountLabel;
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var baseComponent = require('../base-component.js');
6
+ var utils = require('../utils.js');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __publicField = (obj, key, value) => {
11
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
12
+ return value;
13
+ };
14
+ class PageNumberInput extends baseComponent.BaseComponent {
15
+ // #endregion
16
+ // #region constructor
17
+ constructor(element, options) {
18
+ super(element, options);
19
+ // #region fields
20
+ __publicField(this, "cmd");
21
+ __publicField(this, "_numeric");
22
+ this.cmd = this.options.commands["goToPage"];
23
+ this._numeric = new kendo.ui.NumericTextBox(this.element, {
24
+ format: "0",
25
+ decimals: 0,
26
+ min: 0,
27
+ spinners: false,
28
+ change: this._onChange.bind(this),
29
+ spin: this._onChange.bind(this)
30
+ });
31
+ this._numeric._text[0].dataset.role = "telerik_ReportViewer_PageNumberInput";
32
+ this._numeric.element[0].dataset.role = "";
33
+ this.options.controller.on("reportLoadComplete", (event, reportInfo) => {
34
+ this._numeric.max(reportInfo.pageCount);
35
+ this._numeric.min(Math.min(1, reportInfo.pageCount));
36
+ this._numeric.value(Math.min(1, reportInfo.pageCount));
37
+ }).on("loadedReportChange", (event) => {
38
+ this._numeric.min(0);
39
+ this._numeric.max(0);
40
+ this._numeric.value(0);
41
+ }).on("renderingStopped", (event) => {
42
+ this._numeric.min(0);
43
+ this._numeric.max(0);
44
+ this._numeric.value(0);
45
+ }).pageNumberChange((event, value) => {
46
+ this._numeric.value(value);
47
+ });
48
+ }
49
+ // #endregion
50
+ // #region event handlers
51
+ _onChange(event, data) {
52
+ var val = this._numeric.value();
53
+ var num = utils.tryParseInt(val);
54
+ if (!isNaN(num)) {
55
+ this.cmd.exec(num);
56
+ }
57
+ }
58
+ _onSpin(event, data) {
59
+ return this._onChange(event, data);
60
+ }
61
+ // #endregion
62
+ }
63
+
64
+ exports.PageNumberInput = PageNumberInput;
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function TouchBehavior(dom, options) {
6
+ var startDistance;
7
+ var ignoreTouch;
8
+ init(dom);
9
+ function init(element) {
10
+ if (typeof $.fn.kendoTouch === "function") {
11
+ try {
12
+ $(element).mousedown(function() {
13
+ ignoreTouch = true;
14
+ }).mouseup(function() {
15
+ ignoreTouch = false;
16
+ }).kendoTouch({
17
+ multiTouch: true,
18
+ enableSwipe: true,
19
+ swipe: function(e) {
20
+ if (!ignoreTouch) {
21
+ onSwipe(e);
22
+ }
23
+ },
24
+ gesturestart: function(e) {
25
+ if (!ignoreTouch) {
26
+ onGestureStart(e);
27
+ }
28
+ },
29
+ gestureend: function(e) {
30
+ if (!ignoreTouch) {
31
+ onGestureEnd(e);
32
+ }
33
+ },
34
+ gesturechange: function(e) {
35
+ if (!ignoreTouch) {
36
+ onGestureChange(e);
37
+ }
38
+ },
39
+ doubletap: function(e) {
40
+ if (!ignoreTouch) {
41
+ onDoubleTap(e);
42
+ }
43
+ },
44
+ touchstart: function(e) {
45
+ if (!ignoreTouch) {
46
+ fire("touchstart");
47
+ }
48
+ }
49
+ });
50
+ } catch (e) {
51
+ console.error("Instantiation of Kendo Touch threw an exception", e);
52
+ throw e;
53
+ }
54
+ }
55
+ }
56
+ function onDoubleTap(e) {
57
+ fire("doubletap", e);
58
+ }
59
+ function onGestureStart(e) {
60
+ startDistance = kendo.touchDelta(e.touches[0], e.touches[1]).distance;
61
+ }
62
+ function onGestureEnd(e) {
63
+ }
64
+ function onGestureChange(e) {
65
+ var current = kendo.touchDelta(e.touches[0], e.touches[1]).distance;
66
+ onPinch({
67
+ distance: current,
68
+ lastDistance: startDistance
69
+ });
70
+ startDistance = current;
71
+ }
72
+ function onSwipe(e) {
73
+ fire("swipe", e);
74
+ }
75
+ function onPinch(e) {
76
+ fire("pinch", e);
77
+ }
78
+ function fire(func, args) {
79
+ var handler = options[func];
80
+ if (typeof handler === "function") {
81
+ handler(args);
82
+ }
83
+ }
84
+ }
85
+
86
+ exports.TouchBehavior = TouchBehavior;
@@ -0,0 +1,142 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var enums = require('./enums.js');
6
+
7
+ function UIController(options) {
8
+ var stateFlags = {
9
+ ExportInProgress: 1 << 0,
10
+ PrintInProgress: 1 << 1,
11
+ RenderInProgress: 1 << 2
12
+ };
13
+ function getState(flags) {
14
+ return (state & flags) != 0;
15
+ }
16
+ function setState(flags, value) {
17
+ if (value) {
18
+ state |= flags;
19
+ } else {
20
+ state &= ~flags;
21
+ }
22
+ }
23
+ var controller = options.controller;
24
+ var historyManager = options.history;
25
+ var state = 0;
26
+ var refreshUI;
27
+ var commands = options.commands;
28
+ if (!controller) {
29
+ throw "No controller (telerikReporting.ReportViewerController) has been specified.";
30
+ }
31
+ function getDocumentMapState() {
32
+ var args = {};
33
+ controller.getDocumentMapState(args);
34
+ return args;
35
+ }
36
+ function getParametersAreaState() {
37
+ var args = {};
38
+ controller.getParametersAreaState(args);
39
+ return args;
40
+ }
41
+ function getSearchDialogState() {
42
+ var args = {};
43
+ controller.getSearchDialogState(args);
44
+ return args;
45
+ }
46
+ function getSendEmailDialogState() {
47
+ var args = {};
48
+ controller.getSendEmailDialogState(args);
49
+ return args;
50
+ }
51
+ function updateUI() {
52
+ if (!refreshUI) {
53
+ refreshUI = true;
54
+ window.setTimeout(function() {
55
+ try {
56
+ updateUICore();
57
+ } finally {
58
+ refreshUI = false;
59
+ }
60
+ }, 10);
61
+ }
62
+ }
63
+ function updateUICore() {
64
+ var rs = controller.getReportSource();
65
+ var pageCount = controller.getPageCount();
66
+ var currentPageNumber = controller.getCurrentPageNumber();
67
+ var hasReport = rs && rs.report;
68
+ var hasPages = hasReport && pageCount > 0;
69
+ var nextPage = hasPages && currentPageNumber < pageCount;
70
+ var prevPage = hasPages && currentPageNumber > 1;
71
+ var hasPage = hasPages && currentPageNumber;
72
+ var documentMapState = getDocumentMapState();
73
+ var parametersAreaState = getParametersAreaState();
74
+ var searchDialogState = getSearchDialogState();
75
+ var sendEmailDialogState = getSendEmailDialogState();
76
+ var renderInProgress = getState(stateFlags.RenderInProgress);
77
+ var printInProgress = getState(stateFlags.PrintInProgress);
78
+ var exportInProgress = getState(stateFlags.ExportInProgress);
79
+ commands.goToFirstPage.enabled(prevPage);
80
+ commands.goToPrevPage.enabled(prevPage);
81
+ commands.stopRendering.enabled(hasReport && renderInProgress);
82
+ commands.goToLastPage.enabled(nextPage);
83
+ commands.goToNextPage.enabled(nextPage);
84
+ commands.goToPage.enabled(hasPages);
85
+ commands.print.enabled(hasPages && !renderInProgress && !printInProgress);
86
+ commands.export.enabled(hasPages && !renderInProgress && !exportInProgress);
87
+ commands.refresh.enabled(hasReport);
88
+ commands.historyBack.enabled(historyManager && historyManager.canMoveBack());
89
+ commands.historyForward.enabled(historyManager && historyManager.canMoveForward());
90
+ commands.toggleDocumentMap.enabled(hasReport && documentMapState.enabled).checked(documentMapState.enabled && documentMapState.visible);
91
+ commands.toggleParametersArea.enabled(hasReport && parametersAreaState.enabled).checked(parametersAreaState.enabled && parametersAreaState.visible);
92
+ commands.togglePrintPreview.enabled(hasPages).checked(controller.getViewMode() == enums.ViewModes.PRINT_PREVIEW);
93
+ commands.pageMode.enabled(hasPages).checked(controller.getPageMode() == enums.PageModes.CONTINUOUS_SCROLL);
94
+ commands.zoom.enabled(hasPage);
95
+ commands.zoomIn.enabled(hasPage);
96
+ commands.zoomOut.enabled(hasPage);
97
+ commands.toggleZoomMode.enabled(hasPage).checked(controller.getScaleMode() == enums.ScaleModes.FIT_PAGE || controller.getScaleMode() == enums.ScaleModes.FIT_PAGE_WIDTH);
98
+ commands.toggleSearchDialog.enabled(hasPages).checked(searchDialogState.visible);
99
+ commands.toggleSendEmailDialog.enabled(hasPages).checked(sendEmailDialogState.visible);
100
+ controller.updateUI(null);
101
+ controller.pageNumberChange(currentPageNumber);
102
+ controller.pageCountChange(pageCount);
103
+ }
104
+ controller.setParametersAreaVisible(updateUI);
105
+ controller.setDocumentMapVisible(updateUI);
106
+ controller.updateUIInternal(updateUI);
107
+ controller.setSearchDialogVisible(updateUI);
108
+ controller.setSendEmailDialogVisible(updateUI);
109
+ controller.scaleModeChanged(updateUI);
110
+ controller.currentPageChanged(updateUI);
111
+ controller.beforeLoadReport(function() {
112
+ setState(stateFlags.RenderInProgress, true);
113
+ updateUI();
114
+ });
115
+ controller.reportLoadProgress(updateUI);
116
+ controller.reportLoadComplete(function() {
117
+ setState(stateFlags.RenderInProgress, false);
118
+ updateUI();
119
+ });
120
+ controller.reportSourceChanged(updateUI);
121
+ controller.viewModeChanged(updateUI);
122
+ controller.pageModeChanged(function() {
123
+ updateUI();
124
+ });
125
+ controller.setUIState(function(event, args) {
126
+ setState(stateFlags[args.operationName], args.inProgress);
127
+ updateUI();
128
+ });
129
+ controller.error(function() {
130
+ setState(stateFlags.ExportInProgress, false);
131
+ setState(stateFlags.PrintInProgress, false);
132
+ setState(stateFlags.RenderInProgress, false);
133
+ updateUI();
134
+ });
135
+ controller.renderingStopped(function() {
136
+ setState(stateFlags.RenderInProgress, false);
137
+ updateUI();
138
+ });
139
+ updateUI();
140
+ }
141
+
142
+ exports.UIController = UIController;
@@ -0,0 +1,282 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var utils = require('./utils.js');
6
+
7
+ var UIFreezeCoordinator = {
8
+ $placeholder: null,
9
+ $scrollableContainer: null,
10
+ // Holds all items initial position per container
11
+ itemsInitialState: {},
12
+ // Holds the bounds of the frozen areas by X per container
13
+ xFrozenAreasBounds: {},
14
+ // Holds the bounds of the frozen areas by Y per container
15
+ yFrozenAreasBounds: {},
16
+ freezeMaxZIndex: {},
17
+ zIndex: 1,
18
+ // Holds default background-color value per container
19
+ freezeBGColor: {},
20
+ // Holds whether freezing has been applied per container.
21
+ currentlyFrozenContainer: {
22
+ vertical: {},
23
+ horizontal: {}
24
+ },
25
+ isInitialize: false,
26
+ scaleFactor: null,
27
+ /**
28
+ * Initialize the uiFreezeCoordinator object
29
+ * Takes one parameter
30
+ * - $placeholder - PageArea jQuery DOM element
31
+ */
32
+ init: function($placeholder) {
33
+ this.$placeholder = $placeholder;
34
+ this.$scrollableContainer = $placeholder.find(".trv-page-container");
35
+ if (this.isInitialize) {
36
+ this.reset($placeholder);
37
+ }
38
+ this._attachToScrollEvent();
39
+ this.isInitialize = true;
40
+ },
41
+ reset: function($placeholder) {
42
+ this.$placeholder = $placeholder;
43
+ this.$scrollableContainer = $placeholder.find(".trv-page-container");
44
+ this.itemsInitialState = {};
45
+ this.xFrozenAreasBounds = {};
46
+ this.yFrozenAreasBounds = {};
47
+ this.currentlyfreezedContainer = {
48
+ vertical: {},
49
+ horizontal: {}
50
+ };
51
+ },
52
+ setScaleFactor: function(scale) {
53
+ this.scaleFactor = scale;
54
+ },
55
+ /**
56
+ * Initializing scroll listener
57
+ */
58
+ _attachToScrollEvent: function() {
59
+ var thisInstance = this;
60
+ this.$scrollableContainer.scroll(function updateFreezeUIOnScroll() {
61
+ var $freezeItems = thisInstance.$scrollableContainer.find("div[data-sticky-id]");
62
+ if ($freezeItems.length) {
63
+ var tableIDs = $freezeItems.map(function(index2, $element) {
64
+ return $($element).attr("data-sticky-id");
65
+ }).get();
66
+ var uniqueIDs = tableIDs.filter(function(item, index2) {
67
+ return index2 === tableIDs.indexOf(item);
68
+ });
69
+ var scrollableContainerScrollTop = thisInstance.$scrollableContainer.scrollTop();
70
+ var scrollableContainerScrollLeft = thisInstance.$scrollableContainer.scrollLeft();
71
+ for (var index = 0; index < uniqueIDs.length; index++) {
72
+ var freezeItemsContainerID = uniqueIDs[index];
73
+ if (!thisInstance.itemsInitialState[freezeItemsContainerID]) {
74
+ thisInstance._saveFreezeItemsInitialState(freezeItemsContainerID);
75
+ }
76
+ thisInstance._updateFreezeItemsOnScroll(
77
+ freezeItemsContainerID,
78
+ scrollableContainerScrollTop,
79
+ scrollableContainerScrollLeft
80
+ );
81
+ }
82
+ }
83
+ });
84
+ },
85
+ _saveFreezeItemsInitialState: function(freezeItemsContainerID) {
86
+ var $allFreezeItems = $("[data-sticky-direction][data-sticky-id='" + freezeItemsContainerID + "']");
87
+ var $freezeActions = $("[data-reporting-action][data-sticky-id='" + freezeItemsContainerID + "']");
88
+ var yAreaBounds;
89
+ var xAreaBounds;
90
+ this.itemsInitialState[freezeItemsContainerID] = {};
91
+ this.freezeBGColor[freezeItemsContainerID] = $("[data-id='" + freezeItemsContainerID + "']").attr("data-sticky-bg-color");
92
+ for (var index = 0; index < $allFreezeItems.length; index++) {
93
+ var $item = $($allFreezeItems[index]);
94
+ var scrollDirection = $item.attr("data-sticky-direction");
95
+ var itemID = $item.attr("data-id");
96
+ var itemPosition = $item.position();
97
+ var scaledItemPosition = { top: itemPosition.top / this.scaleFactor, left: itemPosition.left / this.scaleFactor };
98
+ var itemBounds = utils.rectangle(scaledItemPosition.left, scaledItemPosition.top, $item.outerWidth(true) * this.scaleFactor, $item.outerHeight(true) * this.scaleFactor);
99
+ switch (scrollDirection) {
100
+ case "Vertical":
101
+ yAreaBounds = yAreaBounds ? yAreaBounds.union(itemBounds) : itemBounds;
102
+ break;
103
+ case "Horizontal":
104
+ xAreaBounds = xAreaBounds ? xAreaBounds.union(itemBounds) : itemBounds;
105
+ break;
106
+ }
107
+ this._saveFreezeItemInitialState(freezeItemsContainerID, $item, itemID, scaledItemPosition);
108
+ }
109
+ this.freezeMaxZIndex[freezeItemsContainerID] = $freezeActions.length ? $freezeActions.css("zIndex") : this.zIndex;
110
+ this.yFrozenAreasBounds[freezeItemsContainerID] = yAreaBounds;
111
+ this.xFrozenAreasBounds[freezeItemsContainerID] = xAreaBounds;
112
+ },
113
+ /**
114
+ * Save the freeze UI item initial position based on the wrapper element and current page
115
+ * - freezeItemsContainerID - string. A parent/wrapper element identifier
116
+ * - $item - JQuery DOM element of the freezed item
117
+ * - itemID - string. A ID of the freeze UI item
118
+ * - position - object. Contains the top and left values
119
+ */
120
+ _saveFreezeItemInitialState: function(freezeItemsContainerID, $item, itemID, position) {
121
+ var itemBgColor = $item.css("background-color");
122
+ var hasInitialBgColor = this._hasSetBgColor(itemBgColor);
123
+ var itemState = {
124
+ top: position.top,
125
+ left: position.left,
126
+ zIndex: $item.css("zIndex"),
127
+ hasBgColor: hasInitialBgColor
128
+ };
129
+ this.itemsInitialState[freezeItemsContainerID][itemID] = itemState;
130
+ },
131
+ _updateFreezeItemsOnScroll: function(freezeItemsContainerID, scrollableContainerScrollTop, scrollableContainerScrollLeft) {
132
+ var $elementWrapper = $("div[data-id='" + freezeItemsContainerID + "']");
133
+ if (this._isInScrollVisibleArea($elementWrapper)) {
134
+ var $pageContainer = $elementWrapper.closest(".trv-report-page");
135
+ var pageContainerPosition = $pageContainer.position();
136
+ var pageContainerMargin = parseFloat($pageContainer.css("margin-top"));
137
+ var pageContainerTopOffset = parseFloat($pageContainer.css("padding-top"));
138
+ var pageContainerLeftOffset = parseFloat($pageContainer.css("padding-left"));
139
+ var pageContainerBorderTopWidth = parseFloat($pageContainer.css("border-top-width"));
140
+ var pageContainerBorderLeftWidth = parseFloat($pageContainer.css("border-left-width"));
141
+ var $rowHeaders = $("[data-sticky-direction*='Horizontal'][data-sticky-id='" + freezeItemsContainerID + "']");
142
+ var $colHeaders = $("[data-sticky-direction*='Vertical'][data-sticky-id='" + freezeItemsContainerID + "']");
143
+ var hasFixRow = $rowHeaders.length > 0;
144
+ var hasFixColumn = $colHeaders.length > 0;
145
+ var elementWrapperPosition = $elementWrapper.position();
146
+ var elementWrapperTopPosition = elementWrapperPosition.top + pageContainerPosition.top + pageContainerMargin + pageContainerTopOffset + pageContainerBorderTopWidth;
147
+ var elementWrapperLeftPosition = elementWrapperPosition.left + pageContainerLeftOffset + pageContainerBorderLeftWidth;
148
+ var verticalMoveOffset = scrollableContainerScrollTop - elementWrapperTopPosition;
149
+ var horizontalMoveOffset = scrollableContainerScrollLeft - elementWrapperLeftPosition;
150
+ if (hasFixColumn && verticalMoveOffset > 0) {
151
+ if (scrollableContainerScrollTop <= $elementWrapper.outerHeight() * this.scaleFactor + elementWrapperTopPosition - this.yFrozenAreasBounds[freezeItemsContainerID].height) {
152
+ this.currentlyFrozenContainer.vertical[freezeItemsContainerID] = true;
153
+ this._updateUIElementsPosition($colHeaders, "top", verticalMoveOffset / this.scaleFactor, freezeItemsContainerID);
154
+ }
155
+ } else {
156
+ if (this.currentlyFrozenContainer.vertical[freezeItemsContainerID]) {
157
+ delete this.currentlyFrozenContainer.vertical[freezeItemsContainerID];
158
+ this._updateUIElementsPosition($colHeaders, "top", -1, freezeItemsContainerID);
159
+ }
160
+ }
161
+ if (hasFixRow && horizontalMoveOffset > 0) {
162
+ if (scrollableContainerScrollLeft <= $elementWrapper.outerWidth() * this.scaleFactor + elementWrapperLeftPosition - this.xFrozenAreasBounds[freezeItemsContainerID].width) {
163
+ this.currentlyFrozenContainer.horizontal[freezeItemsContainerID] = true;
164
+ this._updateUIElementsPosition($rowHeaders, "left", horizontalMoveOffset / this.scaleFactor, freezeItemsContainerID);
165
+ }
166
+ } else {
167
+ if (this.currentlyFrozenContainer.horizontal[freezeItemsContainerID]) {
168
+ delete this.currentlyFrozenContainer.horizontal[freezeItemsContainerID];
169
+ this._updateUIElementsPosition($rowHeaders, "left", -1, freezeItemsContainerID);
170
+ }
171
+ }
172
+ } else {
173
+ if (this.currentlyFrozenContainer.horizontal[freezeItemsContainerID] || this.currentlyFrozenContainer.vertical[freezeItemsContainerID]) {
174
+ this._resetToDefaultPosition(freezeItemsContainerID);
175
+ }
176
+ }
177
+ },
178
+ /**
179
+ * Move all freeze items to their initial position
180
+ * Takes one parameters
181
+ * - freezeItemsContainerID - string. A parent/wrapper element identifier
182
+ */
183
+ _resetToDefaultPosition: function(freezeItemsContainerID) {
184
+ var $rowHeaders = $("[data-sticky-direction*='Horizontal'][data-sticky-id='" + freezeItemsContainerID + "']");
185
+ var $colHeaders = $("[data-sticky-direction*='Vertical'][data-sticky-id='" + freezeItemsContainerID + "']");
186
+ this._updateUIElementsPosition($colHeaders, "top", -1, freezeItemsContainerID);
187
+ this._updateUIElementsPosition($rowHeaders, "left", -1, freezeItemsContainerID);
188
+ delete this.currentlyFrozenContainer.horizontal[freezeItemsContainerID];
189
+ delete this.currentlyFrozenContainer.vertical[freezeItemsContainerID];
190
+ },
191
+ /**
192
+ * Update the freeze elements position
193
+ * Takes four parameters
194
+ * - targetElements -Array. Collection of DOM element, that has a freeze attribute
195
+ * - position - string. Indicates which position property to be updated - top or left
196
+ * - offset - integer. The value of the increase that should be applied.
197
+ * If it is negative number, should not move the items and it should set their initial position
198
+ * - freezeItemsContainerID - string. A parent/wrapper element identifier
199
+ */
200
+ _updateUIElementsPosition: function(targetElements, position, offset, freezeItemsContainerID) {
201
+ for (var index = 0; index < targetElements.length; index++) {
202
+ var $item = $(targetElements[index]);
203
+ var itemFreezeDirection = $item.attr("data-sticky-direction");
204
+ var isFrozenBothDirection = itemFreezeDirection.indexOf(",") > 0;
205
+ var itemID = $item.attr("data-id");
206
+ var itemInitialState = this.itemsInitialState[freezeItemsContainerID][itemID];
207
+ var itemNewPostion = itemInitialState[position];
208
+ var initialZIndex = itemInitialState["zIndex"];
209
+ var hasInitialBgColor = itemInitialState["hasBgColor"];
210
+ var zIndexValue = 1;
211
+ var maxZIndex = this.freezeMaxZIndex[freezeItemsContainerID] ? this.freezeMaxZIndex[freezeItemsContainerID] : zIndexValue;
212
+ if (isFrozenBothDirection) {
213
+ zIndexValue = initialZIndex !== "auto" ? initialZIndex : maxZIndex + 2;
214
+ } else {
215
+ zIndexValue = initialZIndex !== "auto" ? initialZIndex + 1 : maxZIndex;
216
+ }
217
+ var newStyleRules = {
218
+ "z-index": zIndexValue
219
+ };
220
+ if (offset >= 0) {
221
+ itemNewPostion = itemNewPostion + offset;
222
+ } else {
223
+ newStyleRules["z-index"] = initialZIndex;
224
+ }
225
+ if (!hasInitialBgColor) {
226
+ this._applyBgColorOnScroll($item, isFrozenBothDirection, hasInitialBgColor, offset >= 0, freezeItemsContainerID);
227
+ }
228
+ newStyleRules[position] = itemNewPostion + "px";
229
+ $item.css(newStyleRules);
230
+ }
231
+ },
232
+ // eslint-disable-next-line max-params
233
+ _applyBgColorOnScroll: function($item, isItemFrozenBothDirection, hasInitialBgColor, shouldApplyBGColor, freezeItemsContainerID) {
234
+ if ($item.is("img")) {
235
+ return true;
236
+ }
237
+ if (isItemFrozenBothDirection && this._isFrozen(freezeItemsContainerID) && !hasInitialBgColor) {
238
+ $item.css("background-color", this.freezeBGColor[freezeItemsContainerID]);
239
+ return true;
240
+ }
241
+ if (shouldApplyBGColor) {
242
+ $item.css("background-color", this.freezeBGColor[freezeItemsContainerID]);
243
+ } else {
244
+ $item.css("background-color", "initial");
245
+ }
246
+ },
247
+ _hasSetBgColor: function(bgColorValue) {
248
+ return utils.getColorAlphaValue(bgColorValue) > 0;
249
+ },
250
+ _isFrozen: function(freezeItemsContainerID) {
251
+ return this.currentlyFrozenContainer.horizontal[freezeItemsContainerID] || this.currentlyFrozenContainer.vertical[freezeItemsContainerID];
252
+ },
253
+ /**
254
+ * Checks if an UI element is in the visible part of the scrollable container
255
+ * Takes one parameters
256
+ * - $element - JQuery DOM element
257
+ */
258
+ _isInScrollVisibleArea: function($element) {
259
+ var $page = $element.closest(".trv-report-page");
260
+ var elementPosition = $element.position();
261
+ return this._isVisibleVertically($element, $page, elementPosition) && this._isVisibleHorizontally($element, $page, elementPosition);
262
+ },
263
+ _isVisibleHorizontally: function($element, $page, elementPosition) {
264
+ var pageLeftOffset = parseFloat($page.css("padding-left"));
265
+ var scrollableContainerLeftScrollPosition = this.$scrollableContainer.scrollLeft();
266
+ var scrollableContainerWidth = this.$scrollableContainer.width();
267
+ var elementWidth = $element.outerWidth(true) * this.scaleFactor;
268
+ var elementLeftOffset = elementPosition.left + pageLeftOffset;
269
+ return elementLeftOffset > scrollableContainerLeftScrollPosition - elementWidth && elementLeftOffset < scrollableContainerLeftScrollPosition + elementWidth + scrollableContainerWidth;
270
+ },
271
+ _isVisibleVertically: function($element, $page, elementPosition) {
272
+ var pageTopOffset = parseFloat($page.css("padding-top"));
273
+ var pagePosition = $page.position();
274
+ var scrollableContainerTopScrollPosition = this.$scrollableContainer.scrollTop();
275
+ var scrollableContainerHeight = this.$scrollableContainer.height();
276
+ var elementHeight = $element.outerHeight(true) * this.scaleFactor;
277
+ var elementTopOffset = elementPosition.top + pageTopOffset + pagePosition.top;
278
+ return elementTopOffset > scrollableContainerTopScrollPosition - elementHeight && elementTopOffset < scrollableContainerTopScrollPosition + elementHeight + scrollableContainerHeight;
279
+ }
280
+ };
281
+
282
+ exports.UIFreezeCoordinator = UIFreezeCoordinator;