9 |
9 |
10 IriSP.Widgets.Controller.prototype.defaults = { |
10 IriSP.Widgets.Controller.prototype.defaults = { |
11 disable_annotate_btn: false, |
11 disable_annotate_btn: false, |
12 disable_search_btn: false, |
12 disable_search_btn: false, |
13 disable_ctrl_f: false, |
13 disable_ctrl_f: false, |
14 always_show_search: false |
14 disable_fullscreen : true, |
|
15 always_show_search: false, |
|
16 enable_quiz_toggle: undefined |
15 }; |
17 }; |
16 |
18 |
17 IriSP.Widgets.Controller.prototype.template = |
19 IriSP.Widgets.Controller.prototype.template = |
18 '<div class="Ldt-Ctrl">' |
20 '<div class="Ldt-Ctrl">' |
19 + '<div class="Ldt-Ctrl-Left">' |
21 + '<div class="Ldt-Ctrl-Left">' |
23 + '<div class="Ldt-Ctrl-button Ldt-Ctrl-Annotate Ldt-TraceMe" title="{{l10n.annotate}}"></div>' |
25 + '<div class="Ldt-Ctrl-button Ldt-Ctrl-Annotate Ldt-TraceMe" title="{{l10n.annotate}}"></div>' |
24 + '<div class="Ldt-Ctrl-spacer"></div>' |
26 + '<div class="Ldt-Ctrl-spacer"></div>' |
25 + '{{/disable_annotate_btn}}' |
27 + '{{/disable_annotate_btn}}' |
26 + '{{^disable_search_btn}}' |
28 + '{{^disable_search_btn}}' |
27 + '<div class="Ldt-Ctrl-button Ldt-Ctrl-SearchBtn Ldt-TraceMe" title="{{l10n.search}}"></div>' |
29 + '<div class="Ldt-Ctrl-button Ldt-Ctrl-SearchBtn Ldt-TraceMe" title="{{l10n.search}}"></div>' |
28 + '<div class="Ldt-Ctrl-spacer"></div>' |
|
29 + '{{/disable_search_btn}}' |
30 + '{{/disable_search_btn}}' |
30 + '<div class="Ldt-Ctrl-Search">' |
31 + '<div class="Ldt-Ctrl-Search">' |
31 + '<input placeholder="{{ l10n.search }}" type="search" class="Ldt-Ctrl-SearchInput Ldt-TraceMe"></input>' |
32 + '<input placeholder="{{ l10n.search }}" type="search" class="Ldt-Ctrl-SearchInput Ldt-TraceMe"></input>' |
32 + '</div>' |
33 + '</div>' |
|
34 + '<div class="Ldt-Ctrl-Quiz-Enable Ldt-TraceMe" title="Activer/Désactiver le quiz"></div>' |
|
35 + '<div class="Ldt-Ctrl-Quiz-Create Ldt-TraceMe" ></div>' |
33 + '</div>' |
36 + '</div>' |
34 + '<div class="Ldt-Ctrl-Right">' |
37 + '<div class="Ldt-Ctrl-Right">' |
|
38 + '{{^disable_fullscreen}}<div class="Ldt-Ctrl-Fullscreen-Button Ldt-TraceMe" title="Passer le lecteur en plein-écran"></div{{/disable_fullscreen}}' |
35 + '<div class="Ldt-Ctrl-spacer"></div>' |
39 + '<div class="Ldt-Ctrl-spacer"></div>' |
36 + '<div class="Ldt-Ctrl-Time">' |
40 + '<div class="Ldt-Ctrl-Time">' |
37 + '<div class="Ldt-Ctrl-Time-Elapsed" title="{{l10n.elapsed_time}}">00:00</div>' |
41 + '<div class="Ldt-Ctrl-Time-Elapsed" title="{{l10n.elapsed_time}}">00:00</div>' |
38 + '<div class="Ldt-Ctrl-Time-Separator">/</div>' |
42 + '<div class="Ldt-Ctrl-Time-Separator">/</div>' |
39 + '<div class="Ldt-Ctrl-Time-Total" title="{{l10n.total_time}}">00:00</div>' |
43 + '<div class="Ldt-Ctrl-Time-Total" title="{{l10n.total_time}}">00:00</div>' |
71 annotate: "Annoter", |
76 annotate: "Annoter", |
72 search: "Rechercher", |
77 search: "Rechercher", |
73 elapsed_time: "Temps écoulé", |
78 elapsed_time: "Temps écoulé", |
74 total_time: "Durée totale", |
79 total_time: "Durée totale", |
75 volume: "Niveau sonore", |
80 volume: "Niveau sonore", |
76 volume_control: "Réglage du niveau sonore" |
81 volume_control: "Réglage du niveau sonore", |
|
82 enable_quiz: "Activer le quiz" |
77 } |
83 } |
78 }; |
84 }; |
79 |
85 |
80 IriSP.Widgets.Controller.prototype.draw = function() { |
86 IriSP.Widgets.Controller.prototype.draw = function() { |
81 var _this = this; |
87 var _this = this; |
82 this.renderTemplate(); |
88 this.renderTemplate(); |
83 |
89 |
84 // Define blocks |
90 // Define blocks |
85 this.$playButton = this.$.find(".Ldt-Ctrl-Play"); |
91 this.$playButton = this.$.find(".Ldt-Ctrl-Play"); |
86 this.$searchBlock = this.$.find(".Ldt-Ctrl-Search"); |
92 this.$searchBlock = this.$.find(".Ldt-Ctrl-Search"); |
87 this.$searchInput = this.$.find(".Ldt-Ctrl-SearchInput"); |
93 this.$searchInput = this.$.find(".Ldt-Ctrl-SearchInput"); |
88 this.$volumeBar = this.$.find(".Ldt-Ctrl-Volume-Bar"); |
94 this.$volumeBar = this.$.find(".Ldt-Ctrl-Volume-Bar"); |
89 |
95 |
90 // handle events |
96 // handle events |
91 this.onMediaEvent("play","playButtonUpdater"); |
97 this.onMediaEvent("play","playButtonUpdater"); |
92 this.onMediaEvent("pause","playButtonUpdater"); |
98 this.onMediaEvent("pause","playButtonUpdater"); |
93 this.onMediaEvent("volumechange","volumeUpdater"); |
99 this.onMediaEvent("volumechange","volumeUpdater"); |
94 this.onMediaEvent("timeupdate","timeDisplayUpdater"); |
100 this.onMediaEvent("timeupdate","timeDisplayUpdater"); |
95 this.onMediaEvent("loadedmetadata","volumeUpdater"); |
101 this.onMediaEvent("loadedmetadata","volumeUpdater"); |
96 |
102 |
97 // handle clicks |
103 // handle clicks |
98 this.$playButton.click(this.functionWrapper("playHandler")); |
104 this.$playButton.click(this.functionWrapper("playHandler")); |
99 |
105 |
|
106 if (this.enable_quiz_toggle !== undefined) { |
|
107 if (this.enable_quiz_toggle) { |
|
108 this.$.find(".Ldt-Ctrl-Quiz-Enable").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
|
109 this.$.find(".Ldt-Ctrl-Quiz-Create").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
|
110 // this.player.trigger("QuizCreator.show"); |
|
111 this.$.find("#QuizEditContainer").show(); |
|
112 } |
|
113 else |
|
114 { |
|
115 this.$.find(".Ldt-Ctrl-Quiz-Enable").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
|
116 this.$.find(".Ldt-Ctrl-Quiz-Create").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
|
117 this.player.trigger("QuizCreator.hide"); |
|
118 this.$.find("#QuizEditContainer").hide(); |
|
119 } |
|
120 } else { |
|
121 this.$.find(".Ldt-Ctrl-Quiz-Enable").hide(); |
|
122 } |
|
123 |
100 this.$.find(".Ldt-Ctrl-Annotate").click(function() { |
124 this.$.find(".Ldt-Ctrl-Annotate").click(function() { |
101 _this.player.trigger("CreateAnnotation.toggle"); |
125 _this.player.trigger("CreateAnnotation.toggle"); |
102 }); |
126 }); |
103 this.$.find(".Ldt-Ctrl-SearchBtn").click(this.functionWrapper("searchButtonHandler")); |
127 this.$.find(".Ldt-Ctrl-SearchBtn").click(this.functionWrapper("searchButtonHandler")); |
104 |
128 |
105 this.$searchInput.keyup(this.functionWrapper("searchHandler")); |
129 this.$searchInput.keyup(this.functionWrapper("searchHandler")); |
106 this.$searchInput.on("search", this.functionWrapper("searchHandler")); |
130 this.$searchInput.on("search", this.functionWrapper("searchHandler")); |
107 |
131 |
108 var _volctrl = this.$.find(".Ldt-Ctrl-Volume-Control"); |
132 // Fullscreen handling |
|
133 this.$.find(".Ldt-Ctrl-Fullscreen-Button").click(this.functionWrapper("toggleFullscreen")); |
|
134 var fullscreen_event_name = IriSP.getFullscreenEventname(); |
|
135 if (fullscreen_event_name) { |
|
136 document.addEventListener(fullscreen_event_name, function() { |
|
137 if (IriSP.isFullscreen() && IriSP.getFullscreenElement() == _this.$[0]) { |
|
138 _this.$.addClass("Ldt-Fullscreen-Element"); |
|
139 } else { |
|
140 _this.$.removeClass("Ldt-Fullscreen-Element"); |
|
141 } |
|
142 }); |
|
143 }; |
|
144 |
|
145 // Quiz activation |
|
146 this.$.find(".Ldt-Ctrl-Quiz-Enable").click(this.functionWrapper("toggleQuiz")); |
|
147 this.$.find(".Ldt-Ctrl-Quiz-Create").click(this.functionWrapper("createQuiz")); |
|
148 |
|
149 var _volctrl = this.$.find(".Ldt-Ctrl-Volume-Control"); |
109 this.$.find('.Ldt-Ctrl-Sound') |
150 this.$.find('.Ldt-Ctrl-Sound') |
110 .click(this.functionWrapper("muteHandler")) |
151 .click(this.functionWrapper("muteHandler")) |
111 .mouseover(function() { |
152 .mouseover(function() { |
112 _volctrl.show(); |
153 _volctrl.show(); |
113 }) |
154 }) |
201 .removeClass("Ldt-Ctrl-Play-PlayState") |
242 .removeClass("Ldt-Ctrl-Play-PlayState") |
202 .addClass("Ldt-Ctrl-Play-PauseState"); |
243 .addClass("Ldt-Ctrl-Play-PauseState"); |
203 } |
244 } |
204 }; |
245 }; |
205 |
246 |
|
247 //FullScreen |
|
248 IriSP.Widgets.Controller.prototype.toggleFullscreen = function() { |
|
249 if (IriSP.isFullscreen()) { |
|
250 IriSP.setFullScreen(this.$[0], false); |
|
251 } else { |
|
252 IriSP.setFullScreen(this.$[0], true); |
|
253 } |
|
254 }; |
|
255 |
|
256 //Quiz |
|
257 IriSP.Widgets.Controller.prototype.createQuiz = function() { |
|
258 this.player.trigger("Quiz.hide"); |
|
259 this.media.pause(); |
|
260 this.player.trigger("QuizCreator.create"); |
|
261 }; |
|
262 |
|
263 IriSP.Widgets.Controller.prototype.toggleQuiz = function() { |
|
264 this.enable_quiz_toggle = !this.enable_quiz_toggle; |
|
265 if (this.enable_quiz_toggle) { |
|
266 $(".Ldt-Ctrl-Quiz-Enable").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
|
267 $(".Ldt-Ctrl-Quiz-Create").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
|
268 this.player.trigger("Quiz.activate"); |
|
269 } |
|
270 else |
|
271 { |
|
272 $(".Ldt-Ctrl-Quiz-Enable").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
|
273 $(".Ldt-Ctrl-Quiz-Create").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
|
274 this.player.trigger("Quiz.deactivate"); |
|
275 this.player.trigger("QuizCreator.hide"); |
|
276 } |
|
277 }; |
206 |
278 |
207 IriSP.Widgets.Controller.prototype.playHandler = function() { |
279 IriSP.Widgets.Controller.prototype.playHandler = function() { |
208 if (this.media.getPaused()) { |
280 if (this.media.getPaused()) { |
209 this.media.play(); |
281 this.media.play(); |
210 } else { |
282 } else { |
211 this.media.pause(); |
283 this.media.pause(); |
212 } |
284 } |
213 }; |
285 }; |
214 |
286 |
215 IriSP.Widgets.Controller.prototype.muteHandler = function() { |
287 IriSP.Widgets.Controller.prototype.muteHandler = function() { |
216 this.media.setMuted(!this.media.getMuted()); |
288 this.media.setMuted(!this.media.getMuted()); |
217 }; |
289 }; |
222 if (_vol === false) { |
294 if (_vol === false) { |
223 _vol = .5; |
295 _vol = .5; |
224 } |
296 } |
225 var _soundCtl = this.$.find(".Ldt-Ctrl-Sound"); |
297 var _soundCtl = this.$.find(".Ldt-Ctrl-Sound"); |
226 _soundCtl.removeClass("Ldt-Ctrl-Sound-Mute Ldt-Ctrl-Sound-Half Ldt-Ctrl-Sound-Full"); |
298 _soundCtl.removeClass("Ldt-Ctrl-Sound-Mute Ldt-Ctrl-Sound-Half Ldt-Ctrl-Sound-Full"); |
227 if (_muted) { |
299 if (_muted) { |
228 _soundCtl.attr("title", this.l10n.unmute) |
300 _soundCtl.attr("title", this.l10n.unmute) |
229 .addClass("Ldt-Ctrl-Sound-Mute"); |
301 .addClass("Ldt-Ctrl-Sound-Mute"); |
230 } else { |
302 } else { |
231 _soundCtl.attr("title", this.l10n.mute) |
303 _soundCtl.attr("title", this.l10n.mute) |
232 .addClass(_vol < .5 ? "Ldt-Ctrl-Sound-Half" : "Ldt-Ctrl-Sound-Full" ); |
304 .addClass(_vol < .5 ? "Ldt-Ctrl-Sound-Half" : "Ldt-Ctrl-Sound-Full" ); |
233 } |
305 } |
234 this.$volumeBar.slider("value", _muted ? 0 : 100 * _vol); |
306 this.$volumeBar.slider("value", _muted ? 0 : 100 * _vol); |