浏览代码

Just some minor work on file dropping.

dev-bank
Bryan Miller 6 年前
父节点
当前提交
1e47e836dd
共有 2 个文件被更改,包括 28 次插入0 次删除
  1. +25
    -0
      app/js/ctrls/CTRLIO.js
  2. +3
    -0
      app/js/main.js

+ 25
- 0
app/js/ctrls/CTRLIO.js 查看文件

import NESPalette from "/app/js/models/NESPalette.js"; import NESPalette from "/app/js/models/NESPalette.js";





function HANDLE_DragOver(e){
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
};

function HANDLE_FileDrop(e){
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files;

for (let i=0; i < files.length; i++){
console.log(files[i]);
}
}

class CTRLIO{ class CTRLIO{
constructor(){} constructor(){}

initialize(){
var e = document.querySelectorAll(".drop-zone");
for (let i=0; i < e.length; e++){
e[i].addEventListener("dragover", HANDLE_DragOver);
e[i].addEventListener("drop", HANDLE_FileDrop);
}
}
} }





+ 3
- 0
app/js/main.js 查看文件

import CTRLPalettesStore from "/app/js/ctrls/CTRLPalettesStore.js"; import CTRLPalettesStore from "/app/js/ctrls/CTRLPalettesStore.js";
import CTRLBanksStore from "/app/js/ctrls/CTRLBanksStore.js"; import CTRLBanksStore from "/app/js/ctrls/CTRLBanksStore.js";
import CTRLBankTools from "/app/js/ctrls/CTRLBankTools.js"; import CTRLBankTools from "/app/js/ctrls/CTRLBankTools.js";
import CTRLIO from "/app/js/ctrls/CTRLIO.js";


import NESPalette from "/app/js/models/NESPalette.js"; import NESPalette from "/app/js/models/NESPalette.js";




CTRLPalettesStore.initialize(); CTRLPalettesStore.initialize();
CTRLBanksStore.initialize(); CTRLBanksStore.initialize();

CTRLIO.initialize();
} }





正在加载...
取消
保存