From 792766a59b281fd46899b8908da31115216aa2b7 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 21 Feb 2013 12:32:37 +0530 Subject: [PATCH] embed player: make showLayers an array, acturally hide layers that are not shown, add timeline (type) option --- static/js/pandora/embedPanel.js | 40 ++++++++++++++++++++------------- static/js/pandora/utils.js | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/static/js/pandora/embedPanel.js b/static/js/pandora/embedPanel.js index 31430a30..621a9f74 100644 --- a/static/js/pandora/embedPanel.js +++ b/static/js/pandora/embedPanel.js @@ -83,8 +83,10 @@ pandora.ui.embedPanel = function() { + '/timelineantialias' + size + 'p' + i + '.jpg' } : '/' + options.item + '/' + 'timeline16p.png', - // timelineType: pandora.user.ui.videoTimeline, - // timelineTypes: pandora.site.timelines, + timelineType: options.showTimeline + ? options.timeline : '', + timelineTypes: options.showTimeline + ? pandora.site.timelines : [], title: video.title, video: video.video, volume: pandora.user.ui.videoVolume, @@ -130,7 +132,7 @@ pandora.ui.embedPanel = function() { position: options.position, showInToOut: options.playInToOut, subtitles: ui.videoSubtitles ? video.subtitles : [], - type: ui.videoTimeline, + type: options.timeline, width: window.innerWidth - 16 }, options['in'] ? { 'in': options['in'] @@ -151,17 +153,20 @@ pandora.ui.embedPanel = function() { if (options.showAnnotations) { if (options.playInToOut) { video.annotations.forEach(function(layer) { - var items = []; - layer.items.forEach(function(item) { - if (( - item['in'] >= options['in'] && item['in'] <= options.out - ) || ( - item.out >= options['in'] && item.out <= options.out - )) { - items.push(item); - } - }); - layer.items = items; + var items; + if (Ox.contains(options.showLayers, layer.id)) { + items = []; + layer.items.forEach(function(item) { + if (( + item['in'] >= options['in'] && item['in'] <= options.out + ) || ( + item.out >= options['in'] && item.out <= options.out + )) { + items.push(item); + } + }); + layer.items = items; + } }); } $annotations = Ox.AnnotationPanel(Ox.extend({ @@ -169,7 +174,7 @@ pandora.ui.embedPanel = function() { layers: video.annotations, position: options.position, range: options.annotationsRange, - showLayers: options.showLayers, + showLayers: ui.showLayers, showUsers: true, sort: options.annotationsSort, width: window.innerWidth @@ -269,8 +274,11 @@ pandora.ui.embedPanel = function() { playInToOut: true, showAnnotations: false, showCloseButton: false, - showLayers: ui.showLayers, + showLayers: pandora.site.layers.map(function(layer) { + return layer.id; + }), showTimeline: false, + timeline: ui.videoTimeline, width: window.innerWidth }; ui.hash.query.forEach(function(condition) { diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index ffff484c..5a6540db 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -1057,7 +1057,7 @@ pandora.normalizeHashQuery = function(state) { 'matchRatio', 'paused', 'playInToOut', 'showAnnotations', 'showCloseButton', 'showLayers', 'showTimeline', - 'title' + 'timeline', 'title' ], isEmbed = state.hash && state.hash.query && Ox.indexOf(state.hash.query, function(condition) {