@progress/telerik-jquery-report-viewer 21.24.130 → 22.24.514

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/accessibility.js +218 -0
  3. package/dist/cjs/binder.js +172 -0
  4. package/dist/cjs/command.js +32 -0
  5. package/dist/cjs/commandSet.js +167 -0
  6. package/dist/cjs/controller.js +1207 -0
  7. package/dist/cjs/documentMapArea.js +168 -0
  8. package/dist/cjs/domUtils.js +50 -0
  9. package/dist/cjs/enums.js +52 -0
  10. package/dist/cjs/event-emitter.js +17 -0
  11. package/dist/cjs/events.js +23 -0
  12. package/dist/cjs/globalSettings.js +9 -0
  13. package/dist/cjs/history.js +131 -0
  14. package/dist/cjs/index.js +58 -0
  15. package/dist/cjs/jqueryThrottleDebounce.js +48 -0
  16. package/dist/cjs/kendo-jquery.js +4 -0
  17. package/dist/cjs/mainMenu.js +332 -0
  18. package/dist/cjs/mem-storage.js +44 -0
  19. package/dist/cjs/pagesArea.js +641 -0
  20. package/dist/cjs/parameterValidators.js +167 -0
  21. package/dist/cjs/parameters.js +921 -0
  22. package/dist/cjs/parametersArea.js +502 -0
  23. package/dist/cjs/perspectives.js +138 -0
  24. package/dist/cjs/print.js +166 -0
  25. package/dist/cjs/report-viewer/report-viewer-settings.js +138 -0
  26. package/dist/cjs/reportViewer.js +654 -0
  27. package/dist/cjs/scroll.js +537 -0
  28. package/dist/cjs/search.js +634 -0
  29. package/dist/cjs/sendEmail.js +435 -0
  30. package/dist/cjs/service-client-sentinel.js +52 -0
  31. package/dist/cjs/serviceClient.js +405 -0
  32. package/dist/cjs/sideMenu.js +225 -0
  33. package/dist/cjs/sr.js +164 -0
  34. package/dist/cjs/stringResources.js +11 -0
  35. package/dist/cjs/telerikReportViewer.kendo.js +60196 -0
  36. package/dist/cjs/telerikReportViewer.kendo.min.js +19776 -0
  37. package/dist/cjs/template-cache.js +39 -0
  38. package/dist/cjs/touch.js +86 -0
  39. package/dist/cjs/uiController.js +142 -0
  40. package/dist/cjs/uiFreezeCoordinator.js +281 -0
  41. package/dist/cjs/utils.js +492 -0
  42. package/dist/es/accessibility.js +214 -0
  43. package/dist/es/binder.js +168 -0
  44. package/dist/es/command.js +28 -0
  45. package/dist/es/commandSet.js +163 -0
  46. package/dist/es/controller.js +1203 -0
  47. package/dist/es/documentMapArea.js +164 -0
  48. package/dist/es/domUtils.js +43 -0
  49. package/dist/es/enums.js +41 -0
  50. package/dist/es/event-emitter.js +13 -0
  51. package/dist/es/events.js +19 -0
  52. package/dist/es/globalSettings.js +5 -0
  53. package/dist/es/history.js +127 -0
  54. package/dist/es/index.js +24 -0
  55. package/dist/es/jqueryThrottleDebounce.js +46 -0
  56. package/dist/es/kendo-jquery.js +1 -0
  57. package/dist/es/mainMenu.js +328 -0
  58. package/dist/es/mem-storage.js +40 -0
  59. package/dist/es/pagesArea.js +637 -0
  60. package/dist/es/parameterValidators.js +163 -0
  61. package/dist/es/parameters.js +916 -0
  62. package/dist/es/parametersArea.js +498 -0
  63. package/dist/es/perspectives.js +134 -0
  64. package/dist/es/print.js +162 -0
  65. package/dist/es/report-viewer/report-viewer-settings.js +134 -0
  66. package/dist/es/reportViewer.js +650 -0
  67. package/dist/es/scroll.js +533 -0
  68. package/dist/es/search.js +630 -0
  69. package/dist/es/sendEmail.js +431 -0
  70. package/dist/es/service-client-sentinel.js +48 -0
  71. package/dist/es/serviceClient.js +401 -0
  72. package/dist/es/sideMenu.js +221 -0
  73. package/dist/es/sr.js +162 -0
  74. package/dist/es/stringResources.js +7 -0
  75. package/dist/es/telerikReportViewer.kendo.js +60194 -0
  76. package/dist/es/telerikReportViewer.kendo.min.js +19774 -0
  77. package/dist/es/template-cache.js +35 -0
  78. package/dist/es/touch.js +82 -0
  79. package/dist/es/uiController.js +138 -0
  80. package/dist/es/uiFreezeCoordinator.js +277 -0
  81. package/dist/es/utils.js +447 -0
  82. package/dist/font/font-icons.css +4 -4
  83. package/dist/font/font-icons.min.css +3 -3
  84. package/dist/js/telerikReportViewer.js +8574 -8249
  85. package/dist/js/telerikReportViewer.min.js +1 -17
  86. package/dist/js/telerikReportViewer.stringResources.js +166 -173
  87. package/dist/styles/telerikReportViewer.css +1 -1
  88. package/dist/styles/telerikReportViewer.min.css +1 -1
  89. package/dist/templates/telerikReportViewerTemplate-FA.html +3 -3
  90. package/dist/templates/telerikReportViewerTemplate.html +3 -3
  91. package/package.json +13 -7
  92. /package/dist/font/{ReportingIcons-18.0.24.130.ttf → ReportingIcons-18.1.24.514.ttf} +0 -0
