|
1 /* Tangles */ |
|
2 var tangleMsPerPixel = 100, |
|
3 activeTangle, |
|
4 tangleStartX, |
|
5 tangleStartVal, |
|
6 tangleHasMoved; |
|
7 |
|
8 $('.chapter-widget-info').on('mousedown', '.time-tangle', function(evt){ |
|
9 // $(".time-tangle").mousedown(function(evt) { |
|
10 |
|
11 activeTangle = $(this); |
|
12 activeTangle.addClass("active"); |
|
13 tangleStartVal = +activeTangle.attr("data-milliseconds"); |
|
14 tangleStartX = evt.pageX; |
|
15 tangleHasMoved = false; |
|
16 $(this).siblings(".time-tangle").addClass("deactivate"); |
|
17 return false; |
|
18 }); |
|
19 $(document) |
|
20 .mousemove(function(evt) { |
|
21 if (activeTangle) { |
|
22 tangleHasMoved = true; |
|
23 var newval = new IriSP.Model.Time(tangleMsPerPixel * (evt.pageX - tangleStartX) + tangleStartVal); |
|
24 activeTangle.trigger("valuechange", newval); |
|
25 return false; |
|
26 } |
|
27 }) |
|
28 .mouseup(function() { |
|
29 if (activeTangle) { |
|
30 activeTangle.text(activeTangle.text().replace(/\.\d+$/,'')); |
|
31 $(".time-tangle").removeClass("active deactivate"); |
|
32 activeTangle = undefined; |
|
33 } |
|
34 }); |
|
35 |
|
36 $(".tangle-start") |
|
37 .mouseup(function(evt) { |
|
38 if (!tangleHasMoved && currentMedia && currentSegment) { |
|
39 currentMedia.setCurrentTime(currentSegment.begin); |
|
40 } |
|
41 }) |
|
42 .on("valuechange", function(evt, val) { |
|
43 if (currentMedia && currentSegment) { |
|
44 currentSegment.setBegin(val); |
|
45 } |
|
46 }); |
|
47 $(".tangle-end") |
|
48 .mouseup(function(evt) { |
|
49 if (!tangleHasMoved && currentMedia && currentSegment) { |
|
50 currentMedia.setCurrentTime(currentSegment.end); |
|
51 } |
|
52 }) |
|
53 .on("valuechange", function(evt, val) { |
|
54 if (currentMedia && currentSegment) { |
|
55 currentSegment.setEnd(val); |
|
56 } |
|
57 }); |
|
58 $(".tangle-duration").on("valuechange", function(evt, val) { |
|
59 if (currentMedia && currentSegment) { |
|
60 currentSegment.setDuration(val); |
|
61 } |
|
62 }); |