2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-06-16 20:00:10 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.enterFullscreen = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.appPanel.size(0, 0);
|
|
|
|
pandora.user.ui.showSidebar && pandora.$ui.mainPanel.size(0, 0);
|
|
|
|
pandora.$ui.rightPanel.size(0, 0).size(2, 0);
|
|
|
|
!pandora.user.ui.showMovies && pandora.$ui.contentPanel.css({
|
2011-05-25 19:42:45 +00:00
|
|
|
top: (-112 - Ox.UI.SCROLLBAR_SIZE) + 'px' // fixme: rightPanel.size(0, 0) doesn't preserve negative top of browser
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user.ui.showMovies && pandora.$ui.contentPanel.size(0, 0);
|
|
|
|
pandora.$ui.player.options({
|
|
|
|
height: pandora.$document.height() - 2,
|
|
|
|
width: pandora.$document.width() - 2
|
2011-06-16 20:00:10 +00:00
|
|
|
});
|
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.exitFullscreen = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.appPanel.size(0, 20);
|
|
|
|
pandora.user.ui.showSidebar && pandora.$ui.mainPanel.size(0, pandora.user.ui.sidebarSize);
|
|
|
|
pandora.$ui.rightPanel.size(0, 24).size(2, 16);
|
|
|
|
!pandora.user.ui.showMovies && pandora.$ui.contentPanel.css({
|
2011-05-25 19:42:45 +00:00
|
|
|
top: 24 + (-112 - Ox.UI.SCROLLBAR_SIZE) + 'px' // fixme: rightPanel.size(0, 0) doesn't preserve negative top of browser
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user.ui.showMovies && pandora.$ui.contentPanel.size(0, 112 + Ox.UI.SCROLLBAR_SIZE);
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.getFoldersHeight = function() {
|
|
|
|
var height = 48;
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.site.sectionFolders[pandora.user.ui.section].forEach(function(folder, i) {
|
|
|
|
height += pandora.user.ui.showFolder[pandora.user.ui.section][folder.id] * (
|
2011-05-25 19:42:45 +00:00
|
|
|
!!folder.showBrowser * 40 + folder.items * 16
|
|
|
|
);
|
2011-06-16 20:00:10 +00:00
|
|
|
Ox.print('h', height);
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
/*
|
2011-06-06 15:48:11 +00:00
|
|
|
$.each(pandora.user.ui.showFolder[pandora.user.ui.section], function(id, show) {
|
|
|
|
var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id);
|
2011-05-25 19:42:45 +00:00
|
|
|
height += show * (
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.site.sectionFolders[pandora.user.ui.section][i].showBrowser * 40 +
|
|
|
|
pandora.site.sectionFolders[pandora.user.ui.section][i].items * 16
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
return height;
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.getFoldersWidth = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
var width = pandora.user.ui.sidebarSize;
|
2011-05-25 19:42:45 +00:00
|
|
|
// fixme: don't use height(), look up in splitpanels
|
2011-06-16 20:00:10 +00:00
|
|
|
Ox.print(pandora.getFoldersHeight(), '>', pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height());
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.getFoldersHeight() > pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height()) {
|
2011-05-25 19:42:45 +00:00
|
|
|
width -= Ox.UI.SCROLLBAR_SIZE;
|
|
|
|
}
|
|
|
|
return width;
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.getGroupWidth = function(pos, panelWidth) { // fixme: don't pass panelWidth
|
|
|
|
var width = {};
|
|
|
|
width.list = Math.floor(panelWidth / 5) + (panelWidth % 5 > pos);
|
|
|
|
width.column = width.list - 40 - Ox.UI.SCROLLBAR_SIZE;
|
|
|
|
return width;
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.getSortOperator = function(key) { // fixme: make static
|
2011-06-06 15:48:11 +00:00
|
|
|
var type = Ox.getObjectById(pandora.site.itemKeys, key).type;
|
2011-05-25 19:42:45 +00:00
|
|
|
return ['hue', 'string', 'text'].indexOf(
|
|
|
|
Ox.isArray(type) ? type[0] : type
|
|
|
|
) > -1 ? '+' : '-';
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.login = function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user = data.user;
|
|
|
|
Ox.Theme(pandora.user.ui.theme);
|
|
|
|
pandora.$ui.appPanel.reload();
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.logout = function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user = data.user;
|
|
|
|
Ox.Theme(pandora.site.user.ui.theme);
|
|
|
|
pandora.$ui.appPanel.reload();
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.reloadGroups = function(i) {
|
2011-06-16 20:00:10 +00:00
|
|
|
var query = pandora.Query.toObject(),
|
|
|
|
view = pandora.user.ui.lists[pandora.user.ui.list].listView;
|
|
|
|
if(view == 'clip') {
|
|
|
|
pandora.$ui.list.options({
|
|
|
|
items: function(data, callback) {
|
|
|
|
return pandora.api.findAnnotations($.extend(data, {
|
|
|
|
itemQuery: query
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (view == 'map') {
|
2011-06-18 18:48:49 +00:00
|
|
|
pandora.$ui.map.options({
|
|
|
|
places: function(data, callback) {
|
2011-06-16 20:00:10 +00:00
|
|
|
return pandora.api.findPlaces($.extend(data, {
|
|
|
|
itemQuery: query
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (view == 'calendar') {
|
|
|
|
pandora.$ui.list.options({
|
|
|
|
items: function(data, callback) {
|
|
|
|
return pandora.api.findEvents($.extend(data, {
|
|
|
|
itemQuery: query
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
pandora.$ui.list.options({
|
|
|
|
items: function(data, callback) {
|
|
|
|
return pandora.api.find($.extend(data, {
|
|
|
|
query: query
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2011-06-06 15:48:11 +00:00
|
|
|
$.each(pandora.user.queryGroups, function(i_, group_) {
|
2011-05-25 19:42:45 +00:00
|
|
|
if (i_ != i) {
|
|
|
|
//Ox.print('setting groups request', i, i_)
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.groups[i_].options({
|
2011-05-25 19:42:45 +00:00
|
|
|
items: function(data, callback) {
|
|
|
|
delete data.keys;
|
|
|
|
return pandora.api.find($.extend(data, {
|
|
|
|
group: group_.id,
|
|
|
|
query: pandora.Query.toObject(group_.id)
|
|
|
|
}), callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2011-08-17 13:23:17 +00:00
|
|
|
pandora.URL.push(pandora.Query.toString());
|
2011-06-19 18:11:27 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.getListData = function() {
|
|
|
|
var data = {};
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.user.ui.list) {
|
|
|
|
var folder = pandora.$ui.folderList['personal'].options('selected')[0] ==
|
|
|
|
pandora.user.ui.list ? 'personal' : 'featured';
|
|
|
|
data = pandora.$ui.folderList[folder].value(pandora.user.ui.list);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
2011-06-06 15:48:11 +00:00
|
|
|
data.editable = data.user == pandora.user.username && data.type == 'static';
|
2011-05-25 19:42:45 +00:00
|
|
|
return data;
|
2011-06-19 18:11:27 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
2011-08-19 16:49:09 +00:00
|
|
|
pandora.getVideoPartAndPosition = function(durations, position) {
|
|
|
|
var duration = 0, ret;
|
|
|
|
Ox.forEach(durations, function(d, i) {
|
|
|
|
if (duration + d > position) {
|
|
|
|
ret = {
|
|
|
|
part: i,
|
|
|
|
position: position - duration
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
duration += d;
|
|
|
|
});
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.reloadList = function() {
|
|
|
|
Ox.print('reloadList')
|
|
|
|
var listData = pandora.getListData();
|
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.groups.forEach(function($group) {
|
2011-05-25 19:42:45 +00:00
|
|
|
$group.reloadList();
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.list.bindEvent({
|
2011-05-25 19:42:45 +00:00
|
|
|
init: function(event, data) {
|
2011-06-04 16:42:07 +00:00
|
|
|
var folder = listData.status == 'private' ? 'personal' : listData.status;
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[folder].value(listData.id, 'items', data.items);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.bindEventOnce({
|
|
|
|
load: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.list.gainFocus();
|
|
|
|
if (data) pandora.$ui.list.options({selected: [data.items]});
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.reloadList();
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.resizeGroups = function(width) {
|
2011-06-06 15:48:11 +00:00
|
|
|
var widths = $.map(pandora.user.queryGroups, function(v, i) {
|
2011-05-25 19:42:45 +00:00
|
|
|
return pandora.getGroupWidth(i, width);
|
|
|
|
});
|
|
|
|
//Ox.print('widths', widths);
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.browser.size(0, widths[0].list).size(2, widths[4].list);
|
|
|
|
pandora.$ui.groupsInnerPanel.size(0, widths[1].list).size(2, widths[3].list);
|
|
|
|
$.each(pandora.$ui.groups, function(i, list) {
|
2011-05-25 19:42:45 +00:00
|
|
|
list.resizeColumn('name', widths[i].column);
|
|
|
|
});
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.resizeFolders = function() {
|
|
|
|
var width = pandora.getFoldersWidth(),
|
|
|
|
columnWidth = {};
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.user.ui.section == 'site') {
|
2011-05-25 19:42:45 +00:00
|
|
|
columnWidth.title = width - 16;
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.section == 'items') {
|
2011-05-25 19:42:45 +00:00
|
|
|
columnWidth = {user: parseInt((width - 88) * 0.4)};
|
|
|
|
columnWidth.name = (width - 88) - columnWidth.user;
|
|
|
|
}
|
|
|
|
//Ox.print('sectionsWidth', width)
|
2011-06-06 15:48:11 +00:00
|
|
|
$.each(pandora.$ui.folderList, function(id, $list) {
|
|
|
|
var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id);
|
|
|
|
pandora.$ui.folder[i].css({width: width + 'px'});
|
2011-05-25 19:42:45 +00:00
|
|
|
$list.css({width: width + 'px'});
|
|
|
|
Ox.print('...', id, $list.options())
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.user.ui.section == 'site') {
|
2011-05-25 19:42:45 +00:00
|
|
|
$list.resizeColumn('title', columnWidth.title);
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.section == 'items') {
|
|
|
|
if (pandora.site.sectionFolders[pandora.user.ui.section][i].showBrowser) {
|
2011-05-25 19:42:45 +00:00
|
|
|
$list.resizeColumn('user', columnWidth.user)
|
|
|
|
.resizeColumn('name', columnWidth.name);
|
|
|
|
} else {
|
|
|
|
$list.resizeColumn(id == 'favorite' ? 'id' : 'name', width - 88);
|
|
|
|
}
|
|
|
|
}
|
2011-06-06 15:48:11 +00:00
|
|
|
if (!pandora.user.ui.showFolder[pandora.user.ui.section][id]) {
|
|
|
|
pandora.$ui.folder[i].update();
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
});
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.saveVideoPosition = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
//alert(JSON.stringify(['videoPosition|' + old.user.ui.item, pandora.$ui[old.user.ui.itemView == 'player' ? 'player' : 'editor'].options('position')]));
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|
|
|
|
pandora.selectList = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.user.ui.list) {
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.api.findLists({
|
|
|
|
keys: ['status', 'user'],
|
|
|
|
query: {
|
2011-06-06 15:48:11 +00:00
|
|
|
conditions: [{key: 'id', value: pandora.user.ui.list, operator: '='}],
|
2011-05-25 19:42:45 +00:00
|
|
|
operator: ''
|
|
|
|
},
|
|
|
|
range: [0, 1]
|
|
|
|
}, function(result) {
|
|
|
|
var folder, list;
|
|
|
|
if (result.data.items.length) {
|
|
|
|
list = result.data.items[0];
|
|
|
|
folder = list.status == 'featured' ? 'featured' : (
|
2011-06-06 15:48:11 +00:00
|
|
|
list.user == pandora.user.username ? 'personal' : 'favorite'
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[folder]
|
|
|
|
.options('selected', [pandora.user.ui.list])
|
2011-05-25 19:42:45 +00:00
|
|
|
.gainFocus();
|
|
|
|
} else {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user.ui.list = '';
|
|
|
|
//pandora.user.ui.listQuery.conditions = []; // fixme: Query should read from pandora.ui.list, and not need pandora.ui.listQuery to be reset
|
2011-05-25 19:42:45 +00:00
|
|
|
//pandora.URL.set(pandora.Query.toString());
|
|
|
|
}
|
2011-06-16 20:00:10 +00:00
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
2011-06-16 20:00:10 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
|