diff --git a/static/js/appPanel.js b/static/js/appPanel.js index 71a45e3..71f2717 100644 --- a/static/js/appPanel.js +++ b/static/js/appPanel.js @@ -25,31 +25,31 @@ oml.ui.appPanel = function() { setPage(ui.page); function setPage(page, previousPage) { + var dialogs = { + appDialog: ['about', 'faq', 'terms', 'development', 'contact'], + updateDialog: ['update'], + userDialog: ['preferences', 'peers', 'transfers'], + importExportDialog: ['import', 'export'] + }; // close dialogs - if ( - !Ox.contains(['import', 'export'], page) - || !Ox.contains(['import', 'export'], previousPage) - ) { + if (Ox.every(dialog, function(pages) { + return !Ox.contains(pages, page); + }) && Ox.some(dialog, function(pages) { + return Ox.contains(pages, previousPage) + })) { $('.OxDialog:visible').each(function() { Ox.$elements[$(this).data('oxid')].close(); }); } - // open dialog - if (Ox.contains([ - 'welcome', 'app', 'update', 'preferences', 'users', - 'notifications', 'transfers', 'help' - ], page)) { - oml.$ui[page + 'Dialog'] = oml.ui[page + 'Dialog']().open(); - } else if (Ox.contains(['import', 'export'], page)) { - if ( - oml.$ui.importExportDialog - && oml.$ui.importExportDialog.is(':visible') - ) { - oml.$ui.importExportDialog.select(page); - } else { - oml.$ui.importExportDialog = oml.ui.importExportDialog(page).open(); + // open dialogs + Ox.forEach(dialogs, function(pages, dialog) { + if (Ox.contains(pages, page) && !Ox.contains(pages, previousPage)) { + $('.OxDialog:visible').each(function() { + Ox.$elements[$(this).data('oxid')].close(); + }); + oml.$ui[dialog] = oml.ui[dialog]().open(); } - } + }); } that.reload = function() {