allow for selecting lists via list menu
This commit is contained in:
parent
3bed914023
commit
6be21617cd
4 changed files with 52 additions and 33 deletions
|
@ -364,11 +364,6 @@ pandora.ui.folderList = function(id) {
|
||||||
},
|
},
|
||||||
select: function(data) {
|
select: function(data) {
|
||||||
var list = data.ids.length ? data.ids[0] : '';
|
var list = data.ids.length ? data.ids[0] : '';
|
||||||
if (list) {
|
|
||||||
Ox.forEach(pandora.$ui.folderList, function($list, id_) {
|
|
||||||
id != id_ && $list.options('selected', []);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
pandora.UI.set({
|
pandora.UI.set({
|
||||||
find: {
|
find: {
|
||||||
conditions: list ? [
|
conditions: list ? [
|
||||||
|
|
|
@ -317,12 +317,23 @@ pandora.ui.folders = function() {
|
||||||
}
|
}
|
||||||
that.bindEvent({
|
that.bindEvent({
|
||||||
pandora_find: function() {
|
pandora_find: function() {
|
||||||
var previousUI = pandora.UI.getPrevious();
|
var folder = pandora.getListData().folder,
|
||||||
|
list = pandora.user.ui._list,
|
||||||
|
previousList = pandora.UI.getPrevious()._list;
|
||||||
|
if (list != previousList) {
|
||||||
|
Ox.forEach(pandora.$ui.folderList, function($list, id) {
|
||||||
|
id != folder && $list.options('selected', []);
|
||||||
|
});
|
||||||
|
folder && pandora.$ui.folderList[folder].options({selected: [list]});
|
||||||
|
}
|
||||||
|
/*
|
||||||
if (!pandora.user.ui._list && previousUI._list) {
|
if (!pandora.user.ui._list && previousUI._list) {
|
||||||
|
pandora.$ui.folderList[pandora.getListData(previous)]
|
||||||
Ox.forEach(pandora.$ui.folderList, function($list) {
|
Ox.forEach(pandora.$ui.folderList, function($list) {
|
||||||
$list.options({selected: []});
|
$list.options({selected: []});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return that;
|
return that;
|
||||||
|
|
|
@ -155,7 +155,13 @@ pandora.ui.mainMenu = function() {
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: function(data) {
|
change: function(data) {
|
||||||
var value = data.checked[0] ? data.checked[0].id : null;
|
var value = data.checked[0] ? data.checked[0].id : null;
|
||||||
if (data.id == 'find') {
|
if (data.id == 'allitems') {
|
||||||
|
if (data.checked) {
|
||||||
|
pandora.UI.set('find', {conditions: [], operator: '&'});
|
||||||
|
} else {
|
||||||
|
that.checkItem('allitems');
|
||||||
|
}
|
||||||
|
} else if (data.id == 'find') {
|
||||||
pandora.$ui.findSelect.options({value: value});
|
pandora.$ui.findSelect.options({value: value});
|
||||||
} else if (data.id == 'itemview') {
|
} else if (data.id == 'itemview') {
|
||||||
pandora.UI.set({itemView: value});
|
pandora.UI.set({itemView: value});
|
||||||
|
@ -208,11 +214,11 @@ pandora.ui.mainMenu = function() {
|
||||||
set.listSort = pandora.site.user.ui.listSort;
|
set.listSort = pandora.site.user.ui.listSort;
|
||||||
}
|
}
|
||||||
pandora.UI.set(set);
|
pandora.UI.set(set);
|
||||||
} else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(data.id) > -1) {
|
} else if (data.id.substr(0, 8) == 'viewlist') {
|
||||||
pandora.UI.set({
|
pandora.UI.set({
|
||||||
find: {
|
find: {
|
||||||
conditions: value ? [
|
conditions: data.checked ? [
|
||||||
{key: 'list', value: value.substr(8), operator: '=='}
|
{key: 'list', value: data.id.substr(8), operator: '=='}
|
||||||
] : [],
|
] : [],
|
||||||
operator: '&'
|
operator: '&'
|
||||||
}
|
}
|
||||||
|
@ -345,9 +351,15 @@ pandora.ui.mainMenu = function() {
|
||||||
&& pandora.UI.set({showTimeline: !ui.showTimeline});
|
&& pandora.UI.set({showTimeline: !ui.showTimeline});
|
||||||
},
|
},
|
||||||
pandora_find: function() {
|
pandora_find: function() {
|
||||||
var action = ui._list
|
var list = ui._list,
|
||||||
&& pandora.getListData(ui._list).user == pandora.user.username
|
listData = pandora.getListData(),
|
||||||
|
previousList = pandora.UI.getPrevious()._list,
|
||||||
|
action = list && listData.user == pandora.user.username
|
||||||
? 'enableItem' : 'disableItem';
|
? 'enableItem' : 'disableItem';
|
||||||
|
if (list != previousList) {
|
||||||
|
that.uncheckItem(previousList == '' ? 'allitems' : 'viewlist' + previousList);
|
||||||
|
that.checkItem(list == '' ? 'allitems' : 'viewlist' + list);
|
||||||
|
}
|
||||||
that[action]('editlist');
|
that[action]('editlist');
|
||||||
that[action]('duplicatelist');
|
that[action]('duplicatelist');
|
||||||
that[action]('deletelist');
|
that[action]('deletelist');
|
||||||
|
@ -415,18 +427,17 @@ pandora.ui.mainMenu = function() {
|
||||||
return {
|
return {
|
||||||
id: folder + 'lists',
|
id: folder + 'lists',
|
||||||
title: Ox.toTitleCase(folder) + ' Lists',
|
title: Ox.toTitleCase(folder) + ' Lists',
|
||||||
items: [{
|
items: Ox.isUndefined(lists)
|
||||||
group: folder + 'lists',
|
? [{id: 'loading', title: 'Loading...', disabled: true}]
|
||||||
min: 0,
|
: lists[folder].length == 0
|
||||||
max: 1,
|
? [{id: 'nolists', title: 'No ' + Ox.toTitleCase(folder) + ' Lists', disabled: true}]
|
||||||
items: lists ? lists[folder].map(function(list) {
|
: lists[folder].map(function(list) {
|
||||||
return {
|
return {
|
||||||
id: 'viewlist' + list.id,
|
id: 'viewlist' + list.id,
|
||||||
title: (folder == 'favorite' ? list.user + ': ' : '') + list.name,
|
title: (folder == 'favorite' ? list.user + ': ' : '') + list.name,
|
||||||
checked: list.id == pandora.user.ui._list
|
checked: list.id == pandora.user.ui._list
|
||||||
};
|
};
|
||||||
}) : [{id: 'loading', title: 'Loading...', disabled: true}]
|
})
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
|
@ -497,7 +508,7 @@ pandora.ui.mainMenu = function() {
|
||||||
] };
|
] };
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixme: the sidebar makes the same requests.
|
// fixme: the sidebar makes (almost) the same requests.
|
||||||
// is it ok to make them twice, or should the sidebar trigger the menu replace?
|
// is it ok to make them twice, or should the sidebar trigger the menu replace?
|
||||||
|
|
||||||
var counter = 0,
|
var counter = 0,
|
||||||
|
@ -520,7 +531,8 @@ pandora.ui.mainMenu = function() {
|
||||||
Ox.forEach(queries, function(query, folder) {
|
Ox.forEach(queries, function(query, folder) {
|
||||||
pandora.api.findLists({
|
pandora.api.findLists({
|
||||||
query: query,
|
query: query,
|
||||||
keys: ['id', 'name', 'user']
|
keys: ['id', 'name', 'user'],
|
||||||
|
sort: [{key: 'position', operator: '+'}]
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
lists[folder] = result.data.items;
|
lists[folder] = result.data.items;
|
||||||
if (++counter == 3) {
|
if (++counter == 3) {
|
||||||
|
|
|
@ -572,20 +572,21 @@ pandora.getItemByIdOrTitle = function(str, callback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pandora.getListData = function() {
|
pandora.getListData = function(list) {
|
||||||
var data = {}, folder;
|
var data = {};
|
||||||
if (pandora.user.ui._list) {
|
list = Ox.isUndefined(list) ? pandora.user.ui._list : list;
|
||||||
Ox.forEach(pandora.$ui.folderList, function(list, key) {
|
if (list) {
|
||||||
if (list.options('selected').length) {
|
Ox.forEach(pandora.$ui.folderList, function($list, id) {
|
||||||
folder = key;
|
var values = $list.value(list);
|
||||||
|
if (!Ox.isEmpty(values)) {
|
||||||
|
data = Ox.extend({
|
||||||
|
editable: data.user == pandora.user.username
|
||||||
|
&& data.type == 'static',
|
||||||
|
folder: id
|
||||||
|
}, values);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (folder) {
|
|
||||||
data = pandora.$ui.folderList[folder].value(pandora.user.ui._list);
|
|
||||||
data.editable = data.user == pandora.user.username && data.type == 'static';
|
|
||||||
data.folder = folder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue