integration/js/editor.js
changeset 19 43ac4bd80e71
parent 18 c85b323f5174
child 22 bd904d592881
equal deleted inserted replaced
11:265a5f1cc7cf 19:43ac4bd80e71
       
     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"><img src="{{thumbnail}}" alt="{{title}}" />'
       
     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></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").on("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         
       
    43         $(".tab-segment").click(function() {
       
    44             $(".col-middle").removeClass("empty-mode pvw-mode").addClass("segment-mode");
       
    45             return false;
       
    46         });
       
    47         $(".tab-pvw").click(function() {
       
    48             $(".col-middle").removeClass("empty-mode segment-mode").addClass("pvw-mode");
       
    49             return false;
       
    50         });
       
    51         
       
    52         function disableMoveItemVideo() {
       
    53             $(".organize-segments .top, .organize-segments .bottom").removeClass("disable");
       
    54             $(".organize-segments .item-video:last-child .bottom, .organize-segments .item-video:first-child .top").addClass("disable");
       
    55         }
       
    56         
       
    57         $(".organize-segments").sortable({
       
    58             stop : function(){
       
    59                 disableMoveItemVideo();
       
    60             }
       
    61         });
       
    62         
       
    63         $(".organize-segments .top").click(function(e){
       
    64             var currentItem = $(this).parents(".item-video");
       
    65             currentItem.insertBefore(currentItem.prev());
       
    66             disableMoveItemVideo();
       
    67         });
       
    68         
       
    69         $(".organize-segments .bottom").click(function(e){
       
    70             var currentItem = $(this).parents(".item-video");
       
    71             currentItem.insertAfter(currentItem.next());
       
    72             disableMoveItemVideo();
       
    73         });
       
    74         
       
    75         
       
    76     }
       
    77     
       
    78     IriSP.Hashcut = Hashcut;
       
    79 }
       
    80 )();
       
    81 
       
    82 $(function() {
       
    83     var hashcut = new IriSP.Hashcut();
       
    84 });