Commit f3da456e authored by ephoto_dam's avatar ephoto_dam

module Ephoto Dam Field in progress

parent 6cef6bc2
.field--type-ephoto-dam-field .form-type-textfield {
float:left;
margin-right:5px;
}
.field--type-ephoto-dam-field .form-type-number {
float:left;
margin-right:10px;
}
.field--type-ephoto-dam-field .field-multiple-drag {
......@@ -35,6 +29,10 @@
text-align:left
}
.ephoto-dam-field-url-suffix, .ephoto-dam-field-imagesize-suffix {
padding-right:10px
}
.ephoto-dam-field-button {
border-radius:2em !important;
margin:5px 0 0 0 !important;
......@@ -45,10 +43,6 @@
}
.ephoto-dam-field-file-button {
margin:2.1em 0 0 0 !important;
}
#edit-default-value-input .ephoto-dam-field-file-button {
margin:1.8em 0 0 0 !important;
}
......
......@@ -43,6 +43,7 @@
enableVersionSupport: function(el) {
if(el.checked) {
$('.ephoto-dam-field-version-field').removeClass('ephoto-dam-field-hidden');
$('.ephoto-dam-field-version-prefix').removeClass('ephoto-dam-field-hidden');
$('.ephoto-dam-field-versions-button').removeClass('ephoto-dam-field-hidden');
$('.ephoto-dam-field-file-button').addClass('ephoto-dam-field-hidden');
......@@ -50,6 +51,7 @@
else {
$('.ephoto-dam-field-version-field').addClass('ephoto-dam-field-hidden');
$('.ephoto-dam-field-version-prefix').addClass('ephoto-dam-field-hidden');
$('.ephoto-dam-field-versions-button').addClass('ephoto-dam-field-hidden');
$('.ephoto-dam-field-file-button').removeClass('ephoto-dam-field-hidden');
......@@ -128,7 +130,7 @@
this.fieldSelected = this._getFieldValues()[delta];
if (!this.fieldSelected) {
alert(Drupal.t('Field selection error'));
console.log('Field selection error');
return;
}
......@@ -154,8 +156,9 @@
/**
* Get URL of selected file
*/
getUrl: function(none, dcore) {
getUrl: function(empty_value, dcore) {
if (dcore === 'fileDoesNotExist') {
console.log('File does not exist');
return;
}
......@@ -163,6 +166,7 @@
var version_support = this.settings.version_support === '1';
if (!this.fieldSelected) {
console.log('Field selected missing');
return;
}
......@@ -178,7 +182,7 @@
_getFieldValues: function() {
var fields = [];
var sizes = $('.ephoto-dam-field-imagesize-field').toArray();
var inputs = $('.ephoto-dam-field-value-field').toArray();
var inputs = $('.ephoto-dam-field-url-field').toArray();
$('.ephoto-dam-field-version-field').map(function(index, el) {
fields.push({
......
......@@ -46,39 +46,54 @@ class EphotoDamFieldWidget extends WidgetBase {
}
$classes = ['ephoto-dam-field-field', 'ephoto-dam-field-url-field'];
if (!$is_default_values_form) $classes[] = 'ephoto-dam-field-hidden';
if (!$is_default_values_form) $classes[] = 'ephoto-dam-field-hidden';
$suffix_classes = ['ephoto-dam-field-url-suffix'];
$element['url'] = [
'#type' => 'textfield',
'#title' => $this->t('URL') . ' ' . ($delta + 1),
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : null,
'#size' => 60,
'#default_value' => isset($items[$delta]->url) ? $items[$delta]->url : null,
'#size' => 70,
'#maxlength' => 256,
'#field_suffix' => '  ',
'#field_suffix' => '<span class="' . implode(' ', $suffix_classes). '"></span>',
'#attributes' => [
'class' => ['ephoto-dam-field-field', 'ephoto-dam-field-url-field'],
'readonly' => 'readonly',
'onclick' => 'this.focus();this.select()'
]
];
];
$classes = ['ephoto-dam-field-field', 'ephoto-dam-field-imagesize-field'];
$suffix_classes = ['ephoto-dam-field-imagesize-suffix'];
if (!$is_default_values_form && empty($items[$delta]->image_size)) {
$classes[] = 'ephoto-dam-field-hidden';
$suffix_classes[] = 'ephoto-dam-field-hidden';
}
$element['image_size'] = [
'#type' => 'textfield',
'#title' => '&nbsp;',
'#default_value' => isset($items[$delta]->image_size) ? $items[$delta]->image_size : null,
'#size' => 5,
'#size' => 4,
'#maxlength' => 60,
'#field_suffix' => 'px, &nbsp;',
'#field_suffix' => '<span class="' . implode(' ', $suffix_classes). '">px</span>',
'#attributes' => [
'class' => ['ephoto-dam-field-field', 'ephoto-dam-field-imagesize-field'],
'placeholder' => $this->t('Image size'),
'class' => $classes,
'placeholder' => $this->t('Size'),
'max' => 1600,
'onclick' => 'this.focus();this.select()'
]
];
];
$classes = ['ephoto-dam-field-field', 'ephoto-dam-field-version-field'];
if (!$version_support) $classes[] = 'ephoto-dam-field-hidden';
$prefix_classes = ['ephoto-dam-field-version-prefix'];
if (!$version_support) {
$classes[] = 'ephoto-dam-field-hidden';
$prefix_classes[] = 'ephoto-dam-field-hidden';
}
$element['version'] = [
'#type' => 'textfield',
......@@ -86,10 +101,10 @@ class EphotoDamFieldWidget extends WidgetBase {
'#default_value' => !empty($items[$delta]->version) ? $items[$delta]->version : ($is_default_values_form ? null : $this->t('Current version')),
'#size' => 10,
'#maxlength' => 60,
'#field_prefix' => $this->t('version'),
'#field_prefix' => '<span class="' . implode(' ', $prefix_classes). '">, &nbsp;' . $this->t('version') . '</span>',
'#attributes' => [
'class' => $classes,
'placeholder' => $this->t('Version name'),
'placeholder' => $this->t('Name'),
'onclick' => 'this.focus();this.select()'
]
];
......
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