| 1 |
Drupal.behaviors.libraryCheckInput = function (context) {
|
| 2 |
$('input.form-autocomplete:not(.libraryCheckInput)', context).addClass('libraryCheckInput').bind('keyup blur', function() {
|
| 3 |
libraryCheckFile($(this));
|
| 4 |
});
|
| 5 |
};
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Checks if the current input is a valid filename.
|
| 9 |
*/
|
| 10 |
function libraryCheckFile(input) {
|
| 11 |
var basepath = Drupal.settings.basePath;
|
| 12 |
var input, value, type, status_image, status, extention;
|
| 13 |
|
| 14 |
value = input.val();
|
| 15 |
status_image = input.parents('tr').find('img');
|
| 16 |
type = input.parents('tr').find('td:eq(2)').text();
|
| 17 |
status_image.attr('src', basepath + Drupal.settings.jqp_module_path + '/loading.gif');
|
| 18 |
|
| 19 |
$.ajax({
|
| 20 |
url:basepath + 'jqp_ajax_check_file',
|
| 21 |
type:'post',
|
| 22 |
dataType:'json',
|
| 23 |
data:{path: value, type:type},
|
| 24 |
success:function (json) {
|
| 25 |
status = (json.result) ? 'ok' : 'warning';
|
| 26 |
|
| 27 |
if (json.result == true) {
|
| 28 |
extention = value.substr(value.lastIndexOf('.') + 1, value.length);
|
| 29 |
input.parents('tr').find('.form-select').val((extention == 'js' ? 'scripts' : 'stylesheets'));
|
| 30 |
};
|
| 31 |
input.parents('tr').removeClass('warning ok').addClass(status);
|
| 32 |
status_image.attr('src', basepath + 'misc/watchdog-' + status + '.png');
|
| 33 |
}
|
| 34 |
});
|
| 35 |
}
|