add volumes folder

This commit is contained in:
rlx 2011-09-01 04:46:44 +00:00
parent e501717300
commit 9a57ba6208
10 changed files with 329 additions and 229 deletions

View file

@ -499,7 +499,6 @@
"site": {
"id": "{{settings.SITEID}}",
"name": "{{settings.SITENAME}}",
"sectionName": "{{settings.SITENAME}}",
"url": "{{settings.URL}}"
},
"sitePages": [
@ -572,15 +571,11 @@
"showInfo": true,
"showMovies": true,
"showFolder": {
"site": {
"site": true,
"user": true,
"admin": true
},
"items": {
"personal": true,
"favorite": true,
"featured": true
"featured": true,
"volumes": true
}
},
"showSidebar": true,
@ -594,7 +589,10 @@
"videoView": "player",
"videoVolume": 1
},
"username": ""
"username": "",
"volumes": [
{"name": "Movies A-Z", "path": "", "items": 1234}
]
},
"userLevels": ["guest", "member", "staff", "admin"],
"video": {

View file

@ -48,27 +48,21 @@ Ox.load('Geo', function() {
return key.find ? key : null;
}),
sectionFolders: {
site: $.merge([
{id: 'site', title: 'Site', items: $.merge([
{id: 'home', title: 'Home'}
], $.merge(data.site.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'}
]}
] : []),
items: [
{id: 'personal', title: 'Personal Lists'},
{id: 'favorite', title: 'Favorite Lists', showBrowser: false},
{id: 'featured', title: 'Featured 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},
{id: 'featured', title: 'Featured Edits', showBrowser: false}
],
texts: [
{id: 'personal', title: 'Personal Texts'},
{id: 'favorite', title: 'Favorite Texts', showBrowser: false},
{id: 'featured', title: 'Featured Texts', showBrowser: false}
]
},
sortKeys: $.map(data.site.itemKeys, function(key, i) {

View file

@ -25,9 +25,9 @@ pandora.exitFullscreen = function() {
};
pandora.getFoldersHeight = function() {
var height = 48;
var height = 0;
pandora.site.sectionFolders[pandora.user.ui.section].forEach(function(folder, i) {
height += pandora.user.ui.showFolder[pandora.user.ui.section][folder.id] * (
height += 16 + pandora.user.ui.showFolder[pandora.user.ui.section][folder.id] * (
!!folder.showBrowser * 40 + folder.items * 16
);
Ox.print('h', height);
@ -212,11 +212,9 @@ pandora.resizeGroups = function(width) {
pandora.resizeFolders = function() {
var width = pandora.getFoldersWidth(),
columnWidth = {};
if (pandora.user.ui.section == 'site') {
columnWidth.title = width - 16;
} else if (pandora.user.ui.section == 'items') {
columnWidth = {user: parseInt((width - 88) * 0.4)};
columnWidth.name = (width - 88) - columnWidth.user;
if (pandora.user.ui.section == 'items') {
columnWidth = {user: parseInt((width - 96) * 0.4)};
columnWidth.name = (width - 96) - columnWidth.user;
}
//Ox.print('sectionsWidth', width)
$.each(pandora.$ui.folderList, function(id, $list) {
@ -224,14 +222,12 @@ pandora.resizeFolders = function() {
pandora.$ui.folder[i].css({width: width + 'px'});
$list.css({width: width + 'px'});
Ox.print('...', width, id, $list.options())
if (pandora.user.ui.section == 'site') {
$list.resizeColumn('title', columnWidth.title);
} else if (pandora.user.ui.section == 'items') {
if (pandora.user.ui.section == 'items') {
if (pandora.site.sectionFolders[pandora.user.ui.section][i].showBrowser) {
$list.resizeColumn('user', columnWidth.user)
.resizeColumn('name', columnWidth.name);
} else {
$list.resizeColumn(id == 'favorite' ? 'id' : 'name', width - 88);
$list.resizeColumn(id == 'favorite' ? 'id' : 'name', width - 96);
}
}
if (!pandora.user.ui.showFolder[pandora.user.ui.section][id]) {

View file

@ -330,7 +330,7 @@ pandora.ui.accountSignoutDialog = function() {
.css({position: 'absolute', left: '16px', top: '16px', width: '64px', height: '64px'})
)
.append(
Ox.Element()
$('<div>')
.css({position: 'absolute', left: '96px', top: '16px', width: '192px'})
.html('Are you sure you want to sign out?')
),

View file

@ -1,6 +1,8 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.folderBrowserList = function(id) {
var columnWidth = (pandora.user.ui.sidebarSize - Ox.UI.SCROLLBAR_SIZE - 88) / 2,
// fixme: user and name are set to the same width here,
// but resizeFolders will set them to different widths
var columnWidth = (pandora.user.ui.sidebarSize - Ox.UI.SCROLLBAR_SIZE - 96) / 2,
i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id),
that = Ox.TextList({
columns: [
@ -43,10 +45,11 @@ pandora.ui.folderBrowserList = function(id) {
{
align: 'right',
id: 'items',
format: {type: 'number'},
operator: '-',
title: 'Items',
visible: true,
width: 40
width: 48
},
{
clickable: function(data) {
@ -68,7 +71,7 @@ pandora.ui.folderBrowserList = function(id) {
operator: '+',
title: $('<img>')
.attr({
src: Ox.UI.getImageURL('symbolFind')
src: Ox.UI.getImageURL('symbolEdit')
})
.css({
width: '10px',
@ -89,7 +92,7 @@ pandora.ui.folderBrowserList = function(id) {
return $('<img>')
.attr({
src: Ox.UI.getImageURL(
'symbol' + (id == 'favorite' ? 'Check' : 'Star')
'symbol' + (id == 'favorite' ? 'Like' : 'Star')
)
})
.css({
@ -106,7 +109,7 @@ pandora.ui.folderBrowserList = function(id) {
title: $('<img>')
.attr({
src: Ox.UI.getImageURL(
'symbol' + (id == 'favorite' ? 'Check' : 'Star')
'symbol' + (id == 'favorite' ? 'Like' : 'Star')
)
})
.css({

View file

@ -12,39 +12,13 @@ pandora.ui.folders = function() {
pandora.$ui.folder = [];
pandora.$ui.folderBrowser = {};
pandora.$ui.folderList = {};
if (pandora.user.ui.section == 'site') {
pandora.site.sectionFolders.site.forEach(function(folder, i) {
var height = (Ox.getObjectById(pandora.site.sectionFolders.site, folder.id).items.length * 16);
pandora.$ui.folder[i] = Ox.CollapsePanel({
id: folder.id,
collapsed: !pandora.user.ui.showFolder.site[folder.id],
size: 16,
title: folder.title
})
.bindEvent({
toggle: function(event, data) {
}
});
//alert(JSON.stringify(Ox.getObjectById(pandora.site.sectionFolders.site, folder.id)))
pandora.$ui.folder[i].$content.css({
height: height + 'px'
})
//.appendTo(that);
pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id)
.css({
height: height + 'px'
})
.appendTo(pandora.$ui.folder[i].$content);
pandora.$ui.folder.forEach(function($folder) {
that.append($folder);
});
});
//pandora.resizeFolders();
} else if (pandora.user.ui.section == 'items') {
if (pandora.user.ui.section == 'items') {
pandora.site.sectionFolders.items.forEach(function(folder, i) {
var extras = [];
if (folder.id == 'personal' && pandora.user.level != 'guest') {
var extras;
if (folder.id == 'personal') {
if (pandora.user.level == 'guest') {
extras = [infoButton('Personal Lists', 'To create and publish your own lists of movies, please sign up or sign in.')];
} else {
extras = [Ox.Select({
items: [
{ id: 'new', title: 'New List...' },
@ -84,7 +58,11 @@ pandora.ui.folders = function() {
}
}
})];
} else if (folder.id == 'favorite' && pandora.user.level != 'guest') {
}
} else if (folder.id == 'favorite') {
if (pandora.user.level == 'guest') {
extras = [infoButton('Favorite Lists', 'To browse and subscribe to shared lists from other users, please sign up or sign in.')];
} else {
extras = [Ox.Button({
selectable: true,
style: 'symbol',
@ -108,7 +86,11 @@ pandora.ui.folders = function() {
pandora.resizeFolders();
}
})];
} else if (folder.id == 'featured' && pandora.user.level == 'admin') {
}
} else if (folder.id == 'featured') {
if (pandora.user.level != 'admin') {
extras = [infoButton('Featured Lists', 'Featured lists are selected public lists, picked by the ' + pandora.site.site.name + ' staff.')];
} else {
extras = [Ox.Button({
selectable: true,
style: 'symbol',
@ -132,6 +114,29 @@ pandora.ui.folders = function() {
}
})];
}
} else if (folder.id == 'volumes') {
if (pandora.user.level == 'guest') {
extras = [infoButton('Local Volumes', 'To import movies from a local disk, please sign up or sign in.')];
} else {
extras = [Ox.Select({
items: [
{ id: 'add', title: 'Add Volume...' },
{ id: 'scan', title: 'Scan Selected Volume...' },
{ id: 'remove', title: 'Remove Selected Volume...' },
{},
{ id: 'import', title: 'Import Movies...' }
],
max: 0,
min: 0,
selectable: false,
type: 'image'
})
.bindEvent({
click: function(data) {
}
})];
}
}
pandora.$ui.folder[i] = Ox.CollapsePanel({
id: folder.id,
collapsed: !pandora.user.ui.showFolder.items[folder.id],
@ -180,7 +185,7 @@ pandora.ui.folders = function() {
.bindEventOnce({
init: function(event, data) {
Ox.print('init', i, counter)
if (++counter == 3) {
if (++counter == 4) {
pandora.$ui.folder.forEach(function($folder) {
that.append($folder);
});
@ -192,6 +197,53 @@ pandora.ui.folders = function() {
.appendTo(pandora.$ui.folder[i].$content);
});
}
function infoButton(title, text) {
return Ox.Button({
style: 'symbol',
title: 'info',
type: 'image'
}).bindEvent({
click: function() {
var $dialog = Ox.Dialog({
buttons: Ox.merge([
Ox.Button({title: 'Close'}).bindEvent({
click: function() {
$dialog.close();
}
})
], title != 'Featured Lists' ? [
Ox.Button({title: 'Sign Up'}).bindEvent({
click: function() {
$dialog.close();
pandora.$ui.accountDialog = pandora.ui.accountDialog('signup').open();
}
}),
Ox.Button({title: 'Sign In'}).bindEvent({
click: function() {
$dialog.close();
pandora.$ui.accountDialog = pandora.ui.accountDialog('signin').open();
}
})
] : []),
content: Ox.Element()
.append(
$('<img>')
.attr({src: '/static/png/icon64.png'})
.css({position: 'absolute', left: '16px', top: '16px', width: '64px', height: '64px'})
)
.append(
$('<div>')
.css({position: 'absolute', left: '96px', top: '16px', width: '192px'})
.html(text)
),
fixedSize: true,
height: 128,
width: 304,
title: title
}).open();
}
});
}
that.toggle = function() {
};

View file

@ -2,58 +2,115 @@
pandora.ui.folderList = function(id) {
var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id),
that;
if (pandora.user.ui.section == 'site') {
that = Ox.TextList({
columns: [
if (pandora.user.ui.section == 'items') {
var columns, items;
if (id == 'volumes') {
columns = [
{
format: function() {
return $('<img>')
.attr({
src: Ox.UI.PATH + 'png/icon16.png'
})
return $('<img>').attr({
src: Ox.UI.getImageURL('symbolVolume')
}).css({
width: '10px',
height: '10px',
padding: '3px 1px 1px 3px'
});
},
id: 'id',
id: 'user',
operator: '+',
unique: true,
visible: true,
width: 16
},
{
id: 'title',
editable: true,
id: 'name',
operator: '+',
tooltip: 'Edit Title',
unique: true,
visible: true,
width: pandora.user.ui.sidebarSize - 16
}
],
items: function(data, callback) {
var result = {data: {}};
if (!data.range) {
result.data.items = Ox.getObjectById(pandora.site.sectionFolders.site, id).items.length;
} else {
result.data.items = Ox.getObjectById(pandora.site.sectionFolders.site, id).items;
}
callback(result);
width: pandora.user.ui.sidebarWidth - 96
},
max: 1,
min: 1,
sort: [{key: '', operator: ''}]
})
.bindEvent({
select: function(event, data) {
// fixme: duplicated
$.each(pandora.$ui.folderList, function(id_, $list) {
id != id_ && $list.options('selected', []);
})
pandora.URL.set((id == 'admin' ? 'admin/' : '' ) + data.ids[0]);
{
align: 'right',
id: 'items',
format: {type: 'number'},
operator: '-',
visible: true,
width: 48
},
{
clickable: function(data) {
return data.mounted;
},
format: function(value, data) {
return $('<img>')
.attr({
src: Ox.UI.getImageURL(data.mounted ? 'symbolScan' : 'symbolEdit')
})
.css({
width: '10px',
height: '10px',
padding: '3px 2px 1px 2px'
});
} else if (pandora.user.ui.section == 'items') {
that = Ox.TextList({
columns: [
},
id: 'path',
operator: '+',
tooltip: function(data) {
return data.mounted ? 'Scan Volume' : 'Edit Path';
},
visible: true,
width: 16
},
{
clickable: true,
format: function(value, data) {
return $('<img>')
.attr({
src: Ox.UI.getImageURL('symbolMount')
})
.css({
width: '10px',
height: '10px',
padding: '3px 2px 1px 2px',
opacity: data.mounted ? 1 : 0.25
});
},
id: 'mounted',
operator: '+',
tooltip: function(data) {
return data.mounted ? 'Unmount Volume' : 'Mount Volume';
},
visible: true,
width: 16
}
];
items = function(data, callback) {
var volumes = pandora.user.volumes || [
{"name": "Movies A-M", "path": "/Volumes/Movies A-M", "items": 1234},
{"name": "Movies N-Z", "path": "/Volumes/Movies N-Z", "items": 987}
];
if (!data.keys) {
data = {items: volumes.length};
} else {
data = {items: volumes.map(function(volume) {
return Ox.extend({id: volume.name, user: pandora.user.username, mounted: false}, volume);
})};
}
// fixme: ridiculous (we're binding to init too late)
setTimeout(function() {
callback({data: data});
}, 1000);
};
} else {
columns = [
{
format: function() {
return $('<img>').attr({
src: Ox.UI.PATH + 'png/icon16.png'
src: Ox.UI.getImageURL('symbolIcon')
}).css({
width: '10px',
height: '10px',
padding: '3px 1px 1px 3px'
});
},
id: 'user',
@ -69,7 +126,9 @@ pandora.ui.folderList = function(id) {
operator: '+',
unique: true,
visible: id == 'favorite',
width: pandora.user.ui.sidebarWidth - 88
// fixme: user and name are set to the same width here,
// but resizeFolders will set them to different widths
width: pandora.user.ui.sidebarWidth - 96
},
{
editable: function(data) {
@ -82,14 +141,15 @@ pandora.ui.folderList = function(id) {
operator: '+',
tooltip: id == 'personal' ? 'Edit Title' : null,
visible: id != 'favorite',
width: pandora.user.ui.sidebarWidth - 88
width: pandora.user.ui.sidebarWidth - 96
},
{
align: 'right',
id: 'items',
format: {type: 'number'},
operator: '-',
visible: true,
width: 40
width: 48
},
{
clickable: function(data) {
@ -120,11 +180,11 @@ pandora.ui.folderList = function(id) {
{
clickable: id == 'personal',
format: function(value) {
//var symbols = {private: 'Publish', public: 'Publish', featured: 'Star'};
var symbols = {personal: 'Publish', favorite: 'Like', featured: 'Star'};
return $('<img>')
.attr({
src: Ox.UI.getImageURL(
'symbol' + (value == 'featured' ? 'Star' : 'Publish')
'symbol' + symbols[id]
)
})
.css({
@ -142,8 +202,8 @@ pandora.ui.folderList = function(id) {
visible: true,
width: 16
}
],
items: function(data, callback) {
];
items = function(data, callback) {
var query;
if (id == 'personal') {
query = {conditions: [
@ -161,25 +221,22 @@ pandora.ui.folderList = function(id) {
return pandora.api.findLists(Ox.extend(data, {
query: query
}), callback);
},
};
}
that = Ox.TextList({
columns: columns,
items: items,
max: 1,
min: 0,
pageLength: 1000,
sort: [
{key: 'position', operator: '+'}
],
sortable: id == 'personal' || id == 'favorite' || pandora.user.level == 'admin'
sort: [{key: 'position', operator: '+'}],
sortable: id != 'featured' || pandora.user.level == 'admin'
})
.css({
left: 0,
top: 0,
width: pandora.user.ui.sidebarWidth + 'px',
})
.bind({
dragenter: function(e) {
//Ox.print('DRAGENTER', e)
}
})
.bindEvent({
click: function(event, data) {
var $list = pandora.$ui.folderList[id];
@ -192,6 +249,10 @@ pandora.ui.folderList = function(id) {
}, function(result) {
$list.value(result.data.id, 'status', result.data.status);
});
} else if (data.key == 'path') {
} else if (data.key == 'mounted') {
alert(JSON.stringify(data));
}
},
'delete': function(event, data) {
@ -203,7 +264,6 @@ pandora.ui.folderList = function(id) {
id: data.ids[0]
}, function(result) {
pandora.UI.set(['lists', data.ids[0]].join('|'), null);
Ox.print('SHOULD BE DELETED:', pandora.user.ui.lists)
Ox.Request.clearCache(); // fixme: remove
$list.reloadList();
});
@ -259,7 +319,7 @@ pandora.ui.folderList = function(id) {
$.each(pandora.$ui.folderList, function(id_, $list) {
id != id_ && $list.options('selected', []);
})
pandora.URL.set('?find=list:' + data.ids[0]);
pandora.URL.set('?find=' + (id == 'volumes' ? 'volume' : 'list') + ':' + data.ids[0]);
} else {
pandora.URL.set('?find=');
}

View file

@ -459,6 +459,7 @@ pandora.ui.list = function() { // fixme: remove view argument
var $tooltip = Ox.Tooltip({
animate: false
}).css({
fontSize: '11px',
textAlign: 'center'
});
@ -500,7 +501,7 @@ pandora.ui.list = function() { // fixme: remove view argument
dragover: function(e) {
$tooltip.options({
title: getTitle(e, ids.length == 1 ? item : items, data.id.split('/').pop())
+ (editable && e.shiftKey && result.data.items
+ (editable && e.metaKey && result.data.items
? '<br/>and remove ' + result.data.items + ' '
+ pandora.site.itemName[result.data.items == 1 ? 'singular' : 'plural'].toLowerCase()
+ '<br/>from the list "' + pandora.user.ui.list.split('/').pop() + '"'
@ -516,7 +517,7 @@ pandora.ui.list = function() { // fixme: remove view argument
drop: function(e) {
Ox.print('DROP', data);
var $this = $(this), folder, listData;
if (editable && e.shiftKey) {
if (editable && e.metaKey) {
pandora.api.removeListItems({
list: pandora.user.ui.list,
items: ids
@ -563,7 +564,7 @@ pandora.ui.list = function() { // fixme: remove view argument
}
});
function getTitle(e, item, list) {
return (editable && e.shiftKey ? 'Move' : 'Copy') + ' '
return (editable && e.metaKey ? 'Move' : 'Copy') + ' '
+ (Ox.isString(item) ? '"' + item + '"' : item + ' ' + pandora.site.itemName[item == 1 ? 'singular' : 'plural'].toLowerCase())
+ (list ? '<br/>to the list "' + list + '"' : '');
}

View file

@ -2,10 +2,9 @@
pandora.ui.sectionButtons = function() {
var that = Ox.ButtonGroup({
buttons: [
{id: 'site', selected: pandora.user.ui.section == 'site', title: pandora.site.site.name},
{id: 'items', selected: pandora.user.ui.section == 'items', title: pandora.site.itemName.plural},
{id: 'texts', selected: pandora.user.ui.section == 'texts', title: 'Texts'},
{id: 'admin', selected: pandora.user.ui.section == 'admin', title: 'Admin'}
{id: 'edits', selected: pandora.user.ui.section == 'edits', title: 'Edits'},
{id: 'texts', selected: pandora.user.ui.section == 'texts', title: 'Texts'}
],
id: 'sectionButtons',
selectable: true
@ -16,14 +15,12 @@ pandora.ui.sectionButtons = function() {
.bindEvent({
change: function(event, data) {
var section = data.selected[0];
if (section == 'site') {
pandora.URL.set(pandora.user.ui.sitePage);
} else if (section == 'items') {
if (section == 'items') {
pandora.URL.set(pandora.Query.toString());
} else if (section == 'clips') {
pandora.URL.set('clips');
} else if (section == 'texts') {
pandora.URL.set('texts');
} else if (section == 'admin') {
pandora.URL.set('admin');
}
}
});

View file

@ -4,10 +4,9 @@ pandora.ui.sectionSelect = function() {
var that = Ox.Select({
id: 'sectionSelect',
items: [
{checked: pandora.user.ui.section == 'site', id: 'site', title: pandora.site.site.name},
{checked: pandora.user.ui.section == 'items', id: 'items', title: pandora.site.itemName.plural},
{checked: pandora.user.ui.section == 'texts', id: 'texts', title: 'Texts'},
{checked: pandora.user.ui.section == 'admin', id: 'admin', title: 'Admin'}
{checked: pandora.user.ui.section == 'edits', id: 'edits', title: 'Edits'},
{checked: pandora.user.ui.section == 'texts', id: 'texts', title: 'Texts'}
]
}).css({
float: 'left',