cablegates/static/js/pandora/ui/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-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({
items: [
{id: 'user', title: 'Find: User', checked: true},
{id: 'list', title: 'Find: List'}
],
overlap: 'right',
type: 'image'
})
.bindEvent({
change: function(data) {
2011-09-01 09:17:49 +00:00
var key = data.selected[0].id == 'user' ? 'user' : 'name',
value = pandora.$ui.findListInput[id].value();
value && updateItems(key, value);
2011-09-01 07:00:35 +00:00
pandora.$ui.findListInput[id].options({
placeholder: data.selected[0].title
});
}
}),
pandora.$ui.findListInput[id] = Ox.Input({
2011-09-01 07:43:32 +00:00
changeOnKeypress: true,
2011-09-01 07:00:35 +00:00
clear: true,
placeholder: 'Find: User',
width: pandora.getFoldersWidth() - 24
})
.bindEvent({
2011-09-01 07:43:32 +00:00
change: function(data) {
Ox.print('ID::', id)
2011-09-01 07:00:35 +00:00
var key = pandora.$ui.findListSelect[id].value() == 'user' ? 'user' : 'name',
value = data.value;
2011-09-01 09:17:49 +00:00
updateItems(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);
2011-09-01 09:17:49 +00:00
function updateItems(key, 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
return that;
};