pandora/static/js/pandora/folderBrowserBar.js

71 lines
2.8 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) {
2013-02-16 01:20:40 +00:00
var ui = pandora.user.ui,
folderItems = ui.section == 'items' ? 'Lists' : Ox.toTitleCase(ui.section),
folderItem = folderItems.slice(0, -1),
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: [
2013-05-09 10:13:58 +00:00
{id: 'user', title: Ox._('Find: User')},
{id: 'name', title: Ox._('Find: {0}', [folderItem])}
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,
2013-05-09 10:13:58 +00:00
placeholder: Ox._('Find: User'),
2011-12-21 15:34:28 +00:00
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);
}
})
2012-05-26 15:46:24 +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: '&'};
2013-02-16 01:20:40 +00:00
return pandora.api['find' + folderItems](Ox.extend(data, {
2011-09-01 09:17:49 +00:00
query: query
}), callback);
}
});
}
2011-05-25 19:42:45 +00:00
return that;
};