Commit 1aab214c66cc9bfb98f2fcfdef5cb7ac602447f5
1 parent
06f9fbc3
Exists in
master
and in
1 other branch
Correção de bug na timeline.
Showing
4 changed files
with
379 additions
and
340 deletions
Show diff stats
view/assets/js/dynamic-selection-workflow.js
1 | 1 | (function(dynworkflow, $, undefined) { |
2 | 2 | |
3 | - // Workflow configuration | |
4 | - var jsonWF = {}; | |
5 | - var baseUrl = ''; | |
6 | - | |
7 | - // Main configurations: right-hand, left-hand and facial | |
8 | - var mainConfig = ''; | |
9 | - // The converted Main Config (right/left-hand) to hand for using the same configuration | |
10 | - var preprocessedMainConfig = ''; | |
11 | - // Subconfigurations: movimento, articulacao, configuracao, orientacao, etc | |
12 | - var currentSubconfig = ''; | |
13 | - var currentSubConfigName = ''; | |
14 | - var currentSubconfigParent = ''; | |
15 | - var currentStep = 0; | |
16 | - | |
17 | - function _preprocessMainConfig(config) { | |
18 | - config = config.replace('right-hand', 'hand'); | |
19 | - config = config.replace('left-hand', 'hand'); | |
20 | - return config; | |
21 | - } | |
22 | - | |
23 | - function _getFirstKey(json) { | |
24 | - var first_key = undefined; | |
25 | - for (first_key in json) break; | |
26 | - return first_key; | |
27 | - } | |
28 | - | |
29 | - function _getAttributes(json) { | |
30 | - var result = []; | |
31 | - for (attr in json) { | |
32 | - result.push(attr); | |
33 | - } | |
34 | - return result; | |
35 | - } | |
36 | - | |
37 | - function _updateAndGetFirstMovementSubConfig() { | |
38 | - var selectedMovement = movement.getPreviousSelectedMovement(mainConfig); | |
39 | - if (typeof selectedMovement == 'undefined') return -1; | |
40 | - | |
41 | - currentSubconfigParent = jsonWF[preprocessedMainConfig]['movimento'][selectedMovement]; | |
42 | - currentSubConfigName = _getFirstKey(currentSubconfigParent); | |
43 | - return currentSubConfigName; | |
44 | - } | |
45 | - | |
46 | - function _updateAndGetMovementConfig() { | |
47 | - currentSubconfigParent = jsonWF[preprocessedMainConfig]; | |
48 | - currentSubConfigName = _getFirstKey(currentSubconfigParent); | |
49 | - return currentSubConfigName; | |
50 | - } | |
51 | - | |
52 | - function _getNextSubConfig(toForward) { | |
53 | - var attrs = _getAttributes(currentSubconfigParent); | |
54 | - for (var i = 0; i < attrs.length; i++) { | |
55 | - if (toForward && attrs[i] == currentSubConfigName && i < attrs.length - 1) { | |
56 | - return attrs[i + 1]; | |
57 | - } else if (!toForward && attrs[i] == currentSubConfigName && i >= 1) { | |
58 | - return attrs[i - 1]; | |
59 | - } | |
60 | - } | |
61 | - if (toForward && currentSubConfigName == 'movimento') { | |
62 | - return _updateAndGetFirstMovementSubConfig(); | |
63 | - } else if (!toForward && preprocessedMainConfig == 'hand') { | |
64 | - return _updateAndGetMovementConfig(); | |
65 | - } else if (!toForward) { | |
66 | - return currentSubConfigName; | |
67 | - } else { | |
68 | - return -1; | |
69 | - } | |
70 | - } | |
71 | - | |
72 | - function _showCurrentSubconfig() { | |
73 | - _showSubconfiguration(mainConfig, currentSubConfigName, currentStep); | |
74 | - } | |
75 | - | |
76 | - // It checks if a selection panel is already loaded | |
77 | - function _isSubconfigurationPanelLoaded(mainConfig, subConfig, stepNumber) { | |
78 | - var stepNumber = stepNumber + 1; | |
79 | - return $('.selection-panel-body[mainConfig=' + mainConfig + '][subConfig=' + subConfig + | |
80 | - '][step=' + stepNumber + ']').length > 0; | |
81 | - } | |
82 | - | |
83 | - function _showLoadedSubconfigurationPanel(mainConfig, subConfig, stepNumber) { | |
84 | - var stepNumber = stepNumber + 1; | |
85 | - return $('.selection-panel-body[mainConfig=' + mainConfig + '][subConfig=' + subConfig + | |
86 | - '][step=' + stepNumber + ']').show(); | |
87 | - } | |
88 | - | |
89 | - // It renders or shows the requested selection panel | |
90 | - function _showSubconfiguration(mainConfig, subConfig, stepNumber) { | |
91 | - $('.selection-panel-body').hide(); | |
92 | - if (_isSubconfigurationPanelLoaded(mainConfig, subConfig, stepNumber)) { | |
93 | - _showLoadedSubconfigurationPanel(mainConfig, subConfig, stepNumber); | |
94 | - } else { | |
95 | - var step = currentSubconfig[stepNumber]; | |
96 | - step = typeof step == 'undefined' ? 'passo-1' : step; | |
97 | - dynengine.render(baseUrl, '/' + preprocessedMainConfig + '/' + subConfig + | |
98 | - '/' + step + '.html', '#selection-panel', true); | |
99 | - } | |
100 | - _selectTimelineIcon(mainConfig, subConfig, true); | |
101 | - } | |
102 | - | |
103 | - function _selectSubConfig(subConfig) { | |
104 | - if (subConfig == 'movimento') { | |
105 | - _updateAndGetMovementConfig(); | |
106 | - } else if (currentSubConfigName == 'movimento') { | |
107 | - _updateAndGetFirstMovementSubConfig(); | |
108 | - } | |
109 | - currentSubConfigName = subConfig; | |
110 | - currentSubconfig = currentSubconfigParent[currentSubConfigName]; | |
111 | - currentStep = 0; | |
112 | - _showCurrentSubconfig(); | |
113 | - } | |
114 | - | |
115 | - // It shows the next selection panel on the workflow | |
116 | - function _showNextSubConfig() { | |
117 | - _walkOnTheWorkflow(true); | |
118 | - } | |
119 | - | |
120 | - function _showPreviousSubConfig() { | |
121 | - _walkOnTheWorkflow(false); | |
122 | - } | |
123 | - | |
124 | - function _walkOnTheWorkflow(toForward) { | |
125 | - currentStep = toForward ? currentStep + 1 : currentStep - 1; | |
126 | - | |
127 | - if (currentStep >= 0 && currentStep < currentSubconfig.length) { | |
128 | - _showCurrentSubconfig(); | |
129 | - } else { | |
130 | - var nextSubConfig = _getNextSubConfig(toForward); | |
131 | - if (nextSubConfig != -1) { | |
132 | - _selectSubConfig(nextSubConfig); | |
133 | - } else { | |
134 | - wikilibras.hideSelectionPanel(); | |
135 | - } | |
136 | - } | |
137 | - } | |
138 | - | |
139 | - function _checkIfFinished(mainConfig, currentSubConfigName) { | |
140 | - var numberOfSteps = currentSubconfig.length; | |
141 | - var completedSteps = $('.selection-panel-body[mainConfig=' + mainConfig + | |
142 | - '][subConfig=' + currentSubConfigName + '] .selection-panel-option[select=true]').length; | |
143 | - return completedSteps != 0 && completedSteps == numberOfSteps; | |
144 | - } | |
145 | - | |
146 | - // A callback function to be called when the user selects a option on a panel | |
147 | - function _userSelectedAnOption() { | |
148 | - if (_checkIfFinished(mainConfig, currentSubConfigName)) { | |
149 | - _setupCheckIcon(mainConfig, currentSubConfigName); | |
150 | - } | |
151 | - _showNextSubConfig(); | |
152 | - } | |
153 | - | |
154 | - function _cleanStep(mainConfig, subConfig, step) { | |
155 | - var baseId = '.selection-panel-body[mainConfig=' + mainConfig + '][subConfig=' + | |
156 | - subConfig + '][step=' + step + ']'; | |
157 | - $(baseId + ' .selection-panel-option').removeAttr('select'); | |
158 | - var icon_id = '.subconfiguration-panel[mainConfig=' + mainConfig + | |
159 | - '] .icon_container[json_name=' + subConfig + ']'; | |
160 | - $(icon_id).removeAttr('complete'); | |
161 | - } | |
162 | - | |
163 | - // Timeline functions | |
164 | - function _selectTimelineIcon(mainConfig, subConfig) { | |
165 | - var baseId = '.subconfiguration-panel[mainConfig=' + mainConfig + '] .subconfiguration-options'; | |
166 | - var iconContainer = '.icon_container[json_name=' + subConfig + ']'; | |
167 | - var iconId = baseId + ' ' + iconContainer; | |
168 | - | |
169 | - var previousSelected = $(baseId + ' .icon_container[select=true]').attr('json_name'); | |
170 | - if (typeof previousSelected != 'undefined') { | |
171 | - _deselectTimelineIcon(mainConfig, previousSelected); | |
172 | - } | |
173 | - | |
174 | - wikilibras.enableIconHover($(iconId), true); | |
175 | - $(iconId).attr('select', true); | |
176 | - // scrollTo icon | |
177 | - $(baseId).scrollTo(iconContainer, {'offset': -60, 'duration': 750}); | |
178 | - } | |
179 | - | |
180 | - function _deselectTimelineIcon(mainConfig, subConfig) { | |
181 | - var icon_id = '.subconfiguration-panel[mainConfig=' + mainConfig + | |
182 | - '] .icon_container[json_name=' + subConfig + ']'; | |
183 | - | |
184 | - if ($(icon_id + '[complete=true]').length > 0) { | |
185 | - _setupCheckIcon(mainConfig, subConfig); | |
186 | - } else { | |
187 | - wikilibras.enableIconHover($(icon_id), false); | |
188 | - $(icon_id).attr('select', false); | |
189 | - } | |
190 | - } | |
191 | - | |
192 | - function _setupCheckIcon(mainConfig, subConfig) { | |
193 | - var icon_id = $('.subconfiguration-panel[mainConfig=' + mainConfig + | |
194 | - '] .icon_container[json_name=' + subConfig + ']'); | |
195 | - wikilibras.enableIconCheck(icon_id, true); | |
196 | - $(icon_id).attr('complete', true); | |
197 | - $(icon_id).attr('select', false); | |
198 | - } | |
199 | - | |
200 | - function _isTimelineLoaded() { | |
201 | - return $('.subconfiguration-panel[mainConfig=' + mainConfig + ']').length > 0; | |
202 | - } | |
203 | - | |
204 | - function _setupTimelineListeners(timelineBaseId) { | |
205 | - $(timelineBaseId + ' .icon_container[json_name]').off('click').on('click', | |
206 | - function() { | |
207 | - var subConfig = $(this).attr('json_name'); | |
208 | - _selectSubConfig(subConfig); | |
209 | - }); | |
210 | - | |
211 | - $(timelineBaseId + ' .arrow[name=right-arrow]').off('click').on('click', function() { | |
212 | - _showNextSubConfig(); | |
213 | - }); | |
214 | - | |
215 | - $(timelineBaseId + ' .arrow[name=left-arrow]').off('click').on('click', function() { | |
216 | - _showPreviousSubConfig(); | |
217 | - }); | |
218 | - } | |
219 | - | |
220 | - function _setupTimelineIcons(timelineBaseId, toUpdate) { | |
221 | - if (!toUpdate) { | |
222 | - $(timelineBaseId).show(); | |
223 | - $(timelineBaseId + " .subconfiguration-options").scrollTo(0, 0); | |
224 | - return; | |
3 | + // Workflow configuration | |
4 | + var jsonWF = {}; | |
5 | + var baseUrl = ''; | |
6 | + | |
7 | + // Main configurations: right-hand, left-hand and facial | |
8 | + var mainConfig = ''; | |
9 | + // The converted Main Config (right/left-hand) to hand for using the same configuration | |
10 | + var preprocessedMainConfig = ''; | |
11 | + // Subconfigurations: movimento, articulacao, configuracao, orientacao, etc | |
12 | + var currentSubconfig = ''; | |
13 | + var currentSubConfigName = ''; | |
14 | + var currentSubconfigParent = ''; | |
15 | + var currentStep = 0; | |
16 | + | |
17 | + function _preprocessMainConfig(config) { | |
18 | + config = config.replace('right-hand', 'hand'); | |
19 | + config = config.replace('left-hand', 'hand'); | |
20 | + return config; | |
225 | 21 | } |
22 | + | |
23 | + function _getFirstKey(json) { | |
24 | + var first_key = undefined; | |
25 | + for (first_key in json) | |
26 | + break; | |
27 | + return first_key; | |
28 | + } | |
29 | + | |
30 | + function _getAttributes(json) { | |
31 | + var result = []; | |
32 | + for (attr in json) { | |
33 | + result.push(attr); | |
34 | + } | |
35 | + return result; | |
36 | + } | |
37 | + | |
38 | + function _updateAndGetFirstMovementSubConfig() { | |
39 | + var selectedMovement = movement.getPreviousSelectedMovement(mainConfig); | |
40 | + if (typeof selectedMovement == 'undefined') | |
41 | + return -1; | |
42 | + | |
43 | + currentSubconfigParent = jsonWF[preprocessedMainConfig]['movimento'][selectedMovement]; | |
44 | + currentSubConfigName = _getFirstKey(currentSubconfigParent); | |
45 | + return currentSubConfigName; | |
46 | + } | |
47 | + | |
48 | + function _updateAndGetMovementConfig() { | |
49 | + currentSubconfigParent = jsonWF[preprocessedMainConfig]; | |
50 | + currentSubConfigName = _getFirstKey(currentSubconfigParent); | |
51 | + return currentSubConfigName; | |
52 | + } | |
53 | + | |
54 | + function _getNextSubConfig(toForward) { | |
55 | + var attrs = _getAttributes(currentSubconfigParent); | |
56 | + for (var i = 0; i < attrs.length; i++) { | |
57 | + if (toForward && attrs[i] == currentSubConfigName | |
58 | + && i < attrs.length - 1) { | |
59 | + return attrs[i + 1]; | |
60 | + } else if (!toForward && attrs[i] == currentSubConfigName && i >= 1) { | |
61 | + return attrs[i - 1]; | |
62 | + } | |
63 | + } | |
64 | + if (toForward && currentSubConfigName == 'movimento') { | |
65 | + return _updateAndGetFirstMovementSubConfig(); | |
66 | + } else if (!toForward && preprocessedMainConfig == 'hand') { | |
67 | + return _updateAndGetMovementConfig(); | |
68 | + } else if (!toForward) { | |
69 | + return currentSubConfigName; | |
70 | + } else { | |
71 | + return -1; | |
72 | + } | |
73 | + } | |
74 | + | |
75 | + function _showCurrentSubconfig() { | |
76 | + _showSubconfiguration(mainConfig, currentSubConfigName, currentStep); | |
77 | + } | |
78 | + | |
79 | + // It checks if a selection panel is already loaded | |
80 | + function _isSubconfigurationPanelLoaded(mainConfig, subConfig, stepNumber) { | |
81 | + var stepNumber = stepNumber + 1; | |
82 | + return $('.selection-panel-body[mainConfig=' + mainConfig | |
83 | + + '][subConfig=' + subConfig + '][step=' + stepNumber + ']').length > 0; | |
84 | + } | |
85 | + | |
86 | + function _showLoadedSubconfigurationPanel(mainConfig, subConfig, stepNumber) { | |
87 | + var stepNumber = stepNumber + 1; | |
88 | + return $( | |
89 | + '.selection-panel-body[mainConfig=' + mainConfig | |
90 | + + '][subConfig=' + subConfig + '][step=' + stepNumber | |
91 | + + ']').show(); | |
92 | + } | |
93 | + | |
94 | + // It renders or shows the requested selection panel | |
95 | + function _showSubconfiguration(mainConfig, subConfig, stepNumber) { | |
96 | + $('.selection-panel-body').hide(); | |
97 | + if (_isSubconfigurationPanelLoaded(mainConfig, subConfig, stepNumber)) { | |
98 | + _showLoadedSubconfigurationPanel(mainConfig, subConfig, stepNumber); | |
99 | + } else { | |
100 | + var step = currentSubconfig[stepNumber]; | |
101 | + step = typeof step == 'undefined' ? 'passo-1' : step; | |
102 | + dynengine.render(baseUrl, '/' + preprocessedMainConfig + '/' | |
103 | + + subConfig + '/' + step + '.html', '#selection-panel', | |
104 | + true); | |
105 | + } | |
106 | + _selectTimelineIcon(mainConfig, subConfig, true); | |
107 | + } | |
108 | + | |
109 | + function _selectSubConfig(subConfig) { | |
110 | + if (subConfig == 'movimento') { | |
111 | + _updateAndGetMovementConfig(); | |
112 | + } else if (currentSubConfigName == 'movimento') { | |
113 | + _updateAndGetFirstMovementSubConfig(); | |
114 | + } | |
115 | + currentSubConfigName = subConfig; | |
116 | + currentSubconfig = currentSubconfigParent[currentSubConfigName]; | |
117 | + currentStep = 0; | |
118 | + _showCurrentSubconfig(); | |
119 | + } | |
120 | + | |
121 | + // It shows the next selection panel on the workflow | |
122 | + function _showNextSubConfig() { | |
123 | + _walkOnTheWorkflow(true); | |
124 | + } | |
125 | + | |
126 | + function _showPreviousSubConfig() { | |
127 | + _walkOnTheWorkflow(false); | |
128 | + } | |
129 | + | |
130 | + function _walkOnTheWorkflow(toForward) { | |
131 | + currentStep = toForward ? currentStep + 1 : currentStep - 1; | |
132 | + | |
133 | + if (currentStep >= 0 && currentStep < currentSubconfig.length) { | |
134 | + _showCurrentSubconfig(); | |
135 | + } else { | |
136 | + var nextSubConfig = _getNextSubConfig(toForward); | |
137 | + if (nextSubConfig != -1) { | |
138 | + _selectSubConfig(nextSubConfig); | |
139 | + } else { | |
140 | + wikilibras.hideSelectionPanel(); | |
141 | + } | |
142 | + } | |
143 | + } | |
144 | + | |
145 | + function _checkIfFinished(mainConfig, currentSubConfigName) { | |
146 | + var numberOfSteps = currentSubconfig.length; | |
147 | + var completedSteps = $('.selection-panel-body[mainConfig=' + mainConfig | |
148 | + + '][subConfig=' + currentSubConfigName | |
149 | + + '] .selection-panel-option[select=true]').length; | |
150 | + return completedSteps != 0 && completedSteps == numberOfSteps; | |
151 | + } | |
152 | + | |
153 | + // A callback function to be called when the user selects a option on a panel | |
154 | + function _userSelectedAnOption() { | |
155 | + if (_checkIfFinished(mainConfig, currentSubConfigName)) { | |
156 | + _setupCheckIcon(mainConfig, currentSubConfigName); | |
157 | + } | |
158 | + _showNextSubConfig(); | |
159 | + } | |
160 | + | |
161 | + function _cleanStep(mainConfig, subConfig, step) { | |
162 | + var baseId = '.selection-panel-body[mainConfig=' + mainConfig | |
163 | + + '][subConfig=' + subConfig + '][step=' + step + ']'; | |
164 | + $(baseId + ' .selection-panel-option').removeAttr('select'); | |
165 | + var icon_id = '.subconfiguration-panel[mainConfig=' + mainConfig | |
166 | + + '] .icon_container[json_name=' + subConfig + ']'; | |
167 | + $(icon_id).removeAttr('complete'); | |
168 | + } | |
169 | + | |
170 | + // Timeline functions | |
171 | + function _selectTimelineIcon(mainConfig, subConfig) { | |
172 | + var baseId = '.subconfiguration-panel[mainConfig=' + mainConfig | |
173 | + + '] .subconfiguration-options'; | |
174 | + var iconContainer = '.icon_container[json_name=' + subConfig + ']'; | |
175 | + var iconId = baseId + ' ' + iconContainer; | |
176 | + | |
177 | + var previousSelected = $(baseId + ' .icon_container[select=true]') | |
178 | + .attr('json_name'); | |
179 | + if (typeof previousSelected != 'undefined') { | |
180 | + _deselectTimelineIcon(mainConfig, previousSelected); | |
181 | + } | |
182 | + | |
183 | + wikilibras.enableIconHover($(iconId), true); | |
184 | + $(iconId).attr('select', true); | |
185 | + $(baseId).scrollTo(iconContainer, { | |
186 | + 'offset' : -60, | |
187 | + 'duration' : 750 | |
188 | + }); | |
189 | + } | |
190 | + | |
191 | + function _deselectTimelineIcon(mainConfig, subConfig) { | |
192 | + var icon_id = '.subconfiguration-panel[mainConfig=' + mainConfig | |
193 | + + '] .icon_container[json_name=' + subConfig + ']'; | |
194 | + | |
195 | + if ($(icon_id + '[complete=true]').length > 0) { | |
196 | + _setupCheckIcon(mainConfig, subConfig); | |
197 | + } else { | |
198 | + wikilibras.enableIconHover($(icon_id), false); | |
199 | + $(icon_id).removeAttr('select'); | |
200 | + } | |
201 | + } | |
202 | + | |
203 | + function _setupCheckIcon(mainConfig, subConfig) { | |
204 | + var icon_id = $('.subconfiguration-panel[mainConfig=' + mainConfig | |
205 | + + '] .icon_container[json_name=' + subConfig + ']'); | |
206 | + wikilibras.enableIconCheck(icon_id, true); | |
207 | + $(icon_id).attr('complete', true); | |
208 | + $(icon_id).attr('select', false); | |
209 | + } | |
210 | + | |
211 | + function _isTimelineLoaded() { | |
212 | + return $('.subconfiguration-panel[mainConfig=' + mainConfig + ']').length > 0; | |
213 | + } | |
214 | + | |
215 | + function _setupTimelineListeners(timelineBaseId) { | |
216 | + $(timelineBaseId + ' .icon_container[json_name]').off('click').on( | |
217 | + 'click', function() { | |
218 | + var subConfig = $(this).attr('json_name'); | |
219 | + _selectSubConfig(subConfig); | |
220 | + }); | |
221 | + $(timelineBaseId + ' .icon_container[json_name]').off('mouseover').on( | |
222 | + 'mouseover', function() { | |
223 | + if (wikilibras.canHover(this)) { | |
224 | + wikilibras.enableIconHover(this, true); | |
225 | + } | |
226 | + }); | |
227 | + $(timelineBaseId + ' .icon_container[json_name]').off('mouseout').on( | |
228 | + 'mouseout', function() { | |
229 | + if (wikilibras.canHover(this)) { | |
230 | + wikilibras.enableIconHover(this, false); | |
231 | + } | |
232 | + }); | |
233 | + $(timelineBaseId + ' .arrow[name=right-arrow]').off('click').on( | |
234 | + 'click', function() { | |
235 | + _showNextSubConfig(); | |
236 | + }); | |
237 | + $(timelineBaseId + ' .arrow[name=left-arrow]').off('click').on('click', | |
238 | + function() { | |
239 | + _showPreviousSubConfig(); | |
240 | + }); | |
241 | + } | |
242 | + | |
243 | + function _setupTimelineIcons(timelineBaseId, toUpdate) { | |
244 | + if (!toUpdate) { | |
245 | + $(timelineBaseId).show(); | |
246 | + $(timelineBaseId + " .subconfiguration-options").scrollTo(0, 0); | |
247 | + return; | |
248 | + } | |
249 | + | |
250 | + $(timelineBaseId + ' .icon_container[json_name]').attr("active", | |
251 | + "false"); | |
252 | + for ( var name in currentSubconfigParent) { | |
253 | + $(timelineBaseId + ' .icon_container[json_name=' + name + ']') | |
254 | + .attr("active", "true"); | |
255 | + } | |
256 | + | |
257 | + if (preprocessedMainConfig == 'hand') { | |
258 | + $(timelineBaseId + ' .icon_container[json_name=movimento]').attr( | |
259 | + "active", "true"); | |
260 | + _setupCheckIcon(mainConfig, 'movimento'); | |
261 | + } | |
262 | + _selectTimelineIcon(mainConfig, currentSubConfigName); | |
263 | + _setupTimelineListeners(timelineBaseId); | |
264 | + $(timelineBaseId).show(); | |
265 | + } | |
266 | + | |
267 | + function _setupTimeline(toUpdate) { | |
268 | + var timelineBaseId = '.subconfiguration-panel[mainConfig=' + mainConfig | |
269 | + + ']'; | |
270 | + if (_isTimelineLoaded()) { | |
271 | + _setupTimelineIcons(timelineBaseId, toUpdate); | |
272 | + } else { | |
273 | + dynengine.render(baseUrl, '/' + preprocessedMainConfig | |
274 | + + '/timeline.html', '#selection-panel', false, function() { | |
275 | + _setupTimelineIcons(timelineBaseId, true); | |
276 | + }); | |
277 | + } | |
278 | + } | |
279 | + | |
280 | + function _initTimeline() { | |
281 | + if (preprocessedMainConfig != 'hand' || _isTimelineLoaded()) { | |
282 | + _setupTimeline(false); | |
283 | + } | |
284 | + } | |
285 | + | |
286 | + function _cleanTimeline() { | |
287 | + $(".subconfiguration-panel").remove(); | |
288 | + } | |
289 | + | |
290 | + function _cleanPreviousLoadedPanel() { | |
291 | + $('.selection-panel-body[mainConfig=' + mainConfig + ']').each( | |
292 | + function() { | |
293 | + var subConfigName = $(this).attr("subConfig"); | |
294 | + if (subConfigName.indexOf("articulacao") != -1 | |
295 | + || subConfigName.indexOf("configuracao") != -1 | |
296 | + || subConfigName.indexOf("orientacao") != -1 | |
297 | + || subConfigName.indexOf("movimento") != -1) { | |
298 | + return; | |
299 | + } | |
300 | + $( | |
301 | + '.selection-panel-body[mainConfig=' + mainConfig | |
302 | + + '][subConfig=' + subConfigName + ']') | |
303 | + .remove(); | |
304 | + }); | |
305 | + } | |
306 | + | |
307 | + // Public methods | |
308 | + dynworkflow.selectMainConfig = function(config) { | |
309 | + mainConfig = config; | |
310 | + preprocessedMainConfig = _preprocessMainConfig(mainConfig); | |
311 | + currentSubconfigParent = jsonWF[preprocessedMainConfig]; | |
312 | + currentSubConfigName = _getFirstKey(currentSubconfigParent); | |
313 | + currentSubconfig = currentSubconfigParent[currentSubConfigName]; | |
314 | + currentStep = 0; | |
315 | + | |
316 | + _showCurrentSubconfig(); | |
317 | + }; | |
318 | + | |
319 | + dynworkflow.selectMovement = function(movement) { | |
320 | + var subconfigJSON = currentSubconfig[movement]; | |
321 | + currentSubConfigName = _getFirstKey(subconfigJSON); | |
322 | + currentSubconfigParent = subconfigJSON; | |
323 | + currentSubconfig = subconfigJSON[currentSubConfigName]; | |
324 | + currentStep = 0; | |
325 | + | |
326 | + _cleanPreviousLoadedPanel(); | |
327 | + _showCurrentSubconfig(); | |
328 | + _setupTimeline(true); | |
329 | + }; | |
330 | + | |
331 | + dynworkflow.selectSubConfig = function(subConfig) { | |
332 | + _selectSubConfig(subConfig); | |
333 | + }; | |
334 | + | |
335 | + dynworkflow.userSelectedAnOption = function() { | |
336 | + _userSelectedAnOption(); | |
337 | + }; | |
338 | + | |
339 | + dynworkflow.cleanStep = function(mainConfig, subConfig, step) { | |
340 | + _cleanStep(mainConfig, subConfig, step); | |
341 | + }; | |
342 | + | |
343 | + dynworkflow.getFacialParameters = function() { | |
344 | + return _getAttributes(jsonWF['facial']); | |
345 | + }; | |
346 | + | |
347 | + dynworkflow.getMovementParameters = function(movementName) { | |
348 | + return _getAttributes(jsonWF['hand']['movimento'][movementName]); | |
349 | + }; | |
350 | + | |
351 | + dynworkflow.getMainConfig = function() { | |
352 | + return mainConfig; | |
353 | + }; | |
354 | + | |
355 | + dynworkflow.initTimeline = function() { | |
356 | + _initTimeline(); | |
357 | + }; | |
226 | 358 | |
227 | - $(timelineBaseId + ' .icon_container[json_name]').attr("active", "false"); | |
228 | - for (var name in currentSubconfigParent) { | |
229 | - $(timelineBaseId + ' .icon_container[json_name=' + name + ']').attr("active", "true"); | |
230 | - } | |
231 | - | |
232 | - if (preprocessedMainConfig == 'hand') { | |
233 | - $(timelineBaseId + ' .icon_container[json_name=movimento]').attr("active", "true"); | |
234 | - _setupCheckIcon(mainConfig, 'movimento'); | |
235 | - } | |
236 | - _selectTimelineIcon(mainConfig, currentSubConfigName); | |
237 | - _setupTimelineListeners(timelineBaseId); | |
238 | - $(timelineBaseId).show(); | |
239 | - } | |
240 | - | |
241 | - function _setupTimeline(toUpdate) { | |
242 | - var timelineBaseId = '.subconfiguration-panel[mainConfig=' + mainConfig + ']'; | |
243 | - if (_isTimelineLoaded()) { | |
244 | - _setupTimelineIcons(timelineBaseId, toUpdate); | |
245 | - } else { | |
246 | - dynengine.render(baseUrl, '/' + preprocessedMainConfig + | |
247 | - '/timeline.html', '#selection-panel', false, function() { | |
248 | - _setupTimelineIcons(timelineBaseId, true); | |
249 | - }); | |
250 | - } | |
251 | - } | |
252 | - | |
253 | - // Public methods | |
254 | - dynworkflow.selectMainConfig = function(config) { | |
255 | - mainConfig = config; | |
256 | - preprocessedMainConfig = _preprocessMainConfig(mainConfig); | |
257 | - currentSubconfigParent = jsonWF[preprocessedMainConfig]; | |
258 | - currentSubConfigName = _getFirstKey(currentSubconfigParent); | |
259 | - currentSubconfig = currentSubconfigParent[currentSubConfigName]; | |
260 | - currentStep = 0; | |
261 | - | |
262 | - _showCurrentSubconfig(); | |
263 | - }; | |
264 | - | |
265 | - dynworkflow.finishMainConfigSetup = function(subConfig) { | |
266 | - // hide the timeline on the first subconfiguration for "hand" | |
267 | - if (preprocessedMainConfig != 'hand' || _isTimelineLoaded()) { | |
268 | - _setupTimeline(false); | |
269 | - } | |
270 | - }; | |
271 | - | |
272 | - function _cleanPreviousLoadedPanel() { | |
273 | - $('.selection-panel-body[mainConfig=' + mainConfig + ']').each(function() { | |
274 | - var subConfigName = $(this).attr("subConfig"); | |
275 | - if (subConfigName.indexOf("articulacao") != -1 || | |
276 | - subConfigName.indexOf("configuracao") != -1 || | |
277 | - subConfigName.indexOf("orientacao") != -1 || | |
278 | - subConfigName.indexOf("movimento") != -1) { | |
279 | - return; | |
280 | - } | |
281 | - $('.selection-panel-body[mainConfig=' + mainConfig + '][subConfig=' + | |
282 | - subConfigName + ']').remove(); | |
283 | - }); | |
284 | - } | |
285 | - | |
286 | - dynworkflow.selectMovement = function(movement) { | |
287 | - var subconfigJSON = currentSubconfig[movement]; | |
288 | - currentSubConfigName = _getFirstKey(subconfigJSON); | |
289 | - currentSubconfigParent = subconfigJSON; | |
290 | - currentSubconfig = subconfigJSON[currentSubConfigName]; | |
291 | - currentStep = 0; | |
292 | - | |
293 | - _cleanPreviousLoadedPanel(); | |
294 | - _showCurrentSubconfig(); | |
295 | - _setupTimeline(true); | |
296 | - }; | |
297 | - | |
298 | - dynworkflow.selectSubConfig = function(subConfig) { | |
299 | - _selectSubConfig(subConfig); | |
300 | - }; | |
301 | - | |
302 | - dynworkflow.userSelectedAnOption = function() { | |
303 | - _userSelectedAnOption(); | |
304 | - }; | |
305 | - | |
306 | - dynworkflow.cleanStep = function(mainConfig, subConfig, step) { | |
307 | - _cleanStep(mainConfig, subConfig, step); | |
308 | - }; | |
309 | - | |
310 | - dynworkflow.getFacialParameters = function() { | |
311 | - return _getAttributes(jsonWF['facial']); | |
312 | - }; | |
313 | - | |
314 | - dynworkflow.getMovementParameters = function(movementName) { | |
315 | - return _getAttributes(jsonWF['hand']['movimento'][movementName]); | |
316 | - }; | |
317 | - | |
318 | - dynworkflow.getMainConfig = function() { | |
319 | - return mainConfig; | |
320 | - }; | |
321 | - | |
322 | - dynworkflow.load = function() { | |
323 | - baseUrl = $('#server-url').data('url'); | |
324 | - $.get(baseUrl + '/conf/selection-workflow-json', function(result) { | |
325 | - jsonWF = $.parseJSON(result); | |
326 | - }).fail(function() { | |
327 | - console.log('Failed to load the workflow configuration'); | |
328 | - }); | |
329 | - }; | |
359 | + dynworkflow.load = function() { | |
360 | + baseUrl = $('#server-url').data('url'); | |
361 | + $.get(baseUrl + '/conf/selection-workflow-json', function(result) { | |
362 | + jsonWF = $.parseJSON(result); | |
363 | + }).fail(function() { | |
364 | + console.log('Failed to load the workflow configuration'); | |
365 | + }); | |
366 | + _cleanTimeline(); | |
367 | + }; | |
330 | 368 | |
331 | 369 | }(window.dynworkflow = window.dynworkflow || {}, jQuery)); | ... | ... |
view/assets/js/teached-signs.js
... | ... | @@ -70,7 +70,6 @@ |
70 | 70 | $('#teached-sign-name').html(signName); |
71 | 71 | $('#teached-sign-modal').modal('show'); |
72 | 72 | }); |
73 | - | |
74 | 73 | } |
75 | 74 | |
76 | 75 | function _updateTeachedSignsContainer() { |
... | ... | @@ -81,7 +80,6 @@ |
81 | 80 | |
82 | 81 | teachedSigns.setup = function() { |
83 | 82 | _getProjectId().done(function(response) { |
84 | - console.log(response); | |
85 | 83 | if (typeof response == "undefined" || response.length < 1) { |
86 | 84 | return; |
87 | 85 | } | ... | ... |
view/assets/js/wikilibras.js
... | ... | @@ -168,10 +168,10 @@ |
168 | 168 | function _showSelectionPanel(option) { |
169 | 169 | _clearPreviousSelection(); |
170 | 170 | _selectIcon(option, true); |
171 | + dynworkflow.selectMainConfig(option); | |
171 | 172 | _setupGUIOnSelection(option, function() { |
172 | - dynworkflow.finishMainConfigSetup(option); | |
173 | + dynworkflow.initTimeline(); | |
173 | 174 | }); |
174 | - dynworkflow.selectMainConfig(option); | |
175 | 175 | } |
176 | 176 | |
177 | 177 | function _hideSelectionPanel() { |
... | ... | @@ -463,7 +463,7 @@ |
463 | 463 | $(".row .col-md-12 p").remove(); |
464 | 464 | } |
465 | 465 | |
466 | - function _loadMainComponents(task) { | |
466 | + function _loadMainComponents() { | |
467 | 467 | dynengine.load(); |
468 | 468 | dynworkflow.load(); |
469 | 469 | submitSign.setup(upload_signs_url); |
... | ... | @@ -511,14 +511,18 @@ |
511 | 511 | _selectAnOption(parentId, el); |
512 | 512 | } |
513 | 513 | |
514 | - wikilibras.enableIconHover = function(container, isHover) { | |
515 | - _enableIconHover(container, isHover); | |
516 | - } | |
517 | - | |
518 | 514 | wikilibras.enableIconCheck = function(container, isHover) { |
519 | 515 | _enableIconCheck(container, isHover); |
520 | 516 | } |
521 | 517 | |
518 | + wikilibras.canHover = function(container) { | |
519 | + return _canHover(container); | |
520 | + } | |
521 | + | |
522 | + wikilibras.enableIconHover = function(container, isHover) { | |
523 | + _enableIconHover(container, isHover); | |
524 | + } | |
525 | + | |
522 | 526 | wikilibras.getRenderedAvatarUrl = function(userId, signName) { |
523 | 527 | return _getRenderedAvatarUrl(userId, signName); |
524 | 528 | } | ... | ... |
view/template.html
... | ... | @@ -298,12 +298,11 @@ |
298 | 298 | </div> |
299 | 299 | <div id="teached-signs-container" class="sub-main-container"> |
300 | 300 | <h4 class="teached-signs-msg" type="none">Você ainda não ensinou |
301 | - sinais.</h4> | |
302 | - <h4 class="teached-signs-msg" type="one"> | |
303 | - Você já ensinou 1 sinal de LIBRAS. | |
304 | - </h4> | |
301 | + sinais a Ícaro.</h4> | |
302 | + <h4 class="teached-signs-msg" type="one">Você já ensinou a Ícaro | |
303 | + 1 sinal de LIBRAS.</h4> | |
305 | 304 | <h4 class="teached-signs-msg" type="more"> |
306 | - Você já ensinou <span>x</span> sinais de LIBRAS. | |
305 | + Você já ensinou a Ícaro <span>x</span> sinais de LIBRAS. | |
307 | 306 | </h4> |
308 | 307 | <div id="signs-list-container" class="row"></div> |
309 | 308 | <div id="teached-sign-modal" class="modal fade" tabindex="-1" |
... | ... | @@ -319,7 +318,7 @@ |
319 | 318 | </div> |
320 | 319 | </div> |
321 | 320 | <div id="tutorial-container" class="sub-main-container"> |
322 | - <span>Tutorial</span> | |
321 | + <h4>Aprenda como ajudar Ícaro.</h4> | |
323 | 322 | </div> |
324 | 323 | </div> |
325 | 324 | ... | ... |