diff --git a/filefield.js b/filefield.js
index 409565a3cd6b60f320e9890ca4bfb5f06d827283..1f8fc47c50e6a4eb1c61ac713630c33fc1da9df5 100644
--- a/filefield.js
+++ b/filefield.js
@@ -1,10 +1,10 @@
// $Id$
/**
- * Auto Attach standard client side file input validation
+ * Auto-attach standard client side file input validation.
*/
-Drupal.filefieldValidateAutoAttach = function() {
- $("input[@type='file']").change( function() {
+Drupal.behaviors.filefieldValidateAutoAttach = function(context) {
+ $("input[@type='file']", context).change( function() {
$('.filefield-js-error').remove();
/**
@@ -13,8 +13,9 @@ Drupal.filefieldValidateAutoAttach = function() {
if(this.accept.length > 1){
v = new RegExp('\\.(' + (this.accept ? this.accept : '') + ')$', 'gi');
if (!v.test(this.value)) {
- var error = 'The file ' + this.value + " is not supported.\n";
- error += "Only the following file types are supported: \n" + this.accept.replace(/\|/g, ' ');
+ var error = Drupal.t("The file @filename is not supported. \nOnly the following file types are supported: \n@extensions",
+ { '@filename' : this.value, '@extensions': this.accept.replace(/\|/g, ' ') }
+ );
alert(error);
// what do I prepend this to?
// .prepend($('
'));
@@ -29,9 +30,3 @@ Drupal.filefieldValidateAutoAttach = function() {
/* @todo */
});
}
-
-// Global killswitch
-if (Drupal.jsEnabled) {
- $(document).ready(Drupal.filefieldValidateAutoAttach);
-}
-
diff --git a/filefield.module b/filefield.module
index 8138cbe4294dd5556ba1482d789f500314429468..32191ac31baae03ca9b0383d8d8b3a2708e72f8f 100644
--- a/filefield.module
+++ b/filefield.module
@@ -349,9 +349,7 @@ function theme_filefield_container_item($element) {
function filefield_file_upload_form(&$form, &$form_state, $field, $delta, $item = NULL) {
$form['#attributes']['enctype'] = 'multipart/form-data';
- //drupal_add_js('misc/progress.js');
- //drupal_add_js('misc/upload.js');
- //drupal_add_js(drupal_get_path('module', 'filefield') .'/filefield.js');
+ drupal_add_js(drupal_get_path('module', 'filefield') .'/filefield.js');
$id = 'filefield-'. $field_name_css .'-'. $delta .'-form';
@@ -402,7 +400,7 @@ function filefield_file_upload_process($element, $edit, &$form_state, $form) {
'!size' => format_size(file_upload_max_size()),
));
if (!empty($field['widget']['file_extensions'])) {
- $upload_description .= ' ' . t('Allowed extensions: %ext.', array(
+ $upload_description .= ' ' . t('Allowed extensions: %ext', array(
'%ext' => $field['widget']['file_extensions'],
));
}