Browse Source

Pull request #2279: REPORT-56417 提供通过FileList对象上传文件的接口

Merge in VISUAL/fineui from ~TELLER/fineui:datatransfer to master

* commit 'a4592af5b1f673f639dad3678787ef8f2b4ef4ee':
  REPORT-56417 feat: 提供通过dataTransfer对象上传文件的接口
es6
Teller 3 years ago
parent
commit
083e66bcb1
  1. 6
      src/base/single/editor/editor.multifile.js
  2. 10
      src/base/single/input/file.js
  3. 15
      src/polyfill/event.js
  4. 2
      typescript/widget/editor/editor.multifile.ts

6
src/base/single/editor/editor.multifile.js

@ -91,6 +91,12 @@ BI.MultifileEditor = BI.inherit(BI.Widget, {
this.file.upload();
},
sendFiles: function (files) {
this._reset();
this.file.sendFiles(files);
},
reset: function () {
this._reset();
}

10
src/base/single/input/file.js

@ -683,6 +683,16 @@
}
},
sendFiles: function (files) {
if (!this.wrap) return;
this.wrap.dom.input.files = files;
var event = new CustomEvent("change");
this.wrap.dom.input.dispatchEvent(event);
},
_setEnable: function (enable) {
BI.File.superclass._setEnable.apply(this, arguments);
if (enable === true) {

15
src/polyfill/event.js

@ -0,0 +1,15 @@
(function () {
if (typeof window.CustomEvent === "function") return false; // If not IE
function CustomEvent (event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent("CustomEvent");
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
}());

2
typescript/widget/editor/editor.multifile.ts

@ -30,4 +30,6 @@ export declare class MultifileEditor extends Widget {
size: number;
type: string;
}[];
sendFiles(files: FileList): void;
}

Loading…
Cancel
Save