|
1 /* |
|
2 The Slider Widget shows time position and allows seek |
|
3 */ |
|
4 |
|
5 IriSP.Widgets.Slice = function(player, config) { |
|
6 IriSP.Widgets.Widget.call(this, player, config); |
|
7 this.sliding = false; |
|
8 }; |
|
9 |
|
10 IriSP.Widgets.Slice.prototype = new IriSP.Widgets.Widget(); |
|
11 |
|
12 IriSP.Widgets.Slice.prototype.defaults = { |
|
13 show_arrow: false |
|
14 }; |
|
15 |
|
16 IriSP.Widgets.Slice.prototype.template = |
|
17 '<div class="Ldt-Slice"></div>' |
|
18 + '{{#show_arrow}}<div class="Ldt-Slice-Arrow"></div>{{/show_arrow}}'; |
|
19 |
|
20 IriSP.Widgets.Slice.prototype.draw = function() { |
|
21 |
|
22 this.renderTemplate(); |
|
23 |
|
24 this.$slider = this.$.find(".Ldt-Slice"); |
|
25 |
|
26 if (this.show_arrow) { |
|
27 this.insertSubwidget(this.$.find(".Ldt-Slice-Arrow"), { type: "Arrow" },"arrow"); |
|
28 } |
|
29 |
|
30 this.min = 0; |
|
31 this.max = this.media.duration.valueOf(); |
|
32 |
|
33 var _this = this, |
|
34 _currentTime; |
|
35 |
|
36 this.$slider.slider({ |
|
37 range: true, |
|
38 values: [0, this.max], |
|
39 min: 0, |
|
40 max: this.max, |
|
41 change: function(event, ui) { |
|
42 if (_this.arrow) { |
|
43 _this.arrow.moveToTime((ui.values[0]+ui.values[1])/2); |
|
44 } |
|
45 if (_this.onBoundsChanged) { |
|
46 _this.onBoundsChanged(ui.values[0],ui.values[1]); |
|
47 } |
|
48 }, |
|
49 start: function() { |
|
50 _this.sliding = true; |
|
51 if (!_this.media.getPaused()) { |
|
52 _this.media.pause(); |
|
53 } |
|
54 _currentTime = _this.media.getCurrentTime(); |
|
55 }, |
|
56 slide: function(event, ui) { |
|
57 _this.media.setCurrentTime(ui.value); |
|
58 }, |
|
59 stop: function() { |
|
60 _this.sliding = false; |
|
61 _this.media.setCurrentTime(_currentTime); |
|
62 } |
|
63 }); |
|
64 |
|
65 this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle"); |
|
66 this.$slider.find(".ui-slider-handle:last").addClass("Ldt-Slice-right-handle"); |
|
67 |
|
68 this.getWidgetAnnotations().forEach(function(_a) { |
|
69 _a.on("enter", function() { |
|
70 _this.$slider.slider("values",[_a.begin, _a.end]); |
|
71 }); |
|
72 }); |
|
73 }; |
|
74 |
|
75 IriSP.Widgets.Slice.prototype.show = function() { |
|
76 this.$slider.show(); |
|
77 }; |
|
78 |
|
79 IriSP.Widgets.Slice.prototype.hide = function() { |
|
80 this.$slider.hide(); |
|
81 }; |