From c187102b0d3535e97b690c04f98990fbba325f76 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 5 Feb 2014 07:35:30 +0000 Subject: [PATCH] enable subtitles on edits --- static/js/editPanel.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/static/js/editPanel.js b/static/js/editPanel.js index d33b54ae..5032c284 100644 --- a/static/js/editPanel.js +++ b/static/js/editPanel.js @@ -136,6 +136,7 @@ pandora.ui.editPanel = function() { }); }) ), + subtitles: getSubtitles(edit.clips), timeline: ui.videoTimeline, timelineTooltip: 'timeline ' + Ox.SYMBOLS.SHIFT + 'T', video: getVideos(), @@ -414,6 +415,34 @@ pandora.ui.editPanel = function() { return layers; } + function getSubtitles(clips) { + var subtitles = [], + subtitlesLayer = pandora.site.layers.filter(function(layer) { + return layer.isSubtitles; + }).map(function(layer) { + return layer.id; + })[0]; + subtitlesLayer && clips.map(function(clip) { + if (clip.layers[subtitlesLayer]) { + clip.layers[subtitlesLayer].forEach(function(subtitle) { + subtitles.push({ + id: subtitle.id, + 'in': Math.max( + clip['position'], + subtitle['in'] - clip['in'] + clip['position'] + ), + out: Math.min( + clip['position'] + clip['duration'], + subtitle.out - clip['in'] + clip['position'] + ), + text: subtitle.value.replace(/\n/g, ' ').replace(//g, '\n') + }); + }); + } + }); + return subtitles; + } + function serializeClips(clips) { // can be ids or clips return clips.map(function(clip) { @@ -439,6 +468,7 @@ pandora.ui.editPanel = function() { duration: edit.duration, layers: getLayers(edit.clips), smallTimelineURL: getSmallTimelineURL(), + subtitles: getSubtitles(edit.clips), video: getVideos() }); updateSmallTimelineURL();