From e26ac5563e0d6391558688190fe840c774d14521 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 25 Jan 2017 10:28:10 +0100 Subject: [PATCH] Add accept attributes for widget File in order to be able to filter extensions in upload dialog --- api/js/etemplate/et2_widget_file.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/js/etemplate/et2_widget_file.js b/api/js/etemplate/et2_widget_file.js index 00786f8d79..dc869bb34a 100644 --- a/api/js/etemplate/et2_widget_file.js +++ b/api/js/etemplate/et2_widget_file.js @@ -88,6 +88,12 @@ var et2_file = (function(){ "use strict"; return et2_inputWidget.extend( "type": "any", "default": et2_no_init, "description": "A (js) function called when a file to be uploaded is finished." + }, + accept: { + "name": "Acceptable extensions", + "type": "string", + "default": '', + "description": "Define types of files that the server accepts. Multiple types can be seperated by comma and the default is to accept everything." } }, @@ -180,6 +186,7 @@ var et2_file = (function(){ "use strict"; return et2_inputWidget.extend( jQuery(span).removeClass('et2_file_spanActive'); } }); + if (this.options.accept) this.input.attr('accept', this.options.accept); var self = this; // trigger native input upload file if (!this.options.readonly) this.span.click(function(){self.input.click()});