/* ======================================================================== * Bootstrap (plugin): validator.js v0.10.2 * ======================================================================== * The MIT License (MIT) * * Copyright (c) 2015 Cina Saffary. * Made by @1000hz in the style of Bootstrap 3 era @fat * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * ======================================================================== */ +function(t){"use strict";function e(e){return e.is('[type="checkbox"]')?e.prop("checked"):e.is('[type="radio"]')?!!t('[name="'+e.attr("name")+'"]:checked').length:t.trim(e.val())}function r(e){return this.each(function(){var r=t(this),o=t.extend({},a.DEFAULTS,r.data(),"object"==typeof e&&e),i=r.data("bs.validator");(i||"destroy"!=e)&&(i||r.data("bs.validator",i=new a(this,o)),"string"==typeof e&&i[e]())})}var a=function(r,o){this.options=o,this.$element=t(r),this.$inputs=this.$element.find(a.INPUT_SELECTOR),this.$btn=t('button[type="submit"], input[type="submit"]').filter('[form="'+this.$element.attr("id")+'"]').add(this.$element.find('input[type="submit"], button[type="submit"]')),o.errors=t.extend({},a.DEFAULTS.errors,o.errors);for(var i in o.custom)if(!o.errors[i])throw new Error("Missing default error message for custom validator: "+i);t.extend(a.VALIDATORS,o.custom),this.$element.attr("novalidate",!0),this.toggleSubmit(),this.$element.on("input.bs.validator change.bs.validator focusout.bs.validator",a.INPUT_SELECTOR,t.proxy(this.onInput,this)),this.$element.on("submit.bs.validator",t.proxy(this.onSubmit,this)),this.$element.find("[data-match]").each(function(){var r=t(this),a=r.data("match");t(a).on("input.bs.validator",function(t){e(r)&&r.trigger("input.bs.validator")})})};a.INPUT_SELECTOR=':input:not([type="submit"], button):enabled:visible',a.FOCUS_OFFSET=20,a.DEFAULTS={delay:500,html:!1,disable:!0,focus:!0,custom:{},errors:{match:"Does not match",minlength:"Not long enough"},feedback:{success:"glyphicon-ok",error:"glyphicon-remove"}},a.VALIDATORS={"native":function(t){var e=t[0];return e.checkValidity?e.checkValidity():!0},match:function(e){var r=e.data("match");return!e.val()||e.val()===t(r).val()},minlength:function(t){var e=t.data("minlength");return!t.val()||t.val().length>=e}},a.prototype.onInput=function(e){var r=this,a=t(e.target),o="focusout"!==e.type;this.validateInput(a,o).done(function(){r.toggleSubmit()})},a.prototype.validateInput=function(r,a){var o=e(r),i=r.data("bs.validator.previous"),s=r.data("bs.validator.errors");if(i===o)return t.Deferred().resolve();r.data("bs.validator.previous",o),r.is('[type="radio"]')&&(r=this.$element.find('input[name="'+r.attr("name")+'"]'));var n=t.Event("validate.bs.validator",{relatedTarget:r[0]});if(this.$element.trigger(n),!n.isDefaultPrevented()){var d=this;return this.runValidators(r).done(function(e){r.data("bs.validator.errors",e),e.length?a?d.defer(r,d.showErrors):d.showErrors(r):d.clearErrors(r),s&&e.toString()===s.toString()||(n=e.length?t.Event("invalid.bs.validator",{relatedTarget:r[0],detail:e}):t.Event("valid.bs.validator",{relatedTarget:r[0],detail:s}),d.$element.trigger(n)),d.toggleSubmit(),d.$element.trigger(t.Event("validated.bs.validator",{relatedTarget:r[0]}))})}},a.prototype.runValidators=function(r){function o(t){return r.data(t+"-error")||r.data("error")||"native"==t&&r[0].validationMessage||n.errors[t]}var i=[],s=t.Deferred(),n=this.options;return r.data("bs.validator.deferred")&&r.data("bs.validator.deferred").reject(),r.data("bs.validator.deferred",s),t.each(a.VALIDATORS,t.proxy(function(t,a){if((e(r)||r.attr("required"))&&(r.data(t)||"native"==t)&&!a.call(this,r)){var s=o(t);!~i.indexOf(s)&&i.push(s)}},this)),!i.length&&e(r)&&r.data("remote")?this.defer(r,function(){var a={};a[r.attr("name")]=e(r),t.get(r.data("remote"),a).fail(function(t,e,r){i.push(o("remote")||r)}).always(function(){s.resolve(i)})}):s.resolve(i),s.promise()},a.prototype.validate=function(){var e=this;return t.when(this.$inputs.map(function(r){return e.validateInput(t(this),!1)})).then(function(){e.toggleSubmit(),e.focusError()}),this},a.prototype.focusError=function(){if(this.options.focus){var e=t(".has-error:first :input");0!==e.length&&(t(document.body).animate({scrollTop:e.offset().top-a.FOCUS_OFFSET},250),e.focus())}},a.prototype.showErrors=function(e){var r=this.options.html?"html":"text",a=e.data("bs.validator.errors"),o=e.closest(".form-group"),i=o.find(".help-block.with-errors"),s=o.find(".form-control-feedback");a.length&&(a=t("