Daniel@0
|
1 "use strict";
|
Daniel@0
|
2
|
Daniel@0
|
3 App.module("RepresentationModule", function(RepresentationModule, App, Backbone, Marionette, $, _, Logger) {
|
Daniel@0
|
4
|
Daniel@0
|
5 RepresentationModule.addInitializer(function(options){
|
Daniel@0
|
6
|
Daniel@0
|
7 RepresentationModule.registerMaster({
|
Daniel@0
|
8 id: "entity._pair",
|
Daniel@0
|
9 inherit: "entity._",
|
Daniel@0
|
10
|
Daniel@0
|
11 defaultConfigParameterValues: {
|
Daniel@0
|
12 comparisonMode: "superposition"
|
Daniel@0
|
13 },
|
Daniel@0
|
14
|
Daniel@0
|
15
|
Daniel@0
|
16 // =================================================================
|
Daniel@0
|
17 // config grid panel
|
Daniel@0
|
18
|
Daniel@0
|
19
|
Daniel@0
|
20 // -----------------------------------------------------------------
|
Daniel@0
|
21 // config grid panel - prepare
|
Daniel@0
|
22
|
Daniel@0
|
23 prepareConfigGridPanelMainArea: function(configGridPanelView) {
|
Daniel@0
|
24 // Comparison mode radio buttons (tick boxes)
|
Daniel@0
|
25 var $comparisonModeTickBoxes = configGridPanelView._$mainArea.find("[data-comparison-mode]");
|
Daniel@0
|
26 configGridPanelView._$mainArea.data("$tickboxes_comparisonMode", $comparisonModeTickBoxes);
|
Daniel@0
|
27 $comparisonModeTickBoxes.each(function() {
|
Daniel@0
|
28 var $tickbox = $(this);
|
Daniel@0
|
29 var comparisonMode = $tickbox.data("comparison-mode");
|
Daniel@0
|
30 configGridPanelView._$mainArea.data("$tickbox_comparison-mode_" + comparisonMode, $tickbox);
|
Daniel@0
|
31 });
|
Daniel@0
|
32
|
Daniel@0
|
33 // Parent master's behaviour
|
Daniel@0
|
34 RepresentationModule.getMasterById("entity._").prepareConfigGridPanelMainArea.apply(this, arguments);
|
Daniel@0
|
35 },
|
Daniel@0
|
36
|
Daniel@0
|
37
|
Daniel@0
|
38 __panelInputChangeValueHandler: function(event) {
|
Daniel@0
|
39 if (event.type == "tickboxchangevalue") {
|
Daniel@0
|
40 var $thickbox = $(event.target);
|
Daniel@0
|
41 var comparisonMode = $thickbox.data("comparisonMode");
|
Daniel@0
|
42 if (comparisonMode) {
|
Daniel@0
|
43 var configGridPanelView = $thickbox.data("configGridPanelView");
|
Daniel@0
|
44 if (!configGridPanelView._$mainArea.data("ignoreChangesInComparisonModeTickboxes")) {
|
Daniel@0
|
45 var master = $thickbox.data("configGridPanelView")._masterBehindMainArea;
|
Daniel@0
|
46 master.planConfigParameterUpdateWithRespectToValueAndDefaultValue(configGridPanelView._cachedConfig, "comparisonMode", comparisonMode);
|
Daniel@0
|
47 }
|
Daniel@0
|
48 return;
|
Daniel@0
|
49 };
|
Daniel@0
|
50 }
|
Daniel@0
|
51
|
Daniel@0
|
52 // Parent master's behaviour
|
Daniel@0
|
53 RepresentationModule.getMasterById("entity._").__panelInputChangeValueHandler.apply(this, arguments);
|
Daniel@0
|
54 },
|
Daniel@0
|
55
|
Daniel@0
|
56
|
Daniel@0
|
57 // -----------------------------------------------------------------
|
Daniel@0
|
58 // config grid panel - sync
|
Daniel@0
|
59
|
Daniel@0
|
60 syncConfigGridPanelMainArea: function(configGridPanelView, instant) {
|
Daniel@0
|
61
|
Daniel@0
|
62 // comparison mode tick boxes + field visibility
|
Daniel@0
|
63 var comparisonMode = this.getConfigParameterValueOrDefaultValue(configGridPanelView._cachedConfig, "comparisonMode").toLowerCase();
|
Daniel@0
|
64 var plannedComparisonMode = this.getConfigPlannedParameterValueOrDefaultValue(configGridPanelView._cachedConfig, "comparisonMode").toLowerCase();
|
Daniel@0
|
65 var comparisonModeHash = comparisonMode + plannedComparisonMode;
|
Daniel@0
|
66 if (configGridPanelView._$mainArea.data("comparisonModeHash") != comparisonModeHash) {
|
Daniel@0
|
67 configGridPanelView._$mainArea.data("comparisonModeHash", comparisonModeHash);
|
Daniel@0
|
68
|
Daniel@0
|
69 // tick boxes
|
Daniel@0
|
70 configGridPanelView._$mainArea.data("ignoreChangesInComparisonModeTickboxes", true);
|
Daniel@0
|
71 configGridPanelView._$mainArea.data("$tickboxes_comparisonMode").each(function() {
|
Daniel@0
|
72 var $tickbox = $(this);
|
Daniel@0
|
73 var value = plannedComparisonMode == $tickbox.data("comparison-mode") ? "1" : "";
|
Daniel@0
|
74 var baseValue = (comparisonMode !== plannedComparisonMode)
|
Daniel@0
|
75 ? (value ? "" : "1")
|
Daniel@0
|
76 : (value ? "1" : "");
|
Daniel@0
|
77
|
Daniel@0
|
78 $tickbox.tickbox("option", {
|
Daniel@0
|
79 "value": value,
|
Daniel@0
|
80 "baseValue": baseValue
|
Daniel@0
|
81 });
|
Daniel@0
|
82 });
|
Daniel@0
|
83 configGridPanelView._$mainArea.removeData("ignoreChangesInComparisonModeTickboxes");
|
Daniel@0
|
84
|
Daniel@0
|
85 // show / hide input blocks
|
Daniel@0
|
86 // var presentParameterNames = _.keys(this._getPresentParameterNamesForLibrary(plannedComparisonMode));
|
Daniel@0
|
87 // var absentParameterNames = _.difference(_.keys(this.options.presenceOfParameters), presentParameterNames);
|
Daniel@0
|
88 //
|
Daniel@0
|
89 // for (var i = 0; i < presentParameterNames.length; i++) {
|
Daniel@0
|
90 // configGridPanelView._$mainArea.data("$inputBlock_" + presentParameterNames[i]).show();
|
Daniel@0
|
91 // }
|
Daniel@0
|
92 // for (var i = 0; i < absentParameterNames.length; i++) {
|
Daniel@0
|
93 // configGridPanelView._$mainArea.data("$inputBlock_" + absentParameterNames[i]).hide();
|
Daniel@0
|
94 // }
|
Daniel@0
|
95 }
|
Daniel@0
|
96
|
Daniel@0
|
97 // Parent master's behaviour
|
Daniel@0
|
98 RepresentationModule.getMasterById("entity._").syncConfigGridPanelMainArea.apply(this, arguments);
|
Daniel@0
|
99 },
|
Daniel@0
|
100
|
Daniel@0
|
101
|
Daniel@0
|
102 // =================================================================
|
Daniel@0
|
103 // vis instance rendering
|
Daniel@0
|
104
|
Daniel@0
|
105
|
Daniel@0
|
106 // -----------------------------------------------------------------
|
Daniel@0
|
107 // debug mode
|
Daniel@0
|
108
|
Daniel@0
|
109 _mapDerivedVisInstanceDataAttributesToDebugAPIQueryBoxes: function (viewMaster) {
|
Daniel@0
|
110 if (viewMaster.options.visInstanceSupportedComparisonModes.length) {
|
Daniel@0
|
111 return [["left", "base", "apiRequestURIOnTheLeft", "apiResponseOnTheLeft"],
|
Daniel@0
|
112 ["right", "base", "apiRequestURIOnTheRight", "apiResponseOnTheRight"]];
|
Daniel@0
|
113 } else {
|
Daniel@0
|
114 return [];
|
Daniel@0
|
115 }
|
Daniel@0
|
116 }
|
Daniel@0
|
117 });
|
Daniel@0
|
118 });
|
Daniel@0
|
119 }, Logger);
|