update filter, add list dialog

This commit is contained in:
rolux 2011-09-19 12:29:55 +00:00
parent 4b523361fe
commit f597de57b5
11 changed files with 75 additions and 48 deletions

View file

@ -31,7 +31,7 @@
{
"id": "all",
"title": "All",
"type": "string",
"type": "text",
"find": true
},
{

View file

@ -94,7 +94,7 @@ function constructList() {
app.api.api(function(results) {
var items = [];
Ox.forEach(results.data.actions, function(v, k) {
items.push({'name': v})
items.push({'name': k})
});
items.sort(_sort);
var result = {'data': {'items': items.length}};
@ -104,7 +104,7 @@ function constructList() {
app.api.api(function(results) {
var items = [];
Ox.forEach(results.data.actions, function(v, k) {
items.push({'name': v})
items.push({'name': k})
});
items.sort(_sort);
var result = {'data': {'items': items}};
@ -142,7 +142,7 @@ function constructList() {
.addClass("margin")
.click(function() { $code.toggle()})
.appendTo(info)
var f = app.actions[k].code[0];
var f = app.actions[id].code[0];
$('<span>').html(' View Source ('+f+')').appendTo(info)
$('<pre>').append($code).appendTo(info)
hljs.highlightBlock($code[0], ' ');

View file

@ -96,7 +96,7 @@ pandora.Query = (function() {
find: {index: -1, key: '', value: ''},
groups: [], // {index, query, selected}
list: '',
query: {conditions: [], operator: ''}
query: {conditions: [], operator: '&'}
},
subconditions = [];
if (str.length) {

View file

@ -1,21 +1,27 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.filter = function() {
pandora.ui.filter = function(list) {
var that = Ox.Filter({
findKeys: Ox.map(pandora.site.itemKeys, function(key) {
return key.id == 'all' ? null : {
autocomplete: key.autocomplete,
autocompleteSortKey: key.autocompleteSortKey,
format: key.format,
id: key.id,
title: key.title,
type: key.type == 'layer' ? Ox.getObjectById(
pandora.site.layers, key.id
).type : key.type
};
}),
sortKeys: pandora.site.sortKeys,
viewKeys: pandora.site.listViews
});
findKeys: Ox.merge(Ox.map(pandora.site.itemKeys, function(key) {
return {
autocomplete: key.autocomplete,
autocompleteSortKey: key.autocompleteSortKey,
format: key.format,
id: key.id,
title: key.title,
type: key.type == 'layer' ? Ox.getObjectById(
pandora.site.layers, key.id
).type : key.type
};
}), {
id: 'list',
title: 'List',
type: 'list'
}),
query: list ? list.query : pandora.user.ui.query,
sortKeys: pandora.site.sortKeys,
viewKeys: pandora.site.listViews
})
.css({padding: '16px'});
return that;
};

View file

@ -1,5 +1,5 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.filterDialog = function() {
pandora.ui.filterDialog = function(list) {
var that = Ox.Dialog({
buttons: [
Ox.Button({
@ -11,6 +11,7 @@ pandora.ui.filterDialog = function() {
alert(JSON.stringify(pandora.$ui.filter.options('query')));
}
}),
/*
Ox.Button({
id: 'cancel',
title: 'Cancel'
@ -20,9 +21,10 @@ pandora.ui.filterDialog = function() {
pandora.$ui.filterDialog.close();
}
}),
*/
Ox.Button({
id: 'save',
title: 'Save'
id: 'done',
title: 'Done'
})
.bindEvent({
click: function() {
@ -30,13 +32,13 @@ pandora.ui.filterDialog = function() {
}
})
],
content: pandora.$ui.filter = pandora.ui.filter().css({padding: '16px'}),
content: pandora.$ui.filter = pandora.ui.filter(list),
maxWidth: 648 + Ox.UI.SCROLLBAR_SIZE,
minHeight: 264,
minWidth: 648 + Ox.UI.SCROLLBAR_SIZE,
height: 264,
keys: {enter: 'save', escape: 'cancel'},
title: 'Advanced Find',
// keys: {enter: 'save', escape: 'cancel'},
title: list ? 'Smart List - ' + list.name : 'Advanced Find',
width: 648 + Ox.UI.SCROLLBAR_SIZE
});
return that;

View file

@ -138,7 +138,11 @@ pandora.ui.folderBrowserList = function(id) {
.bindEvent({
click: function(data) {
if (data.key == 'type') {
alert('...');
/*
if (that.value(data.id, 'type') == 'smart') {
pandora.$ui.filterDialog = pandora.ui.filterDialog(that.value(data.id, 'query')).open();
}
*/
} else if (data.key == 'subscribed') {
var subscribed = that.value(data.id, 'subscribed');
pandora.api[subscribed ? 'unsubscribeFromList' : 'subscribeToList']({

View file

@ -8,6 +8,9 @@ pandora.ui.folderList = function(id) {
if (id != 'volumes') {
columns = [
{
clickable: function(data) {
return data.user == pandora.user.username;
},
format: function() {
return $('<img>').attr({
src: Ox.UI.getImageURL('symbolIcon')
@ -19,6 +22,9 @@ pandora.ui.folderList = function(id) {
},
id: 'user',
operator: '+',
tooltip: function(data) {
return data.user == pandora.user.username ? 'Edit Icon' : '';
},
visible: true,
width: 16
},
@ -229,6 +235,7 @@ pandora.ui.folderList = function(id) {
that = Ox.TextList({
columns: columns,
items: items,
keys: ['query'],
max: 1,
min: 0,
pageLength: 1000,
@ -282,15 +289,20 @@ pandora.ui.folderList = function(id) {
}
},
click: function(data) {
var $list = pandora.$ui.folderList[id];
if (data.key == 'type') {
pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
//var $list = pandora.$ui.folderList[id];
if (data.key == 'user') {
pandora.$ui.filterDialog = pandora.ui.listDialog(that.value(data.id), 'icon').open();
} else if (data.key == 'type') {
if (that.value(data.id, 'type') == 'smart') {
pandora.$ui.filterDialog = pandora.ui.listDialog(that.value(data.id), 'query').open();
}
} else if (data.key == 'status') {
pandora.api.editList({
id: data.id,
status: $list.value(data.id, data.key) == 'private' ? 'public' : 'private'
status: that.value(data.id, data.key) == 'private' ? 'public' : 'private'
}, function(result) {
$list.value(result.data.id, 'status', result.data.status);
that.value(result.data.id, 'status', result.data.status);
});
} else if (data.key == 'path') {
@ -300,23 +312,23 @@ pandora.ui.folderList = function(id) {
},
'delete': function(data) {
// fixme: add a confirmation dialog
var $list = pandora.$ui.folderList[id];
//var $list = pandora.$ui.folderList[id];
pandora.URL.set('?find=');
$list.options({selected: []});
that.options({selected: []});
if (id == 'personal') {
pandora.api.removeList({
id: data.ids[0]
}, function(result) {
pandora.UI.set(['lists', data.ids[0]].join('|'), null);
Ox.Request.clearCache(); // fixme: remove
$list.reloadList();
that.reloadList();
});
} else if (id == 'favorite') {
pandora.api.unsubscribeFromList({
id: data.ids[0]
}, function(result) {
Ox.Request.clearCache(); // fixme: remove
$list.reloadList();
that.reloadList();
});
} else if (id == 'featured' && pandora.user.level == 'admin') {
pandora.api.editList({
@ -330,7 +342,7 @@ pandora.ui.folderList = function(id) {
result.data.user == pandora.user.username ? 'personal' : 'favorite'
].reloadList();
}
$list.reloadList();
that.reloadList();
});
}
},

View file

@ -27,9 +27,11 @@ pandora.ui.info = function() {
if (result.data) {
pandora.$ui.videoPreview && pandora.$ui.videoPreview.removeElement();
pandora.$ui.videoPreview = pandora.ui.videoPreview({
id: id,
duration: result.data.duration,
frameRatio: result.data.videoRatio
frameRatio: result.data.videoRatio,
height: pandora.getInfoHeight(),
id: id,
width: pandora.user.ui.sidebarSize
}).appendTo(pandora.$ui.info);
}
});

View file

@ -23,6 +23,7 @@ pandora.ui.leftPanel = function() {
.bindEvent({
resize: function(data) {
pandora.user.ui.sidebarSize = data.size;
var infoHeight = pandora.getInfoHeight();
if (data.size < pandora.site.sectionButtonsWidth && pandora.$ui.sectionButtons) {
pandora.$ui.sectionButtons.removeElement();
delete pandora.$ui.sectionButtons;
@ -32,8 +33,8 @@ pandora.ui.leftPanel = function() {
delete pandora.$ui.sectionSelect;
pandora.$ui.sectionbar.append(pandora.$ui.sectionButtons = pandora.ui.sectionButtons());
}
!pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -infoSize});
pandora.$ui.leftPanel.size(2, pandora.getInfoHeight());
!pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -infoHeight});
pandora.$ui.leftPanel.size(2, infoHeight);
pandora.$ui.info.resizeInfo();
pandora.resizeFolders();
},

View file

@ -4,20 +4,19 @@ pandora.ui.videoPreview = function(data) {
var that = Ox.VideoPreview({
duration: data.duration,
getFrame: function(position) {
var width = pandora.user.ui.sidebarSize,
height = Math.min(width, 256),
resolution = Ox.filter(pandora.site.video.resolutions, function(resolution, i) {
return resolution >= height || i == pandora.site.video.resolutions.length - 1;
var resolution = Ox.filter(pandora.site.video.resolutions, function(resolution, i) {
return resolution >= data.height || i == pandora.site.video.resolutions.length - 1;
})[0];
return '/' + data.id + '/' + resolution + 'p' + (
Ox.isUndefined(position) ? '' : position
) + '.jpg';
},
frameCSS: data.frameCSS,
frameRatio: data.frameRatio,
height: pandora.getInfoHeight(),
height: data.height,
scaleToFill: true,
timeline: '/' + data.id + '/timeline16p.png',
width: pandora.user.ui.sidebarSize
width: data.width
})
.bindEvent({
click: function(event) {

View file

@ -43,5 +43,6 @@
"js/pandora/ui/mediaView.js",
"js/pandora/ui/home.js",
"js/pandora/ui/preferencesDialog.js",
"js/pandora/ui/listDialog.js",
"js/pandora/ui/siteDialog.js"
]