Commit d95110b4 authored by ephoto_dam's avatar ephoto_dam

Ephoto Dam field in progress

parent ecb566a8
......@@ -10,13 +10,18 @@
/**
* EPHOTO ID of Drupal Addon
*/
CLIENT_ID : 'CaCvqS5H',
CLIENT_ID: 'CaCvqS5H',
/**
* Settings
*/
settings: drupalSettings.ephotoDamField,
/**
* Current authid
*/
authid: null,
/**
* Ephoto Dam instance
*/
......@@ -25,7 +30,12 @@
/**
* Ephoto Dam Server connected
*/
connected: false,
connected: false,
/**
* Current selected field
*/
fieldSelected : null,
/**
* Enable version support
......@@ -66,46 +76,75 @@
return;
}
this.authid = $.cookie('drupal_ephoto_dam_authid');
this.ephoto = new ePhoto({
'server': this.settings.server_url,
'authID': $.cookie('drupal_ephoto_dam_authid'),
'authID': this.authid,
'client': this.CLIENT_ID
});
this.ephoto.connect();
this.ephoto.File.setMode('link');
if (this.settings.version_support === '1') {
this.ephoto.File.callOnFileReceived(this.getVersionUrls.bind(this));
}
else {
this.ephoto.File.callOnFileReceived(this.getFileUrl.bind(this));
}
//this.ephoto.File.enableDCore();
this.ephoto.File.setMode('manual');
this.ephoto.callOnConnect(function() {
$.cookie('drupal_ephoto_dam_authid', self.ephoto.getAuthID(), { path:'/' });
let version = self.ephoto.getVersion().split('.');
self.connected = true;
});
// 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 function'));
return;
}
self.authid = self.ephoto.getAuthID();
$.cookie('drupal_ephoto_dam_authid', self.authid, { path:'/' });
this.ephoto.File.callOnFileReceived(this.insert.bind(this));
self.connected = true;
});
},
/**
*
*/
selectUrls: function() {
selectVersions: function() {
let versions = this._getFieldValues();
// this.ephoto.File.setButtons !!
this.ephoto.File.get();
},
},
/**
*
*/
getVersionUrls: function() {
console.log('get version urls!');
},
/**
*
*/
selectUrl: function(delta) {
let field = this._getFieldValues()[delta];
select: function(delta) {
this.fieldSelected = this._getFieldValues()[delta];
if (!this.fieldSelected) {
alert(Drupal.t('Field selection error'));
return;
}
this.ephoto.File.setButtons( this.ephoto.IMAGE_FILES, [ {
'definition': field.size ? 'custom' : 'middle',
'size': field.size.toString(),
'definition': 'custom',
'size': this.fieldSelected.size.toString(),
'dpi': '72',
'format': 'jpeg',
'notEnlarge': '1'
......@@ -117,8 +156,18 @@
/**
*
*/
insert: function() {
getFileUrl: function() {
console.log('get file url!');
if (!this._fieldSelected) {
alert(Drupal.t('Field selection error'));
return;
}
this.ephoto.File.store(function(url) {
this._fieldSelected.value = url;
this._fieldSelected = null;
});
},
/**
......
This diff is collapsed.
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