bootstrapValidator.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /**
  2. * BootstrapValidator v0.1.0 (http://github.com/nghuuphuoc/bootstrapvalidator)
  3. *
  4. * A jQuery plugin to validate form fields. Use with Bootstrap 3
  5. *
  6. * @author Nguyen Huu Phuoc <phuoc@huuphuoc.me>
  7. * @copyright (c) 2013 Nguyen Huu Phuoc
  8. * @license MIT
  9. */
  10. (function($) {
  11. var BootstrapValidator = function(form, options) {
  12. this.$form = $(form);
  13. this.options = $.extend({}, BootstrapValidator.DEFAULT_OPTIONS, options);
  14. this.invalidFields = {};
  15. this.xhrRequests = {};
  16. this.numPendingRequests = null;
  17. this.formSubmited = false;
  18. this._init();
  19. };
  20. // The default options
  21. BootstrapValidator.DEFAULT_OPTIONS = {
  22. // The form CSS class
  23. elementClass: 'bootstrap-validator-form',
  24. // Default invalid message
  25. message: 'This value is not valid',
  26. // The submit buttons selector
  27. // These buttons will be disabled when the form input are invalid
  28. submitButtons: 'button[type="submit"]',
  29. // Map the field name with validator rules
  30. fields: null
  31. };
  32. BootstrapValidator.prototype = {
  33. constructor: BootstrapValidator,
  34. /**
  35. * Init form
  36. */
  37. _init: function() {
  38. if (this.options.fields == null) {
  39. return;
  40. }
  41. var that = this;
  42. this.$form
  43. .addClass(this.options.elementClass)
  44. .on('submit', function(e) {
  45. that.formSubmited = true;
  46. if (that.options.fields) {
  47. for (var field in that.options.fields) {
  48. if (that.numPendingRequests > 0 || that.numPendingRequests == null) {
  49. // Check if the field is valid
  50. var $field = that.getFieldElement(field);
  51. if ($field.data('bootstrapValidator.isValid') !== true) {
  52. that.validateField(field);
  53. }
  54. }
  55. }
  56. if (!that.isValid()) {
  57. that.$form.find(that.options.submitButtons).attr('disabled', 'disabled');
  58. e.preventDefault();
  59. }
  60. }
  61. });
  62. for (var field in this.options.fields) {
  63. this._initField(field);
  64. }
  65. },
  66. /**
  67. * Init field
  68. *
  69. * @param {String} field The field name
  70. */
  71. _initField: function(field) {
  72. if (this.options.fields[field] == null || this.options.fields[field].validators == null) {
  73. return;
  74. }
  75. var $field = this.getFieldElement(field);
  76. if (null == $field) {
  77. return;
  78. }
  79. // Create a help block element for showing the error
  80. var that = this,
  81. $parent = $field.parents('.form-group'),
  82. helpBlock = $parent.find('.help-block');
  83. if (helpBlock.length == 0) {
  84. var $small = $('<small/>').addClass('help-block').appendTo($parent);
  85. $field.data('bootstrapValidator.error', $small);
  86. // Calculate the number of columns of the label/field element
  87. // Then set offset to the help block element
  88. var label, cssClasses, offset;
  89. if (label = $parent.find('label').get(0)) {
  90. cssClasses = $(label).attr('class').split(' ');
  91. for (var i = 0; i < cssClasses.length; i++) {
  92. if (cssClasses[i].substr(0, 7) == 'col-lg-') {
  93. offset = cssClasses[i].substr(7);
  94. break;
  95. }
  96. }
  97. } else {
  98. cssClasses = $parent.children().eq(0).attr('class').split(' ');
  99. for (var i = 0; i < cssClasses.length; i++) {
  100. if (cssClasses[i].substr(0, 14) == 'col-lg-offset-') {
  101. offset = cssClasses[i].substr(14);
  102. break;
  103. }
  104. }
  105. }
  106. $small.addClass('col-lg-offset-' + offset).addClass('col-lg-' + parseInt(12 - offset));
  107. } else {
  108. $field.data('bootstrapValidator.error', helpBlock.eq(0));
  109. }
  110. var type = $field.attr('type'),
  111. event = ('checkbox' == type || 'radio' == type) ? 'change' : 'keyup';
  112. $field.on(event, function() {
  113. that.formSubmited = false;
  114. that.validateField(field);
  115. });
  116. },
  117. /**
  118. * Get field element
  119. *
  120. * @param {String} field The field name
  121. * @returns {jQuery}
  122. */
  123. getFieldElement: function(field) {
  124. var fields = this.$form.find('[name="' + field + '"]');
  125. return (fields.length == 0) ? null : $(fields[0]);
  126. },
  127. /**
  128. * Validate given field
  129. *
  130. * @param {String} field The field name
  131. */
  132. validateField: function(field) {
  133. var $field = this.getFieldElement(field);
  134. if (null == $field) {
  135. // Return if cannot find the field with given name
  136. return;
  137. }
  138. var that = this,
  139. validators = that.options.fields[field].validators;
  140. for (var validatorName in validators) {
  141. if (!$.fn.bootstrapValidator.validators[validatorName]) {
  142. continue;
  143. }
  144. var isValid = $.fn.bootstrapValidator.validators[validatorName].validate(that, $field, validators[validatorName]);
  145. if (isValid === false) {
  146. that.showError($field, validatorName);
  147. break;
  148. } else if (isValid === true) {
  149. that.removeError($field);
  150. }
  151. }
  152. },
  153. /**
  154. * Show field error
  155. *
  156. * @param {jQuery} $field The field element
  157. * @param {String} validatorName
  158. */
  159. showError: function($field, validatorName) {
  160. var field = $field.attr('name'),
  161. validator = this.options.fields[field].validators[validatorName],
  162. message = validator.message || this.options.message,
  163. $parent = $field.parents('.form-group');
  164. this.invalidFields[field] = true;
  165. // Add has-error class to parent element
  166. $parent.removeClass('has-success').addClass('has-error');
  167. $field.data('bootstrapValidator.error').html(message).show();
  168. this.$form.find(this.options.submitButtons).attr('disabled', 'disabled');
  169. },
  170. /**
  171. * Remove error from given field
  172. *
  173. * @param {jQuery} $field The field element
  174. */
  175. removeError: function($field) {
  176. delete this.invalidFields[$field.attr('name')];
  177. $field.parents('.form-group').removeClass('has-error').addClass('has-success');
  178. $field.data('bootstrapValidator.error').hide();
  179. this.$form.find(this.options.submitButtons).removeAttr('disabled');
  180. },
  181. /**
  182. * Start remote checking
  183. *
  184. * @param {jQuery} $field The field element
  185. * @param {String} validatorName
  186. * @param {XMLHttpRequest} xhr
  187. */
  188. startRequest: function($field, validatorName, xhr) {
  189. var field = $field.attr('name');
  190. $field.data('bootstrapValidator.isValid', false);
  191. this.$form.find(this.options.submitButtons).attr('disabled', 'disabled');
  192. if(this.numPendingRequests == null){
  193. this.numPendingRequests = 0;
  194. }
  195. this.numPendingRequests++;
  196. // Abort the previous request
  197. if (!this.xhrRequests[field]) {
  198. this.xhrRequests[field] = {};
  199. }
  200. if (this.xhrRequests[field][validatorName]) {
  201. this.numPendingRequests--;
  202. this.xhrRequests[field][validatorName].abort();
  203. }
  204. this.xhrRequests[field][validatorName] = xhr;
  205. },
  206. /**
  207. * Complete remote checking
  208. *
  209. * @param {jQuery} $field The field element
  210. * @param {String} validatorName
  211. * @param {boolean} isValid
  212. */
  213. completeRequest: function($field, validatorName, isValid) {
  214. if (isValid === false) {
  215. this.showError($field, validatorName);
  216. } else if (isValid === true) {
  217. this.removeError($field);
  218. $field.data('bootstrapValidator.isValid', true);
  219. }
  220. var field = $field.attr('name');
  221. delete this.xhrRequests[field][validatorName];
  222. this.numPendingRequests--;
  223. if (this.numPendingRequests <= 0) {
  224. this.numPendingRequests = 0;
  225. if (this.formSubmited) {
  226. this.$form.submit();
  227. }
  228. }
  229. },
  230. /**
  231. * Check the form validity
  232. *
  233. * @returns {boolean}
  234. */
  235. isValid: function() {
  236. if (this.numPendingRequests > 0) {
  237. return false;
  238. }
  239. for (var field in this.invalidFields) {
  240. if (this.invalidFields[field]) {
  241. return false;
  242. }
  243. }
  244. return true;
  245. }
  246. };
  247. // Plugin definition
  248. $.fn.bootstrapValidator = function(options) {
  249. return this.each(function() {
  250. var $this = $(this), data = $this.data('bootstrapValidator');
  251. if (!data) {
  252. $this.data('bootstrapValidator', (data = new BootstrapValidator(this, options)));
  253. }
  254. });
  255. };
  256. // Available validators
  257. $.fn.bootstrapValidator.validators = {};
  258. $.fn.bootstrapValidator.Constructor = BootstrapValidator;
  259. }(window.jQuery));
  260. ;(function($) {
  261. $.fn.bootstrapValidator.validators.between = {
  262. /**
  263. * Return true if the input value is between (strictly or not) two given numbers
  264. *
  265. * @param {BootstrapValidator} validator The validator plugin instance
  266. * @param {jQuery} $field Field element
  267. * @param {Object} options Can consist of the following keys:
  268. * - min
  269. * - max
  270. * - inclusive [optional]: Can be true or false. Default is true
  271. * - message: The invalid message
  272. * @returns {boolean}
  273. */
  274. validate: function(validator, $field, options) {
  275. var value = parseFloat($field.val());
  276. return (options.inclusive === true)
  277. ? (value > options.min && value < options.max)
  278. : (value >= options.min && value <= options.max);
  279. }
  280. };
  281. }(window.jQuery));
  282. ;(function($) {
  283. $.fn.bootstrapValidator.validators.digits = {
  284. /**
  285. * Return true if the input value contains digits only
  286. *
  287. * @param {BootstrapValidator} validator Validate plugin instance
  288. * @param {jQuery} $field Field element
  289. * @param {Object} options
  290. * @returns {boolean}
  291. */
  292. validate: function(validator, $field, options) {
  293. return /^\d+$/.test($field.val());
  294. }
  295. }
  296. }(window.jQuery));
  297. ;(function($) {
  298. $.fn.bootstrapValidator.validators.emailAddress = {
  299. /**
  300. * Return true if and only if the input value is a valid email address
  301. *
  302. * @param {BootstrapValidator} validator Validate plugin instance
  303. * @param {jQuery} $field Field element
  304. * @param {Object} options
  305. * @returns {boolean}
  306. */
  307. validate: function(validator, $field, options) {
  308. var value = $field.val(),
  309. // Email address regular expression
  310. // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
  311. emailRegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  312. return emailRegExp.test(value);
  313. }
  314. }
  315. }(window.jQuery));
  316. ;(function($) {
  317. $.fn.bootstrapValidator.validators.greaterThan = {
  318. /**
  319. * Return true if the input value is greater than or equals to given number
  320. *
  321. * @param {BootstrapValidator} validator Validate plugin instance
  322. * @param {jQuery} $field Field element
  323. * @param {Object} options Can consist of the following keys:
  324. * - value: The number used to compare to
  325. * - inclusive [optional]: Can be true or false. Default is true
  326. * - message: The invalid message
  327. * @returns {boolean}
  328. */
  329. validate: function(validator, $field, options) {
  330. var value = parseFloat($field.val());
  331. return (options.inclusive === true) ? (value > options.value) : (value >= options.value);
  332. }
  333. }
  334. }(window.jQuery));
  335. ;(function($) {
  336. $.fn.bootstrapValidator.validators.hexColor = {
  337. /**
  338. * Return true if the input value is a valid hex color
  339. *
  340. * @param {BootstrapValidator} validator The validator plugin instance
  341. * @param {jQuery} $field Field element
  342. * @param {Object} options Can consist of the following keys:
  343. * - message: The invalid message
  344. * @returns {boolean}
  345. */
  346. validate: function(validator, $field, options) {
  347. var value = $field.val();
  348. return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(value);
  349. }
  350. };
  351. }(window.jQuery));
  352. ;(function($) {
  353. $.fn.bootstrapValidator.validators.identical = {
  354. /**
  355. * Check if input value equals to value of particular one
  356. *
  357. * @param {BootstrapValidator} validator The validator plugin instance
  358. * @param {jQuery} $field Field element
  359. * @param {Object} options Consists of the following key:
  360. * - field: The name of field that will be used to compare with current one
  361. * @returns {boolean}
  362. */
  363. validate: function(validator, $field, options) {
  364. var value = $field.val(),
  365. $compareWith = validator.getFieldElement(options.field);
  366. if ($compareWith && value == $compareWith.val()) {
  367. validator.removeError($compareWith);
  368. return true;
  369. } else {
  370. return false;
  371. }
  372. }
  373. };
  374. }(window.jQuery));
  375. ;(function($) {
  376. $.fn.bootstrapValidator.validators.lessThan = {
  377. /**
  378. * Return true if the input value is less than or equal to given number
  379. *
  380. * @param {BootstrapValidator} validator The validator plugin instance
  381. * @param {jQuery} $field Field element
  382. * @param {Object} options Can consist of the following keys:
  383. * - value: The number used to compare to
  384. * - inclusive [optional]: Can be true or false. Default is true
  385. * - message: The invalid message
  386. * @returns {boolean}
  387. */
  388. validate: function(validator, $field, options) {
  389. var value = parseFloat($field.val());
  390. return (options.inclusive === true) ? (value < options.value) : (value <= options.value);
  391. }
  392. };
  393. }(window.jQuery));
  394. ;(function($) {
  395. $.fn.bootstrapValidator.validators.notEmpty = {
  396. /**
  397. * Check if input value is empty or not
  398. *
  399. * @param {BootstrapValidator} validator The validator plugin instance
  400. * @param {jQuery} $field Field element
  401. * @param {Object} options
  402. * @returns {boolean}
  403. */
  404. validate: function(validator, $field, options) {
  405. var type = $field.attr('type');
  406. return ('checkbox' == type || 'radio' == type) ? $field.is(':checked') : ($.trim($field.val()) != '');
  407. }
  408. };
  409. }(window.jQuery));
  410. ;(function($) {
  411. $.fn.bootstrapValidator.validators.regexp = {
  412. /**
  413. * Check if the element value matches given regular expression
  414. *
  415. * @param {BootstrapValidator} validator The validator plugin instance
  416. * @param {jQuery} $field Field element
  417. * @param {Object} options Consists of the following key:
  418. * - regexp: The regular expression you need to check
  419. * @returns {boolean}
  420. */
  421. validate: function(validator, $field, options) {
  422. var value = $field.val();
  423. return value.match(options.regexp);
  424. }
  425. };
  426. }(window.jQuery));
  427. ;(function($) {
  428. $.fn.bootstrapValidator.validators.remote = {
  429. /**
  430. * Request a remote server to check the input value
  431. *
  432. * @param {BootstrapValidator} validator Plugin instance
  433. * @param {jQuery} $field Field element
  434. * @param {Object} options Can consist of the following keys:
  435. * - url
  436. * - data [optional]: By default, it will take the value
  437. * {
  438. * <fieldName>: <fieldValue>
  439. * }
  440. * - message: The invalid message
  441. * @returns {string}
  442. */
  443. validate: function(validator, $field, options) {
  444. var value = $field.val(), name = $field.attr('name'), data = options.data;
  445. if (data == null) {
  446. data = {};
  447. data[name] = value;
  448. }
  449. var xhr = $.ajax({
  450. type: 'POST',
  451. url: options.url,
  452. dataType: 'json',
  453. data: data
  454. }).success(function(response) {
  455. var isValid = response.valid === true || response.valid === 'true';
  456. validator.completeRequest($field, 'remote', isValid);
  457. });
  458. validator.startRequest($field, 'remote', xhr);
  459. return 'pending';
  460. }
  461. };
  462. }(window.jQuery));
  463. ;(function($) {
  464. $.fn.bootstrapValidator.validators.stringLength = {
  465. /**
  466. * Check if the length of element value is less or more than given number
  467. *
  468. * @param {BootstrapValidator} validator The validator plugin instance
  469. * @param {jQuery} $field Field element
  470. * @param {Object} options Consists of following keys:
  471. * - min
  472. * - max
  473. * At least one of two keys is required
  474. * @returns {boolean}
  475. */
  476. validate: function(validator, $field, options) {
  477. var value = $.trim($field.val()), length = value.length;
  478. if ((options.min && length < options.min) || (options.max && length > options.max)) {
  479. return false;
  480. }
  481. return true;
  482. }
  483. };
  484. }(window.jQuery));
  485. ;(function($) {
  486. $.fn.bootstrapValidator.validators.uri = {
  487. /**
  488. * Return true if the input value is a valid URL
  489. *
  490. * @param {BootstrapValidator} validator The validator plugin instance
  491. * @param {jQuery} $field Field element
  492. * @param {Object} options
  493. * @returns {boolean}
  494. */
  495. validate: function(validator, $field, options) {
  496. // Credit to https://gist.github.com/dperini/729294
  497. //
  498. // Regular Expression for URL validation
  499. //
  500. // Author: Diego Perini
  501. // Updated: 2010/12/05
  502. //
  503. // the regular expression composed & commented
  504. // could be easily tweaked for RFC compliance,
  505. // it was expressly modified to fit & satisfy
  506. // these test for an URL shortener:
  507. //
  508. // http://mathiasbynens.be/demo/url-regex
  509. //
  510. // Notes on possible differences from a standard/generic validation:
  511. //
  512. // - utf-8 char class take in consideration the full Unicode range
  513. // - TLDs have been made mandatory so single names like "localhost" fails
  514. // - protocols have been restricted to ftp, http and https only as requested
  515. //
  516. // Changes:
  517. //
  518. // - IP address dotted notation validation, range: 1.0.0.0 - 223.255.255.255
  519. // first and last IP address of each class is considered invalid
  520. // (since they are broadcast/network addresses)
  521. //
  522. // - Added exclusion of private, reserved and/or local networks ranges
  523. //
  524. // Compressed one-line versions:
  525. //
  526. // Javascript version
  527. //
  528. // /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i
  529. //
  530. // PHP version
  531. //
  532. // _^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/[^\s]*)?$_iuS
  533. var urlExp = new RegExp(
  534. "^" +
  535. // protocol identifier
  536. "(?:(?:https?|ftp)://)" +
  537. // user:pass authentication
  538. "(?:\\S+(?::\\S*)?@)?" +
  539. "(?:" +
  540. // IP address exclusion
  541. // private & local networks
  542. "(?!10(?:\\.\\d{1,3}){3})" +
  543. "(?!127(?:\\.\\d{1,3}){3})" +
  544. "(?!169\\.254(?:\\.\\d{1,3}){2})" +
  545. "(?!192\\.168(?:\\.\\d{1,3}){2})" +
  546. "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" +
  547. // IP address dotted notation octets
  548. // excludes loopback network 0.0.0.0
  549. // excludes reserved space >= 224.0.0.0
  550. // excludes network & broacast addresses
  551. // (first & last IP address of each class)
  552. "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
  553. "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
  554. "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
  555. "|" +
  556. // host name
  557. "(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)" +
  558. // domain name
  559. "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*" +
  560. // TLD identifier
  561. "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
  562. ")" +
  563. // port number
  564. "(?::\\d{2,5})?" +
  565. // resource path
  566. "(?:/[^\\s]*)?" +
  567. "$", "i"
  568. );
  569. return urlExp.test($field.val());
  570. }
  571. };
  572. }(window.jQuery));
  573. ;(function($) {
  574. $.fn.bootstrapValidator.validators.usZipCode = {
  575. /**
  576. * Return true if and only if the input value is a valid US zip code
  577. *
  578. * @param {BootstrapValidator} validator The validator plugin instance
  579. * @param {jQuery} $field Field element
  580. * @param {Object} options
  581. * @returns {boolean}
  582. */
  583. validate: function(validateInstance, $field, options) {
  584. var value = $field.val();
  585. return /^\d{5}([\-]\d{4})?$/.test(value);
  586. }
  587. };
  588. }(window.jQuery));