diff --git a/src/base/single/editor/editor.multifile.js b/src/base/single/editor/editor.multifile.js index 68b5bcc2e..1175d01c7 100644 --- a/src/base/single/editor/editor.multifile.js +++ b/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(); } diff --git a/src/base/single/input/file.js b/src/base/single/input/file.js index fa589681b..904fbfcf5 100644 --- a/src/base/single/input/file.js +++ b/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) { diff --git a/src/polyfill/event.js b/src/polyfill/event.js new file mode 100644 index 000000000..346ec16c8 --- /dev/null +++ b/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; +}()); diff --git a/typescript/widget/editor/editor.multifile.ts b/typescript/widget/editor/editor.multifile.ts index 3a29e0960..905d423e6 100644 --- a/typescript/widget/editor/editor.multifile.ts +++ b/typescript/widget/editor/editor.multifile.ts @@ -30,4 +30,6 @@ export declare class MultifileEditor extends Widget { size: number; type: string; }[]; + + sendFiles(files: FileList): void; }