allow for ctrl+n in list folders, and alt+ctrl+n in the personal lists folder; plus cover various corner cases regarding the selected list when switching between list folders and list browsers
This commit is contained in:
parent
1eef7e7fd1
commit
0c37faa946
4 changed files with 99 additions and 14 deletions
|
@ -261,9 +261,15 @@ pandora.getListData = function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
data = pandora.$ui.folderList[folder].value(pandora.user.ui.list);
|
// the one case where folder is undefinded is when on page load
|
||||||
|
// the folderLists call getListData to determine which list is selected
|
||||||
|
if (folder) {
|
||||||
|
Ox.print('gLD f', folder)
|
||||||
|
data = pandora.$ui.folderList[folder].value(pandora.user.ui.list);
|
||||||
|
data.editable = data.user == pandora.user.username && data.type == 'static';
|
||||||
|
data.folder = folder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
data.editable = data.user == pandora.user.username && data.type == 'static';
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,7 @@ pandora.ui.folderBrowserList = function(id) {
|
||||||
}), callback);
|
}), callback);
|
||||||
},
|
},
|
||||||
pageLength: 1000,
|
pageLength: 1000,
|
||||||
// fixme: select if previously selected
|
selected: pandora.getListData().folder == id ? [pandora.user.ui.list] : [],
|
||||||
// selected: pandora.user.ui.list ? [pandora.user.ui.list] : [],
|
|
||||||
sort: [
|
sort: [
|
||||||
{key: 'name', operator: '+'}
|
{key: 'name', operator: '+'}
|
||||||
]
|
]
|
||||||
|
|
|
@ -15,6 +15,7 @@ pandora.ui.folders = function() {
|
||||||
pandora.$ui.findListElement = {};
|
pandora.$ui.findListElement = {};
|
||||||
pandora.$ui.findListSelect = {};
|
pandora.$ui.findListSelect = {};
|
||||||
pandora.$ui.findListInput = {};
|
pandora.$ui.findListInput = {};
|
||||||
|
pandora.$ui.manageListsButton = {};
|
||||||
if (pandora.user.ui.section == 'items') {
|
if (pandora.user.ui.section == 'items') {
|
||||||
pandora.site.sectionFolders.items.forEach(function(folder, i) {
|
pandora.site.sectionFolders.items.forEach(function(folder, i) {
|
||||||
var extras;
|
var extras;
|
||||||
|
@ -26,10 +27,12 @@ pandora.ui.folders = function() {
|
||||||
items: [
|
items: [
|
||||||
{ id: 'new', title: 'New List...' },
|
{ id: 'new', title: 'New List...' },
|
||||||
{ id: 'newfromselection', title: 'New List from Current Selection...', disabled: true },
|
{ id: 'newfromselection', title: 'New List from Current Selection...', disabled: true },
|
||||||
|
{},
|
||||||
{ id: 'newsmart', title: 'New Smart List...' },
|
{ id: 'newsmart', title: 'New Smart List...' },
|
||||||
{ id: 'newfromresults', title: 'New Smart List from Current Results...', disabled: true },
|
{ id: 'newfromresults', title: 'New Smart List from Current Results...', disabled: true },
|
||||||
{},
|
{},
|
||||||
{ id: 'addselection', title: 'Add Selection to List...' }
|
{ id: 'copyselection', title: 'Copy Selection to List...' },
|
||||||
|
{ id: 'moveselection', title: 'Move Selection to List...' }
|
||||||
],
|
],
|
||||||
max: 0,
|
max: 0,
|
||||||
min: 0,
|
min: 0,
|
||||||
|
@ -38,15 +41,15 @@ pandora.ui.folders = function() {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function(event, data) {
|
click: function(event, data) {
|
||||||
var $list = pandora.$ui.folderList[folder.id],
|
var $list = pandora.$ui.folderList[folder.id];
|
||||||
id;
|
// fixme: duplicated
|
||||||
if (data.id == 'new' || data.id == 'newsmart') {
|
if (data.id == 'new' || data.id == 'newsmart') {
|
||||||
pandora.api.addList({
|
pandora.api.addList({
|
||||||
name: 'Untitled',
|
name: 'Untitled',
|
||||||
status: 'private',
|
status: 'private',
|
||||||
type: data.id == 'new' ? 'static' : 'smart'
|
type: data.id == 'new' ? 'static' : 'smart'
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
id = result.data.id;
|
var id = result.data.id;
|
||||||
pandora.UI.set(['lists', id].join('|'), pandora.site.user.ui.lists['']); // fixme: necessary?
|
pandora.UI.set(['lists', id].join('|'), pandora.site.user.ui.lists['']); // fixme: necessary?
|
||||||
pandora.URL.set('?find=list:' + id)
|
pandora.URL.set('?find=list:' + id)
|
||||||
Ox.Request.clearCache(); // fixme: remove
|
Ox.Request.clearCache(); // fixme: remove
|
||||||
|
@ -66,7 +69,7 @@ pandora.ui.folders = function() {
|
||||||
if (pandora.user.level == 'guest') {
|
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.')];
|
extras = [infoButton('Favorite Lists', 'To browse and subscribe to shared lists from other users, please sign up or sign in.')];
|
||||||
} else {
|
} else {
|
||||||
extras = [Ox.Button({
|
extras = [pandora.$ui.manageListsButton['favorite'] = Ox.Button({
|
||||||
selectable: true,
|
selectable: true,
|
||||||
style: 'symbol',
|
style: 'symbol',
|
||||||
title: 'Edit',
|
title: 'Edit',
|
||||||
|
@ -82,6 +85,21 @@ pandora.ui.folders = function() {
|
||||||
pandora.$ui.folderBrowser.favorite = pandora.ui.folderBrowser('favorite')
|
pandora.$ui.folderBrowser.favorite = pandora.ui.folderBrowser('favorite')
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
listData = pandora.getListData();
|
||||||
|
if (
|
||||||
|
pandora.$ui.folderList.favorite.options('selected').length
|
||||||
|
&& !listData.subscribed
|
||||||
|
) {
|
||||||
|
// the selected list in the favorite browser is not in the favorite 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.URL.set('?find=');
|
||||||
|
}
|
||||||
|
}
|
||||||
pandora.$ui.folderBrowser.favorite.replaceWith(
|
pandora.$ui.folderBrowser.favorite.replaceWith(
|
||||||
pandora.$ui.folderList.favorite = pandora.ui.folderList('favorite')
|
pandora.$ui.folderList.favorite = pandora.ui.folderList('favorite')
|
||||||
);
|
);
|
||||||
|
@ -94,7 +112,7 @@ pandora.ui.folders = function() {
|
||||||
if (pandora.user.level != 'admin') {
|
if (pandora.user.level != 'admin') {
|
||||||
extras = [infoButton('Featured Lists', 'Featured lists are selected public lists, picked by the ' + pandora.site.site.name + ' staff.')];
|
extras = [infoButton('Featured Lists', 'Featured lists are selected public lists, picked by the ' + pandora.site.site.name + ' staff.')];
|
||||||
} else {
|
} else {
|
||||||
extras = [Ox.Button({
|
extras = [pandora.$ui.manageListsButton['featured'] = Ox.Button({
|
||||||
selectable: true,
|
selectable: true,
|
||||||
style: 'symbol',
|
style: 'symbol',
|
||||||
title: 'Edit',
|
title: 'Edit',
|
||||||
|
@ -103,12 +121,33 @@ pandora.ui.folders = function() {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: function(event, data) {
|
change: function(event, data) {
|
||||||
|
var listData;
|
||||||
Ox.Request.clearCache(); // fixme: remove
|
Ox.Request.clearCache(); // fixme: remove
|
||||||
pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser;
|
pandora.site.sectionFolders.items[i].showBrowser = !pandora.site.sectionFolders.items[i].showBrowser;
|
||||||
if (pandora.site.sectionFolders.items[i].showBrowser) {
|
if (pandora.site.sectionFolders.items[i].showBrowser) {
|
||||||
pandora.$ui.folderList.featured.replaceWith(
|
pandora.$ui.folderList.featured.replaceWith(
|
||||||
pandora.$ui.folderBrowser.featured = pandora.ui.folderBrowser('featured'));
|
pandora.$ui.folderBrowser.featured = pandora.ui.folderBrowser('featured')
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
|
listData = pandora.getListData();
|
||||||
|
Ox.print('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 (Ox.getObjectById(pandora.site.sectionFolders.items, 'favorite').showBrowser) {
|
||||||
|
// but in the favorite browser
|
||||||
|
pandora.$ui.folderList.favorite.options({selected: [listData.id]});
|
||||||
|
} else {
|
||||||
|
// and nowhere else
|
||||||
|
pandora.URL.set('?find=');
|
||||||
|
}
|
||||||
|
}
|
||||||
pandora.$ui.folderBrowser.featured.replaceWith(
|
pandora.$ui.folderBrowser.featured.replaceWith(
|
||||||
pandora.$ui.folderList.featured = pandora.ui.folderList('featured')
|
pandora.$ui.folderList.featured = pandora.ui.folderList('featured')
|
||||||
);
|
);
|
||||||
|
|
|
@ -229,6 +229,7 @@ pandora.ui.folderList = function(id) {
|
||||||
max: 1,
|
max: 1,
|
||||||
min: 0,
|
min: 0,
|
||||||
pageLength: 1000,
|
pageLength: 1000,
|
||||||
|
selected: pandora.getListData().folder == id ? [pandora.user.ui.list] : [],
|
||||||
sort: [{key: 'position', operator: '+'}],
|
sort: [{key: 'position', operator: '+'}],
|
||||||
sortable: id != 'featured' || pandora.user.level == 'admin'
|
sortable: id != 'featured' || pandora.user.level == 'admin'
|
||||||
})
|
})
|
||||||
|
@ -238,6 +239,45 @@ pandora.ui.folderList = function(id) {
|
||||||
width: pandora.user.ui.sidebarWidth + 'px',
|
width: pandora.user.ui.sidebarWidth + 'px',
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
|
add: function(event) {
|
||||||
|
// fixme: this is duplicated,
|
||||||
|
// see folder collapse panel menu handler
|
||||||
|
var i = ['personal', 'favorite', 'featured'].indexOf(id);
|
||||||
|
if (id == 'personal') {
|
||||||
|
if (event.keys == '' || event.keys == 'alt') {
|
||||||
|
pandora.api.addList({
|
||||||
|
name: 'Untitled',
|
||||||
|
status: 'private',
|
||||||
|
type: event.keys == '' ? 'static' : 'smart'
|
||||||
|
}, function(result) {
|
||||||
|
var id = result.data.id;
|
||||||
|
pandora.UI.set(['lists', id].join('|'), pandora.site.user.ui.lists['']); // fixme: necessary?
|
||||||
|
pandora.URL.set('?find=list:' + id)
|
||||||
|
Ox.Request.clearCache(); // fixme: remove
|
||||||
|
that.reloadList().bindEventOnce({
|
||||||
|
load: function(event, data) {
|
||||||
|
that.gainFocus()
|
||||||
|
.options({selected: [id]})
|
||||||
|
.editCell(id, 'name');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (id == 'favorite' || (id == 'featured' && pandora.user.level == 'admin')) {
|
||||||
|
// this makes the button trigger a change event,
|
||||||
|
// which is already being handled in folders.js
|
||||||
|
pandora.$ui.manageListsButton[id].options({selected: true});
|
||||||
|
/*
|
||||||
|
if (!pandora.site.sectionFolders.items[i].showBrowser) {
|
||||||
|
pandora.site.sectionFolders.items[i].showBrowser = true;
|
||||||
|
pandora.$ui.manageListsButton[id].options({selected: true});
|
||||||
|
pandora.$ui.folderList[id].replaceWith(
|
||||||
|
pandora.$ui.folderBrowser[id] = pandora.ui.folderBrowser(id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
},
|
||||||
click: function(event, data) {
|
click: function(event, data) {
|
||||||
var $list = pandora.$ui.folderList[id];
|
var $list = pandora.$ui.folderList[id];
|
||||||
if (data.key == 'type') {
|
if (data.key == 'type') {
|
||||||
|
@ -256,6 +296,7 @@ pandora.ui.folderList = function(id) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'delete': function(event, data) {
|
'delete': function(event, data) {
|
||||||
|
// fixme: add a confirmation dialog
|
||||||
var $list = pandora.$ui.folderList[id];
|
var $list = pandora.$ui.folderList[id];
|
||||||
pandora.URL.set('?find=');
|
pandora.URL.set('?find=');
|
||||||
$list.options({selected: []});
|
$list.options({selected: []});
|
||||||
|
@ -316,9 +357,9 @@ pandora.ui.folderList = function(id) {
|
||||||
},
|
},
|
||||||
select: function(event, data) {
|
select: function(event, data) {
|
||||||
if (data.ids.length) {
|
if (data.ids.length) {
|
||||||
$.each(pandora.$ui.folderList, function(id_, $list) {
|
Ox.forEach(pandora.$ui.folderList, function($list, id_) {
|
||||||
id != id_ && $list.options('selected', []);
|
id != id_ && $list.options('selected', []);
|
||||||
})
|
});
|
||||||
pandora.URL.set('?find=' + (id == 'volumes' ? 'volume' : 'list') + ':' + data.ids[0]);
|
pandora.URL.set('?find=' + (id == 'volumes' ? 'volume' : 'list') + ':' + data.ids[0]);
|
||||||
} else {
|
} else {
|
||||||
pandora.URL.set('?find=');
|
pandora.URL.set('?find=');
|
||||||
|
|
Loading…
Reference in a new issue