update page change dialog handler

This commit is contained in:
rlx 2016-01-13 12:22:25 +05:30
parent 04a2e41bc6
commit ef185073aa

View file

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