diff --git a/wcs/qommon/static/js/qommon.fileupload.js b/wcs/qommon/static/js/qommon.fileupload.js index b8febec26..13868e25f 100644 --- a/wcs/qommon/static/js/qommon.fileupload.js +++ b/wcs/qommon/static/js/qommon.fileupload.js @@ -1,13 +1,13 @@ -$(function() { - $('.file-upload-widget').each(function() { +$.WcsFileUpload = { + prepare: function() { var base_widget = $(this); if ($(base_widget).find('input[type=hidden]').val()) { $(base_widget).find('input[type=file]').hide(); $(base_widget).find('.use-file-from-fargo').hide(); - $(this).addClass('has-file'); + $(base_widget).addClass('has-file'); } else { $(base_widget).find('.fileinfo').hide(); - $(this).addClass('has-no-file'); + $(base_widget).addClass('has-no-file'); } $(this).find('input[type=file]').fileupload({ dropZone: base_widget, @@ -57,5 +57,9 @@ $(function() { $(base_widget).find('input[type=file]').click(); return false; }); - }); + } +} + +$(function() { + $('.file-upload-widget').each($.WcsFileUpload.prepare); });