2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-12-22 15:48:48 +00:00
|
|
|
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
2011-12-22 15:48:48 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.appPanel = function() {
|
2011-06-19 17:49:25 +00:00
|
|
|
var that = Ox.SplitPanel({
|
2011-05-25 19:42:45 +00:00
|
|
|
elements: [
|
|
|
|
{
|
2011-06-06 15:48:11 +00:00
|
|
|
element: pandora.$ui.mainMenu = pandora.ui.mainMenu(),
|
2011-05-25 19:42:45 +00:00
|
|
|
size: 20
|
|
|
|
},
|
|
|
|
{
|
2011-06-06 15:48:11 +00:00
|
|
|
element: pandora.$ui.mainPanel = pandora.ui.mainPanel()
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
});
|
2011-11-09 22:32:54 +00:00
|
|
|
setPage(pandora.user.ui.page);
|
2011-05-25 19:42:45 +00:00
|
|
|
that.display = function() {
|
|
|
|
// fixme: move animation into Ox.App
|
2011-10-23 14:25:23 +00:00
|
|
|
var animate = $('.OxScreen').length == 0;
|
2011-11-04 15:54:42 +00:00
|
|
|
Ox.Log('', 'ANIMATE?', animate)
|
2011-08-24 21:04:13 +00:00
|
|
|
animate && pandora.$ui.body.css({opacity: 0});
|
2011-06-06 15:48:11 +00:00
|
|
|
that.appendTo(pandora.$ui.body);
|
2011-08-24 21:04:13 +00:00
|
|
|
animate && pandora.$ui.body.animate({opacity: 1}, 1000);
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
2013-07-08 17:16:13 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
that.reload = function() {
|
2013-07-29 08:46:55 +00:00
|
|
|
Ox.Request.cancel();
|
|
|
|
Ox.Request.clearCache();
|
2011-11-04 22:14:13 +00:00
|
|
|
pandora.$ui.appPanel.remove();
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.appPanel = pandora.ui.appPanel().appendTo(pandora.$ui.body);
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
2013-07-08 17:16:13 +00:00
|
|
|
};
|
2011-11-09 22:32:54 +00:00
|
|
|
that.bindEvent({
|
|
|
|
pandora_page: function(data) {
|
|
|
|
setPage(data.value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
function setPage(page) {
|
2013-03-04 12:32:08 +00:00
|
|
|
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']
|
|
|
|
};
|
2011-12-23 10:51:53 +00:00
|
|
|
if (page === '') {
|
2013-07-09 09:05:24 +00:00
|
|
|
if (pandora.$ui.appPanel && pandora.$ui.home) {
|
|
|
|
// unless we're on page load, remove home screen
|
2012-02-19 12:58:49 +00:00
|
|
|
pandora.$ui.home.fadeOutScreen();
|
|
|
|
}
|
2013-03-04 12:32:08 +00:00
|
|
|
Ox.forEach(dialogPages, function(pages, dialog) {
|
|
|
|
// close all dialogs
|
|
|
|
if (pandora.$ui[dialog + 'Dialog']) {
|
|
|
|
pandora.$ui[dialog + 'Dialog'].close();
|
|
|
|
}
|
2012-02-18 06:35:38 +00:00
|
|
|
});
|
2013-08-10 08:58:22 +00:00
|
|
|
pandora.$ui.tv && pandora.$ui.tv.fadeOutScreen();
|
2011-12-23 10:51:53 +00:00
|
|
|
} else if (page == 'home') {
|
2013-07-09 09:05:24 +00:00
|
|
|
if (pandora.$ui.appPanel) {
|
|
|
|
// unless we're on page load, show home screen
|
|
|
|
pandora.$ui.home = pandora.ui.home().fadeInScreen();
|
|
|
|
}
|
2011-12-19 21:12:23 +00:00
|
|
|
} else if (page == 'tv') {
|
2013-07-09 09:05:24 +00:00
|
|
|
// if we're on page load, show tv immediately
|
2011-12-19 21:12:23 +00:00
|
|
|
pandora.$ui.tv = pandora.ui.tv()[
|
|
|
|
!pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen'
|
|
|
|
]();
|
2012-02-19 12:58:49 +00:00
|
|
|
pandora.$ui.home && pandora.$ui.tv.mute();
|
2014-01-17 13:49:11 +00:00
|
|
|
} else if (page == 'documents') {
|
|
|
|
if (pandora.user.ui.part.documents) {
|
2014-01-20 11:13:07 +00:00
|
|
|
pandora.openDocumentDialog({
|
|
|
|
ids: [pandora.user.ui.part.documents.split('/')[0]]
|
|
|
|
});
|
2014-01-17 13:49:11 +00:00
|
|
|
} else {
|
|
|
|
pandora.UI.set({page: ''});
|
|
|
|
}
|
2014-11-20 13:38:13 +00:00
|
|
|
} else if (page == 'entities') {
|
|
|
|
if (pandora.user.ui.part.entities) {
|
2014-11-21 14:46:10 +00:00
|
|
|
pandora.$ui.entityDialog = pandora.ui.entityDialog().open();
|
2014-11-20 13:38:13 +00:00
|
|
|
} else {
|
|
|
|
pandora.UI.set({page: ''});
|
|
|
|
}
|
2013-03-04 12:32:08 +00:00
|
|
|
} 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();
|
|
|
|
}
|
|
|
|
});
|
2013-08-10 08:58:22 +00:00
|
|
|
// remove tv (may be active behind home screen)
|
|
|
|
pandora.$ui.tv && pandora.$ui.tv.remove();
|
2013-03-04 12:32:08 +00:00
|
|
|
if (Ox.getIndexById(pandora.site.sitePages, page) > -1 || page == 'software') {
|
|
|
|
if (pandora.$ui.siteDialog && pandora.$ui.siteDialog.is(':visible')) {
|
|
|
|
pandora.$ui.siteDialog.select(page);
|
|
|
|
} else {
|
|
|
|
pandora.$ui.siteDialog = pandora.ui.siteDialog(page).open();
|
|
|
|
}
|
|
|
|
} else if (['signup', 'signin'].indexOf(page) > -1) {
|
|
|
|
if (pandora.user.level == 'guest') {
|
|
|
|
if (pandora.$ui.accountDialog && pandora.$ui.accountDialog.is(':visible')) {
|
|
|
|
pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions(page));
|
|
|
|
} else {
|
|
|
|
pandora.$ui.accountDialog = pandora.ui.accountDialog(page).open();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pandora.UI.set({page: ''});
|
|
|
|
}
|
|
|
|
} else if (['preferences', 'signout'].indexOf(page) > -1) {
|
|
|
|
if (pandora.user.level == 'guest') {
|
|
|
|
pandora.UI.set({page: ''});
|
|
|
|
} else if (page == 'preferences') {
|
|
|
|
pandora.$ui.preferencesDialog = pandora.ui.preferencesDialog().open();
|
|
|
|
} else {
|
|
|
|
pandora.ui.accountSignoutDialog().open();
|
|
|
|
}
|
|
|
|
} else if (page == 'help') {
|
|
|
|
pandora.$ui.helpDialog = pandora.ui.helpDialog().open();
|
|
|
|
} else if (page == 'api') {
|
|
|
|
pandora.$ui.apiDialog = pandora.ui.apiDialog().open();
|
|
|
|
}
|
2011-11-09 22:32:54 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|