pandora/static/js/pandora/titlesDialog.js

176 lines
5.6 KiB
JavaScript
Raw Normal View History

2011-10-11 11:29:05 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-11-05 17:04:10 +00:00
'use strict';
2011-10-11 11:29:05 +00:00
pandora.ui.titlesDialog = function() {
var height = Math.round((window.innerHeight - 48) * 0.9),
2011-10-11 16:01:33 +00:00
width = 512 + Ox.UI.SCROLLBAR_SIZE,
2011-10-11 11:29:05 +00:00
numberOfTitles = 0,
$findInput = Ox.Input({
changeOnKeypress: true,
clear: true,
placeholder: 'Find',
2011-10-11 11:29:05 +00:00
width: 192
})
.css({float: 'right', margin: '4px'})
2011-10-11 11:29:05 +00:00
.bindEvent({
change: function(data) {
var query = {
conditions: [
{key: 'title', value: data.value, operator: '='},
{key: 'sorttitle', value: data.value, operator: '='}
],
operator: '|'
};
$list.options({
items: function(data, callback) {
return pandora.api.findTitles(Ox.extend(data, {
query: query
}), callback);
}
2011-10-29 17:46:46 +00:00
});
2011-10-11 11:29:05 +00:00
}
}),
$list = Ox.TextList({
columns: [
{
id: 'id',
title: 'ID',
unique: true,
visible: false,
},
{
id: 'title',
operator: '+',
removable: false,
title: 'Title',
visible: true,
2011-10-11 16:01:33 +00:00
width: 256
2011-10-11 11:29:05 +00:00
},
{
2011-10-11 16:01:33 +00:00
editable: true,
id: 'sorttitle',
2011-10-11 11:29:05 +00:00
operator: '+',
title: 'Sort Title',
visible: true,
2011-10-11 16:01:33 +00:00
width: 256
2011-10-11 11:29:05 +00:00
},
],
columnsVisible: true,
items: pandora.api.findTitles,
keys: [],
max: 1,
scrollbarVisible: true,
2011-10-11 16:01:33 +00:00
sort: [{key: 'sorttitle', operator: '+'}]
2011-10-11 11:29:05 +00:00
})
.bindEvent({
init: function(data) {
numberOfTitles = data.items;
$status.html(
Ox.formatNumber(numberOfTitles)
+ ' title' + (numberOfTitles == 1 ? '' : 's')
);
2011-10-11 11:29:05 +00:00
},
open: function(data) {
2012-05-22 13:15:16 +00:00
$list.find('.OxItem.OxSelected > .OxCell.OxColumnSorttitle')
.trigger('mousedown')
.trigger('mouseup');
},
select: function(data) {
$findButton.options({disabled: !data.ids.length});
},
2011-10-11 16:01:33 +00:00
submit: function(data) {
Ox.Request.clearCache('findTitles');
2011-10-11 16:01:33 +00:00
pandora.api.editTitle({
id: data.id,
2011-10-11 16:58:12 +00:00
sorttitle: data.value
2011-10-11 16:01:33 +00:00
});
2011-10-11 11:29:05 +00:00
}
}),
$findButton = Ox.Button({
disabled: true,
title: 'Find',
width: 48,
}).bindEvent({
click: function() {
that.close();
pandora.UI.set('find', {
conditions: [{
key: 'title',
value: $list.value($list.options('selected'), 'title'),
operator: '='
}],
operator: '&'
})
}
}),
2011-10-11 11:29:05 +00:00
that = Ox.Dialog({
buttons: [
2011-10-11 16:30:06 +00:00
Ox.Button({
title: 'Manage Names...'
}).bindEvent({
click: function() {
that.close();
(pandora.$ui.namesDialog || (
pandora.$ui.namesDialog = pandora.ui.namesDialog()
)).open();
2011-10-11 16:30:06 +00:00
}
}),
{},
$findButton,
2011-10-11 11:29:05 +00:00
Ox.Button({
title: 'Done',
width: 48
2011-10-11 11:29:05 +00:00
}).bindEvent({
click: function() {
that.close();
}
})
],
closeButton: true,
content: Ox.SplitPanel({
elements: [
{
2011-10-11 16:01:33 +00:00
element: Ox.Bar({size: 24})
.append($status)
.append(
$findInput
2011-10-11 16:01:33 +00:00
),
size: 24
2011-10-11 11:29:05 +00:00
},
{
2011-10-11 16:01:33 +00:00
element: $list
2011-10-11 11:29:05 +00:00
}
],
2011-10-11 16:01:33 +00:00
orientation: 'vertical'
2011-10-11 11:29:05 +00:00
}),
height: height,
maximizeButton: true,
minHeight: 256,
minWidth: 512,
padding: 0,
title: 'Manage Titles',
width: width
}),
$status = $('<div>')
.css({
position: 'absolute',
top: '4px',
2011-10-11 16:30:06 +00:00
left: '128px',
right: '128px',
bottom: '4px',
paddingTop: '2px',
fontSize: '9px',
textAlign: 'center',
})
2012-05-22 13:15:16 +00:00
.appendTo(that.find('.OxButtonsbar'));
2011-10-11 11:29:05 +00:00
return that;
};