Commit 0fdd4d57 authored by ephoto_dam's avatar ephoto_dam

Ephoto Dam Field in progress

parent 2f381cfb
......@@ -92,8 +92,6 @@
this.ephoto.File.enableDCore();
this.ephoto.File.setMode('manual');
this.ephoto.callOnConnect(function() {
let version = self.ephoto.getVersion().split('.');
......@@ -117,8 +115,23 @@
selectVersions: function() {
let versions = this._getFieldValues();
// this.ephoto.File.setButtons !!
//this.ephoto.File.get();
if (!versions) {
console.log('Field selection error');
return;
}
this.ephoto.File.setButtons( this.ephoto.IMAGE_FILES, [ {
'mode': 'none'
} ] );
this.ephoto.File.get();
},
/**
*
*/
getUrlsVersions: function() {
var version_support = this.settings.version_support === '1';
},
/**
......@@ -134,15 +147,12 @@
return;
}
let size = this.fieldSelected.size.toString().split('x').map(function(val) {
val = val === '' || isNaN(val) ? 0 : parseInt(val, 10);
return (val > 1600) ? 1600 : ((val <= 0) ? '' : val);
}).join('x');
let size = this._checkSizeValue(this.fieldSelected.size);
if (size === '' || size === 0) return;
this.ephoto.File.setButtons( this.ephoto.IMAGE_FILES, [ {
'mode': 'link',
'definition': 'custom',
'size': size,
'dpi': 72,
......@@ -155,25 +165,38 @@
/**
* Get URL of selected file
*
* @param {string} URL value
* @param {object} DublinCore values
*/
getUrl: function(empty_value, dcore) {
if (dcore === 'fileDoesNotExist') {
getUrl: function(url, dcore) {
if (url === 'fileDoesNotExist') {
console.log('File does not exist');
return;
}
var self = this;
var version_support = this.settings.version_support === '1';
var self = this;
if (!this.fieldSelected) {
console.log('Field selected missing');
return;
}
this.ephoto.File.store(function(url) {
self.fieldSelected.input.val(url);
self.fieldSelected = null;
});
self.fieldSelected.input.val(url);
self.fieldSelected = null;
},
/**
* Check size value
*
* @param {number} A size value
*/
_checkSizeValue: function(size) {
return size.toString().split('x').map(function(val) {
val = val === '' || isNaN(val) ? 0 : parseInt(val, 10);
return (val > 1600) ? 1600 : ((val <= 0) ? '' : val);
}).join('x');
},
/**
......
......@@ -47,7 +47,7 @@ class EphotoDamFieldWidget extends WidgetBase {
$classes = ['ephoto-dam-field-field', 'ephoto-dam-field-url-field'];
if (!$is_default_values_form) $classes[] = 'ephoto-dam-field-hidden';
$suffix_classes = ['ephoto-dam-field-url-suffix'];
$element['url'] = [
......@@ -82,8 +82,8 @@ class EphotoDamFieldWidget extends WidgetBase {
'#attributes' => [
'class' => $classes,
'placeholder' => $this->t('Size'),
'max' => 1600,
'onclick' => 'this.focus();this.select()'
'max' => 1600,
'onclick' => 'this.focus();this.select()'
]
];
......@@ -104,11 +104,11 @@ class EphotoDamFieldWidget extends WidgetBase {
'#field_prefix' => '<span class="' . implode(' ', $prefix_classes). '">, &nbsp;' . $this->t('version') . '</span>',
'#attributes' => [
'class' => $classes,
'placeholder' => $this->t('Name'),
'onclick' => 'this.focus();this.select()'
'placeholder' => $this->t('Name'),
'onclick' => 'this.focus();this.select()'
]
];
$classes = ['button', 'ephoto-dam-field-button', 'ephoto-dam-field-file-button'];
if ($version_support) $classes[] = 'ephoto-dam-field-hidden';
......
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