--- a/integration/js/editor.js Wed Oct 24 15:58:27 2012 +0200
+++ b/integration/js/editor.js Wed Oct 24 17:44:18 2012 +0200
@@ -1,3 +1,50 @@
-$(function() {
+(function() {
+ var Hashcut = function() {
+ var directory = new IriSP.Model.Directory(),
+ project = directory.remoteSource({
+ url: "data/bpidata.json",
+ serializer: IriSP.serializers.medialist
+ }),
+ mediatemplate = '<li class="item-video"><a class="clearfix" href="#"><img src="{{thumbnail}}" alt="aperçu" />'
+ + '<span class="video-info"><span class="title-video">{{title}}</span><span class="author">{{description}}</span>'
+ + '<span class="time-length">Durée : <span>{{duration}}</span></span></span></a></li>';
+ project.onLoad(function() {
+ var html = '';
+ project.getMedias().forEach(function(_m) {
+ html += Mustache.to_html(mediatemplate, _m);
+ });
+ $(".col-left .list-video").html(html);
+ });
+
+ $(".col-left input").bind("keyup change input paste", function() {
+ var val = $(this).val();
+ if (val) {
+ var find = IriSP.Model.regexpFromTextOrArray(val, true),
+ replace = IriSP.Model.regexpFromTextOrArray(val, false);
+ }
+ $(".col-left .item-video").each(function() {
+ var li = $(this),
+ title = $(this).find(".title-video"),
+ titletext = title.text();
+ if (val && find.test(titletext)) {
+ title.html(titletext.replace(replace, '<span style="background: yellow;">$1</span>'));
+ li.show();
+ } else {
+ title.text(titletext);
+ if (val) {
+ li.hide();
+ } else {
+ li.show();
+ }
+ }
+ })
+ });
+ }
+ IriSP.Hashcut = Hashcut;
+}
+)();
+
+$(function() {
+ var hashcut = new IriSP.Hashcut();
});