make 'Embed Document...' available in both documents view and documents dialog
This commit is contained in:
parent
6448f1b1f5
commit
42ffdf3358
2 changed files with 32 additions and 52 deletions
|
@ -239,6 +239,7 @@ pandora.ui.documentsPanel = function(options) {
|
|||
{},
|
||||
{id: 'open', title: '', keyboard: 'return'},
|
||||
{id: 'edit', title: ''},
|
||||
{id: 'embed', title: Ox._('Embed Document...')},
|
||||
{},
|
||||
{id: 'remove', title: '', keyboard: 'delete'}
|
||||
] : [
|
||||
|
@ -246,6 +247,7 @@ pandora.ui.documentsPanel = function(options) {
|
|||
{},
|
||||
{id: 'open', title: '', keyboard: 'return'},
|
||||
{id: 'add', title: ''},
|
||||
{id: 'embed', title: Ox._('Embed Document...')},
|
||||
{},
|
||||
{id: 'replace', title: Ox._('Replace Document...')},
|
||||
{id: 'delete', title: '', keyboard: 'delete'}
|
||||
|
@ -259,18 +261,20 @@ pandora.ui.documentsPanel = function(options) {
|
|||
click: function(data) {
|
||||
if (data.id == 'add') {
|
||||
isItemView ? openDocumentsDialog() : addDocuments();
|
||||
} else if (data.id == 'upload') {
|
||||
uploadDocuments(data);
|
||||
} else if (data.id == 'open') {
|
||||
openDocuments();
|
||||
} else if (data.id == 'edit') {
|
||||
editDocuments();
|
||||
} else if (data.id == 'replace') {
|
||||
replaceDocument(data.files);
|
||||
} else if (data.id == 'remove') {
|
||||
removeDocuments();
|
||||
} else if (data.id == 'delete') {
|
||||
deleteDocuments();
|
||||
} else if (data.id == 'edit') {
|
||||
editDocuments();
|
||||
} else if (data.id == 'embed') {
|
||||
openEmbedDialog();
|
||||
} else if (data.id == 'open') {
|
||||
openDocuments();
|
||||
} else if (data.id == 'remove') {
|
||||
removeDocuments();
|
||||
} else if (data.id == 'replace') {
|
||||
replaceDocument(data.files);
|
||||
} else if (data.id == 'upload') {
|
||||
uploadDocuments(data);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -303,18 +307,7 @@ pandora.ui.documentsPanel = function(options) {
|
|||
.css({float: 'right', margin: '4px 2px'})
|
||||
.bindEvent({
|
||||
click: function(data) {
|
||||
var selected = $list.options('selected');
|
||||
if (data.id == 'next') {
|
||||
selected.push(selected.shift());
|
||||
} else {
|
||||
selected.splice(0, 0, selected.pop());
|
||||
}
|
||||
$list.options('selected', selected);
|
||||
$item.empty();
|
||||
if (selected.length) {
|
||||
$preview = renderPreview().appendTo($item);
|
||||
$data = renderData().appendTo($item);
|
||||
}
|
||||
$list.selectSelected(data.id == 'previous' ? -1 : 1);
|
||||
}
|
||||
})
|
||||
.hide()
|
||||
|
@ -448,12 +441,6 @@ pandora.ui.documentsPanel = function(options) {
|
|||
openDocumentsDialog();
|
||||
}
|
||||
|
||||
function getEmbed(item) {
|
||||
return '<a href="/documents/'
|
||||
+ item.id + '"><img src="/documents/'
|
||||
+ item.id + '/256p.jpg"></a>';
|
||||
}
|
||||
|
||||
function getOrderButtonTitle() {
|
||||
return ui.documentsSort[0].operator == '+' ? 'up' : 'down';
|
||||
}
|
||||
|
@ -494,6 +481,12 @@ pandora.ui.documentsPanel = function(options) {
|
|||
pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open();
|
||||
}
|
||||
|
||||
function openEmbedDialog() {
|
||||
pandora.$ui.embedDocumentDialog = pandora.ui.embedDocumentDialog(
|
||||
ui.documentsSelection[isItemView ? ui.item : ''][0]
|
||||
).open();
|
||||
}
|
||||
|
||||
function replaceDocument(file) {
|
||||
var id = $list.options('selected')[0];
|
||||
}
|
||||
|
@ -655,15 +648,6 @@ pandora.ui.documentsPanel = function(options) {
|
|||
type: 'textarea',
|
||||
value: item.description,
|
||||
width: width
|
||||
}),
|
||||
Ox.Input({
|
||||
disabled: true,
|
||||
height: 36,
|
||||
id: 'embed',
|
||||
placeholder: Ox._('HTML Embed'),
|
||||
type: 'textarea',
|
||||
value: getEmbed(item),
|
||||
width: width
|
||||
})
|
||||
],
|
||||
width: 240
|
||||
|
@ -817,6 +801,7 @@ pandora.ui.documentsPanel = function(options) {
|
|||
+ pandora.site.itemName.singular
|
||||
))
|
||||
[selected.length ? 'enableItem' : 'disableItem']('edit')
|
||||
[selected.length ? 'enableItem' : 'disableItem']('embed')
|
||||
[selected.length ? 'enableItem' : 'disableItem']('remove');
|
||||
} else {
|
||||
$itemMenu.setItemTitle('add', Ox._(
|
||||
|
@ -826,6 +811,7 @@ pandora.ui.documentsPanel = function(options) {
|
|||
.setItemTitle('replace', Ox._('Replace ' + string + '...'))
|
||||
.setItemTitle('delete', Ox._('Delete ' + string + '...'))
|
||||
[selected.length ? 'enableItem' : 'disableItem']('add')
|
||||
[selected.length ? 'enableItem' : 'disableItem']('embed')
|
||||
[selected.length == 1 ? 'enableItem' : 'disableItem']('replace')
|
||||
[selected.length ? 'enableItem' : 'disableItem']('delete');
|
||||
}
|
||||
|
@ -899,4 +885,4 @@ pandora.ui.documentsPanel = function(options) {
|
|||
|
||||
return that;
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3,26 +3,20 @@
|
|||
|
||||
pandora.ui.embedDocumentDialog = function(id) {
|
||||
|
||||
var isImage = Ox.contains(['jpg', 'png'], selected.split('.').pop()),
|
||||
url = 'http' + (pandora.site.site.https ? 's' : '') + '://'
|
||||
+ pandora.site.site.url + '/documents/' + id,
|
||||
|
||||
$content = Ox.Element()
|
||||
var $content = Ox.Element()
|
||||
.css({margin: '16px'})
|
||||
.html(
|
||||
Ox._('To embed this file, use the following HTML:<br>')
|
||||
),
|
||||
.html(Ox._('To embed this document, use the following HTML:')),
|
||||
|
||||
$embed = $('<textarea>')
|
||||
.css({
|
||||
width: '336px',
|
||||
width: '322px',
|
||||
height: '64px',
|
||||
marginTop: '8px',
|
||||
marginTop: '8px'
|
||||
})
|
||||
.val(
|
||||
isImage
|
||||
? '<img src="' + url + '">'
|
||||
: '<a href="' + url + '"><img src="' + url + '.jpg"></a>'
|
||||
'<a href="/documents/'
|
||||
+ id + '"><img src="/documents/'
|
||||
+ id + '/256p.jpg"></a>'
|
||||
)
|
||||
.on({
|
||||
click: function() {
|
||||
|
@ -49,7 +43,7 @@ pandora.ui.embedDocumentDialog = function(id) {
|
|||
height: 128,
|
||||
keys: {escape: 'close'},
|
||||
removeOnClose: true,
|
||||
title: Ox._('Embed File'),
|
||||
title: Ox._('Embed Document'),
|
||||
width: 368
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue