2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.folderBrowserList = function(id) {
|
2011-09-01 04:46:44 +00:00
|
|
|
// 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,
|
2011-06-06 15:48:11 +00:00
|
|
|
i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id),
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.TextList({
|
2011-05-25 19:42:45 +00:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
format: function() {
|
2011-09-01 07:00:35 +00:00
|
|
|
return $('<img>').attr({
|
|
|
|
src: Ox.UI.getImageURL('symbolIcon')
|
|
|
|
}).css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px 2px 1px 2px'
|
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
id: 'id',
|
|
|
|
operator: '+',
|
2011-09-01 07:00:35 +00:00
|
|
|
title: $('<img>').attr({
|
|
|
|
src: Ox.UI.getImageURL('symbolIcon')
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px 2px 1px 2px',
|
|
|
|
}),
|
|
|
|
unique: true,
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'user',
|
|
|
|
operator: '+',
|
|
|
|
title: 'User',
|
|
|
|
visible: true,
|
|
|
|
width: Math.floor(columnWidth)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'name',
|
|
|
|
operator: '+',
|
|
|
|
title: 'List',
|
|
|
|
visible: true,
|
|
|
|
width: Math.ceil(columnWidth)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
id: 'items',
|
2011-09-01 04:46:44 +00:00
|
|
|
format: {type: 'number'},
|
2011-05-25 19:42:45 +00:00
|
|
|
operator: '-',
|
|
|
|
title: 'Items',
|
|
|
|
visible: true,
|
2011-09-01 04:46:44 +00:00
|
|
|
width: 48
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
clickable: function(data) {
|
2011-09-01 07:43:32 +00:00
|
|
|
return data.type == 'smart' || data.user == pandora.user.username;
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
2011-08-28 19:50:38 +00:00
|
|
|
format: function(value, data) {
|
2011-05-25 19:42:45 +00:00
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
2011-08-28 19:50:38 +00:00
|
|
|
src: Ox.UI.getImageURL(value == 'static' ? 'symbolClick' : 'symbolFind')
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px 2px 1px 2px', // fixme: strange
|
2011-08-28 19:50:38 +00:00
|
|
|
opacity: data.user == pandora.user.username ? 1 : 0.25
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
id: 'type',
|
|
|
|
operator: '+',
|
|
|
|
title: $('<img>')
|
|
|
|
.attr({
|
2011-09-01 04:46:44 +00:00
|
|
|
src: Ox.UI.getImageURL('symbolEdit')
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px 2px 1px 2px',
|
|
|
|
}),
|
2011-08-28 19:50:38 +00:00
|
|
|
tooltip: function(data) {
|
|
|
|
return data.type == 'smart'
|
|
|
|
? (data.user == pandora.user.username ? 'Edit Query' : 'Show Query')
|
2011-09-01 07:43:32 +00:00
|
|
|
: (data.user == pandora.user.username ? 'Edit Default View' : 'Default View: ...');
|
2011-08-28 19:50:38 +00:00
|
|
|
},
|
2011-05-25 19:42:45 +00:00
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
clickable: true,
|
|
|
|
format: function(value) {
|
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
2011-08-09 17:07:24 +00:00
|
|
|
src: Ox.UI.getImageURL(
|
2011-09-01 04:46:44 +00:00
|
|
|
'symbol' + (id == 'favorite' ? 'Like' : 'Star')
|
2011-05-25 19:42:45 +00:00
|
|
|
)
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px 2px 1px 2px',
|
2011-08-28 19:50:38 +00:00
|
|
|
opacity: id == 'favorite'
|
2011-09-01 07:00:35 +00:00
|
|
|
? (value ? 1 : 0.25)
|
|
|
|
: (value == 'featured' ? 1 : 0.25)
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
id: id == 'favorite' ? 'subscribed' : 'status',
|
|
|
|
operator: '+',
|
|
|
|
title: $('<img>')
|
|
|
|
.attr({
|
2011-08-09 17:07:24 +00:00
|
|
|
src: Ox.UI.getImageURL(
|
2011-09-01 04:46:44 +00:00
|
|
|
'symbol' + (id == 'favorite' ? 'Like' : 'Star')
|
2011-05-25 19:42:45 +00:00
|
|
|
)
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px 2px 1px 2px'
|
|
|
|
}),
|
2011-08-28 19:50:38 +00:00
|
|
|
tooltip: function(data) {
|
|
|
|
var checked = id == 'favorite' ? data.subscribed : data.status == 'featured';
|
|
|
|
return (checked ? 'Remove from' : 'Add to')
|
|
|
|
+ ' ' + Ox.toTitleCase(id) + ' Lists';
|
|
|
|
},
|
2011-05-25 19:42:45 +00:00
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
|
|
|
],
|
|
|
|
columnsVisible: true,
|
|
|
|
items: function(data, callback) {
|
|
|
|
var query = id == 'favorite' ? {conditions: [
|
|
|
|
{key: 'status', value: 'public', operator: '='},
|
2011-09-01 07:00:35 +00:00
|
|
|
{key: 'user', value: pandora.user.username, operator: '!'}
|
|
|
|
], operator: '&'} : {conditions: [
|
|
|
|
{key: 'status', value: 'private', operator: '!'}
|
|
|
|
], operator: ''};
|
|
|
|
return pandora.api.findLists(Ox.extend(data, {
|
2011-05-25 19:42:45 +00:00
|
|
|
query: query
|
|
|
|
}), callback);
|
|
|
|
},
|
|
|
|
pageLength: 1000,
|
|
|
|
// fixme: select if previously selected
|
2011-06-06 15:48:11 +00:00
|
|
|
// selected: pandora.user.ui.list ? [pandora.user.ui.list] : [],
|
2011-05-25 19:42:45 +00:00
|
|
|
sort: [
|
|
|
|
{key: 'name', operator: '+'}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(event, data) {
|
|
|
|
if (data.key == 'type') {
|
|
|
|
alert('...');
|
|
|
|
} else if (data.key == 'subscribed') {
|
|
|
|
var subscribed = that.value(data.id, 'subscribed');
|
|
|
|
pandora.api[subscribed ? 'unsubscribeFromList' : 'subscribeToList']({
|
|
|
|
id: data.id,
|
|
|
|
}, function(result) {
|
|
|
|
that.value(data.id, 'subscribed', !subscribed);
|
|
|
|
});
|
|
|
|
} else if (data.key == 'status') {
|
|
|
|
pandora.api.editList({
|
|
|
|
id: data.id,
|
|
|
|
status: that.value(data.id, 'status') == 'featured' ? 'public' : 'featured'
|
|
|
|
}, function(result) {
|
|
|
|
Ox.print('result', result)
|
2011-06-06 15:48:11 +00:00
|
|
|
if (result.data.user == pandora.user.username || result.data.subscribed) {
|
2011-05-25 19:42:45 +00:00
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[
|
|
|
|
result.data.user == pandora.user.username ? 'personal' : 'favorite'
|
2011-05-25 19:42:45 +00:00
|
|
|
].reloadList();
|
|
|
|
}
|
|
|
|
that.value(data.id, 'status', result.data.status);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
init: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.site.sectionFolders[pandora.user.ui.section][i].items = data.items;
|
|
|
|
pandora.$ui.folder[i].$content.css({
|
2011-05-25 19:42:45 +00:00
|
|
|
height: 40 + data.items * 16 + 'px'
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[id].css({
|
2011-05-25 19:42:45 +00:00
|
|
|
height: 16 + data.items * 16 + 'px'
|
|
|
|
});
|
|
|
|
pandora.resizeFolders();
|
|
|
|
},
|
|
|
|
paste: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.list.triggerEvent('paste', data);
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
select: function(event, data) {
|
|
|
|
// fixme: duplicated
|
|
|
|
if (data.ids.length) {
|
2011-06-06 15:48:11 +00:00
|
|
|
$.each(pandora.$ui.folderList, function(id_, $list) {
|
2011-05-25 19:42:45 +00:00
|
|
|
id != id_ && $list.options('selected', []);
|
|
|
|
});
|
|
|
|
pandora.UI.set({list: data.ids[0]});
|
|
|
|
pandora.URL.set('?find=list:' + data.ids[0]);
|
|
|
|
} else {
|
|
|
|
pandora.UI.set({list: ''});
|
|
|
|
pandora.URL.set('');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
2011-08-28 06:24:01 +00:00
|
|
|
/*
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.folderList = function(id) {
|
2011-06-06 15:48:11 +00:00
|
|
|
var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id),
|
2011-05-25 19:42:45 +00:00
|
|
|
that;
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.user.ui.section == 'site') {
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.TextList({
|
2011-05-25 19:42:45 +00:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
format: function() {
|
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
|
|
|
src: Ox.UI.PATH + 'png/icon16.png'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
id: 'id',
|
|
|
|
operator: '+',
|
|
|
|
unique: true,
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'title',
|
|
|
|
operator: '+',
|
|
|
|
visible: true,
|
2011-06-06 15:48:11 +00:00
|
|
|
width: pandora.user.ui.sidebarSize - 16
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
items: function(data, callback) {
|
|
|
|
var result = {data: {}};
|
|
|
|
if (!data.range) {
|
2011-06-06 15:48:11 +00:00
|
|
|
result.data.items = Ox.getObjectById(pandora.site.sectionFolders.site, id).items.length;
|
2011-05-25 19:42:45 +00:00
|
|
|
} else {
|
2011-06-06 15:48:11 +00:00
|
|
|
result.data.items = Ox.getObjectById(pandora.site.sectionFolders.site, id).items;
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
callback(result);
|
|
|
|
},
|
|
|
|
max: 1,
|
|
|
|
min: 1,
|
|
|
|
sort: [{key: '', operator: ''}]
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
select: function(event, data) {
|
|
|
|
// fixme: duplicated
|
2011-06-06 15:48:11 +00:00
|
|
|
$.each(pandora.$ui.folderList, function(id_, $list) {
|
2011-05-25 19:42:45 +00:00
|
|
|
id != id_ && $list.options('selected', []);
|
|
|
|
})
|
|
|
|
pandora.URL.set((id == 'admin' ? 'admin/' : '' ) + data.ids[0]);
|
|
|
|
},
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.section == 'items') {
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.TextList({
|
2011-05-25 19:42:45 +00:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
format: function() {
|
|
|
|
return $('<img>').attr({
|
|
|
|
src: Ox.UI.PATH + 'png/icon16.png'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
id: 'user',
|
|
|
|
operator: '+',
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value) {
|
|
|
|
return value.split('/').join(': ');
|
|
|
|
},
|
|
|
|
id: 'id',
|
|
|
|
operator: '+',
|
|
|
|
unique: true,
|
|
|
|
visible: id == 'favorite',
|
2011-06-06 15:48:11 +00:00
|
|
|
width: pandora.user.ui.sidebarWidth - 88
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
editable: function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
return data.user == pandora.user.username;
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
id: 'name',
|
|
|
|
input: {
|
|
|
|
autovalidate: pandora.ui.autovalidateListname
|
|
|
|
},
|
|
|
|
operator: '+',
|
|
|
|
visible: id != 'favorite',
|
2011-06-06 15:48:11 +00:00
|
|
|
width: pandora.user.ui.sidebarWidth - 88
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
id: 'items',
|
|
|
|
operator: '-',
|
|
|
|
visible: true,
|
|
|
|
width: 40
|
|
|
|
},
|
|
|
|
{
|
|
|
|
clickable: function(data) {
|
|
|
|
return data.type == 'smart';
|
|
|
|
},
|
|
|
|
format: function(value) {
|
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
2011-08-09 17:07:24 +00:00
|
|
|
src: Ox.UI.getImageURL('symbolFind')
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px 2px 1px 2px',
|
|
|
|
opacity: value == 'static' ? 0.1 : 1
|
|
|
|
});
|
|
|
|
},
|
|
|
|
id: 'type',
|
|
|
|
operator: '+',
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
clickable: id == 'personal',
|
|
|
|
format: function(value) {
|
|
|
|
//var symbols = {private: 'Publish', public: 'Publish', featured: 'Star'};
|
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
2011-08-09 17:07:24 +00:00
|
|
|
src: Ox.UI.getImageURL(
|
|
|
|
'symbol' + (value == 'featured' ? 'Star' : 'Publish')
|
2011-05-25 19:42:45 +00:00
|
|
|
)
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px 2px 1px 2px',
|
|
|
|
opacity: value == 'private' ? 0.1 : 1
|
|
|
|
})
|
|
|
|
},
|
|
|
|
id: 'status',
|
|
|
|
operator: '+',
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
}
|
|
|
|
],
|
|
|
|
items: function(data, callback) {
|
|
|
|
var query;
|
|
|
|
if (id == 'personal') {
|
|
|
|
query = {conditions: [
|
2011-06-06 15:48:11 +00:00
|
|
|
{key: 'user', value: pandora.user.username, operator: '='},
|
2011-05-25 19:42:45 +00:00
|
|
|
{key: 'status', value: 'featured', operator: '!'}
|
|
|
|
], operator: '&'};
|
|
|
|
} else if (id == 'favorite') {
|
|
|
|
query = {conditions: [
|
|
|
|
{key: 'subscribed', value: true, operator: '='},
|
|
|
|
{key: 'status', value: 'featured', operator: '!'},
|
|
|
|
], operator: '&'};
|
|
|
|
} else if (id == 'featured') {
|
|
|
|
query = {conditions: [{key: 'status', value: 'featured', operator: '='}], operator: '&'};
|
|
|
|
}
|
|
|
|
return pandora.api.findLists($.extend(data, {
|
|
|
|
query: query
|
|
|
|
}), callback);
|
|
|
|
},
|
|
|
|
max: 1,
|
|
|
|
min: 0,
|
|
|
|
pageLength: 1000,
|
|
|
|
sort: [
|
|
|
|
{key: 'position', operator: '+'}
|
|
|
|
],
|
2011-06-06 15:48:11 +00:00
|
|
|
sortable: id == 'personal' || id == 'favorite' || pandora.user.level == 'admin'
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
left: 0,
|
|
|
|
top: 0,
|
2011-06-06 15:48:11 +00:00
|
|
|
width: pandora.user.ui.sidebarWidth + 'px',
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
.bind({
|
|
|
|
dragenter: function(e) {
|
|
|
|
//Ox.print('DRAGENTER', e)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
var $list = pandora.$ui.folderList[id];
|
2011-05-25 19:42:45 +00:00
|
|
|
if (data.key == 'type') {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
|
2011-05-25 19:42:45 +00:00
|
|
|
} else if (data.key == 'status') {
|
|
|
|
pandora.api.editList({
|
|
|
|
id: data.id,
|
|
|
|
status: $list.value(data.id, data.key) == 'private' ? 'public' : 'private'
|
|
|
|
}, function(result) {
|
|
|
|
$list.value(result.data.id, 'status', result.data.status);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'delete': function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
var $list = pandora.$ui.folderList[id];
|
|
|
|
pandora.user.ui.listQuery.conditions = [];
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.URL.set(pandora.Query.toString());
|
|
|
|
$list.options({selected: []});
|
|
|
|
if (id == 'personal') {
|
|
|
|
pandora.api.removeList({
|
|
|
|
id: data.ids[0]
|
|
|
|
}, function(result) {
|
|
|
|
// fixme: is this the best way to delete a ui preference?
|
2011-06-06 15:48:11 +00:00
|
|
|
delete pandora.user.ui.lists[data.ids[0]];
|
|
|
|
pandora.UI.set({lists: pandora.user.ui.lists});
|
2011-05-25 19:42:45 +00:00
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
|
|
|
$list.reloadList();
|
|
|
|
});
|
|
|
|
} else if (id == 'favorite') {
|
|
|
|
pandora.api.unsubscribeFromList({
|
|
|
|
id: data.ids[0]
|
|
|
|
}, function(result) {
|
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
|
|
|
$list.reloadList();
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (id == 'featured' && pandora.user.level == 'admin') {
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.api.editList({
|
|
|
|
id: data.ids[0],
|
|
|
|
status: 'public'
|
|
|
|
}, function(result) {
|
|
|
|
// fixme: duplicated
|
2011-06-06 15:48:11 +00:00
|
|
|
if (result.data.user == pandora.user.username || result.data.subscribed) {
|
2011-05-25 19:42:45 +00:00
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[
|
|
|
|
result.data.user == pandora.user.username ? 'personal' : 'favorite'
|
2011-05-25 19:42:45 +00:00
|
|
|
].reloadList();
|
|
|
|
}
|
|
|
|
$list.reloadList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
init: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.site.sectionFolders[pandora.user.ui.section][i].items = data.items;
|
|
|
|
pandora.$ui.folder[i].$content.css({
|
2011-05-25 19:42:45 +00:00
|
|
|
height: data.items * 16 + 'px'
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[id].css({
|
2011-05-25 19:42:45 +00:00
|
|
|
height: data.items * 16 + 'px'
|
|
|
|
});
|
|
|
|
pandora.resizeFolders();
|
|
|
|
},
|
|
|
|
move: function(event, data) {
|
|
|
|
data.ids.forEach(function(id, pos) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user.ui.lists[id].position = pos;
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
pandora.api.sortLists({
|
|
|
|
section: id,
|
|
|
|
ids: data.ids
|
|
|
|
});
|
|
|
|
},
|
|
|
|
paste: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.list.triggerEvent('paste', data);
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
select: function(event, data) {
|
|
|
|
if (data.ids.length) {
|
2011-06-06 15:48:11 +00:00
|
|
|
$.each(pandora.$ui.folderList, function(id_, $list) {
|
2011-05-25 19:42:45 +00:00
|
|
|
id != id_ && $list.options('selected', []);
|
2011-08-16 14:19:37 +00:00
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.URL.set('?find=list:' + data.ids[0]);
|
|
|
|
} else {
|
|
|
|
pandora.URL.set('?find=');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
submit: function(event, data) {
|
|
|
|
data_ = {id: data.id};
|
|
|
|
data_[data.key] = data.value;
|
|
|
|
pandora.api.editList(data_, function(result) {
|
|
|
|
if (result.data.id != data.id) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[id].value(data.id, 'name', result.data.name);
|
|
|
|
pandora.$ui.folderList[id].value(data.id, 'id', result.data.id);
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.URL.set('?find=list:' + result.data.id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
|
|
|
pandora.ui.folders = function() {
|
2011-06-19 17:49:25 +00:00
|
|
|
var that = Ox.Element()
|
2011-05-25 19:42:45 +00:00
|
|
|
.css({overflowX: 'hidden', overflowY: 'auto'})
|
|
|
|
.bindEvent({
|
|
|
|
resize: function(event, data) {
|
|
|
|
pandora.resizeFolders();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var counter = 0;
|
|
|
|
//var $sections = [];
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folder = [];
|
|
|
|
pandora.$ui.folderBrowser = {};
|
|
|
|
pandora.$ui.folderList = {};
|
|
|
|
if (pandora.user.ui.section == 'site') {
|
|
|
|
$.each(pandora.site.sectionFolders.site, function(i, folder) {
|
|
|
|
var height = (Ox.getObjectById(pandora.site.sectionFolders.site, folder.id).items.length * 16);
|
2011-06-19 17:49:25 +00:00
|
|
|
pandora.$ui.folder[i] = Ox.CollapsePanel({
|
2011-05-25 19:42:45 +00:00
|
|
|
id: folder.id,
|
2011-06-06 15:48:11 +00:00
|
|
|
collapsed: !pandora.user.ui.showFolder.site[folder.id],
|
2011-05-25 19:42:45 +00:00
|
|
|
size: 16,
|
|
|
|
title: folder.title
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
toggle: function(event, data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
//alert(JSON.stringify(Ox.getObjectById(pandora.site.sectionFolders.site, folder.id)))
|
|
|
|
pandora.$ui.folder[i].$content.css({
|
2011-05-25 19:42:45 +00:00
|
|
|
height: height + 'px'
|
|
|
|
})
|
|
|
|
//.appendTo(that);
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id)
|
2011-05-25 19:42:45 +00:00
|
|
|
.css({
|
|
|
|
height: height + 'px'
|
|
|
|
})
|
2011-06-06 15:48:11 +00:00
|
|
|
.appendTo(pandora.$ui.folder[i].$content);
|
|
|
|
pandora.$ui.folder.forEach(function($folder) {
|
2011-05-25 19:42:45 +00:00
|
|
|
that.append($folder);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//pandora.resizeFolders();
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.section == 'items') {
|
|
|
|
$.each(pandora.site.sectionFolders.items, function(i, folder) {
|
2011-05-25 19:42:45 +00:00
|
|
|
var extras = [];
|
2011-06-06 15:48:11 +00:00
|
|
|
if (folder.id == 'personal' && pandora.user.level != 'guest') {
|
2011-06-19 17:49:25 +00:00
|
|
|
extras = [Ox.Select({
|
2011-05-25 19:42:45 +00:00
|
|
|
items: [
|
|
|
|
{ id: 'new', title: 'New List...' },
|
|
|
|
{ id: 'newfromselection', title: 'New List from Current Selection...', disabled: true },
|
|
|
|
{ id: 'newsmart', title: 'New Smart List...' },
|
|
|
|
{ id: 'newfromresults', title: 'New Smart List from Current Results...', disabled: true },
|
|
|
|
{},
|
|
|
|
{ id: 'addselection', title: 'Add Selection to List...' }
|
|
|
|
],
|
|
|
|
max: 0,
|
|
|
|
min: 0,
|
|
|
|
selectable: false,
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
var $list = pandora.$ui.folderList[folder.id],
|
2011-05-25 19:42:45 +00:00
|
|
|
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;
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.UI.set(['lists', id].join('|'), pandora.site.user.ui.lists['']); // fixme: necessary?
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.URL.set('?find=list:' + id)
|
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
|
|
|
$list.reloadList().bindEventOnce({
|
|
|
|
load: function(event, data) {
|
|
|
|
$list.gainFocus()
|
|
|
|
.options({selected: [id]})
|
|
|
|
.editCell(id, 'name');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})];
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (folder.id == 'favorite' && pandora.user.level != 'guest') {
|
2011-06-19 17:49:25 +00:00
|
|
|
extras = [Ox.Button({
|
2011-05-25 19:42:45 +00:00
|
|
|
selectable: true,
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'Edit',
|
|
|
|
tooltip: 'Manage Favorite Lists',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(event, data) {
|
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
2011-06-06 15:48:11 +00:00
|
|
|
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')
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
|
|
|
} else {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderBrowser.favorite.replaceWith(
|
|
|
|
pandora.$ui.folderList.favorite = pandora.ui.folderList('favorite')
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
pandora.resizeFolders();
|
|
|
|
}
|
|
|
|
})];
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (folder.id == 'featured' && pandora.user.level == 'admin') {
|
2011-06-19 17:49:25 +00:00
|
|
|
extras = [Ox.Button({
|
2011-05-25 19:42:45 +00:00
|
|
|
selectable: true,
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'Edit',
|
|
|
|
tooltip: 'Manage Featured Lists',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(event, data) {
|
|
|
|
Ox.Request.clearCache(); // fixme: remove
|
2011-06-06 15:48:11 +00:00
|
|
|
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'));
|
2011-05-25 19:42:45 +00:00
|
|
|
} else {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folderBrowser.featured.replaceWith(
|
|
|
|
pandora.$ui.folderList.featured = pandora.ui.folderList('featured')
|
2011-05-25 19:42:45 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
pandora.resizeFolders();
|
|
|
|
}
|
|
|
|
})];
|
|
|
|
}
|
2011-06-19 17:49:25 +00:00
|
|
|
pandora.$ui.folder[i] = Ox.CollapsePanel({
|
2011-05-25 19:42:45 +00:00
|
|
|
id: folder.id,
|
2011-06-06 15:48:11 +00:00
|
|
|
collapsed: !pandora.user.ui.showFolder.items[folder.id],
|
2011-05-25 19:42:45 +00:00
|
|
|
extras: extras,
|
|
|
|
size: 16,
|
|
|
|
title: folder.title
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
// fixme: duplicated
|
|
|
|
click: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
var $list = pandora.$ui.folderList[i],
|
2011-05-25 19:42:45 +00:00
|
|
|
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(event, data) {
|
|
|
|
$list.gainFocus()
|
|
|
|
.options({selected: [id]})
|
|
|
|
.editCell(id, 'name');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (data.id == 'browse') {
|
|
|
|
alert('??')
|
2011-08-28 06:24:01 +00:00
|
|
|
//pandora.$ui.sectionList[1].replaceWith(pandora.$ui.publicLists = pandora.ui.publicLists());
|
|
|
|
//pandora.site.showAllPublicLists = true;
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
toggle: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
data.collapsed && pandora.$ui.folderList[folder.id].loseFocus();
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.UI.set('showFolder|items|' + folder.id, !data.collapsed);
|
|
|
|
pandora.resizeFolders();
|
|
|
|
}
|
|
|
|
});
|
2011-06-06 15:48:11 +00:00
|
|
|
//$sections.push(pandora.$ui.section[i]);
|
|
|
|
pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id)
|
2011-05-25 19:42:45 +00:00
|
|
|
.bindEventOnce({
|
|
|
|
init: function(event, data) {
|
|
|
|
Ox.print('init', i, counter)
|
|
|
|
if (++counter == 3) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.folder.forEach(function($folder) {
|
2011-05-25 19:42:45 +00:00
|
|
|
that.append($folder);
|
|
|
|
});
|
|
|
|
pandora.resizeFolders();
|
|
|
|
pandora.selectList(); //fixme: doesn't work
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2011-06-06 15:48:11 +00:00
|
|
|
.appendTo(pandora.$ui.folder[i].$content);
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
that.toggle = function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
return that;
|
|
|
|
};
|
2011-08-28 06:24:01 +00:00
|
|
|
*/
|
2011-05-25 19:42:45 +00:00
|
|
|
|