forked from marisademeglio/media-overlays-js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmo-highlighter-view.js
50 lines (37 loc) · 1.05 KB
/
mo-highlighter-view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
MOHighligher = Backbone.View.extend({
el: "#readium-content-container",
initialize: function() {
this.model.on("change:text_hash", this.highlight, this);
this.model.on("change:playing", this.highlight, this);
this.model.on("change:highlight_progress", this.toggleHighlights, this);
},
highlight: function() {
if(this.model.shouldHighlight()) {
var selector = "#" + this.model.get("text_hash");
this.$(selector).addClass('readium-highlight');
}
},
toggleHighlights: function() {
this.$('.readium-highlight').toggleClass("readium-highlight", this.model.shouldHighlight());
}
});
MOPlayerView = Backbone.View.extend({
el: "#readium-mo-player",
initialize: function() {
this.model.on("change:playing", this.render, this);
},
render: function() {
var playing = this.model.get("playing");
this.$('#play-btn').toggle(!playing);
this.$('#pause-btn').toggle(playing);
return this;
},
events: {
"click #play-btn": function(e) {
this.model.play();
},
"click #pause-btn": function(e) {
this.model.pause();
},
}
});