equal
deleted
inserted
replaced
1 IriSP.ArrowWidget = function(Popcorn, config, Serializer) { |
1 IriSP.ArrowWidget = function(Popcorn, config, Serializer) { |
2 IriSP.Widget.call(this, Popcorn, config, Serializer); |
2 IriSP.Widget.call(this, Popcorn, config, Serializer); |
3 |
3 |
4 this._oldAnnotation = null; |
4 this._oldAnnotation = null; |
5 |
5 this._blockArrow = false; |
6 }; |
6 }; |
7 |
7 |
8 |
8 |
9 IriSP.ArrowWidget.prototype = new IriSP.Widget(); |
9 IriSP.ArrowWidget.prototype = new IriSP.Widget(); |
10 |
10 |
17 |
17 |
18 IriSP.ArrowWidget.prototype.draw = function() { |
18 IriSP.ArrowWidget.prototype.draw = function() { |
19 var templ = Mustache.to_html(IriSP.arrowWidget_template, {}); |
19 var templ = Mustache.to_html(IriSP.arrowWidget_template, {}); |
20 this.selector.append(templ); |
20 this.selector.append(templ); |
21 this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.timeUpdateHandler)); |
21 this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.timeUpdateHandler)); |
|
22 this._Popcorn.listen("IriSP.ArrowWidget.blockArrow", IriSP.wrap(this, this.blockArrow)); |
|
23 this._Popcorn.listen("IriSP.ArrowWidget.releaseArrow", IriSP.wrap(this, this.releaseArrow)); |
|
24 |
22 }; |
25 }; |
23 |
26 |
24 IriSP.ArrowWidget.prototype.timeUpdateHandler = function(percents) { |
27 IriSP.ArrowWidget.prototype.timeUpdateHandler = function(percents) { |
|
28 if (this._blockArrow) |
|
29 return; |
|
30 |
25 var currentTime = this._Popcorn.currentTime(); |
31 var currentTime = this._Popcorn.currentTime(); |
26 var currentAnnotation = this._serializer.currentAnnotations(currentTime)[0]; // FIXME : use the others ? |
32 var currentAnnotation = this._serializer.currentAnnotations(currentTime)[0]; // FIXME : use the others ? |
27 |
33 |
28 /* move the arrow only if the current annotation changes */ |
34 /* move the arrow only if the current annotation changes */ |
29 if (currentAnnotation != this._oldAnnotation) { |
35 if (currentAnnotation != this._oldAnnotation) { |
64 |
70 |
65 this.selector.children(".Ldt-arrowWidget").animate({"left" : corrected_pixels + "px"}); |
71 this.selector.children(".Ldt-arrowWidget").animate({"left" : corrected_pixels + "px"}); |
66 |
72 |
67 this._oldAnnotation = currentAnnotation; |
73 this._oldAnnotation = currentAnnotation; |
68 } |
74 } |
69 } |
75 }; |
|
76 |
|
77 /** Block the arrow for instance when the user is annotating */ |
|
78 IriSP.ArrowWidget.prototype.blockArrow = function() { |
|
79 this._blockArrow = true; |
|
80 }; |
|
81 |
|
82 IriSP.ArrowWidget.prototype.releaseArrow = function() { |
|
83 this._blockArrow = false; |
|
84 }; |