| author | cavaliet |
| Thu, 02 Jan 2014 16:40:25 +0100 | |
| branch | new-model |
| changeset 1019 | 3ab36f402b0c |
| parent 928 | 5aadbc9f27cd |
| child 1020 | 198c2b79f5e1 |
| permissions | -rw-r--r-- |
| 880 | 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); |
|
| 924 | 7 |
this.sliding = false; |
| 880 | 8 |
}; |
9 |
||
10 |
IriSP.Widgets.Slice.prototype = new IriSP.Widgets.Widget(); |
|
11 |
||
12 |
IriSP.Widgets.Slice.prototype.defaults = { |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
13 |
show_arrow: false |
| 880 | 14 |
}; |
15 |
||
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
16 |
IriSP.Widgets.Slice.prototype.template = |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
17 |
'<div class="Ldt-Slice"></div>' |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
18 |
+ '{{#show_arrow}}<div class="Ldt-Slice-Arrow"></div>{{/show_arrow}}'; |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
19 |
|
| 880 | 20 |
IriSP.Widgets.Slice.prototype.draw = function() { |
21 |
|
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
22 |
this.renderTemplate(); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
23 |
|
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
24 |
this.$slider = this.$.find(".Ldt-Slice"); |
| 880 | 25 |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
26 |
if (this.show_arrow) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
27 |
this.insertSubwidget(this.$.find(".Ldt-Slice-Arrow"), { type: "Arrow" },"arrow"); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
28 |
} |
| 880 | 29 |
|
30 |
this.min = 0; |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
31 |
this.max = this.media.duration.valueOf(); |
| 880 | 32 |
|
| 924 | 33 |
var _this = this, |
34 |
_currentTime; |
|
| 880 | 35 |
|
36 |
this.$slider.slider({ |
|
37 |
range: true, |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
38 |
values: [0, this.max], |
| 880 | 39 |
min: 0, |
40 |
max: this.max, |
|
41 |
change: function(event, ui) { |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
42 |
if (_this.arrow) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
43 |
_this.arrow.moveToTime((ui.values[0]+ui.values[1])/2); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
44 |
} |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
45 |
if (_this.onBoundsChanged) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
46 |
_this.onBoundsChanged(ui.values[0],ui.values[1]); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
47 |
} |
| 923 | 48 |
}, |
49 |
start: function() { |
|
| 924 | 50 |
_this.sliding = true; |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
51 |
if (!_this.media.getPaused()) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
52 |
_this.media.pause(); |
| 923 | 53 |
} |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
54 |
_currentTime = _this.media.getCurrentTime(); |
| 924 | 55 |
}, |
56 |
slide: function(event, ui) { |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
57 |
_this.media.setCurrentTime(ui.value); |
| 924 | 58 |
}, |
59 |
stop: function() { |
|
60 |
_this.sliding = false; |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
61 |
_this.media.setCurrentTime(_currentTime); |
| 880 | 62 |
} |
63 |
}); |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
64 |
|
| 880 | 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"); |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
67 |
|
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
68 |
this.getWidgetAnnotations().forEach(function(_a) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
69 |
_a.on("enter", function() { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
70 |
_this.$slider.slider("values",[_a.begin, _a.end]); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
71 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
72 |
}); |
| 880 | 73 |
}; |
74 |
||
75 |
IriSP.Widgets.Slice.prototype.show = function() { |
|
76 |
this.$slider.show(); |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
77 |
}; |
| 880 | 78 |
|
79 |
IriSP.Widgets.Slice.prototype.hide = function() { |
|
80 |
this.$slider.hide(); |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
928
diff
changeset
|
81 |
}; |