text: !function(t){"use strict";t.fn.formalize=function(){this.each(function(){function a(t,a,e){t?(e.addClass("valid"),e.removeClass("invalid"),e.parent().find(".tagInfo").html("")):(e.removeClass("valid"),e.addClass("invalid"),e.parent().find(".tagInfo").html(a))}function e(t){return t.hasClass("frz-counter-words")?" ":t.hasClass("frz-counter-sentences")?".":t.hasClass("frz-counter-paragraphs")?"\n":""}function i(t){var a,i;return i=t.attr("type"),"number"===i?isNaN(t.val())||""===t.val()?0:t.val():(a=t.val().split(e(t)),a.length)}function n(a){var e,i,n;e=a.css("font-family"),i=a.css("font-size"),i&&v.css("font-size",i),e&&v.css("font-family",e),"off"===a.attr("wrap")&&v.css("overflow-wrap","normal").css("white-space","pre"),v.text(a.val()+"\n"),n=v.html().replace(/\n/g,"<br>"),v.html(n),a.is(":visible")?v.css("width",a.width()):v.css("width",t(window).width()/2),a.css("height",v.height())}function s(t,e,i){var n=t.val();e.test(n)?a(!0,null,t):a(!1,i,t)}function l(t){var e,i;return i=t.val(),e=t.attr("required"),e&&""===i?(a(!1,"Required field!",t),!1):void a(!0,null,t)}var o,r,c,d,p,h,u,f,v,g,m,b,C,x;o=t(this),r="input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea",u=function(t){if("function"==typeof t.mask){var a=t.attr("type");"tel"===a&&t.mask(C,x)}},C=function(t){return 11===t.replace(/\D/g,"").length?"(00) 00000-0000":"(00) 0000-00009"},x={onKeyPress:function(t,a,e,i){e.mask(C.apply({},arguments),i)}},t(this).find(r).each(function(a,e){var i;i=t(e).attr("required"),i&&t(this).siblings("label").append(' <span class="frz-char-required">*</span>'),t(e).val().length>0||e.autofocus||void 0!==t(this).attr("placeholder")||t(e)[0].validity.badInput===!0?t(this).siblings("label, i").addClass("active"):t(this).siblings("label, i").removeClass("active"),u(t(e))}),c="input.prefix ~ input, button.prefix ~ input, input.prefix ~ textarea, button.prefix ~ textarea",d="input.prefix, button.prefix",p="input ~ input.suffix, input ~ button.suffix, textarea ~ input.suffix, textarea ~ button.suffix",t(this).find(c).each(function(a,e){var i=t(e).siblings(d);t(i).wrapAll('<span class="frz-btn-prefix">'),t(e).addClass("frz-affix")}),t(this).find(p).each(function(){var a,e;a=t(this),e=a.siblings("input, textarea"),a.wrapAll('<span class="frz-btn-suffix">'),e.addClass("frz-affix")}),t(this).find(".frz-affix").each(function(){var a,e;a=t(this),e=a.next("label"),e.andSelf().siblings("i.prefix, i.suffix").andSelf().wrapAll('<span class="frz-input-affix">'),e.before(" ")}),t(this).on("change",r,function(){0===t(this).val().length&&void 0===t(this).attr("placeholder")||t(this).siblings("label").addClass("active"),h(t(this))}),t(this).find(r).not("input[type=button], input[type=submit]").each(function(){var a,e,i,n,s;a=t(this),e=a.parent(),i=e.has("span.tagInfo").length,n=a.attr("maxlength")||a.attr("max")||a.attr("data-max"),s=a.attr("minlength")||a.attr("min")||a.attr("data-min"),i||e.append('<span class="tagInfo"></span>'),s&&n?(a.addClass("frz-counter"),e.append('<span class="tagCount">'+s+" / "+n+"</span>")):n?(a.addClass("frz-counter"),e.append('<span class="tagCount">0 / '+n+"</span>")):s&&(a.addClass("frz-counter"),e.append('<span class="tagCount">'+s+" / *</span>"))}),t(this).find(".frz-counter, .frz-counter-words, .frz-counter-sentences, .frz-counter-paragraphs").each(function(){var a,e,i,n;a=t(this),e=a.parent(),i=e.find(".tagCount").length,n=a.hasClass("frz-counter"),i||e.append('<span class="tagCount">0</span>'),n||a.addClass("frz-counter")}),t(this).on("keyup keydown",".frz-counter",function(){var e,n,s,l;e=t(this),n=e.attr("maxlength")||e.attr("max")||e.attr("data-max"),s=e.attr("minlength")||e.attr("min")||e.attr("data-min"),n=n>=0?n:"*",s=s>=0?s:0,l=i(e),l=parseInt(l,10),0===s&&"*"===n?e.parent().find(".tagCount").html(l):s>l?(e.parent().find(".tagCount").html(l+" < "+s+" / "+n),a(!1,"Can't be less than "+s,e)):l>=s&&("*"!==n&&n>=l||"*"===n)?(e.parent().find(".tagCount").html(l+" / "+n),a(!0,"",e)):l>n&&(e.parent().find(".tagCount").html(l+" / "+n),a(!1,"Can't be more than "+n,e))}),t(this).on("reset",function(a){var e=t(a.target);e.is("form")&&(e.find(r).removeClass("valid").removeClass("invalid"),e.find(r).each(function(){""===t(this).attr("value")&&t(this).siblings("label, i").removeClass("active")}),e.find("select").each(function(){var t=e.find("option[selected]").text();e.siblings("input.select-dropdown").val(t)}))}),t(this).on("focus",r,function(){t(this).siblings("label, i").addClass("active")}),t(document).on("blur",r,function(){var a=t(this);0===a.val().length&&a[0].validity.badInput!==!0&&void 0===a.attr("placeholder")&&a.siblings("label, i").removeClass("active"),h(a)}),f="input[type=radio], input[type=checkbox]",t(this).on("keyup.radio",f,function(a){if(9===a.which){t(this).addClass("tabbed");var e=t(this);return void e.one("blur",function(a){t(this).removeClass("tabbed")})}}),t(this).find("textarea").addClass("formalize-textarea"),v=t(".hiddendiv").first(),v.length||(v=t('<div class="hiddendiv common"></div>'),t(this).append(v)),g=".formalize-textarea",t(g).each(function(){var a=t(this);a.val().length&&n(a)}),t(this).on("keyup keydown autoresize",g,function(){n(t(this))}),t(this).find('input[type="file"]').each(function(){var a,e,i,n,s,l,o;a=t(this).attr("placeholder")||t(this).data("placeholder"),e=t(this).attr("multiple"),n=t(this).siblings("label"),s=n.text(),l=t(this).siblings(".tagInfo"),o=l.text(),n.remove(),l.remove(),void 0===a&&void 0===e?a="Upload file":void 0===a&&e&&(a="Upload one or more files"),t('<i class="material-icons">file_upload</i>').insertBefore(t(this)),t(this).siblings("i").andSelf().wrapAll('<div class="btn">'),i='<div class="file-path-wrapper"><label class="active"> '+s+' </label><input class="file-path validate" type="text" placeholder="'+a+'"><span class="tagInfo">'+o+"</span></div>",t(this).parent().after(i)}),t(this).on("change",'input[type="file"]',function(){var a,e,i,n,s;for(a=t(this).closest(".col"),e=a.find("input.file-path"),i=t(this)[0].files,n=[],s=0;s<i.length;s+=1)n.push(i[s].name);e.val(n.join(", ")),e.trigger("change")}),m="input[type=range]",b=!1,t(this).find(m).each(function(){var a=t('<span class="thumb"><span class="value"></span></span>');t(this).after(a)}),t(this).on("change",m,function(a){var e=t(this).siblings(".thumb");e.find(".value").html(t(this).val())}),t(this).on("input mousedown touchstart",m,function(a){var e,i;e=t(this).siblings(".thumb"),i=t(this).outerWidth(),e.length<=0&&(e=t('<span class="thumb"><span class="value"></span></span>'),t(this).after(e)),e.find(".value").html(t(this).val()),b=!0,t(this).addClass("active"),e.hasClass("active")||e.animate({width:30,height:30,top:-28},300,function(){}),e.find(".value").html(t(this).val())}),t(this).on("mouseup touchend",m,function(){b=!1,t(this).removeClass("active")}),t(this).on("mousemove touchmove",m,function(a){var e,i,n;e=t(this).siblings(".thumb"),b&&(e.hasClass("active")||e.animate({width:30,height:30,top:-28},300,function(){}),i=void 0===a.pageX||null===a.pageX?a.originalEvent.touches[0].pageX-t(this).offset().left:a.pageX-t(this).offset().left,n=t(this).outerWidth(),0>i?i=0:i>n&&(i=n),e.addClass("active").css("left",i),e.find(".value").html(e.siblings(m).val()))}),t(this).on("mouseout touchleave",m,function(){if(!b){var a=t(this).siblings(".thumb");a.hasClass("active")&&a.animate({width:0,height:0,top:10},300,function(){}),a.removeClass("active")}}),t(this).find("select").each(function(){var a,e,i,n,s;a=t(this),e=t(this).attr("multiple"),e?(i='<ul class="dropdown-content multiple-select-dropdown">',n="",a.find("option:checked").each(function(){n+=t(this).text()+", "}),n=n.replace(/,\s*$/,"")):(i='<ul class="dropdown-content">',n=a.find(":selected").text()),a.wrap('<div class="select-wrapper">'),a.before('<span class="caret">▼</span>'),a.before('<input type="text" class="select-dropdown" readonly="true" value="'+n+'">'),s=a,a.find("option").each(function(){var a,n,l,o,r,c;a=t(this),n=a.parent(),l=a.is(":selected"),s.is(n)||(i+='<li class="optgroup"><span>'+n.attr("label")+"</span></li>"),s=n,o="",a.attr("disabled")&&(o="disabled"),r="",c="",l&&(r="active",c="checked"),i+=e?'<li data-value="'+a.val()+'" class=" '+o+" "+r+' "><span><input type="checkbox" '+c+" "+o+"><label></label>"+a.text()+"</span></li>":'<li data-value="'+a.val()+'" class="'+o+'"><span>'+a.text()+"</span></li>"}),i+="</ul>",a.before(i)}),t(this).on("click",".select-dropdown",function(){var a,e,i;a=t(this),e=a.css("width"),i=a.next(".dropdown-content"),i.css("top","0px"),i.css("width",e),i.slideToggle(),i.hasClass("actived")?i.removeClass("actived"):i.addClass("actived")}),t(this).on("click",".dropdown-content:not(.multiple-select-dropdown) li:not(.optgroup, .disabled)",function(){var a,e,i,n;a=t(this),e=a.text(),i=a.attr("data-value"),n=a.parent(),n.parent().find("select").val(i),n.prev(".select-dropdown").val(e),n.slideToggle(),n.hasClass("actived")?n.removeClass("actived"):n.addClass("actived")}),t(this).on("click",".multiple-select-dropdown li:not(.optgroup, .disabled)",function(){var a,e,i,n,s,l;a=t(this),e=a.attr("data-value"),i=a.find('input[type="checkbox"]'),n=a.parent(),s=n.parent(),a.hasClass("active")?(a.removeClass("active"),i.prop("checked",!1),s.find("select option[value='"+e+"']").prop("selected",!1)):(a.addClass("active"),i.prop("checked",!0),s.find("select option[value='"+e+"']").prop("selected",!0)),l="",s.find("select option:checked").each(function(){l+=t(this).text()+", "}),l=l.replace(/,\s*$/,""),n.prev(".select-dropdown").val(l)}),t(document).on("click",function(a){if(!t(a.target).closest(".dropdown-content").length&&!t(a.target).is(".dropdown-content").length&&!t(a.target).is(".select-dropdown")){var e=o.find(".dropdown-content.actived");e.slideToggle(),e.hasClass("actived")?e.removeClass("actived"):e.addClass("actived")}}),h=function(t){var a,e,i;a=t.attr("type"),e=t.val(),i=t.attr("pattern")?new RegExp(t.attr("pattern"),"g"):"",l(t),i?s(t,i,"Invalid value!"):"email"===a?s(t,/^([\w\-\.]+@([\w\-]+\.)+[\w\-]{2,4})?$/,"Invalid email!"):"url"===a?s(t,/https?:\/\/(www\.)?[\-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([\-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/,"Invalid URL!"):"tel"===a&&s(t,/[\(?\)? ?\d-*]{8,15}/,"Invalid Telephone!")}})}}(jQuery),$(document).ready(function(){"use strict";$(".formalize").formalize()});