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,
|
2011-10-11 16:20:41 +00:00
|
|
|
placeholder: 'Find',
|
2011-10-11 11:29:05 +00:00
|
|
|
width: 192
|
|
|
|
})
|
2011-10-11 16:20:41 +00:00
|
|
|
.css({float: 'right', margin: '4px'})
|
2011-10-11 11:29:05 +00:00
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
2011-10-11 16:20:41 +00:00
|
|
|
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,
|
2012-06-27 22:24:02 +00:00
|
|
|
sort: [{key: 'sorttitle', operator: '+'}],
|
|
|
|
unique: 'id'
|
2011-10-11 11:29:05 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
init: function(data) {
|
|
|
|
numberOfTitles = data.items;
|
2011-10-11 16:13:21 +00:00
|
|
|
$status.html(
|
|
|
|
Ox.formatNumber(numberOfTitles)
|
|
|
|
+ ' title' + (numberOfTitles == 1 ? '' : 's')
|
|
|
|
);
|
2011-10-11 11:29:05 +00:00
|
|
|
},
|
2011-10-11 17:25:06 +00:00
|
|
|
open: function(data) {
|
2012-05-22 13:15:16 +00:00
|
|
|
$list.find('.OxItem.OxSelected > .OxCell.OxColumnSorttitle')
|
2011-11-08 18:16:48 +00:00
|
|
|
.trigger('mousedown')
|
|
|
|
.trigger('mouseup');
|
2011-10-11 17:25:06 +00:00
|
|
|
},
|
2011-10-11 18:13:51 +00:00
|
|
|
select: function(data) {
|
|
|
|
$findButton.options({disabled: !data.ids.length});
|
|
|
|
},
|
2011-10-11 16:01:33 +00:00
|
|
|
submit: function(data) {
|
2011-10-11 17:25:06 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2011-10-11 18:13:51 +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
|
2011-10-11 18:13:51 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
2013-07-14 15:36:49 +00:00
|
|
|
pandora.UI.set({find: {
|
2011-10-11 18:13:51 +00:00
|
|
|
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 18:13:51 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2011-10-11 11:29:05 +00:00
|
|
|
that = Ox.Dialog({
|
2012-09-15 12:14:12 +00:00
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Manage Names...')
|
2012-09-15 12:14:12 +00:00
|
|
|
}).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'),
|
2012-09-15 12:14:12 +00:00
|
|
|
width: 48
|
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
}
|
|
|
|
})
|
2011-10-11 11:29:05 +00:00
|
|
|
],
|
2012-09-15 12:14:12 +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'),
|
2012-09-15 12:14:12 +00:00
|
|
|
width: width
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resizeend: function(data) {
|
|
|
|
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
|
|
|
}),
|
2011-10-11 16:13:21 +00:00
|
|
|
|
|
|
|
$status = $('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
top: '4px',
|
2011-10-11 16:30:06 +00:00
|
|
|
left: '128px',
|
|
|
|
right: '128px',
|
2011-10-11 16:13:21 +00:00
|
|
|
bottom: '4px',
|
|
|
|
paddingTop: '2px',
|
|
|
|
fontSize: '9px',
|
2012-05-26 15:46:24 +00:00
|
|
|
textAlign: 'center'
|
2011-10-11 16:13:21 +00:00
|
|
|
})
|
2012-05-22 13:15:16 +00:00
|
|
|
.appendTo(that.find('.OxButtonsbar'));
|
2011-10-11 11:29:05 +00:00
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|
|
|
|
|