2014-01-07 08:24:00 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
pandora.ui.documentsPanel = function(options) {
|
|
|
|
|
|
|
|
var ui = pandora.user.ui,
|
2014-02-08 16:43:56 +00:00
|
|
|
hasItemView = ui.section == 'items' && ui.item,
|
2014-02-13 08:50:48 +00:00
|
|
|
hasListSelection = ui.section == 'items' && !ui.item && ui.listSelection.length,
|
2014-01-09 08:06:01 +00:00
|
|
|
isItemView = options.isItemView,
|
2014-01-20 11:13:07 +00:00
|
|
|
listLoaded = false,
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
columns = [
|
|
|
|
{
|
|
|
|
id: 'name',
|
|
|
|
operator: '+',
|
|
|
|
title: Ox._('Name'),
|
|
|
|
visible: true,
|
|
|
|
width: 256
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value) {
|
|
|
|
return value.toUpperCase();
|
|
|
|
},
|
|
|
|
id: 'extension',
|
|
|
|
operator: '+',
|
|
|
|
title: Ox._('Extension'),
|
|
|
|
visible: true,
|
|
|
|
width: 64
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: function(value) {
|
|
|
|
return Ox.isArray(value)
|
|
|
|
? Ox.formatDimensions(value, 'px')
|
|
|
|
: Ox.formatCount(value, 'page');
|
|
|
|
},
|
|
|
|
id: 'dimensions',
|
|
|
|
operator: '-',
|
|
|
|
title: Ox._('Dimensions'),
|
|
|
|
visible: true,
|
|
|
|
width: 128
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: function(value) {
|
|
|
|
return Ox.formatValue(value, 'B');
|
|
|
|
},
|
|
|
|
id: 'size',
|
|
|
|
operator: '-',
|
|
|
|
title: Ox._('Size'),
|
|
|
|
visible: true,
|
|
|
|
width: 64
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'description',
|
|
|
|
operator: '+',
|
|
|
|
title: Ox._('Description'),
|
|
|
|
visible: true,
|
|
|
|
width: 256
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
id: 'matches',
|
|
|
|
operator: '-',
|
|
|
|
title: Ox._('Matches'),
|
|
|
|
visible: true,
|
|
|
|
width: 64
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'user',
|
|
|
|
operator: '+',
|
|
|
|
title: Ox._('User'),
|
|
|
|
visible: true,
|
|
|
|
width: 128
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: function(value) {
|
|
|
|
return Ox.formatDate(value, '%F %T');
|
|
|
|
},
|
|
|
|
id: 'created',
|
|
|
|
operator: '-',
|
|
|
|
title: Ox._('Created'),
|
|
|
|
visible: true,
|
|
|
|
width: 144
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: function(value) {
|
|
|
|
return Ox.formatDate(value, '%F %T');
|
|
|
|
},
|
|
|
|
id: 'modified',
|
|
|
|
operator: '-',
|
|
|
|
title: Ox._('Modified'),
|
|
|
|
visible: true,
|
|
|
|
width: 144
|
|
|
|
}
|
|
|
|
],
|
|
|
|
|
2014-01-07 11:38:19 +00:00
|
|
|
$listBar = Ox.Bar({size: 24}),
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
$viewSelect = Ox.Select({
|
|
|
|
items: [
|
2014-01-07 11:38:19 +00:00
|
|
|
{id: 'list', title: Ox._('View as List')},
|
|
|
|
{id: 'grid', title: Ox._('View as Grid')}
|
2014-01-07 08:24:00 +00:00
|
|
|
],
|
2014-01-07 11:38:19 +00:00
|
|
|
value: ui.documentsView,
|
|
|
|
width: 128
|
2014-01-07 08:24:00 +00:00
|
|
|
})
|
2014-01-16 05:37:06 +00:00
|
|
|
.css({float: 'left', margin: '4px 2px 4px 4px'})
|
2014-01-07 08:24:00 +00:00
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
2014-01-07 11:38:19 +00:00
|
|
|
pandora.UI.set({documentsView: data.value});
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
})
|
2014-01-07 11:38:19 +00:00
|
|
|
.appendTo($listBar),
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
$sortSelect = Ox.Select({
|
|
|
|
items: columns.map(function(column) {
|
|
|
|
return {
|
|
|
|
id: column.id,
|
2014-02-13 15:32:14 +00:00
|
|
|
title: Ox._('Sort by {0}', [column.title])
|
2014-01-07 08:24:00 +00:00
|
|
|
};
|
|
|
|
}),
|
2014-01-07 11:38:19 +00:00
|
|
|
value: ui.documentsSort[0].key,
|
|
|
|
width: 128
|
2014-01-07 08:24:00 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
var key = data.value;
|
|
|
|
pandora.UI.set({documentsSort: [{
|
2014-01-07 08:37:03 +00:00
|
|
|
key: key,
|
2014-01-07 08:24:00 +00:00
|
|
|
operator: Ox.getObjectById(columns, key).operator
|
|
|
|
}]});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$orderButton = Ox.Button({
|
|
|
|
overlap: 'left',
|
|
|
|
title: getOrderButtonTitle(),
|
|
|
|
tooltip: getOrderButtonTooltip(),
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
pandora.UI.set({documentsSort: [{
|
|
|
|
key: ui.documentsSort[0].key,
|
|
|
|
operator: ui.documentsSort[0].operator == '+' ? '-' : '+'
|
|
|
|
}]});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$sortElement = Ox.FormElementGroup({
|
|
|
|
elements: [$sortSelect, $orderButton],
|
|
|
|
float: 'right'
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px 2px'})
|
2014-01-07 11:38:19 +00:00
|
|
|
.appendTo($listBar),
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
$findSelect = Ox.Select({
|
|
|
|
items: isItemView ? [
|
|
|
|
{id: 'all', title: Ox._('Find: All')},
|
|
|
|
{id: 'name', title: Ox._('Find: Name')}
|
|
|
|
] : [
|
|
|
|
{id: 'all', title: Ox._('Find: All')},
|
|
|
|
{id: 'name', title: Ox._('Find: Name')},
|
|
|
|
{id: 'user', title: Ox._('Find: User')}
|
|
|
|
],
|
|
|
|
overlap: 'right',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
2014-01-07 12:40:33 +00:00
|
|
|
$findInput.options({placeholder: data.title}).focusInput();
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$findInput = Ox.Input({
|
|
|
|
changeOnKeypress: true,
|
|
|
|
clear: true,
|
|
|
|
placeholder: Ox._('Find: All'),
|
|
|
|
width: 192
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: updateList
|
|
|
|
}),
|
|
|
|
|
|
|
|
$findElement = Ox.FormElementGroup({
|
|
|
|
elements: [
|
|
|
|
$findSelect,
|
|
|
|
$findInput
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.css({float: 'right', margin: '4px 4px 4px 2px'})
|
2014-01-07 11:38:19 +00:00
|
|
|
.appendTo($listBar),
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
$list = renderList(),
|
|
|
|
|
2014-01-07 11:38:19 +00:00
|
|
|
$listStatusbar = Ox.Bar({size: 16}).css({textAlign: 'center'}),
|
2014-01-07 08:24:00 +00:00
|
|
|
|
2014-01-07 11:38:19 +00:00
|
|
|
$listStatus = Ox.Element()
|
2014-01-07 08:24:00 +00:00
|
|
|
.css({
|
|
|
|
margin: '2px 4px',
|
|
|
|
fontSize: '9px',
|
|
|
|
overflow: 'hidden',
|
|
|
|
textOverflow: 'ellipsis'
|
|
|
|
})
|
|
|
|
.html(Ox._('Loading...'))
|
2014-01-07 11:38:19 +00:00
|
|
|
.appendTo($listStatusbar),
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
$listPanel = Ox.SplitPanel({
|
|
|
|
elements: [
|
2014-01-07 11:38:19 +00:00
|
|
|
{element: $listBar, size: 24},
|
2014-01-07 08:24:00 +00:00
|
|
|
{element: $list},
|
2014-01-07 11:38:19 +00:00
|
|
|
{element: $listStatusbar, size: 16}
|
2014-01-07 08:24:00 +00:00
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
2014-01-07 11:38:19 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: function() {
|
|
|
|
$list.size();
|
|
|
|
},
|
2014-01-07 08:24:00 +00:00
|
|
|
}),
|
|
|
|
|
2014-01-07 11:38:19 +00:00
|
|
|
$itemBar = Ox.Bar({size: 24}),
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
$itemMenu = Ox.MenuButton({
|
|
|
|
items: isItemView ? [
|
2014-02-15 14:39:46 +00:00
|
|
|
{
|
|
|
|
id: 'add',
|
|
|
|
disabled: !pandora.site.capabilities.canManageDocuments[pandora.user.level],
|
|
|
|
title: Ox._('Add Documents to {0}...', [pandora.site.itemName.singular]),
|
|
|
|
keyboard: 'control n'
|
|
|
|
},
|
2014-01-16 04:50:44 +00:00
|
|
|
{},
|
2014-01-07 11:38:19 +00:00
|
|
|
{id: 'open', title: '', keyboard: 'return'},
|
2014-01-07 08:24:00 +00:00
|
|
|
{id: 'edit', title: ''},
|
2014-02-04 05:53:28 +00:00
|
|
|
{id: 'embed', title: Ox._('Embed Document...')},
|
2014-01-16 02:44:39 +00:00
|
|
|
{},
|
2014-01-07 12:40:33 +00:00
|
|
|
{id: 'remove', title: '', keyboard: 'delete'}
|
2014-01-07 08:24:00 +00:00
|
|
|
] : [
|
2014-02-14 15:23:59 +00:00
|
|
|
{id: 'upload', title: Ox._('Upload {0}...', [Ox._('Documents')]), file: {width: 192}},
|
2014-01-16 04:50:44 +00:00
|
|
|
{},
|
2014-01-07 11:38:19 +00:00
|
|
|
{id: 'open', title: '', keyboard: 'return'},
|
2014-01-16 02:44:39 +00:00
|
|
|
{id: 'add', title: ''},
|
2014-02-04 05:53:28 +00:00
|
|
|
{id: 'embed', title: Ox._('Embed Document...')},
|
2014-01-16 02:44:39 +00:00
|
|
|
{},
|
2014-02-14 15:23:59 +00:00
|
|
|
{id: 'replace', title: Ox._('Replace {0}...', [Ox._('Document')])},
|
2014-01-07 08:24:00 +00:00
|
|
|
{id: 'delete', title: '', keyboard: 'delete'}
|
|
|
|
],
|
|
|
|
title: 'set',
|
2014-01-18 01:20:31 +00:00
|
|
|
tooltip: Ox._('Options'),
|
2014-01-07 11:38:19 +00:00
|
|
|
type: 'image'
|
2014-01-07 08:24:00 +00:00
|
|
|
})
|
2014-01-07 11:38:19 +00:00
|
|
|
.css({float: 'left', margin: '4px'})
|
2014-01-07 08:24:00 +00:00
|
|
|
.bindEvent({
|
2014-01-07 14:29:12 +00:00
|
|
|
click: function(data) {
|
2014-01-16 02:44:39 +00:00
|
|
|
if (data.id == 'add') {
|
2014-01-16 04:50:44 +00:00
|
|
|
isItemView ? openDocumentsDialog() : addDocuments();
|
2014-02-04 05:53:28 +00:00
|
|
|
} else if (data.id == 'delete') {
|
|
|
|
deleteDocuments();
|
2014-01-07 14:29:12 +00:00
|
|
|
} else if (data.id == 'edit') {
|
|
|
|
editDocuments();
|
2014-02-04 05:53:28 +00:00
|
|
|
} else if (data.id == 'embed') {
|
|
|
|
openEmbedDialog();
|
|
|
|
} else if (data.id == 'open') {
|
|
|
|
openDocuments();
|
2014-01-07 14:29:12 +00:00
|
|
|
} else if (data.id == 'remove') {
|
|
|
|
removeDocuments();
|
2014-02-04 05:53:28 +00:00
|
|
|
} else if (data.id == 'replace') {
|
|
|
|
replaceDocument(data.files);
|
|
|
|
} else if (data.id == 'upload') {
|
|
|
|
uploadDocuments(data);
|
2014-01-07 14:29:12 +00:00
|
|
|
}
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
})
|
2014-01-07 11:38:19 +00:00
|
|
|
.appendTo($itemBar),
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
$deselectButton = Ox.Button({
|
|
|
|
title: 'close',
|
|
|
|
tooltip: Ox._('Done'),
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'right', margin: '4px 4px 4px 2px'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
pandora.UI.set(
|
|
|
|
'documentsSelection.' + (isItemView ? ui.item : ''),
|
|
|
|
[]
|
2014-01-07 11:38:19 +00:00
|
|
|
);
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
})
|
2014-02-03 04:01:25 +00:00
|
|
|
.hide()
|
2014-01-07 11:38:19 +00:00
|
|
|
.appendTo($itemBar),
|
|
|
|
|
|
|
|
$selectButton = Ox.ButtonGroup({
|
|
|
|
buttons: [
|
2014-02-13 13:57:36 +00:00
|
|
|
{id: 'previous', title: 'left', tooltip: Ox._('Previous')},
|
|
|
|
{id: 'next', title: 'right', tooltip: Ox._('Next')}
|
2014-01-07 11:38:19 +00:00
|
|
|
],
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'right', margin: '4px 2px'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(data) {
|
2014-02-04 05:53:28 +00:00
|
|
|
$list.selectSelected(data.id == 'previous' ? -1 : 1);
|
2014-01-07 11:38:19 +00:00
|
|
|
}
|
|
|
|
})
|
2014-02-03 04:01:25 +00:00
|
|
|
.hide()
|
2014-01-07 11:38:19 +00:00
|
|
|
.appendTo($itemBar),
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
$item = Ox.Element().css({overflowY: 'scroll'}),
|
|
|
|
|
|
|
|
$preview,
|
|
|
|
|
2014-01-16 14:12:51 +00:00
|
|
|
$data,
|
2014-01-07 08:24:00 +00:00
|
|
|
|
2014-01-07 11:38:19 +00:00
|
|
|
$itemStatusbar = Ox.Bar({size: 16})
|
|
|
|
.css({textAlign: 'center'}),
|
|
|
|
|
|
|
|
$itemStatus = Ox.Element()
|
|
|
|
.css({
|
|
|
|
margin: '2px 4px',
|
|
|
|
fontSize: '9px',
|
|
|
|
overflow: 'hidden',
|
|
|
|
textOverflow: 'ellipsis'
|
|
|
|
})
|
|
|
|
.appendTo($itemStatusbar),
|
|
|
|
|
2014-01-07 08:24:00 +00:00
|
|
|
$itemPanel = Ox.SplitPanel({
|
|
|
|
elements: [
|
2014-01-07 11:38:19 +00:00
|
|
|
{element: $itemBar, size: 24},
|
|
|
|
{element: $item},
|
|
|
|
{element: $itemStatusbar, size: 16}
|
2014-01-07 08:24:00 +00:00
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: function(data) {
|
2014-01-07 11:38:19 +00:00
|
|
|
ui.documentSize = data.size;
|
2014-01-16 02:22:59 +00:00
|
|
|
resizeItem();
|
2014-01-07 08:24:00 +00:00
|
|
|
},
|
|
|
|
resizeend: function(data) {
|
|
|
|
// set to 0 so that UI.set registers a change of the value
|
|
|
|
ui.documentSize = 0;
|
|
|
|
pandora.UI.set({documentSize: data.size});
|
|
|
|
},
|
2014-01-07 14:29:12 +00:00
|
|
|
toggle: function(data) {
|
2014-01-07 08:24:00 +00:00
|
|
|
pandora.UI.set({showDocument: !data.collapsed});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
that = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: $listPanel
|
|
|
|
},
|
|
|
|
{
|
|
|
|
collapsible: isItemView,
|
2014-01-07 14:29:12 +00:00
|
|
|
collapsed: isItemView && !ui.showDocument,
|
2014-01-07 08:24:00 +00:00
|
|
|
element: $itemPanel,
|
2014-01-07 08:37:03 +00:00
|
|
|
size: ui.documentSize,
|
2014-01-07 11:38:19 +00:00
|
|
|
resizable: true,
|
2014-01-07 14:29:12 +00:00
|
|
|
resize: [192, 256, 320, 384],
|
|
|
|
tooltip: 'document <span class="OxBright">'
|
|
|
|
+ Ox.SYMBOLS.SHIFT + 'D</span>'
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2014-01-16 03:06:48 +00:00
|
|
|
pandora_documentsize: function(data) {
|
|
|
|
that.size(1, data.value);
|
|
|
|
},
|
2014-01-07 08:24:00 +00:00
|
|
|
pandora_documentssort: function(data) {
|
|
|
|
updateSortElement();
|
|
|
|
$list.options({sort: data.value});
|
2014-01-07 11:38:19 +00:00
|
|
|
},
|
|
|
|
pandora_documentsview: function(data) {
|
|
|
|
$listPanel.replaceElement(1, $list = renderList());
|
2014-01-07 14:29:12 +00:00
|
|
|
},
|
|
|
|
pandora_showdocument: function(data) {
|
2014-09-23 21:56:11 +00:00
|
|
|
isItemView && that.toggleElement(1);
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-02-02 13:40:01 +00:00
|
|
|
if (isItemView) {
|
|
|
|
pandora.$ui.documentsList = $list;
|
|
|
|
}
|
|
|
|
|
2014-02-17 11:44:16 +00:00
|
|
|
// to determine the width of the find input inside
|
|
|
|
// the documents dialog, that dialog has to be present
|
|
|
|
setTimeout(function() {
|
|
|
|
$findInput.options({width: getFindInputWidth()});
|
|
|
|
});
|
|
|
|
|
2014-01-07 08:24:00 +00:00
|
|
|
that.bindEvent(
|
2014-01-07 11:38:19 +00:00
|
|
|
'pandora_documentsselection.' + (isItemView ? ui.item.toLowerCase() : ''),
|
2014-01-07 08:24:00 +00:00
|
|
|
selectDocuments
|
2014-01-07 08:37:03 +00:00
|
|
|
);
|
2014-01-07 08:24:00 +00:00
|
|
|
|
|
|
|
function addDocuments() {
|
2014-01-18 01:20:31 +00:00
|
|
|
var ids = ui.documentsSelection[''];
|
2014-01-09 08:06:01 +00:00
|
|
|
pandora.api.addDocument({
|
2014-02-13 08:50:48 +00:00
|
|
|
item: hasItemView ? ui.item : ui.listSelection,
|
2014-01-18 01:20:31 +00:00
|
|
|
ids: ids
|
2014-01-09 08:06:01 +00:00
|
|
|
}, function() {
|
|
|
|
Ox.Request.clearCache();
|
2014-02-13 08:50:48 +00:00
|
|
|
if (ui.item && ui.itemView == 'documents') {
|
2014-01-18 01:20:31 +00:00
|
|
|
// FIXME: $list.reloadList() would be much better
|
2014-01-09 08:06:01 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2014-01-17 13:49:11 +00:00
|
|
|
pandora.$ui.item = pandora.ui.item()
|
|
|
|
);
|
2014-01-18 01:20:31 +00:00
|
|
|
// FIXME: there has to be a way to do this without timeout
|
|
|
|
setTimeout(function() {
|
|
|
|
pandora.UI.set('documentsSelection.' + ui.item, ids);
|
|
|
|
}, 1000);
|
2014-01-09 08:06:01 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-01-07 12:40:33 +00:00
|
|
|
function closeDocuments() {
|
|
|
|
if (pandora.$ui.documentDialog) {
|
|
|
|
pandora.$ui.documentDialog.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-07 08:24:00 +00:00
|
|
|
function deleteDocuments() {
|
2014-01-16 02:57:15 +00:00
|
|
|
pandora.ui.deleteDocumentDialog(
|
|
|
|
$list.options('selected').map(function(id) {
|
|
|
|
return $list.value(id);
|
|
|
|
}),
|
|
|
|
function() {
|
|
|
|
Ox.Request.clearCache();
|
|
|
|
// ...
|
|
|
|
$list.reloadList();
|
|
|
|
}
|
|
|
|
).open();
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
|
2014-01-07 11:38:19 +00:00
|
|
|
function editDocuments() {
|
2014-01-08 08:35:02 +00:00
|
|
|
pandora.UI.set('documentsSelection.', $list.options('selected'));
|
2014-01-16 03:56:20 +00:00
|
|
|
openDocumentsDialog();
|
2014-01-07 11:38:19 +00:00
|
|
|
}
|
|
|
|
|
2014-01-07 08:24:00 +00:00
|
|
|
function getOrderButtonTitle() {
|
|
|
|
return ui.documentsSort[0].operator == '+' ? 'up' : 'down';
|
|
|
|
}
|
|
|
|
|
|
|
|
function getOrderButtonTooltip() {
|
2014-01-07 12:40:33 +00:00
|
|
|
return Ox._(ui.documentsSort[0].operator == '+' ? 'Ascending' : 'Descending');
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
|
2014-02-17 11:44:16 +00:00
|
|
|
function getFindInputWidth() {
|
|
|
|
// 2 * 128px selects + 2 * 16px buttons + 4 * 4px margins = 304px
|
|
|
|
return Math.min(192, (
|
|
|
|
isItemView
|
|
|
|
? window.innerWidth - (ui.showSidebar * ui.sidebarSize) - 1
|
|
|
|
- (ui.showDocument * ui.documentSize)
|
|
|
|
: pandora.$ui.documentsDialog.options('width')
|
|
|
|
- ui.documentSize - 1
|
|
|
|
) - 304);
|
|
|
|
}
|
|
|
|
|
2014-01-07 08:24:00 +00:00
|
|
|
function getPreviewSize() {
|
2014-01-07 11:38:19 +00:00
|
|
|
var ratio = $list.value($list.options('selected')[0], 'ratio'),
|
2014-01-07 08:24:00 +00:00
|
|
|
size = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE,
|
|
|
|
height = ratio > 1 ? size / ratio : size,
|
|
|
|
width = ratio > 1 ? size : size * ratio,
|
|
|
|
left = Math.floor((size - width) / 2);
|
|
|
|
return {
|
|
|
|
height: height,
|
|
|
|
// fixme: CSS gets applied twice, to image and enclosing element
|
|
|
|
margin: [8, 8, 8, 8 + left].map(function(px) {
|
|
|
|
return Math.round(px / 2) + 'px';
|
|
|
|
}).join(' '),
|
|
|
|
width: width
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-01-07 12:40:33 +00:00
|
|
|
function openDocuments() {
|
2014-01-20 11:13:07 +00:00
|
|
|
pandora.openDocumentDialog({
|
|
|
|
documents: $list.options('selected').map(function(id) {
|
|
|
|
return $list.value(id);
|
|
|
|
})
|
|
|
|
}).bindEvent({
|
|
|
|
close: function() {
|
|
|
|
$list.closePreview();
|
|
|
|
}
|
|
|
|
});
|
2014-01-07 12:40:33 +00:00
|
|
|
}
|
|
|
|
|
2014-01-16 03:56:20 +00:00
|
|
|
function openDocumentsDialog() {
|
|
|
|
pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open();
|
|
|
|
}
|
|
|
|
|
2014-02-04 05:53:28 +00:00
|
|
|
function openEmbedDialog() {
|
|
|
|
pandora.$ui.embedDocumentDialog = pandora.ui.embedDocumentDialog(
|
|
|
|
ui.documentsSelection[isItemView ? ui.item : ''][0]
|
|
|
|
).open();
|
|
|
|
}
|
|
|
|
|
2014-01-09 08:06:01 +00:00
|
|
|
function replaceDocument(file) {
|
|
|
|
var id = $list.options('selected')[0];
|
|
|
|
}
|
|
|
|
|
2014-01-07 08:24:00 +00:00
|
|
|
function removeDocuments() {
|
|
|
|
pandora.api.removeDocument({
|
|
|
|
item: ui.item,
|
|
|
|
ids: $list.options('selected')
|
|
|
|
}, function() {
|
|
|
|
Ox.Request.clearCache();
|
|
|
|
// ...
|
|
|
|
$list.reloadList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-01-16 14:12:51 +00:00
|
|
|
function renderData() {
|
2014-01-18 00:43:50 +00:00
|
|
|
var $name, $description,
|
2014-01-16 14:12:51 +00:00
|
|
|
item = $list.value($list.options('selected')[0]),
|
2014-01-07 08:24:00 +00:00
|
|
|
editable = item.user == pandora.user.username
|
2014-04-17 19:32:30 +00:00
|
|
|
|| pandora.site.capabilities.canEditDocuments[pandora.user.level]
|
|
|
|
|| options.editable,
|
2014-01-16 14:12:51 +00:00
|
|
|
labelWidth = 80,
|
|
|
|
width = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE;
|
|
|
|
return isItemView
|
|
|
|
? Ox.Element()
|
2014-01-18 00:43:50 +00:00
|
|
|
.css({textAlign: 'center'})
|
2014-01-16 14:12:51 +00:00
|
|
|
.append(
|
2014-01-18 00:43:50 +00:00
|
|
|
Ox.$('<div>').css({height: '8px'})
|
2014-01-16 14:12:51 +00:00
|
|
|
)
|
|
|
|
.append(
|
2014-01-18 00:43:50 +00:00
|
|
|
$name = Ox.EditableContent({
|
|
|
|
editable: editable,
|
2014-01-18 00:50:02 +00:00
|
|
|
tooltip: editable ? pandora.getEditTooltip('name') : '',
|
2014-01-16 14:12:51 +00:00
|
|
|
value: item.name,
|
|
|
|
width: width
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
textAlign: 'center',
|
|
|
|
fontWeight: 'bold'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
edit: function() {
|
2014-01-18 00:43:50 +00:00
|
|
|
$name.options({
|
2014-01-16 14:12:51 +00:00
|
|
|
width: that.width()
|
|
|
|
});
|
|
|
|
},
|
2014-01-18 00:43:50 +00:00
|
|
|
submit: function(data) {
|
|
|
|
pandora.api.editDocument({
|
|
|
|
name: data.value,
|
|
|
|
id: item.id,
|
|
|
|
item: ui.item,
|
|
|
|
}, function(result) {
|
|
|
|
$name.options({value: result.data.name});
|
|
|
|
Ox.Request.clearCache('findDocuments');
|
|
|
|
$list.reloadList();
|
|
|
|
});
|
2014-01-16 14:12:51 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.append(
|
|
|
|
Ox.$('<div>').css({height: '8px'})
|
|
|
|
)
|
|
|
|
.append(
|
|
|
|
$description = Ox.EditableContent({
|
2014-03-01 09:13:41 +00:00
|
|
|
clickLink: pandora.clickLink,
|
2014-01-18 00:43:50 +00:00
|
|
|
editable: editable,
|
2014-01-16 14:12:51 +00:00
|
|
|
format: function(value) {
|
|
|
|
return '<div class="OxLight" style="text-align: center">'
|
|
|
|
+ value + '</div>';
|
|
|
|
},
|
|
|
|
height: width,
|
2014-02-13 16:24:52 +00:00
|
|
|
placeholder: Ox._('No description'),
|
2014-01-18 00:50:02 +00:00
|
|
|
tooltip: editable ? pandora.getEditTooltip('description') : '',
|
2014-01-16 14:12:51 +00:00
|
|
|
type: 'textarea',
|
|
|
|
value: item.description || '',
|
|
|
|
width: width
|
|
|
|
})
|
|
|
|
.css({
|
2014-01-18 00:43:50 +00:00
|
|
|
margin: '0 8px',
|
2014-01-16 14:12:51 +00:00
|
|
|
textAlign: 'center'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(data) {
|
|
|
|
pandora.api.editDocument({
|
|
|
|
description: data.value,
|
|
|
|
id: item.id,
|
|
|
|
item: ui.item,
|
|
|
|
}, function(result) {
|
|
|
|
$description.options({value: result.data.description});
|
|
|
|
Ox.Request.clearCache('findDocuments');
|
|
|
|
$list.reloadList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
: Ox.Form({
|
|
|
|
items: [
|
|
|
|
Ox.Input({
|
|
|
|
disabled: !editable,
|
|
|
|
id: 'name',
|
|
|
|
label: Ox._('Name'),
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
value: item.name,
|
|
|
|
width: width
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'extension',
|
|
|
|
label: Ox._('Extension'),
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
value: item.extension,
|
|
|
|
width: width
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'dimensions',
|
|
|
|
label: Ox._('Dimensions'),
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
value: Ox.isArray(item.dimensions)
|
|
|
|
? Ox.formatDimensions(item.dimensions, 'px')
|
|
|
|
: Ox.formatCount(item.dimensions, 'page'),
|
|
|
|
width: width
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'size',
|
|
|
|
label: Ox._('Size'),
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
value: Ox.formatValue(item.size, 'B'),
|
|
|
|
width: width
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'matches',
|
|
|
|
label: Ox._('Matches'),
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
value: item.matches,
|
|
|
|
width: width
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'username',
|
|
|
|
label: Ox._('Username'),
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
value: item.user,
|
|
|
|
width: width
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
disabled: !editable,
|
|
|
|
height: 256,
|
|
|
|
id: 'description',
|
|
|
|
placeholder: Ox._('Description'),
|
|
|
|
type: 'textarea',
|
|
|
|
value: item.description,
|
|
|
|
width: width
|
|
|
|
})
|
|
|
|
],
|
|
|
|
width: 240
|
|
|
|
})
|
|
|
|
.css({margin: '12px 8px 8px 8px'})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(event) {
|
|
|
|
var data = Ox.extend({id: item.id}, event.id, event.data.value);
|
|
|
|
if (isItemView) {
|
|
|
|
data.item = ui.item;
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
2014-01-16 14:12:51 +00:00
|
|
|
pandora.api.editDocument(data, function(result) {
|
|
|
|
$list.value(result.data.id, event.id, result.data[event.id]);
|
|
|
|
if (event.id == 'name') {
|
|
|
|
$list.value(item.id, 'id', result.data.id);
|
|
|
|
}
|
|
|
|
Ox.Request.clearCache('findDocuments');
|
|
|
|
$list.reloadList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderList() {
|
|
|
|
var options = {
|
|
|
|
items: pandora.api.findDocuments,
|
2014-04-17 19:19:08 +00:00
|
|
|
keys: ['description', 'dimensions', 'extension', 'id', 'name', 'ratio', 'size', 'user'],
|
2014-01-07 15:54:20 +00:00
|
|
|
query: {
|
2014-01-08 04:32:57 +00:00
|
|
|
conditions: isItemView ? [{ key: 'item', value: ui.item, operator: '==' }] : [],
|
2014-01-07 15:54:20 +00:00
|
|
|
operator: '&'
|
|
|
|
},
|
2014-01-08 08:35:02 +00:00
|
|
|
selected: ui.documentsSelection[isItemView ? ui.item : ''] || [],
|
2014-01-07 08:24:00 +00:00
|
|
|
sort: ui.documentsSort.concat([
|
|
|
|
{key: 'extension', operator: '+'},
|
2014-01-07 11:38:19 +00:00
|
|
|
{key: 'name', operator: '+'}
|
2014-01-07 08:24:00 +00:00
|
|
|
]),
|
|
|
|
unique: 'id'
|
|
|
|
};
|
|
|
|
return (ui.documentsView == 'list' ? Ox.TableList(Ox.extend(options, {
|
|
|
|
columns: columns,
|
|
|
|
columnsVisible: true,
|
|
|
|
scrollbarVisible: true,
|
|
|
|
})) : Ox.IconList(Ox.extend(options, {
|
|
|
|
item: function(data, sort, size) {
|
|
|
|
var sortKey = sort[0].key,
|
|
|
|
infoKey = sortKey == 'name' ? 'extension' : sortKey,
|
|
|
|
info = (
|
|
|
|
Ox.getObjectById(columns, infoKey).format || Ox.identity
|
|
|
|
)(data[infoKey]),
|
|
|
|
size = size || 128;
|
|
|
|
return {
|
2014-01-07 11:38:19 +00:00
|
|
|
height: Math.round(data.ratio > 1 ? size / data.ratio : size),
|
2014-01-07 08:24:00 +00:00
|
|
|
id: data.id,
|
|
|
|
info: info,
|
|
|
|
title: data.name,
|
|
|
|
url: '/documents/' + data.id + '/256p.jpg',
|
2014-01-07 11:38:19 +00:00
|
|
|
width: Math.round(data.ratio > 1 ? size : size * data.ratio)
|
2014-01-07 08:24:00 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
size: 128
|
|
|
|
})))
|
|
|
|
.bindEvent({
|
2014-01-16 03:56:20 +00:00
|
|
|
add: function() {
|
|
|
|
// we can't open upload dialog via control+n
|
|
|
|
isItemView && openDocumentsDialog();
|
|
|
|
},
|
2014-01-07 12:40:33 +00:00
|
|
|
closepreview: closeDocuments,
|
2014-01-18 01:20:31 +00:00
|
|
|
'delete': isItemView ? removeDocuments : deleteDocuments,
|
2014-01-07 08:24:00 +00:00
|
|
|
init: function(data) {
|
2014-01-07 11:38:19 +00:00
|
|
|
$listStatus.html(
|
2014-01-07 08:24:00 +00:00
|
|
|
Ox.toTitleCase(Ox.formatCount(data.items, 'document'))
|
2014-01-18 02:01:26 +00:00
|
|
|
+ (isItemView ? '' : ', ' + Ox.formatValue(data.size, 'B'))
|
2014-01-07 08:24:00 +00:00
|
|
|
);
|
|
|
|
},
|
2014-01-07 14:29:12 +00:00
|
|
|
key_escape: function() {
|
|
|
|
pandora.UI.set({document: ''});
|
|
|
|
},
|
2014-01-07 12:40:33 +00:00
|
|
|
open: openDocuments,
|
|
|
|
openpreview: openDocuments,
|
2014-01-07 11:38:19 +00:00
|
|
|
select: function(data) {
|
2014-01-07 08:24:00 +00:00
|
|
|
pandora.UI.set(
|
|
|
|
'documentsSelection.' + (isItemView ? ui.item : ''),
|
|
|
|
data.ids
|
|
|
|
);
|
|
|
|
},
|
2014-01-07 11:38:19 +00:00
|
|
|
sort: function(data) {
|
|
|
|
pandora.UI.set({documentsSort: [data]});
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
2014-01-07 15:54:20 +00:00
|
|
|
})
|
|
|
|
.bindEventOnce({
|
|
|
|
load: function() {
|
2014-01-20 11:13:07 +00:00
|
|
|
listLoaded = true;
|
2014-01-07 15:54:20 +00:00
|
|
|
selectDocuments();
|
2014-01-18 01:51:24 +00:00
|
|
|
!ui.showBrowser && $list.gainFocus();
|
2014-01-07 15:54:20 +00:00
|
|
|
}
|
2014-01-07 08:24:00 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderPreview() {
|
2014-01-07 11:38:19 +00:00
|
|
|
var selected = $list.options('selected')[0],
|
|
|
|
size = getPreviewSize(),
|
2014-01-07 08:24:00 +00:00
|
|
|
src = '/documents/' + selected + '/256p.jpg';
|
|
|
|
return Ox.ImageElement({
|
|
|
|
height: size.height,
|
|
|
|
src: src,
|
2014-01-18 01:20:31 +00:00
|
|
|
// fixme: this tends to stick around after menu click
|
|
|
|
// (and may not be necessary in the first place)
|
|
|
|
// tooltip: Ox._('Click to open document'),
|
2014-01-07 08:24:00 +00:00
|
|
|
width: size.width
|
|
|
|
})
|
|
|
|
.css({
|
2014-01-07 11:38:19 +00:00
|
|
|
borderRadius: '8px',
|
2014-01-07 08:24:00 +00:00
|
|
|
margin: size.margin,
|
2014-01-07 11:38:19 +00:00
|
|
|
cursor: 'pointer'
|
2014-01-07 08:24:00 +00:00
|
|
|
})
|
|
|
|
.on({
|
2014-01-07 12:40:33 +00:00
|
|
|
click: openDocuments
|
2014-01-07 08:24:00 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-01-16 02:22:59 +00:00
|
|
|
function resizeItem() {
|
2014-01-16 02:29:04 +00:00
|
|
|
var size = getPreviewSize(),
|
|
|
|
width = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE;
|
2014-01-16 04:50:44 +00:00
|
|
|
$preview && $preview.options({
|
2014-01-16 02:29:04 +00:00
|
|
|
height: size.height,
|
|
|
|
width: size.width
|
|
|
|
}).css({
|
|
|
|
margin: size.margin
|
2014-01-16 02:22:59 +00:00
|
|
|
});
|
2014-01-16 14:12:51 +00:00
|
|
|
if (!isItemView && $data) {
|
|
|
|
$data.options('items').forEach(function($item) {
|
|
|
|
$item.options({width: width});
|
|
|
|
});
|
|
|
|
}
|
2014-01-16 02:22:59 +00:00
|
|
|
}
|
|
|
|
|
2014-01-07 08:24:00 +00:00
|
|
|
function selectDocuments() {
|
2014-02-03 04:01:25 +00:00
|
|
|
// FIXME: this looks wrong - will produce inconsistent state
|
2014-01-20 11:13:07 +00:00
|
|
|
if(!listLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
2014-01-07 11:38:19 +00:00
|
|
|
var selected = ui.documentsSelection[isItemView ? ui.item : ''] || [],
|
2014-02-14 15:23:59 +00:00
|
|
|
string = Ox._(selected.length < 2 ? 'Document' : 'Documents');
|
2014-01-07 11:38:19 +00:00
|
|
|
$list.options({selected: selected});
|
2014-02-14 15:23:59 +00:00
|
|
|
$itemMenu.setItemTitle('open', Ox._('Open {0}', [string]))
|
2014-02-03 04:03:25 +00:00
|
|
|
[selected.length ? 'enableItem' : 'disableItem']('open');
|
2014-01-07 08:24:00 +00:00
|
|
|
if (isItemView) {
|
2014-02-14 15:23:59 +00:00
|
|
|
$itemMenu.setItemTitle('edit', Ox._('Edit {0}...', [string]))
|
2014-02-03 04:01:25 +00:00
|
|
|
.setItemTitle('remove', Ox._(
|
2014-02-14 15:23:59 +00:00
|
|
|
'Remove {0} from {1}',
|
|
|
|
[string, Ox._(pandora.site.itemName.singular)]
|
2014-02-03 04:01:25 +00:00
|
|
|
))
|
2014-02-03 04:03:25 +00:00
|
|
|
[selected.length ? 'enableItem' : 'disableItem']('edit')
|
2014-02-04 05:53:28 +00:00
|
|
|
[selected.length ? 'enableItem' : 'disableItem']('embed')
|
2014-02-03 04:03:25 +00:00
|
|
|
[selected.length ? 'enableItem' : 'disableItem']('remove');
|
2014-01-07 08:24:00 +00:00
|
|
|
} else {
|
2014-02-14 15:23:59 +00:00
|
|
|
$itemMenu.setItemTitle('add', Ox._('Add {0} to {1} {2}', [
|
2014-02-18 08:28:57 +00:00
|
|
|
string,
|
2014-02-14 15:23:59 +00:00
|
|
|
Ox._(hasListSelection ? 'Selected' : 'Current'),
|
2014-02-18 08:28:57 +00:00
|
|
|
Ox._(pandora.site.itemName[
|
|
|
|
hasListSelection && ui.listSelection.length > 1
|
|
|
|
? 'plural' : 'singular'])
|
2014-02-14 15:23:59 +00:00
|
|
|
]))
|
|
|
|
.setItemTitle('replace', Ox._('Replace {0}...', [string]))
|
|
|
|
.setItemTitle('delete', Ox._('Delete {0}...', [string]))
|
2014-02-13 08:50:48 +00:00
|
|
|
[selected.length && (hasItemView || hasListSelection) ? 'enableItem' : 'disableItem']('add')
|
2014-02-04 05:53:28 +00:00
|
|
|
[selected.length ? 'enableItem' : 'disableItem']('embed')
|
2014-02-03 04:01:25 +00:00
|
|
|
[selected.length == 1 ? 'enableItem' : 'disableItem']('replace')
|
2014-02-03 04:03:25 +00:00
|
|
|
[selected.length ? 'enableItem' : 'disableItem']('delete');
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
2014-01-07 11:38:19 +00:00
|
|
|
$selectButton[selected.length > 1 ? 'show' : 'hide']();
|
|
|
|
$deselectButton[selected.length ? 'show' : 'hide']();
|
2014-01-07 08:24:00 +00:00
|
|
|
$item.empty();
|
2014-01-07 11:38:19 +00:00
|
|
|
if (selected.length) {
|
2014-01-07 08:24:00 +00:00
|
|
|
$preview = renderPreview().appendTo($item);
|
2014-01-16 14:12:51 +00:00
|
|
|
$data = renderData().appendTo($item);
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
2014-01-07 14:29:12 +00:00
|
|
|
$itemStatus.html(
|
|
|
|
selected.length
|
|
|
|
? Ox.formatCount(selected.length, 'Document')
|
|
|
|
: Ox._('No document selected')
|
|
|
|
);
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateList() {
|
|
|
|
var key = $findSelect.value(),
|
|
|
|
value = $findInput.value(),
|
2014-01-16 03:56:20 +00:00
|
|
|
itemCondition = isItemView
|
|
|
|
? {key: 'item', operator: '==', value: ui.item}
|
|
|
|
: null,
|
|
|
|
findQuery = {
|
2014-01-07 15:54:20 +00:00
|
|
|
conditions: [].concat(
|
2014-01-16 03:56:20 +00:00
|
|
|
key != 'user'
|
|
|
|
? [{key: 'name', operator: '=', value: value}]
|
|
|
|
: [],
|
|
|
|
key == 'all'
|
|
|
|
? [
|
|
|
|
{key: 'extension', operator: '=', value: value},
|
|
|
|
{key: 'description', operator: '=', value: value}
|
|
|
|
]
|
|
|
|
: [],
|
|
|
|
key != 'name'
|
|
|
|
? [{key: 'user', operator: '=', value: value}]
|
|
|
|
: []
|
2014-01-07 15:54:20 +00:00
|
|
|
),
|
2014-01-16 03:56:20 +00:00
|
|
|
operator: '|'
|
|
|
|
},
|
|
|
|
query = isItemView
|
|
|
|
? {
|
|
|
|
conditions: [itemCondition].concat(findQuery),
|
|
|
|
operator: '&'
|
|
|
|
}
|
|
|
|
: findQuery;
|
2014-01-07 08:24:00 +00:00
|
|
|
$list.options({query: query});
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateSortElement() {
|
|
|
|
$sortSelect.value(ui.documentsSort[0].key);
|
|
|
|
$orderButton.options({
|
|
|
|
title: getOrderButtonTitle(),
|
|
|
|
tooltip: getOrderButtonTooltip()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function uploadDocuments(data) {
|
|
|
|
pandora.ui.uploadDocumentDialog(data.files, function(files) {
|
|
|
|
if (files) {
|
|
|
|
Ox.Request.clearCache('findDocuments');
|
|
|
|
$list.bindEventOnce({
|
|
|
|
load: function() {
|
2014-02-14 13:40:21 +00:00
|
|
|
$list.options({selected: files.ids});
|
2014-01-07 08:24:00 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.reloadList();
|
|
|
|
}
|
|
|
|
}).open();
|
|
|
|
}
|
|
|
|
|
2014-02-13 12:07:28 +00:00
|
|
|
that.selectSelected = function(offset) {
|
|
|
|
$list.selectSelected(offset);
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
2014-02-08 16:34:15 +00:00
|
|
|
that.updateSize = function() {
|
2014-02-17 11:44:16 +00:00
|
|
|
$findInput.options({width: getFindInputWidth()});
|
2014-02-08 16:34:15 +00:00
|
|
|
$list.size();
|
|
|
|
};
|
|
|
|
|
2014-01-07 08:24:00 +00:00
|
|
|
return that;
|
|
|
|
|
2014-02-04 05:53:28 +00:00
|
|
|
};
|