2011-05-25 19:42:45 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=js
|
2010-09-05 00:31:29 +00:00
|
|
|
/***
|
|
|
|
Pandora
|
|
|
|
***/
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
// fixme: never set pandora.ui.videoPosition to 0 ... set to null a.k.a. delete
|
2011-01-30 03:54:38 +00:00
|
|
|
// fixme: sort=-director doesn't work
|
|
|
|
// fixme: don't reload full right panel on sortSelect
|
2011-02-09 14:29:26 +00:00
|
|
|
// fixme: clear items cache after login/logout
|
2011-04-23 06:30:07 +00:00
|
|
|
// fixme: rename config to site (site/user is better than config/user)
|
2011-05-25 19:42:45 +00:00
|
|
|
// fixme: replace global app object with pandora.app or move to pandora itself
|
2011-04-23 06:30:07 +00:00
|
|
|
Ox.load('UI', {
|
2011-04-27 19:26:01 +00:00
|
|
|
debug: true,
|
2011-04-23 06:30:07 +00:00
|
|
|
hideScreen: false,
|
2011-04-27 19:26:01 +00:00
|
|
|
loadImages: true,
|
2011-04-23 06:30:07 +00:00
|
|
|
showScreen: true,
|
|
|
|
theme: 'modern'
|
|
|
|
}, function() {
|
2011-01-30 03:54:38 +00:00
|
|
|
|
2011-05-24 19:59:13 +00:00
|
|
|
Ox.load('Geo', function() {
|
|
|
|
|
2011-04-23 06:30:07 +00:00
|
|
|
window.pandora = new Ox.App({url: '/api/'}).bindEvent({
|
2011-01-30 03:54:38 +00:00
|
|
|
|
2011-04-23 06:30:07 +00:00
|
|
|
load: function(event, data) {
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui = {};
|
|
|
|
loadResources('/static/json/pandora.json', function() {
|
|
|
|
Ox.print('Ox.App load', data);
|
|
|
|
|
|
|
|
Ox.UI.hideLoadingScreen();
|
|
|
|
|
|
|
|
$.extend(app, {
|
|
|
|
$ui: {
|
|
|
|
body: $('body'),
|
|
|
|
document: $(document),
|
|
|
|
window: $(window)
|
|
|
|
.resize(resizeWindow)
|
|
|
|
.unload(unloadWindow)
|
|
|
|
},
|
|
|
|
config: data.config,
|
|
|
|
ui: {
|
|
|
|
findKeys: $.map(data.config.itemKeys, function(key, i) {
|
|
|
|
return key.find ? key : null;
|
2011-01-24 04:08:45 +00:00
|
|
|
}),
|
2011-05-25 19:42:45 +00:00
|
|
|
infoRatio: 16 / 9,
|
|
|
|
sectionElement: 'buttons',
|
|
|
|
sectionFolders: {
|
|
|
|
site: $.merge([
|
|
|
|
{id: 'site', title: 'Site', items: $.merge([
|
|
|
|
{id: 'home', title: 'Home'}
|
|
|
|
], $.merge(data.config.sitePages, [
|
|
|
|
{id: 'software', title: 'Software'},
|
|
|
|
{id: 'help', title: 'Help'}
|
|
|
|
]))},
|
|
|
|
{id: 'user', title: 'User', items: [
|
|
|
|
{id: 'preferences', title: 'Preferences'},
|
|
|
|
{id: 'archives', title: 'Archives'}
|
|
|
|
]}
|
|
|
|
], data.user.level == 'admin' ? [
|
|
|
|
{id: 'admin', title: 'Admin', items: [
|
|
|
|
{id: 'statistics', title: 'Statistics'},
|
|
|
|
{id: 'users', title: 'Users'}
|
|
|
|
]}
|
|
|
|
] : []),
|
2011-01-21 09:40:53 +00:00
|
|
|
items: [
|
2011-05-25 19:42:45 +00:00
|
|
|
{id: 'personal', title: 'Personal Lists'},
|
|
|
|
{id: 'favorite', title: 'Favorite Lists', showBrowser: false},
|
|
|
|
{id: 'featured', title: 'Featured Lists', showBrowser: false}
|
|
|
|
],
|
|
|
|
},
|
|
|
|
selectedMovies: [],
|
|
|
|
sortKeys: $.map(data.config.itemKeys, function(key, i) {
|
|
|
|
return key.columnWidth ? key : null;
|
2011-04-20 18:52:15 +00:00
|
|
|
})
|
2011-01-15 06:09:31 +00:00
|
|
|
},
|
2011-05-25 19:42:45 +00:00
|
|
|
user: data.user.level == 'guest' ? $.extend({}, data.config.user) : data.user
|
2011-01-03 06:44:38 +00:00
|
|
|
});
|
2011-02-25 12:12:56 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
if (data.user.level == 'guest' && $.browser.mozilla) {
|
|
|
|
app.user.ui.theme = 'classic';
|
2011-02-03 21:39:42 +00:00
|
|
|
}
|
2011-01-13 01:58:11 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.URL.parse();
|
|
|
|
window.onpopstate = function() {
|
|
|
|
pandora.URL.update();
|
|
|
|
};
|
2010-12-26 20:16:56 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
Ox.Theme(app.user.ui.theme);
|
|
|
|
app.$ui.appPanel = pandora.ui.appPanel().display();
|
2011-01-18 04:07:40 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
Ox.Request.requests() && app.$ui.loadingIcon.start();
|
|
|
|
app.$ui.body.ajaxStart(app.$ui.loadingIcon.start);
|
|
|
|
app.$ui.body.ajaxStop(app.$ui.loadingIcon.stop);
|
2011-01-18 04:07:40 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
app.ui.sectionButtonsWidth = app.$ui.sectionButtons.width() + 8;
|
2011-01-15 06:09:31 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
window.pandora.app = app;
|
|
|
|
}, '/static/');
|
2011-01-14 09:54:35 +00:00
|
|
|
}
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
2011-01-03 23:39:10 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
app = {
|
|
|
|
requests: {}
|
|
|
|
};
|
|
|
|
|
|
|
|
function loadResources(json, callback, prefix) {
|
|
|
|
prefix = prefix || '';
|
|
|
|
$.getJSON(json, function(files) {
|
|
|
|
var promises = [];
|
|
|
|
files.forEach(function(file) {
|
|
|
|
// fixme: opera doesnt fire onload for svg
|
|
|
|
if ($.browser.opera && Ox.endsWith(file, '.svg')) {
|
|
|
|
return;
|
2011-04-20 18:52:15 +00:00
|
|
|
}
|
2011-05-25 19:42:45 +00:00
|
|
|
//Ox.print('load', file)
|
|
|
|
var dfd = new $.Deferred();
|
|
|
|
Ox.loadFile(prefix + file, function() {
|
|
|
|
dfd.resolve();
|
|
|
|
});
|
|
|
|
promises.push(dfd.promise());
|
|
|
|
});
|
|
|
|
//Ox.print('promises.length', promises.length)
|
|
|
|
$.when.apply(null, promises)
|
|
|
|
.done(function() {
|
|
|
|
//Ox.print('promises done')
|
|
|
|
$(function() {
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.fail(function() {
|
|
|
|
throw new Error('File not found.')
|
|
|
|
});
|
|
|
|
});
|
2011-01-21 09:40:53 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 21:12:52 +00:00
|
|
|
function resizeWindow() {
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.resizeFolders();
|
2011-02-09 14:29:26 +00:00
|
|
|
if (!app.user.ui.item) {
|
2011-01-17 21:12:52 +00:00
|
|
|
app.$ui.list.size();
|
2011-05-25 21:31:47 +00:00
|
|
|
pandora.resizeGroups(app.$ui.rightPanel.width());
|
2011-01-17 21:12:52 +00:00
|
|
|
if (app.user.ui.listView == 'map') {
|
2011-02-25 10:23:46 +00:00
|
|
|
app.$ui.map.resize();
|
2011-01-17 21:12:52 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//Ox.print('app.$ui.window.resize');
|
|
|
|
app.$ui.browser.scrollToSelection();
|
|
|
|
app.user.ui.itemView == 'player' && app.$ui.player.options({
|
|
|
|
// fixme: duplicated
|
2011-05-25 19:42:45 +00:00
|
|
|
height: app.$ui.contentPanel.size(1),
|
2011-01-17 21:12:52 +00:00
|
|
|
width: app.$ui.document.width() - app.$ui.mainPanel.size(0) - 1
|
|
|
|
});
|
|
|
|
app.user.ui.itemView == 'timeline' && app.$ui.editor.options({
|
|
|
|
// fixme: duplicated
|
2011-05-25 19:42:45 +00:00
|
|
|
height: app.$ui.contentPanel.size(1),
|
2011-02-03 21:39:42 +00:00
|
|
|
width: app.$ui.document.width() - app.$ui.mainPanel.size(0) - 1
|
2011-01-17 21:12:52 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 04:58:40 +00:00
|
|
|
function unloadWindow() {
|
|
|
|
// fixme: ajax request has to have async set to false for this to work
|
|
|
|
app.user.ui.section == 'items' &&
|
|
|
|
['player', 'timeline'].indexOf(app.user.ui.itemView) > -1 &&
|
|
|
|
app.user.ui.item &&
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.UI.set(
|
2011-01-23 04:58:40 +00:00
|
|
|
'videoPosition|' + app.user.ui.item,
|
|
|
|
app.$ui[
|
|
|
|
app.user.ui.itemView == 'player' ? 'player' : 'editor'
|
|
|
|
].options('position')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-22 23:33:51 +00:00
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|