openmedialibrary/static/js/appPanel.js
2016-01-13 13:54:44 +05:30

67 lines
No EOL
1.9 KiB
JavaScript

'use strict';
oml.ui.appPanel = function() {
var ui = oml.user.ui,
that = Ox.SplitPanel({
elements: [
{
element: oml.$ui.mainMenu = oml.ui.mainMenu(),
size: 20
},
{
element: oml.$ui.mainPanel = oml.ui.mainPanel()
}
],
orientation: 'vertical'
})
.bindEvent({
oml_page: function(data) {
setPage(data.value, data.previousValue);
}
});
setPage(ui.page);
function setPage(page, previousPage) {
var dialogs = {
welcomeDialog: ['welcome'],
appDialog: ['about', 'faq', 'terms', 'development', 'contact'],
updateDialog: ['update'],
userDialog: ['preferences', 'peers', 'transfers'],
importExportDialog: ['import', 'export']
};
// close dialogs
if (Ox.every(dialogs, function(pages) {
return !Ox.contains(pages, page);
}) && Ox.some(dialogs, function(pages) {
return Ox.contains(pages, previousPage)
})) {
$('.OxDialog:visible').each(function() {
Ox.$elements[$(this).data('oxid')].close();
});
}
// 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() {
Ox.Request.cancel();
Ox.Request.clearCache();
oml.unbindEvent();
oml.$ui.appPanel.remove();
oml.$ui.appPanel = oml.ui.appPanel().appendTo(Ox.$body);
return that;
};
return that;
};