groups/modules/commons/commons_media/commons_media_autoupload.js
Marton Kiss 8ac59801be Refactor commons build process
Update commons modules to release 7.12, and move the codebase under
modules/commons instead of constant fetching from remote repository.
The commons.make file removed so it is not required to rebuild
groups distribution.

Change-Id: I3be393ba1af34427e2915b18ab1ad718fd4e54db
2014-05-28 15:58:33 +02:00

21 lines
640 B
JavaScript

(function ($) {
Drupal.behaviors.autoUpload = {
attach: function (context, settings) {
// Loop through all of the managed file form elements on the page.
$('.form-managed-file').each(function(index, element) {
// Hide/show the file upload/remove button if a file is not present.
if ($(this).children('span.file').length == 0 ) {
$(this).children('input.form-submit').hide();
};
// Automatically upload the file if a file is selected.
$(this).delegate('input.form-file', 'change', function() {
$(this).siblings('input.form-submit').mousedown();
});
});
}
};
})(jQuery);