| 1 |
// $Id: video_upload.js,v 1.3 2008/05/26 17:05:36 jhedstrom Exp $
|
| 2 |
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* jquery for Video Upload module
|
| 6 |
*/
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Attach validation behavior to the form
|
| 10 |
*/
|
| 11 |
Drupal.behaviors.videoUploadValidateAccept = function() {
|
| 12 |
/**
|
| 13 |
* Client-side validation of the input (if type = file) accept
|
| 14 |
* attribute
|
| 15 |
*/
|
| 16 |
$("input[@type='file'].video-upload").change(function() {
|
| 17 |
Drupal.videoUploadValidateFile(this)
|
| 18 |
});
|
| 19 |
}
|
| 20 |
|
| 21 |
/**
|
| 22 |
* Attempt to validate file type based on the attach attribute of the
|
| 23 |
* file tag
|
| 24 |
*/
|
| 25 |
Drupal.videoUploadValidateFile = function(file) {
|
| 26 |
$('.video-upload-js-error').remove();
|
| 27 |
if (file.accept.length > 1){
|
| 28 |
acc = new RegExp('\\.(' + (file.accept ? file.accept : '') + ')$','gi');
|
| 29 |
if (!acc.test(file.value)) {
|
| 30 |
alert('The file ' + file.value + ' does not appear to be a video file.\n'
|
| 31 |
+ 'Please use a video file with one of these extensions: \n' + file.accept.replace(/\|/g, ', ')
|
| 32 |
);
|
| 33 |
file.value = '';
|
| 34 |
return false;
|
| 35 |
}
|
| 36 |
}
|
| 37 |
return true;
|
| 38 |
};
|