pandora/static/js/folderBrowserBar.js

72 lines
2.8 KiB
JavaScript
Raw Normal View History

2011-11-05 17:04:10 +00:00
'use strict';
2018-06-19 06:33:26 +00:00
2013-07-15 11:39:23 +00:00
pandora.ui.folderBrowserBar = function(id, section) {
section = section || pandora.user.ui.section;
2013-02-16 01:20:40 +00:00
var ui = pandora.user.ui,
2016-10-04 22:00:03 +00:00
folderItems = pandora.getFolderItems(section),
2013-02-16 01:20:40 +00:00
folderItem = folderItems.slice(0, -1),
that = Ox.Bar({
2011-05-25 19:42:45 +00:00
size: 24
});
pandora.$ui.findListsElement[id] = Ox.FormElementGroup({
2011-09-01 07:00:35 +00:00
elements: [
pandora.$ui.findListsSelect[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')},
2014-02-13 16:24:52 +00:00
{id: 'name', title: Ox._('Find: {0}', [Ox._(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,
value = pandora.$ui.findListsInput[id].value();
2011-12-21 15:34:28 +00:00
value && updateList(key, value);
pandora.$ui.findListsInput[id].options({
2011-12-21 15:34:28 +00:00
placeholder: data.title
});
}
}),
pandora.$ui.findListsInput[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) {
var key = pandora.$ui.findListsSelect[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;
};