refactor dialog closing code in app panel
This commit is contained in:
parent
c4feabb3cb
commit
889aace64e
1 changed files with 52 additions and 33 deletions
|
@ -36,13 +36,26 @@ pandora.ui.appPanel = function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
function setPage(page) {
|
function setPage(page) {
|
||||||
|
var dialogPages = {
|
||||||
|
site: pandora.site.sitePages.map(function(page) {
|
||||||
|
return page.id;
|
||||||
|
}).concat(['software']),
|
||||||
|
account: ['signup', 'signin'],
|
||||||
|
accountSignout: ['signout'],
|
||||||
|
preferences: ['preferences'],
|
||||||
|
help: ['help'],
|
||||||
|
api: ['api']
|
||||||
|
};
|
||||||
if (page === '') {
|
if (page === '') {
|
||||||
if (pandora.$ui.home && pandora.$ui.appPanel) {
|
if (pandora.$ui.home && pandora.$ui.appPanel) {
|
||||||
// unless we're on page load, remove home screen
|
// unless we're on page load, remove home screen
|
||||||
pandora.$ui.home.fadeOutScreen();
|
pandora.$ui.home.fadeOutScreen();
|
||||||
}
|
}
|
||||||
['site', 'account', 'preferences', 'help', 'api'].forEach(function(dialog) {
|
Ox.forEach(dialogPages, function(pages, dialog) {
|
||||||
pandora.$ui[dialog + 'Dialog'] && pandora.$ui[dialog + 'Dialog'].close();
|
// close all dialogs
|
||||||
|
if (pandora.$ui[dialog + 'Dialog']) {
|
||||||
|
pandora.$ui[dialog + 'Dialog'].close();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (pandora.$ui.tv) {
|
if (pandora.$ui.tv) {
|
||||||
pandora.$ui.tv.fadeOutScreen();
|
pandora.$ui.tv.fadeOutScreen();
|
||||||
|
@ -52,19 +65,25 @@ pandora.ui.appPanel = function() {
|
||||||
pandora.$ui.home = pandora.ui.home()[
|
pandora.$ui.home = pandora.ui.home()[
|
||||||
!pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen'
|
!pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen'
|
||||||
]();
|
]();
|
||||||
} else if (
|
} else if (page == 'tv') {
|
||||||
Ox.getIndexById(pandora.site.sitePages, page) > -1
|
pandora.$ui.tv = pandora.ui.tv()[
|
||||||
|| page == 'software'
|
!pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen'
|
||||||
) {
|
]();
|
||||||
|
pandora.$ui.home && pandora.$ui.tv.mute();
|
||||||
|
} else {
|
||||||
|
// open dialog
|
||||||
|
Ox.forEach(dialogPages, function(pages, dialog) {
|
||||||
|
// close all other dialogs
|
||||||
|
if (pages.indexOf(page) == -1 && pandora.$ui[dialog + 'Dialog']) {
|
||||||
|
pandora.$ui[dialog + 'Dialog'].close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (Ox.getIndexById(pandora.site.sitePages, page) > -1 || page == 'software') {
|
||||||
if (pandora.$ui.siteDialog && pandora.$ui.siteDialog.is(':visible')) {
|
if (pandora.$ui.siteDialog && pandora.$ui.siteDialog.is(':visible')) {
|
||||||
pandora.$ui.siteDialog.select(page);
|
pandora.$ui.siteDialog.select(page);
|
||||||
} else {
|
} else {
|
||||||
pandora.$ui.siteDialog = pandora.ui.siteDialog(page).open();
|
pandora.$ui.siteDialog = pandora.ui.siteDialog(page).open();
|
||||||
}
|
}
|
||||||
} else if (page == 'help') {
|
|
||||||
pandora.$ui.helpDialog = pandora.ui.helpDialog().open();
|
|
||||||
} else if (page == 'api') {
|
|
||||||
pandora.$ui.apiDialog = pandora.ui.apiDialog().open();
|
|
||||||
} else if (['signup', 'signin'].indexOf(page) > -1) {
|
} else if (['signup', 'signin'].indexOf(page) > -1) {
|
||||||
if (pandora.user.level == 'guest') {
|
if (pandora.user.level == 'guest') {
|
||||||
if (pandora.$ui.accountDialog && pandora.$ui.accountDialog.is(':visible')) {
|
if (pandora.$ui.accountDialog && pandora.$ui.accountDialog.is(':visible')) {
|
||||||
|
@ -83,11 +102,11 @@ pandora.ui.appPanel = function() {
|
||||||
} else {
|
} else {
|
||||||
pandora.ui.accountSignoutDialog().open();
|
pandora.ui.accountSignoutDialog().open();
|
||||||
}
|
}
|
||||||
} else if (page == 'tv') {
|
} else if (page == 'help') {
|
||||||
pandora.$ui.tv = pandora.ui.tv()[
|
pandora.$ui.helpDialog = pandora.ui.helpDialog().open();
|
||||||
!pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen'
|
} else if (page == 'api') {
|
||||||
]();
|
pandora.$ui.apiDialog = pandora.ui.apiDialog().open();
|
||||||
pandora.$ui.home && pandora.$ui.tv.mute();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return that;
|
return that;
|
||||||
|
|
Loading…
Reference in a new issue