pandora/static/js/titlesDialog.js

181 lines
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),
2014-09-26 12:12:25 +00:00
width = 512 + Ox.UI.SCROLLBAR_SIZE,
2011-10-11 11:29:05 +00:00
$findInput = Ox.Input({
changeOnKeypress: true,
clear: true,
2014-02-13 16:24:52 +00:00
placeholder: Ox._('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({
2012-06-20 10:47:15 +00:00
query: query
2011-10-29 17:46:46 +00:00
});
2011-10-11 11:29:05 +00:00
}
}),
2012-06-27 07:41:39 +00:00
$list = Ox.TableList({
2011-10-11 11:29:05 +00:00
columns: [
{
id: 'id',
2013-05-09 10:13:58 +00:00
title: Ox._('ID'),
2012-05-26 15:46:24 +00:00
visible: false
2011-10-11 11:29:05 +00:00
},
{
id: 'title',
operator: '+',
removable: false,
2013-05-09 10:13:58 +00:00
title: Ox._('Title'),
2011-10-11 11:29:05 +00:00
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: '+',
2013-05-09 10:13:58 +00:00
title: Ox._('Sort Title'),
2011-10-11 11:29:05 +00:00
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,
sort: [{key: 'sorttitle', operator: '+'}],
unique: 'id'
2011-10-11 11:29:05 +00:00
})
.bindEvent({
init: function(data) {
$status.html(
Ox.toTitleCase(Ox.formatCount(data.items, 'title'))
);
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,
2013-05-09 10:13:58 +00:00
title: Ox._('Find'),
2012-05-26 15:46:24 +00:00
width: 48
}).bindEvent({
click: function() {
that.close();
2013-07-14 15:36:49 +00:00
pandora.UI.set({find: {
conditions: [{
key: 'title',
value: $list.value($list.options('selected'), 'title'),
operator: '='
}],
operator: '&'
2013-07-14 15:36:49 +00:00
}});
2012-06-11 08:50:03 +00:00
pandora.$ui.findElement.updateElement();
}
}),
2011-10-11 11:29:05 +00:00
that = Ox.Dialog({
buttons: [
Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Manage Names...')
}).bindEvent({
click: function() {
that.close();
(pandora.$ui.namesDialog || (
pandora.$ui.namesDialog = pandora.ui.namesDialog()
)).open();
}
}),
{},
$findButton,
Ox.Button({
2013-05-09 10:13:58 +00:00
title: Ox._('Done'),
width: 48
}).bindEvent({
click: function() {
that.close();
}
})
2011-10-11 11:29:05 +00:00
],
closeButton: true,
content: Ox.SplitPanel({
elements: [
{
element: Ox.Bar({size: 24})
.append($status)
.append(
$findInput
),
size: 24
},
{
element: $list
}
],
orientation: 'vertical'
}),
height: height,
maximizeButton: true,
minHeight: 256,
minWidth: 512,
padding: 0,
2013-05-09 10:13:58 +00:00
title: Ox._('Manage Titles'),
width: width
})
.bindEvent({
resizeend: function(data) {
2014-09-26 12:12:25 +00:00
var width = (data.width - Ox.UI.SCROLLBAR_SIZE) / 2;
[
{id: 'title', width: Math.ceil(width)},
{id: 'sorttitle', width: Math.floor(width)}
].forEach(function(column) {
$list.resizeColumn(column.id, column.width);
});
}
2011-10-11 11:29:05 +00:00
}),
$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',
2012-05-26 15:46:24 +00:00
textAlign: 'center'
})
2012-05-22 13:15:16 +00:00
.appendTo(that.find('.OxButtonsbar'));
2011-10-11 11:29:05 +00:00
return that;
};