pandora/static/js/filterDialog.js

91 lines
3.9 KiB
JavaScript
Raw Normal View History

2011-11-05 17:04:10 +00:00
'use strict';
2018-06-19 06:33:26 +00:00
pandora.ui.filterDialog = function() {
2011-06-19 17:49:25 +00:00
var that = Ox.Dialog({
buttons: [
Ox.Button({
id: 'done',
2013-05-09 10:13:58 +00:00
title: Ox._('Done')
})
.bindEvent({
click: function() {
var list = pandora.$ui.filterForm.getList();
if (list.save) {
pandora.api[
pandora.user.ui.section == 'documents' ? 'addCollection' : 'addList'
]({
name: list.name,
query: list.query,
status: 'private',
type: 'smart'
}, function(result) {
var $list = pandora.$ui.folderList.personal,
id = result.data.id;
if (pandora.user.ui.section) {
pandora.UI.set({
findDocuments: {
conditions: [{key: 'collection', value: id, operator: '=='}],
operator: '&'
}
});
} else {
pandora.UI.set({
find: {
conditions: [{key: 'list', value: id, operator: '=='}],
operator: '&'
}
});
}
Ox.Request.clearCache(); // fixme: remove
$list.bindEventOnce({
load: function(data) {
$list.gainFocus()
.options({selected: [id]});
}
})
.reloadList();
});
} else if (!pandora.user.ui.updateAdvancedFindResults) {
pandora.$ui.filterForm.updateResults();
}
that.close();
}
})
],
2019-06-07 15:30:09 +00:00
content: pandora.$ui.filterForm = (pandora.user.ui.section == 'documents'
? pandora.ui.documentFilterForm
: pandora.ui.filterForm
)({
mode: 'find'
}),
2014-09-26 12:12:25 +00:00
maxWidth: 648 + Ox.UI.SCROLLBAR_SIZE,
minHeight: 264,
2014-09-26 12:12:25 +00:00
minWidth: 648 + Ox.UI.SCROLLBAR_SIZE,
height: 264,
// keys: {enter: 'save', escape: 'cancel'},
removeOnClose: true,
title: Ox._('Advanced Find'),
2014-09-26 12:12:25 +00:00
width: 648 + Ox.UI.SCROLLBAR_SIZE
}),
$updateCheckbox = Ox.Checkbox({
2013-05-09 10:13:58 +00:00
title: Ox._('Update Results in the Background'),
value: pandora.user.ui.updateAdvancedFindResults
})
.css({float: 'left', margin: '4px'})
.bindEvent({
change: function(data) {
pandora.UI.set({updateAdvancedFindResults: data.value});
data.value && pandora.$ui.filterForm.updateResults();
}
});
$($updateCheckbox.find('.OxButton')[0]).css({margin: 0});
$(that.find('.OxBar')[1]).append($updateCheckbox);
2011-05-25 19:42:45 +00:00
return that;
2011-05-25 19:42:45 +00:00
};