|
22
|
1 |
IriSP.Hashcut = function() { |
|
|
2 |
|
|
|
3 |
/* Load Media List */ |
|
|
4 |
|
|
|
5 |
var directory = new IriSP.Model.Directory(), |
|
|
6 |
project = directory.remoteSource({ |
|
|
7 |
url: "data/bpidata.json", |
|
|
8 |
serializer: IriSP.serializers.medialist |
|
|
9 |
}), |
|
|
10 |
mediatemplate = '<li class="item-video" data-media-id="{{id}}"><img src="{{thumbnail}}" alt="{{title}}" />' |
|
|
11 |
+ '<span class="video-info"><span class="title-video">{{title}}</span><span class="author">{{description}}</span>' |
|
|
12 |
+ '<span class="time-length">Durée : <span>{{duration}}</span></span></span></li>'; |
|
|
13 |
|
|
|
14 |
/* Fill left column with Media List */ |
|
|
15 |
|
|
|
16 |
project.onLoad(function() { |
|
|
17 |
var html = ''; |
|
|
18 |
project.getMedias().forEach(function(_m) { |
|
|
19 |
html += Mustache.to_html(mediatemplate, _m); |
|
13
|
20 |
}); |
|
22
|
21 |
$(".col-left .list-video").html(html); |
|
|
22 |
}); |
|
|
23 |
|
|
|
24 |
/* Search Media with left column form */ |
|
|
25 |
|
|
|
26 |
$(".col-left input").on("keyup change input paste", function() { |
|
|
27 |
var val = $(this).val(); |
|
|
28 |
if (val) { |
|
|
29 |
var find = IriSP.Model.regexpFromTextOrArray(val, true), |
|
|
30 |
replace = IriSP.Model.regexpFromTextOrArray(val, false); |
|
|
31 |
} |
|
|
32 |
$(".col-left .item-video").each(function() { |
|
|
33 |
var li = $(this), |
|
|
34 |
title = $(this).find(".title-video"), |
|
|
35 |
titletext = title.text(); |
|
|
36 |
if (val && find.test(titletext)) { |
|
|
37 |
title.html(titletext.replace(replace, '<span style="background: yellow;">$1</span>')); |
|
|
38 |
li.show(); |
|
|
39 |
} else { |
|
|
40 |
title.text(titletext); |
|
|
41 |
if (val) { |
|
|
42 |
li.hide(); |
|
13
|
43 |
} else { |
|
22
|
44 |
li.show(); |
|
13
|
45 |
} |
|
22
|
46 |
} |
|
|
47 |
}) |
|
|
48 |
}); |
|
|
49 |
|
|
|
50 |
/* Slider */ |
|
|
51 |
|
|
|
52 |
var timeSlider = $(".Ldt-Slider"); |
|
|
53 |
timeSlider.slider({ |
|
|
54 |
range: "min", |
|
|
55 |
value: 0, |
|
|
56 |
min: 0, |
|
|
57 |
max: 920, |
|
|
58 |
slide: function(event, ui) { |
|
|
59 |
console.log(ui.value); |
|
|
60 |
//TODO: Slide to correct Timecode |
|
|
61 |
} |
|
|
62 |
}); |
|
|
63 |
|
|
|
64 |
var timeSliderHandle = timeSlider.find('.ui-slider-handle'), |
|
|
65 |
timeSliderMaximized = false, |
|
|
66 |
timeSliderTimeoutId = false, |
|
|
67 |
timeSliderMinimizedHeight = 4, |
|
|
68 |
timeSliderMaximizedHeight = 10, |
|
|
69 |
timeSliderTimeoutDuration = 1500, |
|
|
70 |
timeTooltip = $(".Ldt-Slider-Time"); |
|
|
71 |
|
|
|
72 |
timeSlider.css(calculateSliderCss(timeSliderMinimizedHeight)); |
|
|
73 |
timeSliderHandle.css(calculateHandleCss(timeSliderMinimizedHeight)); |
|
|
74 |
|
|
|
75 |
function timeSliderMouseOver() { |
|
|
76 |
if (timeSliderTimeoutId) { |
|
|
77 |
window.clearTimeout(timeSliderTimeoutId); |
|
|
78 |
timeSliderTimeoutId = false; |
|
|
79 |
} |
|
|
80 |
if (!timeSliderMaximized) { |
|
|
81 |
timeSliderAnimateToHeight(timeSliderMaximizedHeight); |
|
|
82 |
timeSliderMaximized = true; |
|
|
83 |
} |
|
|
84 |
} |
|
|
85 |
|
|
|
86 |
function timeSliderMouseOut() { |
|
|
87 |
timeTooltip.hide(); |
|
|
88 |
if (timeSliderTimeoutId) { |
|
|
89 |
clearTimeout(timeSliderTimeoutId); |
|
|
90 |
timeSliderTimeoutId = false; |
|
|
91 |
} |
|
|
92 |
timeSliderTimeoutId = setTimeout(function() { |
|
|
93 |
if (timeSliderMaximized) { |
|
|
94 |
timeSliderAnimateToHeight(timeSliderMinimizedHeight); |
|
|
95 |
timeSliderMaximized = false; |
|
|
96 |
} |
|
|
97 |
timeSliderTimeoutId = false; |
|
|
98 |
}, timeSliderTimeoutDuration); |
|
|
99 |
} |
|
|
100 |
|
|
|
101 |
timeSlider |
|
|
102 |
.mouseover(function() { |
|
|
103 |
timeTooltip.show(); |
|
|
104 |
timeSliderMouseOver(); |
|
|
105 |
}) |
|
|
106 |
.mouseout(timeSliderMouseOut) |
|
|
107 |
.mousemove(function(_e) { |
|
|
108 |
var _x = _e.pageX - timeSlider.offset().left, |
|
|
109 |
_t = new IriSP.Model.Time(); // _this.media.duration * _x / _this.width |
|
|
110 |
timeTooltip.text(_t.toString()).css("left",_x); |
|
15
|
111 |
}); |
|
22
|
112 |
|
|
|
113 |
$(".Ldt-Ctrl").mouseover(timeSliderMouseOver).mouseout(timeSliderMouseOut); |
|
|
114 |
|
|
|
115 |
function timeSliderAnimateToHeight(_height) { |
|
|
116 |
timeSlider.stop().animate( |
|
|
117 |
calculateSliderCss(_height), |
|
|
118 |
500, |
|
|
119 |
function() { |
|
|
120 |
IriSP.jQuery(this).css("overflow","visible"); |
|
|
121 |
}); |
|
|
122 |
timeSliderHandle.stop().animate( |
|
|
123 |
calculateHandleCss(_height), |
|
|
124 |
500, |
|
|
125 |
function() { |
|
|
126 |
IriSP.jQuery(this).css("overflow","visible"); |
|
|
127 |
}); |
|
|
128 |
} |
|
|
129 |
|
|
|
130 |
function calculateSliderCss(_size) { |
|
|
131 |
return { |
|
|
132 |
height: _size + "px", |
|
|
133 |
"margin-top": (timeSliderMinimizedHeight - _size) + "px" |
|
|
134 |
}; |
|
|
135 |
} |
|
|
136 |
|
|
|
137 |
function calculateHandleCss(_size) { |
|
|
138 |
return { |
|
|
139 |
height: (2 + _size) + "px", |
|
|
140 |
width: (2 + _size) + "px", |
|
|
141 |
"margin-left": -Math.ceil(2 + _size / 2) + "px" |
|
18
|
142 |
} |
|
22
|
143 |
} |
|
|
144 |
|
|
|
145 |
/* Controller Widget */ |
|
|
146 |
|
|
|
147 |
var volBlock = $(".Ldt-Ctrl-Volume-Control"); |
|
|
148 |
$('.Ldt-Ctrl-Sound') |
|
|
149 |
.click(function(){}) //TODO: Add Mute Handler |
|
|
150 |
.mouseover(function() { |
|
|
151 |
volBlock.show(); |
|
|
152 |
}) |
|
|
153 |
.mouseout(function() { |
|
|
154 |
volBlock.hide(); |
|
18
|
155 |
}); |
|
22
|
156 |
volBlock.mouseover(function() { |
|
|
157 |
volBlock.show(); |
|
|
158 |
}).mouseout(function() { |
|
|
159 |
volBlock.hide(); |
|
|
160 |
}); |
|
|
161 |
|
|
|
162 |
var volBar = $(".Ldt-Ctrl-Volume-Bar"); |
|
|
163 |
volBar.slider({ |
|
|
164 |
slide: function(event, ui) { |
|
|
165 |
volBar.attr("title",'Volume : ' + ui.value + '%'); |
|
|
166 |
//_this.media.setVolume(ui.value / 100); |
|
|
167 |
}, |
|
|
168 |
stop: function() { |
|
|
169 |
// IriSP.Widgets.Controller.prototype.volumeUpdater |
|
|
170 |
} |
|
|
171 |
}); |
|
|
172 |
|
|
|
173 |
/* Set current Media */ |
|
|
174 |
var currentMedia; |
|
|
175 |
|
|
|
176 |
function setMedia(mediaid) { |
|
|
177 |
currentMedia = project.getElement(mediaid); |
|
|
178 |
if (currentMedia.elementType == "media") { |
|
|
179 |
$("video").hide(); |
|
|
180 |
var currentvideo = $('video[data-media-id="' + mediaid + '"]'); |
|
|
181 |
console.log(currentvideo); |
|
|
182 |
} |
|
|
183 |
} |
|
|
184 |
|
|
|
185 |
function addMediaPlayer(media) { |
|
18
|
186 |
|
|
13
|
187 |
} |
|
22
|
188 |
/* Click on media items */ |
|
|
189 |
|
|
|
190 |
$(".col-left").on("click", ".item-video", function() { |
|
|
191 |
setMedia($(this).attr("data-media-id")); |
|
|
192 |
}); |
|
12
|
193 |
|
|
22
|
194 |
/* Click on Tabs */ |
|
|
195 |
|
|
|
196 |
function showSegmentation() { |
|
|
197 |
$(".col-middle").removeClass("empty-mode pvw-mode").addClass("segment-mode"); |
|
|
198 |
return false; |
|
|
199 |
} |
|
|
200 |
function showPreview() { |
|
|
201 |
$(".col-middle").removeClass("empty-mode segment-mode").addClass("pvw-mode"); |
|
|
202 |
return false; |
|
|
203 |
} |
|
|
204 |
|
|
|
205 |
$(".tab-segment").click(showSegmentation); |
|
|
206 |
$(".tab-pvw").click(showPreview); |
|
|
207 |
|
|
|
208 |
function disableMoveItemVideo() { |
|
|
209 |
$(".organize-segments .top, .organize-segments .bottom").removeClass("disable"); |
|
|
210 |
$(".organize-segments .item-video:last-child .bottom, .organize-segments .item-video:first-child .top").addClass("disable"); |
|
|
211 |
} |
|
|
212 |
|
|
|
213 |
$(".organize-segments").sortable({ |
|
|
214 |
stop : function(){ |
|
|
215 |
disableMoveItemVideo(); |
|
|
216 |
} |
|
|
217 |
}); |
|
|
218 |
|
|
|
219 |
$(".organize-segments .top").click(function(e){ |
|
|
220 |
var currentItem = $(this).parents(".item-video"); |
|
|
221 |
currentItem.insertBefore(currentItem.prev()); |
|
|
222 |
disableMoveItemVideo(); |
|
|
223 |
}); |
|
|
224 |
|
|
|
225 |
$(".organize-segments .bottom").click(function(e){ |
|
|
226 |
var currentItem = $(this).parents(".item-video"); |
|
|
227 |
currentItem.insertAfter(currentItem.next()); |
|
|
228 |
disableMoveItemVideo(); |
|
|
229 |
}); |
|
|
230 |
|
|
13
|
231 |
} |
|
|
232 |
|
|
|
233 |
$(function() { |
|
|
234 |
var hashcut = new IriSP.Hashcut(); |
|
12
|
235 |
}); |