');s&&r.add(o).addClass("ie"),e.css({position:"absolute",left:"-9999px"}),n.append(a,s?r:o).insertAfter(e),e.attr("tabIndex",-1),o.attr("tabIndex",-1),o.click(function(){e.focus().click()}),e.change(function(){var t,s,n=[];if(i){t=e[0].files;for(var o=0,r=t.length;r>o;o++)n.push(t[o].name);s=n.join(", ")}else s=e.val().split("\\").pop();a.val(s).attr("title",s)}),a.on({blur:function(){e.trigger("blur")},keydown:function(i){if(13===i.which)s||e.trigger("click"),t(this).closest("form").one("keydown",function(e){13===e.which&&e.preventDefault()});else{if(8!==i.which&&46!==i.which)return 9===i.which?void 0:!1;s&&e.replaceWith(e=e.clone(!0)),e.val("").trigger("change"),a.val("")}}})}},e("../../plugin")(n)}(jQuery,window,document)},{"../../plugin":12}],6:[function(e){!function(t){var i={};i.name="idealradiocheck",i.methods={_init:function(){var e=t(this.el),i=t("
");i.addClass("ideal-"+(e.is(":checkbox")?"check":"radio")),e.is(":checked")&&i.addClass("checked"),i.insertAfter(e),e.parent("label").addClass("ideal-radiocheck-label").attr("onclick",""),e.css({position:"absolute",left:"-9999px"}),e.on({change:function(){var e=t(this);e.is('input[type="radio"]')&&e.parent().siblings("label").find(".ideal-radio").removeClass("checked"),i.toggleClass("checked",e.is(":checked"))},focus:function(){i.addClass("focus")},blur:function(){i.removeClass("focus")},click:function(){t(this).trigger("focus")}})}},e("../../plugin")(i)}(jQuery,window,document)},{"../../plugin":12}],7:[function(e,t){t.exports={name:"datepicker",methods:{_init:function(){this._buildDatepicker()},_buildDatepicker:function(){var e=this.$form.find("input.datepicker");jQuery.ui&&($.datepicker._checkOffset=function(e,t){return t}),jQuery.ui&&e.length&&(e.each(function(){$(this).datepicker({beforeShow:function(e){$(e).addClass("open")},onChangeMonthYear:function(){var e=$(this),t=e.outerWidth();setTimeout(function(){e.datepicker("widget").css("width",t)},1)},onClose:function(){$(this).removeClass("open")}})}),e.on("focus keyup",function(){var e=$(this),t=e.outerWidth();e.datepicker("widget").css("width",t)}))}}}},{}],8:[function(e,t){function i(e,t){var i=/\{@([^}]+)\}(.+?)\{\/\1\}/g,s=/\{#([^}]+)\}/g,n=/\{([^}]+)\}/g;return e.replace(i,function(e,i,n){return $.map(t[i],function(e){return n.replace(s,function(t,i){return e[i]})}).join("")}).replace(n,function(e,i){return t[i]||""})}t.exports={name:"dynamicFields",options:{templates:{base:'
'}},methods:{addFields:function(e){var t=this;$.each(e,function(e,s){var n=s.type.split(":"),a={},o=t.$form.find(t.opts.field).last();s.name=e,s.type=n[0],n[1]&&(s.subtype=n[1]),s.html=i(t.opts.templates.base,{label:s.label,field:i(t.opts.templates[s.type],s)}),t._inject("addFields",s),s.after||s.before?t.$form.find('[name="'+(s.after||s.before)+'"]').first().each(function(){t._getField(this)[s.after?"after":"before"](s.html)}):o.length?o.after(s.html):t.$form.append(s.html),s.rules&&(a[e]=s.rules,t.addRules(a))})},removeFields:function(e){var t=this;$.each(e.split(" "),function(e,i){var s=t._getField($('[name="'+i+'"]'));t.$fields=t.$fields.filter(function(){return!$(this).is(s)}),s.remove()}),this._inject("removeFields")},toggleFields:function(e){var t=this;$.each(e.split(" "),function(e,i){var s=t._getField($('[name="'+i+'"]'));s.data("idealforms-valid",s.is(":visible")).toggle()}),this._inject("toggleFields")}}}},{}],9:[function(e){!function(t){var i={};i.name="idealsteps",i.defaults={nav:".idealsteps-nav",navItems:"li",buildNavItems:!0,wrap:".idealsteps-wrap",step:".idealsteps-step",activeClass:"idealsteps-step-active",before:null,after:null,fadeSpeed:0},i.methods={_init:function(){var e=this,i=this.opts.activeClass;this.$el=t(this.el),this.$nav=this.$el.find(this.opts.nav),this.$navItems=this.$nav.find(this.opts.navItems),this.$wrap=this.$el.find(this.opts.wrap),this.$steps=this.$wrap.find(this.opts.step),this.opts.buildNavItems&&this._buildNavItems(),this.$steps.hide().first().show(),this.$navItems.removeClass(i).first().addClass(i),this.$navItems.click(function(t){t.preventDefault(),e.go(e.$navItems.index(this))})},_buildNavItems:function(){var e,i=this,s="function"==typeof this.opts.buildNavItems,n=function(e){return'
"};e=s?this.$steps.map(function(e){return n(i.opts.buildNavItems.call(i,e))}).get():this.$steps.map(function(e){return n(++e)}).get(),this.$navItems=t(e.join("")),this.$nav.append(t("
").append(this.$navItems))},_getCurIdx:function(){return this.$steps.index(this.$steps.filter(":visible"))},go:function(e){var t=this.opts.activeClass,i=this.opts.fadeSpeed;"function"==typeof e&&(e=e.call(this,this._getCurIdx())),e>=this.$steps.length&&(e=0),0>e&&(e=this.$steps.length-1),this.opts.before&&this.opts.before.call(this,e),this.$navItems.removeClass(t).eq(e).addClass(t),this.$steps.fadeOut(i).eq(e).fadeIn(i),this.opts.after&&this.opts.after.call(this,e)},prev:function(){this.go(this._getCurIdx()-1)},next:function(){this.go(this._getCurIdx()+1)},first:function(){this.go(0)},last:function(){this.go(this.$steps.length-1)}},e("../../plugin")(i)}(jQuery,window,document)},{"../../plugin":12}],10:[function(e,t){e("./idealsteps"),t.exports={name:"steps",options:{steps:{container:".idealsteps-container",nav:".idealsteps-nav",navItems:"li",buildNavItems:function(e){return"Step "+(e+1)},wrap:".idealsteps-wrap",step:".idealsteps-step",activeClass:"idealsteps-step-active",before:null,after:null,fadeSpeed:0}},methods:{_init:function(){this._buildSteps()},_validate:function(){var e=this;this._updateSteps(),this._hasExtension("ajax")&&$.each($.idealforms._requests,function(t,i){i.done(function(){e._updateSteps()})})},focusFirstInvalid:function(e){this.$stepsContainer.idealsteps("go",function(){return this.$steps.filter(function(){return $(this).find(e).length}).index()})},_buildSteps:function(){var e=this,t=!$.isEmptyObject(this.opts.rules),i=this.opts.steps.buildNavItems,s=t?'
';this.opts.steps.buildNavItems&&(this.opts.steps.buildNavItems=function(t){return i.call(e,t)+s}),this.$stepsContainer=this.$form.closest(this.opts.steps.container).idealsteps(this.opts.steps)},_updateSteps:function(){var e=this;this.$stepsContainer.idealsteps("_inject",function(){var t=this;this.$navItems.each(function(i){var s=t.$steps.eq(i).find(e.getInvalid()).length;$(this).find("span").text(s).toggleClass("zero",!s)})})},addRules:function(){this.firstStep()},addFields:function(e){e.after=this.$stepsContainer.find(this.opts.steps.step).eq(e.appendToStep).find("input, textarea, select").last()[0].name},toggleFields:function(){this._updateSteps()},removeFields:function(){this._updateSteps()},goToStep:function(e){this.$stepsContainer.idealsteps("go",e)},prevStep:function(){this.$stepsContainer.idealsteps("prev")},nextStep:function(){this.$stepsContainer.idealsteps("next")},firstStep:function(){this.$stepsContainer.idealsteps("first")},lastStep:function(){this.$stepsContainer.idealsteps("last")}}}},{"./idealsteps":9}],11:[function(e){/*!
+!function e(t,i,s){function n(o,r){if(!i[o]){if(!t[o]){var l="function"==typeof require&&require;if(!r&&l)return l(o,!0);if(a)return a(o,!0);throw new Error("Cannot find module '"+o+"'")}var d=i[o]={exports:{}};t[o][0].call(d.exports,function(e){var i=t[o][1][e];return n(i?i:e)},d,d.exports,e,t,i,s)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o
').appendTo("body").css("width").replace("px","")},methods:{_init:function(){function e(){var e=t.$form.outerWidth(),i=t.opts.adaptiveWidth>e;t.$form.toggleClass("adaptive",i),t._hasExtension("steps")&&t.$stepsContainer.toggleClass("adaptive",i),$("#ui-datepicker-div").hide()}var t=this;$(window).resize(e),e(),this.$form.find("select, .datepicker").each(function(){t._getField(this).find(t.opts.error).addClass("hidden")}),$("p.idealforms-field-width").remove()}}}},{}],3:[function(e,t){t.exports={name:"ajax",methods:{_init:function(){$.extend($.idealforms,{_requests:{}}),$.idealforms.errors.ajax=$.idealforms.errors.ajax||"Loading...",$.extend($.idealforms.rules,{ajax:function(e){var t=this,i=this._getField(e),s=$(e).data("idealforms-ajax"),n=$.idealforms._getKey("errors."+e.name+".ajaxError",t.opts),a=$.idealforms._requests,o={};return o[e.name]=e.value,i.addClass("ajax"),a[e.name]&&a[e.name].abort(),a[e.name]=$.post(s,o,function(s){s===!0?(i.data("idealforms-valid",!0),t._handleError(e),t._handleStyle(e)):t._handleError(e,n),i.removeClass("ajax")},"json"),!1}})},_validate:function(e,t){"ajax"!=t&&$.idealforms._requests[e.name]&&($.idealforms._requests[e.name].abort(),this._getField(e).removeClass("ajax"))}}}},{}],4:[function(e,t){e("./idealfile"),e("./idealradiocheck"),t.exports={name:"customInputs",options:{customInputs:{i18n:{open:"Open"}}},methods:{_init:function(){this._buildCustomInputs()},addFields:function(){this._buildCustomInputs()},_buildCustomInputs:function(){this.$form.find(":file").idealfile(this.opts.customInputs.i18n),this.$form.find(":checkbox, :radio").idealradiocheck()}}}},{"./idealfile":5,"./idealradiocheck":6}],5:[function(e){!function(t){var i="undefined"!=typeof t("
")[0].multiple,s=/msie/i.test(navigator.userAgent),n={};n.name="idealfile",n.defaults={open:"Open"},n.methods={_init:function(){var e=t(this.el).addClass("ideal-file"),n=t('
'),a=t('
'),o=t('
'+this.opts.open+" "),r=t('
'+this.opts.open+" ");s&&r.add(o).addClass("ie"),e.css({position:"absolute",left:"-9999px"}),n.append(a,s?r:o).insertAfter(e),e.attr("tabIndex",-1),o.attr("tabIndex",-1),o.click(function(){e.focus().click()}),e.change(function(){var t,s,n=[];if(i){t=e[0].files;for(var o=0,r=t.length;r>o;o++)n.push(t[o].name);s=n.join(", ")}else s=e.val().split("\\").pop();a.val(s).attr("title",s)}),a.on({blur:function(){e.trigger("blur")},keydown:function(i){if(13===i.which)s||e.trigger("click"),t(this).closest("form").one("keydown",function(e){13===e.which&&e.preventDefault()});else{if(8!==i.which&&46!==i.which)return 9===i.which?void 0:!1;s&&e.replaceWith(e=e.clone(!0)),e.val("").trigger("change"),a.val("")}}})}},e("../../plugin")(n)}(jQuery,window,document)},{"../../plugin":12}],6:[function(e){!function(t){var i={};i.name="idealradiocheck",i.methods={_init:function(){var e=t(this.el),i=t("
");i.addClass("ideal-"+(e.is(":checkbox")?"check":"radio")),e.is(":checked")&&i.addClass("checked"),i.insertAfter(e),e.parent("label").addClass("ideal-radiocheck-label").attr("onclick",""),e.css({position:"absolute",left:"-9999px"}),e.on({change:function(){var e=t(this);e.is('input[type="radio"]')&&e.parent().siblings("label").find(".ideal-radio").removeClass("checked"),i.toggleClass("checked",e.is(":checked"))},focus:function(){i.addClass("focus")},blur:function(){i.removeClass("focus")},click:function(){t(this).trigger("focus")}})}},e("../../plugin")(i)}(jQuery,window,document)},{"../../plugin":12}],7:[function(e,t){t.exports={name:"datepicker",methods:{_init:function(){this._buildDatepicker()},_buildDatepicker:function(){var e=this.$form.find("input.datepicker");jQuery.ui&&($.datepicker._checkOffset=function(e,t){return t}),jQuery.ui&&e.length&&(e.each(function(){$(this).datepicker({beforeShow:function(e){$(e).addClass("open")},onChangeMonthYear:function(){var e=$(this),t=e.outerWidth();setTimeout(function(){e.datepicker("widget").css("width",t)},1)},onClose:function(){$(this).removeClass("open")}})}),e.on("focus keyup",function(){var e=$(this),t=e.outerWidth();e.datepicker("widget").css("width",t)}))}}}},{}],8:[function(e,t){function i(e,t){var i=/\{@([^}]+)\}(.+?)\{\/\1\}/g,s=/\{#([^}]+)\}/g,n=/\{([^}]+)\}/g;return e.replace(i,function(e,i,n){return $.map(t[i],function(e){return n.replace(s,function(t,i){return e[i]})}).join("")}).replace(n,function(e,i){return t[i]||""})}t.exports={name:"dynamicFields",options:{templates:{base:'
{label} {field}
',text:'
',file:'
',textarea:'
',group:'
{@list} {#text} {/list}
',select:'
{@list} {#text} {/list} '}},methods:{addFields:function(e){var t=this;$.each(e,function(e,s){var n=s.type.split(":"),a={},o=t.$form.find(t.opts.field).last();s.name=e,s.type=n[0],n[1]&&(s.subtype=n[1]),s.html=i(t.opts.templates.base,{label:s.label,field:i(t.opts.templates[s.type],s)}),t._inject("addFields",s),s.after||s.before?t.$form.find('[name="'+(s.after||s.before)+'"]').first().each(function(){t._getField(this)[s.after?"after":"before"](s.html)}):o.length?o.after(s.html):t.$form.append(s.html),s.rules&&(a[e]=s.rules,t.addRules(a))})},removeFields:function(e){var t=this;$.each(e.split(" "),function(e,i){var s=t._getField($('[name="'+i+'"]'));t.$fields=t.$fields.filter(function(){return!$(this).is(s)}),s.remove()}),this._inject("removeFields")},toggleFields:function(e){var t=this;$.each(e.split(" "),function(e,i){var s=t._getField($('[name="'+i+'"]'));s.data("idealforms-valid",s.is(":visible")).toggle()}),this._inject("toggleFields")}}}},{}],9:[function(e){!function(t){var i={};i.name="idealsteps",i.defaults={nav:".idealsteps-nav",navItems:"li",buildNavItems:!0,wrap:".idealsteps-wrap",step:".idealsteps-step",activeClass:"idealsteps-step-active",before:null,after:null,fadeSpeed:0},i.methods={_init:function(){var e=this,i=this.opts.activeClass;this.$el=t(this.el),this.$nav=this.$el.find(this.opts.nav),this.$navItems=this.$nav.find(this.opts.navItems),this.$wrap=this.$el.find(this.opts.wrap),this.$steps=this.$wrap.find(this.opts.step),this.opts.buildNavItems&&this._buildNavItems(),this.$steps.hide().first().show(),this.$navItems.removeClass(i).first().addClass(i),this.$navItems.click(function(t){t.preventDefault(),e.go(e.$navItems.index(this))})},_buildNavItems:function(){var e,i=this,s="function"==typeof this.opts.buildNavItems,n=function(e){return'
'+e+" "};e=s?this.$steps.map(function(e){return n(i.opts.buildNavItems.call(i,e))}).get():this.$steps.map(function(e){return n(++e)}).get(),this.$navItems=t(e.join("")),this.$nav.append(t("
").append(this.$navItems))},_getCurIdx:function(){return this.$steps.index(this.$steps.filter(":visible"))},go:function(e){var t=this.opts.activeClass,i=this.opts.fadeSpeed;"function"==typeof e&&(e=e.call(this,this._getCurIdx())),e>=this.$steps.length&&(e=0),0>e&&(e=this.$steps.length-1),this.opts.before&&this.opts.before.call(this,e),this.$navItems.removeClass(t).eq(e).addClass(t),this.$steps.fadeOut(i).eq(e).fadeIn(i),this.opts.after&&this.opts.after.call(this,e)},prev:function(){this.go(this._getCurIdx()-1)},next:function(){this.go(this._getCurIdx()+1)},first:function(){this.go(0)},last:function(){this.go(this.$steps.length-1)}},e("../../plugin")(i)}(jQuery,window,document)},{"../../plugin":12}],10:[function(e,t){e("./idealsteps"),t.exports={name:"steps",options:{steps:{container:".idealsteps-container",nav:".idealsteps-nav",navItems:"li",buildNavItems:function(e){return this.opts.steps.i18n.step+" "+(e+1)},wrap:".idealsteps-wrap",step:".idealsteps-step",activeClass:"idealsteps-step-active",before:null,after:null,fadeSpeed:0,i18n:{step:"Step"}}},methods:{_init:function(){this._buildSteps()},_validate:function(){var e=this;this._updateSteps(),this._hasExtension("ajax")&&$.each($.idealforms._requests,function(t,i){i.done(function(){e._updateSteps()})})},focusFirstInvalid:function(e){this.$stepsContainer.idealsteps("go",function(){return this.$steps.filter(function(){return $(this).find(e).length}).index()})},_buildSteps:function(){var e=this,t=!$.isEmptyObject(this.opts.rules),i=this.opts.steps.buildNavItems,s=t?'
':'
0 ';this.opts.steps.buildNavItems&&(this.opts.steps.buildNavItems=function(t){return i.call(e,t)+s}),this.$stepsContainer=this.$form.closest(this.opts.steps.container).idealsteps(this.opts.steps)},_updateSteps:function(){var e=this;this.$stepsContainer.idealsteps("_inject",function(){var t=this;this.$navItems.each(function(i){var s=t.$steps.eq(i).find(e.getInvalid()).length;$(this).find("span").text(s).toggleClass("zero",!s)})})},addRules:function(){this.firstStep()},addFields:function(e){e.after=this.$stepsContainer.find(this.opts.steps.step).eq(e.appendToStep).find("input, textarea, select").last()[0].name},toggleFields:function(){this._updateSteps()},removeFields:function(){this._updateSteps()},goToStep:function(e){this.$stepsContainer.idealsteps("go",e)},prevStep:function(){this.$stepsContainer.idealsteps("prev")},nextStep:function(){this.$stepsContainer.idealsteps("next")},firstStep:function(){this.$stepsContainer.idealsteps("first")},lastStep:function(){this.$stepsContainer.idealsteps("last")}}}},{"./idealsteps":9}],11:[function(e){/*!
* jQuery Ideal Forms
* @author: Cedric Ruiz
* @version: 3.0
* @license GPL or MIT
*/
-!function(t){var i={};i.name="idealforms",i.defaults={field:".field",error:".error",iconHtml:"
",iconClass:"icon",invalidClass:"invalid",validClass:"valid",silentLoad:!0,onValidate:t.noop,onSubmit:t.noop},i.global={_format:function(e){var t=[].slice.call(arguments,1);return e.replace(/\{(\d)\}/g,function(e,i){return t[+i]||""}).replace(/\{\*([^*}]*)\}/g,function(e,i){return t.join(i||", ")})},_getKey:function(e,t){return e.split(".").reduce(function(e,t){return e&&e[t]},t)},ruleSeparator:" ",argSeparator:":",rules:e("./rules"),errors:e("./errors"),extensions:[e("./extensions/dynamic-fields/dynamic-fields.ext"),e("./extensions/ajax/ajax.ext"),e("./extensions/steps/steps.ext"),e("./extensions/custom-inputs/custom-inputs.ext"),e("./extensions/datepicker/datepicker.ext"),e("./extensions/adaptive/adaptive.ext")]},i.methods=t.extend({},e("./private"),e("./public")),e("./plugin")(i)}(jQuery,window,document)},{"./errors":1,"./extensions/adaptive/adaptive.ext":2,"./extensions/ajax/ajax.ext":3,"./extensions/custom-inputs/custom-inputs.ext":4,"./extensions/datepicker/datepicker.ext":7,"./extensions/dynamic-fields/dynamic-fields.ext":8,"./extensions/steps/steps.ext":10,"./plugin":12,"./private":13,"./public":14,"./rules":15}],12:[function(e,t){t.exports=function(){var e=Array.prototype;return function(t){function i(e,i){this.opts=$.extend({},t.defaults,i),this.el=e,this._name=t.name,this._init()}t=$.extend(!0,{name:"plugin",defaults:{disabledExtensions:"none"},methods:{},global:{}},t),$[t.name]=$.extend({addExtension:function(e){t.global.extensions.push(e)}},t.global),i._extended={},i.prototype._hasExtension=function(e){var i=this;return t.global.extensions.filter(function(t){return t.name==e&&i.opts.disabledExtensions.indexOf(t.name)<0}).length},i.prototype._extend=function(e){var t=this;$.each(e,function(e,s){$.extend(t.opts,$.extend(!0,s.options,t.opts)),$.each(s.methods,function(e,n){t.opts.disabledExtensions.indexOf(s.name)>-1||(i.prototype[e]?(i._extended[e]=i._extended[e]||[],i._extended[e].push({name:s.name,fn:n})):i.prototype[e]=n)})})},i.prototype._inject=function(e){var t=[].slice.call(arguments,1);if("function"==typeof e)return e.call(this);var s=this;i._extended[e]&&$.each(i._extended[e],function(e,i){i.fn.apply(s,t)})},i.prototype._init=$.noop,i.prototype[t.name]=function(t){if(!t)return this;try{return this[t].apply(this,e.slice.call(arguments,1))}catch(i){}},$.extend(i.prototype,t.methods),$.fn[t.name]=function(){var s,n=e.slice.call(arguments),a="string"==typeof n[0]&&n[0].split(":"),o=a[a.length>1?1:0],r=a.length>1&&a[0],l="object"==typeof n[0]&&n[0],d=n.slice(1);return r&&(o=r+o.substr(0,1).toUpperCase()+o.substr(1,o.length-1)),this.each(function(){var e=$.data(this,t.name);return e?s=e[t.name].apply(e,[o].concat(d)):$.data(this,t.name,new i(this,l))}),r?s:this}}}()},{}],13:[function(e,t){t.exports={_init:function(){var e=this;this._extend($.idealforms.extensions),this.$form=$(this.el),this.$fields=$(),this.$inputs=$(),this._inject("_init"),this.addRules(this.opts.rules||{}),this.$form.submit(function(t){t.preventDefault(),e._validateAll(),e.focusFirstInvalid(),e.opts.onSubmit.call(e,e.getInvalid().length,t)}),this.opts.silentLoad||this.focusFirstInvalid()},_buildField:function(e){var t,i=this._getField(e);t=$(this.opts.iconHtml,{"class":this.opts.iconClass,click:function(){$(e).focus()}}),this.$fields.filter(i).length||(this.$fields=this.$fields.add(i),this.opts.iconHtml&&i.append(t),i.addClass("idealforms-field idealforms-field-"+e.type)),this._addEvents(e),this._inject("_buildField",e)},_addEvents:function(e){var t=this,i=this._getField(e);$(e).on("change keyup",function(e){9!=e.which&&16!=e.which&&t._validate(this,!0,!0)}).focus(function(){return t.isValid(this.name)?!1:((t._isRequired(this)||this.value)&&i.find(t.opts.error).show(),void 0)}).blur(function(){i.find(t.opts.error).hide()})},_isRequired:function(e){return $(e).is(":checkbox, :radio, select")?!0:this.opts.rules[e.name].indexOf("required")>-1},_getRelated:function(e){return this._getField(e).find('[name="'+e.name+'"]')},_getField:function(e){return $(e).closest(this.opts.field)},_getFirstInvalid:function(){return this.getInvalid().first().find("input:first, textarea, select")},_handleError:function(e,t,i){i=i||this.isValid(e.name);var s=this._getField(e).find(this.opts.error);this.$form.find(this.opts.error).hide(),t&&s.text(t),s.toggle(!i)},_handleStyle:function(e,t){t=t||this.isValid(e.name),this._getField(e).removeClass(this.opts.validClass+" "+this.opts.invalidClass).addClass(t?this.opts.validClass:this.opts.invalidClass).find("."+this.opts.iconClass).show()},_fresh:function(e){this._getField(e).removeClass(this.opts.validClass+" "+this.opts.invalidClass).find(this.opts.error).hide().end().find("."+this.opts.iconClass).toggle(this._isRequired(e))},_validate:function(e,t,i){var s,n=this,a=this._getField(e),o=this.opts.rules[e.name].split($.idealforms.ruleSeparator),r=a.data("idealforms-value"),l=!0;return $(e).is(":checkbox, :radio")||r!=e.value?(a.data("idealforms-value",e.value),e.value||this._isRequired(e)?$.each(o,function(o,r){r=r.split($.idealforms.argSeparator),s=r[0];var d,u=$.idealforms.rules[s],c=r.slice(1);return d=$.idealforms._format.apply(null,[$.idealforms._getKey("errors."+e.name+"."+s,n.opts)||$.idealforms.errors[s]].concat(c)),l="function"==typeof u?u.apply(n,[e,e.value].concat(c)):u.test(e.value),a.data("idealforms-valid",l),t&&n._handleError(e,d,l),i&&n._handleStyle(e,l),n.opts.onValidate.call(n,e,s,l),l}):(a.removeData("idealforms-valid"),this._fresh(e)),this._inject("_validate",e,s,l),l):a.data("idealforms-valid")},_validateAll:function(){var e=this;this.$inputs.each(function(){e._validate(this,!0)})}}},{}],14:[function(e,t){t.exports={addRules:function(e){var t=this,i=this.$form.find($.map(e,function(e,t){return'[name="'+t+'"]'}).join(","));$.extend(this.opts.rules,e),i.each(function(){t._buildField(this)}),this.$inputs=this.$inputs.add(i),this._validateAll(),this.$fields.find(this.opts.error).hide(),this._inject("addRules")},getInvalid:function(){return this.$fields.filter(function(){return $(this).data("idealforms-valid")===!1})},focusFirstInvalid:function(){var e=this._getFirstInvalid()[0];e&&(this._handleError(e),this._handleStyle(e),this._inject("focusFirstInvalid",e),e.focus())},isValid:function(e){return e?!this.getInvalid().find('[name="'+e+'"]').length:!this.getInvalid().length},reset:function(e){var t=this,i=this.$inputs;e&&(i=i.filter('[name="'+e+'"]')),i.filter("input:not(:checkbox, :radio)").val(""),i.filter(":checkbox, :radio").prop("checked",!1),i.filter("select").find("option").prop("selected",function(){return this.defaultSelected}),i.change().each(function(){t._resetErrorAndStyle(this)}),this._inject("reset",e)}}},{}],15:[function(e,t){t.exports={required:/.+/,digits:/^\d+$/,email:/^[^@]+@[^@]+\..{2,6}$/,username:/^[a-z](?=[\w.]{3,31}$)\w*\.?\w*$/i,pass:/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/,strongpass:/(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/,phone:/^[2-9]\d{2}-\d{3}-\d{4}$/,zip:/^\d{5}$|^\d{5}-\d{4}$/,url:/^(?:(ftp|http|https):\/\/)?(?:[\w\-]+\.)+[a-z]{2,6}([\:\/?#].*)?$/i,number:function(e,t){return!isNaN(t)},range:function(e,t,i,s){return Number(t)>=min&&Number(t)<=s},min:function(e,t,i){return t.length>=i},max:function(e,t,i){return t.length<=i},minoption:function(e,t,i){return this._getRelated(e).filter(":checked").length>=i},maxoption:function(e,t,i){return this._getRelated(e).filter(":checked").length<=i},minmax:function(e,t,i,s){return t.length>=i&&t.length<=s},select:function(e,t,i){return t!=i},extension:function(e){var t=[].slice.call(arguments,1),i=!1;return $.each(e.files||[{name:e.value}],function(e,s){i=$.inArray(s.name.split(".").pop().toLowerCase(),t)>-1}),i},equalto:function(e,t,i){var s=this,n=$('[name="'+i+'"]');return this.getInvalid().find(n).length?!1:(n.off("keyup.equalto").on("keyup.equalto",function(){s._getField(e).removeData("idealforms-value"),s._validate(e,!1,!0)}),e.value==n.val())},date:function(e,t,i){function s(e,t){for(var i,s,n,a=0,o=t.length;o>a;a++)/m/.test(t[a])&&(i=e[a]),/d/.test(t[a])&&(s=e[a]),/y/.test(t[a])&&(n=e[a]);return i&&s&&n?i>0&&13>i&&n&&4==n.length&&s>0&&s<=new Date(n,i,0).getDate():!1}i=i||"mm/dd/yyyy";var n=/[^mdy]/.exec(i)[0],a=i.split(n),o=t.split(n);return s(o,a)}}},{}]},{},[11]);
\ No newline at end of file
+!function(t){var i={};i.name="idealforms",i.defaults={i18n:"en",field:".field",error:".error",iconHtml:"
",iconClass:"icon",invalidClass:"invalid",validClass:"valid",silentLoad:!0,onValidate:t.noop,onSubmit:t.noop},i.global={_format:function(e){var t=[].slice.call(arguments,1);return e.replace(/\{(\d)\}/g,function(e,i){return t[+i]||""}).replace(/\{\*([^*}]*)\}/g,function(e,i){return t.join(i||", ")})},_getKey:function(e,t){return e.split(".").reduce(function(e,t){return e&&e[t]},t)},i18n:{},ruleSeparator:" ",argSeparator:":",rules:e("./rules"),errors:e("./errors"),extensions:[e("./extensions/dynamic-fields/dynamic-fields.ext"),e("./extensions/ajax/ajax.ext"),e("./extensions/steps/steps.ext"),e("./extensions/custom-inputs/custom-inputs.ext"),e("./extensions/datepicker/datepicker.ext"),e("./extensions/adaptive/adaptive.ext")]},i.methods=t.extend({},e("./private"),e("./public")),e("./plugin")(i)}(jQuery,window,document)},{"./errors":1,"./extensions/adaptive/adaptive.ext":2,"./extensions/ajax/ajax.ext":3,"./extensions/custom-inputs/custom-inputs.ext":4,"./extensions/datepicker/datepicker.ext":7,"./extensions/dynamic-fields/dynamic-fields.ext":8,"./extensions/steps/steps.ext":10,"./plugin":12,"./private":13,"./public":14,"./rules":15}],12:[function(e,t){t.exports=function(){var e=Array.prototype;return function(t){function i(e,i){this.opts=$.extend({},t.defaults,i),this.el=e,this._name=t.name,this._init()}t=$.extend(!0,{name:"plugin",defaults:{disabledExtensions:"none"},methods:{},global:{}},t),$[t.name]=$.extend({addExtension:function(e){t.global.extensions.push(e)}},t.global),i._extended={},i.prototype._hasExtension=function(e){var i=this;return t.global.extensions.filter(function(t){return t.name==e&&i.opts.disabledExtensions.indexOf(t.name)<0}).length},i.prototype._extend=function(e){var t=this;$.each(e,function(e,s){$.extend(t.opts,$.extend(!0,s.options,t.opts)),$.each(s.methods,function(e,n){t.opts.disabledExtensions.indexOf(s.name)>-1||(i.prototype[e]?(i._extended[e]=i._extended[e]||[],i._extended[e].push({name:s.name,fn:n})):i.prototype[e]=n)})})},i.prototype._inject=function(e){var t=[].slice.call(arguments,1);if("function"==typeof e)return e.call(this);var s=this;i._extended[e]&&$.each(i._extended[e],function(e,i){i.fn.apply(s,t)})},i.prototype._init=$.noop,i.prototype[t.name]=function(t){if(!t)return this;try{return this[t].apply(this,e.slice.call(arguments,1))}catch(i){}},$.extend(i.prototype,t.methods),$.fn[t.name]=function(){var s,n=e.slice.call(arguments),a="string"==typeof n[0]&&n[0].split(":"),o=a[a.length>1?1:0],r=a.length>1&&a[0],l="object"==typeof n[0]&&n[0],d=n.slice(1);return r&&(o=r+o.substr(0,1).toUpperCase()+o.substr(1,o.length-1)),this.each(function(){var e=$.data(this,t.name);return e?s=e[t.name].apply(e,[o].concat(d)):$.data(this,t.name,new i(this,l))}),r?s:this}}}()},{}],13:[function(e,t){t.exports={_init:function(){var e=this;this.$form=$(this.el),this.$fields=$(),this.$inputs=$(),this._extend($.idealforms.extensions),this._i18n(),this._inject("_init"),this.addRules(this.opts.rules||{}),this.$form.submit(function(t){t.preventDefault(),e._validateAll(),e.focusFirstInvalid(),e.opts.onSubmit.call(e,e.getInvalid().length,t)}),this.opts.silentLoad||this.focusFirstInvalid()},_i18n:function(){if("en"!=this.opts.i18n){var e=$.idealforms.i18n[this.opts.i18n],t=e.errors,i={};delete e.errors;for(var s in e)i[s]={i18n:e[s]};$.extend($.idealforms.errors,t),$.extend(!0,this.opts,i)}},_buildField:function(e){var t,i=this._getField(e);t=$(this.opts.iconHtml,{"class":this.opts.iconClass,click:function(){$(e).focus()}}),this.$fields.filter(i).length||(this.$fields=this.$fields.add(i),this.opts.iconHtml&&i.append(t),i.addClass("idealforms-field idealforms-field-"+e.type)),this._addEvents(e),this._inject("_buildField",e)},_addEvents:function(e){var t=this,i=this._getField(e);$(e).on("change keyup",function(e){9!=e.which&&16!=e.which&&t._validate(this,!0,!0)}).focus(function(){return t.isValid(this.name)?!1:((t._isRequired(this)||this.value)&&i.find(t.opts.error).show(),void 0)}).blur(function(){i.find(t.opts.error).hide()})},_isRequired:function(e){return $(e).is(":checkbox, :radio, select")?!0:this.opts.rules[e.name].indexOf("required")>-1},_getRelated:function(e){return this._getField(e).find('[name="'+e.name+'"]')},_getField:function(e){return $(e).closest(this.opts.field)},_getFirstInvalid:function(){return this.getInvalid().first().find("input:first, textarea, select")},_handleError:function(e,t,i){i=i||this.isValid(e.name);var s=this._getField(e).find(this.opts.error);this.$form.find(this.opts.error).hide(),t&&s.text(t),s.toggle(!i)},_handleStyle:function(e,t){t=t||this.isValid(e.name),this._getField(e).removeClass(this.opts.validClass+" "+this.opts.invalidClass).addClass(t?this.opts.validClass:this.opts.invalidClass).find("."+this.opts.iconClass).show()},_fresh:function(e){this._getField(e).removeClass(this.opts.validClass+" "+this.opts.invalidClass).find(this.opts.error).hide().end().find("."+this.opts.iconClass).toggle(this._isRequired(e))},_validate:function(e,t,i){var s,n=this,a=this._getField(e),o=this.opts.rules[e.name].split($.idealforms.ruleSeparator),r=a.data("idealforms-value"),l=!0;return $(e).is(":checkbox, :radio")||r!=e.value?(a.data("idealforms-value",e.value),e.value||this._isRequired(e)?$.each(o,function(o,r){r=r.split($.idealforms.argSeparator),s=r[0];var d,u=$.idealforms.rules[s],c=r.slice(1);return d=$.idealforms._format.apply(null,[$.idealforms._getKey("errors."+e.name+"."+s,n.opts)||$.idealforms.errors[s]].concat(c)),l="function"==typeof u?u.apply(n,[e,e.value].concat(c)):u.test(e.value),a.data("idealforms-valid",l),t&&n._handleError(e,d,l),i&&n._handleStyle(e,l),n.opts.onValidate.call(n,e,s,l),l}):(a.removeData("idealforms-valid"),this._fresh(e)),this._inject("_validate",e,s,l),l):a.data("idealforms-valid")},_validateAll:function(){var e=this;this.$inputs.each(function(){e._validate(this,!0)})}}},{}],14:[function(e,t){t.exports={addRules:function(e){var t=this,i=this.$form.find($.map(e,function(e,t){return'[name="'+t+'"]'}).join(","));$.extend(this.opts.rules,e),i.each(function(){t._buildField(this)}),this.$inputs=this.$inputs.add(i),this._validateAll(),this.$fields.find(this.opts.error).hide(),this._inject("addRules")},getInvalid:function(){return this.$fields.filter(function(){return $(this).data("idealforms-valid")===!1})},focusFirstInvalid:function(){var e=this._getFirstInvalid()[0];e&&(this._handleError(e),this._handleStyle(e),this._inject("focusFirstInvalid",e),e.focus())},isValid:function(e){return e?!this.getInvalid().find('[name="'+e+'"]').length:!this.getInvalid().length},reset:function(e){var t=this,i=this.$inputs;e&&(i=i.filter('[name="'+e+'"]')),i.filter("input:not(:checkbox, :radio)").val(""),i.filter(":checkbox, :radio").prop("checked",!1),i.filter("select").find("option").prop("selected",function(){return this.defaultSelected}),i.change().each(function(){t._resetErrorAndStyle(this)}),this._inject("reset",e)}}},{}],15:[function(e,t){t.exports={required:/.+/,digits:/^\d+$/,email:/^[^@]+@[^@]+\..{2,6}$/,username:/^[a-z](?=[\w.]{3,31}$)\w*\.?\w*$/i,pass:/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/,strongpass:/(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/,phone:/^[2-9]\d{2}-\d{3}-\d{4}$/,zip:/^\d{5}$|^\d{5}-\d{4}$/,url:/^(?:(ftp|http|https):\/\/)?(?:[\w\-]+\.)+[a-z]{2,6}([\:\/?#].*)?$/i,number:function(e,t){return!isNaN(t)},range:function(e,t,i,s){return Number(t)>=min&&Number(t)<=s},min:function(e,t,i){return t.length>=i},max:function(e,t,i){return t.length<=i},minoption:function(e,t,i){return this._getRelated(e).filter(":checked").length>=i},maxoption:function(e,t,i){return this._getRelated(e).filter(":checked").length<=i},minmax:function(e,t,i,s){return t.length>=i&&t.length<=s},select:function(e,t,i){return t!=i},extension:function(e){var t=[].slice.call(arguments,1),i=!1;return $.each(e.files||[{name:e.value}],function(e,s){i=$.inArray(s.name.split(".").pop().toLowerCase(),t)>-1}),i},equalto:function(e,t,i){var s=this,n=$('[name="'+i+'"]');return this.getInvalid().find(n).length?!1:(n.off("keyup.equalto").on("keyup.equalto",function(){s._getField(e).removeData("idealforms-value"),s._validate(e,!1,!0)}),e.value==n.val())},date:function(e,t,i){function s(e,t){for(var i,s,n,a=0,o=t.length;o>a;a++)/m/.test(t[a])&&(i=e[a]),/d/.test(t[a])&&(s=e[a]),/y/.test(t[a])&&(n=e[a]);return i&&s&&n?i>0&&13>i&&n&&4==n.length&&s>0&&s<=new Date(n,i,0).getDate():!1}i=i||"mm/dd/yyyy";var n=/[^mdy]/.exec(i)[0],a=i.split(n),o=t.split(n);return s(o,a)}}},{}]},{},[11]);
\ No newline at end of file
diff --git a/js/private.js b/js/private.js
index 5caef4a..5c63ba5 100644
--- a/js/private.js
+++ b/js/private.js
@@ -7,12 +7,14 @@ module.exports = {
var self = this;
- this._extend($.idealforms.extensions);
-
this.$form = $(this.el);
this.$fields = $();
this.$inputs = $();
+ this._extend($.idealforms.extensions);
+
+ this._i18n();
+
this._inject('_init');
this.addRules(this.opts.rules || {});
@@ -27,6 +29,22 @@ module.exports = {
if (! this.opts.silentLoad) this.focusFirstInvalid();
},
+ _i18n: function() {
+
+ if (this.opts.i18n == 'en') return;
+
+ var lang = $.idealforms.i18n[this.opts.i18n]
+ , errors = lang.errors
+ , options = {};
+
+ delete lang.errors;
+
+ for (var ext in lang) options[ext] = { i18n: lang[ext] };
+
+ $.extend($.idealforms.errors, errors);
+ $.extend(true, this.opts, options);
+ },
+
_buildField: function(input) {
var self = this