1 /* Displays Play and Pause buttons, Search Button and Form, Volume Control */ |
1 /* Displays Play and Pause buttons, Search Button and Form, Volume Control */ |
2 |
2 // Controller |
3 IriSP.Widgets.Controller = function(player, config) { |
3 |
4 IriSP.Widgets.Widget.call(this, player, config); |
4 import controllerStyles from "./Controller.module.css"; |
5 this.lastSearchValue = ""; |
5 |
6 }; |
6 import jQuery from "jquery"; |
7 |
7 |
8 IriSP.Widgets.Controller.prototype = new IriSP.Widgets.Widget(); |
8 const Controller = function (ns) { |
9 |
9 return class extends ns.Widgets.Widget { |
10 IriSP.Widgets.Controller.prototype.defaults = { |
10 constructor(player, config) { |
11 disable_annotate_btn: false, |
11 super(player, config); |
12 disable_search_btn: false, |
12 this.lastSearchValue = ""; |
13 disable_ctrl_f: false, |
13 } |
14 disable_fullscreen : true, |
14 |
15 always_show_search: false, |
15 static defaults = { |
16 enable_quiz_toggle: undefined |
16 disable_annotate_btn: false, |
17 }; |
17 disable_search_btn: false, |
18 |
18 disable_ctrl_f: false, |
19 IriSP.Widgets.Controller.prototype.template = |
19 disable_fullscreen: true, |
20 '<div class="Ldt-Ctrl">' |
20 always_show_search: false, |
21 + '<div class="Ldt-Ctrl-Left">' |
21 enable_quiz_toggle: undefined, |
22 + '<div class="Ldt-Ctrl-button Ldt-Ctrl-Play Ldt-Ctrl-Play-PlayState Ldt-TraceMe" title="{{l10n.play_pause}}"></div>' |
22 }; |
23 + '<div class="Ldt-Ctrl-spacer"></div>' |
23 |
24 + '{{^disable_annotate_btn}}' |
24 static template = |
25 + '<div class="Ldt-Ctrl-button Ldt-Ctrl-Annotate Ldt-TraceMe" title="{{l10n.annotate}}"></div>' |
25 '<div class="Ldt-Ctrl">' + |
26 + '<div class="Ldt-Ctrl-spacer"></div>' |
26 '<div class="Ldt-Ctrl-Left">' + |
27 + '{{/disable_annotate_btn}}' |
27 '<div class="Ldt-Ctrl-button Ldt-Ctrl-Play Ldt-Ctrl-Play-PlayState Ldt-TraceMe" title="{{l10n.play_pause}}"></div>' + |
28 + '{{^disable_search_btn}}' |
28 '<div class="Ldt-Ctrl-spacer"></div>' + |
29 + '<div class="Ldt-Ctrl-button Ldt-Ctrl-SearchBtn Ldt-TraceMe" title="{{l10n.search}}"></div>' |
29 "{{^disable_annotate_btn}}" + |
30 + '{{/disable_search_btn}}' |
30 '<div class="Ldt-Ctrl-button Ldt-Ctrl-Annotate Ldt-TraceMe" title="{{l10n.annotate}}"></div>' + |
31 + '<div class="Ldt-Ctrl-Search">' |
31 '<div class="Ldt-Ctrl-spacer"></div>' + |
32 + '<input placeholder="{{ l10n.search }}" type="search" class="Ldt-Ctrl-SearchInput Ldt-TraceMe"></input>' |
32 "{{/disable_annotate_btn}}" + |
33 + '</div>' |
33 "{{^disable_search_btn}}" + |
34 + '<div class="Ldt-Ctrl-Quiz-Enable Ldt-TraceMe" title="Activer/Désactiver le quiz"></div>' |
34 '<div class="Ldt-Ctrl-button Ldt-Ctrl-SearchBtn Ldt-TraceMe" title="{{l10n.search}}"></div>' + |
35 + '<div class="Ldt-Ctrl-Quiz-Create Ldt-TraceMe" ></div>' |
35 "{{/disable_search_btn}}" + |
36 + '</div>' |
36 '<div class="Ldt-Ctrl-Search">' + |
37 + '<div class="Ldt-Ctrl-Right">' |
37 '<input placeholder="{{ l10n.search }}" type="search" class="Ldt-Ctrl-SearchInput Ldt-TraceMe"></input>' + |
38 + '{{^disable_fullscreen}}<div class="Ldt-Ctrl-Fullscreen-Button Ldt-TraceMe" title="Passer le lecteur en plein-écran"></div{{/disable_fullscreen}}' |
38 "</div>" + |
39 + '<div class="Ldt-Ctrl-spacer"></div>' |
39 '<div class="Ldt-Ctrl-Quiz-Enable Ldt-TraceMe" title="Activer/Désactiver le quiz"></div>' + |
40 + '<div class="Ldt-Ctrl-Time">' |
40 '<div class="Ldt-Ctrl-Quiz-Create Ldt-TraceMe" ></div>' + |
41 + '<div class="Ldt-Ctrl-Time-Elapsed" title="{{l10n.elapsed_time}}">00:00</div>' |
41 "</div>" + |
42 + '<div class="Ldt-Ctrl-Time-Separator">/</div>' |
42 '<div class="Ldt-Ctrl-Right">' + |
43 + '<div class="Ldt-Ctrl-Time-Total" title="{{l10n.total_time}}">00:00</div>' |
43 '{{^disable_fullscreen}}<div class="Ldt-Ctrl-Fullscreen-Button Ldt-TraceMe" title="Passer le lecteur en plein-écran"></div{{/disable_fullscreen}}' + |
44 + '</div>' |
44 '<div class="Ldt-Ctrl-spacer"></div>' + |
45 + '<div class="Ldt-Ctrl-spacer"></div>' |
45 '<div class="Ldt-Ctrl-Time">' + |
46 + '<div class="Ldt-Ctrl-button Ldt-Ctrl-Sound Ldt-Ctrl-Sound-Full Ldt-TraceMe" title="{{l10n.mute_unmute}}"></div>' |
46 '<div class="Ldt-Ctrl-Time-Elapsed" title="{{l10n.elapsed_time}}">00:00</div>' + |
47 + '</div>' |
47 '<div class="Ldt-Ctrl-Time-Separator">/</div>' + |
48 + '<div class="Ldt-Ctrl-Volume-Control" title="{{l10n.volume_control}}">' |
48 '<div class="Ldt-Ctrl-Time-Total" title="{{l10n.total_time}}">00:00</div>' + |
49 + '<div class="Ldt-Ctrl-Volume-Bar"></div>' |
49 "</div>" + |
50 + '</div>' |
50 '<div class="Ldt-Ctrl-spacer"></div>' + |
51 + '</div>'; |
51 '<div class="Ldt-Ctrl-button Ldt-Ctrl-Sound Ldt-Ctrl-Sound-Full Ldt-TraceMe" title="{{l10n.mute_unmute}}"></div>' + |
52 |
52 "</div>" + |
53 IriSP.Widgets.Controller.prototype.messages = { |
53 '<div class="Ldt-Ctrl-Volume-Control" title="{{l10n.volume_control}}">' + |
54 en: { |
54 '<div class="Ldt-Ctrl-Volume-Bar"></div>' + |
|
55 "</div>" + |
|
56 "</div>"; |
|
57 |
|
58 static messages = { |
|
59 en: { |
55 play_pause: "Play/Pause", |
60 play_pause: "Play/Pause", |
56 mute_unmute: "Mute/Unmute", |
61 mute_unmute: "Mute/Unmute", |
57 play: "Play", |
62 play: "Play", |
58 pause: "Pause", |
63 pause: "Pause", |
59 mute: "Mute", |
64 mute: "Mute", |
77 search: "Rechercher", |
82 search: "Rechercher", |
78 elapsed_time: "Temps écoulé", |
83 elapsed_time: "Temps écoulé", |
79 total_time: "Durée totale", |
84 total_time: "Durée totale", |
80 volume: "Niveau sonore", |
85 volume: "Niveau sonore", |
81 volume_control: "Réglage du niveau sonore", |
86 volume_control: "Réglage du niveau sonore", |
82 enable_quiz: "Activer le quiz" |
87 enable_quiz: "Activer le quiz", |
83 } |
88 }, |
84 }; |
89 }; |
85 |
90 |
86 IriSP.Widgets.Controller.prototype.draw = function() { |
91 draw() { |
87 var _this = this; |
92 var _this = this; |
88 this.renderTemplate(); |
93 this.renderTemplate(); |
89 |
94 |
90 // Define blocks |
95 // Define blocks |
91 this.$playButton = this.$.find(".Ldt-Ctrl-Play"); |
96 this.$playButton = this.$.find(".Ldt-Ctrl-Play"); |
92 this.$searchBlock = this.$.find(".Ldt-Ctrl-Search"); |
97 this.$searchBlock = this.$.find(".Ldt-Ctrl-Search"); |
93 this.$searchInput = this.$.find(".Ldt-Ctrl-SearchInput"); |
98 this.$searchInput = this.$.find(".Ldt-Ctrl-SearchInput"); |
94 this.$volumeBar = this.$.find(".Ldt-Ctrl-Volume-Bar"); |
99 this.$volumeBar = this.$.find(".Ldt-Ctrl-Volume-Bar"); |
95 |
100 |
96 // handle events |
101 // handle events |
97 this.onMediaEvent("play","playButtonUpdater"); |
102 this.onMediaEvent("play", "playButtonUpdater"); |
98 this.onMediaEvent("pause","playButtonUpdater"); |
103 this.onMediaEvent("pause", "playButtonUpdater"); |
99 this.onMediaEvent("volumechange","volumeUpdater"); |
104 this.onMediaEvent("volumechange", "volumeUpdater"); |
100 this.onMediaEvent("timeupdate","timeDisplayUpdater"); |
105 this.onMediaEvent("timeupdate", "timeDisplayUpdater"); |
101 this.onMediaEvent("loadedmetadata","volumeUpdater"); |
106 this.onMediaEvent("loadedmetadata", "volumeUpdater"); |
102 |
107 |
103 // handle clicks |
108 // handle clicks |
104 this.$playButton.click(this.functionWrapper("playHandler")); |
109 this.$playButton.click(this.functionWrapper("playHandler")); |
105 |
110 |
106 if (this.enable_quiz_toggle !== undefined) { |
111 if (this.enable_quiz_toggle !== undefined) { |
107 if (this.enable_quiz_toggle) { |
112 if (this.enable_quiz_toggle) { |
108 this.$.find(".Ldt-Ctrl-Quiz-Enable").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
113 this.$.find(".Ldt-Ctrl-Quiz-Enable").addClass( |
109 this.$.find(".Ldt-Ctrl-Quiz-Create").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
114 "Ldt-Ctrl-Quiz-Toggle-Active" |
110 // this.player.trigger("QuizCreator.show"); |
115 ); |
111 this.$.find("#QuizEditContainer").show(); |
116 this.$.find(".Ldt-Ctrl-Quiz-Create").addClass( |
|
117 "Ldt-Ctrl-Quiz-Toggle-Active" |
|
118 ); |
|
119 // this.player.trigger("QuizCreator.show"); |
|
120 this.$.find("#QuizEditContainer").show(); |
|
121 } else { |
|
122 this.$.find(".Ldt-Ctrl-Quiz-Enable").removeClass( |
|
123 "Ldt-Ctrl-Quiz-Toggle-Active" |
|
124 ); |
|
125 this.$.find(".Ldt-Ctrl-Quiz-Create").removeClass( |
|
126 "Ldt-Ctrl-Quiz-Toggle-Active" |
|
127 ); |
|
128 this.player.trigger("QuizCreator.hide"); |
|
129 this.$.find("#QuizEditContainer").hide(); |
112 } |
130 } |
113 else |
131 } else { |
114 { |
132 this.$.find(".Ldt-Ctrl-Quiz-Enable").hide(); |
115 this.$.find(".Ldt-Ctrl-Quiz-Enable").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
133 } |
116 this.$.find(".Ldt-Ctrl-Quiz-Create").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
134 |
117 this.player.trigger("QuizCreator.hide"); |
135 this.$.find(".Ldt-Ctrl-Annotate").click(function () { |
118 this.$.find("#QuizEditContainer").hide(); |
136 _this.player.trigger("CreateAnnotation.toggle"); |
|
137 }); |
|
138 this.$.find(".Ldt-Ctrl-SearchBtn").click( |
|
139 this.functionWrapper("searchButtonHandler") |
|
140 ); |
|
141 |
|
142 this.$searchInput.keyup(this.functionWrapper("searchHandler")); |
|
143 this.$searchInput.on("search", this.functionWrapper("searchHandler")); |
|
144 |
|
145 // Fullscreen handling |
|
146 this.$.find(".Ldt-Ctrl-Fullscreen-Button").click( |
|
147 this.functionWrapper("toggleFullscreen") |
|
148 ); |
|
149 var fullscreen_event_name = ns.getFullscreenEventname(); |
|
150 if (fullscreen_event_name) { |
|
151 document.addEventListener(fullscreen_event_name, function () { |
|
152 if (ns.isFullscreen() && ns.getFullscreenElement() == _this.$[0]) { |
|
153 _this.$.addClass("Ldt-Fullscreen-Element"); |
|
154 } else { |
|
155 _this.$.removeClass("Ldt-Fullscreen-Element"); |
|
156 } |
|
157 }); |
|
158 } |
|
159 |
|
160 // Quiz activation |
|
161 this.$.find(".Ldt-Ctrl-Quiz-Enable").click( |
|
162 this.functionWrapper("toggleQuiz") |
|
163 ); |
|
164 this.$.find(".Ldt-Ctrl-Quiz-Create").click( |
|
165 this.functionWrapper("createQuiz") |
|
166 ); |
|
167 |
|
168 var _volctrl = this.$.find(".Ldt-Ctrl-Volume-Control"); |
|
169 this.$.find(".Ldt-Ctrl-Sound") |
|
170 .click(this.functionWrapper("muteHandler")) |
|
171 .mouseover(function () { |
|
172 _volctrl.show(); |
|
173 }) |
|
174 .mouseout(function () { |
|
175 _volctrl.hide(); |
|
176 }); |
|
177 _volctrl |
|
178 .mouseover(function () { |
|
179 _volctrl.show(); |
|
180 }) |
|
181 .mouseout(function () { |
|
182 _volctrl.hide(); |
|
183 }); |
|
184 |
|
185 // Handle CTRL-F |
|
186 if (!this.disable_ctrl_f) { |
|
187 var _fKey = "F".charCodeAt(0), |
|
188 _lastCtrlFTime = 0; |
|
189 jQuery(document).keydown(function (_event) { |
|
190 if (_event.keyCode === _fKey && (_event.ctrlKey || _event.metaKey)) { |
|
191 var _time = jQuery.now(); |
|
192 if (_time - _lastCtrlFTime > 2000) { |
|
193 _this.searchButtonHandler(); |
|
194 } |
|
195 _lastCtrlFTime = _time; |
|
196 return false; |
|
197 } |
|
198 }); |
|
199 } |
|
200 |
|
201 // Allow Volume Cursor Dragging |
|
202 this.$volumeBar.slider({ |
|
203 slide: function (event, ui) { |
|
204 _this.$volumeBar.attr( |
|
205 "title", |
|
206 _this.l10n.volume + ": " + ui.value + "%" |
|
207 ); |
|
208 _this.media.setVolume(ui.value / 100); |
|
209 }, |
|
210 stop: this.functionWrapper("volumeUpdater"), |
|
211 }); |
|
212 |
|
213 // trigger an ns.Player.MouseOver to the widgets that are interested (i.e : sliderWidget) |
|
214 this.$.hover( |
|
215 function () { |
|
216 _this.player.trigger("Player.MouseOver"); |
|
217 }, |
|
218 function () { |
|
219 _this.player.trigger("Player.MouseOut"); |
119 } |
220 } |
120 } else { |
221 ); |
121 this.$.find(".Ldt-Ctrl-Quiz-Enable").hide(); |
222 |
122 } |
223 this.timeDisplayUpdater(new ns.Model.Time(0)); |
123 |
224 |
124 this.$.find(".Ldt-Ctrl-Annotate").click(function() { |
225 var annotations = this.source.getAnnotations(); |
125 _this.player.trigger("CreateAnnotation.toggle"); |
226 annotations.on("search", function (_text) { |
126 }); |
|
127 this.$.find(".Ldt-Ctrl-SearchBtn").click(this.functionWrapper("searchButtonHandler")); |
|
128 |
|
129 this.$searchInput.keyup(this.functionWrapper("searchHandler")); |
|
130 this.$searchInput.on("search", this.functionWrapper("searchHandler")); |
|
131 |
|
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"); |
|
150 this.$.find('.Ldt-Ctrl-Sound') |
|
151 .click(this.functionWrapper("muteHandler")) |
|
152 .mouseover(function() { |
|
153 _volctrl.show(); |
|
154 }) |
|
155 .mouseout(function() { |
|
156 _volctrl.hide(); |
|
157 }); |
|
158 _volctrl.mouseover(function() { |
|
159 _volctrl.show(); |
|
160 }).mouseout(function() { |
|
161 _volctrl.hide(); |
|
162 }); |
|
163 |
|
164 // Handle CTRL-F |
|
165 if (!this.disable_ctrl_f) { |
|
166 var _fKey = "F".charCodeAt(0), |
|
167 _lastCtrlFTime = 0; |
|
168 IriSP.jQuery(document).keydown(function(_event) { |
|
169 if (_event.keyCode === _fKey && (_event.ctrlKey || _event.metaKey)) { |
|
170 var _time = IriSP.jQuery.now(); |
|
171 if (_time - _lastCtrlFTime > 2000) { |
|
172 _this.searchButtonHandler(); |
|
173 } |
|
174 _lastCtrlFTime = _time; |
|
175 return false; |
|
176 } |
|
177 }); |
|
178 } |
|
179 |
|
180 // Allow Volume Cursor Dragging |
|
181 this.$volumeBar.slider({ |
|
182 slide: function(event, ui) { |
|
183 _this.$volumeBar.attr("title",_this.l10n.volume+': ' + ui.value + '%'); |
|
184 _this.media.setVolume(ui.value / 100); |
|
185 }, |
|
186 stop: this.functionWrapper("volumeUpdater") |
|
187 }); |
|
188 |
|
189 // trigger an IriSP.Player.MouseOver to the widgets that are interested (i.e : sliderWidget) |
|
190 this.$.hover( |
|
191 function() { |
|
192 _this.player.trigger("Player.MouseOver"); |
|
193 }, |
|
194 function() { |
|
195 _this.player.trigger("Player.MouseOut"); |
|
196 }); |
|
197 |
|
198 this.timeDisplayUpdater(new IriSP.Model.Time(0)); |
|
199 |
|
200 var annotations = this.source.getAnnotations(); |
|
201 annotations.on("search", function(_text) { |
|
202 _this.$searchInput.val(_text); |
227 _this.$searchInput.val(_text); |
203 _this.showSearchBlock(); |
228 _this.showSearchBlock(); |
204 }); |
229 }); |
205 annotations.on("found", function(_text) { |
230 annotations.on("found", function (_text) { |
206 _this.$searchInput.css('background-color','#e1ffe1'); |
231 _this.$searchInput.css("background-color", "#e1ffe1"); |
207 }); |
232 }); |
208 annotations.on("not-found", function(_text) { |
233 annotations.on("not-found", function (_text) { |
209 _this.$searchInput.css('background-color', "#d62e3a"); |
234 _this.$searchInput.css("background-color", "#d62e3a"); |
210 }); |
235 }); |
211 annotations.on("search-cleared", function() { |
236 annotations.on("search-cleared", function () { |
212 _this.hideSearchBlock(); |
237 _this.hideSearchBlock(); |
213 }); |
238 }); |
214 if (_this.always_show_search) { |
239 if (_this.always_show_search) { |
215 _this.showSearchBlock(); |
240 _this.showSearchBlock(); |
216 } |
241 } |
217 }; |
242 } |
218 |
243 |
219 /* Update the elasped time div */ |
244 /* Update the elasped time div */ |
220 IriSP.Widgets.Controller.prototype.timeDisplayUpdater = function(_time) { |
245 timeDisplayUpdater(_time) { |
221 |
246 // we get it at each call because it may change. |
222 // we get it at each call because it may change. |
247 var _totalTime = this.media.duration; |
223 var _totalTime = this.media.duration; |
248 this.$.find(".Ldt-Ctrl-Time-Elapsed").html(_time.toString()); |
224 this.$.find(".Ldt-Ctrl-Time-Elapsed").html(_time.toString()); |
249 this.$.find(".Ldt-Ctrl-Time-Total").html(_totalTime.toString()); |
225 this.$.find(".Ldt-Ctrl-Time-Total").html(_totalTime.toString()); |
250 } |
226 }; |
251 |
227 |
252 /* update the icon of the button - separate function from playHandler |
228 /* update the icon of the button - separate function from playHandler |
|
229 because in some cases (for instance, when the user directly clicks on |
253 because in some cases (for instance, when the user directly clicks on |
230 the jwplayer window) we have to change the icon without playing/pausing |
254 the jwplayer window) we have to change the icon without playing/pausing |
231 */ |
255 */ |
232 IriSP.Widgets.Controller.prototype.playButtonUpdater = function() { |
256 playButtonUpdater() { |
233 if (this.media.getPaused()) { |
257 if (this.media.getPaused()) { |
234 /* the background sprite is changed by adding/removing the correct classes */ |
258 /* the background sprite is changed by adding/removing the correct classes */ |
235 this.$playButton |
259 this.$playButton |
236 .attr("title", this.l10n.play) |
260 .attr("title", this.l10n.play) |
237 .removeClass("Ldt-Ctrl-Play-PauseState") |
261 .removeClass("Ldt-Ctrl-Play-PauseState") |
238 .addClass("Ldt-Ctrl-Play-PlayState"); |
262 .addClass("Ldt-Ctrl-Play-PlayState"); |
239 } else { |
263 } else { |
240 this.$playButton |
264 this.$playButton |
241 .attr("title", this.l10n.pause) |
265 .attr("title", this.l10n.pause) |
242 .removeClass("Ldt-Ctrl-Play-PlayState") |
266 .removeClass("Ldt-Ctrl-Play-PlayState") |
243 .addClass("Ldt-Ctrl-Play-PauseState"); |
267 .addClass("Ldt-Ctrl-Play-PauseState"); |
244 } |
268 } |
245 }; |
269 } |
246 |
270 |
247 //FullScreen |
271 //FullScreen |
248 IriSP.Widgets.Controller.prototype.toggleFullscreen = function() { |
272 toggleFullscreen() { |
249 if (IriSP.isFullscreen()) { |
273 if (ns.isFullscreen()) { |
250 IriSP.setFullScreen(this.$[0], false); |
274 ns.setFullScreen(this.$[0], false); |
251 } else { |
275 } else { |
252 IriSP.setFullScreen(this.$[0], true); |
276 ns.setFullScreen(this.$[0], true); |
253 } |
277 } |
254 }; |
278 } |
255 |
279 |
256 //Quiz |
280 //Quiz |
257 IriSP.Widgets.Controller.prototype.createQuiz = function() { |
281 createQuiz() { |
258 this.player.trigger("Quiz.hide"); |
282 this.player.trigger("Quiz.hide"); |
259 this.media.pause(); |
283 this.media.pause(); |
260 this.player.trigger("QuizCreator.create"); |
284 this.player.trigger("QuizCreator.create"); |
261 }; |
285 } |
262 |
286 |
263 IriSP.Widgets.Controller.prototype.toggleQuiz = function() { |
287 toggleQuiz() { |
264 this.enable_quiz_toggle = !this.enable_quiz_toggle; |
288 this.enable_quiz_toggle = !this.enable_quiz_toggle; |
265 if (this.enable_quiz_toggle) { |
289 if (this.enable_quiz_toggle) { |
266 $(".Ldt-Ctrl-Quiz-Enable").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
290 $(".Ldt-Ctrl-Quiz-Enable").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
267 $(".Ldt-Ctrl-Quiz-Create").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
291 $(".Ldt-Ctrl-Quiz-Create").addClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
268 this.player.trigger("Quiz.activate"); |
292 this.player.trigger("Quiz.activate"); |
269 } |
293 } else { |
270 else |
|
271 { |
|
272 $(".Ldt-Ctrl-Quiz-Enable").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
294 $(".Ldt-Ctrl-Quiz-Enable").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
273 $(".Ldt-Ctrl-Quiz-Create").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
295 $(".Ldt-Ctrl-Quiz-Create").removeClass("Ldt-Ctrl-Quiz-Toggle-Active"); |
274 this.player.trigger("Quiz.deactivate"); |
296 this.player.trigger("Quiz.deactivate"); |
275 this.player.trigger("QuizCreator.hide"); |
297 this.player.trigger("QuizCreator.hide"); |
276 } |
298 } |
277 }; |
299 } |
278 |
300 |
279 IriSP.Widgets.Controller.prototype.playHandler = function() { |
301 playHandler() { |
280 if (this.media.getPaused()) { |
302 if (this.media.getPaused()) { |
281 this.media.play(); |
303 this.media.play(); |
282 } else { |
304 } else { |
283 this.media.pause(); |
305 this.media.pause(); |
284 } |
306 } |
285 }; |
307 } |
286 |
308 |
287 IriSP.Widgets.Controller.prototype.muteHandler = function() { |
309 muteHandler() { |
288 this.media.setMuted(!this.media.getMuted()); |
310 this.media.setMuted(!this.media.getMuted()); |
289 }; |
311 } |
290 |
312 |
291 IriSP.Widgets.Controller.prototype.volumeUpdater = function() { |
313 volumeUpdater() { |
292 var _muted = this.media.getMuted(), |
314 var _muted = this.media.getMuted(), |
293 _vol = this.media.getVolume(); |
315 _vol = this.media.getVolume(); |
294 if (_vol === false) { |
316 if (_vol === false) { |
295 _vol = .5; |
317 _vol = 0.5; |
296 } |
318 } |
297 var _soundCtl = this.$.find(".Ldt-Ctrl-Sound"); |
319 var _soundCtl = this.$.find(".Ldt-Ctrl-Sound"); |
298 _soundCtl.removeClass("Ldt-Ctrl-Sound-Mute Ldt-Ctrl-Sound-Half Ldt-Ctrl-Sound-Full"); |
320 _soundCtl.removeClass( |
299 if (_muted) { |
321 "Ldt-Ctrl-Sound-Mute Ldt-Ctrl-Sound-Half Ldt-Ctrl-Sound-Full" |
300 _soundCtl.attr("title", this.l10n.unmute) |
322 ); |
301 .addClass("Ldt-Ctrl-Sound-Mute"); |
323 if (_muted) { |
302 } else { |
324 _soundCtl |
303 _soundCtl.attr("title", this.l10n.mute) |
325 .attr("title", this.l10n.unmute) |
304 .addClass(_vol < .5 ? "Ldt-Ctrl-Sound-Half" : "Ldt-Ctrl-Sound-Full" ); |
326 .addClass("Ldt-Ctrl-Sound-Mute"); |
305 } |
327 } else { |
306 this.$volumeBar.slider("value", _muted ? 0 : 100 * _vol); |
328 _soundCtl |
307 }; |
329 .attr("title", this.l10n.mute) |
308 |
330 .addClass(_vol < 0.5 ? "Ldt-Ctrl-Sound-Half" : "Ldt-Ctrl-Sound-Full"); |
309 IriSP.Widgets.Controller.prototype.showSearchBlock = function() { |
331 } |
310 this.$searchBlock.animate({ width:"160px" }, 200); |
332 this.$volumeBar.slider("value", _muted ? 0 : 100 * _vol); |
311 this.$searchInput.css('background-color','#fff'); |
333 } |
312 this.$searchInput.focus(); |
334 |
313 }; |
335 showSearchBlock() { |
314 |
336 this.$searchBlock.animate({ width: "160px" }, 200); |
315 IriSP.Widgets.Controller.prototype.hideSearchBlock = function() { |
337 this.$searchInput.css("background-color", "#fff"); |
316 if (! this.always_show_search) { |
338 this.$searchInput.focus(); |
317 this.$searchBlock.animate( { width: 0 }, 200); |
339 } |
318 } |
340 |
319 }; |
341 hideSearchBlock() { |
320 |
342 if (!this.always_show_search) { |
321 /** react to clicks on the search button */ |
343 this.$searchBlock.animate({ width: 0 }, 200); |
322 IriSP.Widgets.Controller.prototype.searchButtonHandler = function() { |
344 } |
323 if ( !this.$searchBlock.width() ) { |
345 } |
|
346 |
|
347 /** react to clicks on the search button */ |
|
348 searchButtonHandler() { |
|
349 if (!this.$searchBlock.width()) { |
324 this.showSearchBlock(); |
350 this.showSearchBlock(); |
325 var _val = this.$searchInput.val(); |
351 var _val = this.$searchInput.val(); |
326 if (_val) { |
352 if (_val) { |
327 this.source.getAnnotations().search(_val); |
353 this.source.getAnnotations().search(_val); |
328 } |
354 } |
329 } else { |
355 } else { |
330 this.hideSearchBlock(); |
356 this.hideSearchBlock(); |
331 } |
357 } |
|
358 } |
|
359 |
|
360 /** this handler is called whenever the content of the search |
|
361 field changes */ |
|
362 searchHandler() { |
|
363 if (!this.$searchBlock.width()) { |
|
364 this.$searchBlock.css({ width: "160px" }); |
|
365 this.$searchInput.css("background-color", "#fff"); |
|
366 } |
|
367 var _val = this.$searchInput.val(); |
|
368 this._positiveMatch = false; |
|
369 |
|
370 // do nothing if the search field is empty, instead of highlighting everything. |
|
371 if (_val !== this.lastSearchValue) { |
|
372 if (_val) { |
|
373 this.source.getAnnotations().search(_val); |
|
374 } else { |
|
375 this.source.getAnnotations().trigger("clear-search"); |
|
376 this.$searchInput.css("background-color", ""); |
|
377 } |
|
378 } |
|
379 this.lastSearchValue = _val; |
|
380 } |
|
381 }; |
332 }; |
382 }; |
333 |
383 |
334 /** this handler is called whenever the content of the search |
384 export { Controller, controllerStyles }; |
335 field changes */ |
|
336 IriSP.Widgets.Controller.prototype.searchHandler = function() { |
|
337 if ( !this.$searchBlock.width() ) { |
|
338 this.$searchBlock.css({ width:"160px" }); |
|
339 this.$searchInput.css('background-color','#fff'); |
|
340 } |
|
341 var _val = this.$searchInput.val(); |
|
342 this._positiveMatch = false; |
|
343 |
|
344 // do nothing if the search field is empty, instead of highlighting everything. |
|
345 if (_val !== this.lastSearchValue) { |
|
346 if (_val) { |
|
347 this.source.getAnnotations().search(_val); |
|
348 } else { |
|
349 this.source.getAnnotations().trigger("clear-search"); |
|
350 this.$searchInput.css('background-color',''); |
|
351 } |
|
352 } |
|
353 this.lastSearchValue = _val; |
|
354 }; |
|