From 5b0a8ea03e4311f48ba07a27ae14ba346c9fa3ac Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 24 Apr 2012 08:16:45 +0000 Subject: [PATCH] when the browser has focus, make pressing space shift the focus to the player/editor/timeline and trigger play (fixes #526) --- static/js/pandora/browser.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/static/js/pandora/browser.js b/static/js/pandora/browser.js index 06ecdc59..0b016000 100644 --- a/static/js/pandora/browser.js +++ b/static/js/pandora/browser.js @@ -122,6 +122,12 @@ pandora.ui.browser = function() { open: function() { that.scrollToSelection(); }, + openpreview: function() { + var itemView = pandora.user.ui.itemView; + if (['player', 'editor', 'timeline'].indexOf(itemView) > -1) { + pandora.$ui[itemView].gainFocus().triggerEvent('key_space'); + } + }, select: function(data) { data.ids.length && pandora.UI.set({ 'item': data.ids[0] @@ -157,6 +163,18 @@ pandora.ui.browser = function() { pandora_showsiteposters: function() { pandora.user.ui.icons == 'posters' && that.reloadList(true); } + }) + .bindEventOnce({ + load: function() { + // gain focus if we're on page load or if we've just switched + // to an item and the not-yet-garbage-collected list still has + // focus + if (Ox.Focus.focused() === null || ( + pandora.$ui.list && pandora.$ui.list.hasFocus() + )) { + that.gainFocus(); + } + } }); that.css({overflowY: 'hidden'}); // this fixes a bug in firefox pandora.enableDragAndDrop(that, false);