| author | Anthony Ly <anthonyly.com@gmail.com> |
| Tue, 04 Jun 2013 12:50:33 +0200 | |
| changeset 74 | 22aca5b735a2 |
| parent 63 | 55b26d1c32ef |
| child 101 | e40637c085b0 |
| permissions | -rw-r--r-- |
| 25 | 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 |
activeTangle = $(this); |
|
10 |
activeTangle.addClass("active"); |
|
11 |
tangleStartVal = +activeTangle.attr("data-milliseconds"); |
|
12 |
tangleStartX = evt.pageX; |
|
13 |
tangleHasMoved = false; |
|
| 28 | 14 |
$(this).parents('td').siblings('td').find(".time-tangle").addClass("deactivate"); |
| 25 | 15 |
return false; |
16 |
}); |
|
| 28 | 17 |
|
| 25 | 18 |
$(document) |
19 |
.mousemove(function(evt) { |
|
20 |
if (activeTangle) { |
|
21 |
tangleHasMoved = true; |
|
22 |
var newval = new IriSP.Model.Time(tangleMsPerPixel * (evt.pageX - tangleStartX) + tangleStartVal); |
|
23 |
activeTangle.trigger("valuechange", newval); |
|
24 |
return false; |
|
25 |
} |
|
26 |
}) |
|
27 |
.mouseup(function() { |
|
28 |
if (activeTangle) { |
|
29 |
$(".time-tangle").removeClass("active deactivate"); |
|
30 |
activeTangle = undefined; |
|
31 |
} |
|
32 |
}); |
|
| 28 | 33 |
|
34 |
function updateRenderChapter(chapterData){ |
|
35 |
var segment = $('.chapter-segments li#'+chapterData.id), |
|
36 |
wChapterSegmentWrap = $('.chapter-segments').width(), |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
63
diff
changeset
|
37 |
wSegmentNew = chapterData.getDuration() * wChapterSegmentWrap / myMedia.duration, |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
63
diff
changeset
|
38 |
lSegmentNew = chapterData.begin * wChapterSegmentWrap / myMedia.duration, |
| 28 | 39 |
row = $('#row-list-chapter-'+chapterData.id), |
40 |
form = ($('#form-chapter-edit-'+chapterData.id).length) ? $('#form-chapter-edit-'+chapterData.id) : false; |
|
41 |
||
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
63
diff
changeset
|
42 |
segment.css({ |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
63
diff
changeset
|
43 |
width : wSegmentNew, |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
63
diff
changeset
|
44 |
left : lSegmentNew |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
63
diff
changeset
|
45 |
}); |
| 28 | 46 |
|
47 |
row.find('.begin').text(chapterData.begin); |
|
48 |
row.find('.duration').text(chapterData.getDuration()); |
|
49 |
row.find('.end').text(chapterData.end); |
|
50 |
||
51 |
if(form){ |
|
52 |
form.find('.begin').text(chapterData.begin); |
|
53 |
form.find('.begin').attr('data-milliseconds',chapterData.begin); |
|
54 |
form.find('.duration').text(chapterData.getDuration()); |
|
55 |
form.find('.end').text(chapterData.end); |
|
56 |
form.find('.end').attr('data-milliseconds',chapterData.end); |
|
57 |
} |
|
58 |
} |
|
59 |
||
60 |
function updateChapterDuration(val, chapterBefore, chapterAfter){ |
|
| 63 | 61 |
if (val<=chapterAfter.end && val>=chapterBefore.begin) { |
| 28 | 62 |
chapterAfter.setBegin(val); |
63 |
chapterBefore.setEnd(val); |
|
64 |
||
65 |
updateRenderChapter(chapterAfter); |
|
66 |
updateRenderChapter(chapterBefore); |
|
67 |
} |
|
68 |
} |
|
69 |
||
70 |
$('.chapter-widget-info').on('valuechange', '.tangle-start', function(evt, val){ |
|
71 |
var indexChapter = _.indexOf(chapters, currentChapter); |
|
72 |
if(indexChapter == 0 || chapters.length<=1) return; |
|
| 25 | 73 |
|
| 28 | 74 |
var chapterBefore = chapters[indexChapter-1], |
75 |
chapterAfter = currentChapter; |
|
76 |
||
77 |
updateChapterDuration(val, chapterBefore, chapterAfter); |
|
78 |
}); |
|
79 |
||
80 |
$('.chapter-widget-info').on('valuechange', '.tangle-end', function(evt, val){ |
|
81 |
var indexChapter = _.indexOf(chapters, currentChapter); |
|
82 |
if(indexChapter == chapters.length-1 || chapters.length<=1) return; |
|
83 |
|
|
84 |
var chapterAfter = chapters[indexChapter+1], |
|
85 |
chapterBefore = currentChapter; |
|
86 |
|
|
87 |
updateChapterDuration(val, chapterBefore, chapterAfter); |
|
88 |
}); |
|
89 |
/* |
|
| 25 | 90 |
$(".tangle-start") |
91 |
.mouseup(function(evt) { |
|
| 28 | 92 |
|
| 25 | 93 |
if (!tangleHasMoved && currentMedia && currentSegment) { |
94 |
currentMedia.setCurrentTime(currentSegment.begin); |
|
95 |
} |
|
96 |
}) |
|
97 |
.on("valuechange", function(evt, val) { |
|
| 28 | 98 |
|
| 25 | 99 |
if (currentMedia && currentSegment) { |
100 |
currentSegment.setBegin(val); |
|
101 |
} |
|
102 |
}); |
|
| 28 | 103 |
|
| 25 | 104 |
$(".tangle-end") |
105 |
.mouseup(function(evt) { |
|
106 |
if (!tangleHasMoved && currentMedia && currentSegment) { |
|
107 |
currentMedia.setCurrentTime(currentSegment.end); |
|
108 |
} |
|
109 |
}) |
|
110 |
.on("valuechange", function(evt, val) { |
|
111 |
if (currentMedia && currentSegment) { |
|
112 |
currentSegment.setEnd(val); |
|
113 |
} |
|
114 |
}); |
|
115 |
$(".tangle-duration").on("valuechange", function(evt, val) { |
|
116 |
if (currentMedia && currentSegment) { |
|
117 |
currentSegment.setDuration(val); |
|
118 |
} |
|
| 28 | 119 |
|
120 |
}); */ |