@@ -0,0 +1,498 @@
1
+ import { each, 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;
160
+ each(parameterEditors, function() {
161
+ if (this && this.match(parameter, editorsType)) {
162
+ factory = this;
163
+ }
164
+ return !factory;
165
+ });
166
+ return factory;
167
+ }
168
+ function showError(error) {
169
+ $errorMessage.text(error);
170
+ (error ? $.fn.addClass : $.fn.removeClass).call($placeholder, "trv-error");
171
+ }
172
+ function showPreviewButton() {
173
+ (allParametersAutoRefresh() ? $.fn.removeClass : $.fn.addClass).call($placeholder, "preview");
174
+ }
175
+ function allParametersAutoRefresh() {
176
+ var allAuto = true;
177
+ each(parameters, function() {
178
+ return allAuto = !this.isVisible || this.autoRefresh;
179
+ });
180
+ return allAuto;
181
+ }
182
+ function allParametersValid() {
183
+ var allValid = true;
184
+ each(parameters, function() {
185
+ return allValid = !this.Error;
186
+ });
187
+ return allValid;
188
+ }
189
+ function clearEditors() {
190
+ each(editors, function() {
191
+ if (this.hasOwnProperty("destroy")) {
192
+ this.destroy();
193
+ }
194
+ });
195
+ editors = {};
196
+ }
197
+ function fill(newParameters) {
198
+ recentParameterValues = {};
199
+ processedParameterValues = {};
200
+ parameters = newParameters || [];
201
+ clearEditors();
202
+ var $parameterContainer;
203
+ var $tempContainer = $("<div></div>");
204
+ each(parameters, function() {
205
+ try {
206
+ this.value = ParameterValidators.validate(this, this.value);
207
+ } catch (e) {
208
+ this.Error = this.Error || e;
209
+ }
210
+ var hasError = Boolean(this.Error);
211
+ var hasValue = !hasError;
212
+ if (hasValue) {
213
+ recentParameterValues[this.id] = this.value;
214
+ if (this.availableValues) {
215
+ processedParameterValues[this.id] = { valueMember: this.value, displayMember: this.label, availableValues: this.availableValues, multivalue: this.multivalue };
216
+ } else {
217
+ processedParameterValues[this.id] = this.value;
218
+ }
219
+ } else {
220
+ this.Error = stringResources.invalidParameter;
221
+ }
222
+ if (this.isVisible || options.showHiddenParameters) {
223
+ $parameterContainer = createParameterUI(this);
224
+ if ($parameterContainer) {
225
+ $tempContainer.append($parameterContainer);
226
+ }
227
+ }
228
+ });
229
+ if (initialParameterValues !== void 0) {
230
+ if (null === initialParameterValues) {
231
+ initialParameterValues = {};
232
+ each(parameters, function() {
233
+ if (this.isVisible) {
234
+ initialParameterValues[this.id] = this.value;
235
+ } else {
236
+ delete recentParameterValues[this.id];
237
+ }
238
+ });
239
+ } else {
240
+ each(parameters, function() {
241
+ if (!(this.id in initialParameterValues)) {
242
+ delete recentParameterValues[this.id];
243
+ }
244
+ });
245
+ }
246
+ }
247
+ $content.empty();
248
+ if (parameters.length > 0) {
249
+ $content.append($tempContainer.children());
250
+ if (enableAccessibility) {
251
+ $content.attr("aria-label", "Parameters area. Contains " + parameters.length + " parameters.");
252
+ }
253
+ }
254
+ showPreviewButton();
255
+ var allValid = allParametersValid();
256
+ enablePreviewButton(allValid);
257
+ applyProcessedParameters();
258
+ }
259
+ function applyParameters() {
260
+ controller.setParameters($.extend({}, recentParameterValues));
261
+ controller.previewReport(false);
262
+ }
263
+ function applyProcessedParameters() {
264
+ controller.setProcessedParameter($.extend({}, processedParameterValues));
265
+ }
266
+ function allParametersValidForAutoRefresh() {
267
+ var triggerAutoUpdate = true;
268
+ for (var i = parameters.length - 1; triggerAutoUpdate && i >= 0; i--) {
269
+ var p = parameters[i];
270
+ triggerAutoUpdate = p.id in recentParameterValues && (Boolean(p.autoRefresh) || !p.isVisible);
271
+ }
272
+ return triggerAutoUpdate;
273
+ }
274
+ function raiseParametersReady() {
275
+ parametersArea.parametersReady(recentParameterValues);
276
+ }
277
+ function tryRefreshReport() {
278
+ raiseParametersReady();
279
+ if (allParametersValidForAutoRefresh()) {
280
+ applyParameters();
281
+ }
282
+ }
283
+ function invalidateChildParameters(parameter) {
284
+ if (parameter.childParameters) {
285
+ each(parameter.childParameters, function(index, parameterId) {
286
+ var childParameter = getParameterById(parameterId);
287
+ if (childParameter) {
288
+ invalidateChildParameters(childParameter);
289
+ }
290
+ delete recentParameterValues[parameterId];
291
+ resetPendingParameterChange(parameterId);
292
+ });
293
+ }
294
+ }
295
+ function resetPendingParameterChange(parameterId) {
296
+ if (editors) {
297
+ var editor = editors[parameterId];
298
+ if (editor && typeof editor.clearPendingChange === "function") {
299
+ editor.clearPendingChange();
300
+ }
301
+ }
302
+ }
303
+ function onParameterChanged(parameter, newValue) {
304
+ delete parameter["Error"];
305
+ parameter.value = newValue;
306
+ recentParameterValues[parameter.id] = newValue;
307
+ if (initialParameterValues !== void 0) {
308
+ if (parameter.id in initialParameterValues) {
309
+ recentParameterValues[parameter.id] = newValue;
310
+ }
311
+ } else {
312
+ recentParameterValues[parameter.id] = newValue;
313
+ }
314
+ invalidateChildParameters(parameter);
315
+ if (parameter.childParameters) {
316
+ updateParameters(tryRefreshReport);
317
+ } else {
318
+ var allValid = allParametersValid();
319
+ enablePreviewButton(allValid);
320
+ if (allValid) {
321
+ var errorMsg = document.querySelector(".trv-pages-area .trv-error-message");
322
+ if ($previewButton.is(":visible") && errorMsg) {
323
+ errorMsg.textContent = stringResources.tryReportPreview;
324
+ }
325
+ tryRefreshReport();
326
+ }
327
+ }
328
+ }
329
+ function getParameterById(parameterId) {
330
+ if (parameters) {
331
+ for (var i = 0; i < parameters.length; i++) {
332
+ var p = parameters[i];
333
+ if (p.id === parameterId) {
334
+ return p;
335
+ }
336
+ }
337
+ }
338
+ return null;
339
+ }
340
+ function hasVisibleParameters(params) {
341
+ if (!params || null === params) {
342
+ return false;
343
+ }
344
+ var result = false;
345
+ each(params, function() {
346
+ result = this.isVisible;
347
+ return !result;
348
+ });
349
+ return result;
350
+ }
351
+ var loadingCount = 0;
352
+ function beginLoad() {
353
+ loadingCount++;
354
+ $placeholder.addClass("trv-loading");
355
+ }
356
+ function endLoad() {
357
+ if (loadingCount > 0) {
358
+ if (0 === --loadingCount) {
359
+ $placeholder.removeClass("trv-loading");
360
+ }
361
+ }
362
+ }
363
+ var parametersAreaNecessary = false;
364
+ function onLoadParametersComplete(params, successAction) {
365
+ parametersAreaNecessary = hasVisibleParameters(params);
366
+ if (!parametersAreaNecessary) {
367
+ showParametersArea(false);
368
+ }
369
+ fill(params);
370
+ showError("");
371
+ if (parametersAreaNecessary && parametersAreaVisible) {
372
+ showParametersArea(true);
373
+ if (enableAccessibility) {
374
+ setSplitbarAccessibilityAttributes();
375
+ }
376
+ }
377
+ controller.updateUIInternal();
378
+ if (typeof successAction === "function") {
379
+ successAction();
380
+ }
381
+ endLoad();
382
+ }
383
+ function updateParameters(successAction) {
384
+ acceptParameters(controller.loadParameters(recentParameterValues), successAction);
385
+ }
386
+ function acceptParameters(controllerLoadParametersPromise, successAction) {
387
+ beginLoad();
388
+ controllerLoadParametersPromise.then(function(parameters2) {
389
+ onLoadParametersComplete(parameters2, successAction);
390
+ }).catch(function(error) {
391
+ endLoad();
392
+ clear();
393
+ if (!$placeholder.hasClass("trv-hidden")) {
394
+ showError(error);
395
+ }
396
+ parametersArea.error(error);
397
+ });
398
+ }
399
+ function getEventHandlerFromArguments(args) {
400
+ var arg0;
401
+ if (args && args.length) {
402
+ arg0 = args[0];
403
+ }
404
+ if (typeof arg0 === "function") {
405
+ return arg0;
406
+ }
407
+ return null;
408
+ }
409
+ function eventFactory(event, args) {
410
+ var h = getEventHandlerFromArguments(args);
411
+ if (h) {
412
+ $parametersArea.on(event, h);
413
+ } else {
414
+ $parametersArea.trigger(event, args);
415
+ }
416
+ return controller;
417
+ }
418
+ function onLoadParametersSuccess() {
419
+ if (initialParameterValues === null) {
420
+ initialParameterValues = $.extend({}, recentParameterValues);
421
+ }
422
+ raiseParametersReady();
423
+ }
424
+ function showParametersArea(show) {
425
+ var splitter = GlobalSettings.viewerInstances.find((element) => element.id === options.viewerSelector + "-parameters-splitter").instance;
426
+ var sibling = $placeholder.prev();
427
+ if (options.parametersAreaPosition === ParametersAreaPositions.TOP || options.parametersAreaPosition === ParametersAreaPositions.LEFT) {
428
+ sibling = $placeholder.next();
429
+ }
430
+ if (splitter) {
431
+ (parametersAreaNecessary ? $.fn.removeClass : $.fn.addClass).call(sibling, "trv-hidden");
432
+ splitter.toggle(".trv-parameters-area", show);
433
+ }
434
+ }
435
+ function setSplitbarAccessibilityAttributes() {
436
+ var splitbar = $placeholder.prev();
437
+ var tabIndex = $placeholder.find(".trv-parameters-area-content").attr("tabIndex");
438
+ if (options.parametersAreaPosition === ParametersAreaPositions.TOP || options.parametersAreaPosition === ParametersAreaPositions.LEFT) {
439
+ splitbar = $placeholder.next();
440
+ }
441
+ splitbar.attr("aria-label", stringResources.ariaLabelParametersAreaSplitter);
442
+ splitbar.attr("tabIndex", tabIndex);
443
+ }
444
+ function onReloadParameters(event, controllerLoadParametersPromise) {
445
+ showError();
446
+ $content.empty();
447
+ acceptParameters(controllerLoadParametersPromise, onLoadParametersSuccess);
448
+ }
449
+ controller.reloadParameters(onReloadParameters).beforeLoadReport(function() {
450
+ loadingCount = 0;
451
+ beginLoad();
452
+ }).error(endLoad).pageReady(endLoad);
453
+ controller.getParametersAreaState(function(event, args) {
454
+ var parametersAreaNecessary2 = false;
455
+ if (parameters) {
456
+ parametersAreaNecessary2 = hasVisibleParameters(parameters);
457
+ }
458
+ args.enabled = parametersAreaNecessary2;
459
+ args.visible = parametersAreaVisible;
460
+ }).setParametersAreaVisible(function(event, args) {
461
+ parametersAreaVisible = args.visible;
462
+ showParametersArea(args.visible && hasVisibleParameters(parameters));
463
+ });
464
+ function clear() {
465
+ fill([]);
466
+ }
467
+ $.extend(
468
+ parametersArea,
469
+ {
470
+ allParametersValid: function() {
471
+ return allParametersValid();
472
+ },
473
+ clear: function() {
474
+ clear();
475
+ },
476
+ error: function() {
477
+ return eventFactory(Events.ERROR, arguments);
478
+ },
479
+ parametersReady: function() {
480
+ return eventFactory(Events.PARAMETERS_READY, arguments);
481
+ },
482
+ setParameters: function(parameterValues) {
483
+ initialParameterValues = null === parameterValues ? null : $.extend({}, parameterValues);
484
+ }
485
+ }
486
+ );
487
+ return parametersArea;
488
+ }
489
+ var pluginName = "telerik_ReportViewer_ParametersArea";
490
+ $.fn[pluginName] = function(options, otherOptions) {
491
+ return each(this, function() {
492
+ if (!$.data(this, pluginName)) {
493
+ $.data(this, pluginName, new ParametersArea(this, options, otherOptions));
494
+ }
495
+ });
496
+ };
497
+
498
+ 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 };