From 22c0813a9b328151d04e995a56da9908347f1aa4 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 2 Aug 2013 15:07:54 +0000 Subject: [PATCH] utils: add isVideoView ('video' is a video view, not a clips view); don't throw when calling getListData on load --- static/js/utils.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/static/js/utils.js b/static/js/utils.js index 073f10d0..7758fd73 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -986,7 +986,7 @@ pandora.getItemIdAndPosition = function() { ret = getIdAndPositionByClipId(selected[0]); } } else { - if (['player', 'editor', 'timeline'].indexOf(ui.itemView) > -1) { + if (pandora.isVideoView()) { ret = getIdAndPositionByItemId(ui.item); } else if ( ['clips', 'map', 'calendar'].indexOf(ui.itemView) > -1 @@ -1074,7 +1074,7 @@ pandora.getListData = function(list) { } else { list = Ox.isUndefined(list) ? pandora.user.ui[pandora.user.ui.section.slice(0, -1)] : list; } - if (list) { + if (list && pandora.$ui.folderList) { Ox.forEach(pandora.$ui.folderList, function($list, id) { var ret = true; // for the current list, we have to check in which @@ -1225,7 +1225,7 @@ pandora.getSpan = function(state, val, callback) { }); } else { isName = val[0] == '@'; - isVideoView = Ox.contains(['player', 'editor', 'timeline'], state.view); + isVideoView = pandora.isVideoView(state.view); canBeAnnotation = state.item && (!state.view || isVideoView) && !isName; canBeEvent = !state.view || state.view == 'calendar'; canBePlace = !state.view || state.view == 'map'; @@ -1481,7 +1481,7 @@ pandora.isClipView = function(view, item) { item = pandora.user.ui.item; } return ( - !item ? ['calendar', 'clip', 'map', 'video'] : ['calendar', 'clips', 'map'] + !item ? ['calendar', 'clip', 'map'] : ['calendar', 'clips', 'map'] ).indexOf(view) > -1; }; @@ -1497,6 +1497,18 @@ pandora.isPrintURL = function(url) { return /^#print(\?.*?)?$/.test(hash); }; +pandora.isVideoView = function(view, item) { + if (arguments.length == 0) { + item = pandora.user.ui.item; + view = !item ? pandora.user.ui.listView : pandora.user.ui.itemView; + } else if (arguments.length == 1) { + item = pandora.user.ui.item; + } + return ( + !item ? ['video'] : ['player', 'editor', 'timeline'] + ).indexOf(view) > -1; +}; + pandora.logEvent = function(data, event, element) { var element = this, handlers = self.eventHandlers ? self.eventHandlers[event] : [];