Setup UI - Support client-side validator (jQuery)
[civicrm-core.git] / setup / res / installer.js
CommitLineData
16d2d517
TO
1(function($){
2 /**
3 * Enable or disable an error message.
4 *
5 * <p id="my-error-message">The world is one fire.</p>
6 * Ex: $('#my-error-message').toggleError(false)
7 *
8 * @param bool isError
9 */
10 $.fn.toggleError = function (isError) {
11 this.toggleClass('install-validate-ok', !isError)
12 .toggleClass('install-validate-bad', isError)
13 .toggleClass('error', isError);
14
15 var errors = $('.install-validate-bad');
16 $('#install_button').prop('disabled', errors.length > 0);
17 return this;
18 };
19
20 /**
21 * Ex: $('.watch-these').useValidator(function(){
22 * $('#some-error-message').toggleError(booleanExpression);
23 * })
24 * @param cb
25 */
26 $.fn.useValidator = function(cb) {
27 cb();
28 this.on('change', cb);
29 return this;
30 };
31})($);