var dialog = Dialog.create({
title: gettext('Document Metadata'),
executeButtonText: gettext('Close'),
- cssClass: 'metadataEditor'
+ cssClass: 'metadataEditor',
+ closeButton: false
}),
view = new View(params.doc.root, ctx.config);
dialog.show();
dialog.setContentView(view.dom);
dialog.on('execute', function(e) {
+ var cover_url = view.getMetadataByKey('relation.coverimage.url');
+ if (cover_url && !cover_url.match(/\.(png|jpg|jpeg|gif|tif|tiff)$/i)) {
+ window.alert(gettext('The cover needs to be an image file: jpg, png, gif. Use another URL or clear the cover field.'));
+ return;
+ }
e.success();
});
}
view.addMetadataRow(row);
});
},
+ getMetadataByKey: function (key) {
+ var ret;
+ this.node.getMetadata().some(function (row) {
+ if (row.key == 'relation.coverimage.url') {
+ ret = row.value;
+ return true;
+ }
+ });
+ return ret;
+ },
addMetadataRow: function(row) {
console.log(row);
var newRow = $(_.template(itemTemplate)({key: row.getKey() || '', value: row.getValue() || ''}));
<div class="rng-dialog modal hide static <%= cssClass %>">
<div class="modal-header">
- <button type="button" class="close">×</button>
+ <% if(closeButton) { %><button type="button" class="close">×</button><% } %>
<h1><%= title %></h1>
</div>
<div class="modal-body">