openmedialibrary/static/js/appPanel.js

82 lines
2.5 KiB
JavaScript
Raw Normal View History

2014-05-04 17:26:43 +00:00
'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) {
2014-05-17 08:17:34 +00:00
setPage(data.value, data.previousValue);
2014-05-04 17:26:43 +00:00
}
});
setPage(ui.page);
2014-05-17 08:17:34 +00:00
function setPage(page, previousPage) {
2016-01-13 06:52:25 +00:00
var dialogs = {
2016-01-13 08:24:44 +00:00
welcomeDialog: ['welcome'],
2016-01-13 06:52:25 +00:00
appDialog: ['about', 'faq', 'terms', 'development', 'contact'],
updateDialog: ['update'],
userDialog: ['preferences', 'peers', 'transfers'],
importExportDialog: ['import', 'export']
};
2014-05-04 17:26:43 +00:00
// close dialogs
2016-01-13 07:29:53 +00:00
if (Ox.every(dialogs, function(pages) {
2016-01-13 06:52:25 +00:00
return !Ox.contains(pages, page);
2016-01-13 07:29:53 +00:00
}) && Ox.some(dialogs, function(pages) {
2016-01-13 06:52:25 +00:00
return Ox.contains(pages, previousPage)
})) {
2014-05-17 08:17:34 +00:00
$('.OxDialog:visible').each(function() {
2014-09-29 13:17:59 +00:00
Ox.$elements[$(this).data('oxid')].close();
2014-05-17 08:17:34 +00:00
});
}
2016-01-13 06:52:25 +00:00
// 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();
2014-05-17 08:17:34 +00:00
}
2016-01-13 06:52:25 +00:00
});
2014-05-04 17:26:43 +00:00
}
oml.bindEvent({
transfer: Ox.throttle(function(data) {
oml.$ui.list.value(data.id, {
mediastate: data.progress < 1 ? 'transferring' : 'available'
});
oml.$ui.browser.value(data.id, {
mediastate: data.progress < 1 ? 'transferring' : 'available'
});
if (data.progress == 1 && data.id == ui.item) {
Ox.Request.clearCache();
oml.$ui.infoView.updateElement(ui.item);
}
2016-01-17 07:57:32 +00:00
}, 250)
});
2014-05-04 17:26:43 +00:00
that.reload = function() {
Ox.Request.cancel();
Ox.Request.clearCache();
2014-05-18 23:24:04 +00:00
oml.unbindEvent();
2014-05-04 17:26:43 +00:00
oml.$ui.appPanel.remove();
oml.$ui.appPanel = oml.ui.appPanel().appendTo(Ox.$body);
return that;
};
return that;
};