cablegates/static/js/pandora/ui/folderBrowserBar.js

61 lines
2.4 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-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
Ox.print('ID', id)
pandora.$ui.findListElement[id] = Ox.FormElementGroup({
elements: [
pandora.$ui.findListSelect[id] = Ox.Select({
items: [
{id: 'user', title: 'Find: User', checked: true},
{id: 'list', title: 'Find: List'}
],
overlap: 'right',
type: 'image'
})
.bindEvent({
change: function(data) {
pandora.$ui.findListInput[id].options({
placeholder: data.selected[0].title
});
}
}),
pandora.$ui.findListInput[id] = Ox.Input({
clear: true,
placeholder: 'Find: User',
width: pandora.getFoldersWidth() - 24
})
.bindEvent({
submit: function(data) {
var key = pandora.$ui.findListSelect[id].value() == 'user' ? 'user' : 'name',
value = data.value;
pandora.$ui.folderList[id].options({
items: function(data, callback) {
var query = id == 'favorite' ? {conditions: [
{key: 'status', value: 'public', operator: '='},
{key: 'user', value: pandora.user.username, operator: '!'},
{key: key, value: value, operator: ''}
], operator: '&'} : {conditions: [
{key: 'status', value: 'private', operator: '!'},
{key: key, value: value, operator: ''}
], operator: '&'};
return pandora.api.findLists(Ox.extend(data, {
query: query
}), callback);
}
});
}
})
],
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);
return that;
};