-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from BurdaMagazinOrg/feature/eb_widget
Looks good. Follow Up Tickets DRPLDCX-55 and DRPLDCX-56 are in place. Merging.
- Loading branch information
Showing
18 changed files
with
319 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.dcx-dropzone { | ||
width: 100%; | ||
text-align: center; | ||
margin: 1em 0; | ||
padding: 1em; | ||
height: 300px; | ||
background-color: white; | ||
outline: 2px dashed #0074bd; | ||
outline-offset: -10px; | ||
color: #004f80; | ||
} | ||
|
||
.dcx-dropzone.is-dragover { | ||
background-color: #6b6b6b; | ||
} | ||
|
||
.box__dragndrop, | ||
.box__uploading, | ||
.box__success, | ||
.box__error { | ||
display: none; | ||
} | ||
|
||
.box__input { | ||
position: relative; | ||
top: 50%; | ||
} | ||
|
||
.dcx-dropzone.is-uploading .box__input { | ||
display: none; | ||
} | ||
.dcx-dropzone.is-uploading .box__uploading { | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: DC-X Dropzone UI | ||
type: module | ||
description: 'Dropzone Element for DCX DnD' | ||
|
||
version: '0' | ||
core: '8.x' | ||
package: dcx | ||
|
||
dependencies: | ||
- dcx_migration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dropzone: | ||
version: 0 | ||
js: | ||
js/dcx-dropzone-ui.js: {} | ||
css: | ||
theme: | ||
css/dcx-dropzone-ui.css: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
function dcx_dropzone_ui_theme() { | ||
return [ | ||
'dcxdropzone' => [ | ||
'render element' => 'element', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Prepares variables for dropzone form element. | ||
* | ||
* Default template: dcxdropzone.html.twig. | ||
* | ||
* @param array $variables | ||
* An associative array containing: | ||
* - element: A render element representing the file. | ||
*/ | ||
function template_preprocess_dcxdropzone(&$variables) { | ||
$element = $variables['element']; | ||
|
||
$variables['attributes'] = []; | ||
if (isset($element['#id'])) { | ||
$variables['attributes']['id'] = $element['#id']; | ||
} | ||
if (!empty($element['#attributes']['class'])) { | ||
$variables['attributes']['class'] = (array) $element['#attributes']['class']; | ||
} | ||
|
||
$variables['attributes']['class'][] = 'dcx-dropzone'; | ||
|
||
if (isset($element['#dropzone_description'])) { | ||
$variables['description'] = $element['#dropzone_description']; | ||
} | ||
else { | ||
$variables['description'] = 'DC-X Dropzone'; | ||
} | ||
|
||
$variables['dropvalue'] = $element['dropvalue']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(function ($, Drupal, drupalSettings) { | ||
"use strict"; | ||
|
||
Drupal.behaviors.dcxDropzoneUi = { | ||
attach: function (context, settings) { | ||
|
||
var dropzone_id = drupalSettings.dcx_dropzone.dropzone_id, | ||
dropzone = $('#' + dropzone_id); | ||
|
||
dropzone.on('dragover dragenter', function (event) { | ||
event.preventDefault(); | ||
dropzone.addClass('is-dragover'); | ||
}); | ||
|
||
dropzone.on('dragleave dragend drop', function (event) { | ||
event.preventDefault(); | ||
dropzone.removeClass('is-dragover'); | ||
}); | ||
|
||
dropzone.on('drop', function (event) { | ||
event.preventDefault(); | ||
|
||
if (dropzone.hasClass('is-uploading')) return false; | ||
|
||
dropzone.addClass('is-uploading').removeClass('is-error'); | ||
|
||
|
||
var uri = decodeURIComponent(event.originalEvent.dataTransfer.getData('text/uri-list')); | ||
var data = uri.split('?')[0]; | ||
data = [{'documenttype-image': data.substr(data.indexOf('document'))}]; | ||
|
||
$.ajax({ | ||
url: "/dcx-migration/upload", | ||
method: 'POST', | ||
data: JSON.stringify(data) | ||
}).complete(function() { | ||
dropzone.removeClass('is-uploading'); | ||
}).success(function(data) { | ||
dropzone.addClass( data.success == true ? 'is-success' : 'is-error' ); | ||
}); | ||
}); | ||
} | ||
}; | ||
|
||
})(jQuery, Drupal, drupalSettings); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div{{ attributes }}> | ||
|
||
<div class="box__input"> | ||
|
||
{{description}} | ||
</div> | ||
|
||
<div class="box__uploading">Uploading…</div> | ||
<div class="box__success">Done!</div> | ||
<div class="box__error">Error! <span></span>.</div> | ||
</div> | ||
{{ dropvalue }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: DC-X Entity Browser | ||
type: module | ||
description: 'Entity Browser integration for dcx' | ||
|
||
version: '0' | ||
core: '8.x' | ||
package: dcx | ||
|
||
dependencies: | ||
- dcx_dropzone_ui | ||
- entity_browser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
/** | ||
* @param $form | ||
*/ | ||
function dcx_entity_browser_form_entity_browser_media_entity_browser_form_alter(&$form) { | ||
|
||
if (!empty($form['widget']['dropzone']['#type']) && $form['widget']['dropzone']['#type'] == 'dcxdropzone') { | ||
$form['actions'] = []; | ||
} | ||
} |
Oops, something went wrong.