Commit d4d0fe971e259bcce4cae19fd95fe7e259aacc59

Authored by Adabriand Furtado
1 parent 5bfc2de5
Exists in master and in 1 other branch dynamic

Comentários no módulo de controle do Workflow e remoção de código desnecessário.

view/assets/js/articulation.js
... ... @@ -31,7 +31,7 @@
31 31 $(articulation_x_y + " .ball-selector").off("click").on("click", function(a) {
32 32 var b = $(a.target);
33 33 if (!b.hasClass("ball-selector")) {
34   - dynworkflow.selectedConfig();
  34 + dynworkflow.userSelectedAnOption();
35 35 return;
36 36 }
37 37 var c = b.parent(".grid-row"),
... ... @@ -42,7 +42,7 @@
42 42 selectedY = g;
43 43 _setupModuleZ(hand);
44 44 //_updateParameterJSON(hand);
45   - dynworkflow.selectedConfig();
  45 + dynworkflow.userSelectedAnOption();
46 46 });
47 47 }
48 48  
... ... @@ -52,7 +52,7 @@
52 52 $(articulation_z + " .ball-selector").off("click").on("click", function(a) {
53 53 var b = $(a.target);
54 54 if (!b.hasClass("ball-selector")) {
55   - dynworkflow.selectedConfig();
  55 + dynworkflow.userSelectedAnOption();
56 56 return;
57 57 }
58 58 var c = b.parent(".grid-row"),
... ... @@ -60,7 +60,7 @@
60 60 h = b.attr("data-z");
61 61 b.attr("data-z") && e.attr("data-z", h), _updateASelector(articulation_z, b);
62 62 //_updateParameterJSON(hand);
63   - dynworkflow.selectedConfig();
  63 + dynworkflow.userSelectedAnOption();
64 64 });
65 65 }
66 66  
... ...
view/assets/js/configuration.js
... ... @@ -4,8 +4,8 @@
4 4 var baseId = ".selection-panel-body[mainConfig=right-hand][subConfig=configuracao][step=1]";
5 5 $(baseId + " .selection-panel-option"
6 6 ).off("click").on("click", function() {
7   - wikilibras.selectConfig(baseId, this);
8   - dynworkflow.selectedConfig();
  7 + wikilibras.selectAnOption(baseId, this);
  8 + dynworkflow.userSelectedAnOption();
9 9 });
10 10 };
11 11  
... ... @@ -13,8 +13,8 @@
13 13 var stepTwoBaseId = ".selection-panel-body[mainConfig=right-hand][subConfig=configuracao][step=2]";
14 14 $(stepTwoBaseId + " .selection-panel-option").off("click").on(
15 15 "click", function() {
16   - wikilibras.selectConfig(stepTwoBaseId, this);
17   - dynworkflow.selectedConfig();
  16 + wikilibras.selectAnOption(stepTwoBaseId, this);
  17 + dynworkflow.userSelectedAnOption();
18 18 });
19 19  
20 20 var stepOneBaseId = ".selection-panel-body[mainConfig=right-hand][subConfig=configuracao][step=1]";
... ...
view/assets/js/dynamic-selection-workflow.js
1 1 (function(dynworkflow, $, undefined) {
2 2  
  3 + // Workflow configuration
3 4 var jsonWF = {};
4 5 var baseUrl = "";
5 6  
  7 + // Main configurations: right-hand, left-hand and facial
6 8 var mainConfig = "";
  9 + // The converted Main Config (right/left-hand) to hand for using the same configuration
7 10 var preprocessedMainConfig = "";
8   - var currentSubconfigParent = "";
  11 + // Subconfigurations: Movimento, articulacao, configuracao, orientacao, etc
9 12 var currentSubconfig = "";
10 13 var currentSubConfigName = "";
  14 + var currentSubconfigParent = "";
11 15 var currentStep = 0;
12 16  
13 17 function _preprocessMainConfig(config) {
14 18 config = config.replace("right-hand", "hand");
15 19 config = config.replace("left-hand", "hand");
16 20 return config;
17   - };
  21 + }
18 22  
19 23 function _getFirstKey(json) {
20 24 var first_key = undefined;
... ... @@ -44,6 +48,7 @@
44 48 _showSubconfiguration(mainConfig, currentSubConfigName, currentStep);
45 49 }
46 50  
  51 + // It checks if a selection panel is already loaded
47 52 function _isSubconfigurationPanelLoaded(mainConfig, subConfig, stepNumber) {
48 53 var stepNumber = stepNumber + 1;
49 54 return $(".selection-panel-body[mainConfig=" + mainConfig + "][subConfig=" + subConfig +
... ... @@ -56,9 +61,9 @@
56 61 "][step=" + stepNumber + "]").show();
57 62 }
58 63  
  64 + // It renders or shows the requested selection panel
59 65 function _showSubconfiguration(mainConfig, subConfig, stepNumber) {
60 66 $(".selection-panel-body").hide();
61   -
62 67 if (_isSubconfigurationPanelLoaded(mainConfig, subConfig, stepNumber)) {
63 68 _showLoadedSubconfigurationPanel(mainConfig, subConfig, stepNumber);
64 69 } else {
... ... @@ -67,36 +72,9 @@
67 72 dynengine.render(baseUrl, "/" + preprocessedMainConfig + "/" + subConfig +
68 73 "/" + step + ".html", "#selection-panel", true);
69 74 }
70   -
71 75 _selectTimelineIcon(mainConfig, subConfig, true);
72 76 }
73 77  
74   - dynworkflow.selectMainConfig = function(config) {
75   - mainConfig = config;
76   - preprocessedMainConfig = _preprocessMainConfig(mainConfig)
77   - currentSubConfigName = _getFirstKey(jsonWF[preprocessedMainConfig]);
78   - currentSubconfig = jsonWF[preprocessedMainConfig][currentSubConfigName];
79   - currentSubconfigParent = jsonWF[preprocessedMainConfig];
80   - currentStep = 0;
81   -
82   - _showCurrentSubconfig();
83   -
84   - if (preprocessedMainConfig != "hand" || _isTimelineLoaded()) {
85   - _setupTimeline();
86   - }
87   - }
88   -
89   - dynworkflow.selectMovement = function(movement) {
90   - var subconfigJSON = currentSubconfig[movement]
91   - currentSubConfigName = _getFirstKey(subconfigJSON);
92   - currentSubconfigParent = subconfigJSON;
93   - currentSubconfig = subconfigJSON[currentSubConfigName];
94   - currentStep = 0;
95   -
96   - _showCurrentSubconfig();
97   - _setupTimeline();
98   - }
99   -
100 78 function _selectSubConfig(subConfig) {
101 79 currentSubConfigName = subConfig;
102 80 currentSubconfig = currentSubconfigParent[currentSubConfigName];
... ... @@ -105,15 +83,8 @@
105 83 _showCurrentSubconfig();
106 84 }
107 85  
108   - dynworkflow.selectSubConfig = function(subConfig) {
109   - _selectSubConfig(subConfig);
110   - }
111   -
112   - dynworkflow.nextSubConfig = function() {
113   - _nextSubConfig();
114   - }
115   -
116   - function _nextSubConfig() {
  86 + // It show the next selection panel on the workflow
  87 + function _showNextSubConfig() {
117 88 currentStep = currentStep + 1;
118 89 if (currentStep < currentSubconfig.length) {
119 90 _showCurrentSubconfig();
... ... @@ -127,17 +98,15 @@
127 98 }
128 99 }
129 100  
130   - function _selectedConfig() {
  101 + // A callback function to be called when the user selects a option on a panel
  102 + function _userSelectedAnOption() {
131 103 if (currentStep == currentSubconfig.length - 1) {
132 104 _setupCheckIcon(mainConfig, currentSubConfigName);
133 105 }
134   - _nextSubConfig();
135   - }
136   -
137   - dynworkflow.selectedConfig = function() {
138   - _selectedConfig();
  106 + _showNextSubConfig();
139 107 }
140 108  
  109 + // Timeline functions
141 110 function _selectTimelineIcon(mainConfig, subConfig) {
142 111 var icon_id = ".subconfiguration-panel[mainConfig=" + mainConfig +
143 112 "] .icon_container[json_name=" + subConfig + "]";
... ... @@ -177,7 +146,7 @@
177 146 }
178 147  
179 148 function _setupTimelineIcons(timelineBaseId) {
180   - $(timelineBaseId + " .icon_container").hide();
  149 + $(timelineBaseId + " .icon_container[json_name]").hide();
181 150  
182 151 for (var name in currentSubconfigParent) {
183 152 $(timelineBaseId + " .icon_container[json_name=" + name + "]").show();
... ... @@ -188,8 +157,7 @@
188 157 //TODO Refact
189 158 _selectTimelineIcon(mainConfig, "articulacao");
190 159 }
191   -
192   - $(timelineBaseId + " .icon_container").off("click").on("click",
  160 + $(timelineBaseId + " .icon_container[json_name]").off("click").on("click",
193 161 function() {
194 162 var subConfig = $(this).attr("json_name");
195 163 _selectSubConfig(subConfig);
... ... @@ -210,12 +178,42 @@
210 178 }
211 179 }
212 180  
213   - dynworkflow.setupTimeline = function() {
  181 + // Public methods
  182 + dynworkflow.selectMainConfig = function(config) {
  183 + mainConfig = config;
  184 + preprocessedMainConfig = _preprocessMainConfig(mainConfig);
  185 + currentSubConfigName = _getFirstKey(jsonWF[preprocessedMainConfig]);
  186 + currentSubconfig = jsonWF[preprocessedMainConfig][currentSubConfigName];
  187 + currentSubconfigParent = jsonWF[preprocessedMainConfig];
  188 + currentStep = 0;
  189 +
  190 + _showCurrentSubconfig();
  191 +
  192 + if (preprocessedMainConfig != "hand" || _isTimelineLoaded()) {
  193 + _setupTimeline();
  194 + }
  195 + }
  196 +
  197 + dynworkflow.selectMovement = function(movement) {
  198 + var subconfigJSON = currentSubconfig[movement]
  199 + currentSubConfigName = _getFirstKey(subconfigJSON);
  200 + currentSubconfigParent = subconfigJSON;
  201 + currentSubconfig = subconfigJSON[currentSubConfigName];
  202 + currentStep = 0;
  203 +
  204 + _showCurrentSubconfig();
214 205 _setupTimeline();
215 206 }
216   -
  207 +
  208 + dynworkflow.selectSubConfig = function(subConfig) {
  209 + _selectSubConfig(subConfig);
  210 + }
  211 +
  212 + dynworkflow.userSelectedAnOption = function() {
  213 + _userSelectedAnOption();
  214 + }
  215 +
217 216 dynworkflow.load = function() {
218   - loadedPanel = {};
219 217 baseUrl = $('#server-url').data('url');
220 218 $.get(baseUrl + "/conf/selection-workflow-json", function(result) {
221 219 jsonWF = $.parseJSON(result);
... ...
view/assets/js/movement.js
... ... @@ -4,7 +4,7 @@
4 4 var baseId = ".selection-panel-body[mainConfig=right-hand][subConfig=movimento][step=1]";
5 5 $(baseId + " .selection-panel-option").off("click").on(
6 6 "click", function() {
7   - wikilibras.selectConfig(baseId, this);
  7 + wikilibras.selectAnOption(baseId, this);
8 8 dynworkflow.selectMovement($(this).attr("value"));
9 9 });
10 10 };
... ...
view/assets/js/orientation.js
... ... @@ -4,8 +4,8 @@
4 4 var baseId = ".selection-panel-body[mainConfig=right-hand][subConfig=orientacao][step=1]";
5 5 $(baseId + " .selection-panel-option").off("click").on(
6 6 "click", function() {
7   - wikilibras.selectConfig(baseId, this);
8   - dynworkflow.selectedConfig();
  7 + wikilibras.selectAnOption(baseId, this);
  8 + dynworkflow.userSelectedAnOption();
9 9 });
10 10 };
11 11  
... ...
view/assets/js/wikilibras.js
... ... @@ -186,8 +186,6 @@
186 186 }
187 187  
188 188 function _hideSelectionPanel() {
189   - _setupCurrentSubConfiguration(true, false);
190   -
191 189 var config = _getCurrentMainConfiguration();
192 190 _deselectIcon(config);
193 191 if (_isConfigurationComplete(config)) {
... ... @@ -225,148 +223,6 @@
225 223 $("#ready-button").addClass("disabled");
226 224 }
227 225 }
228   - ;
229   -
230   - // Subconfigurations
231   - function _getCurrentSubConfiguration() {
232   - var config = _getCurrentMainConfiguration();
233   - return $(
234   - "#" +
235   - config +
236   - "-subconfiguration-options .icon_container[select=true]")
237   - .attr("panel");
238   - }
239   -
240   - function _getNextSubConfiguration() {
241   - var config = _getCurrentMainConfiguration();
242   - return $(
243   - "#" +
244   - config +
245   - "-subconfiguration-options .icon_container[select=true]")
246   - .attr("next");
247   - }
248   -
249   - function _getPreviousSubConfiguration() {
250   - var config = _getCurrentMainConfiguration();
251   - return $(
252   - "#" +
253   - config +
254   - "-subconfiguration-options .icon_container[select=true]")
255   - .attr("previous");
256   - }
257   -
258   - function _setupCurrentSubConfiguration(onHide, onFinish) {
259   - var current_subconfig = _getCurrentSubConfiguration();
260   -
261   - if (!onHide) {
262   - _selectSubConfigurationIcon(current_subconfig, false);
263   - }
264   -
265   - // Add a check if the user finished a configuration
266   - if (onFinish && _hasSelectedAnOption(current_subconfig)) {
267   - _setupCheckSubConfigurationIcon(current_subconfig);
268   - }
269   -
270   - // Hide the current selection panel
271   - $("#" + current_subconfig).hide();
272   - }
273   -
274   - function _hasMultipleConfigurations(config) {
275   - return $("#" + config).is("[multiple-config]");
276   - }
277   -
278   - function _handleFingersPositionSubConfiguration(main_config) {
279   - var finger_group = $(
280   - "#" +
281   - main_config +
282   - "-fingers-position-1 .selection-panel-option[select=true]")
283   - .attr("group");
284   - $(".finger-group").hide();
285   - $(".finger-group[group=" + finger_group + "]").show();
286   - }
287   -
288   - function _setupMultipleConfiguration(config, selectEvent) {
289   - var sub_config_id = "#" + config + " [sub-config]";
290   - var has_active_config = $(sub_config_id).is(":visible");
291   -
292   - var main_config = _getCurrentMainConfiguration();
293   - var icon_name = _getSubConfigurationIconName(config);
294   - var icon_id = "#" + main_config +
295   - "-subconfiguration-options .icon_container[name=" + icon_name +
296   - "]";
297   - var sub_config = "";
298   -
299   - if (!has_active_config || !selectEvent) {
300   - sub_config = config + "-1";
301   - if (!$(icon_id).is("[tmp-next]")) {
302   - $(icon_id).attr("tmp-next", $(icon_id).attr("next"));
303   - $(icon_id).attr("next", config);
304   - }
305   - } else {
306   - sub_config = $(sub_config_id + ":visible").attr("next");
307   - }
308   - $(sub_config_id).hide();
309   -
310   - if (sub_config == "end") {
311   - var tmp_next = $(icon_id).attr("tmp-next");
312   - $(icon_id).removeAttr("tmp-next");
313   - $(icon_id).attr("next", tmp_next);
314   - config = tmp_next;
315   - if (_hasMultipleConfigurations(config)) {
316   - config = _setupMultipleConfiguration(config, selectEvent);
317   - }
318   - } else {
319   - if (sub_config.indexOf("fingers-position-2") != -1) {
320   - _handleFingersPositionSubConfiguration(main_config);
321   - }
322   - $("#" + sub_config).show();
323   - }
324   - return config;
325   - }
326   -
327   - function _getSubConfigurationIconName(subconfig) {
328   - subconfig = subconfig.replace("right-hand", "hand");
329   - subconfig = subconfig.replace("left-hand", "hand");
330   - return subconfig;
331   - }
332   -
333   - function _selectSubConfigurationIcon(subconfig, isSelect) {
334   - var iconName = _getSubConfigurationIconName(subconfig);
335   - _selectIcon(iconName, isSelect, subconfig);
336   - }
337   -
338   - function _setupCheckSubConfigurationIcon(subconfig) {
339   - var iconName = _getSubConfigurationIconName(subconfig);
340   - _setupCheckIcon(iconName, true, subconfig);
341   - }
342   -
343   - function _showSubConfiguration(next_config, selectEvent) {
344   - var current_config = _getCurrentSubConfiguration();
345   - var next_has_multiple_config = _hasMultipleConfigurations(next_config);
346   -
347   - if (current_config == next_config && !next_has_multiple_config)
348   - return;
349   -
350   - var onFinish = true;
351   - if (next_has_multiple_config) {
352   - next_config = _setupMultipleConfiguration(next_config, selectEvent);
353   - onFinish = next_config != current_config;
354   - }
355   -
356   - _setupCurrentSubConfiguration(false, onFinish);
357   -
358   - if (next_config != "end") {
359   - _selectSubConfigurationIcon(next_config, true);
360   - $("#" + next_config).show();
361   -
362   - var main_config = _getCurrentMainConfiguration();
363   - if (_isHandMovimentComplete(main_config)) {
364   - $(".subconfiguration-panel").fadeIn(300);
365   - }
366   - } else {
367   - _hideSelectionPanel();
368   - }
369   - }
370 226  
371 227 function _setupGUIOnSelection(option) {
372 228 $("#ready-button").fadeOut(300);
... ... @@ -497,7 +353,7 @@
497 353 return $(el).attr("value");
498 354 }
499 355  
500   - function _selectConfig(parentId, el) {
  356 + function _selectAnOption(parentId, el) {
501 357 $(parentId + " .selection-panel-option[select=true]")
502 358 .removeAttr("select");
503 359 $(el).attr("select", true);
... ... @@ -510,17 +366,6 @@
510 366 $("#selection-panel .x").off("click").on("click", function() {
511 367 _hideSelectionPanel();
512 368 });
513   - // $(".selection-panel-body .selection-panel-option").off("click").on(
514   - // "click", function() {
515   - // _selectConfig(this);
516   - // var next = _getNextSubConfiguration();
517   - // _showSubConfiguration(next, true);
518   - // });
519   - // $(".subconfiguration-options .icon_container").off("click").on("click",
520   - // function() {
521   - // var subconfig = $(this).attr("panel");
522   - // _showSubConfiguration(subconfig, false);
523   - // });
524 369 // $(".arrow[name=right-arrow]").off("click").on("click", function() {
525 370 // var next = _getNextSubConfiguration();
526 371 // _showSubConfiguration(next, false);
... ... @@ -683,8 +528,8 @@
683 528 _hideSelectionPanel();
684 529 }
685 530  
686   - wikilibras.selectConfig = function(parentId, el) {
687   - _selectConfig(parentId, el);
  531 + wikilibras.selectAnOption = function(parentId, el) {
  532 + _selectAnOption(parentId, el);
688 533 }
689 534  
690 535 wikilibras.enableIconHover = function(container, isHover) {
... ...