From 03f0b4a726b393877663bc04733f8ed73a6498e3 Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 7 Nov 2011 19:55:39 +0000 Subject: [PATCH] fix a bug where the selected list, if its folder had loaded late, would steal focus from the main find element --- static/js/pandora/menu.js | 10 +++++----- static/js/pandora/utils.js | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/static/js/pandora/menu.js b/static/js/pandora/menu.js index fe46a3027..f3fb853e5 100644 --- a/static/js/pandora/menu.js +++ b/static/js/pandora/menu.js @@ -302,27 +302,27 @@ pandora.ui.mainMenu = function() { } }, key_control_comma: function() { - if (pandora.hasNoDialogOrScreen()) { + if (!pandora.hasDialogOrScreen()) { pandora.URL.push('/preferences'); } }, key_control_f: function() { - if (pandora.hasNoDialogOrScreen()) { + if (!pandora.hasDialogOrScreen()) { pandora.$ui.findInput.focusInput(true); } }, key_control_shift_w: function() { - if (pandora.hasNoDialogOrScreen() || (ui.item || ui._list)) { + if (!pandora.hasDialogOrScreen() || (ui.item || ui._list)) { pandora.UI.set({find: {conditions: [], operator: '&'}}); } }, key_control_slash: function() { - if (pandora.hasNoDialogOrScreen()) { + if (!pandora.hasDialogOrScreen()) { pandora.URL.push('/help'); } }, key_control_w: function() { - if (pandora.hasNoDialogOrScreen()) { + if (!pandora.hasDialogOrScreen()) { if (ui.item) { pandora.UI.set({item: ''}); } else if (ui._list) { diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index dc07ed1ac..d44273ad0 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -719,11 +719,16 @@ pandora.getVideoPartsAndPoints = function(durations, points) { return ret; }; -pandora.hasNoDialogOrScreen = function() { - return $('.OxDialog:visible').length == 0 - && $('.OxFullscreen').length == 0 - && $('.OxScreen').length == 0; -} +pandora.hasDialogOrScreen = function() { + return $('.OxDialog:visible').length + || $('.OxFullscreen').length + || $('.OxScreen').length; +}; + +pandora.hasFocusedInput = function() { + var focused = Ox.Focus.focused(); + return focused && Ox.UI.elements[focused].is('.OxInput'); +}; pandora.isClipView = function(view, item) { if (arguments.length == 0) { @@ -932,8 +937,9 @@ pandora.selectList = function() { ); pandora.$ui.folderList[folder] .options({selected: [pandora.user.ui._list]}); - // Don't steal focus from home screen - $('.OxScreen').length == 0 && pandora.$ui.folderList[folder].gainFocus(); + if (!pandora.hasDialogOrScreen() && !pandora.hasFocusedInput()) { + pandora.$ui.folderList[folder].gainFocus(); + } } }); }