@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,482 @@
1
+ import { escapeHtml } from './utils.js';
2
+ import { stringResources } from './stringResources.js';
3
+ import { ParameterValidators } from './parameterValidators.js';
4
+ import { ParameterEditors } from './parameters.js';
5
+ import { ParametersAreaPositions } from './enums.js';
6
+ import { GlobalSettings } from './globalSettings.js';
7
+
8
+ var defaultOptions = {};
9
+ var Events = {
10
+ PARAMETERS_READY: "pa.parametersReady",
11
+ ERROR: "pa.Error"
12
+ };
13
+ function ParametersArea(placeholder, options, otherOptions) {
14
+ options = $.extend({}, defaultOptions, options, otherOptions);
15
+ var parametersArea = {};
16
+ var $parametersArea = $(parametersArea);
17
+ var editors = {};
18
+ var controller = options.controller;
19
+ if (!controller) {
20
+ throw "No controller (telerikReporting.reportViewerController) has been specified.";
21
+ }
22
+ var parameterEditors = [].concat(options.parameterEditors, ParameterEditors);
23
+ var recentParameterValues;
24
+ var parameters;
25
+ var initialParameterValues;
26
+ var processedParameterValues = void 0;
27
+ var $placeholder = $(placeholder);
28
+ var $content = $placeholder.find(".trv-parameters-area-content");
29
+ var $errorMessage = $placeholder.find(".trv-error-message");
30
+ var $previewButton = $placeholder.find(".trv-parameters-area-preview-button");
31
+ $previewButton.text(stringResources[$previewButton.text()]);
32
+ $previewButton.attr("aria-label", stringResources[$previewButton.attr("aria-label")]);
33
+ $previewButton.on("click", function(e) {
34
+ e.preventDefault();
35
+ if (allParametersValid()) {
36
+ applyParameters();
37
+ }
38
+ });
39
+ var parameterContainerTemplate = options.templates["trv-parameter"];
40
+ var parametersAreaVisible = options.parametersAreaVisible !== false;
41
+ var enableAccessibility = options.enableAccessibility;
42
+ init();
43
+ function init() {
44
+ replaceStringResources($placeholder);
45
+ }
46
+ function replaceStringResources($paramsArea) {
47
+ var $previewButton2 = $paramsArea.find(".trv-parameters-area-preview-button");
48
+ if (!$previewButton2) {
49
+ return;
50
+ }
51
+ $previewButton2.attr("aria-label", stringResources[$previewButton2.attr("aria-label")]);
52
+ $previewButton2.text(stringResources[$previewButton2.text()]);
53
+ }
54
+ function toggleElementDisplay(el, shouldHide) {
55
+ el.style.display = shouldHide ? "none" : "";
56
+ }
57
+ function createParameterContainer() {
58
+ return $(parameterContainerTemplate);
59
+ }
60
+ function createParameterUI(parameter) {
61
+ var $container = createParameterContainer();
62
+ var $editorPlaceholder = $container.find(".trv-parameter-value");
63
+ var $title = $container.find(".trv-parameter-title");
64
+ var $error = $container.find(".trv-parameter-error");
65
+ var $errorMessage2 = $container.find(".trv-parameter-error-message");
66
+ var $useDefaultValueCheckbox = $container.find(".trv-parameter-use-default input");
67
+ var editorsTypes = options.parameters && options.parameters.editors ? options.parameters.editors : null;
68
+ var editorFactory = selectParameterEditorFactory(parameter, editorsTypes);
69
+ var parameterText = escapeHtml(parameter.text);
70
+ var isHiddenParameter = !parameter.isVisible;
71
+ if (isHiddenParameter) {
72
+ parameterText += " [<b>hidden</b>]";
73
+ }
74
+ $title.html(parameterText).attr("title", parameterText);
75
+ $errorMessage2.text(parameter.Error);
76
+ (parameter.Error ? $.fn.show : $.fn.hide).call($error);
77
+ var editor = editorFactory.createEditor(
78
+ $editorPlaceholder,
79
+ {
80
+ templates: options.templates,
81
+ parameterChanged: function(parameter2, newValue) {
82
+ var invalidParameterLI = document.querySelector(".trv-pages-area .trv-error-message ul li." + parameter2.name);
83
+ try {
84
+ newValue = ParameterValidators.validate(parameter2, newValue);
85
+ $error.hide();
86
+ if (invalidParameterLI) {
87
+ toggleElementDisplay(invalidParameterLI, true);
88
+ }
89
+ onParameterChanged(parameter2, newValue);
90
+ } catch (error) {
91
+ if (invalidParameterLI) {
92
+ toggleElementDisplay(invalidParameterLI, false);
93
+ }
94
+ parameter2.Error = error;
95
+ parameter2.value = [];
96
+ $errorMessage2.text(error);
97
+ $error.show();
98
+ enablePreviewButton(false);
99
+ } finally {
100
+ setAccessibilityErrorState(parameter2);
101
+ }
102
+ },
103
+ enableAccessibility
104
+ }
105
+ );
106
+ editors[parameter.id] = editor;
107
+ editor.beginEdit(parameter);
108
+ if (enableAccessibility && !isHiddenParameter) {
109
+ editor.addAccessibility(parameter);
110
+ }
111
+ if ($useDefaultValueCheckbox.length > 0) {
112
+ $useDefaultValueCheckbox.on(
113
+ "click",
114
+ function() {
115
+ var useDefaultValue = $(this).is(":checked");
116
+ if (useDefaultValue) {
117
+ delete recentParameterValues[parameter.id];
118
+ delete initialParameterValues[parameter.id];
119
+ invalidateChildParameters(parameter);
120
+ updateParameters(onLoadParametersSuccess);
121
+ } else {
122
+ recentParameterValues[parameter.id] = parameter.value;
123
+ initialParameterValues[parameter.id] = parameter.value;
124
+ }
125
+ editor.enable(!useDefaultValue);
126
+ raiseParametersReady();
127
+ }
128
+ );
129
+ var hasInitialValues = initialParameterValues !== null;
130
+ if (hasInitialValues) {
131
+ if (!(parameter.id in initialParameterValues)) {
132
+ $useDefaultValueCheckbox.prop("checked", true);
133
+ editor.enable(false);
134
+ }
135
+ } else if (isHiddenParameter) {
136
+ $useDefaultValueCheckbox.prop("checked", true);
137
+ editor.enable(false);
138
+ }
139
+ }
140
+ return $container;
141
+ }
142
+ function setAccessibilityErrorState(parameter) {
143
+ var editor = editors[parameter.id];
144
+ if (!editor || !enableAccessibility) {
145
+ return;
146
+ }
147
+ editor.setAccessibilityErrorState(parameter);
148
+ }
149
+ function enablePreviewButton(enabled) {
150
+ if (enabled) {
151
+ $previewButton.prop("disabled", false);
152
+ $previewButton.removeClass("k-disabled");
153
+ } else {
154
+ $previewButton.prop("disabled", true);
155
+ $previewButton.addClass("k-disabled");
156
+ }
157
+ }
158
+ function selectParameterEditorFactory(parameter, editorsType) {
159
+ var factory = Array.from(parameterEditors).find((editor) => {
160
+ return editor.match(parameter, editorsType);
161
+ });
162
+ return factory;
163
+ }
164
+ function showError(error) {
165
+ $errorMessage.text(error);
166
+ (error ? $.fn.addClass : $.fn.removeClass).call($placeholder, "trv-error");
167
+ }
168
+ function showPreviewButton() {
169
+ (allParametersAutoRefresh() ? $.fn.removeClass : $.fn.addClass).call($placeholder, "preview");
170
+ }
171
+ function allParametersAutoRefresh() {
172
+ var allAuto = Array.from(parameters).every((parameter) => {
173
+ return !parameter.isVisible || parameter.autoRefresh;
174
+ });
175
+ return allAuto;
176
+ }
177
+ function allParametersValid() {
178
+ var allValid = Array.from(parameters).every((parameter) => {
179
+ return !parameter.Error;
180
+ });
181
+ return allValid;
182
+ }
183
+ function clearEditors() {
184
+ Object.entries(editors).forEach(([key, editor]) => {
185
+ if (typeof editor.destroy === "function") {
186
+ editor.destroy();
187
+ }
188
+ });
189
+ editors = {};
190
+ }
191
+ function fill(newParameters) {
192
+ recentParameterValues = {};
193
+ processedParameterValues = {};
194
+ parameters = newParameters || [];
195
+ clearEditors();
196
+ var $parameterContainer;
197
+ var $tempContainer = $("<div></div>");
198
+ Array.from(parameters).forEach((parameter) => {
199
+ try {
200
+ parameter.value = ParameterValidators.validate(parameter, parameter.value);
201
+ } catch (e) {
202
+ parameter.Error = parameter.Error || e;
203
+ }
204
+ var hasError = Boolean(parameter.Error);
205
+ var hasValue = !hasError;
206
+ if (hasValue) {
207
+ recentParameterValues[parameter.id] = parameter.value;
208
+ if (parameter.availableValues) {
209
+ processedParameterValues[parameter.id] = { valueMember: parameter.value, displayMember: parameter.label, availableValues: parameter.availableValues, multivalue: parameter.multivalue };
210
+ } else {
211
+ processedParameterValues[parameter.id] = parameter.value;
212
+ }
213
+ } else {
214
+ parameter.Error = stringResources.invalidParameter;
215
+ }
216
+ if (parameter.isVisible || options.showHiddenParameters) {
217
+ $parameterContainer = createParameterUI(parameter);
218
+ if ($parameterContainer) {
219
+ $tempContainer.append($parameterContainer);
220
+ }
221
+ }
222
+ });
223
+ if (initialParameterValues !== void 0) {
224
+ if (null === initialParameterValues) {
225
+ initialParameterValues = {};
226
+ Array.from(parameters).forEach((parameter) => {
227
+ if (parameter.isVisible) {
228
+ initialParameterValues[parameter.id] = parameter.value;
229
+ } else {
230
+ delete recentParameterValues[parameter.id];
231
+ }
232
+ });
233
+ } else {
234
+ Array.from(parameters).forEach((parameter) => {
235
+ if (!(parameter.id in initialParameterValues)) {
236
+ delete recentParameterValues[parameter.id];
237
+ }
238
+ });
239
+ }
240
+ }
241
+ $content.empty();
242
+ if (parameters.length > 0) {
243
+ $content.append($tempContainer.children());
244
+ if (enableAccessibility) {
245
+ $content.attr("aria-label", "Parameters area. Contains " + parameters.length + " parameters.");
246
+ }
247
+ }
248
+ showPreviewButton();
249
+ var allValid = allParametersValid();
250
+ enablePreviewButton(allValid);
251
+ applyProcessedParameters();
252
+ }
253
+ function applyParameters() {
254
+ controller.setParameters($.extend({}, recentParameterValues));
255
+ controller.previewReport(false);
256
+ }
257
+ function applyProcessedParameters() {
258
+ controller.setProcessedParameter($.extend({}, processedParameterValues));
259
+ }
260
+ function allParametersValidForAutoRefresh() {
261
+ var triggerAutoUpdate = true;
262
+ for (var i = parameters.length - 1; triggerAutoUpdate && i >= 0; i--) {
263
+ var p = parameters[i];
264
+ triggerAutoUpdate = p.id in recentParameterValues && (Boolean(p.autoRefresh) || !p.isVisible);
265
+ }
266
+ return triggerAutoUpdate;
267
+ }
268
+ function raiseParametersReady() {
269
+ parametersArea.parametersReady(recentParameterValues);
270
+ }
271
+ function tryRefreshReport() {
272
+ raiseParametersReady();
273
+ if (allParametersValidForAutoRefresh()) {
274
+ applyParameters();
275
+ }
276
+ }
277
+ function invalidateChildParameters(parameter) {
278
+ if (parameter.childParameters) {
279
+ Array.from(parameter.childParameters).forEach((parameterId) => {
280
+ var childParameter = getParameterById(parameterId);
281
+ if (childParameter) {
282
+ invalidateChildParameters(childParameter);
283
+ }
284
+ delete recentParameterValues[parameterId];
285
+ resetPendingParameterChange(parameterId);
286
+ });
287
+ }
288
+ }
289
+ function resetPendingParameterChange(parameterId) {
290
+ if (editors) {
291
+ var editor = editors[parameterId];
292
+ if (editor && typeof editor.clearPendingChange === "function") {
293
+ editor.clearPendingChange();
294
+ }
295
+ }
296
+ }
297
+ function onParameterChanged(parameter, newValue) {
298
+ delete parameter["Error"];
299
+ parameter.value = newValue;
300
+ recentParameterValues[parameter.id] = newValue;
301
+ if (initialParameterValues !== void 0) {
302
+ if (parameter.id in initialParameterValues) {
303
+ recentParameterValues[parameter.id] = newValue;
304
+ }
305
+ } else {
306
+ recentParameterValues[parameter.id] = newValue;
307
+ }
308
+ invalidateChildParameters(parameter);
309
+ if (parameter.childParameters) {
310
+ updateParameters(tryRefreshReport);
311
+ } else {
312
+ var allValid = allParametersValid();
313
+ enablePreviewButton(allValid);
314
+ if (allValid) {
315
+ var errorMsg = document.querySelector(".trv-pages-area .trv-error-message");
316
+ if ($previewButton.is(":visible") && errorMsg) {
317
+ errorMsg.textContent = stringResources.tryReportPreview;
318
+ }
319
+ tryRefreshReport();
320
+ }
321
+ }
322
+ }
323
+ function getParameterById(parameterId) {
324
+ if (parameters) {
325
+ for (var i = 0; i < parameters.length; i++) {
326
+ var p = parameters[i];
327
+ if (p.id === parameterId) {
328
+ return p;
329
+ }
330
+ }
331
+ }
332
+ return null;
333
+ }
334
+ function hasVisibleParameters(params) {
335
+ if (!params || null === params) {
336
+ return false;
337
+ }
338
+ var hasVisible = Array.from(params).some((parameter) => {
339
+ return parameter.isVisible;
340
+ });
341
+ return hasVisible;
342
+ }
343
+ var loadingCount = 0;
344
+ function beginLoad() {
345
+ loadingCount++;
346
+ $placeholder.addClass("trv-loading");
347
+ }
348
+ function endLoad() {
349
+ if (loadingCount > 0) {
350
+ if (0 === --loadingCount) {
351
+ $placeholder.removeClass("trv-loading");
352
+ }
353
+ }
354
+ }
355
+ var parametersAreaNecessary = false;
356
+ function onLoadParametersComplete(params, successAction) {
357
+ parametersAreaNecessary = hasVisibleParameters(params);
358
+ if (!parametersAreaNecessary) {
359
+ showParametersArea(false);
360
+ }
361
+ fill(params);
362
+ showError("");
363
+ if (parametersAreaNecessary && parametersAreaVisible) {
364
+ showParametersArea(true);
365
+ if (enableAccessibility) {
366
+ setSplitbarAccessibilityAttributes();
367
+ }
368
+ }
369
+ controller.updateUIInternal();
370
+ if (typeof successAction === "function") {
371
+ successAction();
372
+ }
373
+ endLoad();
374
+ }
375
+ function updateParameters(successAction) {
376
+ acceptParameters(controller.loadParameters(recentParameterValues), successAction);
377
+ }
378
+ function acceptParameters(controllerLoadParametersPromise, successAction) {
379
+ beginLoad();
380
+ controllerLoadParametersPromise.then(function(parameters2) {
381
+ onLoadParametersComplete(parameters2, successAction);
382
+ }).catch(function(error) {
383
+ endLoad();
384
+ clear();
385
+ if (!$placeholder.hasClass("trv-hidden")) {
386
+ showError(error);
387
+ }
388
+ parametersArea.error(error);
389
+ });
390
+ }
391
+ function getEventHandlerFromArguments(args) {
392
+ var arg0;
393
+ if (args && args.length) {
394
+ arg0 = args[0];
395
+ }
396
+ if (typeof arg0 === "function") {
397
+ return arg0;
398
+ }
399
+ return null;
400
+ }
401
+ function eventFactory(event, args) {
402
+ var h = getEventHandlerFromArguments(args);
403
+ if (h) {
404
+ $parametersArea.on(event, h);
405
+ } else {
406
+ $parametersArea.trigger(event, args);
407
+ }
408
+ return controller;
409
+ }
410
+ function onLoadParametersSuccess() {
411
+ if (initialParameterValues === null) {
412
+ initialParameterValues = $.extend({}, recentParameterValues);
413
+ }
414
+ raiseParametersReady();
415
+ }
416
+ function showParametersArea(show) {
417
+ var splitter = GlobalSettings.viewerInstances.find((element) => element.id === options.viewerSelector + "-parameters-splitter").instance;
418
+ var sibling = $placeholder.prev();
419
+ if (options.parametersAreaPosition === ParametersAreaPositions.TOP || options.parametersAreaPosition === ParametersAreaPositions.LEFT) {
420
+ sibling = $placeholder.next();
421
+ }
422
+ if (splitter) {
423
+ (parametersAreaNecessary ? $.fn.removeClass : $.fn.addClass).call(sibling, "trv-hidden");
424
+ splitter.toggle(".trv-parameters-area", show);
425
+ }
426
+ }
427
+ function setSplitbarAccessibilityAttributes() {
428
+ var splitbar = $placeholder.prev();
429
+ var tabIndex = $placeholder.find(".trv-parameters-area-content").attr("tabIndex");
430
+ if (options.parametersAreaPosition === ParametersAreaPositions.TOP || options.parametersAreaPosition === ParametersAreaPositions.LEFT) {
431
+ splitbar = $placeholder.next();
432
+ }
433
+ splitbar.attr("aria-label", stringResources.ariaLabelParametersAreaSplitter);
434
+ splitbar.attr("tabIndex", tabIndex);
435
+ }
436
+ function onReloadParameters(event, controllerLoadParametersPromise) {
437
+ showError();
438
+ $content.empty();
439
+ acceptParameters(controllerLoadParametersPromise, onLoadParametersSuccess);
440
+ }
441
+ controller.reloadParameters(onReloadParameters).beforeLoadReport(function() {
442
+ loadingCount = 0;
443
+ beginLoad();
444
+ }).error(endLoad).pageReady(endLoad);
445
+ controller.getParametersAreaState(function(event, args) {
446
+ var parametersAreaNecessary2 = false;
447
+ if (parameters) {
448
+ parametersAreaNecessary2 = hasVisibleParameters(parameters);
449
+ }
450
+ args.enabled = parametersAreaNecessary2;
451
+ args.visible = parametersAreaVisible;
452
+ }).setParametersAreaVisible(function(event, args) {
453
+ parametersAreaVisible = args.visible;
454
+ showParametersArea(args.visible && hasVisibleParameters(parameters));
455
+ });
456
+ function clear() {
457
+ fill([]);
458
+ }
459
+ $.extend(
460
+ parametersArea,
461
+ {
462
+ allParametersValid: function() {
463
+ return allParametersValid();
464
+ },
465
+ clear: function() {
466
+ clear();
467
+ },
468
+ error: function() {
469
+ return eventFactory(Events.ERROR, arguments);
470
+ },
471
+ parametersReady: function() {
472
+ return eventFactory(Events.PARAMETERS_READY, arguments);
473
+ },
474
+ setParameters: function(parameterValues) {
475
+ initialParameterValues = null === parameterValues ? null : $.extend({}, parameterValues);
476
+ }
477
+ }
478
+ );
479
+ return parametersArea;
480
+ }
481
+
482
+ export { ParametersArea };
@@ -0,0 +1,134 @@
1
+ function PerspectiveManager(dom, controller) {
2
+ var smallMenu = dom.querySelectorAll ? dom.querySelectorAll(".trv-menu-small")[0] : false;
3
+ var perspectives = {
4
+ "small": {
5
+ documentMapVisible: false,
6
+ parametersAreaVisible: false,
7
+ onDocumentMapVisibleChanged: function(e, args) {
8
+ if (args.visible) {
9
+ controller.setParametersAreaVisible({ visible: false });
10
+ }
11
+ },
12
+ onParameterAreaVisibleChanged: function(e, args) {
13
+ if (args.visible) {
14
+ controller.setDocumentMapVisible({ visible: false });
15
+ }
16
+ },
17
+ onBeforeLoadReport: function() {
18
+ controller.setParametersAreaVisible({ visible: false });
19
+ controller.setDocumentMapVisible({ visible: false });
20
+ },
21
+ onNavigateToPage: function() {
22
+ controller.setParametersAreaVisible({ visible: false });
23
+ controller.setDocumentMapVisible({ visible: false });
24
+ }
25
+ },
26
+ "large": {
27
+ documentMapVisible: true,
28
+ parametersAreaVisible: true
29
+ }
30
+ };
31
+ var currentPerspective;
32
+ function init() {
33
+ currentPerspective = getPerspective();
34
+ initStateFromController(perspectives["large"]);
35
+ }
36
+ function setPerspective(beforeApplyState) {
37
+ var perspective = getPerspective();
38
+ if (perspective !== currentPerspective) {
39
+ var oldState = perspectives[currentPerspective];
40
+ var newState = perspectives[perspective];
41
+ currentPerspective = perspective;
42
+ if (beforeApplyState) {
43
+ beforeApplyState.call(void 0, oldState, newState);
44
+ }
45
+ applyState(newState);
46
+ }
47
+ }
48
+ function onDocumentMapVisibleChanged(e, args) {
49
+ dispatch("onDocumentMapVisibleChanged", arguments);
50
+ }
51
+ function onParameterAreaVisibleChanged(e, args) {
52
+ dispatch("onParameterAreaVisibleChanged", arguments);
53
+ }
54
+ function onBeforeLoadReport() {
55
+ dispatch("onBeforeLoadReport", arguments);
56
+ }
57
+ function onNavigateToPage() {
58
+ dispatch("onNavigateToPage", arguments);
59
+ }
60
+ function onReportLoadComplete() {
61
+ dispatch("onReportLoadComplete", arguments);
62
+ }
63
+ function onWindowResize() {
64
+ setPerspective(
65
+ function(oldState, newState) {
66
+ initStateFromController(oldState);
67
+ }
68
+ );
69
+ }
70
+ function onCssLoaded() {
71
+ setPerspective(null);
72
+ }
73
+ function dispatch(func, args) {
74
+ var activePerspective = perspectives[currentPerspective];
75
+ var handler = activePerspective[func];
76
+ if (typeof handler === "function") {
77
+ handler.apply(activePerspective, args);
78
+ }
79
+ }
80
+ function attach() {
81
+ window.addEventListener("resize", onWindowResize);
82
+ controller.setDocumentMapVisible(onDocumentMapVisibleChanged);
83
+ controller.setParametersAreaVisible(onParameterAreaVisibleChanged);
84
+ controller.beforeLoadReport(onBeforeLoadReport);
85
+ controller.navigateToPage(onNavigateToPage);
86
+ controller.reportLoadComplete(onReportLoadComplete);
87
+ controller.cssLoaded(onCssLoaded);
88
+ }
89
+ function dispose() {
90
+ window.removeEventListener("resize", onWindowResize);
91
+ }
92
+ function getPerspective() {
93
+ var windowWidthInEm = $(window).width() / parseFloat($("body").css("font-size"));
94
+ var windowMinWidth = 40.5;
95
+ return smallMenu && windowWidthInEm <= windowMinWidth ? "small" : "large";
96
+ }
97
+ function initStateFromController(state) {
98
+ state.documentMapVisible = documentMapVisible();
99
+ state.parametersAreaVisible = parametersAreaVisible();
100
+ }
101
+ function applyState(state) {
102
+ documentMapVisible(state.documentMapVisible);
103
+ parametersAreaVisible(state.parametersAreaVisible);
104
+ }
105
+ function documentMapVisible() {
106
+ if (arguments.length === 0) {
107
+ var args1 = {};
108
+ controller.getDocumentMapState(args1);
109
+ return args1.visible;
110
+ }
111
+ controller.setDocumentMapVisible({
112
+ visible: Boolean(arguments[0])
113
+ });
114
+ return this;
115
+ }
116
+ function parametersAreaVisible() {
117
+ if (arguments.length === 0) {
118
+ var args1 = {};
119
+ controller.getParametersAreaState(args1);
120
+ return args1.visible;
121
+ }
122
+ controller.setParametersAreaVisible({
123
+ visible: Boolean(arguments[0])
124
+ });
125
+ return this;
126
+ }
127
+ init();
128
+ return {
129
+ attach,
130
+ dispose
131
+ };
132
+ }
133
+
134
+ export { PerspectiveManager };