contact.js 124 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733
  1. /* Bootstrap v3.2.0 (c) 2011-2014 Twitter, Inc. Licensed under MIT */
  2. if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.2.0",d.prototype.close=function(b){function c(){f.detach().trigger("closed.bs.alert").remove()}var d=a(this),e=d.attr("data-target");e||(e=d.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,""));var f=a(e);b&&b.preventDefault(),f.length||(f=d.hasClass("alert")?d:d.parent()),f.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.one("bsTransitionEnd",c).emulateTransitionEnd(150):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.2.0",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),d[e](null==f[b]?this.options[b]:f[b]),setTimeout(a.proxy(function(){"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?a=!1:b.find(".active").removeClass("active")),a&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}a&&this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),c.preventDefault()})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b).on("keydown.bs.carousel",a.proxy(this.keydown,this)),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.2.0",c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},c.prototype.keydown=function(a){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.to=function(b){var c=this,d=this.getItemIndex(this.$active=this.$element.find(".item.active"));return b>this.$items.length-1||0>b?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){c.to(b)}):d==b?this.pause().cycle():this.slide(b>d?"next":"prev",a(this.$items[b]))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){return this.sliding?void 0:this.slide("next")},c.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},c.prototype.slide=function(b,c){var d=this.$element.find(".item.active"),e=c||d[b](),f=this.interval,g="next"==b?"left":"right",h="next"==b?"first":"last",i=this;if(!e.length){if(!this.options.wrap)return;e=this.$element.find(".item")[h]()}if(e.hasClass("active"))return this.sliding=!1;var j=e[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:g});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,f&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(e)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:g});return a.support.transition&&this.$element.hasClass("slide")?(e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),d.one("bsTransitionEnd",function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(1e3*d.css("transition-duration").slice(0,-1))):(d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger(m)),f&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this},a(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}}),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.collapse"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b);!e&&f.toggle&&"show"==b&&(b=!b),e||d.data("bs.collapse",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.transitioning=null,this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};c.VERSION="3.2.0",c.DEFAULTS={toggle:!0},c.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},c.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var c=a.Event("show.bs.collapse");if(this.$element.trigger(c),!c.isDefaultPrevented()){var d=this.$parent&&this.$parent.find("> .panel > .in");if(d&&d.length){var e=d.data("bs.collapse");if(e&&e.transitioning)return;b.call(d,"hide"),e||d.data("bs.collapse",null)}var f=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[f](0),this.transitioning=1;var g=function(){this.$element.removeClass("collapsing").addClass("collapse in")[f](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return g.call(this);var h=a.camelCase(["scroll",f].join("-"));this.$element.one("bsTransitionEnd",a.proxy(g,this)).emulateTransitionEnd(350)[f](this.$element[0][h])}}},c.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var d=function(){this.transitioning=0,this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(d,this)).emulateTransitionEnd(350):d.call(this)}}},c.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var d=a.fn.collapse;a.fn.collapse=b,a.fn.collapse.Constructor=c,a.fn.collapse.noConflict=function(){return a.fn.collapse=d,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(c){var d,e=a(this),f=e.attr("data-target")||c.preventDefault()||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),g=a(f),h=g.data("bs.collapse"),i=h?"toggle":e.data(),j=e.attr("data-parent"),k=j&&a(j);h&&h.transitioning||(k&&k.find('[data-toggle="collapse"][data-parent="'+j+'"]').not(e).addClass("collapsed"),e[g.hasClass("in")?"addClass":"removeClass"]("collapsed")),b.call(g,i)})}(jQuery),+function(a){"use strict";function b(b){b&&3===b.which||(a(e).remove(),a(f).each(function(){var d=c(a(this)),e={relatedTarget:this};d.hasClass("open")&&(d.trigger(b=a.Event("hide.bs.dropdown",e)),b.isDefaultPrevented()||d.removeClass("open").trigger("hidden.bs.dropdown",e))}))}function c(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.2.0",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=c(e),g=f.hasClass("open");if(b(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a('<div class="dropdown-backdrop"/>').insertAfter(a(this)).on("click",b);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus"),f.toggleClass("open").trigger("shown.bs.dropdown",h)}return!1}},g.prototype.keydown=function(b){if(/(38|40|27)/.test(b.keyCode)){var d=a(this);if(b.preventDefault(),b.stopPropagation(),!d.is(".disabled, :disabled")){var e=c(d),g=e.hasClass("open");if(!g||g&&27==b.keyCode)return 27==b.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.divider):visible a",i=e.find('[role="menu"]'+h+', [role="listbox"]'+h);if(i.length){var j=i.index(i.filter(":focus"));38==b.keyCode&&j>0&&j--,40==b.keyCode&&j<i.length-1&&j++,~j||(j=0),i.eq(j).trigger("focus")}}}};var h=a.fn.dropdown;a.fn.dropdown=d,a.fn.dropdown.Constructor=g,a.fn.dropdown.noConflict=function(){return a.fn.dropdown=h,this},a(document).on("click.bs.dropdown.data-api",b).on("click.bs.dropdown.data-api",".dropdown form",function(a){a.stopPropagation()}).on("click.bs.dropdown.data-api",f,g.prototype.toggle).on("keydown.bs.dropdown.data-api",f+', [role="menu"], [role="listbox"]',g.prototype.keydown)}(jQuery),+function(a){"use strict";function b(b,d){return this.each(function(){var e=a(this),f=e.data("bs.modal"),g=a.extend({},c.DEFAULTS,e.data(),"object"==typeof b&&b);f||e.data("bs.modal",f=new c(this,g)),"string"==typeof b?f[b](d):g.show&&f.show(d)})}var c=function(b,c){this.options=c,this.$body=a(document.body),this.$element=a(b),this.$backdrop=this.isShown=null,this.scrollbarWidth=0,this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,a.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};c.VERSION="3.2.0",c.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},c.prototype.toggle=function(a){return this.isShown?this.hide():this.show(a)},c.prototype.show=function(b){var c=this,d=a.Event("show.bs.modal",{relatedTarget:b});this.$element.trigger(d),this.isShown||d.isDefaultPrevented()||(this.isShown=!0,this.checkScrollbar(),this.$body.addClass("modal-open"),this.setScrollbar(),this.escape(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',a.proxy(this.hide,this)),this.backdrop(function(){var d=a.support.transition&&c.$element.hasClass("fade");c.$element.parent().length||c.$element.appendTo(c.$body),c.$element.show().scrollTop(0),d&&c.$element[0].offsetWidth,c.$element.addClass("in").attr("aria-hidden",!1),c.enforceFocus();var e=a.Event("shown.bs.modal",{relatedTarget:b});d?c.$element.find(".modal-dialog").one("bsTransitionEnd",function(){c.$element.trigger("focus").trigger(e)}).emulateTransitionEnd(300):c.$element.trigger("focus").trigger(e)}))},c.prototype.hide=function(b){b&&b.preventDefault(),b=a.Event("hide.bs.modal"),this.$element.trigger(b),this.isShown&&!b.isDefaultPrevented()&&(this.isShown=!1,this.$body.removeClass("modal-open"),this.resetScrollbar(),this.escape(),a(document).off("focusin.bs.modal"),this.$element.removeClass("in").attr("aria-hidden",!0).off("click.dismiss.bs.modal"),a.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",a.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal())},c.prototype.enforceFocus=function(){a(document).off("focusin.bs.modal").on("focusin.bs.modal",a.proxy(function(a){this.$element[0]===a.target||this.$element.has(a.target).length||this.$element.trigger("focus")},this))},c.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.bs.modal",a.proxy(function(a){27==a.which&&this.hide()},this)):this.isShown||this.$element.off("keyup.dismiss.bs.modal")},c.prototype.hideModal=function(){var a=this;this.$element.hide(),this.backdrop(function(){a.$element.trigger("hidden.bs.modal")})},c.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},c.prototype.backdrop=function(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=a.support.transition&&d;if(this.$backdrop=a('<div class="modal-backdrop '+d+'" />').appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",a.proxy(function(a){a.target===a.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus.call(this.$element[0]):this.hide.call(this))},this)),e&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!b)return;e?this.$backdrop.one("bsTransitionEnd",b).emulateTransitionEnd(150):b()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var f=function(){c.removeBackdrop(),b&&b()};a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",f).emulateTransitionEnd(150):f()}else b&&b()},c.prototype.checkScrollbar=function(){document.body.clientWidth>=window.innerWidth||(this.scrollbarWidth=this.scrollbarWidth||this.measureScrollbar())},c.prototype.setScrollbar=function(){var a=parseInt(this.$body.css("padding-right")||0,10);this.scrollbarWidth&&this.$body.css("padding-right",a+this.scrollbarWidth)},c.prototype.resetScrollbar=function(){this.$body.css("padding-right","")},c.prototype.measureScrollbar=function(){var a=document.createElement("div");a.className="modal-scrollbar-measure",this.$body.append(a);var b=a.offsetWidth-a.clientWidth;return this.$body[0].removeChild(a),b};var d=a.fn.modal;a.fn.modal=b,a.fn.modal.Constructor=c,a.fn.modal.noConflict=function(){return a.fn.modal=d,this},a(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(c){var d=a(this),e=d.attr("href"),f=a(d.attr("data-target")||e&&e.replace(/.*(?=#[^\s]+$)/,"")),g=f.data("bs.modal")?"toggle":a.extend({remote:!/#/.test(e)&&e},f.data(),d.data());d.is("a")&&c.preventDefault(),f.one("show.bs.modal",function(a){a.isDefaultPrevented()||f.one("hidden.bs.modal",function(){d.is(":visible")&&d.trigger("focus")})}),b.call(f,g,this)})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.tooltip"),f="object"==typeof b&&b;(e||"destroy"!=b)&&(e||d.data("bs.tooltip",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.type=this.options=this.enabled=this.timeout=this.hoverState=this.$element=null,this.init("tooltip",a,b)};c.VERSION="3.2.0",c.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(this.options.viewport.selector||this.options.viewport);for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show()},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var c=a.contains(document.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!c)return;var d=this,e=this.tip(),f=this.getUID(this.type);this.setContent(),e.attr("id",f),this.$element.attr("aria-describedby",f),this.options.animation&&e.addClass("fade");var g="function"==typeof this.options.placement?this.options.placement.call(this,e[0],this.$element[0]):this.options.placement,h=/\s?auto?\s?/i,i=h.test(g);i&&(g=g.replace(h,"")||"top"),e.detach().css({top:0,left:0,display:"block"}).addClass(g).data("bs."+this.type,this),this.options.container?e.appendTo(this.options.container):e.insertAfter(this.$element);var j=this.getPosition(),k=e[0].offsetWidth,l=e[0].offsetHeight;if(i){var m=g,n=this.$element.parent(),o=this.getPosition(n);g="bottom"==g&&j.top+j.height+l-o.scroll>o.height?"top":"top"==g&&j.top-o.scroll-l<0?"bottom":"right"==g&&j.right+k>o.width?"left":"left"==g&&j.left-k<o.left?"right":g,e.removeClass(m).addClass(g)}var p=this.getCalculatedOffset(g,j,k,l);this.applyPlacement(p,g);var q=function(){d.$element.trigger("shown.bs."+d.type),d.hoverState=null};a.support.transition&&this.$tip.hasClass("fade")?e.one("bsTransitionEnd",q).emulateTransitionEnd(150):q()}},c.prototype.applyPlacement=function(b,c){var d=this.tip(),e=d[0].offsetWidth,f=d[0].offsetHeight,g=parseInt(d.css("margin-top"),10),h=parseInt(d.css("margin-left"),10);isNaN(g)&&(g=0),isNaN(h)&&(h=0),b.top=b.top+g,b.left=b.left+h,a.offset.setOffset(d[0],a.extend({using:function(a){d.css({top:Math.round(a.top),left:Math.round(a.left)})}},b),0),d.addClass("in");var i=d[0].offsetWidth,j=d[0].offsetHeight;"top"==c&&j!=f&&(b.top=b.top+f-j);var k=this.getViewportAdjustedDelta(c,b,i,j);k.left?b.left+=k.left:b.top+=k.top;var l=k.left?2*k.left-e+i:2*k.top-f+j,m=k.left?"left":"top",n=k.left?"offsetWidth":"offsetHeight";d.offset(b),this.replaceArrow(l,d[0][n],m)},c.prototype.replaceArrow=function(a,b,c){this.arrow().css(c,a?50*(1-a/b)+"%":"")},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},c.prototype.hide=function(){function b(){"in"!=c.hoverState&&d.detach(),c.$element.trigger("hidden.bs."+c.type)}var c=this,d=this.tip(),e=a.Event("hide.bs."+this.type);return this.$element.removeAttr("aria-describedby"),this.$element.trigger(e),e.isDefaultPrevented()?void 0:(d.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?d.one("bsTransitionEnd",b).emulateTransitionEnd(150):b(),this.hoverState=null,this)},c.prototype.fixTitle=function(){var a=this.$element;(a.attr("title")||"string"!=typeof a.attr("data-original-title"))&&a.attr("data-original-title",a.attr("title")||"").attr("title","")},c.prototype.hasContent=function(){return this.getTitle()},c.prototype.getPosition=function(b){b=b||this.$element;var c=b[0],d="BODY"==c.tagName;return a.extend({},"function"==typeof c.getBoundingClientRect?c.getBoundingClientRect():null,{scroll:d?document.documentElement.scrollTop||document.body.scrollTop:b.scrollTop(),width:d?a(window).width():b.outerWidth(),height:d?a(window).height():b.outerHeight()},d?{top:0,left:0}:b.offset())},c.prototype.getCalculatedOffset=function(a,b,c,d){return"bottom"==a?{top:b.top+b.height,left:b.left+b.width/2-c/2}:"top"==a?{top:b.top-d,left:b.left+b.width/2-c/2}:"left"==a?{top:b.top+b.height/2-d/2,left:b.left-c}:{top:b.top+b.height/2-d/2,left:b.left+b.width}},c.prototype.getViewportAdjustedDelta=function(a,b,c,d){var e={top:0,left:0};if(!this.$viewport)return e;var f=this.options.viewport&&this.options.viewport.padding||0,g=this.getPosition(this.$viewport);if(/right|left/.test(a)){var h=b.top-f-g.scroll,i=b.top+f-g.scroll+d;h<g.top?e.top=g.top-h:i>g.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;j<g.left?e.left=g.left-j:k>g.width&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){return this.$tip=this.$tip||a(this.options.template)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.validate=function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){clearTimeout(this.timeout),this.hide().$element.off("."+this.type).removeData("bs."+this.type)};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;(e||"destroy"!=b)&&(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.2.0",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").empty()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},c.prototype.tip=function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){var e=a.proxy(this.process,this);this.$body=a("body"),this.$scrollElement=a(a(c).is("body")?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",e),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.2.0",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b="offset",c=0;a.isWindow(this.$scrollElement[0])||(b="position",c=this.$scrollElement.scrollTop()),this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight();var d=this;this.$body.find(this.selector).map(function(){var d=a(this),e=d.data("target")||d.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[b]().top+c,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){d.offsets.push(this[0]),d.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b<=e[0])return g!=(a=f[0])&&this.activate(a);for(a=e.length;a--;)g!=f[a]&&b>=e[a]&&(!e[a+1]||b<=e[a+1])&&this.activate(f[a])},b.prototype.activate=function(b){this.activeTarget=b,a(this.selector).parentsUntil(this.options.target,".active").removeClass("active");var c=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',d=a(c).parents("li").addClass("active");d.parent(".dropdown-menu").length&&(d=d.closest("li.dropdown").addClass("active")),d.trigger("activate.bs.scrollspy")};var d=a.fn.scrollspy;a.fn.scrollspy=c,a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=d,this},a(window).on("load.bs.scrollspy.data-api",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);c.call(b,b.data())})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new c(this)),"string"==typeof b&&e[b]()})}var c=function(b){this.element=a(b)};c.VERSION="3.2.0",c.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a")[0],f=a.Event("show.bs.tab",{relatedTarget:e});if(b.trigger(f),!f.isDefaultPrevented()){var g=a(d);this.activate(b.closest("li"),c),this.activate(g,g.parent(),function(){b.trigger({type:"shown.bs.tab",relatedTarget:e})})}}},c.prototype.activate=function(b,c,d){function e(){f.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),g?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var f=c.find("> .active"),g=d&&a.support.transition&&f.hasClass("fade");g?f.one("bsTransitionEnd",e).emulateTransitionEnd(150):e(),f.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this},a(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(c){c.preventDefault(),b.call(a(this),"show")})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=this.unpin=this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.2.0",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=a(document).height(),d=this.$target.scrollTop(),e=this.$element.offset(),f=this.options.offset,g=f.top,h=f.bottom;"object"!=typeof f&&(h=g=f),"function"==typeof g&&(g=f.top(this.$element)),"function"==typeof h&&(h=f.bottom(this.$element));var i=null!=this.unpin&&d+this.unpin<=e.top?!1:null!=h&&e.top+this.$element.height()>=b-h?"bottom":null!=g&&g>=d?"top":!1;if(this.affixed!==i){null!=this.unpin&&this.$element.css("top","");var j="affix"+(i?"-"+i:""),k=a.Event(j+".bs.affix");this.$element.trigger(k),k.isDefaultPrevented()||(this.affixed=i,this.unpin="bottom"==i?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(j).trigger(a.Event(j.replace("affix","affixed"))),"bottom"==i&&this.$element.offset({top:b-this.$element.height()-h}))}}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},d.offsetBottom&&(d.offset.bottom=d.offsetBottom),d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery);
  3. /* Bootstrap: offcanvas.js v3.1.3 (c) 2012-2014 Arnold Daniels Licensed under Apache */
  4. +function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d),this.state=null,this.placement=null,this.options.recalc&&(this.calcClone(),a(window).on("resize",a.proxy(this.recalc,this))),this.options.autohide&&a(document).on("click",a.proxy(this.autohide,this)),this.options.toggle&&this.toggle(),this.options.disablescrolling&&(this.options.disableScrolling=this.options.disablescrolling,delete this.options.disablescrolling)};b.DEFAULTS={toggle:!0,placement:"auto",autohide:!0,recalc:!0,disableScrolling:!0},b.prototype.offset=function(){switch(this.placement){case"left":case"right":return this.$element.outerWidth();case"top":case"bottom":return this.$element.outerHeight()}},b.prototype.calcPlacement=function(){function e(a,b){if(d.css(b)==="auto")return a;if(d.css(a)==="auto")return b;var c=parseInt(d.css(a),10),e=parseInt(d.css(b),10);return c>e?b:a}if(this.options.placement!=="auto"){this.placement=this.options.placement;return}this.$element.hasClass("in")||this.$element.css("visiblity","hidden !important").addClass("in");var b=a(window).width()/this.$element.width(),c=a(window).height()/this.$element.height(),d=this.$element;this.placement=b>=c?e("left","right"):e("top","bottom"),this.$element.css("visibility")==="hidden !important"&&this.$element.removeClass("in").css("visiblity","")},b.prototype.opposite=function(a){switch(a){case"top":return"bottom";case"left":return"right";case"bottom":return"top";case"right":return"left"}},b.prototype.getCanvasElements=function(){var b=this.options.canvas?a(this.options.canvas):this.$element,c=b.find("*").filter(function(){return a(this).css("position")==="fixed"}).not(this.options.exclude);return b.add(c)},b.prototype.slide=function(b,c,d){if(!a.support.transition){var e={};return e[this.placement]="+="+c,b.animate(e,350,d)}var f=this.placement,g=this.opposite(f);b.each(function(){a(this).css(f)!=="auto"&&a(this).css(f,(parseInt(a(this).css(f),10)||0)+c),a(this).css(g)!=="auto"&&a(this).css(g,(parseInt(a(this).css(g),10)||0)-c)}),this.$element.one(a.support.transition.end,d).emulateTransitionEnd(350)},b.prototype.disableScrolling=function(){var b=a("body").width(),c="padding-"+this.opposite(this.placement);a("body").data("offcanvas-style")===undefined&&a("body").data("offcanvas-style",a("body").attr("style")||""),a("body").css("overflow","hidden");if(a("body").width()>b){var d=parseInt(a("body").css(c),10)+a("body").width()-b;setTimeout(function(){a("body").css(c,d)},1)}},b.prototype.show=function(){if(this.state)return;var b=a.Event("show.bs.offcanvas");this.$element.trigger(b);if(b.isDefaultPrevented())return;this.state="slide-in",this.calcPlacement();var c=this.getCanvasElements(),d=this.placement,e=this.opposite(d),f=this.offset();c.index(this.$element)!==-1&&(a(this.$element).data("offcanvas-style",a(this.$element).attr("style")||""),this.$element.css(d,-1*f),this.$element.css(d)),c.addClass("canvas-sliding").each(function(){a(this).data("offcanvas-style")===undefined&&a(this).data("offcanvas-style",a(this).attr("style")||""),a(this).css("position")==="static"&&a(this).css("position","relative"),(a(this).css(d)==="auto"||a(this).css(d)==="0px")&&(a(this).css(e)==="auto"||a(this).css(e)==="0px")&&a(this).css(d,0)}),this.options.disableScrolling&&this.disableScrolling();var g=function(){if(this.state!="slide-in")return;this.state="slid",c.removeClass("canvas-sliding").addClass("canvas-slid"),this.$element.trigger("shown.bs.offcanvas")};setTimeout(a.proxy(function(){this.$element.addClass("in"),this.slide(c,f,a.proxy(g,this))},this),1)},b.prototype.hide=function(b){if(this.state!=="slid")return;var c=a.Event("hide.bs.offcanvas");this.$element.trigger(c);if(c.isDefaultPrevented())return;this.state="slide-out";var d=a(".canvas-slid"),e=this.placement,f=-1*this.offset(),g=function(){if(this.state!="slide-out")return;this.state=null,this.placement=null,this.$element.removeClass("in"),d.removeClass("canvas-sliding"),d.add(this.$element).add("body").each(function(){a(this).attr("style",a(this).data("offcanvas-style")).removeData("offcanvas-style")}),this.$element.trigger("hidden.bs.offcanvas")};d.removeClass("canvas-slid").addClass("canvas-sliding"),setTimeout(a.proxy(function(){this.slide(d,f,a.proxy(g,this))},this),1)},b.prototype.toggle=function(){if(this.state==="slide-in"||this.state==="slide-out")return;this[this.state==="slid"?"hide":"show"]()},b.prototype.calcClone=function(){this.$calcClone=this.$element.clone().html("").addClass("offcanvas-clone").removeClass("in").appendTo(a("body"))},b.prototype.recalc=function(){if(this.$calcClone.css("display")==="none"||this.state!=="slid"&&this.state!=="slide-in")return;this.state=null,this.placement=null;var b=this.getCanvasElements();this.$element.removeClass("in"),b.removeClass("canvas-slid"),b.add(this.$element).add("body").each(function(){a(this).attr("style",a(this).data("offcanvas-style")).removeData("offcanvas-style")})},b.prototype.autohide=function(b){a(b.target).closest(this.$element).length===0&&this.hide()};var c=a.fn.offcanvas;a.fn.offcanvas=function(c){return this.each(function(){var d=a(this),e=d.data("bs.offcanvas"),f=a.extend({},b.DEFAULTS,d.data(),typeof c=="object"&&c);e||d.data("bs.offcanvas",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.offcanvas.Constructor=b,a.fn.offcanvas.noConflict=function(){return a.fn.offcanvas=c,this},a(document).on("click.bs.offcanvas.data-api","[data-toggle=offcanvas]",function(b){var c=a(this),d,e=c.attr("data-target")||b.preventDefault()||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),f=a(e),g=f.data("bs.offcanvas"),h=g?"toggle":c.data();b.stopPropagation(),g?g.toggle():f.offcanvas(h)})}(window.jQuery)
  5. /*============================================
  6. Navigation
  7. ==============================================*/
  8. $('.nav-toggle').on('touchstart click', function(e) {
  9. e.preventDefault();
  10. $( this ).toggleClass( 'active' );
  11. });
  12. $(function dw_hidenav() {
  13. var headerHeight = $('.navbar').height();
  14. $(window).on('scroll', { previousTop: 0 },
  15. function() {
  16. var currentTop = $(window).scrollTop();
  17. if (currentTop < this.previousTop) {
  18. if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
  19. $('.navbar').addClass('visible');
  20. } else {
  21. $('.navbar').removeClass('visible fixed');
  22. }
  23. }
  24. else {
  25. $('.navbar').removeClass('visible');
  26. if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
  27. }
  28. this.previousTop = currentTop;
  29. }
  30. );
  31. });
  32. /*============================================
  33. jQuery JSON
  34. ==============================================*/
  35. /**
  36. * jQuery JSON plugin v2.5.1
  37. * https://github.com/Krinkle/jquery-json
  38. *
  39. * @author Brantley Harris, 2009-2011
  40. * @author Timo Tijhof, 2011-2014
  41. * @source This plugin is heavily influenced by MochiKit's serializeJSON, which is
  42. * copyrighted 2005 by Bob Ippolito.
  43. * @source Brantley Harris wrote this plugin. It is based somewhat on the JSON.org
  44. * website's http://www.json.org/json2.js, which proclaims:
  45. * "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
  46. * I uphold.
  47. * @license MIT License <http://opensource.org/licenses/MIT>
  48. */
  49. (function ($) {
  50. 'use strict';
  51. var escape = /["\\\x00-\x1f\x7f-\x9f]/g,
  52. meta = {
  53. '\b': '\\b',
  54. '\t': '\\t',
  55. '\n': '\\n',
  56. '\f': '\\f',
  57. '\r': '\\r',
  58. '"': '\\"',
  59. '\\': '\\\\'
  60. },
  61. hasOwn = Object.prototype.hasOwnProperty;
  62. /**
  63. * jQuery.toJSON
  64. * Converts the given argument into a JSON representation.
  65. *
  66. * @param o {Mixed} The json-serializable *thing* to be converted
  67. *
  68. * If an object has a toJSON prototype, that will be used to get the representation.
  69. * Non-integer/string keys are skipped in the object, as are keys that point to a
  70. * function.
  71. *
  72. */
  73. $.toJSON = typeof JSON === 'object' && JSON.stringify ? JSON.stringify : function (o) {
  74. if (o === null) {
  75. return 'null';
  76. }
  77. var pairs, k, name, val,
  78. type = $.type(o);
  79. if (type === 'undefined') {
  80. return undefined;
  81. }
  82. // Also covers instantiated Number and Boolean objects,
  83. // which are typeof 'object' but thanks to $.type, we
  84. // catch them here. I don't know whether it is right
  85. // or wrong that instantiated primitives are not
  86. // exported to JSON as an {"object":..}.
  87. // We choose this path because that's what the browsers did.
  88. if (type === 'number' || type === 'boolean') {
  89. return String(o);
  90. }
  91. if (type === 'string') {
  92. return $.quoteString(o);
  93. }
  94. if (typeof o.toJSON === 'function') {
  95. return $.toJSON(o.toJSON());
  96. }
  97. if (type === 'date') {
  98. var month = o.getUTCMonth() + 1,
  99. day = o.getUTCDate(),
  100. year = o.getUTCFullYear(),
  101. hours = o.getUTCHours(),
  102. minutes = o.getUTCMinutes(),
  103. seconds = o.getUTCSeconds(),
  104. milli = o.getUTCMilliseconds();
  105. if (month < 10) {
  106. month = '0' + month;
  107. }
  108. if (day < 10) {
  109. day = '0' + day;
  110. }
  111. if (hours < 10) {
  112. hours = '0' + hours;
  113. }
  114. if (minutes < 10) {
  115. minutes = '0' + minutes;
  116. }
  117. if (seconds < 10) {
  118. seconds = '0' + seconds;
  119. }
  120. if (milli < 100) {
  121. milli = '0' + milli;
  122. }
  123. if (milli < 10) {
  124. milli = '0' + milli;
  125. }
  126. return '"' + year + '-' + month + '-' + day + 'T' +
  127. hours + ':' + minutes + ':' + seconds +
  128. '.' + milli + 'Z"';
  129. }
  130. pairs = [];
  131. if ($.isArray(o)) {
  132. for (k = 0; k < o.length; k++) {
  133. pairs.push($.toJSON(o[k]) || 'null');
  134. }
  135. return '[' + pairs.join(',') + ']';
  136. }
  137. // Any other object (plain object, RegExp, ..)
  138. // Need to do typeof instead of $.type, because we also
  139. // want to catch non-plain objects.
  140. if (typeof o === 'object') {
  141. for (k in o) {
  142. // Only include own properties,
  143. // Filter out inherited prototypes
  144. if (hasOwn.call(o, k)) {
  145. // Keys must be numerical or string. Skip others
  146. type = typeof k;
  147. if (type === 'number') {
  148. name = '"' + k + '"';
  149. } else if (type === 'string') {
  150. name = $.quoteString(k);
  151. } else {
  152. continue;
  153. }
  154. type = typeof o[k];
  155. // Invalid values like these return undefined
  156. // from toJSON, however those object members
  157. // shouldn't be included in the JSON string at all.
  158. if (type !== 'function' && type !== 'undefined') {
  159. val = $.toJSON(o[k]);
  160. pairs.push(name + ':' + val);
  161. }
  162. }
  163. }
  164. return '{' + pairs.join(',') + '}';
  165. }
  166. };
  167. /**
  168. * jQuery.evalJSON
  169. * Evaluates a given json string.
  170. *
  171. * @param str {String}
  172. */
  173. $.evalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
  174. /*jshint evil: true */
  175. return eval('(' + str + ')');
  176. };
  177. /**
  178. * jQuery.secureEvalJSON
  179. * Evals JSON in a way that is *more* secure.
  180. *
  181. * @param str {String}
  182. */
  183. $.secureEvalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
  184. var filtered =
  185. str
  186. .replace(/\\["\\\/bfnrtu]/g, '@')
  187. .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
  188. .replace(/(?:^|:|,)(?:\s*\[)+/g, '');
  189. if (/^[\],:{}\s]*$/.test(filtered)) {
  190. /*jshint evil: true */
  191. return eval('(' + str + ')');
  192. }
  193. throw new SyntaxError('Error parsing JSON, source is not valid.');
  194. };
  195. /**
  196. * jQuery.quoteString
  197. * Returns a string-repr of a string, escaping quotes intelligently.
  198. * Mostly a support function for toJSON.
  199. * Examples:
  200. * >>> jQuery.quoteString('apple')
  201. * "apple"
  202. *
  203. * >>> jQuery.quoteString('"Where are we going?", she asked.')
  204. * "\"Where are we going?\", she asked."
  205. */
  206. $.quoteString = function (str) {
  207. if (str.match(escape)) {
  208. return '"' + str.replace(escape, function (a) {
  209. var c = meta[a];
  210. if (typeof c === 'string') {
  211. return c;
  212. }
  213. c = a.charCodeAt();
  214. return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
  215. }) + '"';
  216. }
  217. return '"' + str + '"';
  218. };
  219. }(jQuery));
  220. /*============================================
  221. Placeholders.js v2.1.1
  222. ==============================================*/
  223. (function(t){"use strict";function e(t,e,r){return t.addEventListener?t.addEventListener(e,r,!1):t.attachEvent?t.attachEvent("on"+e,r):void 0}function r(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(t[r]===e)return!0;return!1}function n(t,e){var r;t.createTextRange?(r=t.createTextRange(),r.move("character",e),r.select()):t.selectionStart&&(t.focus(),t.setSelectionRange(e,e))}function a(t,e){try{return t.type=e,!0}catch(r){return!1}}t.Placeholders={Utils:{addEventListener:e,inArray:r,moveCaret:n,changeType:a}}})(this),function(t){"use strict";function e(){}function r(t,e){var r,n,a=!!e&&t.value!==e,u=t.value===t.getAttribute(V);return(a||u)&&"true"===t.getAttribute(D)?(t.setAttribute(D,"false"),t.value=t.value.replace(t.getAttribute(V),""),t.className=t.className.replace(R,""),n=t.getAttribute(z),n&&(t.setAttribute("maxLength",n),t.removeAttribute(z)),r=t.getAttribute(I),r&&(t.type=r),!0):!1}function n(t){var e,r,n=t.getAttribute(V);return""===t.value&&n?(t.setAttribute(D,"true"),t.value=n,t.className+=" "+k,r=t.getAttribute(z),r||(t.setAttribute(z,t.maxLength),t.removeAttribute("maxLength")),e=t.getAttribute(I),e?t.type="text":"password"===t.type&&K.changeType(t,"text")&&t.setAttribute(I,"password"),!0):!1}function a(t,e){var r,n,a,u,i;if(t&&t.getAttribute(V))e(t);else for(r=t?t.getElementsByTagName("input"):p,n=t?t.getElementsByTagName("textarea"):h,i=0,u=r.length+n.length;u>i;i++)a=r.length>i?r[i]:n[i-r.length],e(a)}function u(t){a(t,r)}function i(t){a(t,n)}function l(t){return function(){b&&t.value===t.getAttribute(V)&&"true"===t.getAttribute(D)?K.moveCaret(t,0):r(t)}}function o(t){return function(){n(t)}}function c(t){return function(e){return m=t.value,"true"===t.getAttribute(D)&&m===t.getAttribute(V)&&K.inArray(C,e.keyCode)?(e.preventDefault&&e.preventDefault(),!1):void 0}}function s(t){return function(){r(t,m),""===t.value&&(t.blur(),K.moveCaret(t,0))}}function d(t){return function(){t===document.activeElement&&t.value===t.getAttribute(V)&&"true"===t.getAttribute(D)&&K.moveCaret(t,0)}}function g(t){return function(){u(t)}}function v(t){t.form&&(L=t.form,L.getAttribute(P)||(K.addEventListener(L,"submit",g(L)),L.setAttribute(P,"true"))),K.addEventListener(t,"focus",l(t)),K.addEventListener(t,"blur",o(t)),b&&(K.addEventListener(t,"keydown",c(t)),K.addEventListener(t,"keyup",s(t)),K.addEventListener(t,"click",d(t))),t.setAttribute(U,"true"),t.setAttribute(V,E),n(t)}var p,h,b,f,m,A,y,E,x,L,T,N,S,w=["text","search","url","tel","email","password","number","textarea"],C=[27,33,34,35,36,37,38,39,40,8,46],B="#ccc",k="placeholdersjs",R=RegExp("(?:^|\\s)"+k+"(?!\\S)"),V="data-placeholder-value",D="data-placeholder-active",I="data-placeholder-type",P="data-placeholder-submit",U="data-placeholder-bound",j="data-placeholder-focus",q="data-placeholder-live",z="data-placeholder-maxlength",F=document.createElement("input"),G=document.getElementsByTagName("head")[0],H=document.documentElement,J=t.Placeholders,K=J.Utils;if(J.nativeSupport=void 0!==F.placeholder,!J.nativeSupport){for(p=document.getElementsByTagName("input"),h=document.getElementsByTagName("textarea"),b="false"===H.getAttribute(j),f="false"!==H.getAttribute(q),A=document.createElement("style"),A.type="text/css",y=document.createTextNode("."+k+" { color:"+B+"; }"),A.styleSheet?A.styleSheet.cssText=y.nodeValue:A.appendChild(y),G.insertBefore(A,G.firstChild),S=0,N=p.length+h.length;N>S;S++)T=p.length>S?p[S]:h[S-p.length],E=T.attributes.placeholder,E&&(E=E.nodeValue,E&&K.inArray(w,T.type)&&v(T));x=setInterval(function(){for(S=0,N=p.length+h.length;N>S;S++)T=p.length>S?p[S]:h[S-p.length],E=T.attributes.placeholder,E&&(E=E.nodeValue,E&&K.inArray(w,T.type)&&(T.getAttribute(U)||v(T),(E!==T.getAttribute(V)||"password"===T.type&&!T.getAttribute(I))&&("password"===T.type&&!T.getAttribute(I)&&K.changeType(T,"text")&&T.setAttribute(I,"password"),T.value===T.getAttribute(V)&&(T.value=E),T.setAttribute(V,E))));f||clearInterval(x)},100)}J.disable=J.nativeSupport?e:u,J.enable=J.nativeSupport?e:i}(this);
  224. /*============================================
  225. Gravity Forms
  226. ==============================================*/
  227. // "prop" method fix for previous versions of jQuery (1.5 and below)
  228. if( typeof jQuery.fn.prop === 'undefined' ) {
  229. jQuery.fn.prop = jQuery.fn.attr;
  230. }
  231. jQuery(document).ready(function(){
  232. //Formatting free form currency fields to currency
  233. jQuery(document).bind('gform_post_render', gformBindFormatPricingFields);
  234. });
  235. function gformBindFormatPricingFields(){
  236. jQuery(".ginput_amount, .ginput_donation_amount").bind("change", function(){
  237. gformFormatPricingField(this);
  238. });
  239. jQuery(".ginput_amount, .ginput_donation_amount").each(function(){
  240. gformFormatPricingField(this);
  241. });
  242. }
  243. //------------------------------------------------
  244. //---------- CURRENCY ----------------------------
  245. //------------------------------------------------
  246. function Currency(currency){
  247. this.currency = currency;
  248. this.toNumber = function(text){
  249. if(this.isNumeric(text))
  250. return parseFloat(text);
  251. return gformCleanNumber(text, this.currency["symbol_right"], this.currency["symbol_left"], this.currency["decimal_separator"]);
  252. };
  253. this.toMoney = function(number){
  254. if(!this.isNumeric(number))
  255. number = this.toNumber(number);
  256. if(number === false)
  257. return "";
  258. number = number + "";
  259. negative = "";
  260. if(number[0] == "-"){
  261. number = parseFloat(number.substr(1));
  262. negative = '-';
  263. }
  264. money = this.numberFormat(number, this.currency["decimals"], this.currency["decimal_separator"], this.currency["thousand_separator"]);
  265. if ( money == '0.00' ){
  266. negative = '';
  267. }
  268. var symbol_left = this.currency["symbol_left"] ? this.currency["symbol_left"] + this.currency["symbol_padding"] : "";
  269. var symbol_right = this.currency["symbol_right"] ? this.currency["symbol_padding"] + this.currency["symbol_right"] : "";
  270. money = negative + this.htmlDecode(symbol_left) + money + this.htmlDecode(symbol_right);
  271. return money;
  272. };
  273. this.numberFormat = function(number, decimals, dec_point, thousands_sep, padded){
  274. var padded = typeof padded == 'undefined';
  275. number = (number+'').replace(',', '').replace(' ', '');
  276. var n = !isFinite(+number) ? 0 : +number,
  277. prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
  278. sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
  279. s = '',
  280. toFixedFix = function (n, prec) {
  281. var k = Math.pow(10, prec);
  282. return '' + Math.round(n * k) / k;
  283. };
  284. if(decimals == '0') {
  285. n = n + 0.0000000001; // getting around floating point arithmetic issue when rounding. ( i.e. 4.005 is represented as 4.004999999999 and gets rounded to 4.00 instead of 4.01 )
  286. s = ('' + Math.round(n)).split('.');
  287. } else
  288. if(decimals == -1) {
  289. s = ('' + n).split('.');
  290. } else {
  291. n = n + 0.0000000001; // getting around floating point arithmetic issue when rounding. ( i.e. 4.005 is represented as 4.004999999999 and gets rounded to 4.00 instead of 4.01 )
  292. // Fix for IE parseFloat(0.55).toFixed(0) = 0;
  293. s = toFixedFix(n, prec).split('.');
  294. }
  295. if (s[0].length > 3) {
  296. s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
  297. }
  298. if(padded) {
  299. if ((s[1] || '').length < prec) {
  300. s[1] = s[1] || '';
  301. s[1] += new Array(prec - s[1].length + 1).join('0');
  302. }
  303. }
  304. return s.join(dec);
  305. }
  306. this.isNumeric = function(number){
  307. return gformIsNumber(number);
  308. };
  309. this.htmlDecode = function(text) {
  310. var c,m,d = text;
  311. // look for numerical entities &#34;
  312. var arr=d.match(/&#[0-9]{1,5};/g);
  313. // if no matches found in string then skip
  314. if(arr!=null){
  315. for(var x=0;x<arr.length;x++){
  316. m = arr[x];
  317. c = m.substring(2,m.length-1); //get numeric part which is refernce to unicode character
  318. // if its a valid number we can decode
  319. if(c >= -32768 && c <= 65535){
  320. // decode every single match within string
  321. d = d.replace(m, String.fromCharCode(c));
  322. }else{
  323. d = d.replace(m, ""); //invalid so replace with nada
  324. }
  325. }
  326. }
  327. return d;
  328. };
  329. }
  330. function gformCleanNumber(text, symbol_right, symbol_left, decimal_separator){
  331. var clean_number = '',
  332. float_number = '',
  333. digit = '',
  334. is_negative = false;
  335. //converting to a string if a number as passed
  336. text = text + " ";
  337. //Removing symbol in unicode format (i.e. &#4444;)
  338. text = text.replace(/&.*?;/g, "");
  339. //Removing symbol from text
  340. text = text.replace(symbol_right, "");
  341. text = text.replace(symbol_left, "");
  342. //Removing all non-numeric characters
  343. for(var i=0; i<text.length; i++){
  344. digit = text.substr(i,1);
  345. if( (parseInt(digit) >= 0 && parseInt(digit) <= 9) || digit == decimal_separator )
  346. clean_number += digit;
  347. else if(digit == '-')
  348. is_negative = true;
  349. }
  350. //Removing thousand separators but keeping decimal point
  351. for(var i=0; i<clean_number.length; i++) {
  352. digit = clean_number.substr(i,1);
  353. if (digit >= '0' && digit <= '9')
  354. float_number += digit;
  355. else if(digit == decimal_separator){
  356. float_number += ".";
  357. }
  358. }
  359. if(is_negative)
  360. float_number = "-" + float_number;
  361. return gformIsNumber(float_number) ? parseFloat(float_number) : false;
  362. }
  363. function gformGetDecimalSeparator(numberFormat){
  364. var s;
  365. switch (numberFormat){
  366. case 'currency' :
  367. var currency = new Currency(gf_global.gf_currency_config);
  368. s = currency.currency["decimal_separator"];
  369. break;
  370. case 'decimal_comma' :
  371. s = ',';
  372. break;
  373. default :
  374. s = "."
  375. }
  376. return s;
  377. }
  378. function gformIsNumber(n) {
  379. return !isNaN(parseFloat(n)) && isFinite(n);
  380. }
  381. function gformIsNumeric(value, number_format){
  382. switch(number_format){
  383. case "decimal_dot" :
  384. var r = new RegExp("^(-?[0-9]{1,3}(?:,?[0-9]{3})*(?:\.[0-9]+)?)$");
  385. return r.test(value);
  386. break;
  387. case "decimal_comma" :
  388. var r = new RegExp("^(-?[0-9]{1,3}(?:\.?[0-9]{3})*(?:,[0-9]+)?)$");
  389. return r.test(value);
  390. break;
  391. }
  392. return false;
  393. }
  394. //------------------------------------------------
  395. //---------- MULTI-PAGE --------------------------
  396. //------------------------------------------------
  397. function gformDeleteUploadedFile(formId, fieldId, deleteButton){
  398. var parent = jQuery("#field_" + formId + "_" + fieldId);
  399. var fileIndex = jQuery(deleteButton).parent().index();
  400. parent.find(".ginput_preview").eq(fileIndex).remove();
  401. //displaying single file upload field
  402. parent.find("input[type=\"file\"]").removeClass("gform_hidden");
  403. //displaying post image label
  404. parent.find(".ginput_post_image_file").show();
  405. //clearing post image meta fields
  406. parent.find("input[type=\"text\"]").val('');
  407. //removing file from uploaded meta
  408. var filesJson = jQuery('#gform_uploaded_files_' + formId).val();
  409. if(filesJson){
  410. var files = jQuery.secureEvalJSON(filesJson);
  411. if(files) {
  412. var inputName = "input_" + fieldId;
  413. var $multfile = parent.find("#gform_multifile_upload_" + formId + "_" + fieldId );
  414. if( $multfile.length > 0 ) {
  415. files[inputName].splice(fileIndex, 1);
  416. var settings = $multfile.data('settings');
  417. var max = settings.gf_vars.max_files;
  418. jQuery("#" + settings.gf_vars.message_id).html('');
  419. if(files[inputName].length < max)
  420. gfMultiFileUploader.toggleDisabled(settings, false);
  421. } else {
  422. files[inputName] = null;
  423. }
  424. jQuery('#gform_uploaded_files_' + formId).val(jQuery.toJSON(files));
  425. }
  426. }
  427. }
  428. //------------------------------------------------
  429. //---------- PRICE -------------------------------
  430. //------------------------------------------------
  431. var _gformPriceFields = new Array();
  432. var _anyProductSelected;
  433. function gformIsHidden(element){
  434. return element.parents('.gfield').not(".gfield_hidden_product").css("display") == "none";
  435. }
  436. function gformCalculateTotalPrice(formId){
  437. if(!_gformPriceFields[formId])
  438. return;
  439. var price = 0;
  440. _anyProductSelected = false; //Will be used by gformCalculateProductPrice().
  441. for(var i=0; i<_gformPriceFields[formId].length; i++){
  442. price += gformCalculateProductPrice(formId, _gformPriceFields[formId][i]);
  443. }
  444. //add shipping price if a product has been selected
  445. if(_anyProductSelected){
  446. //shipping price
  447. var shipping = gformGetShippingPrice(formId)
  448. price += shipping;
  449. }
  450. //gform_product_total filter. Allows uers to perform custom price calculation
  451. if(window["gform_product_total"])
  452. price = window["gform_product_total"](formId, price);
  453. price = gform.applyFilters('gform_product_total', price, formId);
  454. //updating total
  455. var totalElement = jQuery(".ginput_total_" + formId);
  456. if( totalElement.length > 0 ) {
  457. var currentTotal = totalElement.next().val(),
  458. formattedTotal = gformFormatMoney(price);
  459. if (currentTotal != price) {
  460. totalElement.next().val(price).change();
  461. }
  462. if (formattedTotal != totalElement.first().text()) {
  463. totalElement.html(formattedTotal);
  464. }
  465. }
  466. }
  467. function gformGetShippingPrice(formId){
  468. var shippingField = jQuery(".gfield_shipping_" + formId + " input[type=\"hidden\"], .gfield_shipping_" + formId + " select, .gfield_shipping_" + formId + " input:checked");
  469. var shipping = 0;
  470. if(shippingField.length == 1 && !gformIsHidden(shippingField)){
  471. if(shippingField.attr("type") && shippingField.attr("type").toLowerCase() == "hidden")
  472. shipping = shippingField.val();
  473. else
  474. shipping = gformGetPrice(shippingField.val());
  475. }
  476. return gformToNumber(shipping);
  477. }
  478. function gformGetFieldId(element){
  479. var id = jQuery(element).attr("id");
  480. var pieces = id.split("_");
  481. if(pieces.length <=0)
  482. return 0;
  483. var fieldId = pieces[pieces.length-1];
  484. return fieldId;
  485. }
  486. function gformCalculateProductPrice(form_id, productFieldId){
  487. var suffix = '_' + form_id + '_' + productFieldId;
  488. //Drop down auto-calculating labels
  489. jQuery('.gfield_option' + suffix + ', .gfield_shipping_' + form_id).find('select').each(function(){
  490. var dropdown_field = jQuery(this);
  491. var selected_price = gformGetPrice(dropdown_field.val());
  492. var field_id = dropdown_field.attr('id').split('_')[2];
  493. dropdown_field.children('option').each(function(){
  494. var choice_element = jQuery(this);
  495. var label = gformGetOptionLabel(choice_element, choice_element.val(), selected_price, form_id, field_id);
  496. choice_element.html(label);
  497. });
  498. dropdown_field.trigger('chosen:updated');
  499. });
  500. //Checkboxes labels with prices
  501. jQuery('.gfield_option' + suffix).find('.gfield_checkbox').find('input:checkbox').each(function(){
  502. var checkbox_item = jQuery(this);
  503. var id = checkbox_item.attr('id');
  504. var field_id = id.split('_')[2];
  505. var label_id = id.replace('choice_', '#label_');
  506. var label_element = jQuery(label_id);
  507. var label = gformGetOptionLabel(label_element, checkbox_item.val(), 0, form_id, field_id);
  508. label_element.html(label);
  509. });
  510. //Radio button auto-calculating lables
  511. jQuery('.gfield_option' + suffix + ', .gfield_shipping_' + form_id).find('.gfield_radio').each(function(){
  512. var selected_price = 0;
  513. var radio_field = jQuery(this);
  514. var id = radio_field.attr('id');
  515. var fieldId = id.split('_')[2];
  516. var selected_value = radio_field.find('input:radio:checked').val();
  517. if(selected_value)
  518. selected_price = gformGetPrice(selected_value);
  519. radio_field.find('input:radio').each(function(){
  520. var radio_item = jQuery(this);
  521. var label_id = radio_item.attr('id').replace('choice_', '#label_');
  522. var label_element = jQuery(label_id);
  523. if ( label_element ) {
  524. var label = gformGetOptionLabel(label_element, radio_item.val(), selected_price, form_id, fieldId);
  525. label_element.html(label);
  526. }
  527. });
  528. });
  529. var price = gformGetBasePrice(form_id, productFieldId);
  530. var quantity = gformGetProductQuantity( form_id, productFieldId );
  531. //calculating options if quantity is more than 0 (a product was selected).
  532. if( quantity > 0 ) {
  533. jQuery('.gfield_option' + suffix).find('input:checked, select').each(function(){
  534. if(!gformIsHidden(jQuery(this)))
  535. price += gformGetPrice(jQuery(this).val());
  536. });
  537. //setting global variable if quantity is more than 0 (a product was selected). Will be used when calculating total
  538. _anyProductSelected = true;
  539. }
  540. price = price * quantity;
  541. price = Math.round(price * 100) / 100;
  542. return price;
  543. }
  544. function gformGetProductQuantity(formId, productFieldId) {
  545. //If product is not selected
  546. if (!gformIsProductSelected(formId, productFieldId)) {
  547. return 0;
  548. }
  549. var quantity,
  550. quantityInput = jQuery('#ginput_quantity_' + formId + '_' + productFieldId),
  551. numberFormat;
  552. if (quantityInput.length > 0) {
  553. quantity = quantityInput.val();
  554. } else {
  555. quantityInput = jQuery('.gfield_quantity_' + formId + '_' + productFieldId + ' :input');
  556. quantity = 1;
  557. if (quantityInput.length > 0) {
  558. quantity = quantityInput.val();
  559. var htmlId = quantityInput.attr('id'),
  560. fieldId = gf_get_input_id_by_html_id(htmlId);
  561. numberFormat = gf_get_field_number_format( fieldId, formId, 'value' );
  562. }
  563. }
  564. if (!numberFormat)
  565. numberFormat = 'currency';
  566. var decimalSeparator = gformGetDecimalSeparator(numberFormat);
  567. quantity = gformCleanNumber(quantity, '', '', decimalSeparator);
  568. if (!quantity)
  569. quantity = 0;
  570. return quantity;
  571. }
  572. function gformIsProductSelected( formId, productFieldId ) {
  573. var suffix = "_" + formId + "_" + productFieldId;
  574. var productField = jQuery("#ginput_base_price" + suffix + ", .gfield_donation" + suffix + " input[type=\"text\"], .gfield_product" + suffix + " .ginput_amount");
  575. if( productField.val() && ! gformIsHidden(productField) ){
  576. return true;
  577. }
  578. else
  579. {
  580. productField = jQuery(".gfield_product" + suffix + " select, .gfield_product" + suffix + " input:checked, .gfield_donation" + suffix + " select, .gfield_donation" + suffix + " input:checked");
  581. if( productField.val() && ! gformIsHidden(productField) ){
  582. return true;
  583. }
  584. }
  585. return false;
  586. }
  587. function gformGetBasePrice(formId, productFieldId){
  588. var suffix = "_" + formId + "_" + productFieldId;
  589. var price = 0;
  590. var productField = jQuery("#ginput_base_price" + suffix+ ", .gfield_donation" + suffix + " input[type=\"text\"], .gfield_product" + suffix + " .ginput_amount");
  591. if(productField.length > 0){
  592. price = productField.val();
  593. //If field is hidden by conditional logic, don't count it for the total
  594. if(gformIsHidden(productField)){
  595. price = 0;
  596. }
  597. }
  598. else
  599. {
  600. productField = jQuery(".gfield_product" + suffix + " select, .gfield_product" + suffix + " input:checked, .gfield_donation" + suffix + " select, .gfield_donation" + suffix + " input:checked");
  601. var val = productField.val();
  602. if(val){
  603. val = val.split("|");
  604. price = val.length > 1 ? val[1] : 0;
  605. }
  606. //If field is hidden by conditional logic, don't count it for the total
  607. if(gformIsHidden(productField))
  608. price = 0;
  609. }
  610. var c = new Currency(gf_global.gf_currency_config);
  611. price = c.toNumber(price);
  612. return price === false ? 0 : price;
  613. }
  614. function gformFormatMoney(text){
  615. if(!gf_global.gf_currency_config)
  616. return text;
  617. var currency = new Currency(gf_global.gf_currency_config);
  618. return currency.toMoney(text);
  619. }
  620. function gformFormatPricingField(element){
  621. if(gf_global.gf_currency_config){
  622. var currency = new Currency(gf_global.gf_currency_config);
  623. var price = currency.toMoney(jQuery(element).val());
  624. jQuery(element).val(price);
  625. }
  626. }
  627. function gformToNumber(text){
  628. var currency = new Currency(gf_global.gf_currency_config);
  629. return currency.toNumber(text);
  630. }
  631. function gformGetPriceDifference(currentPrice, newPrice){
  632. //getting price difference
  633. var diff = parseFloat(newPrice) - parseFloat(currentPrice);
  634. price = gformFormatMoney(diff);
  635. if(diff > 0)
  636. price = "+" + price;
  637. return price;
  638. }
  639. function gformGetOptionLabel(element, selected_value, current_price, form_id, field_id){
  640. element = jQuery(element);
  641. var price = gformGetPrice(selected_value);
  642. var current_diff = element.attr('price');
  643. var original_label = element.html().replace(/<span(.*)<\/span>/i, "").replace(current_diff, "");
  644. var diff = gformGetPriceDifference(current_price, price);
  645. diff = gformToNumber(diff) == 0 ? "" : " " + diff;
  646. element.attr('price', diff);
  647. //don't add <span> for drop down items (not supported)
  648. var price_label = element[0].tagName.toLowerCase() == "option" ? " " + diff : "<span class='ginput_price'>" + diff + "</span>";
  649. var label = original_label + price_label;
  650. //calling hook to allow for custom option formatting
  651. if(window["gform_format_option_label"])
  652. label = gform_format_option_label(label, original_label, price_label, current_price, price, form_id, field_id);
  653. return label;
  654. }
  655. function gformGetProductIds(parent_class, element){
  656. var classes = jQuery(element).hasClass(parent_class) ? jQuery(element).attr("class").split(" ") : jQuery(element).parents("." + parent_class).attr("class").split(" ");
  657. for(var i=0; i<classes.length; i++){
  658. if(classes[i].substr(0, parent_class.length) == parent_class && classes[i] != parent_class)
  659. return {formId: classes[i].split("_")[2], productFieldId: classes[i].split("_")[3]};
  660. }
  661. return {formId:0, fieldId:0};
  662. }
  663. function gformGetPrice(text){
  664. var val = text.split("|");
  665. var currency = new Currency(gf_global.gf_currency_config);
  666. if(val.length > 1 && currency.toNumber(val[1]) !== false)
  667. return currency.toNumber(val[1]);
  668. return 0;
  669. }
  670. function gformRegisterPriceField(item){
  671. if(!_gformPriceFields[item.formId])
  672. _gformPriceFields[item.formId] = new Array();
  673. //ignore price fields that have already been registered
  674. for(var i=0; i<_gformPriceFields[item.formId].length; i++)
  675. if(_gformPriceFields[item.formId][i] == item.productFieldId)
  676. return;
  677. //registering new price field
  678. _gformPriceFields[item.formId].push(item.productFieldId);
  679. }
  680. function gformInitPriceFields(){
  681. jQuery(".gfield_price").each(function(){
  682. var productIds = gformGetProductIds("gfield_price", this);
  683. gformRegisterPriceField(productIds);
  684. jQuery( this ).on( 'change', 'input[type="text"], input[type="number"], select', function() {
  685. var productIds = gformGetProductIds("gfield_price", this);
  686. if(productIds.formId == 0)
  687. productIds = gformGetProductIds("gfield_shipping", this);
  688. jQuery(document).trigger('gform_price_change', [productIds, this]);
  689. gformCalculateTotalPrice(productIds.formId);
  690. });
  691. jQuery( this ).on( 'click', 'input[type="radio"], input[type="checkbox"]', function() {
  692. var productIds = gformGetProductIds("gfield_price", this);
  693. if(productIds.formId == 0)
  694. productIds = gformGetProductIds("gfield_shipping", this);
  695. jQuery(document).trigger('gform_price_change', [productIds, this]);
  696. gformCalculateTotalPrice(productIds.formId);
  697. });
  698. });
  699. for(formId in _gformPriceFields){
  700. //needed when implementing for in loops
  701. if(!_gformPriceFields.hasOwnProperty(formId))
  702. continue;
  703. gformCalculateTotalPrice(formId);
  704. }
  705. }
  706. //-------------------------------------------
  707. //---------- PASSWORD -----------------------
  708. //-------------------------------------------
  709. function gformShowPasswordStrength(fieldId){
  710. var password = jQuery("#" + fieldId).val();
  711. var confirm = jQuery("#" + fieldId + "_2").val();
  712. var result = gformPasswordStrength(password, confirm);
  713. var text = window['gf_text']["password_" + result];
  714. jQuery("#" + fieldId + "_strength").val(result);
  715. jQuery("#" + fieldId + "_strength_indicator").removeClass("blank mismatch short good bad strong").addClass(result).html(text);
  716. }
  717. // Password strength meter
  718. function gformPasswordStrength(password1, password2) {
  719. var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
  720. if(password1.length <=0)
  721. return "blank";
  722. // password 1 != password 2
  723. if ( (password1 != password2) && password2.length > 0)
  724. return "mismatch";
  725. //password < 4
  726. if ( password1.length < 4 )
  727. return "short";
  728. if ( password1.match(/[0-9]/) )
  729. symbolSize +=10;
  730. if ( password1.match(/[a-z]/) )
  731. symbolSize +=26;
  732. if ( password1.match(/[A-Z]/) )
  733. symbolSize +=26;
  734. if ( password1.match(/[^a-zA-Z0-9]/) )
  735. symbolSize +=31;
  736. natLog = Math.log( Math.pow(symbolSize, password1.length) );
  737. score = natLog / Math.LN2;
  738. if (score < 40 )
  739. return "bad";
  740. if (score < 56 )
  741. return "good";
  742. return "strong";
  743. }
  744. //----------------------------
  745. //------ LIST FIELD ----------
  746. //----------------------------
  747. function gformAddListItem( addButton, max ) {
  748. var $addButton = jQuery( addButton );
  749. if( $addButton.hasClass( 'gfield_icon_disabled' ) ) {
  750. return;
  751. }
  752. var $group = $addButton.parents( '.gfield_list_group' ),
  753. $clone = $group.clone(),
  754. $container = $group.parents( '.gfield_list_container' ),
  755. tabindex = $clone.find( ':input:last' ).attr( 'tabindex' );
  756. // reset all inputs to empty state
  757. $clone
  758. .find( 'input, select' ).attr( 'tabindex', tabindex )
  759. .not( ':checkbox, :radio' ).val( '' );
  760. $clone.find( ':checkbox, :radio' ).prop( 'checked', false );
  761. $clone = gform.applyFilters( 'gform_list_item_pre_add', $clone, $group );
  762. $group.after( $clone );
  763. gformToggleIcons( $container, max );
  764. gformAdjustClasses( $container );
  765. }
  766. function gformDeleteListItem( deleteButton, max ) {
  767. var $deleteButton = jQuery( deleteButton ),
  768. $group = $deleteButton.parents( '.gfield_list_group' ),
  769. $container = $group.parents( '.gfield_list_container' );
  770. $group.remove();
  771. gformToggleIcons( $container, max );
  772. gformAdjustClasses( $container );
  773. }
  774. function gformAdjustClasses( $container ) {
  775. var $groups = $container.find( '.gfield_list_group' );
  776. $groups.each( function( i ) {
  777. var $group = jQuery( this ),
  778. oddEvenClass = ( i + 1 ) % 2 == 0 ? 'gfield_list_row_even' : 'gfield_list_row_odd';
  779. $group.removeClass( 'gfield_list_row_odd gfield_list_row_even' ).addClass( oddEvenClass );
  780. } );
  781. }
  782. function gformToggleIcons( $container, max ) {
  783. var groupCount = $container.find( '.gfield_list_group' ).length,
  784. $addButtons = $container.find( '.add_list_item' );
  785. $container.find( '.delete_list_item' ).css( 'visibility', groupCount == 1 ? 'hidden' : 'visible' );
  786. if ( max > 0 && groupCount >= max ) {
  787. // store original title in the add button
  788. $addButtons.data( 'title', $container.find( '.add_list_item' ).attr( 'title' ) );
  789. $addButtons.addClass( 'gfield_icon_disabled' ).attr( 'title', '' );
  790. } else if( max > 0 ) {
  791. $addButtons.removeClass( 'gfield_icon_disabled' );
  792. if( $addButtons.data( 'title' ) ) {
  793. $addButtons.attr( 'title', $addButtons.data( 'title' ) );
  794. }
  795. }
  796. }
  797. //-----------------------------------
  798. //------ CREDIT CARD FIELD ----------
  799. //-----------------------------------
  800. function gformMatchCard(id) {
  801. var cardType = gformFindCardType(jQuery('#' + id).val());
  802. var cardContainer = jQuery('#' + id).parents('.gfield').find('.gform_card_icon_container');
  803. if(!cardType) {
  804. jQuery(cardContainer).find('.gform_card_icon').removeClass('gform_card_icon_selected gform_card_icon_inactive');
  805. } else {
  806. jQuery(cardContainer).find('.gform_card_icon').removeClass('gform_card_icon_selected').addClass('gform_card_icon_inactive');
  807. jQuery(cardContainer).find('.gform_card_icon_' + cardType).removeClass('gform_card_icon_inactive').addClass('gform_card_icon_selected');
  808. }
  809. }
  810. function gformFindCardType(value) {
  811. if(value.length < 4)
  812. return false;
  813. var rules = window['gf_cc_rules'];
  814. var validCardTypes = new Array();
  815. for(type in rules) {
  816. //needed when implementing for in loops
  817. if(!rules.hasOwnProperty(type))
  818. continue;
  819. for(i in rules[type]) {
  820. if(!rules[type].hasOwnProperty(i))
  821. continue;
  822. if(rules[type][i].indexOf(value.substring(0, rules[type][i].length)) === 0) {
  823. validCardTypes[validCardTypes.length] = type;
  824. break;
  825. }
  826. }
  827. }
  828. return validCardTypes.length == 1 ? validCardTypes[0].toLowerCase() : false;
  829. }
  830. function gformToggleCreditCard(){
  831. if(jQuery("#gform_payment_method_creditcard").is(":checked"))
  832. jQuery(".gform_card_fields_container").slideDown();
  833. else
  834. jQuery(".gform_card_fields_container").slideUp();
  835. }
  836. //----------------------------------------
  837. //------ CHOSEN DROP DOWN FIELD ----------
  838. //----------------------------------------
  839. function gformInitChosenFields(fieldList, noResultsText){
  840. return jQuery(fieldList).each(function(){
  841. var element = jQuery( this );
  842. // RTL support
  843. if( jQuery( 'html' ).attr( 'dir' ) == 'rtl' ) {
  844. element.addClass( 'chosen-rtl chzn-rtl' );
  845. }
  846. // only initialize once
  847. if( element.is(":visible") && element.siblings(".chosen-container").length == 0 ){
  848. var options = gform.applyFilters( 'gform_chosen_options', { no_results_text: noResultsText }, element );
  849. element.chosen( options );
  850. }
  851. });
  852. }
  853. //----------------------------------------
  854. //--- CURRENCY FORMAT NUMBER FIELD -------
  855. //----------------------------------------
  856. function gformInitCurrencyFormatFields(fieldList){
  857. jQuery(fieldList).each(function(){
  858. var $this = jQuery(this);
  859. $this.val( gformFormatMoney( jQuery(this).val() ) );
  860. }).change( function( event ) {
  861. jQuery(this).val( gformFormatMoney( jQuery(this).val() ) );
  862. });
  863. }
  864. //----------------------------------------
  865. //------ CALCULATION FUNCTIONS -----------
  866. //----------------------------------------
  867. var GFCalc = function(formId, formulaFields){
  868. this.patt = /{[^{]*?:(\d+(\.\d+)?)(:(.*?))?}/i;
  869. this.exprPatt = /^[0-9 -/*\(\)]+$/i;
  870. this.isCalculating = {};
  871. this.init = function(formId, formulaFields) {
  872. var calc = this;
  873. jQuery(document).bind("gform_post_conditional_logic", function(){
  874. for(var i=0; i<formulaFields.length; i++) {
  875. var formulaField = jQuery.extend({}, formulaFields[i]);
  876. calc.runCalc(formulaField, formId);
  877. }
  878. });
  879. for(var i=0; i<formulaFields.length; i++) {
  880. var formulaField = jQuery.extend({}, formulaFields[i]);
  881. this.runCalc(formulaField, formId);
  882. this.bindCalcEvents(formulaField, formId);
  883. }
  884. }
  885. this.runCalc = function(formulaField, formId) {
  886. var calcObj = this,
  887. field = jQuery('#field_' + formId + '_' + formulaField.field_id),
  888. formulaInput = jQuery('#input_' + formId + '_' + formulaField.field_id),
  889. previous_val = formulaInput.val(),
  890. formula = gform.applyFilters( 'gform_calculation_formula', formulaField.formula, formulaField, formId, calcObj ),
  891. expr = calcObj.replaceFieldTags( formId, formula, formulaField ).replace(/(\r\n|\n|\r)/gm,""),
  892. result = '';
  893. if(calcObj.exprPatt.test(expr)) {
  894. try {
  895. //run calculation
  896. result = eval(expr);
  897. } catch( e ) { }
  898. }
  899. // if result is postive infinity, negative infinity or a NaN, defaults to 0
  900. if( ! isFinite( result ) )
  901. result = 0;
  902. // allow users to modify result with their own function
  903. if( window["gform_calculation_result"] ) {
  904. result = window["gform_calculation_result"](result, formulaField, formId, calcObj);
  905. if( window.console )
  906. console.log( '"gform_calculation_result" function is deprecated since version 1.8! Use "gform_calculation_result" JS hook instead.' );
  907. }
  908. // allow users to modify result with their own function
  909. result = gform.applyFilters( 'gform_calculation_result', result, formulaField, formId, calcObj );
  910. // allow result to be custom formatted
  911. var formattedResult = gform.applyFilters( 'gform_calculation_format_result', false, result, formulaField, formId, calcObj );
  912. var numberFormat = gf_get_field_number_format(formulaField.field_id, formId);
  913. //formatting number
  914. if( formattedResult !== false) {
  915. result = formattedResult;
  916. }
  917. else if( field.hasClass( 'gfield_price' ) || numberFormat == "currency") {
  918. result = gformFormatMoney(result ? result : 0);
  919. }
  920. else {
  921. var decimalSeparator = ".";
  922. var thousandSeparator = ",";
  923. if(numberFormat == "decimal_comma"){
  924. decimalSeparator = ",";
  925. thousandSeparator = ".";
  926. }
  927. result = gformFormatNumber(result, !gformIsNumber(formulaField.rounding) ? -1 : formulaField.rounding, decimalSeparator, thousandSeparator);
  928. }
  929. //If value doesn't change, abort.
  930. //This is needed to prevent an infinite loop condition with conditional logic
  931. if( result == previous_val )
  932. return;
  933. // if this is a calculation product, handle differently
  934. if(field.hasClass('gfield_price')) {
  935. formulaInput.text(result);
  936. jQuery('#ginput_base_price_' + formId + '_' + formulaField.field_id).val(result).trigger('change');
  937. gformCalculateTotalPrice(formId);
  938. } else {
  939. formulaInput.val(result).trigger('change');
  940. }
  941. }
  942. this.bindCalcEvents = function(formulaField, formId) {
  943. var calcObj = this;
  944. var formulaFieldId = formulaField.field_id;
  945. var matches = getMatchGroups(formulaField.formula, this.patt);
  946. calcObj.isCalculating[formulaFieldId] = false;
  947. for(var i in matches) {
  948. if(! matches.hasOwnProperty(i))
  949. continue;
  950. var inputId = matches[i][1];
  951. var fieldId = parseInt(inputId);
  952. var input = jQuery('#field_' + formId + '_' + fieldId).find('input[name="input_' + inputId + '"], select[name="input_' + inputId + '"]');
  953. if(input.prop('type') == 'checkbox' || input.prop('type') == 'radio') {
  954. jQuery(input).click(function(){
  955. calcObj.bindCalcEvent(inputId, formulaField, formId, 0);
  956. });
  957. } else
  958. if(input.is('select') || input.prop('type') == 'hidden') {
  959. jQuery(input).change(function(){
  960. calcObj.bindCalcEvent(inputId, formulaField, formId, 0);
  961. });
  962. } else {
  963. jQuery(input).keydown(function(){
  964. calcObj.bindCalcEvent(inputId, formulaField, formId);
  965. }).change(function(){
  966. calcObj.bindCalcEvent(inputId, formulaField, formId, 0);
  967. });
  968. }
  969. // allow users to add custom methods for triggering calculations
  970. gform.doAction( 'gform_post_calculation_events', matches[i], formulaField, formId, calcObj );
  971. }
  972. }
  973. this.bindCalcEvent = function(inputId, formulaField, formId, delay) {
  974. var calcObj = this;
  975. var formulaFieldId = formulaField.field_id;
  976. delay = delay == undefined ? 345 : delay;
  977. if(calcObj.isCalculating[formulaFieldId][inputId])
  978. clearTimeout(calcObj.isCalculating[formulaFieldId][inputId]);
  979. calcObj.isCalculating[formulaFieldId][inputId] = window.setTimeout(function() {
  980. calcObj.runCalc(formulaField, formId);
  981. }, delay);
  982. }
  983. this.replaceFieldTags = function( formId, expr, formulaField ) {
  984. var matches = getMatchGroups(expr, this.patt);
  985. var origExpr = expr;
  986. for(i in matches) {
  987. if(! matches.hasOwnProperty(i))
  988. continue;
  989. var inputId = matches[i][1];
  990. var fieldId = parseInt(inputId);
  991. var columnId = matches[i][3];
  992. var value = 0;
  993. var input = jQuery('#field_' + formId + '_' + fieldId).find('input[name="input_' + inputId + '"], select[name="input_' + inputId + '"]');
  994. // radio buttons will return multiple inputs, checkboxes will only return one but it may not be selected, filter out unselected inputs
  995. if( input.length > 1 || input.prop('type') == 'checkbox' )
  996. input = input.filter(':checked');
  997. var isVisible = window['gf_check_field_rule'] ? gf_check_field_rule( formId, fieldId, true, '' ) == 'show' : true;
  998. if( input.length > 0 && isVisible ) {
  999. var val = input.val();
  1000. val = val.split( '|' );
  1001. if( val.length > 1 ) {
  1002. value = val[1];
  1003. } else {
  1004. value = input.val();
  1005. }
  1006. }
  1007. var numberFormat = gf_get_field_number_format( fieldId, formId );
  1008. if( ! numberFormat )
  1009. numberFormat = gf_get_field_number_format( formulaField.field_id, formId );
  1010. var decimalSeparator = gformGetDecimalSeparator(numberFormat);
  1011. // allow users to modify value with their own function
  1012. value = gform.applyFilters( 'gform_merge_tag_value_pre_calculation', value, matches[i], isVisible, formulaField, formId );
  1013. value = gformCleanNumber( value, '', '', decimalSeparator );
  1014. if( ! value )
  1015. value = 0;
  1016. expr = expr.replace( matches[i][0], value );
  1017. }
  1018. return expr;
  1019. }
  1020. this.init(formId, formulaFields);
  1021. }
  1022. function gformFormatNumber(number, rounding, decimalSeparator, thousandSeparator){
  1023. if(typeof decimalSeparator == "undefined"){
  1024. if(window['gf_global']){
  1025. var currency = new Currency(gf_global.gf_currency_config);
  1026. decimalSeparator = currency.currency["decimal_separator"];
  1027. }
  1028. else{
  1029. decimalSeparator = ".";
  1030. }
  1031. }
  1032. if(typeof thousandSeparator == "undefined"){
  1033. if(window['gf_global']){
  1034. var currency = new Currency(gf_global.gf_currency_config);
  1035. thousandSeparator = currency.currency["thousand_separator"];
  1036. }
  1037. else{
  1038. thousandSeparator = ",";
  1039. }
  1040. }
  1041. var currency = new Currency();
  1042. return currency.numberFormat(number, rounding, decimalSeparator, thousandSeparator, false)
  1043. }
  1044. function gformToNumber(text) {
  1045. var currency = new Currency(gf_global.gf_currency_config);
  1046. return currency.toNumber(text);
  1047. }
  1048. function getMatchGroups(expr, patt) {
  1049. var matches = new Array();
  1050. while(patt.test(expr)) {
  1051. var i = matches.length;
  1052. matches[i] = patt.exec(expr)
  1053. expr = expr.replace('' + matches[i][0], '');
  1054. }
  1055. return matches;
  1056. }
  1057. function gf_get_field_number_format(fieldId, formId, context) {
  1058. var fieldNumberFormats = rgars(window, 'gf_global/number_formats/{0}/{1}'.format(formId, fieldId)),
  1059. format = false;
  1060. if (fieldNumberFormats === '') {
  1061. return format;
  1062. }
  1063. if (typeof context == 'undefined') {
  1064. format = fieldNumberFormats.price !== false ? fieldNumberFormats.price : fieldNumberFormats.value;
  1065. } else {
  1066. format = fieldNumberFormats[context];
  1067. }
  1068. return format;
  1069. }
  1070. //----------------------------------------
  1071. //------ JAVASCRIPT HOOK FUNCTIONS -------
  1072. //----------------------------------------
  1073. var gform = {
  1074. hooks: { action: {}, filter: {} },
  1075. addAction: function( action, callable, priority, tag ) {
  1076. gform.addHook( 'action', action, callable, priority, tag );
  1077. },
  1078. addFilter: function( action, callable, priority, tag ) {
  1079. gform.addHook( 'filter', action, callable, priority, tag );
  1080. },
  1081. doAction: function( action ) {
  1082. gform.doHook( 'action', action, arguments );
  1083. },
  1084. applyFilters: function( action ) {
  1085. return gform.doHook( 'filter', action, arguments );
  1086. },
  1087. removeAction: function( action, tag ) {
  1088. gform.removeHook( 'action', action, tag );
  1089. },
  1090. removeFilter: function( action, priority, tag ) {
  1091. gform.removeHook( 'filter', action, priority, tag );
  1092. },
  1093. addHook: function( hookType, action, callable, priority, tag ) {
  1094. if ( undefined == gform.hooks[hookType][action] ) {
  1095. gform.hooks[hookType][action] = [];
  1096. }
  1097. var hooks = gform.hooks[hookType][action];
  1098. if ( undefined == tag ) {
  1099. tag = action + '_' + hooks.length;
  1100. }
  1101. if( priority == undefined ){
  1102. priority = 10;
  1103. }
  1104. gform.hooks[hookType][action].push( { tag:tag, callable:callable, priority:priority } );
  1105. },
  1106. doHook: function( hookType, action, args ) {
  1107. // splice args from object into array and remove first index which is the hook name
  1108. args = Array.prototype.slice.call(args, 1);
  1109. if ( undefined != gform.hooks[hookType][action] ) {
  1110. var hooks = gform.hooks[hookType][action], hook;
  1111. //sort by priority
  1112. hooks.sort(function(a,b){return a["priority"]-b["priority"]});
  1113. for( var i=0; i<hooks.length; i++) {
  1114. hook = hooks[i].callable;
  1115. if(typeof hook != 'function')
  1116. hook = window[hook];
  1117. if ( 'action' == hookType ) {
  1118. hook.apply(null, args);
  1119. } else {
  1120. args[0] = hook.apply(null, args);
  1121. }
  1122. }
  1123. }
  1124. if ( 'filter'==hookType ) {
  1125. return args[0];
  1126. }
  1127. },
  1128. removeHook: function( hookType, action, priority, tag ) {
  1129. if ( undefined != gform.hooks[hookType][action] ) {
  1130. var hooks = gform.hooks[hookType][action];
  1131. for( var i=hooks.length-1; i>=0; i--) {
  1132. if ((undefined==tag||tag==hooks[i].tag) && (undefined==priority||priority==hooks[i].priority)){
  1133. hooks.splice(i,1);
  1134. }
  1135. }
  1136. }
  1137. }
  1138. };
  1139. //----------------------------------------
  1140. //------ reCAPTCHA FUNCTIONS -------------
  1141. //----------------------------------------
  1142. /**
  1143. * Callback function on the reCAPTCAH API script.
  1144. *
  1145. * @see GF_Field_CAPTCHA::get_field_input() in /includes/fields/class-gf-field-catpcha.php
  1146. */
  1147. function renderRecaptcha() {
  1148. jQuery( '.ginput_recaptcha' ).each( function() {
  1149. var $elem = jQuery( this ),
  1150. parameters = {
  1151. 'sitekey': $elem.data( 'sitekey' ),
  1152. 'theme': $elem.data( 'theme' )
  1153. };
  1154. if( $elem.data( 'stoken' ) ) {
  1155. parameters.stoken = $elem.data( 'stoken' );
  1156. }
  1157. grecaptcha.render( this.id, parameters );
  1158. } );
  1159. }
  1160. //----------------------------------------
  1161. //------ MULTIFILE UPLOAD FUNCTIONS ------
  1162. //----------------------------------------
  1163. (function (gfMultiFileUploader, $) {
  1164. gfMultiFileUploader.uploaders = {};
  1165. var strings = typeof gform_gravityforms != 'undefined' ? gform_gravityforms.strings : {};
  1166. var imagesUrl = typeof gform_gravityforms != 'undefined' ? gform_gravityforms.vars.images_url : "";
  1167. $(document).bind('gform_post_render', function(e, formID){
  1168. $("form#gform_" + formID + " .gform_fileupload_multifile").each(function(){
  1169. setup(this);
  1170. });
  1171. var $form = $("form#gform_" + formID);
  1172. if($form.length > 0){
  1173. $form.submit(function(){
  1174. var pendingUploads = false;
  1175. $.each(gfMultiFileUploader.uploaders, function(i, uploader){
  1176. if(uploader.total.queued>0){
  1177. pendingUploads = true;
  1178. return false;
  1179. }
  1180. });
  1181. if(pendingUploads){
  1182. alert(strings.currently_uploading);
  1183. window["gf_submitting_" + formID] = false;
  1184. $('#gform_ajax_spinner_' + formID).remove();
  1185. return false;
  1186. }
  1187. });
  1188. }
  1189. });
  1190. $(document).bind("gform_post_conditional_logic", function(e,formID, fields, isInit){
  1191. if(!isInit){
  1192. $.each(gfMultiFileUploader.uploaders, function(i, uploader){
  1193. uploader.refresh();
  1194. });
  1195. }
  1196. });
  1197. $(document).ready(function () {
  1198. if((typeof adminpage !== 'undefined' && adminpage === 'toplevel_page_gf_edit_forms')|| typeof plupload == 'undefined'){
  1199. $(".gform_button_select_files").prop("disabled", true);
  1200. } else if (typeof adminpage !== 'undefined' && adminpage.indexOf('_page_gf_entries') > -1) {
  1201. $(".gform_fileupload_multifile").each(function(){
  1202. setup(this);
  1203. });
  1204. }
  1205. });
  1206. gfMultiFileUploader.setup = function (uploadElement){
  1207. setup( uploadElement );
  1208. };
  1209. function setup(uploadElement){
  1210. var settings = $(uploadElement).data('settings');
  1211. var uploader = new plupload.Uploader(settings);
  1212. formID = uploader.settings.multipart_params.form_id;
  1213. gfMultiFileUploader.uploaders[settings.container] = uploader;
  1214. var formID;
  1215. var uniqueID;
  1216. uploader.bind('Init', function(up, params) {
  1217. if(!up.features.dragdrop)
  1218. $(".gform_drop_instructions").hide();
  1219. var fieldID = up.settings.multipart_params.field_id;
  1220. var maxFiles = parseInt(up.settings.gf_vars.max_files);
  1221. var initFileCount = countFiles(fieldID);
  1222. if(maxFiles > 0 && initFileCount >= maxFiles){
  1223. gfMultiFileUploader.toggleDisabled(up.settings, true);
  1224. }
  1225. });
  1226. gfMultiFileUploader.toggleDisabled = function (settings, disabled){
  1227. var button = typeof settings.browse_button == "string" ? $("#" + settings.browse_button) : $(settings.browse_button);
  1228. button.prop("disabled", disabled);
  1229. };
  1230. function addMessage(messagesID, message){
  1231. $("#" + messagesID).prepend("<li>" + message + "</li>");
  1232. }
  1233. uploader.init();
  1234. uploader.bind('FilesAdded', function(up, files) {
  1235. var max = parseInt(up.settings.gf_vars.max_files),
  1236. fieldID = up.settings.multipart_params.field_id,
  1237. totalCount = countFiles(fieldID),
  1238. disallowed = up.settings.gf_vars.disallowed_extensions,
  1239. extension;
  1240. if( max > 0 && totalCount >= max){
  1241. $.each(files, function(i, file) {
  1242. up.removeFile(file);
  1243. return;
  1244. });
  1245. return;
  1246. }
  1247. $.each(files, function(i, file) {
  1248. extension = file.name.split('.').pop();
  1249. if($.inArray(extension, disallowed) > -1){
  1250. addMessage(up.settings.gf_vars.message_id, file.name + " - " + strings.illegal_extension);
  1251. up.removeFile(file);
  1252. return;
  1253. }
  1254. if ((file.status == plupload.FAILED) || (max > 0 && totalCount >= max)){
  1255. up.removeFile(file);
  1256. return;
  1257. }
  1258. var size = typeof file.size !== 'undefined' ? plupload.formatSize(file.size) : strings.in_progress;
  1259. var status = '<div id="'
  1260. + file.id
  1261. + '" class="ginput_preview">'
  1262. + file.name
  1263. + ' (' + size + ') <b></b> '
  1264. + '<a href="javascript:void(0)" title="' + strings.cancel_upload + '" onclick=\'$this=jQuery(this); var uploader = gfMultiFileUploader.uploaders.' + up.settings.container + ';uploader.stop();uploader.removeFile(uploader.getFile("' + file.id +'"));$this.after("' + strings.cancelled + '"); uploader.start();$this.remove();\' onkeypress=\'$this=jQuery(this); var uploader = gfMultiFileUploader.uploaders.' + up.settings.container + ';uploader.stop();uploader.removeFile(uploader.getFile("' + file.id +'"));$this.after("' + strings.cancelled + '"); uploader.start();$this.remove();\'>' + strings.cancel + '</a>'
  1265. + '</div>';
  1266. $('#' + up.settings.filelist).prepend(status);
  1267. totalCount++;
  1268. });
  1269. up.refresh(); // Reposition Flash
  1270. var formElementID = "form#gform_" + formID;
  1271. var uidElementID = "input:hidden[name='gform_unique_id']";
  1272. var uidSelector = formElementID + " " + uidElementID;
  1273. var $uid = $(uidSelector);
  1274. if($uid.length==0){
  1275. $uid = $(uidElementID);
  1276. }
  1277. uniqueID = $uid.val();
  1278. if('' === uniqueID){
  1279. uniqueID = generateUniqueID();
  1280. $uid.val(uniqueID);
  1281. }
  1282. if(max > 0 && totalCount >= max){
  1283. gfMultiFileUploader.toggleDisabled(up.settings, true);
  1284. addMessage(up.settings.gf_vars.message_id, strings.max_reached)
  1285. }
  1286. up.settings.multipart_params.gform_unique_id = uniqueID;
  1287. up.start();
  1288. });
  1289. uploader.bind('UploadProgress', function(up, file) {
  1290. var html = file.percent + "%";
  1291. $('#' + file.id + " b").html(html);
  1292. });
  1293. uploader.bind('Error', function(up, err) {
  1294. if(err.code === plupload.FILE_EXTENSION_ERROR){
  1295. var extensions = typeof up.settings.filters.mime_types != 'undefined' ? up.settings.filters.mime_types[0].extensions /* plupoad 2 */ : up.settings.filters[0].extensions;
  1296. addMessage(up.settings.gf_vars.message_id, err.file.name + " - " + strings.invalid_file_extension + " " + extensions);
  1297. } else if (err.code === plupload.FILE_SIZE_ERROR) {
  1298. addMessage(up.settings.gf_vars.message_id, err.file.name + " - " + strings.file_exceeds_limit);
  1299. } else {
  1300. var m = "<li>Error: " + err.code +
  1301. ", Message: " + err.message +
  1302. (err.file ? ", File: " + err.file.name : "") +
  1303. "</li>";
  1304. addMessage(up.settings.gf_vars.message_id, m);
  1305. }
  1306. $('#' + err.file.id ).html('');
  1307. up.refresh(); // Reposition Flash
  1308. });
  1309. uploader.bind('FileUploaded', function(up, file, result) {
  1310. var response = $.secureEvalJSON(result.response);
  1311. if(response.status == "error"){
  1312. addMessage(up.settings.gf_vars.message_id, file.name + " - " + response.error.message);
  1313. $('#' + file.id ).html('');
  1314. return;
  1315. }
  1316. var html = '<strong>' + file.name + '</strong>';
  1317. var formId = up.settings.multipart_params.form_id;
  1318. var fieldId = up.settings.multipart_params.field_id;
  1319. html = "<img "
  1320. + "class='gform_delete' "
  1321. + "src='" + imagesUrl + "/delete.png' "
  1322. + "onclick='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);' "
  1323. + "onkeypress='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);' "
  1324. + "alt='"+ strings.delete_file + "' "
  1325. + "title='" + strings.delete_file
  1326. + "' /> "
  1327. + html;
  1328. html = gform.applyFilters( 'gform_file_upload_markup', html, file, up, strings, imagesUrl );
  1329. $( '#' + file.id ).html( html );
  1330. var fieldID = up.settings.multipart_params["field_id"];
  1331. if(file.percent == 100){
  1332. if(response.status && response.status == 'ok'){
  1333. addFile(fieldID, response.data);
  1334. } else {
  1335. addMessage(up.settings.gf_vars.message_id, strings.unknown_error + ': ' + file.name);
  1336. }
  1337. }
  1338. });
  1339. function getAllFiles(){
  1340. var selector = '#gform_uploaded_files_' + formID,
  1341. $uploadedFiles = $(selector), files;
  1342. files = $uploadedFiles.val();
  1343. files = (typeof files === "undefined") || files === '' ? {} : $.parseJSON(files);
  1344. return files;
  1345. }
  1346. function getFiles(fieldID){
  1347. var allFiles = getAllFiles();
  1348. var inputName = getInputName(fieldID);
  1349. if(typeof allFiles[inputName] == 'undefined')
  1350. allFiles[inputName] = [];
  1351. return allFiles[inputName];
  1352. }
  1353. function countFiles(fieldID){
  1354. var files = getFiles(fieldID);
  1355. return files.length;
  1356. }
  1357. function addFile(fieldID, fileInfo){
  1358. var files = getFiles(fieldID);
  1359. files.unshift(fileInfo);
  1360. setUploadedFiles(fieldID, files);
  1361. }
  1362. function setUploadedFiles(fieldID, files){
  1363. var allFiles = getAllFiles();
  1364. var $uploadedFiles = $('#gform_uploaded_files_' + formID);
  1365. var inputName = getInputName(fieldID);
  1366. allFiles[inputName] = files;
  1367. $uploadedFiles.val($.toJSON(allFiles));
  1368. }
  1369. function getInputName(fieldID){
  1370. return "input_" + fieldID;
  1371. }
  1372. // fixes drag and drop in IE10
  1373. $("#" + settings.drop_element).on({
  1374. "dragenter": ignoreDrag,
  1375. "dragover": ignoreDrag
  1376. });
  1377. function ignoreDrag( e ) {
  1378. e.preventDefault();
  1379. }
  1380. }
  1381. function generateUniqueID() {
  1382. return 'xxxxxxxx'.replace(/[xy]/g, function (c) {
  1383. var r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8;
  1384. return v.toString(16);
  1385. });
  1386. }
  1387. }(window.gfMultiFileUploader = window.gfMultiFileUploader || {}, jQuery));
  1388. //----------------------------------------
  1389. //------ GENERAL FUNCTIONS -------
  1390. //----------------------------------------
  1391. function gformInitSpinner( formId, spinnerUrl ) {
  1392. if( typeof spinnerUrl == 'undefined' || ! spinnerUrl ) {
  1393. spinnerUrl = gform.applyFilters( "gform_spinner_url", gf_global.spinnerUrl, formId );
  1394. }
  1395. jQuery('#gform_' + formId).submit( function () {
  1396. if ( jQuery('#gform_ajax_spinner_' + formId).length == 0 ) {
  1397. /**
  1398. * Filter the element after which the AJAX spinner will be inserted.
  1399. *
  1400. * @since 2.0
  1401. *
  1402. * @param object $targetElem jQuery object containing all of the elements after which the AJAX spinner will be inserted.
  1403. * @param int formId ID of the current form.
  1404. */
  1405. var $spinnerTarget = gform.applyFilters( 'gform_spinner_target_elem', jQuery('#gform_submit_button_' + formId + ', #gform_wrapper_' + formId + ' .gform_next_button, #gform_send_resume_link_button_' + formId ), formId );
  1406. $spinnerTarget.after( '<img id="gform_ajax_spinner_' + formId + '" class="gform_ajax_spinner" src="' + spinnerUrl + '" alt="" />' );
  1407. }
  1408. } );
  1409. }
  1410. //----------------------------------------
  1411. //------ EVENT FUNCTIONS -----------------
  1412. //----------------------------------------
  1413. var __gf_keyup_timeout;
  1414. jQuery( document ).on( 'change keyup', '.gfield_trigger_change input, .gfield_trigger_change select, .gfield_trigger_change textarea', function( event ) {
  1415. gf_raw_input_change( event, this );
  1416. } );
  1417. function gf_raw_input_change( event, elem ) {
  1418. // clear regardless of event type for maximum efficiency ;)
  1419. clearTimeout( __gf_keyup_timeout );
  1420. var $input = jQuery( elem ),
  1421. htmlId = $input.attr( 'id' ),
  1422. fieldId = gf_get_input_id_by_html_id( htmlId ),
  1423. formId = gf_get_form_id_by_html_id( htmlId );
  1424. if( ! fieldId ) {
  1425. return;
  1426. }
  1427. var isChangeElem = $input.is( ':checkbox' ) || $input.is( ':radio' ) || $input.is( 'select' ),
  1428. isKeyupElem = ! isChangeElem || $input.is( 'textarea' );
  1429. if( event.type == 'keyup' && ! isKeyupElem ) {
  1430. return;
  1431. } else if( event.type == 'change' && ! isChangeElem && ! isKeyupElem ) {
  1432. return;
  1433. }
  1434. if( event.type == 'keyup' ) {
  1435. __gf_keyup_timeout = setTimeout( function() {
  1436. gf_input_change( this, formId, fieldId );
  1437. }, 300 );
  1438. } else {
  1439. gf_input_change( this, formId, fieldId );
  1440. }
  1441. }
  1442. function gf_get_input_id_by_html_id( htmlId ) {
  1443. var ids = gf_get_ids_by_html_id( htmlId ),
  1444. id = ids[2];
  1445. if( ids[3] ) {
  1446. id += '.' + ids[3];
  1447. }
  1448. return id;
  1449. }
  1450. function gf_get_form_id_by_html_id( htmlId ) {
  1451. var ids = gf_get_ids_by_html_id( htmlId ),
  1452. id = ids[1];
  1453. return id;
  1454. }
  1455. function gf_get_ids_by_html_id( htmlId ) {
  1456. var ids = htmlId ? htmlId.split( '_' ) : false;
  1457. return ids;
  1458. }
  1459. function gf_input_change( elem, formId, fieldId ) {
  1460. gform.doAction( 'gform_input_change', elem, formId, fieldId );
  1461. }
  1462. function gformExtractFieldId( inputId ) {
  1463. var fieldId = parseInt( inputId.toString().split( '.' )[0] );
  1464. return ! fieldId ? inputId : fieldId;
  1465. }
  1466. function gformExtractInputIndex( inputId ) {
  1467. var inputIndex = parseInt( inputId.toString().split( '.' )[1] );
  1468. return ! inputIndex ? false : inputIndex;
  1469. }
  1470. //----------------------------------------
  1471. //------ HELPER FUNCTIONS ----------------
  1472. //----------------------------------------
  1473. if( ! window['rgars'] ) {
  1474. function rgars( array, prop ) {
  1475. var props = prop.split( '/' ),
  1476. value = array;
  1477. for( var i = 0; i < props.length; i++ ) {
  1478. value = rgar( value, props[ i ] );
  1479. }
  1480. return value;
  1481. }
  1482. }
  1483. if( ! window['rgar'] ) {
  1484. function rgar( array, prop ) {
  1485. if ( typeof array[ prop ] != 'undefined' ) {
  1486. return array[ prop ];
  1487. }
  1488. return '';
  1489. }
  1490. }
  1491. String.prototype.format = function () {
  1492. var args = arguments;
  1493. return this.replace(/{(\d+)}/g, function (match, number) {
  1494. return typeof args[number] != 'undefined' ? args[number] : match;
  1495. });
  1496. };
  1497. /*============================================
  1498. Stripe - Front-end
  1499. ==============================================*/
  1500. /**
  1501. * Front-end Script
  1502. */
  1503. window.GFStripe = null;
  1504. (function($){
  1505. GFStripe = function( args ) {
  1506. for( var prop in args ) {
  1507. if( args.hasOwnProperty( prop ) )
  1508. this[prop] = args[prop];
  1509. }
  1510. this.form = null;
  1511. this.init = function() {
  1512. if( ! this.isCreditCardOnPage() )
  1513. return;
  1514. var GFStripeObj = this;
  1515. Stripe.setPublishableKey( this.apiKey );
  1516. // initialize spinner
  1517. if( ! this.isAjax )
  1518. gformInitSpinner( this.formId );
  1519. // bind Stripe functionality to submit event
  1520. $( '#gform_' + this.formId ).submit( function( event ){
  1521. if ( $(this).data('gfstripesubmitting') ) {
  1522. return;
  1523. } else {
  1524. event.preventDefault();
  1525. $(this).data('gfstripesubmitting', true);
  1526. }
  1527. var form = $(this),
  1528. ccInputPrefix = 'input_' + GFStripeObj.formId + '_' + GFStripeObj.ccFieldId + '_',
  1529. cc = {
  1530. number: form.find( '#' + ccInputPrefix + '1' ).val(),
  1531. exp_month: form.find( '#' + ccInputPrefix + '2_month' ).val(),
  1532. exp_year: form.find( '#' + ccInputPrefix + '2_year' ).val(),
  1533. cvc: form.find( '#' + ccInputPrefix + '3' ).val(),
  1534. name: form.find( '#' + ccInputPrefix + '5').val()
  1535. };
  1536. GFStripeObj.form = form;
  1537. Stripe.card.createToken( cc, function( status, response ) {
  1538. GFStripeObj.responseHandler( status, response );
  1539. } );
  1540. } );
  1541. };
  1542. this.responseHandler = function( status, response ) {
  1543. var form = this.form,
  1544. ccInputPrefix = 'input_' + this.formId + '_' + this.ccFieldId + '_',
  1545. ccInputSuffixes = [ '1', '2_month', '2_year', '3', '5' ],
  1546. cardType = false;
  1547. // remove "name" attribute from credit card inputs
  1548. for( var i = 0; i < ccInputSuffixes.length; i++ ) {
  1549. var input = form.find( '#' + ccInputPrefix + ccInputSuffixes[i] );
  1550. if( ccInputSuffixes[i] == '1' ) {
  1551. var ccNumber = $.trim( input.val() ),
  1552. cardType = gformFindCardType( ccNumber );
  1553. if( typeof this.cardLabels[cardType] != 'undefined' )
  1554. cardType = this.cardLabels[cardType];
  1555. form.append( $( '<input type="hidden" name="stripe_credit_card_last_four" />' ).val( ccNumber.slice( -4 ) ) );
  1556. form.append( $( '<input type="hidden" name="stripe_credit_card_type" />' ).val( cardType ) );
  1557. }
  1558. input.attr( 'name', null );
  1559. }
  1560. // append stripe.js response
  1561. form.append( $( '<input type="hidden" name="stripe_response" />' ).val( $.toJSON( response ) ) );
  1562. // submit the form
  1563. form.submit();
  1564. }
  1565. this.isLastPage = function() {
  1566. var targetPageInput = $( '#gform_target_page_number_' + this.formId );
  1567. if( targetPageInput.length > 0 )
  1568. return targetPageInput.val() == 0;
  1569. return true;
  1570. }
  1571. this.isCreditCardOnPage = function() {
  1572. var currentPage = this.getCurrentPageNumber();
  1573. // if current page is false or no credit card page number, assume this is not a multi-page form
  1574. if( ! this.ccPage || ! currentPage )
  1575. return true;
  1576. return this.ccPage == currentPage;
  1577. }
  1578. this.getCurrentPageNumber = function() {
  1579. var currentPageInput = $( '#gform_source_page_number_' + this.formId );
  1580. return currentPageInput.length > 0 ? currentPageInput.val() : false;
  1581. }
  1582. this.init();
  1583. }
  1584. })(jQuery);
  1585. /*============================================
  1586. UI - Datepicker
  1587. ==============================================*/
  1588. jQuery(document).ready(gformInitDatepicker);
  1589. function gformInitDatepicker(){
  1590. jQuery('.datepicker').each(
  1591. function (){
  1592. var element = jQuery(this);
  1593. var format = "mm/dd/yy";
  1594. if(element.hasClass("mdy"))
  1595. format = "mm/dd/yy";
  1596. else if(element.hasClass("dmy"))
  1597. format = "dd/mm/yy";
  1598. else if(element.hasClass("dmy_dash"))
  1599. format = "dd-mm-yy";
  1600. else if(element.hasClass("dmy_dot"))
  1601. format = "dd.mm.yy";
  1602. else if(element.hasClass("ymd_slash"))
  1603. format = "yy/mm/dd";
  1604. else if(element.hasClass("ymd_dash"))
  1605. format = "yy-mm-dd";
  1606. else if(element.hasClass("ymd_dot"))
  1607. format = "yy.mm.dd";
  1608. var image = "";
  1609. var showOn = "focus";
  1610. if(element.hasClass("datepicker_with_icon")){
  1611. showOn = "both";
  1612. image = jQuery('#gforms_calendar_icon_' + this.id).val();
  1613. }
  1614. element.datepicker( {
  1615. yearRange: '-0:+1',
  1616. minDate: '+90',
  1617. maxDate: '+18M',
  1618. showOn: showOn,
  1619. buttonImage: image,
  1620. buttonImageOnly: true,
  1621. dateFormat: format,
  1622. changeMonth: true,
  1623. changeYear: true,
  1624. onClose: function () {
  1625. element.closest('li').nextAll('li:visible:first').find(':input:first').focus();
  1626. }
  1627. } );
  1628. }
  1629. );
  1630. }
  1631. /*============================================
  1632. Conditional Date
  1633. ==============================================*/
  1634. ;(function($) {
  1635. "use strict";
  1636. function setOptionsByDate()
  1637. {
  1638. $('.booked, .unbooked').each(function() {
  1639. $(this).css('display', 'none');
  1640. });
  1641. var visiting = $('.book-date :input').val();
  1642. if (!visiting) {
  1643. return;
  1644. }
  1645. var visitdate = new Date(visiting);
  1646. var today = new Date().setHours(0, 0, 0, 0);
  1647. if (visitdate < today) {
  1648. alert("Hmm... that date is already booked. " + "Please pick another date.");
  1649. $('.visit-date :input').val('');
  1650. return;
  1651. }
  1652. var month = visitdate.getMonth();
  1653. if (month >= 5 && month <= 7) {
  1654. $('.summer, .year-round').each(function() {
  1655. $(this).css('display', '');
  1656. });
  1657. } else {
  1658. $('.winter, .year-round').each(function() {
  1659. $(this).css('display', '');
  1660. });
  1661. }
  1662. }
  1663. $(document).ready(function() {
  1664. setOptionsByDate();
  1665. $('.visit-date :input').change(function() {
  1666. setOptionsByDate();
  1667. });
  1668. });
  1669. }(jQuery, {}));
  1670. /*============================================
  1671. Conditional Logic
  1672. ==============================================*/
  1673. var __gf_timeout_handle;
  1674. gform.addAction( 'gform_input_change', function( elem, formId, fieldId ) {
  1675. var dependentFieldIds = rgars( gf_form_conditional_logic, [ formId, 'fields', gformExtractFieldId( fieldId ) ].join( '/' ) );
  1676. if( dependentFieldIds ) {
  1677. gf_apply_rules( formId, dependentFieldIds );
  1678. }
  1679. }, 10 );
  1680. function gf_apply_rules(formId, fields, isInit){
  1681. var rule_applied = 0;
  1682. jQuery(document).trigger( 'gform_pre_conditional_logic', [ formId, fields, isInit ] );
  1683. for(var i=0; i < fields.length; i++){
  1684. gf_apply_field_rule(formId, fields[i], isInit, function(){
  1685. rule_applied++;
  1686. if(rule_applied == fields.length){
  1687. jQuery(document).trigger('gform_post_conditional_logic', [formId, fields, isInit]);
  1688. if(window["gformCalculateTotalPrice"])
  1689. window["gformCalculateTotalPrice"](formId);
  1690. }
  1691. });
  1692. }
  1693. }
  1694. function gf_check_field_rule(formId, fieldId, isInit, callback){
  1695. //if conditional logic is not specified for that field, it is supposed to be displayed
  1696. if(!window["gf_form_conditional_logic"] || !window["gf_form_conditional_logic"][formId] || !window["gf_form_conditional_logic"][formId]["logic"][fieldId])
  1697. return "show";
  1698. var conditionalLogic = window["gf_form_conditional_logic"][formId]["logic"][fieldId];
  1699. var action = gf_get_field_action(formId, conditionalLogic["section"]);
  1700. //If section is hidden, always hide field. If section is displayed, see if field is supposed to be displayed or hidden
  1701. if(action != "hide")
  1702. action = gf_get_field_action(formId, conditionalLogic["field"]);
  1703. return action;
  1704. }
  1705. function gf_apply_field_rule(formId, fieldId, isInit, callback){
  1706. var action = gf_check_field_rule(formId, fieldId, isInit, callback);
  1707. gf_do_field_action(formId, action, fieldId, isInit, callback);
  1708. var conditionalLogic = window["gf_form_conditional_logic"][formId]["logic"][fieldId];
  1709. //perform conditional logic for the next button
  1710. if(conditionalLogic["nextButton"]){
  1711. action = gf_get_field_action(formId, conditionalLogic["nextButton"]);
  1712. gf_do_next_button_action(formId, action, fieldId, isInit);
  1713. }
  1714. }
  1715. function gf_get_field_action(formId, conditionalLogic){
  1716. if(!conditionalLogic)
  1717. return "show";
  1718. var matches = 0;
  1719. for(var i = 0; i < conditionalLogic["rules"].length; i++){
  1720. var rule = conditionalLogic["rules"][i];
  1721. if(gf_is_match(formId, rule))
  1722. matches++;
  1723. }
  1724. var action;
  1725. if( (conditionalLogic["logicType"] == "all" && matches == conditionalLogic["rules"].length) || (conditionalLogic["logicType"] == "any" && matches > 0) )
  1726. action = conditionalLogic["actionType"];
  1727. else
  1728. action = conditionalLogic["actionType"] == "show" ? "hide" : "show";
  1729. return action;
  1730. }
  1731. function gf_is_match( formId, rule ) {
  1732. var $ = jQuery,
  1733. inputId = rule['fieldId'],
  1734. fieldId = gformExtractFieldId( inputId ),
  1735. inputIndex = gformExtractInputIndex( inputId ),
  1736. isInputSpecific = inputIndex !== false,
  1737. $inputs;
  1738. if( isInputSpecific ) {
  1739. $inputs = $( '#input_{0}_{1}_{2}'.format( formId, fieldId, inputIndex ) );
  1740. } else {
  1741. $inputs = $( 'input[id="input_{0}_{1}"], input[id^="input_{0}_{1}_"], input[id^="choice_{0}_{1}_"], select#input_{0}_{1}, textarea#input_{0}_{1}'.format( formId, rule.fieldId ) );
  1742. }
  1743. var isCheckable = $.inArray( $inputs.attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1,
  1744. isMatch = isCheckable ? gf_is_match_checkable( $inputs, rule, formId, fieldId ) : gf_is_match_default( $inputs.eq( 0 ), rule, formId, fieldId );
  1745. return gform.applyFilters( 'gform_is_value_match', isMatch, formId, rule );
  1746. }
  1747. function gf_is_match_checkable( $inputs, rule, formId, fieldId ) {
  1748. var isMatch = false;
  1749. $inputs.each( function() {
  1750. var $input = jQuery( this ),
  1751. fieldValue = gf_get_value( $input.val() ),
  1752. isRangeOperator = jQuery.inArray( rule.operator, [ '<', '>' ] ) !== -1,
  1753. isStringOperator = jQuery.inArray( rule.operator, [ 'contains', 'starts_with', 'ends_with' ] ) !== -1;
  1754. // if we are looking for a specific value and this is not it, skip
  1755. if( fieldValue != rule.value && ! isRangeOperator && ! isStringOperator ) {
  1756. return; // continue
  1757. }
  1758. // force an empty value for unchecked items
  1759. if( ! $input.is( ':checked' ) ) {
  1760. fieldValue = '';
  1761. }
  1762. // if the 'other' choice is selected, get the value from the 'other' text input
  1763. else if ( fieldValue == 'gf_other_choice' ) {
  1764. fieldValue = $( '#input_{0}_{1}_other'.format( formId, fieldId ) ).val();
  1765. }
  1766. if( gf_matches_operation( fieldValue, rule.value, rule.operator ) ) {
  1767. isMatch = true;
  1768. return false; // break
  1769. }
  1770. } );
  1771. return isMatch;
  1772. }
  1773. function gf_is_match_default( $input, rule, formId, fieldId ) {
  1774. var val = $input.val(),
  1775. values = ( val instanceof Array ) ? val : [ val ], // transform regular value into array to support multi-select (which returns an array of selected items)
  1776. matchCount = 0;
  1777. for( var i = 0; i < values.length; i++ ) {
  1778. // fields with pipes in the value will use the label for conditional logic comparison
  1779. var hasLabel = values[i] ? values[i].indexOf( '|' ) >= 0 : true,
  1780. fieldValue = gf_get_value( values[i] );
  1781. var fieldNumberFormat = gf_get_field_number_format( rule.fieldId, formId, 'value' );
  1782. if( fieldNumberFormat && ! hasLabel ) {
  1783. fieldValue = gf_format_number( fieldValue, fieldNumberFormat );
  1784. }
  1785. var ruleValue = rule.value;
  1786. if ( fieldNumberFormat ) {
  1787. ruleValue = gf_format_number( ruleValue, fieldNumberFormat );
  1788. }
  1789. if( gf_matches_operation( fieldValue, ruleValue, rule.operator ) ) {
  1790. matchCount++;
  1791. }
  1792. }
  1793. // if operator is 'isnot', none of the values can match
  1794. var isMatch = rule.operator == 'isnot' ? matchCount == values.length : matchCount > 0;
  1795. return isMatch;
  1796. }
  1797. function gf_format_number( value, fieldNumberFormat ) {
  1798. decimalSeparator = '.';
  1799. if( fieldNumberFormat == 'currency' ) {
  1800. decimalSeparator = gformGetDecimalSeparator( 'currency' );
  1801. } else if( fieldNumberFormat == 'decimal_comma' ) {
  1802. decimalSeparator = ',';
  1803. } else if( fieldNumberFormat == 'decimal_dot' ) {
  1804. decimalSeparator = '.';
  1805. }
  1806. // transform to a decimal dot number
  1807. value = gformCleanNumber( value, '', '', decimalSeparator );
  1808. /**
  1809. * Looking at format specified by wp locale creates issues. When performing conditional logic, all numbers will be formatted to decimal dot and then compared that way. AC
  1810. */
  1811. // now transform to number specified by locale
  1812. // if( window['gf_number_format'] && window['gf_number_format'] == 'decimal_comma' ) {
  1813. // value = gformFormatNumber( value, -1, ',', '.' );
  1814. // }
  1815. if( ! value ) {
  1816. value = 0;
  1817. }
  1818. number = value.toString();
  1819. return number;
  1820. }
  1821. function gf_try_convert_float(text){
  1822. /*
  1823. * The only format that should matter is the field format. Attempting to do this by WP locale creates a lot of issues with consistency.
  1824. * var format = window["gf_number_format"] == "decimal_comma" ? "decimal_comma" : "decimal_dot";
  1825. */
  1826. var format = 'decimal_dot';
  1827. if( gformIsNumeric( text, format ) ) {
  1828. var decimal_separator = format == "decimal_comma" ? "," : ".";
  1829. return gformCleanNumber( text, "", "", decimal_separator );
  1830. }
  1831. return text;
  1832. }
  1833. function gf_matches_operation(val1, val2, operation){
  1834. val1 = val1 ? val1.toLowerCase() : "";
  1835. val2 = val2 ? val2.toLowerCase() : "";
  1836. switch(operation){
  1837. case "is" :
  1838. return val1 == val2;
  1839. break;
  1840. case "isnot" :
  1841. return val1 != val2;
  1842. break;
  1843. case ">" :
  1844. val1 = gf_try_convert_float(val1);
  1845. val2 = gf_try_convert_float(val2);
  1846. return gformIsNumber(val1) && gformIsNumber(val2) ? val1 > val2 : false;
  1847. break;
  1848. case "<" :
  1849. val1 = gf_try_convert_float(val1);
  1850. val2 = gf_try_convert_float(val2);
  1851. return gformIsNumber(val1) && gformIsNumber(val2) ? val1 < val2 : false;
  1852. break;
  1853. case "contains" :
  1854. return val1.indexOf(val2) >=0;
  1855. break;
  1856. case "starts_with" :
  1857. return val1.indexOf(val2) ==0;
  1858. break;
  1859. case "ends_with" :
  1860. var start = val1.length - val2.length;
  1861. if(start < 0)
  1862. return false;
  1863. var tail = val1.substring(start);
  1864. return val2 == tail;
  1865. break;
  1866. }
  1867. return false;
  1868. }
  1869. function gf_get_value(val){
  1870. if(!val)
  1871. return "";
  1872. val = val.split("|");
  1873. return val[0];
  1874. }
  1875. function gf_do_field_action(formId, action, fieldId, isInit, callback){
  1876. var conditional_logic = window["gf_form_conditional_logic"][formId];
  1877. var dependent_fields = conditional_logic["dependents"][fieldId];
  1878. for(var i=0; i < dependent_fields.length; i++){
  1879. var targetId = fieldId == 0 ? "#gform_submit_button_" + formId : "#field_" + formId + "_" + dependent_fields[i];
  1880. var defaultValues = conditional_logic["defaults"][dependent_fields[i]];
  1881. //calling callback function on the last dependent field, to make sure it is only called once
  1882. do_callback = (i+1) == dependent_fields.length ? callback : null;
  1883. gf_do_action(action, targetId, conditional_logic["animation"], defaultValues, isInit, do_callback);
  1884. gform.doAction('gform_post_conditional_logic_field_action', formId, action, targetId, defaultValues, isInit);
  1885. }
  1886. }
  1887. function gf_do_next_button_action(formId, action, fieldId, isInit){
  1888. var conditional_logic = window["gf_form_conditional_logic"][formId];
  1889. var targetId = "#gform_next_button_" + formId + "_" + fieldId;
  1890. gf_do_action(action, targetId, conditional_logic["animation"], null, isInit);
  1891. }
  1892. function gf_do_action(action, targetId, useAnimation, defaultValues, isInit, callback){
  1893. var $target = jQuery(targetId);
  1894. if(action == "show"){
  1895. // reset tabindex for selects
  1896. $target.find( 'select' ).each( function() {
  1897. $select = jQuery( this );
  1898. $select.attr( 'tabindex', $select.data( 'tabindex' ) );
  1899. } );
  1900. if(useAnimation && !isInit){
  1901. if($target.length > 0){
  1902. $target.slideDown(callback);
  1903. } else if(callback){
  1904. callback();
  1905. }
  1906. }
  1907. else{
  1908. var display = $target.data('gf_display');
  1909. //defaults to list-item if previous (saved) display isn't set for any reason
  1910. if ( display == '' || display == 'none' ){
  1911. display = 'list-item';
  1912. }
  1913. $target.css('display', display);
  1914. if(callback){
  1915. callback();
  1916. }
  1917. }
  1918. }
  1919. else{
  1920. //if field is not already hidden, reset its values to the default
  1921. var child = $target.children().first();
  1922. if (child.length > 0){
  1923. if(!gformIsHidden(child)){
  1924. gf_reset_to_default(targetId, defaultValues);
  1925. }
  1926. }
  1927. // remove tabindex and stash as a data attr for selects
  1928. $target.find( 'select' ).each( function() {
  1929. $select = jQuery( this );
  1930. $select.data( 'tabindex', $select.attr( 'tabindex' ) ).removeAttr( 'tabindex' );
  1931. } );
  1932. //Saving existing display so that it can be reset when showing the field
  1933. if( ! $target.data('gf_display') ){
  1934. $target.data('gf_display', $target.css('display'));
  1935. }
  1936. if(useAnimation && !isInit){
  1937. if($target.length > 0 && $target.is(":visible")) {
  1938. $target.slideUp(callback);
  1939. } else if(callback) {
  1940. callback();
  1941. }
  1942. } else{
  1943. $target.hide();
  1944. if(callback){
  1945. callback();
  1946. }
  1947. }
  1948. }
  1949. }
  1950. function gf_reset_to_default(targetId, defaultValue){
  1951. var dateFields = jQuery( targetId ).find( '.gfield_date_month input, .gfield_date_day input, .gfield_date_year input, .gfield_date_dropdown_month select, .gfield_date_dropdown_day select, .gfield_date_dropdown_year select' );
  1952. if( dateFields.length > 0 ) {
  1953. dateFields.each( function(){
  1954. var element = jQuery( this );
  1955. // defaultValue is associative array (i.e. [ m: 1, d: 13, y: 1987 ] )
  1956. if( defaultValue ) {
  1957. var key = 'd';
  1958. if (element.parents().hasClass('gfield_date_month') || element.parents().hasClass('gfield_date_dropdown_month') ){
  1959. key = 'm';
  1960. }
  1961. else if(element.parents().hasClass('gfield_date_year') || element.parents().hasClass('gfield_date_dropdown_year') ){
  1962. key = 'y';
  1963. }
  1964. val = defaultValue[ key ];
  1965. }
  1966. else{
  1967. val = "";
  1968. }
  1969. if(element.prop("tagName") == "SELECT" && val != '' )
  1970. val = parseInt(val);
  1971. if(element.val() != val)
  1972. element.val(val).trigger("change");
  1973. else
  1974. element.val(val);
  1975. });
  1976. return;
  1977. }
  1978. //cascading down conditional logic to children to suppport nested conditions
  1979. //text fields and drop downs, filter out list field text fields name with "_shim"
  1980. var target = jQuery(targetId).find('select, input[type="text"]:not([id*="_shim"]), input[type="number"], textarea');
  1981. var target_index = 0;
  1982. target.each(function(){
  1983. var val = "";
  1984. var element = jQuery(this);
  1985. //get name of previous input field to see if it is the radio button which goes with the "Other" text box
  1986. //otherwise field is populated with input field name
  1987. var radio_button_name = element.prev("input").attr("value");
  1988. if(radio_button_name == "gf_other_choice"){
  1989. val = element.attr("value");
  1990. }
  1991. else if(jQuery.isArray(defaultValue)){
  1992. val = defaultValue[target_index];
  1993. }
  1994. else if(jQuery.isPlainObject(defaultValue)){
  1995. val = defaultValue[element.attr("name")];
  1996. if( ! val ) {
  1997. // 'input_123_3_1' => '3.1'
  1998. var inputId = element.attr( 'id' ).split( '_' ).slice( 2 ).join( '.' );
  1999. val = defaultValue[ inputId ];
  2000. }
  2001. }
  2002. else if(defaultValue){
  2003. val = defaultValue;
  2004. }
  2005. if( element.is('select:not([multiple])') && ! val ) {
  2006. val = element.find( 'option' ).not( ':disabled' ).eq(0).val();
  2007. }
  2008. if(element.val() != val) {
  2009. element.val(val).trigger('change');
  2010. if (element.is('select') && element.next().hasClass('chosen-container')) {
  2011. element.trigger('chosen:updated');
  2012. }
  2013. }
  2014. else{
  2015. element.val(val);
  2016. }
  2017. target_index++;
  2018. });
  2019. //checkboxes and radio buttons
  2020. var elements = jQuery(targetId).find('input[type="radio"], input[type="checkbox"]:not(".copy_values_activated")');
  2021. elements.each(function(){
  2022. //is input currently checked?
  2023. var isChecked = jQuery(this).is(':checked') ? true : false;
  2024. //does input need to be marked as checked or unchecked?
  2025. var doCheck = defaultValue ? jQuery.inArray(jQuery(this).attr('id'), defaultValue) > -1 : false;
  2026. //if value changed, trigger click event
  2027. if(isChecked != doCheck){
  2028. //setting input as checked or unchecked appropriately
  2029. if(jQuery(this).attr("type") == "checkbox"){
  2030. jQuery(this).trigger('click');
  2031. }
  2032. else{
  2033. jQuery(this).prop("checked", doCheck);
  2034. //need to set the prop again after the click is triggered
  2035. jQuery(this).trigger('click').prop('checked', doCheck);
  2036. }
  2037. }
  2038. });
  2039. }
  2040. /*============================================
  2041. Date-Picker
  2042. ==============================================*/
  2043. jQuery(document).ready(gformInitDatepicker);
  2044. function gformInitDatepicker() {
  2045. jQuery('.datepicker').each(function () {
  2046. var element = jQuery(this),
  2047. inputId = this.id,
  2048. optionsObj = {
  2049. yearRange: '-100:+20',
  2050. showOn: 'focus',
  2051. dateFormat: 'mm/dd/yy',
  2052. changeMonth: true,
  2053. changeYear: true,
  2054. suppressDatePicker: false,
  2055. onClose: function () {
  2056. element.focus();
  2057. var self = this;
  2058. this.suppressDatePicker = true;
  2059. setTimeout( function() {
  2060. self.suppressDatePicker = false;
  2061. }, 200 );
  2062. },
  2063. beforeShow: function( input, inst ) {
  2064. return ! this.suppressDatePicker;
  2065. }
  2066. };
  2067. if (element.hasClass('dmy')) {
  2068. optionsObj.dateFormat = 'dd/mm/yy';
  2069. } else if (element.hasClass('dmy_dash')) {
  2070. optionsObj.dateFormat = 'dd-mm-yy';
  2071. } else if (element.hasClass('dmy_dot')) {
  2072. optionsObj.dateFormat = 'dd.mm.yy';
  2073. } else if (element.hasClass('ymd_slash')) {
  2074. optionsObj.dateFormat = 'yy/mm/dd';
  2075. } else if (element.hasClass('ymd_dash')) {
  2076. optionsObj.dateFormat = 'yy-mm-dd';
  2077. } else if (element.hasClass('ymd_dot')) {
  2078. optionsObj.dateFormat = 'yy.mm.dd';
  2079. }
  2080. if (element.hasClass('datepicker_with_icon')) {
  2081. optionsObj.showOn = 'both';
  2082. optionsObj.buttonImage = jQuery('#gforms_calendar_icon_' + inputId).val();
  2083. optionsObj.buttonImageOnly = true;
  2084. }
  2085. inputId = inputId.split('_');
  2086. // allow the user to override the datepicker options object
  2087. optionsObj = gform.applyFilters('gform_datepicker_options_pre_init', optionsObj, inputId[1], inputId[2]);
  2088. element.datepicker(optionsObj);
  2089. });
  2090. }