Commit 63ddb683 authored by ephoto_dam's avatar ephoto_dam

Minor improvement in the Ephoto Dam Embed module

parent 40af6057
......@@ -152,9 +152,17 @@
this.ephoto.File.setMode('embed');
this.ephoto.File.enableDCore();
this.ephoto.File.enableDCore('json');
this.ephoto.callOnConnect(function() {
let version = self.ephoto.getVersion().split('.');
// Requires API version 6.0 (Ephoto Dam 4.0)
if (version.length !==3 || version[0] < 6) {
alert(Drupal.t('The version of Ephoto Dam is not compatible with this feature'));
return;
}
CKEDITOR.tools.setCookie( 'drupal_ephoto_dam_authid', self.ephoto.getAuthID());
self.connected = true;
......@@ -335,15 +343,15 @@
}
var self = this;
var embed = this.getURLFromString(html, 'embed');
if(!embed) return;
$.ajax({
url : embed
}).done(function(data) {
var dctype = self.getValueOfXmlNode(dcore, 'dc:type');
var dctype = dcore['dc:type'];
var src, size, type;
switch(dctype) {
......@@ -460,24 +468,15 @@
},
/**
* Build the caption width a DublinCore XML Tag DC = [dc:xxxxx]
* Build the caption width a DublinCore
*/
buildCaption: function(dcore) {
var nodes = $(dcore).find('*'), values = {};
var result = this.settings.captions_format;
var i, node;
for(i = 0; i < nodes.length; i++) {
node = nodes[i];
if(node.nodeName.split(':')[0] === 'dc') {
result = result.replace('[' + node.nodeName + ']', node.textContent);
}
for (const property in dcore) {
result = result.replace('[' + property + ']', dcore[property]);
}
// remove unsupported tags
result = result.replace(/\[dc:(.*)\]/, '');
return result;
},
......@@ -526,13 +525,6 @@
}
return result;
},
/**
* Get the value of a xml node
*/
getValueOfXmlNode(xml, node) {
return xml.getElementsByTagName(node)[0].textContent;
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment