-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjqueryform.com.min.js
executable file
·7 lines (6 loc) · 10.4 KB
/
jqueryform.com.min.js
1
2
3
4
5
6
7
/**
Copyright 2015 JQueryForm.com
License: http://jqueryform.com/license.php
Generated by http://www.jqueryform.com
*/
!function(){function a(){$(".jf-form").on({click:function(){var a=$(this),b=a.closest("div.form-group"),c=b.find("input.jf-has-box");c.each(function(){var b=$(this).attr("id")+"_box",c=$("#"+b);$(this).is(":checked")&&c.show(),a.attr("id")+"_box"==b&&c.focus()})}},".jf-has-box"),$(".jf-option-box").blur(function(){var a=String($(this).attr("id")).replace("_box","");""==$.trim($(this).val())&&$("#"+a).attr("checked",!1),$("#"+a).val($(this).val()).trigger("change")})}function b(){var a="%3Ca%20href%3D%22http%3A%2F%2Fwww.jqueryform.com%22%20target%3D%22_blank%22%20class%3D%22jf-copyright%22%20style%3D%22color%3A%20%23888888%3B%20display%3A%20inline-block%3B%20margin%3A%2016px%3B%22%3EPowered%20by%20SLINGalystics%3C%2Fa%3E",b=".jf-",c=b+"form a"+b+"copyright";$(c).length?$(c).prop("href","").text("Powered by SLINGalytics"):$(decodeURIComponent(a)).appendTo($(b+"form")),$(c).show()}function c(a){var c=function(b){var c=$(b),d=c.is("input.form-control")||c.is("select.form-control")||c.is("textarea.form-control"),e=c.closest("div.form-group").find(".file-input-new");c.closest("div.form-group").addClass("bg-info has-error"+(d?" has-feedback":"")),c.is(":visible")&&d&&!c.data("glyphicon")&&($('<span class="glyphicon glyphicon-warning-sign form-control-feedback" aria-hidden="true"></span>').insertAfter(c),setTimeout(function(){var a=0===e.length?c.offset():c.closest("div.form-group").find("div.file-caption").offset(),b=c.closest("div.form-group").find("span.glyphicon-warning-sign"),d={top:a.top+(c.height()-b.height())/2+4,left:a.left+c.width()+10};b.offset(d)},50),c.data("glyphicon",!0)),g($.Event("invalid-form"),$(a).data("validator"))},d=function(b){$(b).data("glyphicon",!1),$(b).closest("div.form-group").removeClass("bg-info has-error has-feedback").find("span.glyphicon,p.validation-error").remove(),g($.Event("invalid-form"),$(a).data("validator"))};$("input[type=file].form-control").on("fileloaded",function(){d(this,"","")});var e=function(a,b){var c=$(b).closest("div.form-group").find("p.description");c.length>0?a.insertBefore(c):a.appendTo($(b).closest("div.form-group"))},f=function(){var a,b=function(){var a=function(){$("#g-recaptcha-response").length&&($("#g-recaptcha-response").rules("add",{required:!0}),clearInterval(b))},b=setInterval(a,800)},c=function(){$("#g-recaptcha-response").length&&($("#g-recaptcha-response").valid(),a=!0)};return{init:b,checkRequired:function(){a||setInterval(c,800)}}}(),g=function(a,b){var c=b.numberOfInvalids();c&&($("p.error").show(),f.checkRequired()),c=b.numberOfInvalids(),c||$("p.error").hasClass("server-error")||$("p.error").hide()},h={},i=function(a){return $.each(h,function(b,c){var d=new RegExp("{"+b+"}","gi");a=a.replace(d,c)}),a},j=function(){var a=$(".jf-thankyou");if(a.length){var b=$.trim(a.data("redirect"));b=decodeURIComponent(b);var c=i(a.html());if(a.html(c),""===b)return void a.show("slow");var d=parseInt(a.data("seconds"));d>0?a.show("slow"):d=0,setTimeout(function(){b=i(b);try{parent&&(parent.location.href=b)}catch(a){location.href=b}},1e3*d)}},k=function(a){if(null===location.href.match(/^https*/)&&null===$(a).attr("action").match(/^https*/))return $("h4.local-submit").length||$("<h4 style='padding:16px;' class='bg-info local-submit'>Form submit does not work on local computer.<br>Please test it on your web server!</h4>").appendTo($(".jf-form")),!1;var b=[];$(a).find("div.required").not(".jf-hide,.jf-disabled").each(function(){b.push($(this).data("cid"))}),$("#serverValidationFields").val(b.join(","));var c=$(a).ajaxSubmit(),d=c.data("jqxhr");$(".submit p.error").removeClass("server-error"),d.done(function(a){a=$.parseJSON(a),a&&a.validated===!0?($(".jf-form").hide(),h=a.fieldValues,j()):$(".submit p.error").addClass("server-error").show("slow")})};$.validator.methods.required=function(a,b,c){if(!this.depend(c,b))return"dependency-mismatch";if("select"===b.nodeName.toLowerCase()){var d=$(b).val();return d&&d.length>0&&""!=d}return this.checkable(b)?this.getLength(a,b)>0:$.trim(a).length>0},$.validator.methods.equalto=$.validator.methods.equalTo;var l=function(){var a=$(this);return a.hasClass("g-recaptcha-response")?!1:(yes=a.is(":hidden")&&!a.hasClass("image-picker")||a.is(":input.tmp-disabled"),yes)},m=0===String($(a).data("licensekey")).toUpperCase().indexOf("JF-");m?$(".jf-copyright").remove():b(),$(a).validate({errorClass:"validation-error help-block bg-warning",errorElement:"p",ignore:l,highlight:c,unhighlight:d,invalidHandler:g,submitHandler:k,errorPlacement:e}),$(".g-recaptcha").length&&f.init()}function d(a){$.jMaskGlobals.watchDataMask=!0,$(a).each(function(a,b){var c,d={},e=$(b).find("input.datepicker");$.each(["format","weekStart","startDate","endDate","startView","minViewMode","todayBtn","clearBtn","language","orientation","multidate","multidateSeparator","daysOfWeekDisabled","calendarWeeks","autoclose","todayHighlight","datesDisabled","toggleActive","defaultViewDate"],function(a,b){c=e.data("datepicker-"+b.toLowerCase()),c&&(d[b]="daysOfWeekDisabled"==b?String(c):c)}),$(b).datepicker(d)})}function e(){$("input[type=file].form-control").each(function(a,b){var c={showUpload:!1,uploadAsync:!1},d=$(b),e=d.data("allowedfileextensions"),f=d.data("maxfilesize");e&&(c.allowedFileExtensions=String(e).replace(/\s+/g,"").split(",")),f&&(c.maxFileSize=parseFloat(String(f))),d.fileinput(c)}),setTimeout(function(){$("div.btn-file").removeClass("btn-primary").addClass("btn-default")},350)}function f(){$("select.image-picker").each(function(){$(this).imagepicker({show_label:$(this).hasClass("show-labels"),clicked:function(){$(this).trigger("change").blur()},selected:function(){$(this).trigger("change").blur()}})}),$("ul.image_picker_selector").on({mouseup:function(){var a=$(this),b=a.closest("div.form-group").find("select.tmp-disabled");return b.length?(setTimeout(function(){a.removeClass("selected"),b.prop("selectedIndex",-1)},100),!1):void 0},mousedown:function(){var a=$(this),b=a.closest("div.form-group").find("select.tmp-disabled"),c=a.hasClass("selected");return b.length?!1:void(c?a.find(".glyphicon-ok-circle").remove():a.append('<i class="glyphicon glyphicon-ok-circle"></i>'))}},"div.thumbnail")}var g={};g.init=function(g){e(),d(".input-group.date"),f(),a(),c(g),setInterval(b,15432)},window.JF=g}(),function(){function a(a,b){for(var c,d=[],e=!1,f=!1,a=String(a).toLowerCase(),g=0,h=b.length;h>g;g++){c=b[g];var i="#depend"==c.label;if(i&&String(c.value).toLowerCase()==a)e=!0;else{if(i&&e&&String(c.value).toLowerCase()!=a){f=!0;break}e&&d.push(c)}}return d}function b(b){var c=d[b];if(c){var e=c.options,f="#"+b,g="#"+c.dependOn;$(g).change(function(){var b=$(this).val(),c=a(b,e),d=[];$(f).empty();for(var g=0,h=c.length;h>g;g++){var i=c[g];d.push('<option value="'+escape(i.value)+'">'+i.label+"</option>")}$(f).append(d.join())})}}function c(a,c){d=c;for(var e in d)d.hasOwnProperty(e)&&b(e)}var d;$(document).on("dependent:setup",c)}(),function(a){"function"!=typeof String.prototype.startsWith&&(String.prototype.startsWith=function(a){return 0===this.indexOf(a)}),"function"!=typeof String.prototype.endsWith&&(String.prototype.endsWith=function(a){return-1!==this.indexOf(a,this.length-a.length)});var b=function(b){this.selector=b;var c=this,d={getValue:function(){var b=null,d=c.selector,e="#"+d,f='input[name="'+d+'"]:checked',g='input[name="'+d+'[]"]:checked',h="";switch(!0){case a("select"+e).length>0:h="select"+e;var i=a(e).val();b=a.isArray(i)&&1===i.length?i[0]:i;break;case a(e).length>0:h=e,b=a(e).val();break;case a(f).length>0:h=f,b=a(f).val();break;case a(g).length>0:h=g;var j=a(g).map(function(){return this.value}).get();b=1===j.length?j[0]:j}return console.log("The value of "+h+" is : ",b),b},$container:function(){var b=a.map(c.selector.split(","),function(a){return"div."+a});return a(b.join(","))},show:function(){d.$container().show("slow")},hide:function(){d.$container().hide("slow")},disable:function(){d.$container().each(function(){a(this).addClass("jf-disabled"),a(this).find(":input").prop("disabled",!0).addClass("tmp-disabled")})},enable:function(){d.$container().each(function(){a(this).removeClass("jf-disabled"),a(this).find(":input.tmp-disabled").prop("disabled",!1).removeClass("tmp-disabled")})},$field:function(){return a("#"+c.selector)}};return{value:d.getValue(),show:d.show,hide:d.hide,disable:d.disable,enable:d.enable,$field:d.$field(),$container:d.$container()}},c=function(c){this.disabled=c&&c.disabled||!1,this.selector=c&&c.selector||"",this.condition=c&&c.condition||"",this.value=c&&c.value||"";var d=this,e=!1,f=new b(d.selector),g=function(b){var c=a.trim(f.value).toLowerCase(),e=a.trim(d.value).toLowerCase();switch(b){case"==":return c==e;case"!=":return c!=e;default:return c[b](e)}},h={"==":function(){return e=g("==")},"!=":function(){return e=g("!=")},"begins with":function(){return e=g("startsWith")},"ends with":function(){return e=g("endsWith")},contains:function(){return e=-1!==g("indexOf")},"not contains":function(){return e=-1===g("indexOf")}},i=function(){return e},j=function(){return d.disabled?(e=!0,!0):e=h[d.condition]()};this.validate=j,this.isValid=i},d=function(d){this.disabled=d&&d.disabled||!1,this.action=d&&d.action||"",this.selector=d&&d.selector||"",this.match=d&&d.match||"",this.rules=d&&d.rules||[];var e=this,f=!1,g=new b(e.selector),h=g.$field,i=g.$container,j=[],k={all:function(){for(var a=!0,b=0,c=j.length;c>b;b++)a=a&&j[b].isValid();return a},any:function(){for(var a=0,b=j.length;b>a;a++)if(j[a].isValid())return!0;return!1},none:function(){for(var a=!0,b=0,c=j.length;c>b;b++)a=a&&!j[b].isValid();return a}},l={show:function(){g.show()},hide:function(){g.hide()},"jump to":function(){a.scrollTo(i,800);try{h.focus()}catch(b){}},disable:function(){g.disable()},enable:function(){g.enable()}},m=function(){j=[];for(var a=0,b=e.rules.length;b>a;a++){var d=new c(e.rules[a]);d.disabled?console.log("ignore disabled rule: ",e.rules[a]):j.push(d)}},n=function(){if(e.disabled)return console.log("ignore disabled logic"),!0;for(var a=0,b=j.length;b>a;a++)j[a].validate();o()},o=function(){f=k[e.match](),console.log("doAction: "+f),f&&(console.log("going to "+e.action+" "+e.selector),l[e.action]())};m(),this.validate=n,this.isValid=f},e=function(a){this.logics=a&&a.logics||[];var b=this,c=[],e=function(){var a,e,f;for(c=[],a=0,e=b.logics.length;e>a;a++)f=new d(b.logics[a]),f.disabled||c.push(f)},f=function(){e(),console.log("Logics",c);for(var a=0,b=c.length;b>a;a++)c[a].validate()};return{validate:f}};a.formlogic=function(a){var b=new e(a);b.validate()}}(jQuery);