pandora/static/js/pandora/folderBrowserBar.js

68 lines
2.6 KiB
JavaScript
Raw Normal View History

2011-07-29 18:37:11 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-11-05 17:04:10 +00:00
'use strict';
2011-05-25 19:42:45 +00:00
pandora.ui.folderBrowserBar = function(id) {
2011-06-19 17:49:25 +00:00
var that = Ox.Bar({
2011-05-25 19:42:45 +00:00
size: 24
});
2011-09-01 07:00:35 +00:00
pandora.$ui.findListElement[id] = Ox.FormElementGroup({
elements: [
pandora.$ui.findListSelect[id] = Ox.Select({
2011-12-21 15:34:28 +00:00
items: [
2011-12-22 15:48:48 +00:00
{id: 'user', title: 'Find: User'},
{id: 'name', title: 'Find: List'}
2011-12-21 15:34:28 +00:00
],
overlap: 'right',
type: 'image'
})
.bindEvent({
change: function(data) {
2011-12-22 15:48:48 +00:00
var key = data.value,
2011-12-21 15:34:28 +00:00
value = pandora.$ui.findListInput[id].value();
value && updateList(key, value);
pandora.$ui.findListInput[id].options({
placeholder: data.title
});
}
}),
2011-09-01 07:00:35 +00:00
pandora.$ui.findListInput[id] = Ox.Input({
2011-12-21 15:34:28 +00:00
changeOnKeypress: true,
clear: true,
placeholder: 'Find: User',
width: pandora.getFoldersWidth() - 24
})
.bindEvent({
change: function(data) {
2011-12-22 15:48:48 +00:00
var key = pandora.$ui.findListSelect[id].value(),
2011-12-21 15:34:28 +00:00
value = data.value;
updateList(key, value);
}
})
2011-09-01 07:00:35 +00:00
],
2011-05-25 19:42:45 +00:00
})
.css({
2011-09-01 07:00:35 +00:00
float: 'right',
2011-05-25 19:42:45 +00:00
margin: '4px',
align: 'right'
})
.appendTo(that);
function updateList(key, value) {
2011-09-01 09:17:49 +00:00
pandora.$ui.folderList[id].options({
items: function(data, callback) {
var query = id == 'favorite' ? {conditions: [
{key: 'status', value: 'public', operator: '='},
2011-09-28 17:32:03 +00:00
{key: 'user', value: pandora.user.username, operator: '!=='},
2011-10-03 09:31:20 +00:00
{key: key, value: value, operator: '='}
2011-09-01 09:17:49 +00:00
], operator: '&'} : {conditions: [
2011-09-28 17:32:03 +00:00
{key: 'status', value: 'private', operator: '!='},
2011-10-03 09:31:20 +00:00
{key: key, value: value, operator: '='}
2011-09-01 09:17:49 +00:00
], operator: '&'};
return pandora.api.findLists(Ox.extend(data, {
query: query
}), callback);
}
});
}
2011-05-25 19:42:45 +00:00
return that;
};