Commit ceb1d060 authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

Added Chosen support.

parent a13a0578
(function (Drupal, $) {
Drupal.behaviors.cvChosen = {
attach: function () {
$(document).bind('clientsideValidationAlterOptions', function (e, options, form_id) {
if (!Drupal.settings.clientsideValidation.forms[form_id].includeHidden) {
// Do not validate hidden fields. Fix chosen instances.
$('#' + form_id).find('select.chosen-processed').each(function () {
var $select = $(this);
// jQuery validate binds to the click event for selects, not the
// change event.
$select.bind('change', function() {
$(this).trigger('click');
})
var chosen = $select.data('chosen');
if(!chosen.container.is(':hidden')) {
options.ignore = fixIgnore(options.ignore, $select.attr('id'));
}
});
}
});
var fixIgnore = function (ignore, id) {
var ignores = ignore.split(',');
for (var i = 0; i < ignores.length; i++) {
ignores[i] += ':not(#' + id + ')';
}
return ignores.join(',');
};
}
};
})(Drupal, jQuery);
...@@ -40,6 +40,11 @@ function clientside_validation_js_alter(&$javascript) { ...@@ -40,6 +40,11 @@ function clientside_validation_js_alter(&$javascript) {
$javascript[$path . '/clientside_validation.ckeditor.js']['weight'] -= 0.001; $javascript[$path . '/clientside_validation.ckeditor.js']['weight'] -= 0.001;
$javascript[$path . '/clientside_validation.ckeditor.js']['data'] = $path . '/clientside_validation.ckeditor.js'; $javascript[$path . '/clientside_validation.ckeditor.js']['data'] = $path . '/clientside_validation.ckeditor.js';
} }
if (strpos($script, 'chosen') !== FALSE) {
$javascript[$path . '/clientside_validation.chosen.js'] = $javascript[$path. '/clientside_validation.js'];
$javascript[$path . '/clientside_validation.chosen.js']['weight'] -= 0.001;
$javascript[$path . '/clientside_validation.chosen.js']['data'] = $path . '/clientside_validation.chosen.js';
}
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment