diff --git a/yui/build/moodle-atto_filedragdrop-button/moodle-atto_filedragdrop-button-debug.js b/yui/build/moodle-atto_filedragdrop-button/moodle-atto_filedragdrop-button-debug.js index 110c2ce..129de4f 100644 --- a/yui/build/moodle-atto_filedragdrop-button/moodle-atto_filedragdrop-button-debug.js +++ b/yui/build/moodle-atto_filedragdrop-button/moodle-atto_filedragdrop-button-debug.js @@ -81,6 +81,7 @@ Y.namespace('M.atto_filedragdrop').Button = Y.Base.create('button', Y.M.editor_a var handlesDataTransfer = (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length); // @codingStandardsIgnoreLine if (handlesDataTransfer && !/^image\//.test(e.dataTransfer.files[0].type)) { + self.notifyUploadStarted(); var options = host.get('filepickeroptions').link, savepath = (options.savepath === undefined) ? '/' : options.savepath, formData = new FormData(), @@ -135,6 +136,7 @@ Y.namespace('M.atto_filedragdrop').Button = Y.Base.create('button', Y.M.editor_a if (placeholder) { placeholder.remove(true); } + self.notifyUploadCompleted(); return new M.core.ajaxException(result); } @@ -160,6 +162,7 @@ Y.namespace('M.atto_filedragdrop').Button = Y.Base.create('button', Y.M.editor_a self.markUpdated(); } } else { + self.notifyUploadCompleted(); Y.use('moodle-core-notification-alert', function() { new M.core.alert({message: M.util.get_string('servererror', 'moodle')}); }); @@ -167,12 +170,41 @@ Y.namespace('M.atto_filedragdrop').Button = Y.Base.create('button', Y.M.editor_a placeholder.remove(true); } } + self.notifyUploadCompleted(); } }; xhr.open("POST", M.cfg.wwwroot + '/repository/repository_ajax.php?action=upload', true); xhr.send(formData); return false; } + }, + + /** + * Trigger form upload complete events. + */ + notifyUploadCompleted: function() { + var self = this; + if (require.specified('core_form/events')) { + require(['core_form/events'], function(FormEvent) { + if (typeof(FormEvent.triggerUploadCompleted) !== "undefined") { + FormEvent.triggerUploadCompleted(self.editor.get('id')); + } + }); + } + }, + + /** + * Trigger form upload start events. + */ + notifyUploadStarted: function() { + var self = this; + if (require.specified('core_form/events')) { + require(['core_form/events'], function(FormEvent) { + if (typeof(FormEvent.triggerUploadStarted) !== "undefined") { + FormEvent.triggerUploadStarted(self.editor.get('id')); + } + }); + } } }); diff --git a/yui/build/moodle-atto_filedragdrop-button/moodle-atto_filedragdrop-button-min.js b/yui/build/moodle-atto_filedragdrop-button/moodle-atto_filedragdrop-button-min.js index 2a9d856..1239ffb 100644 --- a/yui/build/moodle-atto_filedragdrop-button/moodle-atto_filedragdrop-button-min.js +++ b/yui/build/moodle-atto_filedragdrop-button/moodle-atto_filedragdrop-button-min.js @@ -1 +1 @@ -YUI.add("moodle-atto_filedragdrop-button",function(e,t){var n="atto_filedragdrop",r='{{text}}',i='';e.namespace("M.atto_filedragdrop").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,initializer:function(){this.editor.on("drop",this._handleDragDrop,this)},_handleDragDrop:function(t){var s=this,o=this.get("host"),u=e.Handlebars.compile(r),a=e.Handlebars.compile(i);o.saveSelection(),t=t._event;var f=t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length;if(f&&!/^image\//.test(t.dataTransfer.files[0].type)){var l=o.get("filepickeroptions").link,c=l.savepath===undefined?"/":l.savepath,h=new FormData,p=0,d="",v=new XMLHttpRequest,m="",g=Object.keys(l.repositories);t.preventDefault(),t.stopPropagation(),h.append("repo_upload_file",t.dataTransfer.files[0]),h.append("itemid",l.itemid);for(var y=0;y{{text}}'),c=g.Handlebars.compile('');if(f.saveSelection(),(e=e._event).dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length&&!/^image\//.test(e.dataTransfer.files[0].type)){for(s.notifyUploadStarted(),i=(t=f.get("filepickeroptions").link).savepath===undefined?"/":t.savepath,o=new FormData,r=0,a="",n=new XMLHttpRequest,d="",l=Object.keys(t.repositories),e.preventDefault(),e.stopPropagation(),o.append("repo_upload_file",e.dataTransfer.files[0]),o.append("itemid",t.itemid),p=0;p