integration/js/editor.js
changeset 123 679809037606
parent 118 7ad8b85dbd57
child 131 e2d1478c843f
equal deleted inserted replaced
121:839efd6eddf1 123:679809037606
    17             + '<p class="time-length"><%= gettext("Duration:") %> <span><%= duration.toString() %></span></p></div><div class="media-found-segments"></div></li>'
    17             + '<p class="time-length"><%= gettext("Duration:") %> <span><%= duration.toString() %></span></p></div><div class="media-found-segments"></div></li>'
    18         ),
    18         ),
    19         segmenttemplate = _.template(
    19         segmenttemplate = _.template(
    20             '<li class="item-video annotation" data-segment-id="<%= annotation.id %>" data-media-id="<%= annotation.getMedia().id %>">'
    20             '<li class="item-video annotation" data-segment-id="<%= annotation.id %>" data-media-id="<%= annotation.getMedia().id %>">'
    21             + '<img class="thumbnail" src="<%= annotation.thumbnail %>" alt="<%= annotation.getMedia().title %>" />'
    21             + '<img class="thumbnail" src="<%= annotation.thumbnail %>" alt="<%= annotation.getMedia().title %>" />'
    22             + '<div class="validate <%= annotation.status %>"><div class="validate-tooltip"><ul><li><%= annotation.status_messages.join("</li><li>") %></li></ul></div></div><div class="video-info"><h3 class="title-video"><%= annotation.getMedia().title %></h3>'
    22             + '<div class="validate <%= annotation.status %>"><div class="validate-tooltip"><ul><li><%= annotation.status_messages.join("</li><li>") %></li></ul></div></div><div class="video-info"><h3 class="segment-title"><%= annotation.title %></h3>'
    23             + '<p class="subtitle"><%= annotation.title %></p><p class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</p>'
    23             + '<p class="title-video"><%= annotation.getMedia().title %></p><p class="duration"><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)</p>'
    24             + '<ul class="tools"><li><a class="edit" href="#" title="<%= gettext("Edit segment") %>"></a></li><li><a class="bottom" href="#" title="<%= gettext("Move segment down") %>"></a></li>'
    24             + '<ul class="tools"><li><a class="edit" href="#" title="<%= gettext("Edit segment") %>"></a></li><li><a class="bottom" href="#" title="<%= gettext("Move segment down") %>"></a></li>'
    25             + '<li><a class="top" href="#" title="<%= gettext("Move segment up") %>"></a></li><li><a class="delete" href="#" title="<%= gettext("Delete segment") %>"></a></li></ul></div></li>'
    25             + '<li><a class="top" href="#" title="<%= gettext("Move segment up") %>"></a></li><li><a class="delete" href="#" title="<%= gettext("Delete segment") %>"></a></li></ul></div></li>'
    26         ),
    26         ),
    27         mediasegmenttemplate = _.template(
    27         mediasegmenttemplate = _.template(
    28             '<div class="media-segment">'
    28             '<div class="media-segment">'
    29             + '<div class="media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>; top: <%= top %>px;" data-segment-id="<%= annotation.id %>"></div>'
    29             + '<div class="media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>; top: <%= top %>px;" data-segment-id="<%= annotation.id %>"></div>'
    30             + '<div class="popin media-segment-popin" style="left:<%= popleft %>px; top: <%= 5+top %>px;"><div style="left:<%= pointerpos %>px;" class="pointer"></div><div class="popin-content">'
    30             + '<div class="popin media-segment-popin" style="left:<%= popleft %>px; top: <%= 5+top %>px;"><div style="left:<%= pointerpos %>px;" class="pointer"></div><div class="popin-content">'
    31             + '<h3><%= annotation.title %></h3><a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= gettext("Clone segment") %></a>'
    31             + '<h3 class="segment-title"><%= annotation.title %></h3>'
       
    32             + '<p><%= annotation.description %></p><% if (annotation.keywords.length) { console.log(annotation.keywords); print("<p><strong>" + gettext("Tags:") + "</strong> " + annotation.keywords.join(", ") + "</p>"); } %>'
       
    33             + '<a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= gettext("Clone segment") %></a>'
    32             + '<p><%= gettext("From:") %> <span><%= annotation.begin.toString() %></span> <%= gettext("to:") %> <span><%= annotation.end.toString() %></span> (<%= gettext("duration:") %> <span><%= annotation.getDuration().toString() %></span>)</p>'
    34             + '<p><%= gettext("From:") %> <span><%= annotation.begin.toString() %></span> <%= gettext("to:") %> <span><%= annotation.end.toString() %></span> (<%= gettext("duration:") %> <span><%= annotation.getDuration().toString() %></span>)</p>'
    33             + '</div></div></div>'
    35             + '</div></div></div>'
    34         ),
    36         ),
    35         mediasegmentlisttemplate = _.template(
    37         mediasegmentlisttemplate = _.template(
    36             '<div class="media-segment-list" style="height: <%= height %>px"><div class="media-current-section" style="left: <%= left %>px; width: <%= width %>px;"></div><div class="media-segment-list-inner"></div><%= segments %></div>'
    38             '<div class="media-segment-list" style="height: <%= height %>px"><div class="media-current-section" style="left: <%= left %>px; width: <%= width %>px;"></div><div class="media-segment-list-inner"></div><%= segments %></div>'
    37         ),
    39         ),
    38         mediafoundtemplate = _.template(
    40         mediafoundtemplate = _.template(
    39             '<div class="media-segment"><div class="media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>; top: <%= top %>px;"></div>'
    41             '<div class="media-segment"><div class="media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>; top: <%= top %>px;"></div>'
    40             + '<div class="popin media-found-popin" style="left:<%= popleft %>px; top: <%= 5+top %>px;"><div style="left:<%= pointerpos %>px;" class="pointer"></div><div class="popin-content">'
    42             + '<div class="popin media-found-popin" style="left:<%= popleft %>px; top: <%= 5+top %>px;"><div style="left:<%= pointerpos %>px;" class="pointer"></div><div class="popin-content">'
    41             + '<h3><%= title %></h3><a href="#" class="button clone-segment" data-segment-id="<%= annotation.id %>"><%= gettext("Clone segment") %></a>'
    43             + '<h3 class="segment-title"><%= title %></h3>'
       
    44             + '<p><%= description %></p><% if (tags) { print("<p><strong>" + gettext("Tags:") + "</strong> " + tags + "</p>"); } %>'
       
    45             + '<a href="#" class="button clone-segment" data-segment-id="<%= annotation.id %>"><%= gettext("Clone segment") %></a>'
    42             + '</div></div></div>'
    46             + '</div></div></div>'
    43         ),
    47         ),
    44         mediafoundlisttemplate = _.template(
    48         mediafoundlisttemplate = _.template(
    45             '<div class="media-found-list" style="height: <%= height %>px"><div class="media-segment-list-inner"></div><%= segments %></div>'
    49             '<div class="media-found-list" style="height: <%= height %>px"><div class="media-segment-list-inner"></div><%= segments %></div>'
    46         ),
    50         ),
   148     
   152     
   149     /* Search Media with left column form */
   153     /* Search Media with left column form */
   150     
   154     
   151     $(".col-left input").on("keyup change input paste", function() {
   155     $(".col-left input").on("keyup change input paste", function() {
   152         var val = $(this).val();
   156         var val = $(this).val();
       
   157         if (val.length < 2) {
       
   158             val = false;
       
   159         }
   153         if (val) {
   160         if (val) {
   154             var find = IriSP.Model.regexpFromTextOrArray(val, true),
   161             var find = IriSP.Model.regexpFromTextOrArray(val, true),
   155                 replace = IriSP.Model.regexpFromTextOrArray(val, false);
   162                 replace = IriSP.Model.regexpFromTextOrArray(val, false);
   156         }
   163         }
   157         $(".col-left .item-video").each(function() {
   164         $(".col-left .item-video").each(function() {
   167                 var apimedia = apidirectory.getElement(mediaid);
   174                 var apimedia = apidirectory.getElement(mediaid);
   168                 if (apimedia) {
   175                 if (apimedia) {
   169                     var annotations = apimedia.getAnnotations().searchByTextFields(val);
   176                     var annotations = apimedia.getAnnotations().searchByTextFields(val);
   170                 } else {
   177                 } else {
   171                     var annotations = [];
   178                     var annotations = [];
   172                 }   
   179                 }
   173                 var found = find.test(media.title) || find.test(media.description) || annotations.length;
   180                 var found = find.test(media.title) || find.test(media.description) || annotations.length;
   174                 if (found) {
   181                 if (found) {
   175                     li.find(".title-video").html(media.title.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'));
   182                     li.find(".title-video").html(media.title.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'));
   176                     li.find(".description").html(media.description.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'));
   183                     li.find(".description").html(media.description.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'));
   177                     var html = '',
   184                     var html = '',
   195                             left : k * _a.begin,
   202                             left : k * _a.begin,
   196                             width : k * _a.getDuration(),
   203                             width : k * _a.getDuration(),
   197                             top: 8 * line.index,
   204                             top: 8 * line.index,
   198                             color: IriSP.vizcolors[i % IriSP.vizcolors.length],
   205                             color: IriSP.vizcolors[i % IriSP.vizcolors.length],
   199                             title: _a.title.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'),
   206                             title: _a.title.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'),
       
   207                             description: _a.description.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'),
       
   208                             tags: _a.keywords.join(", ").replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'),
   200                             popleft : corrpos,
   209                             popleft : corrpos,
   201                             pointerpos : (pos - corrpos),
   210                             pointerpos : (pos - corrpos),
   202                         }
   211                         }
   203                         html += mediafoundtemplate(vizdata);
   212                         html += mediafoundtemplate(vizdata);
   204                     });
   213                     });
   224             if (_s.annotation.status === "critical") {
   233             if (_s.annotation.status === "critical") {
   225                 critical = true;
   234                 critical = true;
   226             }
   235             }
   227         });
   236         });
   228         if (critical) {
   237         if (critical) {
   229             messages.push("One or more segments are invalid");
   238             messages.push(gettext("One or more segments are invalid"));
   230         }
   239         }
   231         
   240         
   232         _(mashupcritical).each(function(sc) {
   241         _(mashupcritical).each(function(sc) {
   233             if (!sc.validate(mashup)) {
   242             if (!sc.validate(mashup)) {
   234                 critical = true;
   243                 critical = true;
   241                 messages.push(sc.message);
   250                 messages.push(sc.message);
   242             }
   251             }
   243         });
   252         });
   244         mashup.status = critical ? "critical" : (warning ? "warning" : "valid");
   253         mashup.status = critical ? "critical" : (warning ? "warning" : "valid");
   245         if (!messages.length) {
   254         if (!messages.length) {
   246             messages.push("Your hashcut is valid!");
   255             messages.push(gettext("Your hashcut is valid!"));
   247         }
   256         }
   248         mashupstatus = ' - ' + _(messages).join('\n - ');
   257         mashupstatus = ' - ' + _(messages).join('\n - ');
   249         
   258         
   250         $(".publier-button").toggleClass("disable", critical);
   259         $(".publier-button").toggleClass("disable", critical);
   251         
   260         
   346                     messages.push(sc.message);
   355                     messages.push(sc.message);
   347                 }
   356                 }
   348             });
   357             });
   349             currentSegment.status = critical ? "critical" : (warning ? "warning" : "valid");
   358             currentSegment.status = critical ? "critical" : (warning ? "warning" : "valid");
   350             if (!messages.length) {
   359             if (!messages.length) {
   351                 messages.push("This segment is valid!")
   360                 messages.push(gettext("This segment is valid!"))
   352             }
   361             }
   353             currentSegment.status_messages = _(messages);
   362             currentSegment.status_messages = _(messages);
   354             
   363             
   355             $(".segmentation .validate").removeClass("critical warning valid").addClass(currentSegment.status);
   364             $(".segmentation .validate").removeClass("critical warning valid").addClass(currentSegment.status);
   356             $(".segmentation .validate-tooltip").html("<ul><li>" + currentSegment.status_messages.join("</li><li>")+"</li></ul>");
   365             $(".segmentation .validate-tooltip").html("<ul><li>" + currentSegment.status_messages.join("</li><li>")+"</li></ul>");