123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733 |
- /* Bootstrap v3.2.0 (c) 2011-2014 Twitter, Inc. Licensed under MIT */
- 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);
- /* Bootstrap: offcanvas.js v3.1.3 (c) 2012-2014 Arnold Daniels Licensed under Apache */
- +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)
- /*============================================
- Navigation
- ==============================================*/
- $('.nav-toggle').on('touchstart click', function(e) {
- e.preventDefault();
- $( this ).toggleClass( 'active' );
- });
- $(function dw_hidenav() {
- var headerHeight = $('.navbar').height();
- $(window).on('scroll', { previousTop: 0 },
- function() {
- var currentTop = $(window).scrollTop();
- if (currentTop < this.previousTop) {
- if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
- $('.navbar').addClass('visible');
- } else {
- $('.navbar').removeClass('visible fixed');
- }
- }
- else {
- $('.navbar').removeClass('visible');
- if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
- }
- this.previousTop = currentTop;
- }
- );
- });
- /*============================================
- jQuery JSON
- ==============================================*/
- /**
- * jQuery JSON plugin v2.5.1
- * https://github.com/Krinkle/jquery-json
- *
- * @author Brantley Harris, 2009-2011
- * @author Timo Tijhof, 2011-2014
- * @source This plugin is heavily influenced by MochiKit's serializeJSON, which is
- * copyrighted 2005 by Bob Ippolito.
- * @source Brantley Harris wrote this plugin. It is based somewhat on the JSON.org
- * website's http://www.json.org/json2.js, which proclaims:
- * "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
- * I uphold.
- * @license MIT License <http://opensource.org/licenses/MIT>
- */
- (function ($) {
- 'use strict';
- var escape = /["\\\x00-\x1f\x7f-\x9f]/g,
- meta = {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"': '\\"',
- '\\': '\\\\'
- },
- hasOwn = Object.prototype.hasOwnProperty;
- /**
- * jQuery.toJSON
- * Converts the given argument into a JSON representation.
- *
- * @param o {Mixed} The json-serializable *thing* to be converted
- *
- * If an object has a toJSON prototype, that will be used to get the representation.
- * Non-integer/string keys are skipped in the object, as are keys that point to a
- * function.
- *
- */
- $.toJSON = typeof JSON === 'object' && JSON.stringify ? JSON.stringify : function (o) {
- if (o === null) {
- return 'null';
- }
- var pairs, k, name, val,
- type = $.type(o);
- if (type === 'undefined') {
- return undefined;
- }
- // Also covers instantiated Number and Boolean objects,
- // which are typeof 'object' but thanks to $.type, we
- // catch them here. I don't know whether it is right
- // or wrong that instantiated primitives are not
- // exported to JSON as an {"object":..}.
- // We choose this path because that's what the browsers did.
- if (type === 'number' || type === 'boolean') {
- return String(o);
- }
- if (type === 'string') {
- return $.quoteString(o);
- }
- if (typeof o.toJSON === 'function') {
- return $.toJSON(o.toJSON());
- }
- if (type === 'date') {
- var month = o.getUTCMonth() + 1,
- day = o.getUTCDate(),
- year = o.getUTCFullYear(),
- hours = o.getUTCHours(),
- minutes = o.getUTCMinutes(),
- seconds = o.getUTCSeconds(),
- milli = o.getUTCMilliseconds();
- if (month < 10) {
- month = '0' + month;
- }
- if (day < 10) {
- day = '0' + day;
- }
- if (hours < 10) {
- hours = '0' + hours;
- }
- if (minutes < 10) {
- minutes = '0' + minutes;
- }
- if (seconds < 10) {
- seconds = '0' + seconds;
- }
- if (milli < 100) {
- milli = '0' + milli;
- }
- if (milli < 10) {
- milli = '0' + milli;
- }
- return '"' + year + '-' + month + '-' + day + 'T' +
- hours + ':' + minutes + ':' + seconds +
- '.' + milli + 'Z"';
- }
- pairs = [];
- if ($.isArray(o)) {
- for (k = 0; k < o.length; k++) {
- pairs.push($.toJSON(o[k]) || 'null');
- }
- return '[' + pairs.join(',') + ']';
- }
- // Any other object (plain object, RegExp, ..)
- // Need to do typeof instead of $.type, because we also
- // want to catch non-plain objects.
- if (typeof o === 'object') {
- for (k in o) {
- // Only include own properties,
- // Filter out inherited prototypes
- if (hasOwn.call(o, k)) {
- // Keys must be numerical or string. Skip others
- type = typeof k;
- if (type === 'number') {
- name = '"' + k + '"';
- } else if (type === 'string') {
- name = $.quoteString(k);
- } else {
- continue;
- }
- type = typeof o[k];
- // Invalid values like these return undefined
- // from toJSON, however those object members
- // shouldn't be included in the JSON string at all.
- if (type !== 'function' && type !== 'undefined') {
- val = $.toJSON(o[k]);
- pairs.push(name + ':' + val);
- }
- }
- }
- return '{' + pairs.join(',') + '}';
- }
- };
- /**
- * jQuery.evalJSON
- * Evaluates a given json string.
- *
- * @param str {String}
- */
- $.evalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
- /*jshint evil: true */
- return eval('(' + str + ')');
- };
- /**
- * jQuery.secureEvalJSON
- * Evals JSON in a way that is *more* secure.
- *
- * @param str {String}
- */
- $.secureEvalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
- var filtered =
- str
- .replace(/\\["\\\/bfnrtu]/g, '@')
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
- .replace(/(?:^|:|,)(?:\s*\[)+/g, '');
- if (/^[\],:{}\s]*$/.test(filtered)) {
- /*jshint evil: true */
- return eval('(' + str + ')');
- }
- throw new SyntaxError('Error parsing JSON, source is not valid.');
- };
- /**
- * jQuery.quoteString
- * Returns a string-repr of a string, escaping quotes intelligently.
- * Mostly a support function for toJSON.
- * Examples:
- * >>> jQuery.quoteString('apple')
- * "apple"
- *
- * >>> jQuery.quoteString('"Where are we going?", she asked.')
- * "\"Where are we going?\", she asked."
- */
- $.quoteString = function (str) {
- if (str.match(escape)) {
- return '"' + str.replace(escape, function (a) {
- var c = meta[a];
- if (typeof c === 'string') {
- return c;
- }
- c = a.charCodeAt();
- return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
- }) + '"';
- }
- return '"' + str + '"';
- };
- }(jQuery));
- /*============================================
- Placeholders.js v2.1.1
- ==============================================*/
- (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);
- /*============================================
- Gravity Forms
- ==============================================*/
- // "prop" method fix for previous versions of jQuery (1.5 and below)
- if( typeof jQuery.fn.prop === 'undefined' ) {
- jQuery.fn.prop = jQuery.fn.attr;
- }
- jQuery(document).ready(function(){
- //Formatting free form currency fields to currency
- jQuery(document).bind('gform_post_render', gformBindFormatPricingFields);
- });
- function gformBindFormatPricingFields(){
- jQuery(".ginput_amount, .ginput_donation_amount").bind("change", function(){
- gformFormatPricingField(this);
- });
- jQuery(".ginput_amount, .ginput_donation_amount").each(function(){
- gformFormatPricingField(this);
- });
- }
- //------------------------------------------------
- //---------- CURRENCY ----------------------------
- //------------------------------------------------
- function Currency(currency){
- this.currency = currency;
- this.toNumber = function(text){
- if(this.isNumeric(text))
- return parseFloat(text);
- return gformCleanNumber(text, this.currency["symbol_right"], this.currency["symbol_left"], this.currency["decimal_separator"]);
- };
- this.toMoney = function(number){
- if(!this.isNumeric(number))
- number = this.toNumber(number);
- if(number === false)
- return "";
- number = number + "";
- negative = "";
- if(number[0] == "-"){
- number = parseFloat(number.substr(1));
- negative = '-';
- }
- money = this.numberFormat(number, this.currency["decimals"], this.currency["decimal_separator"], this.currency["thousand_separator"]);
- if ( money == '0.00' ){
- negative = '';
- }
- var symbol_left = this.currency["symbol_left"] ? this.currency["symbol_left"] + this.currency["symbol_padding"] : "";
- var symbol_right = this.currency["symbol_right"] ? this.currency["symbol_padding"] + this.currency["symbol_right"] : "";
- money = negative + this.htmlDecode(symbol_left) + money + this.htmlDecode(symbol_right);
- return money;
- };
- this.numberFormat = function(number, decimals, dec_point, thousands_sep, padded){
- var padded = typeof padded == 'undefined';
- number = (number+'').replace(',', '').replace(' ', '');
- var n = !isFinite(+number) ? 0 : +number,
- prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
- sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
- s = '',
- toFixedFix = function (n, prec) {
- var k = Math.pow(10, prec);
- return '' + Math.round(n * k) / k;
- };
- if(decimals == '0') {
- 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 )
- s = ('' + Math.round(n)).split('.');
- } else
- if(decimals == -1) {
- s = ('' + n).split('.');
- } else {
- 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 )
- // Fix for IE parseFloat(0.55).toFixed(0) = 0;
- s = toFixedFix(n, prec).split('.');
- }
- if (s[0].length > 3) {
- s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
- }
- if(padded) {
- if ((s[1] || '').length < prec) {
- s[1] = s[1] || '';
- s[1] += new Array(prec - s[1].length + 1).join('0');
- }
- }
- return s.join(dec);
- }
- this.isNumeric = function(number){
- return gformIsNumber(number);
- };
- this.htmlDecode = function(text) {
- var c,m,d = text;
- // look for numerical entities "
- var arr=d.match(/&#[0-9]{1,5};/g);
- // if no matches found in string then skip
- if(arr!=null){
- for(var x=0;x<arr.length;x++){
- m = arr[x];
- c = m.substring(2,m.length-1); //get numeric part which is refernce to unicode character
- // if its a valid number we can decode
- if(c >= -32768 && c <= 65535){
- // decode every single match within string
- d = d.replace(m, String.fromCharCode(c));
- }else{
- d = d.replace(m, ""); //invalid so replace with nada
- }
- }
- }
- return d;
- };
- }
- function gformCleanNumber(text, symbol_right, symbol_left, decimal_separator){
- var clean_number = '',
- float_number = '',
- digit = '',
- is_negative = false;
- //converting to a string if a number as passed
- text = text + " ";
- //Removing symbol in unicode format (i.e. ᅜ)
- text = text.replace(/&.*?;/g, "");
- //Removing symbol from text
- text = text.replace(symbol_right, "");
- text = text.replace(symbol_left, "");
- //Removing all non-numeric characters
- for(var i=0; i<text.length; i++){
- digit = text.substr(i,1);
- if( (parseInt(digit) >= 0 && parseInt(digit) <= 9) || digit == decimal_separator )
- clean_number += digit;
- else if(digit == '-')
- is_negative = true;
- }
- //Removing thousand separators but keeping decimal point
- for(var i=0; i<clean_number.length; i++) {
- digit = clean_number.substr(i,1);
- if (digit >= '0' && digit <= '9')
- float_number += digit;
- else if(digit == decimal_separator){
- float_number += ".";
- }
- }
- if(is_negative)
- float_number = "-" + float_number;
- return gformIsNumber(float_number) ? parseFloat(float_number) : false;
- }
- function gformGetDecimalSeparator(numberFormat){
- var s;
- switch (numberFormat){
- case 'currency' :
- var currency = new Currency(gf_global.gf_currency_config);
- s = currency.currency["decimal_separator"];
- break;
- case 'decimal_comma' :
- s = ',';
- break;
- default :
- s = "."
- }
- return s;
- }
- function gformIsNumber(n) {
- return !isNaN(parseFloat(n)) && isFinite(n);
- }
- function gformIsNumeric(value, number_format){
- switch(number_format){
- case "decimal_dot" :
- var r = new RegExp("^(-?[0-9]{1,3}(?:,?[0-9]{3})*(?:\.[0-9]+)?)$");
- return r.test(value);
- break;
- case "decimal_comma" :
- var r = new RegExp("^(-?[0-9]{1,3}(?:\.?[0-9]{3})*(?:,[0-9]+)?)$");
- return r.test(value);
- break;
- }
- return false;
- }
- //------------------------------------------------
- //---------- MULTI-PAGE --------------------------
- //------------------------------------------------
- function gformDeleteUploadedFile(formId, fieldId, deleteButton){
- var parent = jQuery("#field_" + formId + "_" + fieldId);
- var fileIndex = jQuery(deleteButton).parent().index();
- parent.find(".ginput_preview").eq(fileIndex).remove();
- //displaying single file upload field
- parent.find("input[type=\"file\"]").removeClass("gform_hidden");
- //displaying post image label
- parent.find(".ginput_post_image_file").show();
- //clearing post image meta fields
- parent.find("input[type=\"text\"]").val('');
- //removing file from uploaded meta
- var filesJson = jQuery('#gform_uploaded_files_' + formId).val();
- if(filesJson){
- var files = jQuery.secureEvalJSON(filesJson);
- if(files) {
- var inputName = "input_" + fieldId;
- var $multfile = parent.find("#gform_multifile_upload_" + formId + "_" + fieldId );
- if( $multfile.length > 0 ) {
- files[inputName].splice(fileIndex, 1);
- var settings = $multfile.data('settings');
- var max = settings.gf_vars.max_files;
- jQuery("#" + settings.gf_vars.message_id).html('');
- if(files[inputName].length < max)
- gfMultiFileUploader.toggleDisabled(settings, false);
- } else {
- files[inputName] = null;
- }
- jQuery('#gform_uploaded_files_' + formId).val(jQuery.toJSON(files));
- }
- }
- }
- //------------------------------------------------
- //---------- PRICE -------------------------------
- //------------------------------------------------
- var _gformPriceFields = new Array();
- var _anyProductSelected;
- function gformIsHidden(element){
- return element.parents('.gfield').not(".gfield_hidden_product").css("display") == "none";
- }
- function gformCalculateTotalPrice(formId){
- if(!_gformPriceFields[formId])
- return;
- var price = 0;
- _anyProductSelected = false; //Will be used by gformCalculateProductPrice().
- for(var i=0; i<_gformPriceFields[formId].length; i++){
- price += gformCalculateProductPrice(formId, _gformPriceFields[formId][i]);
- }
- //add shipping price if a product has been selected
- if(_anyProductSelected){
- //shipping price
- var shipping = gformGetShippingPrice(formId)
- price += shipping;
- }
- //gform_product_total filter. Allows uers to perform custom price calculation
- if(window["gform_product_total"])
- price = window["gform_product_total"](formId, price);
- price = gform.applyFilters('gform_product_total', price, formId);
- //updating total
- var totalElement = jQuery(".ginput_total_" + formId);
- if( totalElement.length > 0 ) {
- var currentTotal = totalElement.next().val(),
- formattedTotal = gformFormatMoney(price);
- if (currentTotal != price) {
- totalElement.next().val(price).change();
- }
- if (formattedTotal != totalElement.first().text()) {
- totalElement.html(formattedTotal);
- }
- }
- }
- function gformGetShippingPrice(formId){
- var shippingField = jQuery(".gfield_shipping_" + formId + " input[type=\"hidden\"], .gfield_shipping_" + formId + " select, .gfield_shipping_" + formId + " input:checked");
- var shipping = 0;
- if(shippingField.length == 1 && !gformIsHidden(shippingField)){
- if(shippingField.attr("type") && shippingField.attr("type").toLowerCase() == "hidden")
- shipping = shippingField.val();
- else
- shipping = gformGetPrice(shippingField.val());
- }
- return gformToNumber(shipping);
- }
- function gformGetFieldId(element){
- var id = jQuery(element).attr("id");
- var pieces = id.split("_");
- if(pieces.length <=0)
- return 0;
- var fieldId = pieces[pieces.length-1];
- return fieldId;
- }
- function gformCalculateProductPrice(form_id, productFieldId){
- var suffix = '_' + form_id + '_' + productFieldId;
- //Drop down auto-calculating labels
- jQuery('.gfield_option' + suffix + ', .gfield_shipping_' + form_id).find('select').each(function(){
- var dropdown_field = jQuery(this);
- var selected_price = gformGetPrice(dropdown_field.val());
- var field_id = dropdown_field.attr('id').split('_')[2];
- dropdown_field.children('option').each(function(){
- var choice_element = jQuery(this);
- var label = gformGetOptionLabel(choice_element, choice_element.val(), selected_price, form_id, field_id);
- choice_element.html(label);
- });
- dropdown_field.trigger('chosen:updated');
- });
- //Checkboxes labels with prices
- jQuery('.gfield_option' + suffix).find('.gfield_checkbox').find('input:checkbox').each(function(){
- var checkbox_item = jQuery(this);
- var id = checkbox_item.attr('id');
- var field_id = id.split('_')[2];
- var label_id = id.replace('choice_', '#label_');
- var label_element = jQuery(label_id);
- var label = gformGetOptionLabel(label_element, checkbox_item.val(), 0, form_id, field_id);
- label_element.html(label);
- });
- //Radio button auto-calculating lables
- jQuery('.gfield_option' + suffix + ', .gfield_shipping_' + form_id).find('.gfield_radio').each(function(){
- var selected_price = 0;
- var radio_field = jQuery(this);
- var id = radio_field.attr('id');
- var fieldId = id.split('_')[2];
- var selected_value = radio_field.find('input:radio:checked').val();
- if(selected_value)
- selected_price = gformGetPrice(selected_value);
- radio_field.find('input:radio').each(function(){
- var radio_item = jQuery(this);
- var label_id = radio_item.attr('id').replace('choice_', '#label_');
- var label_element = jQuery(label_id);
- if ( label_element ) {
- var label = gformGetOptionLabel(label_element, radio_item.val(), selected_price, form_id, fieldId);
- label_element.html(label);
- }
- });
- });
- var price = gformGetBasePrice(form_id, productFieldId);
- var quantity = gformGetProductQuantity( form_id, productFieldId );
- //calculating options if quantity is more than 0 (a product was selected).
- if( quantity > 0 ) {
- jQuery('.gfield_option' + suffix).find('input:checked, select').each(function(){
- if(!gformIsHidden(jQuery(this)))
- price += gformGetPrice(jQuery(this).val());
- });
- //setting global variable if quantity is more than 0 (a product was selected). Will be used when calculating total
- _anyProductSelected = true;
- }
- price = price * quantity;
- price = Math.round(price * 100) / 100;
- return price;
- }
- function gformGetProductQuantity(formId, productFieldId) {
- //If product is not selected
- if (!gformIsProductSelected(formId, productFieldId)) {
- return 0;
- }
- var quantity,
- quantityInput = jQuery('#ginput_quantity_' + formId + '_' + productFieldId),
- numberFormat;
- if (quantityInput.length > 0) {
- quantity = quantityInput.val();
- } else {
- quantityInput = jQuery('.gfield_quantity_' + formId + '_' + productFieldId + ' :input');
- quantity = 1;
- if (quantityInput.length > 0) {
- quantity = quantityInput.val();
- var htmlId = quantityInput.attr('id'),
- fieldId = gf_get_input_id_by_html_id(htmlId);
- numberFormat = gf_get_field_number_format( fieldId, formId, 'value' );
- }
- }
- if (!numberFormat)
- numberFormat = 'currency';
- var decimalSeparator = gformGetDecimalSeparator(numberFormat);
- quantity = gformCleanNumber(quantity, '', '', decimalSeparator);
- if (!quantity)
- quantity = 0;
- return quantity;
- }
- function gformIsProductSelected( formId, productFieldId ) {
- var suffix = "_" + formId + "_" + productFieldId;
- var productField = jQuery("#ginput_base_price" + suffix + ", .gfield_donation" + suffix + " input[type=\"text\"], .gfield_product" + suffix + " .ginput_amount");
- if( productField.val() && ! gformIsHidden(productField) ){
- return true;
- }
- else
- {
- productField = jQuery(".gfield_product" + suffix + " select, .gfield_product" + suffix + " input:checked, .gfield_donation" + suffix + " select, .gfield_donation" + suffix + " input:checked");
- if( productField.val() && ! gformIsHidden(productField) ){
- return true;
- }
- }
- return false;
- }
- function gformGetBasePrice(formId, productFieldId){
- var suffix = "_" + formId + "_" + productFieldId;
- var price = 0;
- var productField = jQuery("#ginput_base_price" + suffix+ ", .gfield_donation" + suffix + " input[type=\"text\"], .gfield_product" + suffix + " .ginput_amount");
- if(productField.length > 0){
- price = productField.val();
- //If field is hidden by conditional logic, don't count it for the total
- if(gformIsHidden(productField)){
- price = 0;
- }
- }
- else
- {
- productField = jQuery(".gfield_product" + suffix + " select, .gfield_product" + suffix + " input:checked, .gfield_donation" + suffix + " select, .gfield_donation" + suffix + " input:checked");
- var val = productField.val();
- if(val){
- val = val.split("|");
- price = val.length > 1 ? val[1] : 0;
- }
- //If field is hidden by conditional logic, don't count it for the total
- if(gformIsHidden(productField))
- price = 0;
- }
- var c = new Currency(gf_global.gf_currency_config);
- price = c.toNumber(price);
- return price === false ? 0 : price;
- }
- function gformFormatMoney(text){
- if(!gf_global.gf_currency_config)
- return text;
- var currency = new Currency(gf_global.gf_currency_config);
- return currency.toMoney(text);
- }
- function gformFormatPricingField(element){
- if(gf_global.gf_currency_config){
- var currency = new Currency(gf_global.gf_currency_config);
- var price = currency.toMoney(jQuery(element).val());
- jQuery(element).val(price);
- }
- }
- function gformToNumber(text){
- var currency = new Currency(gf_global.gf_currency_config);
- return currency.toNumber(text);
- }
- function gformGetPriceDifference(currentPrice, newPrice){
- //getting price difference
- var diff = parseFloat(newPrice) - parseFloat(currentPrice);
- price = gformFormatMoney(diff);
- if(diff > 0)
- price = "+" + price;
- return price;
- }
- function gformGetOptionLabel(element, selected_value, current_price, form_id, field_id){
- element = jQuery(element);
- var price = gformGetPrice(selected_value);
- var current_diff = element.attr('price');
- var original_label = element.html().replace(/<span(.*)<\/span>/i, "").replace(current_diff, "");
- var diff = gformGetPriceDifference(current_price, price);
- diff = gformToNumber(diff) == 0 ? "" : " " + diff;
- element.attr('price', diff);
- //don't add <span> for drop down items (not supported)
- var price_label = element[0].tagName.toLowerCase() == "option" ? " " + diff : "<span class='ginput_price'>" + diff + "</span>";
- var label = original_label + price_label;
- //calling hook to allow for custom option formatting
- if(window["gform_format_option_label"])
- label = gform_format_option_label(label, original_label, price_label, current_price, price, form_id, field_id);
- return label;
- }
- function gformGetProductIds(parent_class, element){
- var classes = jQuery(element).hasClass(parent_class) ? jQuery(element).attr("class").split(" ") : jQuery(element).parents("." + parent_class).attr("class").split(" ");
- for(var i=0; i<classes.length; i++){
- if(classes[i].substr(0, parent_class.length) == parent_class && classes[i] != parent_class)
- return {formId: classes[i].split("_")[2], productFieldId: classes[i].split("_")[3]};
- }
- return {formId:0, fieldId:0};
- }
- function gformGetPrice(text){
- var val = text.split("|");
- var currency = new Currency(gf_global.gf_currency_config);
- if(val.length > 1 && currency.toNumber(val[1]) !== false)
- return currency.toNumber(val[1]);
- return 0;
- }
- function gformRegisterPriceField(item){
- if(!_gformPriceFields[item.formId])
- _gformPriceFields[item.formId] = new Array();
- //ignore price fields that have already been registered
- for(var i=0; i<_gformPriceFields[item.formId].length; i++)
- if(_gformPriceFields[item.formId][i] == item.productFieldId)
- return;
- //registering new price field
- _gformPriceFields[item.formId].push(item.productFieldId);
- }
- function gformInitPriceFields(){
- jQuery(".gfield_price").each(function(){
- var productIds = gformGetProductIds("gfield_price", this);
- gformRegisterPriceField(productIds);
- jQuery( this ).on( 'change', 'input[type="text"], input[type="number"], select', function() {
- var productIds = gformGetProductIds("gfield_price", this);
- if(productIds.formId == 0)
- productIds = gformGetProductIds("gfield_shipping", this);
- jQuery(document).trigger('gform_price_change', [productIds, this]);
- gformCalculateTotalPrice(productIds.formId);
- });
- jQuery( this ).on( 'click', 'input[type="radio"], input[type="checkbox"]', function() {
- var productIds = gformGetProductIds("gfield_price", this);
- if(productIds.formId == 0)
- productIds = gformGetProductIds("gfield_shipping", this);
- jQuery(document).trigger('gform_price_change', [productIds, this]);
- gformCalculateTotalPrice(productIds.formId);
- });
- });
- for(formId in _gformPriceFields){
- //needed when implementing for in loops
- if(!_gformPriceFields.hasOwnProperty(formId))
- continue;
- gformCalculateTotalPrice(formId);
- }
- }
- //-------------------------------------------
- //---------- PASSWORD -----------------------
- //-------------------------------------------
- function gformShowPasswordStrength(fieldId){
- var password = jQuery("#" + fieldId).val();
- var confirm = jQuery("#" + fieldId + "_2").val();
- var result = gformPasswordStrength(password, confirm);
- var text = window['gf_text']["password_" + result];
- jQuery("#" + fieldId + "_strength").val(result);
- jQuery("#" + fieldId + "_strength_indicator").removeClass("blank mismatch short good bad strong").addClass(result).html(text);
- }
- // Password strength meter
- function gformPasswordStrength(password1, password2) {
- var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
- if(password1.length <=0)
- return "blank";
- // password 1 != password 2
- if ( (password1 != password2) && password2.length > 0)
- return "mismatch";
- //password < 4
- if ( password1.length < 4 )
- return "short";
- if ( password1.match(/[0-9]/) )
- symbolSize +=10;
- if ( password1.match(/[a-z]/) )
- symbolSize +=26;
- if ( password1.match(/[A-Z]/) )
- symbolSize +=26;
- if ( password1.match(/[^a-zA-Z0-9]/) )
- symbolSize +=31;
- natLog = Math.log( Math.pow(symbolSize, password1.length) );
- score = natLog / Math.LN2;
- if (score < 40 )
- return "bad";
- if (score < 56 )
- return "good";
- return "strong";
- }
- //----------------------------
- //------ LIST FIELD ----------
- //----------------------------
- function gformAddListItem( addButton, max ) {
- var $addButton = jQuery( addButton );
- if( $addButton.hasClass( 'gfield_icon_disabled' ) ) {
- return;
- }
- var $group = $addButton.parents( '.gfield_list_group' ),
- $clone = $group.clone(),
- $container = $group.parents( '.gfield_list_container' ),
- tabindex = $clone.find( ':input:last' ).attr( 'tabindex' );
- // reset all inputs to empty state
- $clone
- .find( 'input, select' ).attr( 'tabindex', tabindex )
- .not( ':checkbox, :radio' ).val( '' );
- $clone.find( ':checkbox, :radio' ).prop( 'checked', false );
- $clone = gform.applyFilters( 'gform_list_item_pre_add', $clone, $group );
- $group.after( $clone );
- gformToggleIcons( $container, max );
- gformAdjustClasses( $container );
- }
- function gformDeleteListItem( deleteButton, max ) {
- var $deleteButton = jQuery( deleteButton ),
- $group = $deleteButton.parents( '.gfield_list_group' ),
- $container = $group.parents( '.gfield_list_container' );
- $group.remove();
- gformToggleIcons( $container, max );
- gformAdjustClasses( $container );
- }
- function gformAdjustClasses( $container ) {
- var $groups = $container.find( '.gfield_list_group' );
- $groups.each( function( i ) {
- var $group = jQuery( this ),
- oddEvenClass = ( i + 1 ) % 2 == 0 ? 'gfield_list_row_even' : 'gfield_list_row_odd';
- $group.removeClass( 'gfield_list_row_odd gfield_list_row_even' ).addClass( oddEvenClass );
- } );
- }
- function gformToggleIcons( $container, max ) {
- var groupCount = $container.find( '.gfield_list_group' ).length,
- $addButtons = $container.find( '.add_list_item' );
- $container.find( '.delete_list_item' ).css( 'visibility', groupCount == 1 ? 'hidden' : 'visible' );
- if ( max > 0 && groupCount >= max ) {
- // store original title in the add button
- $addButtons.data( 'title', $container.find( '.add_list_item' ).attr( 'title' ) );
- $addButtons.addClass( 'gfield_icon_disabled' ).attr( 'title', '' );
- } else if( max > 0 ) {
- $addButtons.removeClass( 'gfield_icon_disabled' );
- if( $addButtons.data( 'title' ) ) {
- $addButtons.attr( 'title', $addButtons.data( 'title' ) );
- }
- }
- }
- //-----------------------------------
- //------ CREDIT CARD FIELD ----------
- //-----------------------------------
- function gformMatchCard(id) {
- var cardType = gformFindCardType(jQuery('#' + id).val());
- var cardContainer = jQuery('#' + id).parents('.gfield').find('.gform_card_icon_container');
- if(!cardType) {
- jQuery(cardContainer).find('.gform_card_icon').removeClass('gform_card_icon_selected gform_card_icon_inactive');
- } else {
- jQuery(cardContainer).find('.gform_card_icon').removeClass('gform_card_icon_selected').addClass('gform_card_icon_inactive');
- jQuery(cardContainer).find('.gform_card_icon_' + cardType).removeClass('gform_card_icon_inactive').addClass('gform_card_icon_selected');
- }
- }
- function gformFindCardType(value) {
- if(value.length < 4)
- return false;
- var rules = window['gf_cc_rules'];
- var validCardTypes = new Array();
- for(type in rules) {
- //needed when implementing for in loops
- if(!rules.hasOwnProperty(type))
- continue;
- for(i in rules[type]) {
- if(!rules[type].hasOwnProperty(i))
- continue;
- if(rules[type][i].indexOf(value.substring(0, rules[type][i].length)) === 0) {
- validCardTypes[validCardTypes.length] = type;
- break;
- }
- }
- }
- return validCardTypes.length == 1 ? validCardTypes[0].toLowerCase() : false;
- }
- function gformToggleCreditCard(){
- if(jQuery("#gform_payment_method_creditcard").is(":checked"))
- jQuery(".gform_card_fields_container").slideDown();
- else
- jQuery(".gform_card_fields_container").slideUp();
- }
- //----------------------------------------
- //------ CHOSEN DROP DOWN FIELD ----------
- //----------------------------------------
- function gformInitChosenFields(fieldList, noResultsText){
- return jQuery(fieldList).each(function(){
- var element = jQuery( this );
- // RTL support
- if( jQuery( 'html' ).attr( 'dir' ) == 'rtl' ) {
- element.addClass( 'chosen-rtl chzn-rtl' );
- }
- // only initialize once
- if( element.is(":visible") && element.siblings(".chosen-container").length == 0 ){
- var options = gform.applyFilters( 'gform_chosen_options', { no_results_text: noResultsText }, element );
- element.chosen( options );
- }
- });
- }
- //----------------------------------------
- //--- CURRENCY FORMAT NUMBER FIELD -------
- //----------------------------------------
- function gformInitCurrencyFormatFields(fieldList){
- jQuery(fieldList).each(function(){
- var $this = jQuery(this);
- $this.val( gformFormatMoney( jQuery(this).val() ) );
- }).change( function( event ) {
- jQuery(this).val( gformFormatMoney( jQuery(this).val() ) );
- });
- }
- //----------------------------------------
- //------ CALCULATION FUNCTIONS -----------
- //----------------------------------------
- var GFCalc = function(formId, formulaFields){
- this.patt = /{[^{]*?:(\d+(\.\d+)?)(:(.*?))?}/i;
- this.exprPatt = /^[0-9 -/*\(\)]+$/i;
- this.isCalculating = {};
- this.init = function(formId, formulaFields) {
- var calc = this;
- jQuery(document).bind("gform_post_conditional_logic", function(){
- for(var i=0; i<formulaFields.length; i++) {
- var formulaField = jQuery.extend({}, formulaFields[i]);
- calc.runCalc(formulaField, formId);
- }
- });
- for(var i=0; i<formulaFields.length; i++) {
- var formulaField = jQuery.extend({}, formulaFields[i]);
- this.runCalc(formulaField, formId);
- this.bindCalcEvents(formulaField, formId);
- }
- }
- this.runCalc = function(formulaField, formId) {
- var calcObj = this,
- field = jQuery('#field_' + formId + '_' + formulaField.field_id),
- formulaInput = jQuery('#input_' + formId + '_' + formulaField.field_id),
- previous_val = formulaInput.val(),
- formula = gform.applyFilters( 'gform_calculation_formula', formulaField.formula, formulaField, formId, calcObj ),
- expr = calcObj.replaceFieldTags( formId, formula, formulaField ).replace(/(\r\n|\n|\r)/gm,""),
- result = '';
- if(calcObj.exprPatt.test(expr)) {
- try {
- //run calculation
- result = eval(expr);
- } catch( e ) { }
- }
- // if result is postive infinity, negative infinity or a NaN, defaults to 0
- if( ! isFinite( result ) )
- result = 0;
- // allow users to modify result with their own function
- if( window["gform_calculation_result"] ) {
- result = window["gform_calculation_result"](result, formulaField, formId, calcObj);
- if( window.console )
- console.log( '"gform_calculation_result" function is deprecated since version 1.8! Use "gform_calculation_result" JS hook instead.' );
- }
- // allow users to modify result with their own function
- result = gform.applyFilters( 'gform_calculation_result', result, formulaField, formId, calcObj );
- // allow result to be custom formatted
- var formattedResult = gform.applyFilters( 'gform_calculation_format_result', false, result, formulaField, formId, calcObj );
- var numberFormat = gf_get_field_number_format(formulaField.field_id, formId);
- //formatting number
- if( formattedResult !== false) {
- result = formattedResult;
- }
- else if( field.hasClass( 'gfield_price' ) || numberFormat == "currency") {
- result = gformFormatMoney(result ? result : 0);
- }
- else {
- var decimalSeparator = ".";
- var thousandSeparator = ",";
- if(numberFormat == "decimal_comma"){
- decimalSeparator = ",";
- thousandSeparator = ".";
- }
- result = gformFormatNumber(result, !gformIsNumber(formulaField.rounding) ? -1 : formulaField.rounding, decimalSeparator, thousandSeparator);
- }
- //If value doesn't change, abort.
- //This is needed to prevent an infinite loop condition with conditional logic
- if( result == previous_val )
- return;
- // if this is a calculation product, handle differently
- if(field.hasClass('gfield_price')) {
- formulaInput.text(result);
- jQuery('#ginput_base_price_' + formId + '_' + formulaField.field_id).val(result).trigger('change');
- gformCalculateTotalPrice(formId);
- } else {
- formulaInput.val(result).trigger('change');
- }
- }
- this.bindCalcEvents = function(formulaField, formId) {
- var calcObj = this;
- var formulaFieldId = formulaField.field_id;
- var matches = getMatchGroups(formulaField.formula, this.patt);
- calcObj.isCalculating[formulaFieldId] = false;
- for(var i in matches) {
- if(! matches.hasOwnProperty(i))
- continue;
- var inputId = matches[i][1];
- var fieldId = parseInt(inputId);
- var input = jQuery('#field_' + formId + '_' + fieldId).find('input[name="input_' + inputId + '"], select[name="input_' + inputId + '"]');
- if(input.prop('type') == 'checkbox' || input.prop('type') == 'radio') {
- jQuery(input).click(function(){
- calcObj.bindCalcEvent(inputId, formulaField, formId, 0);
- });
- } else
- if(input.is('select') || input.prop('type') == 'hidden') {
- jQuery(input).change(function(){
- calcObj.bindCalcEvent(inputId, formulaField, formId, 0);
- });
- } else {
- jQuery(input).keydown(function(){
- calcObj.bindCalcEvent(inputId, formulaField, formId);
- }).change(function(){
- calcObj.bindCalcEvent(inputId, formulaField, formId, 0);
- });
- }
- // allow users to add custom methods for triggering calculations
- gform.doAction( 'gform_post_calculation_events', matches[i], formulaField, formId, calcObj );
- }
- }
- this.bindCalcEvent = function(inputId, formulaField, formId, delay) {
- var calcObj = this;
- var formulaFieldId = formulaField.field_id;
- delay = delay == undefined ? 345 : delay;
- if(calcObj.isCalculating[formulaFieldId][inputId])
- clearTimeout(calcObj.isCalculating[formulaFieldId][inputId]);
- calcObj.isCalculating[formulaFieldId][inputId] = window.setTimeout(function() {
- calcObj.runCalc(formulaField, formId);
- }, delay);
- }
- this.replaceFieldTags = function( formId, expr, formulaField ) {
- var matches = getMatchGroups(expr, this.patt);
- var origExpr = expr;
- for(i in matches) {
- if(! matches.hasOwnProperty(i))
- continue;
- var inputId = matches[i][1];
- var fieldId = parseInt(inputId);
- var columnId = matches[i][3];
- var value = 0;
- var input = jQuery('#field_' + formId + '_' + fieldId).find('input[name="input_' + inputId + '"], select[name="input_' + inputId + '"]');
- // radio buttons will return multiple inputs, checkboxes will only return one but it may not be selected, filter out unselected inputs
- if( input.length > 1 || input.prop('type') == 'checkbox' )
- input = input.filter(':checked');
- var isVisible = window['gf_check_field_rule'] ? gf_check_field_rule( formId, fieldId, true, '' ) == 'show' : true;
- if( input.length > 0 && isVisible ) {
- var val = input.val();
- val = val.split( '|' );
- if( val.length > 1 ) {
- value = val[1];
- } else {
- value = input.val();
- }
- }
- var numberFormat = gf_get_field_number_format( fieldId, formId );
- if( ! numberFormat )
- numberFormat = gf_get_field_number_format( formulaField.field_id, formId );
- var decimalSeparator = gformGetDecimalSeparator(numberFormat);
- // allow users to modify value with their own function
- value = gform.applyFilters( 'gform_merge_tag_value_pre_calculation', value, matches[i], isVisible, formulaField, formId );
- value = gformCleanNumber( value, '', '', decimalSeparator );
- if( ! value )
- value = 0;
- expr = expr.replace( matches[i][0], value );
- }
- return expr;
- }
- this.init(formId, formulaFields);
- }
- function gformFormatNumber(number, rounding, decimalSeparator, thousandSeparator){
- if(typeof decimalSeparator == "undefined"){
- if(window['gf_global']){
- var currency = new Currency(gf_global.gf_currency_config);
- decimalSeparator = currency.currency["decimal_separator"];
- }
- else{
- decimalSeparator = ".";
- }
- }
- if(typeof thousandSeparator == "undefined"){
- if(window['gf_global']){
- var currency = new Currency(gf_global.gf_currency_config);
- thousandSeparator = currency.currency["thousand_separator"];
- }
- else{
- thousandSeparator = ",";
- }
- }
- var currency = new Currency();
- return currency.numberFormat(number, rounding, decimalSeparator, thousandSeparator, false)
- }
- function gformToNumber(text) {
- var currency = new Currency(gf_global.gf_currency_config);
- return currency.toNumber(text);
- }
- function getMatchGroups(expr, patt) {
- var matches = new Array();
- while(patt.test(expr)) {
- var i = matches.length;
- matches[i] = patt.exec(expr)
- expr = expr.replace('' + matches[i][0], '');
- }
- return matches;
- }
- function gf_get_field_number_format(fieldId, formId, context) {
- var fieldNumberFormats = rgars(window, 'gf_global/number_formats/{0}/{1}'.format(formId, fieldId)),
- format = false;
- if (fieldNumberFormats === '') {
- return format;
- }
- if (typeof context == 'undefined') {
- format = fieldNumberFormats.price !== false ? fieldNumberFormats.price : fieldNumberFormats.value;
- } else {
- format = fieldNumberFormats[context];
- }
- return format;
- }
- //----------------------------------------
- //------ JAVASCRIPT HOOK FUNCTIONS -------
- //----------------------------------------
- var gform = {
- hooks: { action: {}, filter: {} },
- addAction: function( action, callable, priority, tag ) {
- gform.addHook( 'action', action, callable, priority, tag );
- },
- addFilter: function( action, callable, priority, tag ) {
- gform.addHook( 'filter', action, callable, priority, tag );
- },
- doAction: function( action ) {
- gform.doHook( 'action', action, arguments );
- },
- applyFilters: function( action ) {
- return gform.doHook( 'filter', action, arguments );
- },
- removeAction: function( action, tag ) {
- gform.removeHook( 'action', action, tag );
- },
- removeFilter: function( action, priority, tag ) {
- gform.removeHook( 'filter', action, priority, tag );
- },
- addHook: function( hookType, action, callable, priority, tag ) {
- if ( undefined == gform.hooks[hookType][action] ) {
- gform.hooks[hookType][action] = [];
- }
- var hooks = gform.hooks[hookType][action];
- if ( undefined == tag ) {
- tag = action + '_' + hooks.length;
- }
- if( priority == undefined ){
- priority = 10;
- }
- gform.hooks[hookType][action].push( { tag:tag, callable:callable, priority:priority } );
- },
- doHook: function( hookType, action, args ) {
- // splice args from object into array and remove first index which is the hook name
- args = Array.prototype.slice.call(args, 1);
- if ( undefined != gform.hooks[hookType][action] ) {
- var hooks = gform.hooks[hookType][action], hook;
- //sort by priority
- hooks.sort(function(a,b){return a["priority"]-b["priority"]});
- for( var i=0; i<hooks.length; i++) {
- hook = hooks[i].callable;
- if(typeof hook != 'function')
- hook = window[hook];
- if ( 'action' == hookType ) {
- hook.apply(null, args);
- } else {
- args[0] = hook.apply(null, args);
- }
- }
- }
- if ( 'filter'==hookType ) {
- return args[0];
- }
- },
- removeHook: function( hookType, action, priority, tag ) {
- if ( undefined != gform.hooks[hookType][action] ) {
- var hooks = gform.hooks[hookType][action];
- for( var i=hooks.length-1; i>=0; i--) {
- if ((undefined==tag||tag==hooks[i].tag) && (undefined==priority||priority==hooks[i].priority)){
- hooks.splice(i,1);
- }
- }
- }
- }
- };
- //----------------------------------------
- //------ reCAPTCHA FUNCTIONS -------------
- //----------------------------------------
- /**
- * Callback function on the reCAPTCAH API script.
- *
- * @see GF_Field_CAPTCHA::get_field_input() in /includes/fields/class-gf-field-catpcha.php
- */
- function renderRecaptcha() {
- jQuery( '.ginput_recaptcha' ).each( function() {
- var $elem = jQuery( this ),
- parameters = {
- 'sitekey': $elem.data( 'sitekey' ),
- 'theme': $elem.data( 'theme' )
- };
- if( $elem.data( 'stoken' ) ) {
- parameters.stoken = $elem.data( 'stoken' );
- }
- grecaptcha.render( this.id, parameters );
- } );
- }
- //----------------------------------------
- //------ MULTIFILE UPLOAD FUNCTIONS ------
- //----------------------------------------
- (function (gfMultiFileUploader, $) {
- gfMultiFileUploader.uploaders = {};
- var strings = typeof gform_gravityforms != 'undefined' ? gform_gravityforms.strings : {};
- var imagesUrl = typeof gform_gravityforms != 'undefined' ? gform_gravityforms.vars.images_url : "";
- $(document).bind('gform_post_render', function(e, formID){
- $("form#gform_" + formID + " .gform_fileupload_multifile").each(function(){
- setup(this);
- });
- var $form = $("form#gform_" + formID);
- if($form.length > 0){
- $form.submit(function(){
- var pendingUploads = false;
- $.each(gfMultiFileUploader.uploaders, function(i, uploader){
- if(uploader.total.queued>0){
- pendingUploads = true;
- return false;
- }
- });
- if(pendingUploads){
- alert(strings.currently_uploading);
- window["gf_submitting_" + formID] = false;
- $('#gform_ajax_spinner_' + formID).remove();
- return false;
- }
- });
- }
- });
- $(document).bind("gform_post_conditional_logic", function(e,formID, fields, isInit){
- if(!isInit){
- $.each(gfMultiFileUploader.uploaders, function(i, uploader){
- uploader.refresh();
- });
- }
- });
- $(document).ready(function () {
- if((typeof adminpage !== 'undefined' && adminpage === 'toplevel_page_gf_edit_forms')|| typeof plupload == 'undefined'){
- $(".gform_button_select_files").prop("disabled", true);
- } else if (typeof adminpage !== 'undefined' && adminpage.indexOf('_page_gf_entries') > -1) {
- $(".gform_fileupload_multifile").each(function(){
- setup(this);
- });
- }
- });
- gfMultiFileUploader.setup = function (uploadElement){
- setup( uploadElement );
- };
- function setup(uploadElement){
- var settings = $(uploadElement).data('settings');
- var uploader = new plupload.Uploader(settings);
- formID = uploader.settings.multipart_params.form_id;
- gfMultiFileUploader.uploaders[settings.container] = uploader;
- var formID;
- var uniqueID;
- uploader.bind('Init', function(up, params) {
- if(!up.features.dragdrop)
- $(".gform_drop_instructions").hide();
- var fieldID = up.settings.multipart_params.field_id;
- var maxFiles = parseInt(up.settings.gf_vars.max_files);
- var initFileCount = countFiles(fieldID);
- if(maxFiles > 0 && initFileCount >= maxFiles){
- gfMultiFileUploader.toggleDisabled(up.settings, true);
- }
- });
- gfMultiFileUploader.toggleDisabled = function (settings, disabled){
- var button = typeof settings.browse_button == "string" ? $("#" + settings.browse_button) : $(settings.browse_button);
- button.prop("disabled", disabled);
- };
- function addMessage(messagesID, message){
- $("#" + messagesID).prepend("<li>" + message + "</li>");
- }
- uploader.init();
- uploader.bind('FilesAdded', function(up, files) {
- var max = parseInt(up.settings.gf_vars.max_files),
- fieldID = up.settings.multipart_params.field_id,
- totalCount = countFiles(fieldID),
- disallowed = up.settings.gf_vars.disallowed_extensions,
- extension;
- if( max > 0 && totalCount >= max){
- $.each(files, function(i, file) {
- up.removeFile(file);
- return;
- });
- return;
- }
- $.each(files, function(i, file) {
- extension = file.name.split('.').pop();
- if($.inArray(extension, disallowed) > -1){
- addMessage(up.settings.gf_vars.message_id, file.name + " - " + strings.illegal_extension);
- up.removeFile(file);
- return;
- }
- if ((file.status == plupload.FAILED) || (max > 0 && totalCount >= max)){
- up.removeFile(file);
- return;
- }
- var size = typeof file.size !== 'undefined' ? plupload.formatSize(file.size) : strings.in_progress;
- var status = '<div id="'
- + file.id
- + '" class="ginput_preview">'
- + file.name
- + ' (' + size + ') <b></b> '
- + '<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>'
- + '</div>';
- $('#' + up.settings.filelist).prepend(status);
- totalCount++;
- });
- up.refresh(); // Reposition Flash
- var formElementID = "form#gform_" + formID;
- var uidElementID = "input:hidden[name='gform_unique_id']";
- var uidSelector = formElementID + " " + uidElementID;
- var $uid = $(uidSelector);
- if($uid.length==0){
- $uid = $(uidElementID);
- }
- uniqueID = $uid.val();
- if('' === uniqueID){
- uniqueID = generateUniqueID();
- $uid.val(uniqueID);
- }
- if(max > 0 && totalCount >= max){
- gfMultiFileUploader.toggleDisabled(up.settings, true);
- addMessage(up.settings.gf_vars.message_id, strings.max_reached)
- }
- up.settings.multipart_params.gform_unique_id = uniqueID;
- up.start();
- });
- uploader.bind('UploadProgress', function(up, file) {
- var html = file.percent + "%";
- $('#' + file.id + " b").html(html);
- });
- uploader.bind('Error', function(up, err) {
- if(err.code === plupload.FILE_EXTENSION_ERROR){
- var extensions = typeof up.settings.filters.mime_types != 'undefined' ? up.settings.filters.mime_types[0].extensions /* plupoad 2 */ : up.settings.filters[0].extensions;
- addMessage(up.settings.gf_vars.message_id, err.file.name + " - " + strings.invalid_file_extension + " " + extensions);
- } else if (err.code === plupload.FILE_SIZE_ERROR) {
- addMessage(up.settings.gf_vars.message_id, err.file.name + " - " + strings.file_exceeds_limit);
- } else {
- var m = "<li>Error: " + err.code +
- ", Message: " + err.message +
- (err.file ? ", File: " + err.file.name : "") +
- "</li>";
- addMessage(up.settings.gf_vars.message_id, m);
- }
- $('#' + err.file.id ).html('');
- up.refresh(); // Reposition Flash
- });
- uploader.bind('FileUploaded', function(up, file, result) {
- var response = $.secureEvalJSON(result.response);
- if(response.status == "error"){
- addMessage(up.settings.gf_vars.message_id, file.name + " - " + response.error.message);
- $('#' + file.id ).html('');
- return;
- }
- var html = '<strong>' + file.name + '</strong>';
- var formId = up.settings.multipart_params.form_id;
- var fieldId = up.settings.multipart_params.field_id;
- html = "<img "
- + "class='gform_delete' "
- + "src='" + imagesUrl + "/delete.png' "
- + "onclick='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);' "
- + "onkeypress='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);' "
- + "alt='"+ strings.delete_file + "' "
- + "title='" + strings.delete_file
- + "' /> "
- + html;
- html = gform.applyFilters( 'gform_file_upload_markup', html, file, up, strings, imagesUrl );
- $( '#' + file.id ).html( html );
- var fieldID = up.settings.multipart_params["field_id"];
- if(file.percent == 100){
- if(response.status && response.status == 'ok'){
- addFile(fieldID, response.data);
- } else {
- addMessage(up.settings.gf_vars.message_id, strings.unknown_error + ': ' + file.name);
- }
- }
- });
- function getAllFiles(){
- var selector = '#gform_uploaded_files_' + formID,
- $uploadedFiles = $(selector), files;
- files = $uploadedFiles.val();
- files = (typeof files === "undefined") || files === '' ? {} : $.parseJSON(files);
- return files;
- }
- function getFiles(fieldID){
- var allFiles = getAllFiles();
- var inputName = getInputName(fieldID);
- if(typeof allFiles[inputName] == 'undefined')
- allFiles[inputName] = [];
- return allFiles[inputName];
- }
- function countFiles(fieldID){
- var files = getFiles(fieldID);
- return files.length;
- }
- function addFile(fieldID, fileInfo){
- var files = getFiles(fieldID);
- files.unshift(fileInfo);
- setUploadedFiles(fieldID, files);
- }
- function setUploadedFiles(fieldID, files){
- var allFiles = getAllFiles();
- var $uploadedFiles = $('#gform_uploaded_files_' + formID);
- var inputName = getInputName(fieldID);
- allFiles[inputName] = files;
- $uploadedFiles.val($.toJSON(allFiles));
- }
- function getInputName(fieldID){
- return "input_" + fieldID;
- }
- // fixes drag and drop in IE10
- $("#" + settings.drop_element).on({
- "dragenter": ignoreDrag,
- "dragover": ignoreDrag
- });
- function ignoreDrag( e ) {
- e.preventDefault();
- }
- }
- function generateUniqueID() {
- return 'xxxxxxxx'.replace(/[xy]/g, function (c) {
- var r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8;
- return v.toString(16);
- });
- }
- }(window.gfMultiFileUploader = window.gfMultiFileUploader || {}, jQuery));
- //----------------------------------------
- //------ GENERAL FUNCTIONS -------
- //----------------------------------------
- function gformInitSpinner( formId, spinnerUrl ) {
- if( typeof spinnerUrl == 'undefined' || ! spinnerUrl ) {
- spinnerUrl = gform.applyFilters( "gform_spinner_url", gf_global.spinnerUrl, formId );
- }
- jQuery('#gform_' + formId).submit( function () {
- if ( jQuery('#gform_ajax_spinner_' + formId).length == 0 ) {
- /**
- * Filter the element after which the AJAX spinner will be inserted.
- *
- * @since 2.0
- *
- * @param object $targetElem jQuery object containing all of the elements after which the AJAX spinner will be inserted.
- * @param int formId ID of the current form.
- */
- 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 );
- $spinnerTarget.after( '<img id="gform_ajax_spinner_' + formId + '" class="gform_ajax_spinner" src="' + spinnerUrl + '" alt="" />' );
- }
- } );
- }
- //----------------------------------------
- //------ EVENT FUNCTIONS -----------------
- //----------------------------------------
- var __gf_keyup_timeout;
- jQuery( document ).on( 'change keyup', '.gfield_trigger_change input, .gfield_trigger_change select, .gfield_trigger_change textarea', function( event ) {
- gf_raw_input_change( event, this );
- } );
- function gf_raw_input_change( event, elem ) {
- // clear regardless of event type for maximum efficiency ;)
- clearTimeout( __gf_keyup_timeout );
- var $input = jQuery( elem ),
- htmlId = $input.attr( 'id' ),
- fieldId = gf_get_input_id_by_html_id( htmlId ),
- formId = gf_get_form_id_by_html_id( htmlId );
- if( ! fieldId ) {
- return;
- }
- var isChangeElem = $input.is( ':checkbox' ) || $input.is( ':radio' ) || $input.is( 'select' ),
- isKeyupElem = ! isChangeElem || $input.is( 'textarea' );
- if( event.type == 'keyup' && ! isKeyupElem ) {
- return;
- } else if( event.type == 'change' && ! isChangeElem && ! isKeyupElem ) {
- return;
- }
- if( event.type == 'keyup' ) {
- __gf_keyup_timeout = setTimeout( function() {
- gf_input_change( this, formId, fieldId );
- }, 300 );
- } else {
- gf_input_change( this, formId, fieldId );
- }
- }
- function gf_get_input_id_by_html_id( htmlId ) {
- var ids = gf_get_ids_by_html_id( htmlId ),
- id = ids[2];
- if( ids[3] ) {
- id += '.' + ids[3];
- }
- return id;
- }
- function gf_get_form_id_by_html_id( htmlId ) {
- var ids = gf_get_ids_by_html_id( htmlId ),
- id = ids[1];
- return id;
- }
- function gf_get_ids_by_html_id( htmlId ) {
- var ids = htmlId ? htmlId.split( '_' ) : false;
- return ids;
- }
- function gf_input_change( elem, formId, fieldId ) {
- gform.doAction( 'gform_input_change', elem, formId, fieldId );
- }
- function gformExtractFieldId( inputId ) {
- var fieldId = parseInt( inputId.toString().split( '.' )[0] );
- return ! fieldId ? inputId : fieldId;
- }
- function gformExtractInputIndex( inputId ) {
- var inputIndex = parseInt( inputId.toString().split( '.' )[1] );
- return ! inputIndex ? false : inputIndex;
- }
- //----------------------------------------
- //------ HELPER FUNCTIONS ----------------
- //----------------------------------------
- if( ! window['rgars'] ) {
- function rgars( array, prop ) {
- var props = prop.split( '/' ),
- value = array;
- for( var i = 0; i < props.length; i++ ) {
- value = rgar( value, props[ i ] );
- }
- return value;
- }
- }
- if( ! window['rgar'] ) {
- function rgar( array, prop ) {
- if ( typeof array[ prop ] != 'undefined' ) {
- return array[ prop ];
- }
- return '';
- }
- }
- String.prototype.format = function () {
- var args = arguments;
- return this.replace(/{(\d+)}/g, function (match, number) {
- return typeof args[number] != 'undefined' ? args[number] : match;
- });
- };
- /*============================================
- Stripe - Front-end
- ==============================================*/
- /**
- * Front-end Script
- */
- window.GFStripe = null;
- (function($){
- GFStripe = function( args ) {
- for( var prop in args ) {
- if( args.hasOwnProperty( prop ) )
- this[prop] = args[prop];
- }
- this.form = null;
- this.init = function() {
- if( ! this.isCreditCardOnPage() )
- return;
- var GFStripeObj = this;
- Stripe.setPublishableKey( this.apiKey );
- // initialize spinner
- if( ! this.isAjax )
- gformInitSpinner( this.formId );
- // bind Stripe functionality to submit event
- $( '#gform_' + this.formId ).submit( function( event ){
- if ( $(this).data('gfstripesubmitting') ) {
- return;
- } else {
- event.preventDefault();
- $(this).data('gfstripesubmitting', true);
- }
- var form = $(this),
- ccInputPrefix = 'input_' + GFStripeObj.formId + '_' + GFStripeObj.ccFieldId + '_',
- cc = {
- number: form.find( '#' + ccInputPrefix + '1' ).val(),
- exp_month: form.find( '#' + ccInputPrefix + '2_month' ).val(),
- exp_year: form.find( '#' + ccInputPrefix + '2_year' ).val(),
- cvc: form.find( '#' + ccInputPrefix + '3' ).val(),
- name: form.find( '#' + ccInputPrefix + '5').val()
- };
- GFStripeObj.form = form;
- Stripe.card.createToken( cc, function( status, response ) {
- GFStripeObj.responseHandler( status, response );
- } );
- } );
- };
- this.responseHandler = function( status, response ) {
- var form = this.form,
- ccInputPrefix = 'input_' + this.formId + '_' + this.ccFieldId + '_',
- ccInputSuffixes = [ '1', '2_month', '2_year', '3', '5' ],
- cardType = false;
- // remove "name" attribute from credit card inputs
- for( var i = 0; i < ccInputSuffixes.length; i++ ) {
- var input = form.find( '#' + ccInputPrefix + ccInputSuffixes[i] );
- if( ccInputSuffixes[i] == '1' ) {
- var ccNumber = $.trim( input.val() ),
- cardType = gformFindCardType( ccNumber );
- if( typeof this.cardLabels[cardType] != 'undefined' )
- cardType = this.cardLabels[cardType];
- form.append( $( '<input type="hidden" name="stripe_credit_card_last_four" />' ).val( ccNumber.slice( -4 ) ) );
- form.append( $( '<input type="hidden" name="stripe_credit_card_type" />' ).val( cardType ) );
- }
- input.attr( 'name', null );
- }
- // append stripe.js response
- form.append( $( '<input type="hidden" name="stripe_response" />' ).val( $.toJSON( response ) ) );
- // submit the form
- form.submit();
- }
- this.isLastPage = function() {
- var targetPageInput = $( '#gform_target_page_number_' + this.formId );
- if( targetPageInput.length > 0 )
- return targetPageInput.val() == 0;
- return true;
- }
- this.isCreditCardOnPage = function() {
- var currentPage = this.getCurrentPageNumber();
- // if current page is false or no credit card page number, assume this is not a multi-page form
- if( ! this.ccPage || ! currentPage )
- return true;
- return this.ccPage == currentPage;
- }
- this.getCurrentPageNumber = function() {
- var currentPageInput = $( '#gform_source_page_number_' + this.formId );
- return currentPageInput.length > 0 ? currentPageInput.val() : false;
- }
- this.init();
- }
- })(jQuery);
- /*============================================
- UI - Datepicker
- ==============================================*/
- jQuery(document).ready(gformInitDatepicker);
- function gformInitDatepicker(){
- jQuery('.datepicker').each(
- function (){
- var element = jQuery(this);
- var format = "mm/dd/yy";
- if(element.hasClass("mdy"))
- format = "mm/dd/yy";
- else if(element.hasClass("dmy"))
- format = "dd/mm/yy";
- else if(element.hasClass("dmy_dash"))
- format = "dd-mm-yy";
- else if(element.hasClass("dmy_dot"))
- format = "dd.mm.yy";
- else if(element.hasClass("ymd_slash"))
- format = "yy/mm/dd";
- else if(element.hasClass("ymd_dash"))
- format = "yy-mm-dd";
- else if(element.hasClass("ymd_dot"))
- format = "yy.mm.dd";
- var image = "";
- var showOn = "focus";
- if(element.hasClass("datepicker_with_icon")){
- showOn = "both";
- image = jQuery('#gforms_calendar_icon_' + this.id).val();
- }
- element.datepicker( {
- yearRange: '-0:+1',
- minDate: '+90',
- maxDate: '+18M',
- showOn: showOn,
- buttonImage: image,
- buttonImageOnly: true,
- dateFormat: format,
- changeMonth: true,
- changeYear: true,
- onClose: function () {
- element.closest('li').nextAll('li:visible:first').find(':input:first').focus();
- }
- } );
- }
- );
- }
- /*============================================
- Conditional Date
- ==============================================*/
- ;(function($) {
- "use strict";
- function setOptionsByDate()
- {
- $('.booked, .unbooked').each(function() {
- $(this).css('display', 'none');
- });
- var visiting = $('.book-date :input').val();
- if (!visiting) {
- return;
- }
- var visitdate = new Date(visiting);
- var today = new Date().setHours(0, 0, 0, 0);
- if (visitdate < today) {
- alert("Hmm... that date is already booked. " + "Please pick another date.");
- $('.visit-date :input').val('');
- return;
- }
- var month = visitdate.getMonth();
- if (month >= 5 && month <= 7) {
- $('.summer, .year-round').each(function() {
- $(this).css('display', '');
- });
- } else {
- $('.winter, .year-round').each(function() {
- $(this).css('display', '');
- });
- }
- }
- $(document).ready(function() {
- setOptionsByDate();
- $('.visit-date :input').change(function() {
- setOptionsByDate();
- });
- });
- }(jQuery, {}));
-
- /*============================================
- Conditional Logic
- ==============================================*/
- var __gf_timeout_handle;
- gform.addAction( 'gform_input_change', function( elem, formId, fieldId ) {
- var dependentFieldIds = rgars( gf_form_conditional_logic, [ formId, 'fields', gformExtractFieldId( fieldId ) ].join( '/' ) );
- if( dependentFieldIds ) {
- gf_apply_rules( formId, dependentFieldIds );
- }
- }, 10 );
- function gf_apply_rules(formId, fields, isInit){
- var rule_applied = 0;
- jQuery(document).trigger( 'gform_pre_conditional_logic', [ formId, fields, isInit ] );
- for(var i=0; i < fields.length; i++){
- gf_apply_field_rule(formId, fields[i], isInit, function(){
- rule_applied++;
- if(rule_applied == fields.length){
- jQuery(document).trigger('gform_post_conditional_logic', [formId, fields, isInit]);
- if(window["gformCalculateTotalPrice"])
- window["gformCalculateTotalPrice"](formId);
- }
- });
- }
- }
- function gf_check_field_rule(formId, fieldId, isInit, callback){
- //if conditional logic is not specified for that field, it is supposed to be displayed
- if(!window["gf_form_conditional_logic"] || !window["gf_form_conditional_logic"][formId] || !window["gf_form_conditional_logic"][formId]["logic"][fieldId])
- return "show";
- var conditionalLogic = window["gf_form_conditional_logic"][formId]["logic"][fieldId];
- var action = gf_get_field_action(formId, conditionalLogic["section"]);
- //If section is hidden, always hide field. If section is displayed, see if field is supposed to be displayed or hidden
- if(action != "hide")
- action = gf_get_field_action(formId, conditionalLogic["field"]);
- return action;
- }
- function gf_apply_field_rule(formId, fieldId, isInit, callback){
- var action = gf_check_field_rule(formId, fieldId, isInit, callback);
- gf_do_field_action(formId, action, fieldId, isInit, callback);
- var conditionalLogic = window["gf_form_conditional_logic"][formId]["logic"][fieldId];
- //perform conditional logic for the next button
- if(conditionalLogic["nextButton"]){
- action = gf_get_field_action(formId, conditionalLogic["nextButton"]);
- gf_do_next_button_action(formId, action, fieldId, isInit);
- }
- }
- function gf_get_field_action(formId, conditionalLogic){
- if(!conditionalLogic)
- return "show";
- var matches = 0;
- for(var i = 0; i < conditionalLogic["rules"].length; i++){
- var rule = conditionalLogic["rules"][i];
- if(gf_is_match(formId, rule))
- matches++;
- }
- var action;
- if( (conditionalLogic["logicType"] == "all" && matches == conditionalLogic["rules"].length) || (conditionalLogic["logicType"] == "any" && matches > 0) )
- action = conditionalLogic["actionType"];
- else
- action = conditionalLogic["actionType"] == "show" ? "hide" : "show";
- return action;
- }
- function gf_is_match( formId, rule ) {
- var $ = jQuery,
- inputId = rule['fieldId'],
- fieldId = gformExtractFieldId( inputId ),
- inputIndex = gformExtractInputIndex( inputId ),
- isInputSpecific = inputIndex !== false,
- $inputs;
- if( isInputSpecific ) {
- $inputs = $( '#input_{0}_{1}_{2}'.format( formId, fieldId, inputIndex ) );
- } else {
- $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 ) );
- }
- var isCheckable = $.inArray( $inputs.attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1,
- isMatch = isCheckable ? gf_is_match_checkable( $inputs, rule, formId, fieldId ) : gf_is_match_default( $inputs.eq( 0 ), rule, formId, fieldId );
- return gform.applyFilters( 'gform_is_value_match', isMatch, formId, rule );
- }
- function gf_is_match_checkable( $inputs, rule, formId, fieldId ) {
- var isMatch = false;
- $inputs.each( function() {
- var $input = jQuery( this ),
- fieldValue = gf_get_value( $input.val() ),
- isRangeOperator = jQuery.inArray( rule.operator, [ '<', '>' ] ) !== -1,
- isStringOperator = jQuery.inArray( rule.operator, [ 'contains', 'starts_with', 'ends_with' ] ) !== -1;
- // if we are looking for a specific value and this is not it, skip
- if( fieldValue != rule.value && ! isRangeOperator && ! isStringOperator ) {
- return; // continue
- }
- // force an empty value for unchecked items
- if( ! $input.is( ':checked' ) ) {
- fieldValue = '';
- }
- // if the 'other' choice is selected, get the value from the 'other' text input
- else if ( fieldValue == 'gf_other_choice' ) {
- fieldValue = $( '#input_{0}_{1}_other'.format( formId, fieldId ) ).val();
- }
- if( gf_matches_operation( fieldValue, rule.value, rule.operator ) ) {
- isMatch = true;
- return false; // break
- }
- } );
- return isMatch;
- }
- function gf_is_match_default( $input, rule, formId, fieldId ) {
- var val = $input.val(),
- values = ( val instanceof Array ) ? val : [ val ], // transform regular value into array to support multi-select (which returns an array of selected items)
- matchCount = 0;
- for( var i = 0; i < values.length; i++ ) {
- // fields with pipes in the value will use the label for conditional logic comparison
- var hasLabel = values[i] ? values[i].indexOf( '|' ) >= 0 : true,
- fieldValue = gf_get_value( values[i] );
- var fieldNumberFormat = gf_get_field_number_format( rule.fieldId, formId, 'value' );
- if( fieldNumberFormat && ! hasLabel ) {
- fieldValue = gf_format_number( fieldValue, fieldNumberFormat );
- }
- var ruleValue = rule.value;
- if ( fieldNumberFormat ) {
- ruleValue = gf_format_number( ruleValue, fieldNumberFormat );
- }
- if( gf_matches_operation( fieldValue, ruleValue, rule.operator ) ) {
- matchCount++;
- }
- }
- // if operator is 'isnot', none of the values can match
- var isMatch = rule.operator == 'isnot' ? matchCount == values.length : matchCount > 0;
- return isMatch;
- }
- function gf_format_number( value, fieldNumberFormat ) {
- decimalSeparator = '.';
- if( fieldNumberFormat == 'currency' ) {
- decimalSeparator = gformGetDecimalSeparator( 'currency' );
- } else if( fieldNumberFormat == 'decimal_comma' ) {
- decimalSeparator = ',';
- } else if( fieldNumberFormat == 'decimal_dot' ) {
- decimalSeparator = '.';
- }
- // transform to a decimal dot number
- value = gformCleanNumber( value, '', '', decimalSeparator );
- /**
- * 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
- */
- // now transform to number specified by locale
- // if( window['gf_number_format'] && window['gf_number_format'] == 'decimal_comma' ) {
- // value = gformFormatNumber( value, -1, ',', '.' );
- // }
- if( ! value ) {
- value = 0;
- }
- number = value.toString();
- return number;
- }
- function gf_try_convert_float(text){
- /*
- * The only format that should matter is the field format. Attempting to do this by WP locale creates a lot of issues with consistency.
- * var format = window["gf_number_format"] == "decimal_comma" ? "decimal_comma" : "decimal_dot";
- */
- var format = 'decimal_dot';
- if( gformIsNumeric( text, format ) ) {
- var decimal_separator = format == "decimal_comma" ? "," : ".";
- return gformCleanNumber( text, "", "", decimal_separator );
- }
- return text;
- }
- function gf_matches_operation(val1, val2, operation){
- val1 = val1 ? val1.toLowerCase() : "";
- val2 = val2 ? val2.toLowerCase() : "";
- switch(operation){
- case "is" :
- return val1 == val2;
- break;
- case "isnot" :
- return val1 != val2;
- break;
- case ">" :
- val1 = gf_try_convert_float(val1);
- val2 = gf_try_convert_float(val2);
- return gformIsNumber(val1) && gformIsNumber(val2) ? val1 > val2 : false;
- break;
- case "<" :
- val1 = gf_try_convert_float(val1);
- val2 = gf_try_convert_float(val2);
- return gformIsNumber(val1) && gformIsNumber(val2) ? val1 < val2 : false;
- break;
- case "contains" :
- return val1.indexOf(val2) >=0;
- break;
- case "starts_with" :
- return val1.indexOf(val2) ==0;
- break;
- case "ends_with" :
- var start = val1.length - val2.length;
- if(start < 0)
- return false;
- var tail = val1.substring(start);
- return val2 == tail;
- break;
- }
- return false;
- }
- function gf_get_value(val){
- if(!val)
- return "";
- val = val.split("|");
- return val[0];
- }
- function gf_do_field_action(formId, action, fieldId, isInit, callback){
- var conditional_logic = window["gf_form_conditional_logic"][formId];
- var dependent_fields = conditional_logic["dependents"][fieldId];
- for(var i=0; i < dependent_fields.length; i++){
- var targetId = fieldId == 0 ? "#gform_submit_button_" + formId : "#field_" + formId + "_" + dependent_fields[i];
- var defaultValues = conditional_logic["defaults"][dependent_fields[i]];
- //calling callback function on the last dependent field, to make sure it is only called once
- do_callback = (i+1) == dependent_fields.length ? callback : null;
- gf_do_action(action, targetId, conditional_logic["animation"], defaultValues, isInit, do_callback);
- gform.doAction('gform_post_conditional_logic_field_action', formId, action, targetId, defaultValues, isInit);
- }
- }
- function gf_do_next_button_action(formId, action, fieldId, isInit){
- var conditional_logic = window["gf_form_conditional_logic"][formId];
- var targetId = "#gform_next_button_" + formId + "_" + fieldId;
- gf_do_action(action, targetId, conditional_logic["animation"], null, isInit);
- }
- function gf_do_action(action, targetId, useAnimation, defaultValues, isInit, callback){
- var $target = jQuery(targetId);
- if(action == "show"){
- // reset tabindex for selects
- $target.find( 'select' ).each( function() {
- $select = jQuery( this );
- $select.attr( 'tabindex', $select.data( 'tabindex' ) );
- } );
- if(useAnimation && !isInit){
- if($target.length > 0){
- $target.slideDown(callback);
- } else if(callback){
- callback();
- }
- }
- else{
- var display = $target.data('gf_display');
- //defaults to list-item if previous (saved) display isn't set for any reason
- if ( display == '' || display == 'none' ){
- display = 'list-item';
- }
- $target.css('display', display);
- if(callback){
- callback();
- }
- }
- }
- else{
- //if field is not already hidden, reset its values to the default
- var child = $target.children().first();
- if (child.length > 0){
- if(!gformIsHidden(child)){
- gf_reset_to_default(targetId, defaultValues);
- }
- }
- // remove tabindex and stash as a data attr for selects
- $target.find( 'select' ).each( function() {
- $select = jQuery( this );
- $select.data( 'tabindex', $select.attr( 'tabindex' ) ).removeAttr( 'tabindex' );
- } );
- //Saving existing display so that it can be reset when showing the field
- if( ! $target.data('gf_display') ){
- $target.data('gf_display', $target.css('display'));
- }
- if(useAnimation && !isInit){
- if($target.length > 0 && $target.is(":visible")) {
- $target.slideUp(callback);
- } else if(callback) {
- callback();
- }
- } else{
- $target.hide();
- if(callback){
- callback();
- }
- }
- }
- }
- function gf_reset_to_default(targetId, defaultValue){
- 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' );
- if( dateFields.length > 0 ) {
- dateFields.each( function(){
- var element = jQuery( this );
- // defaultValue is associative array (i.e. [ m: 1, d: 13, y: 1987 ] )
- if( defaultValue ) {
- var key = 'd';
- if (element.parents().hasClass('gfield_date_month') || element.parents().hasClass('gfield_date_dropdown_month') ){
- key = 'm';
- }
- else if(element.parents().hasClass('gfield_date_year') || element.parents().hasClass('gfield_date_dropdown_year') ){
- key = 'y';
- }
- val = defaultValue[ key ];
- }
- else{
- val = "";
- }
- if(element.prop("tagName") == "SELECT" && val != '' )
- val = parseInt(val);
- if(element.val() != val)
- element.val(val).trigger("change");
- else
- element.val(val);
- });
- return;
- }
- //cascading down conditional logic to children to suppport nested conditions
- //text fields and drop downs, filter out list field text fields name with "_shim"
- var target = jQuery(targetId).find('select, input[type="text"]:not([id*="_shim"]), input[type="number"], textarea');
- var target_index = 0;
- target.each(function(){
- var val = "";
- var element = jQuery(this);
- //get name of previous input field to see if it is the radio button which goes with the "Other" text box
- //otherwise field is populated with input field name
- var radio_button_name = element.prev("input").attr("value");
- if(radio_button_name == "gf_other_choice"){
- val = element.attr("value");
- }
- else if(jQuery.isArray(defaultValue)){
- val = defaultValue[target_index];
- }
- else if(jQuery.isPlainObject(defaultValue)){
- val = defaultValue[element.attr("name")];
- if( ! val ) {
- // 'input_123_3_1' => '3.1'
- var inputId = element.attr( 'id' ).split( '_' ).slice( 2 ).join( '.' );
- val = defaultValue[ inputId ];
- }
- }
- else if(defaultValue){
- val = defaultValue;
- }
- if( element.is('select:not([multiple])') && ! val ) {
- val = element.find( 'option' ).not( ':disabled' ).eq(0).val();
- }
- if(element.val() != val) {
- element.val(val).trigger('change');
- if (element.is('select') && element.next().hasClass('chosen-container')) {
- element.trigger('chosen:updated');
- }
- }
- else{
- element.val(val);
- }
- target_index++;
- });
- //checkboxes and radio buttons
- var elements = jQuery(targetId).find('input[type="radio"], input[type="checkbox"]:not(".copy_values_activated")');
- elements.each(function(){
- //is input currently checked?
- var isChecked = jQuery(this).is(':checked') ? true : false;
- //does input need to be marked as checked or unchecked?
- var doCheck = defaultValue ? jQuery.inArray(jQuery(this).attr('id'), defaultValue) > -1 : false;
- //if value changed, trigger click event
- if(isChecked != doCheck){
- //setting input as checked or unchecked appropriately
- if(jQuery(this).attr("type") == "checkbox"){
- jQuery(this).trigger('click');
- }
- else{
- jQuery(this).prop("checked", doCheck);
- //need to set the prop again after the click is triggered
- jQuery(this).trigger('click').prop('checked', doCheck);
- }
- }
- });
- }
- /*============================================
- Date-Picker
- ==============================================*/
- jQuery(document).ready(gformInitDatepicker);
- function gformInitDatepicker() {
- jQuery('.datepicker').each(function () {
- var element = jQuery(this),
- inputId = this.id,
- optionsObj = {
- yearRange: '-100:+20',
- showOn: 'focus',
- dateFormat: 'mm/dd/yy',
- changeMonth: true,
- changeYear: true,
- suppressDatePicker: false,
- onClose: function () {
- element.focus();
- var self = this;
- this.suppressDatePicker = true;
- setTimeout( function() {
- self.suppressDatePicker = false;
- }, 200 );
- },
- beforeShow: function( input, inst ) {
- return ! this.suppressDatePicker;
- }
- };
- if (element.hasClass('dmy')) {
- optionsObj.dateFormat = 'dd/mm/yy';
- } else if (element.hasClass('dmy_dash')) {
- optionsObj.dateFormat = 'dd-mm-yy';
- } else if (element.hasClass('dmy_dot')) {
- optionsObj.dateFormat = 'dd.mm.yy';
- } else if (element.hasClass('ymd_slash')) {
- optionsObj.dateFormat = 'yy/mm/dd';
- } else if (element.hasClass('ymd_dash')) {
- optionsObj.dateFormat = 'yy-mm-dd';
- } else if (element.hasClass('ymd_dot')) {
- optionsObj.dateFormat = 'yy.mm.dd';
- }
- if (element.hasClass('datepicker_with_icon')) {
- optionsObj.showOn = 'both';
- optionsObj.buttonImage = jQuery('#gforms_calendar_icon_' + inputId).val();
- optionsObj.buttonImageOnly = true;
- }
- inputId = inputId.split('_');
- // allow the user to override the datepicker options object
- optionsObj = gform.applyFilters('gform_datepicker_options_pre_init', optionsObj, inputId[1], inputId[2]);
- element.datepicker(optionsObj);
- });
- }
|