mumuki-laboratory 7.10.5 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -7
- data/Rakefile +9 -2
- data/app/assets/javascripts/mumuki_laboratory/application/bridge.js +26 -5
- data/app/assets/javascripts/mumuki_laboratory/application/characters.js +3 -1
- data/app/assets/javascripts/mumuki_laboratory/application/gamification.js +85 -0
- data/app/assets/javascripts/mumuki_laboratory/application/kids.js +160 -334
- data/app/assets/javascripts/mumuki_laboratory/application/kindergarten.js +200 -0
- data/app/assets/javascripts/mumuki_laboratory/application/primary.js +257 -0
- data/app/assets/javascripts/mumuki_laboratory/application/profile.js +31 -16
- data/app/assets/javascripts/mumuki_laboratory/application/submission.js +1 -0
- data/app/assets/javascripts/mumuki_laboratory/application/submissions-store.js +19 -2
- data/app/assets/stylesheets/mumuki_laboratory/application/_errors.scss +1 -3
- data/app/assets/stylesheets/mumuki_laboratory/application/_modules.scss +3 -1
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_avatar.scss +21 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/{_chapter_show.scss → _content_show.scss} +0 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kindergarten.scss +421 -12
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_medal.scss +48 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_terms.scss +44 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_user_profile.scss +9 -0
- data/app/controllers/api/courses_controller.rb +1 -2
- data/app/controllers/api/organizations_controller.rb +2 -3
- data/app/controllers/api/users_controller.rb +2 -4
- data/app/controllers/application_controller.rb +15 -8
- data/app/controllers/book_discussions_controller.rb +4 -0
- data/app/controllers/invitations_controller.rb +1 -2
- data/app/controllers/users_controller.rb +8 -2
- data/app/helpers/avatar_helper.rb +11 -3
- data/app/helpers/contextualization_result_helper.rb +9 -1
- data/app/helpers/kindergarten_helper.rb +5 -0
- data/app/helpers/links_helper.rb +8 -0
- data/app/helpers/medal_helper.rb +36 -0
- data/app/helpers/open_graph_helper.rb +2 -2
- data/app/helpers/organization_list_helper.rb +1 -1
- data/app/helpers/overlapped_buttons_helper.rb +1 -1
- data/app/helpers/page_title_helper.rb +2 -2
- data/app/helpers/profile_helper.rb +9 -1
- data/app/views/book/_header.html.erb +17 -0
- data/app/views/book/show.html.erb +1 -18
- data/app/views/discussions/terms.html.erb +10 -0
- data/app/views/exercise_solutions/_kids_results.html.erb +1 -1
- data/app/views/exercises/show.html.erb +1 -0
- data/app/views/invitations/_invitation_form.html.erb +1 -0
- data/app/views/layouts/_discussions.html.erb +4 -0
- data/app/views/layouts/_error.html.erb +3 -6
- data/app/views/layouts/_guide.html.erb +10 -3
- data/app/views/layouts/_kindergarten.html.erb +38 -0
- data/app/views/layouts/_main.html.erb +3 -1
- data/app/views/layouts/_organization_chooser.html.erb +0 -7
- data/app/views/layouts/_terms_acceptance_disclaimer.html.erb +6 -0
- data/app/views/layouts/application.html.erb +3 -2
- data/app/views/layouts/exercise_inputs/layouts/_input_kindergarten.html.erb +27 -27
- data/app/views/layouts/modals/_guide_corollary.html.erb +9 -0
- data/app/views/layouts/modals/_kindergarten_context.html.erb +30 -0
- data/app/views/layouts/modals/_kindergarten_results.html.erb +23 -0
- data/app/views/layouts/modals/_kindergarten_results_aborted.html.erb +27 -0
- data/app/views/users/_avatar_list.html.erb +6 -2
- data/app/views/users/_edit_user_form.html.erb +9 -4
- data/app/views/users/_term.html.erb +10 -0
- data/app/views/users/_user_form.html.erb +5 -1
- data/app/views/users/terms.html.erb +18 -0
- data/config/routes.rb +2 -0
- data/lib/mumuki/laboratory.rb +1 -1
- data/lib/mumuki/laboratory/controllers/current_organization.rb +1 -1
- data/lib/mumuki/laboratory/controllers/results_rendering.rb +3 -2
- data/lib/mumuki/laboratory/events/events.rb +0 -24
- data/lib/mumuki/laboratory/locales/en.yml +16 -5
- data/lib/mumuki/laboratory/locales/es-CL.yml +5 -4
- data/lib/mumuki/laboratory/locales/es.yml +17 -6
- data/lib/mumuki/laboratory/locales/pt.yml +16 -5
- data/lib/mumuki/laboratory/version.rb +1 -1
- data/spec/capybara_helper.rb +99 -0
- data/spec/controllers/exercise_solutions_controller_spec.rb +3 -4
- data/spec/dummy/db/schema.rb +37 -1
- data/spec/dummy/public/medal/outline.svg +1089 -0
- data/spec/features/choose_organization_spec.rb +12 -30
- data/spec/features/disable_user_flow_spec.rb +3 -5
- data/spec/features/disabled_organization_flow_spec.rb +9 -14
- data/spec/features/exercise_flow_spec.rb +2 -2
- data/spec/features/guide_reset_spec.rb +1 -1
- data/spec/features/guides_flow_spec.rb +1 -1
- data/spec/features/home_private_flow_spec.rb +1 -3
- data/spec/features/home_public_flow_spec.rb +6 -12
- data/spec/features/invitations_flow_spec.rb +2 -2
- data/spec/features/login_flow_spec.rb +2 -2
- data/spec/features/not_found_private_flow_spec.rb +4 -4
- data/spec/features/not_found_public_flow_spec.rb +1 -6
- data/spec/features/profile_flow_spec.rb +1 -1
- data/spec/helpers/page_title_helper_spec.rb +3 -3
- data/spec/javascripts/editors-spec.js +23 -0
- data/spec/javascripts/gamification-spec.js +58 -0
- data/spec/javascripts/submissions-store-spec.js +139 -6
- data/spec/spec_helper.rb +2 -0
- data/spec/teaspoon_env.rb +24 -6
- metadata +41 -7
@@ -0,0 +1,200 @@
|
|
1
|
+
mumuki.load(() => {
|
2
|
+
|
3
|
+
mumuki.isKindergartenExercise = () => !!$('.mu-kindergarten').get(0);
|
4
|
+
|
5
|
+
class MumukiKindergarten extends mumuki.Kids {
|
6
|
+
|
7
|
+
constructor() {
|
8
|
+
super();
|
9
|
+
}
|
10
|
+
|
11
|
+
initialize() {
|
12
|
+
super.initialize();
|
13
|
+
this.$contextModalButton = new mumuki.Button($('#mu-kids-context .mu-kindergarten-modal-button.mu-close'));
|
14
|
+
|
15
|
+
this.resultActions.passed = this._showSuccessPopup.bind(this);
|
16
|
+
this.resultActions.passed_with_warnings = this._showSuccessPopup.bind(this);
|
17
|
+
this.resultActions.failed = this._showFailurePopup.bind(this);
|
18
|
+
this.resultActions.errored = this._showFailurePopup.bind(this);
|
19
|
+
this.resultActions.pending = this._showFailurePopup.bind(this);
|
20
|
+
this.resultActions.aborted = this.showAbortedPopup.bind(this);
|
21
|
+
|
22
|
+
this.speech.verifyBrowserSupport();
|
23
|
+
this.hint.showOrHideExpandHintButton();
|
24
|
+
this.context.showNextOrCloseButton();
|
25
|
+
}
|
26
|
+
|
27
|
+
// ================
|
28
|
+
// == Public API ==
|
29
|
+
// ================
|
30
|
+
|
31
|
+
showNonAbortedPopup(data, animation_name) {
|
32
|
+
data.guide_finished_by_solution = false;
|
33
|
+
this.$submissionResult.html(data.title_html);
|
34
|
+
this.$resultsModal.find('.modal-content').removeClass().addClass('modal-content').addClass(data.status);
|
35
|
+
super.showNonAbortedPopup(data, animation_name, 1000);
|
36
|
+
}
|
37
|
+
|
38
|
+
showAbortedPopup(data) {
|
39
|
+
const $closeResultAbortedModalButton = new mumuki.Button(this.$resultsAbortedModal.find('.mu-close'));
|
40
|
+
$closeResultAbortedModalButton.setWaiting();
|
41
|
+
mumuki.presenterCharacter.playAnimation('failed', $('.mu-kids-character-result-aborted'));
|
42
|
+
super.showAbortedPopup(data);
|
43
|
+
setTimeout(() => $closeResultAbortedModalButton.enable(), 2500);
|
44
|
+
}
|
45
|
+
|
46
|
+
// ==================
|
47
|
+
// == Hook Methods ==
|
48
|
+
// ==================
|
49
|
+
|
50
|
+
_showSuccessPopup(data) {
|
51
|
+
this.showNonAbortedPopup(data, 'success2_l');
|
52
|
+
}
|
53
|
+
|
54
|
+
_showFailurePopup(data) {
|
55
|
+
this.showNonAbortedPopup(data, 'failure');
|
56
|
+
}
|
57
|
+
|
58
|
+
// ====================
|
59
|
+
// == Event Callback ==
|
60
|
+
// ====================
|
61
|
+
|
62
|
+
onReady() {
|
63
|
+
mumuki.resize(this.onResize.bind(this));
|
64
|
+
}
|
65
|
+
|
66
|
+
onResize() {
|
67
|
+
this.scaleState(this.$states, 50);
|
68
|
+
this.scaleBlocksArea(this.$blocks);
|
69
|
+
}
|
70
|
+
|
71
|
+
// ==========================
|
72
|
+
// == Called by the runner ==
|
73
|
+
// ==========================
|
74
|
+
|
75
|
+
restart() {
|
76
|
+
mumuki.presenterCharacter.playAnimation('talk', this.$bubbleCharacterAnimation);
|
77
|
+
}
|
78
|
+
|
79
|
+
// =======================
|
80
|
+
// == Specific Behavior ==
|
81
|
+
// =======================
|
82
|
+
|
83
|
+
get speech() {
|
84
|
+
return {
|
85
|
+
_isPlaying: false,
|
86
|
+
click(selector, locale) {
|
87
|
+
if (this._isPlaying) {
|
88
|
+
this.stop();
|
89
|
+
} else {
|
90
|
+
this.play(selector, locale);
|
91
|
+
}
|
92
|
+
},
|
93
|
+
play(selector, locale) {
|
94
|
+
const msg = new SpeechSynthesisUtterance();
|
95
|
+
msg.text = $(selector).text();
|
96
|
+
msg.lang = locale.split('_')[0];
|
97
|
+
msg.pitch = 0;
|
98
|
+
msg.onend = () => this.stop();
|
99
|
+
this._action('play', 'stop', true, (speech) => {
|
100
|
+
mumuki.presenterCharacter.playAnimation('talk', mumuki.kids.$bubbleCharacterAnimation);
|
101
|
+
speech.speak(msg);
|
102
|
+
})
|
103
|
+
},
|
104
|
+
stop() {
|
105
|
+
this._action('stop', 'play', false, (speech) => speech.cancel())
|
106
|
+
},
|
107
|
+
_action(add, remove, isPlaying, callback) {
|
108
|
+
callback(window.speechSynthesis);
|
109
|
+
const $button = $('.mu-kindergarten-play-description')
|
110
|
+
$button.find(`.mu-kindergarten-${add}`).addClass('hidden');
|
111
|
+
$button.find(`.mu-kindergarten-${remove}`).removeClass('hidden');
|
112
|
+
this._isPlaying = isPlaying;
|
113
|
+
},
|
114
|
+
verifyBrowserSupport() {
|
115
|
+
if (!window.speechSynthesis) {
|
116
|
+
const $button = $('.mu-kindergarten-play-description')
|
117
|
+
$button.prop('disabled', true);
|
118
|
+
$button.css('cursor', 'not-allowed');
|
119
|
+
this._action('play', 'stop', false)
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
}
|
125
|
+
|
126
|
+
get hint() {
|
127
|
+
return {
|
128
|
+
toggle() {
|
129
|
+
$('.mu-kindergarten-light-speech-bubble').toggleClass('open');
|
130
|
+
},
|
131
|
+
toggleMedia() {
|
132
|
+
const $hintMedia = $('.mu-kindergarten-hint-media');
|
133
|
+
const $i = $('.expand-or-collapse-hint-media').children('i');
|
134
|
+
$i.toggleClass('fa-caret-up').toggleClass('fa-caret-down');
|
135
|
+
$hintMedia.toggleClass('closed');
|
136
|
+
},
|
137
|
+
showOrHideExpandHintButton() {
|
138
|
+
const $button = $('.expand-or-collapse-hint-media');
|
139
|
+
const $hintMedia = $('.mu-kindergarten-hint-media');
|
140
|
+
if (!$hintMedia.get(0)) $button.addClass('hidden');
|
141
|
+
},
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
get context() {
|
146
|
+
return {
|
147
|
+
showContext() {
|
148
|
+
mumuki.kids.showContext();
|
149
|
+
this._showFirstSlideImage();
|
150
|
+
},
|
151
|
+
nextSlide() {
|
152
|
+
this._clickButton('next');
|
153
|
+
},
|
154
|
+
prevSlide() {
|
155
|
+
this._clickButton('prev');
|
156
|
+
},
|
157
|
+
_imageSlides() {
|
158
|
+
return $('.mu-kindergarten-context-image-slides');
|
159
|
+
},
|
160
|
+
_activeSlideImage() {
|
161
|
+
return this._imageSlides().find('.active');
|
162
|
+
},
|
163
|
+
_clickButton(prevOrNext) {
|
164
|
+
this._activeSlideImage().removeClass('active')[prevOrNext]().addClass('active');
|
165
|
+
this.showNextOrCloseButton();
|
166
|
+
this._hidePreviousButtonIfFirstImage();
|
167
|
+
},
|
168
|
+
showNextOrCloseButton() {
|
169
|
+
const $next = $('.mu-kindergarten-modal-button.mu-next');
|
170
|
+
const $close = $('.mu-kindergarten-modal-button.mu-close');
|
171
|
+
const isLastChild = this._activeSlideImage().is(':last-child');
|
172
|
+
this._addClassIf($next, 'hidden', () => isLastChild);
|
173
|
+
this._addClassIf($close, 'hidden', () => !isLastChild);
|
174
|
+
},
|
175
|
+
_hidePreviousButtonIfFirstImage() {
|
176
|
+
const $prev = $('.mu-kindergarten-modal-button.mu-previous');
|
177
|
+
this._addClassIf($prev, 'hidden', () => this._activeSlideImage().is(':first-child'))
|
178
|
+
},
|
179
|
+
_showFirstSlideImage() {
|
180
|
+
this._imageSlides().find('img').each((i, el) => this._addClassIf($(el), 'active', () => i === 0))
|
181
|
+
this.showNextOrCloseButton();
|
182
|
+
this._hidePreviousButtonIfFirstImage();
|
183
|
+
},
|
184
|
+
_addClassIf(element, clazz, criteria) {
|
185
|
+
if (criteria()) {
|
186
|
+
element.addClass(clazz)
|
187
|
+
} else {
|
188
|
+
element.removeClass(clazz);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
}
|
195
|
+
|
196
|
+
if (mumuki.isKindergartenExercise()) {
|
197
|
+
mumuki.kids = new MumukiKindergarten();
|
198
|
+
}
|
199
|
+
|
200
|
+
});
|
@@ -0,0 +1,257 @@
|
|
1
|
+
mumuki.load(() => {
|
2
|
+
|
3
|
+
mumuki.isPrimaryExercise = () => !!$('.mu-kids-exercise').get(0) && !$('.mu-kindergarten').get(0);
|
4
|
+
|
5
|
+
class MumukiPrimary extends mumuki.Kids {
|
6
|
+
|
7
|
+
constructor() {
|
8
|
+
super();
|
9
|
+
}
|
10
|
+
|
11
|
+
// ================
|
12
|
+
// == Public API ==
|
13
|
+
// ================
|
14
|
+
|
15
|
+
initialize() {
|
16
|
+
super.initialize();
|
17
|
+
this.$characterSpeechBubble = $('.mu-kids-character-speech-bubble');
|
18
|
+
this.$characterSpeechBubbleNormal = this.$characterSpeechBubble.children('.mu-kids-character-speech-bubble-normal');
|
19
|
+
this.$overlay = $('.mu-kids-overlay');
|
20
|
+
this.$contextModalButton = new mumuki.Button($('.mu-kids-context .modal-footer button'));
|
21
|
+
|
22
|
+
this._paragraphHeight = undefined;
|
23
|
+
this._currentParagraphIndex = 0;
|
24
|
+
this._paragraphCount = 1;
|
25
|
+
this._paragraphsLines = 2;
|
26
|
+
this._availableTabs = ['.description', '.hint'];
|
27
|
+
this._$speechParagraphs = undefined;
|
28
|
+
this._paragraphHeight = undefined;
|
29
|
+
this._scrollHeight = undefined;
|
30
|
+
this._nextSpeechBlinking = undefined;
|
31
|
+
this._$prevSpeech = $('.mu-kids-character-speech-bubble-normal > .mu-kids-prev-speech').hide();
|
32
|
+
this._$nextSpeech = $('.mu-kids-character-speech-bubble-normal > .mu-kids-next-speech');
|
33
|
+
this._$speechTabs = $('.mu-kids-character-speech-bubble-tabs > li:not(.separator)');
|
34
|
+
this._$texts = this.$characterSpeechBubbleNormal.children(this._availableTabs.join(", "));
|
35
|
+
this._$hint = $('.mu-kids-hint');
|
36
|
+
this._$description = $('.mu-kids-description');
|
37
|
+
|
38
|
+
this.resultActions.passed = this._showSuccessPopup.bind(this);
|
39
|
+
this.resultActions.passed_with_warnings = this._showOnCharacterBubble.bind(this);
|
40
|
+
this.resultActions.failed = this._showOnCharacterBubble.bind(this);
|
41
|
+
this.resultActions.errored = this._showOnCharacterBubble.bind(this);
|
42
|
+
this.resultActions.pending = this._showOnCharacterBubble.bind(this);
|
43
|
+
this.resultActions.aborted = this.showAbortedPopup.bind(this);
|
44
|
+
|
45
|
+
this.$contextModal.on('hidden.bs.modal', this.animateSpeech.bind(this));
|
46
|
+
}
|
47
|
+
|
48
|
+
showAbortedPopup(data) {
|
49
|
+
super.showAbortedPopup(data);
|
50
|
+
mumuki.submission.animateTimeoutError(this.submitButton);
|
51
|
+
}
|
52
|
+
|
53
|
+
// ==================
|
54
|
+
// == Hook Methods ==
|
55
|
+
// ==================
|
56
|
+
|
57
|
+
_showSuccessPopup(data) {
|
58
|
+
this.showNonAbortedPopup(data, 'success2_l', 4000);
|
59
|
+
}
|
60
|
+
|
61
|
+
_showFailurePopup(data) {
|
62
|
+
this._showOnCharacterBubble(data);
|
63
|
+
}
|
64
|
+
|
65
|
+
// ====================
|
66
|
+
// == Event Callback ==
|
67
|
+
// ====================
|
68
|
+
|
69
|
+
onReady() {
|
70
|
+
mumuki.resize(this.onResize.bind(this));
|
71
|
+
|
72
|
+
this._availableTabs.forEach((selector) => this._tabParagraphs(selector).contents().unwrap().wrapAll('<p>'));
|
73
|
+
|
74
|
+
this._updateSpeechParagraphs();
|
75
|
+
this._resizeSpeechParagraphs();
|
76
|
+
|
77
|
+
this._$speechTabs.each((i) => {
|
78
|
+
const $tab = $(this._$speechTabs[i]);
|
79
|
+
if ($tab.data('target')) {
|
80
|
+
$tab.click(() => {
|
81
|
+
this._$speechTabs.removeClass('active');
|
82
|
+
$tab.addClass('active');
|
83
|
+
this._$texts.hide();
|
84
|
+
this.$characterSpeechBubbleNormal.children('.' + $tab.data('target')).show();
|
85
|
+
this._updateSpeechParagraphs();
|
86
|
+
})
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
if (this._paragraphCount > 1) {
|
91
|
+
this._nextSpeechBlinking = mumuki.setInterval(() => this._$nextSpeech.fadeTo('slow', 0.1).fadeTo('slow', 1.0), 1000);
|
92
|
+
}
|
93
|
+
|
94
|
+
this._$nextSpeech.click(this._showNextParagraph.bind(this));
|
95
|
+
this._$prevSpeech.click(this._showPrevParagraph.bind(this));
|
96
|
+
this._$description.click(this.animateSpeech.bind(this));
|
97
|
+
|
98
|
+
this._$hint.click(() => {
|
99
|
+
this.animateHint();
|
100
|
+
this._$hint.removeClass('blink');
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
onResize() {
|
105
|
+
const FULL_MARGIN = 30;
|
106
|
+
|
107
|
+
distributeAreas(this.$stateImage, this.$states, this.$blocks, FULL_MARGIN);
|
108
|
+
|
109
|
+
if (!this.$exerciseDescription.hasClass('mu-kids-exercise-description-fixed')) {
|
110
|
+
this.$exerciseDescription.width(this.$exercise.width() - this.$states.width() - FULL_MARGIN / 2);
|
111
|
+
}
|
112
|
+
|
113
|
+
this.$state.each((_index, state) => this.scaleState($(state), FULL_MARGIN));
|
114
|
+
this.scaleBlocksArea(this.$blocks);
|
115
|
+
|
116
|
+
if (this._paragraphCount <= 1) clearInterval(this._nextSpeechBlinking);
|
117
|
+
|
118
|
+
this._updateSpeechParagraphs();
|
119
|
+
this._resizeSpeechParagraphs();
|
120
|
+
}
|
121
|
+
|
122
|
+
onNonAbortedPopupCall(data) {
|
123
|
+
this._showMessageOnCharacterBubble(data);
|
124
|
+
}
|
125
|
+
|
126
|
+
onSubmissionResultModalOpen(_data) {
|
127
|
+
this._showCorollaryCharacter();
|
128
|
+
}
|
129
|
+
|
130
|
+
// ==========================
|
131
|
+
// == Called by the runner ==
|
132
|
+
// ==========================
|
133
|
+
|
134
|
+
restart() {
|
135
|
+
this._hideMessageOnCharacterBubble();
|
136
|
+
const $bubble = this.$characterSpeechBubble;
|
137
|
+
Object.keys(this.resultActions).forEach($bubble.removeClass.bind($bubble));
|
138
|
+
mumuki.presenterCharacter.playAnimation('talk', this.$bubbleCharacterAnimation);
|
139
|
+
}
|
140
|
+
|
141
|
+
// =======================
|
142
|
+
// == Specific Behavior ==
|
143
|
+
// =======================
|
144
|
+
|
145
|
+
_hideMessageOnCharacterBubble() {
|
146
|
+
const $bubble = this.$characterSpeechBubble;
|
147
|
+
$bubble.find('.mu-kids-character-speech-bubble-tabs').show();
|
148
|
+
$bubble.find('.mu-kids-character-speech-bubble-normal').show();
|
149
|
+
$bubble.find('.mu-kids-character-speech-bubble-failed').hide();
|
150
|
+
$bubble.find('.mu-kids-discussion-link').remove();
|
151
|
+
Object.keys(this.resultActions).forEach($bubble.removeClass.bind($bubble));
|
152
|
+
this.$overlay.hide();
|
153
|
+
}
|
154
|
+
|
155
|
+
_showMessageOnCharacterBubble(data) {
|
156
|
+
const renderer = new mumuki.renderers.speechBubble.SpeechBubbleRenderer(this.$characterSpeechBubble);
|
157
|
+
renderer.setDiscussionsLinkHtml($('#mu-kids-discussion-link-html').html());
|
158
|
+
renderer.setResponseData(data);
|
159
|
+
renderer.render();
|
160
|
+
this.$overlay.show();
|
161
|
+
}
|
162
|
+
|
163
|
+
_showOnCharacterBubble(data) {
|
164
|
+
mumuki.presenterCharacter.playAnimation('failure', this.$bubbleCharacterAnimation);
|
165
|
+
this._showMessageOnCharacterBubble(data);
|
166
|
+
}
|
167
|
+
|
168
|
+
_showCorollaryCharacter() {
|
169
|
+
mumuki.characters.magnifying_glass.playAnimation('show', $('.mu-kids-corollary-animation'));
|
170
|
+
}
|
171
|
+
|
172
|
+
animateSpeech() {
|
173
|
+
mumuki.presenterCharacter.playAnimation('talk', this.$bubbleCharacterAnimation);
|
174
|
+
}
|
175
|
+
|
176
|
+
animateHint() {
|
177
|
+
mumuki.presenterCharacter.playAnimation('hint', this.$bubbleCharacterAnimation);
|
178
|
+
}
|
179
|
+
|
180
|
+
_showPrevParagraph() {
|
181
|
+
this.animateSpeech();
|
182
|
+
this._showParagraph(this._currentParagraphIndex - 1);
|
183
|
+
}
|
184
|
+
|
185
|
+
_showNextParagraph() {
|
186
|
+
this.animateSpeech();
|
187
|
+
this._showParagraph(this._currentParagraphIndex + 1);
|
188
|
+
clearInterval(this._nextSpeechBlinking);
|
189
|
+
}
|
190
|
+
|
191
|
+
_resizeSpeechParagraphs(paragraphIndex) {
|
192
|
+
const previousParagraphCount = this._paragraphCount;
|
193
|
+
this._scrollHeight = this.$characterSpeechBubbleNormal[0].scrollHeight;
|
194
|
+
this._paragraphHeight = floatFromPx(this._$speechParagraphs.css('line-height')) * this._paragraphsLines;
|
195
|
+
this._paragraphCount = Math.ceil(this._scrollHeight / this._paragraphHeight);
|
196
|
+
const newParagraphIndex = Math.floor((this._paragraphCount / previousParagraphCount) * this._currentParagraphIndex);
|
197
|
+
this._showParagraph(paragraphIndex || newParagraphIndex);
|
198
|
+
}
|
199
|
+
|
200
|
+
_showParagraph(index) {
|
201
|
+
this.$characterSpeechBubbleNormal[0].scrollTop = index * this._paragraphHeight;
|
202
|
+
this._currentParagraphIndex = index;
|
203
|
+
this._checkArrowsSpeechVisibility();
|
204
|
+
}
|
205
|
+
|
206
|
+
_checkArrowsSpeechVisibility() {
|
207
|
+
this._setVisibility(this._$prevSpeech, this._currentParagraphIndex !== 0);
|
208
|
+
this._setVisibility(this._$nextSpeech, this._currentParagraphIndex !== this._paragraphCount - 1);
|
209
|
+
}
|
210
|
+
|
211
|
+
_setVisibility(element, isVisible) {
|
212
|
+
isVisible ? element.show() : element.hide();
|
213
|
+
}
|
214
|
+
|
215
|
+
_tabParagraphs(selector) {
|
216
|
+
return $('.mu-kids-character-speech-bubble > .mu-kids-character-speech-bubble-normal > div' + selector + ' > p');
|
217
|
+
}
|
218
|
+
|
219
|
+
_updateSpeechParagraphs() {
|
220
|
+
this._$speechParagraphs = this._tabParagraphs('.' + this._getSelectedTabName());
|
221
|
+
this._resizeSpeechParagraphs(0);
|
222
|
+
}
|
223
|
+
|
224
|
+
_getSelectedTabName() {
|
225
|
+
return this._$speechTabs.filter('.active').data('target') || 'description';
|
226
|
+
}
|
227
|
+
|
228
|
+
}
|
229
|
+
|
230
|
+
/**
|
231
|
+
* Assigns propert widths to the states and blocks areas
|
232
|
+
* depending on the presence and type of available states
|
233
|
+
*
|
234
|
+
* @param {*} $muKidsStateImage
|
235
|
+
* @param {*} $muKidsStatesContainer
|
236
|
+
* @param {*} $muKidsBlocks
|
237
|
+
* @param {number} fullMargin
|
238
|
+
*/
|
239
|
+
function distributeAreas($muKidsStateImage, $muKidsStatesContainer, $muKidsBlocks, fullMargin) {
|
240
|
+
if ($muKidsStateImage.children().length) {
|
241
|
+
const ratio = $muKidsStatesContainer.hasClass('mu-kids-single-state') ? 1 : 2;
|
242
|
+
$muKidsStatesContainer.width($muKidsStatesContainer.height() / ratio * 1.25 - fullMargin);
|
243
|
+
} else {
|
244
|
+
$muKidsStatesContainer.width(0);
|
245
|
+
$muKidsBlocks.width('100%');
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
function floatFromPx(value) {
|
250
|
+
return parseFloat(value.substring(0, value.length - 2));
|
251
|
+
}
|
252
|
+
|
253
|
+
if (mumuki.isPrimaryExercise()) {
|
254
|
+
mumuki.kids = new MumukiPrimary();
|
255
|
+
}
|
256
|
+
|
257
|
+
});
|