initial round of text section

This commit is contained in:
j 2013-02-16 01:20:40 +00:00
commit c8af45e7cf
25 changed files with 2243 additions and 984 deletions

View file

@ -7,7 +7,9 @@ pandora.ui.folders = function() {
.css({overflowX: 'hidden', overflowY: 'auto'})
.bindEvent({
resize: pandora.resizeFolders
});
}),
folderItems = ui.section == 'items' ? 'Lists' : Ox.toTitleCase(ui.section),
folderItem = folderItems.slice(0, -1);
//var $sections = [];
pandora.$ui.allItems = pandora.ui.allItems().appendTo(that);
@ -18,15 +20,17 @@ pandora.ui.folders = function() {
pandora.$ui.findListSelect = {};
pandora.$ui.findListInput = {};
pandora.$ui.manageListsButton = {};
if (ui.section == 'items') {
pandora.site.sectionFolders.items.forEach(function(folder, i) {
var extras, $select;
if (folder.id == 'personal') {
if (pandora.user.level == 'guest') {
extras = [
infoButton('Personal Lists', 'To create and share your own lists of movies, please sign up or sign in.')
];
} else {
pandora.site.sectionFolders[ui.section].forEach(function(folder, i) {
var extras, $select;
if (folder.id == 'personal') {
if (pandora.user.level == 'guest') {
extras = [
infoButton('Personal ' + folderItems, 'To create and share your own ' + (ui.section == 'items'
? 'lists of ' + pandora.site.itemName.plural.toLowerCase()
: ui.section) + ', please sign up or sign in.')
];
} else {
if (ui.section == 'items') {
extras = [
pandora.$ui.personalListsMenu = Ox.MenuButton({
items: [
@ -78,195 +82,225 @@ pandora.ui.folders = function() {
}
})
];
}
} 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 = [pandora.$ui.manageListsButton['favorite'] = Ox.Button({
selectable: true,
style: 'symbol',
title: 'Edit',
tooltip: 'Manage Favorite Lists',
type: 'image'
})
.bindEvent({
change: function(data) {
var listData;
Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser;
if (pandora.site.sectionFolders.items[i].showBrowser) {
pandora.$ui.folderList.favorite.replaceWith(
pandora.$ui.folderBrowser.favorite = pandora.ui.folderBrowser('favorite')
);
} else {
listData = pandora.getListData();
if (
pandora.$ui.folderList.favorite.options('selected').length
&& !listData.subscribed
) {
// the selected list in the favorites browser is not in the favorites folder
pandora.$ui.folderList.favorite.options({selected: []});
if (Ox.getObjectById(pandora.site.sectionFolders.items, 'featured').showBrowser) {
// but in the featured browser
pandora.$ui.folderList.featured.options({selected: [listData.id]});
} else {
// and nowhere else
pandora.UI.set({
find: pandora.site.user.ui.find
});
}
extras = [
pandora.$ui.personalListsMenu = Ox.MenuButton({
items: [
{ id: 'new' + folderItem.toLowerCase(), title: 'New ' + folderItem },
{},
{ id: 'delete' + folderItem.toLowerCase(), title: 'Delete Selected ' + folderItem + '...', disabled: !ui[ui.section.slice(0,-1)] }
],
title: 'edit',
tooltip: 'Manage Personal ' + folderItems,
type: 'image'
})
.bindEvent({
click: function(data) {
var $list = pandora.$ui.folderList[folder.id];
// fixme: duplicated
if (data.id == 'new' + folderItem.toLowerCase()) {
pandora['add' + folderItem]();
} else if (data.id == 'delete' + folderItem.toLowerCase()) {
pandora.ui.deleteListDialog().open();
}
pandora.$ui.folderBrowser.favorite.replaceWith(
pandora.$ui.folderList.favorite = pandora.ui.folderList('favorite')
);
}
pandora.resizeFolders();
}
})];
}
} 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 = [pandora.$ui.manageListsButton['featured'] = Ox.Button({
selectable: true,
style: 'symbol',
title: 'Edit',
tooltip: 'Manage Featured Lists',
type: 'image'
})
.bindEvent({
change: function(data) {
var listData;
Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser;
if (pandora.site.sectionFolders.items[i].showBrowser) {
pandora.$ui.folderList.featured.replaceWith(
pandora.$ui.folderBrowser.featured = pandora.ui.folderBrowser('featured')
);
} else {
listData = pandora.getListData();
Ox.Log('', 'FEATURED', listData)
if (
pandora.$ui.folderList.featured.options('selected').length
&& listData.status != 'featured'
) {
// the selected list in the featured browser is not in the featured folder
pandora.$ui.folderList.featured.options({selected: []});
if (listData.user == pandora.user.username) {
// but in the personal folder
pandora.$ui.folderList.personal.options({selected: [listData.id]});
} else if (
listData.subscribed
|| Ox.getObjectById(pandora.site.sectionFolders.items, 'favorite').showBrowser
) {
// but in the favorites folder or browser
pandora.$ui.folderList.favorite.options({selected: [listData.id]});
} else {
// and nowhere else
pandora.UI.set({
find: pandora.site.user.ui.find
});
}
}
pandora.$ui.folderBrowser.featured.replaceWith(
pandora.$ui.folderList.featured = pandora.ui.folderList('featured')
);
}
pandora.resizeFolders();
}
})];
}
} 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.MenuButton({
items: [
{ id: 'add', title: 'Add Volume...', disabled: true },
{ id: 'scan', title: 'Scan Selected Volume...', disabled: true },
{ id: 'remove', title: 'Remove Selected Volume...', disabled: true },
{},
{ id: 'import', title: 'Import Movies...', disabled: true }
],
title: 'edit',
tooltip: 'Manage Volumes',
type: 'image'
})
.bindEvent({
click: function(data) {
}
})];
})
.bindEvent('pandora_' + ui.section.slice(0,-1), function(data) {
pandora.$ui.personalListsMenu[
data.value && data.value.length ? 'enableItem' : 'disableItem'
]('delete' + folderItem.toLowerCase());
})
];
}
}
pandora.$ui.folder[i] = Ox.CollapsePanel({
id: folder.id,
collapsed: !ui.showFolder.items[folder.id],
extras: extras,
size: 16,
title: folder.title
} else if (folder.id == 'favorite') {
if (pandora.user.level == 'guest') {
extras = [infoButton('Favorite ' + folderItems,
'To browse and subscribe to shared ' + folderItems.toLowerCase() + ' from other users, please sign up or sign in.')];
} else {
extras = [pandora.$ui.manageListsButton['favorite'] = Ox.Button({
selectable: true,
style: 'symbol',
title: 'Edit',
tooltip: 'Manage Favorite ' + folderItems,
type: 'image'
})
.bindEvent({
// fixme: duplicated
click: function(data) {
var $list = pandora.$ui.folderList[i],
hasFocus, id;
if (data.id == 'new' || data.id == 'newsmart') {
pandora.api.addList({
name: 'Untitled',
status: 'private',
type: data.id == 'new' ? 'static' : 'smart'
}, function(result) {
id = result.data.id;
pandora.URL.set('?find=list:' + id)
Ox.Request.clearCache(); // fixme: remove
$list.reloadList().bindEventOnce({
load: function(data) {
$list.gainFocus()
.options({selected: [id]})
.editCell(id, 'name');
}
});
});
} else if (data.id == 'browse') {
// alert('??')
/*
pandora.$ui.sectionList[1].replaceWith(pandora.$ui.publicLists = pandora.ui.publicLists());
pandora.site.showAllPublicLists = true;
*/
change: function(data) {
var listData;
Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders[ui.section][i].showBrowser = !pandora.site.sectionFolders[ui.section][i].showBrowser;
if (pandora.site.sectionFolders[ui.section][i].showBrowser) {
pandora.$ui.folderList.favorite.replaceWith(
pandora.$ui.folderBrowser.favorite = pandora.ui.folderBrowser('favorite')
);
} else {
listData = pandora.getListData();
if (
pandora.$ui.folderList.favorite.options('selected').length
&& !listData.subscribed
) {
// the selected list in the favorites browser is not in the favorites folder
pandora.$ui.folderList.favorite.options({selected: []});
if (Ox.getObjectById(pandora.site.sectionFolders[ui.section], 'featured').showBrowser) {
// but in the featured browser
pandora.$ui.folderList.featured.options({selected: [listData.id]});
} else {
// and nowhere else
pandora.UI.set({
find: pandora.site.user.ui.find
});
}
}
pandora.$ui.folderBrowser.favorite.replaceWith(
pandora.$ui.folderList.favorite = pandora.ui.folderList('favorite')
);
}
},
toggle: function(data) {
data.collapsed && pandora.$ui.folderList[folder.id].loseFocus();
pandora.UI.set('showFolder.items.' + folder.id, !data.collapsed);
pandora.resizeFolders();
}
});
//$sections.push(pandora.$ui.section[i]);
pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id)
})];
}
} else if (folder.id == 'featured') {
if (pandora.user.level != 'admin') {
extras = [infoButton('Featured ' + folderItems, 'Featured ' + folderItems.toLowerCase() + ' are selected public ' + folderItems.toLowerCase() + ', picked by the ' + pandora.site.site.name + ' staff.')];
} else {
extras = [pandora.$ui.manageListsButton['featured'] = Ox.Button({
selectable: true,
style: 'symbol',
title: 'Edit',
tooltip: 'Manage Featured ' + folderItems,
type: 'image'
})
.bindEvent({
selectafter: function() {
// ...
},
selectbefore: function() {
// ...
}
})
.bindEventOnce({
init: function(data) {
if (++counter == 4) {
pandora.$ui.folder.forEach(function($folder) {
that.append($folder);
});
pandora.resizeFolders();
pandora.selectList();
change: function(data) {
var listData;
Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders[ui.section][i].showBrowser = !pandora.site.sectionFolders[ui.section][i].showBrowser;
if (pandora.site.sectionFolders[ui.section][i].showBrowser) {
pandora.$ui.folderList.featured.replaceWith(
pandora.$ui.folderBrowser.featured = pandora.ui.folderBrowser('featured')
);
} else {
listData = pandora.getListData();
Ox.Log('', 'FEATURED', listData)
if (
pandora.$ui.folderList.featured.options('selected').length
&& listData.status != 'featured'
) {
// the selected list in the featured browser is not in the featured folder
pandora.$ui.folderList.featured.options({selected: []});
if (listData.user == pandora.user.username) {
// but in the personal folder
pandora.$ui.folderList.personal.options({selected: [listData.id]});
} else if (
listData.subscribed
|| Ox.getObjectById(pandora.site.sectionFolders[ui.section], 'favorite').showBrowser
) {
// but in the favorites folder or browser
pandora.$ui.folderList.favorite.options({selected: [listData.id]});
} else {
// and nowhere else
pandora.UI.set({
find: pandora.site.user.ui.find
});
}
}
pandora.$ui.folderBrowser.featured.replaceWith(
pandora.$ui.folderList.featured = pandora.ui.folderList('featured')
);
}
pandora.resizeFolders();
}
})];
}
} 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.MenuButton({
items: [
{ id: 'add', title: 'Add Volume...', disabled: true },
{ id: 'scan', title: 'Scan Selected Volume...', disabled: true },
{ id: 'remove', title: 'Remove Selected Volume...', disabled: true },
{},
{ id: 'import', title: 'Import Movies...', disabled: true }
],
title: 'edit',
tooltip: 'Manage Volumes',
type: 'image'
})
.appendTo(pandora.$ui.folder[i].$content);
});
}
.bindEvent({
click: function(data) {
}
})];
}
}
pandora.$ui.folder[i] = Ox.CollapsePanel({
id: folder.id,
collapsed: !ui.showFolder.items[folder.id],
extras: extras,
size: 16,
title: folder.title
})
.bindEvent({
// fixme: duplicated
click: function(data) {
var $list = pandora.$ui.folderList[i],
hasFocus, id;
if (data.id == 'new' || data.id == 'newsmart') {
pandora.api.addList({
name: 'Untitled',
status: 'private',
type: data.id == 'new' ? 'static' : 'smart'
}, function(result) {
id = result.data.id;
pandora.URL.set('?find=list:' + id)
Ox.Request.clearCache(); // fixme: remove
$list.reloadList().bindEventOnce({
load: function(data) {
$list.gainFocus()
.options({selected: [id]})
.editCell(id, 'name');
}
});
});
} else if (data.id == 'browse') {
// alert('??')
/*
pandora.$ui.sectionList[1].replaceWith(pandora.$ui.publicLists = pandora.ui.publicLists());
pandora.site.showAllPublicLists = true;
*/
}
},
toggle: function(data) {
data.collapsed && pandora.$ui.folderList[folder.id].loseFocus();
pandora.UI.set('showFolder.items.' + folder.id, !data.collapsed);
pandora.resizeFolders();
}
});
//$sections.push(pandora.$ui.section[i]);
pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id)
.bindEvent({
selectafter: function() {
// ...
},
selectbefore: function() {
// ...
}
})
.bindEventOnce({
init: function(data) {
if (++counter == pandora.site.sectionFolders[ui.section].length) {
pandora.$ui.folder.forEach(function($folder) {
that.append($folder);
});
pandora.resizeFolders();
pandora.selectList();
}
}
})
.appendTo(pandora.$ui.folder[i].$content);
});
function infoButton(title, text) {
return Ox.Button({
style: 'symbol',
@ -340,6 +374,13 @@ pandora.ui.folders = function() {
});
}
*/
},
pandora_text: function() {
if (!pandora.user.ui.text) {
Ox.forEach(pandora.$ui.folderList, function($list, id) {
$list.options('selected', []);
});
}
}
})
return that;