2019-07-26 00:00:24 +08:00
|
|
|
/* global Promise ActiveStorage animateSpinner copyFromClipboard I18n
|
|
|
|
Results ResultAssets FilePreviewModal Comments truncateLongString
|
2022-10-24 19:07:10 +08:00
|
|
|
DragNDropResults initFormSubmitLinks dragNdropAssetsInit
|
2019-08-06 21:06:19 +08:00
|
|
|
GLOBAL_CONSTANTS */
|
2019-07-26 00:00:24 +08:00
|
|
|
|
|
|
|
(function(global) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Copy from clipboard
|
|
|
|
global.copyFromClipboard = (function() {
|
|
|
|
var UPLOADED_IMAGE = {};
|
|
|
|
|
|
|
|
function retrieveImageFromClipboardAsBlob(pasteEvent, callback) {
|
|
|
|
if (pasteEvent.clipboardData === false) {
|
|
|
|
if ((typeof callback) === 'function') {
|
|
|
|
callback(undefined);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let items = pasteEvent.clipboardData.items;
|
|
|
|
if (items === undefined) {
|
|
|
|
if ((typeof callback) === 'function') {
|
|
|
|
callback(undefined);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i += 1) {
|
|
|
|
if (items[i].type.indexOf('image') !== -1) {
|
|
|
|
let blob = items[i].getAsFile();
|
|
|
|
|
|
|
|
if ((typeof callback) === 'function') {
|
|
|
|
callback(blob);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// $(..).modal('hide') don't work properly so here we manually remove the
|
|
|
|
// displayed modal
|
|
|
|
function hideModalForGood() {
|
|
|
|
$('#clipboardPreviewModal').removeClass('in');
|
|
|
|
$('.modal-backdrop').remove();
|
|
|
|
$('body').removeClass('modal-open');
|
|
|
|
$('body').css('padding-right', '');
|
|
|
|
$('#clipboardPreviewModal').hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeModal() {
|
|
|
|
hideModalForGood();
|
|
|
|
$('#clipboardPreviewModal').remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
function addImageCallback() {
|
|
|
|
$('[data-action="addImageFormClipboard"]').on('click', function() {
|
|
|
|
let inputArray = [];
|
|
|
|
let newName = $('#clipboardImageName').val();
|
|
|
|
// check if the name is set
|
|
|
|
if (newName && newName.length > 0) {
|
|
|
|
let extension = UPLOADED_IMAGE.name.slice(
|
|
|
|
(Math.max(0, UPLOADED_IMAGE.name.lastIndexOf('.')) || Infinity) + 1
|
|
|
|
);
|
|
|
|
// hack to inject custom name in File object
|
|
|
|
let name = newName + '.' + extension;
|
|
|
|
let blob = UPLOADED_IMAGE.slice(0, UPLOADED_IMAGE.size, UPLOADED_IMAGE.type);
|
|
|
|
// make new blob with the correct name;
|
|
|
|
let newFile = new File([blob], name, { type: UPLOADED_IMAGE.type });
|
|
|
|
inputArray.push(newFile);
|
|
|
|
} else { // return the default name
|
|
|
|
inputArray.push(UPLOADED_IMAGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// close modal
|
|
|
|
closeModal();
|
2022-10-24 19:07:10 +08:00
|
|
|
DragNDropResults.init(inputArray);
|
2019-07-26 00:00:24 +08:00
|
|
|
// clear all uploaded images
|
|
|
|
UPLOADED_IMAGE = {};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// removes modal from dom
|
|
|
|
function destroyModalCallback() {
|
|
|
|
let modal = $('#clipboardPreviewModal');
|
|
|
|
modal.on('hidden.bs.modal', function() {
|
|
|
|
modal.modal('hide').promise().done(function() {
|
|
|
|
modal.remove();
|
|
|
|
});
|
|
|
|
UPLOADED_IMAGE = {};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate modal html and hook callbacks
|
|
|
|
function clipboardPasteModal() {
|
2019-08-06 21:06:19 +08:00
|
|
|
var html = `<div id="clipboardPreviewModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
|
|
|
<div class="modal-dialog" role="document">
|
|
|
|
<div class="modal-content"><div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
2023-08-17 19:55:17 +08:00
|
|
|
<i class="sn-icon sn-icon-close"></i>
|
2019-08-06 21:06:19 +08:00
|
|
|
</button>
|
|
|
|
<h4 class="modal-title">${I18n.t('assets.from_clipboard.modal_title')}</h4>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p><strong>${I18n.t('assets.from_clipboard.image_preview')}</strong></p>
|
|
|
|
<canvas style="border:1px solid grey;max-width:400px;max-height:300px" id="clipboardPreview" />
|
|
|
|
<p><strong>${I18n.t('assets.from_clipboard.file_name')}</strong></p>
|
|
|
|
<div class="input-group">
|
|
|
|
<input id="clipboardImageName" type="text" class="form-control"
|
|
|
|
placeholder="${I18n.t('assets.from_clipboard.file_name_placeholder')}" aria-describedby="image-name">
|
|
|
|
<span class="input-group-addon" id="image-name"></span></div>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
2023-06-19 21:45:22 +08:00
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">${I18n.t('general.cancel')}</button>
|
2019-08-06 21:06:19 +08:00
|
|
|
<button type="button" class="btn btn-success" data-action="addImageFormClipboard">${I18n.t('assets.from_clipboard.add_image')}</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div><!-- /.modal -->`;
|
2019-07-26 00:00:24 +08:00
|
|
|
return $(html).appendTo($('body')).promise().done(function() {
|
|
|
|
// display modal
|
|
|
|
$('#clipboardPreviewModal').modal('show');
|
|
|
|
// add callback to remove modal from DOM
|
|
|
|
destroyModalCallback();
|
|
|
|
// add callback on image submit
|
|
|
|
addImageCallback();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function listener(pasteEvent) {
|
|
|
|
retrieveImageFromClipboardAsBlob(pasteEvent, function(imageBlob) {
|
|
|
|
if (imageBlob) {
|
|
|
|
clipboardPasteModal().promise().done(function() {
|
|
|
|
var canvas = document.getElementById('clipboardPreview');
|
|
|
|
var ctx = canvas.getContext('2d');
|
|
|
|
var img = new Image();
|
|
|
|
img.onload = function() {
|
|
|
|
canvas.width = this.width;
|
|
|
|
canvas.height = this.height;
|
|
|
|
ctx.drawImage(img, 0, 0);
|
|
|
|
};
|
|
|
|
let URLObj = window.URL || window.webkitURL;
|
|
|
|
img.src = URLObj.createObjectURL(imageBlob);
|
|
|
|
let extension = imageBlob.name.slice(
|
|
|
|
(Math.max(0, imageBlob.name.lastIndexOf('.')) || Infinity) + 1
|
|
|
|
);
|
|
|
|
$('#image-name').html('.' + extension); // add extension near file name
|
|
|
|
// temporary store image blob
|
|
|
|
UPLOADED_IMAGE = imageBlob;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-10-24 19:07:10 +08:00
|
|
|
function init() {
|
2019-07-26 00:00:24 +08:00
|
|
|
global.addEventListener('paste', listener, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function destroy() {
|
|
|
|
global.removeEventListener('paste', listener, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Object.freeze({
|
|
|
|
init: init,
|
|
|
|
destroy: destroy
|
|
|
|
});
|
|
|
|
}());
|
|
|
|
|
|
|
|
// Module to handle file uploading in Results
|
|
|
|
global.DragNDropResults = (function() {
|
|
|
|
var droppedFiles = [];
|
|
|
|
var isValid = true;
|
|
|
|
var totalSize = 0;
|
|
|
|
var fileMaxSizeMb;
|
|
|
|
var fileMaxSize;
|
2023-05-23 23:30:37 +08:00
|
|
|
var itemsNames = {};
|
2019-07-26 00:00:24 +08:00
|
|
|
|
|
|
|
function disableSubmitButton() {
|
|
|
|
$('.save-result').prop('disabled', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function enableSubmitButton() {
|
2023-03-16 21:19:24 +08:00
|
|
|
$('.save-result').prop('disabled', false).focus();
|
2019-07-26 00:00:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function filerAndCheckFiles() {
|
|
|
|
for (let i = 0; i < droppedFiles.length; i += 1) {
|
|
|
|
if (droppedFiles[i].isValid === false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (droppedFiles.length > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function dragNdropAssetsOff() {
|
|
|
|
$('body').off('drag dragstart dragend dragover dragenter dragleave drop');
|
|
|
|
$('.is-dragover').hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
function destroyAll() {
|
|
|
|
dragNdropAssetsOff();
|
|
|
|
droppedFiles = [];
|
|
|
|
isValid = true;
|
|
|
|
totalSize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return the status of files if they are ready to submit
|
|
|
|
function filesStatus() {
|
|
|
|
return isValid;
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateTotalSize() {
|
|
|
|
if (totalSize > fileMaxSize) {
|
|
|
|
isValid = false;
|
|
|
|
disableSubmitButton();
|
|
|
|
$.each($('.panel-result-attachment-new'), function() {
|
|
|
|
if (!$(this).find('p').hasClass('dnd-total-error')) {
|
|
|
|
$(this)
|
|
|
|
.find('.panel-body')
|
|
|
|
.append("<p class='dnd-total-error'>" + I18n.t('general.file.total_size', { size: fileMaxSizeMb }) + '</p>');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$('.dnd-total-error').remove();
|
|
|
|
if (filerAndCheckFiles()) {
|
|
|
|
isValid = true;
|
|
|
|
enableSubmitButton();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function submitResultForm(url, formData) {
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
method: 'POST',
|
|
|
|
data: formData,
|
|
|
|
contentType: false,
|
|
|
|
processData: false,
|
|
|
|
success: function(data) {
|
|
|
|
animateSpinner(null, false);
|
|
|
|
$('#new-result-assets-select').parent().remove();
|
|
|
|
$(data.html).prependTo('#results').promise().done(function() {
|
|
|
|
$.each($('[data-container="new-reports"]').find('.result'), function() {
|
|
|
|
initFormSubmitLinks($(this));
|
|
|
|
ResultAssets.applyEditResultAssetCallback();
|
|
|
|
Results.toggleResultEditButtons(true);
|
|
|
|
Comments.init();
|
|
|
|
ResultAssets.initNewResultAsset();
|
|
|
|
Results.expandResult($(this));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#results-toolbar').show();
|
|
|
|
},
|
|
|
|
error: function() {
|
|
|
|
animateSpinner();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// appent the files to the form before submit
|
|
|
|
function appendFilesToForm(ev, fd) {
|
|
|
|
const form = $(ev.target.form);
|
|
|
|
const url = form.find('#drag-n-drop-assets').data('directUploadUrl');
|
2020-02-27 23:58:00 +08:00
|
|
|
const lastIndex = droppedFiles.length - 1;
|
|
|
|
|
|
|
|
let index = 0;
|
2020-02-12 03:08:36 +08:00
|
|
|
|
2020-02-27 23:58:00 +08:00
|
|
|
const uploadFile = (file) => {
|
|
|
|
const upload = new ActiveStorage.DirectUpload(file, url);
|
2019-07-26 00:00:24 +08:00
|
|
|
|
2020-02-27 23:58:00 +08:00
|
|
|
upload.create((error, blob) => {
|
2019-07-26 00:00:24 +08:00
|
|
|
if (error) {
|
2020-03-03 22:20:29 +08:00
|
|
|
$.each($('.panel-result-attachment-new'), function() {
|
|
|
|
if (!$(this).find('p').hasClass('dnd-total-error')) {
|
|
|
|
$(this)
|
|
|
|
.find('.panel-body')
|
|
|
|
.append("<p class='dnd-total-error'>" + I18n.t('general.file.upload_failure') + '</p>');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
animateSpinner(null, false);
|
2019-07-26 00:00:24 +08:00
|
|
|
} else {
|
2020-02-27 23:58:00 +08:00
|
|
|
fd.append('results_names[' + index + ']', $('input[name="results[name][' + index + ']"]').val());
|
|
|
|
fd.append('results_files[' + index + '][signed_blob_id]', blob.signed_id);
|
|
|
|
if (index === lastIndex) {
|
2019-07-26 00:00:24 +08:00
|
|
|
submitResultForm($(ev.target).attr('data-href'), fd);
|
|
|
|
destroyAll();
|
2020-02-27 23:58:00 +08:00
|
|
|
return;
|
2019-07-26 00:00:24 +08:00
|
|
|
}
|
2020-02-27 23:58:00 +08:00
|
|
|
index += 1;
|
|
|
|
uploadFile(droppedFiles[index]);
|
2019-07-26 00:00:24 +08:00
|
|
|
}
|
|
|
|
});
|
2020-02-27 23:58:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
uploadFile(droppedFiles[index]);
|
2019-07-26 00:00:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* eslint no-param-reassign: ["error", { "props": false }] */
|
|
|
|
function validateFilesSize(file) {
|
|
|
|
var fileSize = file.size;
|
|
|
|
totalSize += parseInt(fileSize, 10);
|
|
|
|
if (fileSize > fileMaxSize) {
|
|
|
|
file.isValid = false;
|
|
|
|
disableSubmitButton();
|
|
|
|
return "<p class='dnd-error'>" + I18n.t('general.file.size_exceeded', { file_size: fileMaxSizeMb }) + '</p>';
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateTextSize(input) {
|
2019-08-06 21:06:19 +08:00
|
|
|
if (input.value.length > GLOBAL_CONSTANTS.NAME_MAX_LENGTH) {
|
2019-07-26 00:00:24 +08:00
|
|
|
$(input).parent().find('.dnd-error').remove();
|
2019-08-06 21:06:19 +08:00
|
|
|
$(input).after("<p class='dnd-error'>" + I18n.t('general.text.length_too_long', { max_length: GLOBAL_CONSTANTS.NAME_MAX_LENGTH }) + '</p>');
|
2019-07-26 00:00:24 +08:00
|
|
|
isValid = false;
|
|
|
|
} else {
|
|
|
|
$(input).parent().find('.dnd-error').remove();
|
|
|
|
isValid = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function uploadedAssetPreview(asset, i) {
|
2023-05-23 23:30:37 +08:00
|
|
|
var html = `<div class="panel panel-default panel-result-attachment-new" data-item-uuid="${asset.uuid}">
|
2019-08-06 21:06:19 +08:00
|
|
|
<div class="panel-heading">
|
2023-06-08 14:33:37 +08:00
|
|
|
<span class="sn-icon sn-icon-files"></span>
|
2019-08-06 21:06:19 +08:00
|
|
|
${I18n.t('assets.drag_n_drop.file_label')}
|
|
|
|
<div class="pull-right">
|
2020-02-12 21:13:09 +08:00
|
|
|
<a data-item-id="${asset.uuid}" href="#">
|
2023-06-08 23:33:50 +08:00
|
|
|
<span class="sn-icon sn-icon-close"></span>
|
2019-08-06 21:06:19 +08:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="control-label">Name</label>
|
2023-05-31 15:08:16 +08:00
|
|
|
<input type="text" class="form-control file-name-field"
|
2020-02-12 03:08:36 +08:00
|
|
|
rel="results[name]" name="results[name][${i}]">
|
2019-08-06 21:06:19 +08:00
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="control-label">${I18n.t('assets.drag_n_drop.file_label')}:</label>
|
|
|
|
${truncateLongString(asset.name, GLOBAL_CONSTANTS.FILENAME_TRUNCATION_LENGTH)}
|
|
|
|
${validateFilesSize(asset)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>`;
|
2019-07-26 00:00:24 +08:00
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
|
|
|
function processResult(ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
ev.stopPropagation();
|
|
|
|
|
|
|
|
if (isValid && filerAndCheckFiles()) {
|
|
|
|
animateSpinner();
|
|
|
|
|
|
|
|
let formData = new FormData();
|
|
|
|
|
|
|
|
appendFilesToForm(ev, formData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-23 23:30:37 +08:00
|
|
|
function restoreItemName(uuid) {
|
|
|
|
$(`.panel-result-attachment-new[data-item-uuid="${uuid}"]`)
|
|
|
|
.find('input[rel="results[name]"]').val((itemsNames[uuid] || ''));
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveItemsNames() {
|
|
|
|
$('.panel-result-attachment-new').each(function() {
|
|
|
|
const panel = $(this);
|
|
|
|
itemsNames[panel.data('item-uuid')] = panel.find('input[rel="results[name]"]').val();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-02-12 21:13:09 +08:00
|
|
|
function removeItemHandler(uuid) {
|
|
|
|
$('[data-item-id="' + uuid + '"]').off('click').on('click', function(e) {
|
2019-07-26 00:00:24 +08:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopImmediatePropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
let $el = $(this);
|
2020-02-12 21:13:09 +08:00
|
|
|
let index = droppedFiles.findIndex((file) => {
|
|
|
|
return file.uuid === $el.data('item-id');
|
|
|
|
});
|
2019-07-26 00:00:24 +08:00
|
|
|
totalSize -= parseInt(droppedFiles[index].size, 10);
|
|
|
|
droppedFiles.splice(index, 1);
|
2020-03-12 18:50:31 +08:00
|
|
|
validateTotalSize();
|
2020-02-12 03:08:36 +08:00
|
|
|
$el.closest('.panel-result-attachment-new').remove();
|
2019-07-26 00:00:24 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// loops through a list of files and display each file in a separate panel
|
|
|
|
function listItems() {
|
|
|
|
totalSize = 0;
|
2023-05-23 23:30:37 +08:00
|
|
|
itemsNames = {};
|
|
|
|
|
|
|
|
saveItemsNames();
|
|
|
|
|
2019-07-26 00:00:24 +08:00
|
|
|
$('.panel-result-attachment-new').remove();
|
|
|
|
if (droppedFiles.length < 1) {
|
|
|
|
disableSubmitButton();
|
|
|
|
} else {
|
|
|
|
dragNdropAssetsOff();
|
|
|
|
|
|
|
|
for (let i = 0; i < droppedFiles.length; i += 1) {
|
|
|
|
$('#new-result-assets-select')
|
|
|
|
.after(uploadedAssetPreview(droppedFiles[i], i))
|
|
|
|
.promise()
|
|
|
|
.done(function() {
|
2023-05-23 23:30:37 +08:00
|
|
|
const uuid = droppedFiles[i].uuid;
|
|
|
|
removeItemHandler(uuid);
|
|
|
|
restoreItemName(uuid);
|
2023-05-16 15:34:36 +08:00
|
|
|
$('.panel-result-attachment-new').on('change', 'input[rel="results[name]"]', function() {
|
|
|
|
DragNDropResults.validateTextSize(this);
|
|
|
|
});
|
2019-07-26 00:00:24 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
validateTotalSize();
|
2022-10-24 19:07:10 +08:00
|
|
|
dragNdropAssetsInit();
|
2023-05-31 15:08:16 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
$('.file-name-field').focus();
|
|
|
|
}, 200);
|
2019-07-26 00:00:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function init(files) {
|
2019-08-06 21:06:19 +08:00
|
|
|
fileMaxSizeMb = GLOBAL_CONSTANTS.FILE_MAX_SIZE_MB;
|
2019-07-26 00:00:24 +08:00
|
|
|
fileMaxSize = fileMaxSizeMb * 1024 * 1024;
|
2020-02-12 21:13:09 +08:00
|
|
|
|
2019-07-26 00:00:24 +08:00
|
|
|
for (let i = 0; i < files.length; i += 1) {
|
2020-02-12 21:13:09 +08:00
|
|
|
files[i].uuid = Math.random().toString(36);
|
2020-02-12 03:08:36 +08:00
|
|
|
droppedFiles.unshift(files[i]);
|
2019-07-26 00:00:24 +08:00
|
|
|
}
|
|
|
|
listItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
return Object.freeze({
|
|
|
|
init: init,
|
|
|
|
listItems: listItems,
|
|
|
|
destroyAll: destroyAll,
|
|
|
|
filesStatus: filesStatus,
|
|
|
|
validateTextSize: validateTextSize,
|
|
|
|
processResult: processResult
|
|
|
|
});
|
|
|
|
}());
|
|
|
|
|
2022-10-24 19:07:10 +08:00
|
|
|
global.dragNdropAssetsInit = function() {
|
2019-07-26 00:00:24 +08:00
|
|
|
var inWindow = true;
|
|
|
|
|
|
|
|
$('body')
|
|
|
|
.on('drag dragstart dragend dragover dragenter dragleave drop', (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
})
|
|
|
|
.on('dragover', function() {
|
|
|
|
inWindow = true;
|
|
|
|
$('.is-dragover').show();
|
|
|
|
})
|
|
|
|
.on('dragleave', function() {
|
|
|
|
inWindow = false;
|
|
|
|
setTimeout(function() {
|
|
|
|
if (!inWindow) {
|
|
|
|
$('.is-dragover').hide();
|
|
|
|
}
|
|
|
|
}, 5000);
|
|
|
|
})
|
|
|
|
.on('drop', function(e) {
|
|
|
|
$('.is-dragover').hide();
|
|
|
|
let files = e.originalEvent.dataTransfer.files;
|
2022-10-24 19:07:10 +08:00
|
|
|
DragNDropResults.init(files);
|
2019-07-26 00:00:24 +08:00
|
|
|
});
|
|
|
|
|
2022-10-24 19:07:10 +08:00
|
|
|
copyFromClipboard.init();
|
2019-07-26 00:00:24 +08:00
|
|
|
};
|
|
|
|
}(window));
|