diff --git a/etemplate/js/et2_widget_file.js b/etemplate/js/et2_widget_file.js index 8daf7b5e99..1783e2b1b9 100644 --- a/etemplate/js/et2_widget_file.js +++ b/etemplate/js/et2_widget_file.js @@ -46,6 +46,18 @@ var et2_file = et2_inputWidget.extend({ "type": "string", "default": et2_no_init, "description": "The ID of an alternate node (div) to display progress and results." + }, + "onStart": { + "name": "Start event handler", + "type": "any", + "default": et2_no_init, + "description": "A (js) function called when an upload starts. Return true to continue with upload, false to cancel." + }, + "onFinish": { + "name": "Finish event handler", + "type": "any", + "default": et2_no_init, + "description": "A (js) function called when all files to be uploaded are finished." } }, @@ -142,6 +154,9 @@ var et2_file = et2_inputWidget.extend({ */ onStart: function(event, file_count) { this.disabled_buttons = $j("input[type='submit'], button").not("[disabled]").attr("disabled", true); + + event.data = this; + if(this.options.onStart && typeof this.options.onStart == 'function') return this.options.onStart(event,file_count); return true; }, @@ -150,6 +165,8 @@ var et2_file = et2_inputWidget.extend({ */ onFinish: function(event, file_count) { this.disabled_buttons.attr("disabled", false); + event.data = this; + if(this.options.onFinish && typeof this.options.onFinish == 'function') return this.options.onFinish(event,file_count); }, @@ -169,8 +186,8 @@ var et2_file = et2_inputWidget.extend({ { var status = $j("