|
13
|
1 |
(function() { |
|
|
2 |
var Hashcut = function() { |
|
|
3 |
var directory = new IriSP.Model.Directory(), |
|
|
4 |
project = directory.remoteSource({ |
|
|
5 |
url: "data/bpidata.json", |
|
|
6 |
serializer: IriSP.serializers.medialist |
|
|
7 |
}), |
|
|
8 |
mediatemplate = '<li class="item-video"><a class="clearfix" href="#"><img src="{{thumbnail}}" alt="aperçu" />' |
|
|
9 |
+ '<span class="video-info"><span class="title-video">{{title}}</span><span class="author">{{description}}</span>' |
|
|
10 |
+ '<span class="time-length">Durée : <span>{{duration}}</span></span></span></a></li>'; |
|
|
11 |
project.onLoad(function() { |
|
|
12 |
var html = ''; |
|
|
13 |
project.getMedias().forEach(function(_m) { |
|
|
14 |
html += Mustache.to_html(mediatemplate, _m); |
|
|
15 |
}); |
|
|
16 |
$(".col-left .list-video").html(html); |
|
|
17 |
}); |
|
|
18 |
|
|
|
19 |
$(".col-left input").bind("keyup change input paste", function() { |
|
|
20 |
var val = $(this).val(); |
|
|
21 |
if (val) { |
|
|
22 |
var find = IriSP.Model.regexpFromTextOrArray(val, true), |
|
|
23 |
replace = IriSP.Model.regexpFromTextOrArray(val, false); |
|
|
24 |
} |
|
|
25 |
$(".col-left .item-video").each(function() { |
|
|
26 |
var li = $(this), |
|
|
27 |
title = $(this).find(".title-video"), |
|
|
28 |
titletext = title.text(); |
|
|
29 |
if (val && find.test(titletext)) { |
|
|
30 |
title.html(titletext.replace(replace, '<span style="background: yellow;">$1</span>')); |
|
|
31 |
li.show(); |
|
|
32 |
} else { |
|
|
33 |
title.text(titletext); |
|
|
34 |
if (val) { |
|
|
35 |
li.hide(); |
|
|
36 |
} else { |
|
|
37 |
li.show(); |
|
|
38 |
} |
|
|
39 |
} |
|
|
40 |
}) |
|
|
41 |
}); |
|
|
42 |
} |
|
12
|
43 |
|
|
13
|
44 |
IriSP.Hashcut = Hashcut; |
|
|
45 |
} |
|
|
46 |
)(); |
|
|
47 |
|
|
|
48 |
$(function() { |
|
|
49 |
var hashcut = new IriSP.Hashcut(); |
|
12
|
50 |
}); |