@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,916 @@
1
+ import { each, parseToLocalDate, areEqual, stringFormat, adjustTimezone, tryParseInt, areEqualArrays, unadjustTimezone, isSpecialKey } from './utils.js';
2
+ import { stringResources } from './stringResources.js';
3
+ import { ParameterEditorTypes, ParameterTypes } from './enums.js';
4
+
5
+ var parameterEditorsMatch = {
6
+ // AvailableValues PROVIDED, MultiValue is TRUE and trv.parameters.editors.multiSelect is unset
7
+ MultiSelect: function(parameter, editorsType) {
8
+ return Boolean(parameter.availableValues) && parameter.multivalue && (!editorsType || !editorsType.multiSelect || editorsType.multiSelect !== ParameterEditorTypes.COMBO_BOX);
9
+ },
10
+ // AvailableValues PROVIDED, MultiValue is TRUE and trv.parameters.editors.multiSelect is set to COMBO_BOX
11
+ MultiSelectCombo: function(parameter, editorsType) {
12
+ return Boolean(parameter.availableValues) && parameter.multivalue && (editorsType && editorsType.multiSelect && editorsType.multiSelect === ParameterEditorTypes.COMBO_BOX);
13
+ },
14
+ // AvailableValues PROVIDED, MultiValue is FALSE and trv.parameters.editors.singleSelect is unset
15
+ SingleSelect: function(parameter, editorsType) {
16
+ return Boolean(parameter.availableValues) && !parameter.multivalue && (!editorsType || !editorsType.singleSelect || editorsType.singleSelect !== ParameterEditorTypes.COMBO_BOX);
17
+ },
18
+ // AvailableValues PROVIDED, MultiValue is FALSE and trv.parameters.editors.singleSelect is set to COMBO_BOX
19
+ SingleSelectCombo: function(parameter, editorsType) {
20
+ return Boolean(parameter.availableValues) && !parameter.multivalue && (editorsType && editorsType.singleSelect && editorsType.singleSelect === ParameterEditorTypes.COMBO_BOX);
21
+ },
22
+ // AvailableValues NOT PROVIDED and MultiValue is TRUE
23
+ MultiValue: function(parameter) {
24
+ return Boolean(parameter.multivalue);
25
+ },
26
+ DateTime: function(parameter) {
27
+ return parameter.type === ParameterTypes.DATETIME;
28
+ },
29
+ String: function(parameter) {
30
+ return parameter.type === ParameterTypes.STRING;
31
+ },
32
+ Number: function(parameter) {
33
+ switch (parameter.type) {
34
+ case ParameterTypes.INTEGER:
35
+ case ParameterTypes.FLOAT:
36
+ return true;
37
+ default:
38
+ return false;
39
+ }
40
+ },
41
+ Boolean: function(parameter) {
42
+ return parameter.type === ParameterTypes.BOOLEAN;
43
+ },
44
+ Default: function(parameter) {
45
+ return true;
46
+ }
47
+ };
48
+ var multivalueUtils = function() {
49
+ var lineSeparator = "\n";
50
+ return {
51
+ formatValue: function(value) {
52
+ var text = "";
53
+ if (value) {
54
+ [].concat(value).forEach(function(val) {
55
+ if (text.length > 0) {
56
+ text += lineSeparator;
57
+ }
58
+ text += val;
59
+ });
60
+ }
61
+ return text;
62
+ },
63
+ parseValues: function(text) {
64
+ return ("" + text).split(lineSeparator);
65
+ }
66
+ };
67
+ }();
68
+ function integerInputBehavior(input) {
69
+ function isValid(newValue) {
70
+ return /^(\-|\+)?([0-9]*)$/.test(newValue);
71
+ }
72
+ function onKeyPress(event) {
73
+ if (isSpecialKey(event.keyCode)) {
74
+ return true;
75
+ }
76
+ return isValid($(input).val() + String.fromCharCode(event.charCode));
77
+ }
78
+ function onPaste(event) {
79
+ }
80
+ function attach(input2) {
81
+ $(input2).on("keypress", onKeyPress).on("paste", onPaste);
82
+ }
83
+ function detach(input2) {
84
+ $(input2).off("keypress", onKeyPress).off("paste", onPaste);
85
+ }
86
+ attach(input);
87
+ return {
88
+ dispose: function() {
89
+ detach(input);
90
+ }
91
+ };
92
+ }
93
+ function floatInputBehavior(input) {
94
+ function isValid(newValue) {
95
+ return /^(\-|\+)?([0-9]*(\.[0-9]*)?)$/.test(newValue);
96
+ }
97
+ function onKeyPress(event) {
98
+ if (isSpecialKey(event.keyCode)) {
99
+ return true;
100
+ }
101
+ return isValid($(input).val() + String.fromCharCode(event.charCode));
102
+ }
103
+ function onPaste(event) {
104
+ }
105
+ function attach(input2) {
106
+ $(input2).on("keypress", onKeyPress).on("paste", onPaste);
107
+ }
108
+ function detach(input2) {
109
+ $(input2).off("keypress", onKeyPress).off("paste", onPaste);
110
+ }
111
+ attach(input);
112
+ return {
113
+ dispose: function() {
114
+ detach(input);
115
+ }
116
+ };
117
+ }
118
+ function applyClass(apply, cssClass, item) {
119
+ var fn = apply ? $.fn.addClass : $.fn.removeClass;
120
+ fn.call(item, cssClass);
121
+ }
122
+ function enableItem(item, enable) {
123
+ applyClass(!enable, "k-disabled", item);
124
+ }
125
+ function selectItem(item, select) {
126
+ applyClass(select, "k-selected", item);
127
+ item.attr("aria-selected", select);
128
+ }
129
+ function addAccessibilityAttributes(editor, type, caption, additionalInfo, error) {
130
+ if (!additionalInfo) {
131
+ additionalInfo = "";
132
+ }
133
+ var label = stringFormat("{0}. {1} {2}. {3}", [caption, type, stringResources.ariaLabelParameter, additionalInfo]);
134
+ editor.attr("aria-label", label);
135
+ setAccessibilityErrorAttributes(editor, error);
136
+ }
137
+ var containerTabIndex;
138
+ var editorsIndex = 0;
139
+ function setEditorTabIndex(editor) {
140
+ if (!containerTabIndex) {
141
+ var $container = $("div.trv-parameters-area-content");
142
+ if ($container.length > 0) {
143
+ var tabIndexAttr = $container.attr("tabIndex");
144
+ if (tabIndexAttr) {
145
+ containerTabIndex = tryParseInt(tabIndexAttr);
146
+ }
147
+ }
148
+ if (!containerTabIndex || isNaN(containerTabIndex)) {
149
+ containerTabIndex = 300;
150
+ }
151
+ }
152
+ var wrapper = editor.closest(".trv-parameter-value");
153
+ var selectAll = wrapper.find(".trv-select-all");
154
+ var clearSelection = wrapper.find(".trv-select-none");
155
+ var widgetParent = editor.closest(".k-widget");
156
+ var hasFocusableElement = widgetParent.find(".k-input");
157
+ var isComboWidget = hasFocusableElement && hasFocusableElement.length;
158
+ if (selectAll && selectAll.length) {
159
+ selectAll.attr("tabindex", containerTabIndex + ++editorsIndex);
160
+ }
161
+ if (clearSelection && clearSelection.length) {
162
+ clearSelection.attr("tabindex", containerTabIndex + ++editorsIndex);
163
+ }
164
+ if (isComboWidget) {
165
+ hasFocusableElement.attr("tabindex", containerTabIndex + ++editorsIndex);
166
+ } else {
167
+ editor.attr("tabindex", containerTabIndex + ++editorsIndex);
168
+ }
169
+ }
170
+ function setAccessibilityErrorAttributes(editor, error) {
171
+ var errToken = stringFormat(" {0}:", [stringResources.ariaLabelErrorMessage]);
172
+ var label = editor.attr("aria-label");
173
+ if (!label) {
174
+ return;
175
+ }
176
+ var errIdx = label.indexOf(errToken);
177
+ if (errIdx > -1) {
178
+ label = label.substring(0, errIdx);
179
+ }
180
+ if (error && error !== "") {
181
+ editor.attr("aria-required", true);
182
+ editor.attr("aria-invalid", true);
183
+ label += errToken + error;
184
+ } else {
185
+ editor.removeAttr("aria-invalid");
186
+ }
187
+ editor.attr("aria-label", label);
188
+ }
189
+ function navigatableEnabledForList(enableAccessibility) {
190
+ return kendo.version >= "2017.3.1018" || enableAccessibility;
191
+ }
192
+ var ParameterEditors = [
193
+ {
194
+ match: parameterEditorsMatch.MultiSelect,
195
+ createEditor: function(placeholder, options) {
196
+ var $placeholder = $(placeholder);
197
+ var enabled = true;
198
+ $placeholder.html(options.templates["trv-parameter-editor-available-values-multiselect"]);
199
+ var $list = $placeholder.find(".trv-list");
200
+ var $selectAll = $placeholder.find(".trv-select-all");
201
+ var $selectNone = $placeholder.find(".trv-select-none");
202
+ var listView;
203
+ var parameter;
204
+ var updateTimeout;
205
+ var valueChangeCallback = options.parameterChanged;
206
+ var initialized;
207
+ $selectAll.text(stringResources[$selectAll.text()]);
208
+ $selectAll.click(function(e) {
209
+ e.preventDefault();
210
+ if (!enabled)
211
+ return;
212
+ setSelectedItems(parameter.availableValues.map(function(av) {
213
+ return av.value;
214
+ }));
215
+ });
216
+ $selectNone.text(stringResources[$selectNone.text()]);
217
+ $selectNone.click(function(e) {
218
+ e.preventDefault();
219
+ if (!enabled)
220
+ return;
221
+ setSelectedItems([]);
222
+ });
223
+ function onSelectionChanged(selection) {
224
+ if (initialized) {
225
+ applyAriaSelected(selection);
226
+ notifyParameterChanged(selection);
227
+ }
228
+ }
229
+ function applyAriaSelected(selection) {
230
+ var children = $list.find(".trv-listviewitem");
231
+ each(children, function() {
232
+ var $item = $(this);
233
+ var isSelected = selection.filter($item).length > 0;
234
+ $item.attr("aria-selected", isSelected);
235
+ });
236
+ }
237
+ function notifyParameterChanged(selection) {
238
+ var availableValues = parameter.availableValues;
239
+ var values = $.map(selection, function(item) {
240
+ return availableValues[$(item).index()].value;
241
+ });
242
+ clearPendingChange();
243
+ var immediateUpdate = !parameter.autoRefresh && !parameter.childParameters;
244
+ updateTimeout = window.setTimeout(
245
+ function() {
246
+ if (!areEqualArrays(parameter.value, values)) {
247
+ valueChangeCallback(parameter, values);
248
+ }
249
+ updateTimeout = null;
250
+ },
251
+ immediateUpdate ? 0 : 1e3
252
+ );
253
+ }
254
+ function clearPendingChange() {
255
+ if (updateTimeout) {
256
+ window.clearTimeout(updateTimeout);
257
+ }
258
+ }
259
+ function getSelectedItems() {
260
+ return $(listView.element).find(".k-selected");
261
+ }
262
+ function onItemClick(e) {
263
+ if (!enabled)
264
+ return;
265
+ var clickedItem = $(e.target);
266
+ var selectedItems = listView.select();
267
+ if (clickedItem.hasClass("k-selected")) {
268
+ selectedItems.splice($.inArray(clickedItem[0], selectedItems), 1);
269
+ } else {
270
+ selectedItems.push(clickedItem);
271
+ }
272
+ listView.clearSelection();
273
+ listView.select(selectedItems);
274
+ listView.trigger("change");
275
+ }
276
+ function onChange(e) {
277
+ onSelectionChanged(getSelectedItems());
278
+ }
279
+ function onKeydown(event) {
280
+ if (!enabled)
281
+ return;
282
+ if (event.which !== 32) {
283
+ return;
284
+ }
285
+ var focused = listView.element.find(".k-focus");
286
+ if (focused.length > 0) {
287
+ focused.toggleClass("k-selected");
288
+ onSelectionChanged(getSelectedItems());
289
+ event.preventDefault();
290
+ }
291
+ }
292
+ function init() {
293
+ setEditorTabIndex($list);
294
+ setSelectedItems(parameter.value);
295
+ listView.element.off().on("touch click", ".trv-listviewitem", onItemClick);
296
+ listView.element.on("keydown", onKeydown);
297
+ initialized = true;
298
+ }
299
+ function clear() {
300
+ initialized = false;
301
+ if (listView) {
302
+ listView.element.off("touch click", ".trv-listviewitem", onItemClick);
303
+ listView.element.off("keydown", onKeydown);
304
+ }
305
+ }
306
+ function setSelectedItems(items) {
307
+ setSelectedItemsCore(items);
308
+ onSelectionChanged(getSelectedItems());
309
+ }
310
+ function setSelectedItemsCore(items) {
311
+ if (!Array.isArray(items)) {
312
+ items = [items];
313
+ }
314
+ var children = $list.find(".trv-listviewitem");
315
+ each(parameter.availableValues, function(i, av) {
316
+ var selected = false;
317
+ each(items, function(j, v) {
318
+ var availableValue = av.value;
319
+ if (v instanceof Date) {
320
+ availableValue = parseToLocalDate(av.value);
321
+ }
322
+ selected = areEqual(v, availableValue);
323
+ return !selected;
324
+ });
325
+ selectItem($(children[i]), selected);
326
+ });
327
+ }
328
+ return {
329
+ beginEdit: function(param) {
330
+ clear();
331
+ parameter = param;
332
+ try {
333
+ listView = $list.kendoListView({
334
+ template: kendo.template('<div class="trv-listviewitem" style="cursor: pointer">${name}</div>'),
335
+ dataSource: { data: parameter.availableValues },
336
+ selectable: "MULTIPLE",
337
+ navigatable: navigatableEnabledForList(options.enableAccessibility),
338
+ change: onChange
339
+ }).data("kendoListView");
340
+ } catch (e) {
341
+ console.error("Instantiation of Kendo ListView as MultiSelect parameter editor threw an exception", e);
342
+ throw e;
343
+ }
344
+ init();
345
+ },
346
+ enable: function(enable) {
347
+ enabled = enable;
348
+ enableItem($list, enabled);
349
+ },
350
+ clearPendingChange,
351
+ addAccessibility: function(param) {
352
+ var info = stringFormat(stringResources.ariaLabelParameterInfo, [param.availableValues.length]);
353
+ addAccessibilityAttributes($list, stringResources.ariaLabelMultiSelect, param.text, info, param.Error);
354
+ $list.attr("aria-multiselectable", "true");
355
+ var items = $list.find(".trv-listviewitem");
356
+ each(items, function() {
357
+ $(this).attr("aria-label", this.innerText);
358
+ });
359
+ },
360
+ setAccessibilityErrorState: function(param) {
361
+ setAccessibilityErrorAttributes($list, param.Error);
362
+ },
363
+ destroy: function() {
364
+ listView.destroy();
365
+ }
366
+ };
367
+ }
368
+ },
369
+ {
370
+ match: parameterEditorsMatch.MultiSelectCombo,
371
+ createEditor: function(placeholder, options) {
372
+ var $placeholder = $(placeholder);
373
+ var enabled = true;
374
+ var selector = ".trv-combo";
375
+ var template = "trv-parameter-editor-available-values-multiselect-combo";
376
+ var valueChangeCallback = options.parameterChanged;
377
+ var $editorDom;
378
+ var $selectNone;
379
+ var $selectAll;
380
+ var editor;
381
+ var updateTimeout;
382
+ var popUpIsClosed = true;
383
+ var parameter;
384
+ $placeholder.html(options.templates[template]);
385
+ $editorDom = $placeholder.find(selector);
386
+ $selectNone = $placeholder.find(".trv-select-none");
387
+ if ($selectNone) {
388
+ $selectNone.text(stringResources[$selectNone.text()]);
389
+ $selectNone.click(function(e) {
390
+ e.preventDefault();
391
+ editor.value([]);
392
+ editor.trigger("change");
393
+ });
394
+ }
395
+ $selectAll = $placeholder.find(".trv-select-all");
396
+ if ($selectAll) {
397
+ $selectAll.text(stringResources[$selectAll.text()]);
398
+ $selectAll.click(function(e) {
399
+ e.preventDefault();
400
+ if (!enabled)
401
+ return;
402
+ var values = $.map(parameter.availableValues, function(dataItem) {
403
+ return dataItem.value;
404
+ });
405
+ editor.value(values);
406
+ editor.trigger("change");
407
+ });
408
+ }
409
+ function onSelectionChanged(selection) {
410
+ notifyParameterChanged(selection);
411
+ }
412
+ function notifyParameterChanged(values) {
413
+ clearPendingChange();
414
+ var immediateUpdate = !parameter.autoRefresh && !parameter.childParameters;
415
+ updateTimeout = window.setTimeout(
416
+ function() {
417
+ if (!areEqualArrays(parameter.value, values)) {
418
+ valueChangeCallback(parameter, values);
419
+ }
420
+ updateTimeout = null;
421
+ },
422
+ immediateUpdate ? 0 : 1e3
423
+ );
424
+ }
425
+ function clearPendingChange() {
426
+ if (updateTimeout) {
427
+ window.clearTimeout(updateTimeout);
428
+ }
429
+ }
430
+ function getSelectedItems() {
431
+ return editor.value();
432
+ }
433
+ function onChange() {
434
+ if (popUpIsClosed) {
435
+ onSelectionChanged(getSelectedItems());
436
+ }
437
+ }
438
+ function init() {
439
+ setEditorTabIndex($editorDom);
440
+ editor.bind("change", onChange);
441
+ }
442
+ function reset() {
443
+ if (editor) {
444
+ editor.unbind("change", onChange);
445
+ }
446
+ }
447
+ return {
448
+ beginEdit: function(param) {
449
+ reset();
450
+ parameter = param;
451
+ try {
452
+ editor = $editorDom.kendoMultiSelect({
453
+ itemTemplate: '<div class="trv-editoritem">${name}</div>',
454
+ dataSource: parameter.availableValues,
455
+ dataTextField: "name",
456
+ dataValueField: "value",
457
+ value: parameter.value,
458
+ filter: "contains",
459
+ autoClose: false,
460
+ open: function() {
461
+ popUpIsClosed = false;
462
+ },
463
+ close: function(e) {
464
+ popUpIsClosed = true;
465
+ onChange();
466
+ },
467
+ autoWidth: true,
468
+ clearButton: false
469
+ }).data("kendoMultiSelect");
470
+ } catch (e) {
471
+ console.error("Instantiation of Kendo MultiSelect as MultiSelectCombo parameter editor threw an exception", e);
472
+ throw e;
473
+ }
474
+ init();
475
+ },
476
+ enable: function(enable) {
477
+ enabled = enable;
478
+ editor.enable(enable);
479
+ },
480
+ clearPendingChange,
481
+ addAccessibility: function(param) {
482
+ var $accessibilityDom = editor.input;
483
+ var info = stringFormat(stringResources.ariaLabelParameterInfo, [param.availableValues.length]);
484
+ addAccessibilityAttributes($accessibilityDom, stringResources.ariaLabelMultiSelect, param.text, info, param.Error);
485
+ var items = editor.items();
486
+ each(items, function() {
487
+ $(this).attr("aria-label", this.innerText);
488
+ });
489
+ },
490
+ setAccessibilityErrorState: function(param) {
491
+ setAccessibilityErrorAttributes($editorDom, param.Error);
492
+ },
493
+ destroy: function() {
494
+ editor.destroy();
495
+ }
496
+ };
497
+ }
498
+ },
499
+ {
500
+ match: parameterEditorsMatch.SingleSelect,
501
+ createEditor: function(placeholder, options) {
502
+ var $placeholder = $(placeholder);
503
+ var enabled = true;
504
+ $placeholder.html(options.templates["trv-parameter-editor-available-values"]);
505
+ var $list = $placeholder.find(".trv-list");
506
+ var $selectNone = $placeholder.find(".trv-select-none");
507
+ var listView;
508
+ var parameter;
509
+ var valueChangeCallback = options.parameterChanged;
510
+ if ($selectNone) {
511
+ $selectNone.text(stringResources[$selectNone.text()]);
512
+ $selectNone.click(function(e) {
513
+ e.preventDefault();
514
+ listView.clearSelection();
515
+ listView.trigger("change");
516
+ });
517
+ }
518
+ function onSelectionChanged(selection) {
519
+ notifyParameterChanged(selection);
520
+ }
521
+ function notifyParameterChanged(selection) {
522
+ var availableValues = parameter.availableValues;
523
+ var values = $.map(selection, function(item) {
524
+ return availableValues[$(item).index()].value;
525
+ });
526
+ if (Array.isArray(values)) {
527
+ values = values[0];
528
+ }
529
+ valueChangeCallback(parameter, values);
530
+ }
531
+ function getSelectedItems() {
532
+ return listView.select();
533
+ }
534
+ function onChange() {
535
+ onSelectionChanged(getSelectedItems());
536
+ }
537
+ function init() {
538
+ setEditorTabIndex($list);
539
+ setSelectedItems(parameter.value);
540
+ listView.bind("change", onChange);
541
+ }
542
+ function reset() {
543
+ if (listView) {
544
+ listView.unbind("change", onChange);
545
+ }
546
+ }
547
+ function setSelectedItems(value) {
548
+ var items = $list.find(".trv-listviewitem");
549
+ each(parameter.availableValues, function(i, av) {
550
+ var availableValue = av.value;
551
+ if (value instanceof Date) {
552
+ availableValue = parseToLocalDate(av.value);
553
+ }
554
+ if (areEqual(value, availableValue)) {
555
+ listView.select(items[i]);
556
+ return false;
557
+ }
558
+ return true;
559
+ });
560
+ }
561
+ return {
562
+ beginEdit: function(param) {
563
+ reset();
564
+ parameter = param;
565
+ try {
566
+ listView = $list.kendoListView({
567
+ template: '<div class="trv-listviewitem">${name}</div>',
568
+ dataSource: { data: parameter.availableValues },
569
+ selectable: true,
570
+ navigatable: navigatableEnabledForList(options.enableAccessibility)
571
+ }).data("kendoListView");
572
+ } catch (e) {
573
+ console.error("Instantiation of Kendo ListView as SingleSelect parameter editor threw an exception", e);
574
+ throw e;
575
+ }
576
+ init();
577
+ },
578
+ enable: function(enable) {
579
+ enabled = enable;
580
+ enableItem($list, enabled);
581
+ if (enabled) {
582
+ listView.bind("change", onChange);
583
+ $list.addClass("k-selectable");
584
+ } else {
585
+ listView.unbind("change", onChange);
586
+ $list.removeClass("k-selectable");
587
+ }
588
+ },
589
+ addAccessibility: function(param) {
590
+ var info = stringFormat(stringResources.ariaLabelParameterInfo, [param.availableValues.length]);
591
+ addAccessibilityAttributes($list, stringResources.ariaLabelSingleValue, param.text, info, param.Error);
592
+ var items = $list.find(".trv-listviewitem");
593
+ each(items, function() {
594
+ $(this).attr("aria-label", this.innerText);
595
+ });
596
+ },
597
+ setAccessibilityErrorState: function(param) {
598
+ setAccessibilityErrorAttributes($list, param.Error);
599
+ },
600
+ destroy: function() {
601
+ listView.destroy();
602
+ }
603
+ };
604
+ }
605
+ },
606
+ {
607
+ match: parameterEditorsMatch.SingleSelectCombo,
608
+ createEditor: function(placeholder, options) {
609
+ var $placeholder = $(placeholder);
610
+ var selector = ".trv-combo";
611
+ var template = "trv-parameter-editor-available-values-combo";
612
+ var valueChangeCallback = options.parameterChanged;
613
+ var $editorDom;
614
+ var $selectNone;
615
+ var editor;
616
+ var parameter;
617
+ $placeholder.html(options.templates[template]);
618
+ $editorDom = $placeholder.find(selector);
619
+ $selectNone = $placeholder.find(".trv-select-none");
620
+ if ($selectNone) {
621
+ $selectNone.text(stringResources[$selectNone.text()]);
622
+ $selectNone.click(function(e) {
623
+ e.preventDefault();
624
+ editor.value("");
625
+ editor.trigger("change");
626
+ });
627
+ }
628
+ function onSelectionChanged(selection, value) {
629
+ notifyParameterChanged(selection, value);
630
+ }
631
+ function notifyParameterChanged(selection, value) {
632
+ var values = value || "";
633
+ var availableValues;
634
+ if (!value && selection >= 0) {
635
+ availableValues = parameter.availableValues;
636
+ values = availableValues[selection].value;
637
+ }
638
+ valueChangeCallback(parameter, values);
639
+ }
640
+ function getSelectedItems() {
641
+ return editor.select();
642
+ }
643
+ function onChange(e) {
644
+ onSelectionChanged(getSelectedItems(), this.value());
645
+ }
646
+ function init() {
647
+ setEditorTabIndex($editorDom);
648
+ editor.bind("change", onChange);
649
+ }
650
+ function reset() {
651
+ if (editor) {
652
+ editor.unbind("change", onChange);
653
+ }
654
+ }
655
+ return {
656
+ beginEdit: function(param) {
657
+ reset();
658
+ parameter = param;
659
+ try {
660
+ editor = $editorDom.kendoComboBox({
661
+ template: '<div class="trv-editoritem">${name}</div>',
662
+ dataSource: parameter.availableValues,
663
+ dataTextField: "name",
664
+ dataValueField: "value",
665
+ value: parameter.value,
666
+ filter: "contains",
667
+ suggest: true,
668
+ clearButton: false
669
+ }).data("kendoComboBox");
670
+ } catch (e) {
671
+ console.error("Instantiation of Kendo ComboBox as SingleSelectCombo parameter editor threw an exception", e);
672
+ throw e;
673
+ }
674
+ init();
675
+ },
676
+ enable: function(enable) {
677
+ editor.enable(enable);
678
+ },
679
+ addAccessibility: function(param) {
680
+ var $accessibilityDom = editor.input;
681
+ var info = stringFormat(stringResources.ariaLabelParameterInfo, [param.availableValues.length]);
682
+ addAccessibilityAttributes($accessibilityDom, stringResources.ariaLabelSingleValue, param.text, info, param.Error);
683
+ var items = editor.items();
684
+ each(items, function() {
685
+ $(this).attr("aria-label", this.innerText);
686
+ });
687
+ },
688
+ setAccessibilityErrorState: function(param) {
689
+ setAccessibilityErrorAttributes($editorDom, param.Error);
690
+ },
691
+ destroy: function() {
692
+ editor.destroy();
693
+ }
694
+ };
695
+ }
696
+ },
697
+ {
698
+ match: parameterEditorsMatch.MultiValue,
699
+ createEditor: function(placeholder, options) {
700
+ var $placeholder = $(placeholder);
701
+ var parameter;
702
+ $placeholder.html(options.templates["trv-parameter-editor-multivalue"]);
703
+ var $textArea = $placeholder.find("textarea").on("change", function() {
704
+ if (options.parameterChanged) {
705
+ options.parameterChanged(parameter, multivalueUtils.parseValues(this.value));
706
+ }
707
+ });
708
+ function setValue(value) {
709
+ parameter.value = value;
710
+ $textArea.val(multivalueUtils.formatValue(value));
711
+ }
712
+ return {
713
+ beginEdit: function(param) {
714
+ parameter = param;
715
+ setValue(param.value);
716
+ setEditorTabIndex($textArea);
717
+ },
718
+ enable: function(enable) {
719
+ enableItem($textArea, enable);
720
+ $textArea.prop("disabled", !enable);
721
+ },
722
+ addAccessibility: function(param) {
723
+ addAccessibilityAttributes($textArea, stringResources.ariaLabelMultiValue, param.text, null, param.Error);
724
+ },
725
+ setAccessibilityErrorState: function(param) {
726
+ setAccessibilityErrorAttributes($textArea, param.Error);
727
+ }
728
+ };
729
+ }
730
+ },
731
+ {
732
+ match: parameterEditorsMatch.DateTime,
733
+ createEditor: function(placeholder, options) {
734
+ var $placeholder = $(placeholder);
735
+ var parameter;
736
+ $placeholder.html(options.templates["trv-parameter-editor-datetime"]);
737
+ try {
738
+ var $dateTimePicker = $placeholder.find("input[type=datetime]").kendoDatePicker({
739
+ change: function() {
740
+ var handler = options.parameterChanged;
741
+ if (handler) {
742
+ var dtv = this.value();
743
+ if (null !== dtv) {
744
+ dtv = adjustTimezone(dtv);
745
+ }
746
+ handler(parameter, dtv);
747
+ }
748
+ }
749
+ });
750
+ var dateTimePicker = $dateTimePicker.data("kendoDatePicker");
751
+ } catch (e) {
752
+ console.error("Instantiation of Kendo DatePicker as DateTime parameter editor threw an exception", e);
753
+ throw e;
754
+ }
755
+ function setValue(value) {
756
+ parameter.value = value;
757
+ var dt = null;
758
+ try {
759
+ if (value) {
760
+ dt = unadjustTimezone(value);
761
+ }
762
+ } catch (e) {
763
+ dt = null;
764
+ }
765
+ dateTimePicker.value(dt);
766
+ }
767
+ return {
768
+ beginEdit: function(param) {
769
+ parameter = param;
770
+ setValue(param.value);
771
+ setEditorTabIndex($dateTimePicker);
772
+ },
773
+ enable: function(enable) {
774
+ dateTimePicker.enable(enable);
775
+ enableItem($dateTimePicker, enable);
776
+ },
777
+ addAccessibility: function(param) {
778
+ addAccessibilityAttributes($dateTimePicker, stringResources.ariaLabelParameterDateTime, param.text, null, param.Error);
779
+ $dateTimePicker.attr("aria-live", "assertive");
780
+ },
781
+ setAccessibilityErrorState: function(param) {
782
+ setAccessibilityErrorAttributes($dateTimePicker, param.Error);
783
+ },
784
+ destroy: function() {
785
+ dateTimePicker.destroy();
786
+ }
787
+ };
788
+ }
789
+ },
790
+ {
791
+ match: parameterEditorsMatch.String,
792
+ createEditor: function(placeholder, options) {
793
+ var $placeholder = $(placeholder);
794
+ var parameter;
795
+ $placeholder.html(options.templates["trv-parameter-editor-text"]);
796
+ var $input = $placeholder.find('input[type="text"]').change(function() {
797
+ if (options.parameterChanged) {
798
+ options.parameterChanged(parameter, $input.val());
799
+ }
800
+ });
801
+ function setValue(value) {
802
+ parameter.value = value;
803
+ $input.val(value);
804
+ }
805
+ return {
806
+ beginEdit: function(param) {
807
+ parameter = param;
808
+ setValue(param.value);
809
+ setEditorTabIndex($input);
810
+ },
811
+ enable: function(enabled) {
812
+ $input.prop("disabled", !enabled);
813
+ enableItem($input, enabled);
814
+ },
815
+ addAccessibility: function(param) {
816
+ addAccessibilityAttributes($input, stringResources.ariaLabelParameterString, param.text, null, param.Error);
817
+ $input.attr("aria-live", "assertive");
818
+ },
819
+ setAccessibilityErrorState: function(param) {
820
+ setAccessibilityErrorAttributes($input, param.Error);
821
+ }
822
+ };
823
+ }
824
+ },
825
+ {
826
+ match: parameterEditorsMatch.Number,
827
+ createEditor: function(placeholder, options) {
828
+ var $placeholder = $(placeholder);
829
+ var parameter;
830
+ var inputBehavior;
831
+ $placeholder.html(options.templates["trv-parameter-editor-number"]);
832
+ var $input = $placeholder.find("input[type=number]").on("change", function() {
833
+ if (options.parameterChanged) {
834
+ options.parameterChanged(parameter, $input.val());
835
+ }
836
+ });
837
+ return {
838
+ beginEdit: function(param) {
839
+ if (inputBehavior) {
840
+ inputBehavior.dispose();
841
+ }
842
+ parameter = param;
843
+ $input.val(parameter.value);
844
+ if (parameter.type === ParameterTypes.INTEGER) {
845
+ inputBehavior = integerInputBehavior($input);
846
+ } else {
847
+ inputBehavior = floatInputBehavior($input);
848
+ }
849
+ setEditorTabIndex($input);
850
+ },
851
+ enable: function(enable) {
852
+ $input.prop("disabled", !enable);
853
+ enableItem($input, enable);
854
+ },
855
+ addAccessibility: function(param) {
856
+ addAccessibilityAttributes($input, stringResources.ariaLabelParameterNumerical, param.text, null, param.Error);
857
+ $input.attr("aria-live", "assertive");
858
+ },
859
+ setAccessibilityErrorState: function(param) {
860
+ setAccessibilityErrorAttributes($input, param.Error);
861
+ }
862
+ };
863
+ }
864
+ },
865
+ {
866
+ match: parameterEditorsMatch.Boolean,
867
+ createEditor: function(placeholder, options) {
868
+ var $placeholder = $(placeholder);
869
+ var parameter;
870
+ $placeholder.html(options.templates["trv-parameter-editor-boolean"]);
871
+ var $input = $placeholder.find("input[type=checkbox]").on("change", function() {
872
+ if (options.parameterChanged) {
873
+ options.parameterChanged(parameter, this.checked);
874
+ }
875
+ });
876
+ function setValue(value) {
877
+ parameter.value = value;
878
+ $input[0].checked = value === true;
879
+ }
880
+ return {
881
+ beginEdit: function(param) {
882
+ parameter = param;
883
+ setValue(param.value);
884
+ setEditorTabIndex($input);
885
+ },
886
+ enable: function(enable) {
887
+ enableItem($input, enable);
888
+ $input.attr("disabled", !enable);
889
+ },
890
+ addAccessibility: function(param) {
891
+ addAccessibilityAttributes($input, stringResources.ariaLabelParameterBoolean, param.text, null, param.Error);
892
+ $input.attr("aria-live", "assertive");
893
+ },
894
+ setAccessibilityErrorState: function(param) {
895
+ setAccessibilityErrorAttributes($input, param.Error);
896
+ }
897
+ };
898
+ }
899
+ },
900
+ {
901
+ match: parameterEditorsMatch.Default,
902
+ createEditor: function(placeholder, options) {
903
+ var $placeholder = $(placeholder);
904
+ $placeholder.html('<div class="trv-parameter-editor-generic"></div>');
905
+ return {
906
+ beginEdit: function(parameter) {
907
+ $placeholder.find(".trv-parameter-editor-generic").text(parameter.Error ? "(error)" : parameter.value);
908
+ },
909
+ enable: function(enable) {
910
+ }
911
+ };
912
+ }
913
+ }
914
+ ];
915
+
916
+ export { ParameterEditors, parameterEditorsMatch };