inventree.js

This commit is contained in:
Oliver Walters 2021-08-30 14:49:40 +10:00
parent 90a75ac7cb
commit 00f012311d

View File

@ -1,5 +1,20 @@
{% load inventree_extras %}
/* globals
ClipboardJS,
inventreeFormDataUpload,
launchModalForm,
user_settings,
*/
/* exported
attachClipboard,
enableDragAndDrop,
inventreeDocReady,
inventreeLoad,
inventreeSave,
*/
function attachClipboard(selector, containerselector, textElement) {
// set container
if (containerselector){
@ -8,6 +23,8 @@ function attachClipboard(selector, containerselector, textElement) {
containerselector = document.body;
}
var text = null;
// set text-function
if (textElement){
text = function() {
@ -21,6 +38,7 @@ function attachClipboard(selector, containerselector, textElement) {
}
// create Clipboard
// eslint-disable-next-line no-unused-vars
var cis = new ClipboardJS(selector, {
text: text,
container: containerselector
@ -51,12 +69,13 @@ function inventreeDocReady() {
// TODO - Only indicate that a drop event will occur if a file is being dragged
var transfer = event.originalEvent.dataTransfer;
// eslint-disable-next-line no-constant-condition
if (true || isFileTransfer(transfer)) {
$(this).addClass('dragover');
}
});
$('.dropzone').on('dragleave drop', function(event) {
$('.dropzone').on('dragleave drop', function() {
$(this).removeClass('dragover');
});
@ -154,7 +173,7 @@ function enableDragAndDrop(element, url, options) {
method - HTTP method
*/
data = options.data || {};
var data = options.data || {};
$(element).on('drop', function(event) {