diff -r 3a2f9993c6cb -r 57f1d252b8f9 integration/js/editor.js --- a/integration/js/editor.js Tue Jan 29 17:26:56 2013 +0100 +++ b/integration/js/editor.js Mon May 06 16:06:47 2013 +0200 @@ -1,5 +1,12 @@ IriSP.editor = function(options) { + window.shortenText = function(text, minlength, maxlength) { + var min = (typeof minlength === "undefined" ? 100 : minlength), + max = (typeof maxlength === "undefined" ? min + 20 : maxlength), + rx = new RegExp("(^.{" + min + "," + max + "})[\s].+$"); + return text.replace(/[\n\r\s]+/mg,' ').replace(rx,'$1…'); + } + /* Load Media List */ var directory = new IriSP.Model.Directory(), @@ -13,7 +20,7 @@ mediatemplate = _.template( '
  • ' + '<%= title %>' - + '

    <%= title %>

    <%= description %>

    ' + + '

    <%= title %>

    <%= shortenText(description) %>

    ' + '

    <%= gettext("Duration:") %> <%= duration.toString() %>

  • ' ), segmenttemplate = _.template( @@ -29,7 +36,7 @@ + '
    ' + '
    ' + '

    <%= annotation.title %>

    ' - + '

    <%= annotation.description %>

    <% if (annotation.keywords.length) { print("

    " + gettext("Tags:") + " " + annotation.keywords.join(", ") + "

    "); } %>' + + '

    <%= shortenText(annotation.description) %>

    <% if (annotation.keywords.length) { print("

    " + gettext("Tags:") + " " + annotation.keywords.join(", ") + "

    "); } %>' + '<%= gettext("Clone segment") %>' + '

    <%= gettext("From:") %> <%= annotation.begin.toString() %> <%= gettext("to:") %> <%= annotation.end.toString() %> (<%= gettext("duration:") %> <%= annotation.getDuration().toString() %>)

    ' + '
    ' @@ -39,11 +46,11 @@ ), mediafoundtemplate = _.template( '
    ' - + '
    ' + + '
    ' + '

    <%= title %>

    ' + '

    <%= description %>

    <% if (tags) { print("

    " + gettext("Tags:") + " " + tags + "

    "); } %>' + '<%= gettext("Clone segment") %>' - + '
    ' + + '
    ' ), mediafoundlisttemplate = _.template( '
    <%= segments %>
    ' @@ -67,12 +74,6 @@ }, { validate: function(_s) { - return (_s.getDuration() < 180000); - }, - message: gettext("A segment must be at most three minutes long") - }, - { - validate: function(_s) { return (!!_s.title && _s.title !== gettext("Untitled segment")); }, message: gettext("A segment must have a title") @@ -167,7 +168,7 @@ media = directory.getElement(mediaid); if (!val) { li.find(".title-video").text(media.title); - li.find(".description").text(media.description); + li.find(".description").text(shortenText(media.description)); li.find(".media-found-segments").html(""); li.show(); } else { @@ -180,7 +181,7 @@ var found = find.test(media.title) || find.test(media.description) || annotations.length; if (found) { li.find(".title-video").html(media.title.replace(replace, '$1')); - li.find(".description").html(media.description.replace(replace, '$1')); + li.find(".description").html(shortenText(media.description).replace(replace, '$1')); var html = '', k = 230 / media.duration, lines = []; @@ -204,7 +205,7 @@ top: 8 * line.index, color: IriSP.vizcolors[i % IriSP.vizcolors.length], title: _a.title.replace(replace, '$1'), - description: _a.description.replace(replace, '$1'), + description: shortenText(_a.description).replace(replace, '$1'), tags: _a.keywords.join(", ").replace(replace, '$1'), popleft : corrpos, pointerpos : (pos - corrpos),