--- 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(
'<li class="item-video media" data-media-id="<%= id %>"><div class="media-count-wrap"><span class="media-count"></span></div>'
+ '<img class="thumbnail" src="<%= thumbnail %>" alt="<%= title %>" />'
- + '<div class="video-info"><h3 class="title-video"><%= title %></h3><p class="description"><%= description %></p>'
+ + '<div class="video-info"><h3 class="title-video"><%= title %></h3><p class="description"><%= shortenText(description) %></p>'
+ '<p class="time-length"><%= gettext("Duration:") %> <span><%= duration.toString() %></span></p></div><div class="media-found-segments"></div></li>'
),
segmenttemplate = _.template(
@@ -29,7 +36,7 @@
+ '<div class="media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>; top: <%= top %>px;" data-segment-id="<%= annotation.id %>"></div>'
+ '<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">'
+ '<h3 class="segment-title"><%= annotation.title %></h3>'
- + '<p><%= annotation.description %></p><% if (annotation.keywords.length) { print("<p><strong>" + gettext("Tags:") + "</strong> " + annotation.keywords.join(", ") + "</p>"); } %>'
+ + '<p><%= shortenText(annotation.description) %></p><% if (annotation.keywords.length) { print("<p><strong>" + gettext("Tags:") + "</strong> " + annotation.keywords.join(", ") + "</p>"); } %>'
+ '<a href="#" class="button reprendre-segment" data-segment-id="<%= annotation.id %>"><%= gettext("Clone segment") %></a>'
+ '<p><%= gettext("From:") %> <span><%= annotation.begin.toString() %></span> <%= gettext("to:") %> <span><%= annotation.end.toString() %></span> (<%= gettext("duration:") %> <span><%= annotation.getDuration().toString() %></span>)</p>'
+ '</div></div></div>'
@@ -39,11 +46,11 @@
),
mediafoundtemplate = _.template(
'<div class="media-segment"><div class="media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>; top: <%= top %>px;"></div>'
- + '<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">'
+ + '<div class="popin media-found-popin" style="left:<%= popleft %>px; top: <%= top-5 %>px;"><div class="popin-content">'
+ '<h3 class="segment-title"><%= title %></h3>'
+ '<p><%= description %></p><% if (tags) { print("<p><strong>" + gettext("Tags:") + "</strong> " + tags + "</p>"); } %>'
+ '<a href="#" class="button clone-segment" data-segment-id="<%= annotation.id %>"><%= gettext("Clone segment") %></a>'
- + '</div></div></div>'
+ + '</div><div style="left:<%= pointerpos %>px;" class="pointer"></div></div></div>'
),
mediafoundlisttemplate = _.template(
'<div class="media-found-list" style="height: <%= height %>px"><div class="media-segment-list-inner"></div><%= segments %></div>'
@@ -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, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'));
- li.find(".description").html(media.description.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'));
+ li.find(".description").html(shortenText(media.description).replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'));
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, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'),
- description: _a.description.replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'),
+ description: shortenText(_a.description).replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'),
tags: _a.keywords.join(", ").replace(replace, '<span style="background: #fc00ff; color: #ffffff;">$1</span>'),
popleft : corrpos,
pointerpos : (pos - corrpos),