1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 17:24:46 +02:00

Add @Toutouwai processwire/processwire-requests#242 to support automatic open of collapsed Inputfield when file dragged into file/image or CKEditor field that supports it

This commit is contained in:
Ryan Cramer
2018-11-08 09:04:04 -05:00
parent 7629e518e3
commit c146c71de3
4 changed files with 15 additions and 2 deletions

View File

@@ -291,7 +291,11 @@ class InputfieldCKEditor extends InputfieldTextarea {
$extraPlugins = $this->extraPlugins;
$imagesField = $this->getImagesFieldName($assetPage);
if($imagesField) $extraPlugins[] = 'uploadimage';
if($imagesField) {
$extraPlugins[] = 'uploadimage';
$this->addClass('InputfieldHasUpload', 'wrapClass');
}
$settings = array(
'baseHref' => $config->urls->root,

View File

@@ -594,6 +594,7 @@ class InputfieldFile extends Inputfield implements InputfieldItemList, Inputfiel
public function renderReady(Inputfield $parent = null, $renderValueMode = false) {
$this->addClass('InputfieldNoFocus', 'wrapClass');
if(!$renderValueMode) $this->addClass('InputfieldHasUpload', 'wrapClass');
if($this->useTags) {
$this->wire('modules')->get('JqueryUI')->use('selectize');

View File

@@ -1319,6 +1319,14 @@ function InputfieldStates($target) {
$(document).on('submit', '.InputfieldFormConfirm', function() {
$(this).addClass('InputfieldFormSubmitted');
});
// open Inputfields supporting uploads when file dragged in, per @Toutouwai #242
$(document).on('dragenter', '.InputfieldHasUpload.InputfieldStateCollapsed', function(e) {
var dt = e.originalEvent.dataTransfer;
if(dt.types && (dt.types.indexOf ? dt.types.indexOf('Files') !== -1 : dt.types.contains('Files'))) {
InputfieldOpen($(this));
}
});
window.addEventListener("beforeunload", InputfieldFormBeforeUnloadEvent);
}

File diff suppressed because one or more lines are too long