2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-11-03 01:52:15 +00:00
|
|
|
|
2011-11-05 16:51:20 +00:00
|
|
|
'use strict';
|
|
|
|
|
2011-09-27 14:14:40 +00:00
|
|
|
/*
|
|
|
|
---- UI Tree ----
|
|
|
|
appPanel
|
|
|
|
mainMenu
|
|
|
|
mainPanel
|
|
|
|
leftPanel
|
|
|
|
sectionbar
|
|
|
|
folders
|
|
|
|
info
|
|
|
|
rightPanel
|
|
|
|
toolbar
|
|
|
|
contentPanel
|
|
|
|
browser <-- should be filters or browser
|
|
|
|
list or item
|
2011-11-04 15:56:38 +00:00
|
|
|
statusbar <-- make part of content panel
|
2011-09-27 14:14:40 +00:00
|
|
|
*/
|
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
(function() {
|
2013-02-18 07:22:47 +00:00
|
|
|
|
2011-11-03 01:52:15 +00:00
|
|
|
window.onerror = function(error, url, line) {
|
|
|
|
try {
|
2014-12-16 13:44:42 +00:00
|
|
|
!isMSIE && !/^resource:/.test(url) && pandora.api.logError({
|
2013-10-22 18:40:02 +00:00
|
|
|
text: error,
|
|
|
|
url: document.location.pathname + ' at ' + url,
|
2011-11-03 01:52:15 +00:00
|
|
|
line: line
|
|
|
|
});
|
|
|
|
} catch(e) {}
|
|
|
|
};
|
2013-07-12 10:33:09 +00:00
|
|
|
|
2013-07-12 20:32:51 +00:00
|
|
|
// handle legacy embed and print URLs
|
2014-01-22 12:25:17 +00:00
|
|
|
if ( document.location.hash) {
|
|
|
|
document.location.hash = document.location.hash.replace(
|
|
|
|
/^#\?(embed|print)=true(&)?/,
|
|
|
|
function() {
|
|
|
|
return '#' + arguments[1] + (arguments[2] ? '?' : '');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2013-07-12 10:33:09 +00:00
|
|
|
|
2012-05-24 13:45:15 +00:00
|
|
|
var animationInterval,
|
2013-03-22 09:54:49 +00:00
|
|
|
enableDebugMode = getLocalStorage('pandora.enableDebugMode'),
|
|
|
|
enableEventLogging = getLocalStorage('pandora.enableEventLogging'),
|
2013-07-12 10:33:09 +00:00
|
|
|
isEmbed = /^#embed(\?.*?)?$/.test(document.location.hash),
|
2013-08-08 12:31:35 +00:00
|
|
|
isMSIE = /MSIE/.test(navigator.userAgent)
|
|
|
|
&& !(Math.round(navigator.userAgent.match(/MSIE (\d+)/)[1]) >= 10),
|
2013-07-12 10:33:09 +00:00
|
|
|
isPrint = /^#print(\?.*?)?$/.test(document.location.hash),
|
2013-02-10 11:52:31 +00:00
|
|
|
legacyThemes = {classic: 'oxlight', modern: 'oxdark'},
|
2013-08-14 16:18:58 +00:00
|
|
|
logoHeight,
|
|
|
|
logoWidth,
|
2013-03-22 09:54:49 +00:00
|
|
|
theme = getLocalStorage('Ox.theme')
|
2013-02-10 11:52:31 +00:00
|
|
|
&& JSON.parse(localStorage['Ox.theme']) || 'oxmedium';
|
|
|
|
|
|
|
|
theme = legacyThemes[theme] || theme;
|
2011-05-25 19:42:45 +00:00
|
|
|
|
2013-02-18 10:18:03 +00:00
|
|
|
loadImages(function(images) {
|
|
|
|
loadScreen(images);
|
2012-05-28 11:36:10 +00:00
|
|
|
loadOxJS(function() {
|
2011-10-23 14:25:23 +00:00
|
|
|
loadOxUI(loadPandora);
|
2012-05-28 11:36:10 +00:00
|
|
|
});
|
2013-02-18 10:18:03 +00:00
|
|
|
});
|
2011-09-03 15:25:32 +00:00
|
|
|
|
2013-07-12 10:33:09 +00:00
|
|
|
function getLocalStorage(key) {
|
|
|
|
// fails if localStorage does not exist or if third party cookies are
|
|
|
|
// disabled
|
|
|
|
try {
|
|
|
|
return localStorage[key];
|
|
|
|
} catch(e) {}
|
|
|
|
}
|
|
|
|
|
2013-05-31 21:17:57 +00:00
|
|
|
function getPandoraVersion() {
|
|
|
|
var i, path, scripts = document.getElementsByTagName('script');
|
2013-12-29 12:03:42 +00:00
|
|
|
for (i = 0; i < scripts.length; i++) {
|
2013-05-31 21:17:57 +00:00
|
|
|
if(/pandora.js/.test(scripts[i].src)) {
|
2013-12-11 20:04:36 +00:00
|
|
|
return scripts[i].src.replace(/.*\?/, '');
|
2013-05-31 21:17:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
function loadImages(callback) {
|
|
|
|
// Opera doesn't fire onload for SVGs,
|
|
|
|
// so we only wait for the PNG to load.
|
|
|
|
var images = {};
|
|
|
|
images.logo = document.createElement('img');
|
|
|
|
images.logo.onload = function() {
|
2013-08-14 16:18:58 +00:00
|
|
|
var ratio = images.logo.width / images.logo.height;
|
|
|
|
logoWidth = isEmbed || isPrint ? 96 : 320;
|
|
|
|
logoHeight = Math.round(logoWidth / ratio);
|
2012-02-15 09:23:30 +00:00
|
|
|
images.logo.style.position = 'absolute';
|
|
|
|
images.logo.style.left = 0;
|
|
|
|
images.logo.style.top = 0;
|
|
|
|
images.logo.style.right = 0;
|
2013-08-14 16:18:58 +00:00
|
|
|
images.logo.style.bottom = logoHeight + 'px';
|
|
|
|
images.logo.style.width = logoWidth + 'px';
|
|
|
|
images.logo.style.height = logoHeight + 'px';
|
2012-02-15 09:23:30 +00:00
|
|
|
images.logo.style.margin = 'auto';
|
2014-02-12 17:56:41 +00:00
|
|
|
images.logo.style.MozUserSelect = 'none';
|
|
|
|
images.logo.style.MSUserSelect = 'none';
|
|
|
|
images.logo.style.OUserSelect = 'none';
|
|
|
|
images.logo.style.WebkitUserSelect = 'none';
|
2012-05-25 21:41:16 +00:00
|
|
|
if (!isMSIE) {
|
|
|
|
images.reflection = document.createElement('img');
|
|
|
|
images.reflection.style.position = 'absolute';
|
|
|
|
images.reflection.style.left = 0;
|
2013-08-14 16:18:58 +00:00
|
|
|
images.reflection.style.top = logoHeight + 'px';
|
2012-05-25 21:41:16 +00:00
|
|
|
images.reflection.style.right = 0;
|
|
|
|
images.reflection.style.bottom = 0;
|
2013-08-14 16:18:58 +00:00
|
|
|
images.reflection.style.width = logoWidth + 'px';
|
|
|
|
images.reflection.style.height = logoHeight + 'px';
|
2012-05-25 21:41:16 +00:00
|
|
|
images.reflection.style.margin = 'auto';
|
|
|
|
images.reflection.style.MozTransform = 'scaleY(-1)';
|
|
|
|
images.reflection.style.MSTransform = 'scaleY(-1)';
|
|
|
|
images.reflection.style.OTransform = 'scaleY(-1)';
|
|
|
|
images.reflection.style.WebkitTransform = 'scaleY(-1)';
|
2013-08-08 12:31:35 +00:00
|
|
|
images.reflection.style.transform = 'scaleY(-1)';
|
2012-05-25 21:41:16 +00:00
|
|
|
images.reflection.src = '/static/png/logo.png';
|
|
|
|
}
|
2012-02-15 09:23:30 +00:00
|
|
|
images.loadingIcon = document.createElement('img');
|
|
|
|
images.loadingIcon.setAttribute('id', 'loadingIcon');
|
|
|
|
images.loadingIcon.style.position = 'absolute';
|
|
|
|
images.loadingIcon.style.left = 0;
|
2013-03-09 03:49:15 +00:00
|
|
|
images.loadingIcon.style.top = isEmbed || isPrint ? '32px' : '80px';
|
2012-02-15 09:23:30 +00:00
|
|
|
images.loadingIcon.style.right = 0;
|
|
|
|
images.loadingIcon.style.bottom = 0;
|
2013-03-09 03:49:15 +00:00
|
|
|
images.loadingIcon.style.width = isEmbed || isPrint ? '16px' : '32px';
|
|
|
|
images.loadingIcon.style.height = isEmbed || isPrint ? '16px' : '32px';
|
2012-02-15 09:23:30 +00:00
|
|
|
images.loadingIcon.style.margin = 'auto';
|
2014-02-12 17:56:41 +00:00
|
|
|
images.loadingIcon.style.MozUserSelect = 'none';
|
|
|
|
images.loadingIcon.style.MSUserSelect = 'none';
|
|
|
|
images.loadingIcon.style.OUserSelect = 'none';
|
|
|
|
images.loadingIcon.style.WebkitUserSelect = 'none';
|
2014-09-27 15:06:01 +00:00
|
|
|
images.loadingIcon.src = '/static/oxjs/' + (enableDebugMode ? 'dev' : 'min')
|
2014-09-26 14:54:20 +00:00
|
|
|
+ '/UI/themes/' + theme + '/svg/symbolLoading.svg';
|
2011-10-23 14:25:23 +00:00
|
|
|
callback(images);
|
|
|
|
};
|
2012-04-20 10:22:32 +00:00
|
|
|
images.logo.src = '/static/png/logo.png';
|
2011-10-23 14:25:23 +00:00
|
|
|
}
|
2011-09-09 23:05:20 +00:00
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
function loadScreen(images) {
|
2012-05-25 21:41:16 +00:00
|
|
|
|
2013-08-14 16:18:58 +00:00
|
|
|
var gradient, loadingScreen;
|
2012-05-25 21:41:16 +00:00
|
|
|
if (!isMSIE) {
|
2013-08-14 16:18:58 +00:00
|
|
|
gradient = document.createElement('div');
|
2012-05-25 21:41:16 +00:00
|
|
|
gradient.style.position = 'absolute';
|
|
|
|
gradient.style.left = 0;
|
2013-08-14 16:18:58 +00:00
|
|
|
gradient.style.top = logoHeight + 'px';
|
2012-05-25 21:41:16 +00:00
|
|
|
gradient.style.right = 0;
|
|
|
|
gradient.style.bottom = 0;
|
2013-08-14 16:18:58 +00:00
|
|
|
// + 2 is a temporary fix for Chrome 26
|
|
|
|
gradient.style.width = logoWidth + 2 + 'px'
|
|
|
|
gradient.style.height = logoHeight + 2 + 'px';
|
2012-05-25 21:41:16 +00:00
|
|
|
gradient.style.margin = 'auto';
|
2013-08-08 12:31:35 +00:00
|
|
|
['-moz-', '-ms-', '-o-', '-webkit-', ''].forEach(function(prefix) {
|
|
|
|
gradient.style.background = theme == 'oxlight' ? prefix + 'linear-gradient(top, rgba(224, 224, 224, 0.75), rgba(224, 224, 224, 1), rgba(224, 224, 224, 1))'
|
|
|
|
: theme == 'oxmedium' ? prefix + 'linear-gradient(top, rgba(144, 144, 144, 0.75), rgba(144, 144, 144, 1), rgba(144, 144, 144, 1))'
|
|
|
|
: prefix + 'linear-gradient(top, rgba(32, 32, 32, 0.75), rgba(32, 32, 32, 1), rgba(32, 32, 32, 1))';
|
|
|
|
|
|
|
|
});
|
2012-05-25 21:41:16 +00:00
|
|
|
}
|
2013-08-14 16:18:58 +00:00
|
|
|
loadingScreen = document.createElement('div');
|
2011-10-23 14:25:23 +00:00
|
|
|
loadingScreen.setAttribute('id', 'loadingScreen');
|
|
|
|
loadingScreen.className = 'OxScreen';
|
|
|
|
loadingScreen.style.position = 'absolute';
|
|
|
|
loadingScreen.style.width = '100%';
|
|
|
|
loadingScreen.style.height = '100%';
|
2013-02-10 11:52:31 +00:00
|
|
|
loadingScreen.style.backgroundColor = theme == 'oxlight' ? 'rgb(224, 224, 224)'
|
|
|
|
: theme == 'oxmedium' ? 'rgb(144, 144, 144)' : 'rgb(32, 32, 32)';
|
2012-03-19 17:08:30 +00:00
|
|
|
loadingScreen.style.zIndex = '1002';
|
2011-10-23 14:25:23 +00:00
|
|
|
loadingScreen.appendChild(images.logo);
|
2012-05-25 21:41:16 +00:00
|
|
|
images.reflection && loadingScreen.appendChild(images.reflection);
|
|
|
|
gradient && loadingScreen.appendChild(gradient);
|
2011-10-23 14:25:23 +00:00
|
|
|
loadingScreen.appendChild(images.loadingIcon);
|
2012-05-25 21:41:16 +00:00
|
|
|
|
2012-06-30 11:56:58 +00:00
|
|
|
// FF3.6 document.body can be undefined here
|
2012-05-25 21:41:16 +00:00
|
|
|
window.onload = function() {
|
|
|
|
document.body.style.margin = 0;
|
|
|
|
document.body.appendChild(loadingScreen);
|
|
|
|
startAnimation();
|
|
|
|
};
|
2012-06-30 11:56:58 +00:00
|
|
|
// IE8 does not call onload if already loaded before set
|
2012-05-25 21:41:16 +00:00
|
|
|
document.body && window.onload();
|
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
}
|
2011-09-18 21:18:05 +00:00
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
function loadOxJS(callback) {
|
2012-02-18 06:44:52 +00:00
|
|
|
var head = document.head
|
|
|
|
|| document.getElementsByTagName('head')[0]
|
|
|
|
|| document.documentElement,
|
|
|
|
script = document.createElement('script');
|
2012-05-25 21:41:16 +00:00
|
|
|
if (isMSIE) {
|
|
|
|
// fixme: find a way to check if css/js have loaded in msie
|
|
|
|
setTimeout(callback, 2500);
|
|
|
|
} else {
|
|
|
|
script.onload = callback;
|
|
|
|
}
|
2014-09-26 14:54:20 +00:00
|
|
|
script.src = '/static/oxjs/' + (enableDebugMode ? 'dev' : 'min') + '/Ox.js?' + getPandoraVersion();
|
2011-10-23 14:25:23 +00:00
|
|
|
script.type = 'text/javascript';
|
2012-02-18 06:44:52 +00:00
|
|
|
head.appendChild(script);
|
2011-10-23 14:25:23 +00:00
|
|
|
}
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
function loadOxUI(callback) {
|
|
|
|
Ox.load({
|
2013-02-18 10:18:03 +00:00
|
|
|
UI: {theme: theme},
|
2011-10-23 14:25:23 +00:00
|
|
|
Geo: {}
|
2011-11-04 11:24:54 +00:00
|
|
|
}, callback);
|
2011-10-23 14:25:23 +00:00
|
|
|
}
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
function loadPandora(browserSupported) {
|
2011-12-30 20:47:40 +00:00
|
|
|
window.pandora = Ox.App({
|
|
|
|
name: 'pandora',
|
2012-05-25 22:00:06 +00:00
|
|
|
url: '/api/'
|
2011-12-30 20:47:40 +00:00
|
|
|
}).bindEvent({
|
2011-10-23 14:25:23 +00:00
|
|
|
load: function(data) {
|
|
|
|
data.browserSupported = browserSupported;
|
|
|
|
Ox.extend(pandora, {
|
|
|
|
requests: {},
|
|
|
|
ui: {}
|
2011-09-09 23:05:20 +00:00
|
|
|
});
|
2011-10-23 14:25:23 +00:00
|
|
|
loadPandoraFiles(function() {
|
2012-06-30 11:56:58 +00:00
|
|
|
enableEventLogging && Ox.Event.bind(pandora.logEvent);
|
2011-10-23 14:25:23 +00:00
|
|
|
initPandora(data);
|
2011-12-30 20:47:40 +00:00
|
|
|
if (pandora.localStorage('local')) {
|
|
|
|
var url = pandora.localStorage('local');
|
2011-12-27 06:54:49 +00:00
|
|
|
window.pandora.local = Ox.API({
|
2013-02-24 09:16:16 +00:00
|
|
|
url: url + '/api/'
|
2011-12-27 06:54:49 +00:00
|
|
|
}, function() {
|
2011-12-30 20:47:40 +00:00
|
|
|
pandora.site.site.videoprefix = url;
|
2011-12-27 06:54:49 +00:00
|
|
|
});
|
|
|
|
}
|
2011-09-20 04:11:25 +00:00
|
|
|
});
|
2011-10-23 14:25:23 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2011-09-20 04:11:25 +00:00
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
function loadPandoraFiles(callback) {
|
2011-10-23 02:29:20 +00:00
|
|
|
var prefix = '/static/';
|
2012-06-30 11:56:58 +00:00
|
|
|
if (enableDebugMode) {
|
2012-01-14 10:49:15 +00:00
|
|
|
Ox.getJSON(prefix + 'json/pandora.json?' + Ox.random(1000), function(files) {
|
2012-06-17 12:54:50 +00:00
|
|
|
Ox.getFile(files.map(function(file) {
|
2014-01-22 10:16:03 +00:00
|
|
|
return prefix + file + '?' + getPandoraVersion();
|
2012-04-19 12:29:47 +00:00
|
|
|
}), callback);
|
2011-09-09 23:05:20 +00:00
|
|
|
});
|
2011-10-23 02:29:20 +00:00
|
|
|
} else {
|
2014-01-02 13:44:41 +00:00
|
|
|
Ox.getScript(prefix + 'js/pandora.min.js?' + getPandoraVersion(), callback);
|
2011-10-23 02:29:20 +00:00
|
|
|
}
|
2011-09-09 23:05:20 +00:00
|
|
|
}
|
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
function initPandora(data) {
|
|
|
|
|
2011-11-04 15:54:42 +00:00
|
|
|
Ox.Log('', 'Ox.App load', data);
|
2011-10-23 14:25:23 +00:00
|
|
|
Ox.extend(pandora, {
|
|
|
|
$ui: {
|
|
|
|
body: $('body'),
|
|
|
|
document: $(document),
|
|
|
|
window: $(window)
|
2012-05-28 14:10:11 +00:00
|
|
|
.on({
|
2013-05-09 17:33:20 +00:00
|
|
|
beforeunload: pandora.beforeUnloadWindow,
|
2013-02-22 02:28:24 +00:00
|
|
|
resize: pandora.resizeWindow,
|
2012-03-17 00:15:06 +00:00
|
|
|
unload: pandora.unloadWindow
|
2011-10-23 14:25:23 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
site: data.site,
|
2011-11-04 15:56:38 +00:00
|
|
|
user: data.user
|
2011-10-23 14:25:23 +00:00
|
|
|
});
|
2011-11-05 22:14:10 +00:00
|
|
|
// make sure all valid ui settings are present
|
2011-11-04 15:56:38 +00:00
|
|
|
pandora.user.ui = Ox.extend(
|
|
|
|
Ox.clone(pandora.site.user.ui), pandora.user.ui
|
|
|
|
);
|
2011-11-05 22:14:10 +00:00
|
|
|
// make sure no invalid ui settings are present
|
|
|
|
Object.keys(pandora.user.ui).forEach(function(key) {
|
|
|
|
if (Ox.isUndefined(pandora.site.user.ui[key])) {
|
|
|
|
delete pandora.user.ui[key];
|
|
|
|
}
|
|
|
|
});
|
2013-10-22 14:27:46 +00:00
|
|
|
// make sure itemSort is valid
|
|
|
|
if (!Ox.contains(pandora.site.itemKeys.filter(function(itemKey) {
|
|
|
|
return itemKey.sort;
|
|
|
|
}).map(function(itemKey) {
|
|
|
|
return itemKey.id;
|
|
|
|
}), pandora.user.ui.itemSort[0].key)) {
|
|
|
|
pandora.user.ui.itemSort = pandora.site.user.ui.itemSort;
|
|
|
|
}
|
|
|
|
// make sure itemView is valid
|
|
|
|
if (!Ox.contains(pandora.site.itemViews.map(function(itemView) {
|
|
|
|
return itemView.id;
|
|
|
|
}), pandora.user.ui.itemView)) {
|
|
|
|
pandora.user.ui.itemView = pandora.site.user.ui.itemView;
|
|
|
|
}
|
2013-02-10 11:52:31 +00:00
|
|
|
// patch theme ... this can be removed at a later point
|
|
|
|
pandora.user.ui.theme = legacyThemes[pandora.user.ui.theme] || pandora.user.ui.theme;
|
2013-02-19 11:48:25 +00:00
|
|
|
// make sure theme is valid
|
|
|
|
if (!Ox.contains(pandora.site.themes, pandora.user.ui.theme)) {
|
|
|
|
pandora.user.ui.theme = pandora.site.user.ui.theme;
|
|
|
|
}
|
2012-04-17 07:06:19 +00:00
|
|
|
// patch itemView ... this can be removed at a later point
|
|
|
|
if (pandora.user.ui.itemView == 'video') {
|
|
|
|
pandora.user.ui.itemView = 'player';
|
|
|
|
}
|
2011-11-04 15:56:38 +00:00
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
Ox.extend(pandora.site, {
|
2012-02-02 05:16:32 +00:00
|
|
|
calendar: data.site.layers.some(function(layer) {
|
|
|
|
return layer.type == 'event'
|
|
|
|
}) ? 'manual' : data.site.layers.some(function(layer) {
|
|
|
|
return layer.hasEvents;
|
|
|
|
}) ? 'auto' : 'none',
|
2012-05-22 15:07:34 +00:00
|
|
|
clipKeys: data.site.clipKeys.map(function(key) {
|
2011-10-23 14:25:23 +00:00
|
|
|
return Ox.extend(key, {
|
|
|
|
operator: pandora.getSortOperator(key.id)
|
|
|
|
});
|
|
|
|
}),
|
2013-09-30 18:34:44 +00:00
|
|
|
filters: data.site.itemKeys.filter(function(key) {
|
|
|
|
return key.filter;
|
|
|
|
}).map(function(key) {
|
|
|
|
return {
|
|
|
|
id: key.id,
|
|
|
|
title: key.title,
|
|
|
|
type: Ox.isArray(key.type) ? key.type[0] : key.type
|
|
|
|
};
|
|
|
|
}),
|
2012-05-22 15:07:34 +00:00
|
|
|
findKeys: data.site.itemKeys.filter(function(key) {
|
|
|
|
return key.find;
|
2011-10-23 14:25:23 +00:00
|
|
|
}),
|
|
|
|
itemsSection: pandora.site.itemName.plural.toLowerCase(),
|
2012-02-02 05:16:32 +00:00
|
|
|
map: data.site.layers.some(function(layer) {
|
|
|
|
return layer.type == 'place'
|
|
|
|
}) ? 'manual' : data.site.layers.some(function(layer) {
|
|
|
|
return layer.hasPlaces;
|
|
|
|
}) ? 'auto' : 'none',
|
2011-10-23 14:25:23 +00:00
|
|
|
sectionFolders: {
|
|
|
|
items: [
|
|
|
|
{id: 'personal', title: 'Personal Lists'},
|
|
|
|
{id: 'favorite', title: 'Favorite Lists', showBrowser: false},
|
|
|
|
{id: 'featured', title: 'Featured Lists', showBrowser: false},
|
|
|
|
{id: 'volumes', title: 'Local Volumes'}
|
|
|
|
],
|
|
|
|
edits: [
|
|
|
|
{id: 'personal', title: 'Personal Edits'},
|
|
|
|
{id: 'favorite', title: 'Favorite Edits', showBrowser: false},
|
2011-10-29 17:46:46 +00:00
|
|
|
{id: 'featured', title: 'Featured Edits', showBrowser: false}
|
2011-10-23 14:25:23 +00:00
|
|
|
],
|
|
|
|
texts: [
|
|
|
|
{id: 'personal', title: 'Personal Texts'},
|
|
|
|
{id: 'favorite', title: 'Favorite Texts', showBrowser: false},
|
2011-10-29 17:46:46 +00:00
|
|
|
{id: 'featured', title: 'Featured Texts', showBrowser: false}
|
|
|
|
]
|
2011-10-23 14:25:23 +00:00
|
|
|
},
|
2012-06-30 20:00:41 +00:00
|
|
|
sortKeys: pandora.getSortKeys()
|
2011-10-23 14:25:23 +00:00
|
|
|
});
|
|
|
|
pandora.site.listSettings = {};
|
2012-05-22 15:07:34 +00:00
|
|
|
Ox.forEach(pandora.site.user.ui, function(val, key) {
|
2011-10-23 14:25:23 +00:00
|
|
|
if (/^list[A-Z]/.test(key)) {
|
2012-05-24 09:56:52 +00:00
|
|
|
pandora.site.listSettings[key] = key[4].toLowerCase() + key.slice(5);
|
2011-10-23 14:25:23 +00:00
|
|
|
}
|
|
|
|
});
|
2013-08-07 14:31:35 +00:00
|
|
|
pandora.site.editSettings = {
|
|
|
|
clip: '',
|
|
|
|
'in': 0,
|
|
|
|
out: 0,
|
|
|
|
position: 0,
|
2013-08-09 12:54:34 +00:00
|
|
|
selection: [],
|
2013-08-07 15:09:28 +00:00
|
|
|
sort: [{key: 'index', operator: '+'}],
|
|
|
|
view: 'list'
|
2013-08-07 14:31:35 +00:00
|
|
|
};
|
2013-08-07 15:23:49 +00:00
|
|
|
pandora.site.textSettings = {
|
2013-11-08 18:57:24 +00:00
|
|
|
position: 0,
|
|
|
|
name: ''
|
2013-08-07 15:23:49 +00:00
|
|
|
};
|
2011-10-23 14:25:23 +00:00
|
|
|
|
|
|
|
Ox.extend(pandora.user, {
|
|
|
|
sectionElement: 'buttons',
|
2013-07-09 14:36:11 +00:00
|
|
|
videoFormat: Ox.getVideoFormat(pandora.site.video.formats)
|
2011-10-23 14:25:23 +00:00
|
|
|
});
|
|
|
|
|
2013-07-09 09:04:35 +00:00
|
|
|
// set locale and initialize url controller
|
2013-07-28 15:57:14 +00:00
|
|
|
// data.locale is prefered language according to http header
|
|
|
|
//pandora.setLocale(pandora.user.ui.locale || data.locale, function() {
|
|
|
|
pandora.setLocale(pandora.user.ui.locale, function() {
|
2013-05-09 10:13:58 +00:00
|
|
|
pandora.URL.init().parse(function() {
|
2013-07-09 09:04:35 +00:00
|
|
|
var isHome = Ox.contains(['/', '/home'], document.location.pathname);
|
2013-05-09 10:13:58 +00:00
|
|
|
if (data.browserSupported) {
|
|
|
|
stopAnimation();
|
|
|
|
$('#loadingScreen').remove();
|
|
|
|
} else {
|
|
|
|
loadBrowserMessage();
|
|
|
|
}
|
|
|
|
Ox.Theme(pandora.user.ui.theme);
|
|
|
|
if (isEmbed) {
|
|
|
|
pandora.$ui.embedPanel = pandora.ui.embedPanel().display();
|
2014-09-23 21:48:59 +00:00
|
|
|
Ox.$parent.bindMessage({
|
2013-05-09 10:13:58 +00:00
|
|
|
settheme: function(data) {
|
|
|
|
if (Ox.contains(pandora.site.themes, data.theme)) {
|
|
|
|
Ox.Theme(data.theme);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
seturl: function(data) {
|
|
|
|
if (pandora.isEmbedURL(data.url)) {
|
|
|
|
pandora.URL.push(data.url);
|
|
|
|
}
|
2013-02-25 08:14:13 +00:00
|
|
|
}
|
2013-05-09 10:13:58 +00:00
|
|
|
});
|
|
|
|
} else if (isPrint) {
|
|
|
|
pandora.$ui.printView = pandora.ui.printView().display();
|
2013-07-09 09:04:35 +00:00
|
|
|
} else if (isHome) {
|
|
|
|
pandora.$ui.home = pandora.ui.home().showScreen(initPandoraApp);
|
2013-05-09 10:13:58 +00:00
|
|
|
} else {
|
2013-07-09 09:04:35 +00:00
|
|
|
initPandoraApp();
|
2012-01-27 14:28:49 +00:00
|
|
|
}
|
2013-05-09 10:13:58 +00:00
|
|
|
});
|
2011-10-23 14:25:23 +00:00
|
|
|
});
|
2011-10-29 17:46:46 +00:00
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 09:04:35 +00:00
|
|
|
function initPandoraApp() {
|
2013-08-03 15:01:47 +00:00
|
|
|
pandora.clipboard = Ox.Clipboard();
|
2013-08-03 14:00:58 +00:00
|
|
|
pandora.history = Ox.History();
|
2013-07-09 09:04:35 +00:00
|
|
|
pandora.$ui.appPanel = pandora.ui.appPanel().display();
|
2013-07-28 09:52:13 +00:00
|
|
|
pandora.$ui.loadingIcon.update(Ox.Request.requests());
|
2013-07-09 09:04:35 +00:00
|
|
|
Ox.Request.bindEvent({
|
|
|
|
error: pandora.ui.errorDialog,
|
|
|
|
request: function(data) {
|
2013-07-28 09:52:13 +00:00
|
|
|
pandora.$ui.loadingIcon.update(data.requests);
|
2013-07-09 09:04:35 +00:00
|
|
|
}
|
|
|
|
});
|
2013-10-25 13:49:45 +00:00
|
|
|
Ox.Fullscreen.bind('exit', pandora.UI.set);
|
2013-07-09 09:04:35 +00:00
|
|
|
pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8;
|
2014-04-09 15:44:28 +00:00
|
|
|
pandora.loadUserScript();
|
2013-07-09 09:04:35 +00:00
|
|
|
}
|
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
function loadBrowserMessage() {
|
2012-05-25 21:41:16 +00:00
|
|
|
var browsers = [].concat(
|
2011-10-23 14:25:23 +00:00
|
|
|
isMSIE ? [{name: 'Chrome Frame', url: 'http://google.com/chromeframe/'}] : [],
|
|
|
|
[
|
|
|
|
{name: 'Chrome', url: 'http://google.com/chrome/'},
|
|
|
|
{name: 'Firefox', url: 'http://mozilla.org/firefox/'},
|
|
|
|
{name: 'Safari', url: 'http://apple.com/safari/'}
|
|
|
|
]
|
|
|
|
),
|
|
|
|
images = browsers.map(function(browser) {
|
2014-09-29 13:23:13 +00:00
|
|
|
return Ox.PATH + 'UI/png/browser' + browser.name.replace(' ', '') + '128.png';
|
2011-10-23 14:25:23 +00:00
|
|
|
}),
|
|
|
|
$loadingScreen = $('#loadingScreen');
|
2012-06-17 12:54:50 +00:00
|
|
|
Ox.getFile(images, function() {
|
2011-10-23 14:25:23 +00:00
|
|
|
var html = pandora.site.site.name
|
|
|
|
+ ' requires an up-to-date web browser. Please take a moment to '
|
|
|
|
+ (
|
|
|
|
isMSIE
|
|
|
|
? 'install <a href="' + browsers[0].url + '">' + browsers[0].name + '</a> or '
|
|
|
|
: ''
|
|
|
|
)
|
|
|
|
+ 'download ' + browsers.filter(function(browser) {
|
|
|
|
return browser.name != 'Chrome Frame';
|
|
|
|
}).map(function(browser, i) {
|
|
|
|
return '<a href="' + browser.url + '">' + browser.name + '</a>'
|
|
|
|
+ (i == 0 ? ', ' : i == 1 ? ' or ' : '');
|
|
|
|
}).join('')
|
|
|
|
+ '. Otherwise, <a href="javascript:pandora.proceed()">proceed</a> at your own risk.',
|
|
|
|
$message = $('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: 0,
|
|
|
|
top: '160px',
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
width: '320px',
|
|
|
|
height: '160px',
|
|
|
|
margin: 'auto'
|
|
|
|
}),
|
|
|
|
$images = $('<div>')
|
|
|
|
.css({
|
|
|
|
margin: '12px',
|
|
|
|
textAlign: 'center'
|
|
|
|
})
|
|
|
|
.appendTo($message);
|
2012-05-24 13:45:15 +00:00
|
|
|
stopAnimation();
|
2011-10-23 14:25:23 +00:00
|
|
|
$('#loadingIcon').remove();
|
|
|
|
$message.appendTo($loadingScreen);
|
|
|
|
browsers.forEach(function(browser) {
|
|
|
|
$('<a>')
|
|
|
|
.attr({
|
|
|
|
href: browser.url,
|
|
|
|
title: browser.name
|
|
|
|
})
|
|
|
|
.append(
|
|
|
|
$('<img>')
|
|
|
|
.attr({
|
2014-09-29 13:23:13 +00:00
|
|
|
src: Ox.PATH + 'UI/png/browser' + browser.name.replace(' ', '') + '128.png'
|
2011-10-23 14:25:23 +00:00
|
|
|
})
|
2012-02-18 06:44:52 +00:00
|
|
|
.css({width: '32px', height: '32px', border: 0, margin: '4px'})
|
2011-10-23 14:25:23 +00:00
|
|
|
)
|
|
|
|
.appendTo($images);
|
2011-10-29 17:46:46 +00:00
|
|
|
});
|
2011-10-23 14:25:23 +00:00
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
textAlign: 'center'
|
|
|
|
})
|
|
|
|
.html(html)
|
|
|
|
.appendTo($message);
|
|
|
|
});
|
|
|
|
|
|
|
|
pandora.proceed = function() {
|
|
|
|
$loadingScreen.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, 1000, function() {
|
|
|
|
$loadingScreen.remove();
|
|
|
|
});
|
2013-08-03 14:00:58 +00:00
|
|
|
};
|
2011-10-23 14:25:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-05-24 13:45:15 +00:00
|
|
|
function startAnimation() {
|
|
|
|
var css, deg = 0, loadingIcon = document.getElementById('loadingIcon'),
|
|
|
|
previousTime = +new Date();
|
|
|
|
animationInterval = setInterval(function() {
|
|
|
|
var currentTime = +new Date(),
|
|
|
|
delta = (currentTime - previousTime) / 1000;
|
|
|
|
previousTime = currentTime;
|
|
|
|
deg = Math.round((deg + delta * 360) % 360 / 30) * 30;
|
|
|
|
css = 'rotate(' + deg + 'deg)';
|
|
|
|
loadingIcon.style.MozTransform = css;
|
2012-05-25 21:41:16 +00:00
|
|
|
loadingIcon.style.MSTransform = css;
|
2012-05-24 17:26:01 +00:00
|
|
|
loadingIcon.style.OTransform = css;
|
2012-05-24 13:45:15 +00:00
|
|
|
loadingIcon.style.WebkitTransform = css;
|
2013-08-08 12:31:35 +00:00
|
|
|
loadingIcon.style.transform = css;
|
2012-05-24 13:45:15 +00:00
|
|
|
}, 83);
|
|
|
|
}
|
|
|
|
|
|
|
|
function stopAnimation() {
|
|
|
|
clearInterval(animationInterval);
|
|
|
|
}
|
|
|
|
|
2011-10-23 14:25:23 +00:00
|
|
|
}());
|