diff -r 2cae82a5bdc2 -r d3d8a88878ed integration/js/editor.js --- a/integration/js/editor.js Tue Nov 06 12:22:30 2012 +0100 +++ b/integration/js/editor.js Tue Nov 06 18:48:59 2012 +0100 @@ -1,10 +1,16 @@ IriSP.hc_messages = { - duration_ : "Durée :", + Duration_ : "Durée :", + duration_ : "durée :", edit_segment: "Éditer le segment", segment_down: "Descendre le segment", segment_up: "Remonter le segment", - delete_segment: "Supprimer le segment" + delete_segment: "Supprimer le segment", + clone_segment: "Cloner le segment", + From_: "De :", + to_: "à :", + segment_title_placeholder: "Segment sans titre", + mashup_title_placeholder: "Hashcut sans titre" } IriSP.Hashcut = function(options) { @@ -20,10 +26,10 @@ mashup = new IriSP.Model.Mashup(false, project), mediatemplate = _.template('
  • <%= title %>' + '<%= title %><%= description %>' - + '<%= IriSP.hc_messages.duration_ %> <%= duration.toString() %>
  • '), + + '<%= IriSP.hc_messages.Duration_ %> <%= duration.toString() %>'), segmenttemplate = _.template('
  • ' + '<%= annotation.getMedia().title %>' - + '<%= annotation.getMedia().title %>' + + '
    • <%= annotation.status_messages.join("
    • ") %>
    <%= annotation.getMedia().title %>' + '<%= annotation.title %><%= annotation.begin.toString() %> - <%= annotation.end.toString() %> (<%= annotation.getDuration().toString() %>)' + '
    • ' + '
  • '), @@ -33,9 +39,58 @@ + '
    ' + '
    ' + '
    ' - + '

    <%= annotation.title %>

    Cloner le segment' - + '

    De: <%= annotation.begin.toString() %> à <%= annotation.end.toString() %> (durée: <%= annotation.getDuration().toString() %>)

    ' + + '

    <%= annotation.title %>

    <%= IriSP.hc_messages.clone_segment %>' + + '

    <%= IriSP.hc_messages.From_ %> <%= annotation.begin.toString() %> <%= IriSP.hc_messages.to_ %> <%= annotation.end.toString() %> (<%= IriSP.hc_messages.duration_ %> <%= annotation.getDuration().toString() %>)

    ' + '
    '); + + /* Validation of segments and mashup */ + + var segmentcritical = [ + { + validate: function(_s) { + var _d = _s.getDuration(); + return (_d > 1000 && _d < 180000); + }, + message: "La durée du segment doit être comprise entre 1 seconde et trois minutes" + }, + { + validate: function(_s) { + return (!!_s.title && _s.title !== IriSP.hc_messages.segment_title_placeholder); + }, + message: "Un titre doit être donné au segment" + } + ]; + var segmentwarning = [ + { + validate: function(_s) { + return (_s.description); + }, + message: "Il est recommandé de donner une description au segment" + } + ]; + + var mashupcritical = [ + { + validate: function(_m) { + return _m.segments.length > 2; + }, + message: "Un hashcut doit être composé d'au moins trois segments" + }, + { + validate: function(_m) { + return (!!_m.title && _m.title !== IriSP.hc_messages.mashup_title_placeholder); + }, + message: "Un titre doit être donné au hashcut" + } + ]; + var mashupwarning = [ + { + validate: function(_m) { + return !!_m.description + }, + message: "Il est recommandé de donner une description au hashcut" + } + ]; /* Fill left column with Media List */ @@ -84,6 +139,7 @@ function updateMashupUI() { var listhtml = '', vizhtml = '', t = 0, k = mashup.duration ? (100 / mashup.duration) : 0; + var critical = false, warning = false, messages = []; mashup.segments.forEach(function(_s) { listhtml += segmenttemplate(_s); var vizdata = { @@ -93,8 +149,35 @@ segmentid: _s.annotation.id } vizhtml += viztemplate(vizdata); + if (_s.annotation.status === "critical") { + critical = true; + } t += _s.duration.milliseconds; }); + if (critical) { + messages.push("Certains segments ne sont pas valides"); + } + + _(mashupcritical).each(function(sc) { + if (!sc.validate(mashup)) { + critical = true; + messages.push(sc.message); + } + }); + _(mashupwarning).each(function(sc) { + if (!sc.validate(mashup)) { + warning = true; + messages.push(sc.message); + } + }); + mashup.status = critical ? "critical" : (warning ? "warning" : "valid"); + if (!messages.length) { + messages.push("Le hashcut est valide !"); + } + $(".publier-button").toggleClass("disable", critical); + + $(".liste-segment .validate").removeClass("critical warning valid").addClass(mashup.status); + $(".liste-segment .validate-tooltip").html(""); var intervals = [ 1000, 2000, 5000, 10000, 30000, 60000, 120000, 300000, 600000, 900000, 1800000, 3600000, 7200000 ]; @@ -435,7 +518,7 @@ var currentMedia, currentSegment; - function updateSliderAndTangles() { + function updateSegmentUI() { if (currentMedia && currentSegment) { var start = currentSegment.begin, end = currentSegment.end, @@ -450,11 +533,34 @@ tangleStart.text(start.toString(tangleStart.hasClass("active"))).attr("data-milliseconds",start.milliseconds); tangleEnd.text(end.toString(tangleEnd.hasClass("active"))).attr("data-milliseconds",end.milliseconds); tangleDuration.text(dur.toString(tangleDuration.hasClass("active"))).attr("data-milliseconds",dur.milliseconds); - $(".segment-info .pointer").css("left", p + "%"); + $(".segmentation .pointer").css("left", p + "%"); $(".media-current-section").css({ left: (k * start) + "%", width: (k * dur) + "%" - }) + }); + var messages = [], + critical = false, + warning = false; + _(segmentcritical).each(function(sc) { + if (!sc.validate(currentSegment)) { + critical = true; + messages.push(sc.message); + } + }); + _(segmentwarning).each(function(sc) { + if (!sc.validate(currentSegment)) { + warning = true; + messages.push(sc.message); + } + }); + currentSegment.status = critical ? "critical" : (warning ? "warning" : "valid"); + if (!messages.length) { + messages.push("Le segment est valide !") + } + currentSegment.status_messages = messages; + + $(".segmentation .validate").removeClass("critical warning valid").addClass(currentSegment.status); + $(".segmentation .validate-tooltip").html(""); } } @@ -484,18 +590,18 @@ currentSegment.setMedia(currentMedia.id); currentSegment.setBegin(0); currentSegment.setEnd(currentMedia.duration); - currentSegment.title = "Segment sans titre"; - currentSegment.description = "Extrait de « " + currentMedia.title + " »"; + currentSegment.title = IriSP.hc_messages.segment_title_placeholder; + currentSegment.description = ""; currentSegment.on("change-begin", function() { if (currentMedia && currentSegment === this) { currentMedia.setCurrentTime(this.begin); - updateSliderAndTangles(); + updateSegmentUI(); } }); currentSegment.on("change-end", function() { if (currentMedia && currentSegment === this) { currentMedia.setCurrentTime(this.end); - updateSliderAndTangles(); + updateSegmentUI(); } }); currentSegment.on("enter", function() { @@ -515,7 +621,7 @@ } $(".add-segment").val(addMode ? "Ajouter au Hashcut" : "Sauvegarder"); $(".create-or-edit").text(addMode ? "Créer un nouveau segment" : "Modifier le segment"); - updateSliderAndTangles(); + updateSegmentUI(); media.show(); $("#segment-title").val(currentSegment.title); $("#segment-description").val(currentSegment.description); @@ -800,12 +906,14 @@ $("#segment-title").on("keyup change input paste", function() { if (currentMedia && currentSegment) { currentSegment.title = $(this).val(); + updateSegmentUI(); updateMashupUI(); } }); $("#segment-description").on("keyup change input paste", function() { if (currentMedia && currentSegment) { currentSegment.description = $(this).val(); + updateSegmentUI(); } }); $("#segment-form").submit(function() { @@ -1021,10 +1129,21 @@ }); /* Changing Hashcut Title and description */ - + + mashup.title = IriSP.hc_messages.mashup_title_placeholder; + $(".title-video-wrap a").text(mashup.title); + $("#hashcut-title").val(mashup.title); + $("#hashcut-title").on("keyup change input paste", function() { mashup.title = $(this).val(); $(".title-video-wrap a").text(mashup.title); + updateMashupUI(); }); + $("#hashcut-description").on("keyup change input paste", function() { + mashup.description = $(this).val(); + updateMashupUI(); + }); + + updateMashupUI(); }