foundation.js 212 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581
  1. /*
  2. * Foundation Responsive Library
  3. * http://foundation.zurb.com
  4. * Copyright 2015, ZURB
  5. * Free to use under the MIT license.
  6. * http://www.opensource.org/licenses/mit-license.php
  7. */
  8. (function ($, window, document, undefined) {
  9. 'use strict';
  10. var header_helpers = function (class_array) {
  11. var head = $('head');
  12. head.prepend($.map(class_array, function (class_name) {
  13. if (head.has('.' + class_name).length === 0) {
  14. return '<meta class="' + class_name + '" />';
  15. }
  16. }));
  17. };
  18. header_helpers([
  19. 'foundation-mq-small',
  20. 'foundation-mq-small-only',
  21. 'foundation-mq-medium',
  22. 'foundation-mq-medium-only',
  23. 'foundation-mq-large',
  24. 'foundation-mq-large-only',
  25. 'foundation-mq-xlarge',
  26. 'foundation-mq-xlarge-only',
  27. 'foundation-mq-xxlarge',
  28. 'foundation-data-attribute-namespace']);
  29. // Enable FastClick if present
  30. $(function () {
  31. if (typeof FastClick !== 'undefined') {
  32. // Don't attach to body if undefined
  33. if (typeof document.body !== 'undefined') {
  34. FastClick.attach(document.body);
  35. }
  36. }
  37. });
  38. // private Fast Selector wrapper,
  39. // returns jQuery object. Only use where
  40. // getElementById is not available.
  41. var S = function (selector, context) {
  42. if (typeof selector === 'string') {
  43. if (context) {
  44. var cont;
  45. if (context.jquery) {
  46. cont = context[0];
  47. if (!cont) {
  48. return context;
  49. }
  50. } else {
  51. cont = context;
  52. }
  53. return $(cont.querySelectorAll(selector));
  54. }
  55. return $(document.querySelectorAll(selector));
  56. }
  57. return $(selector, context);
  58. };
  59. // Namespace functions.
  60. var attr_name = function (init) {
  61. var arr = [];
  62. if (!init) {
  63. arr.push('data');
  64. }
  65. if (this.namespace.length > 0) {
  66. arr.push(this.namespace);
  67. }
  68. arr.push(this.name);
  69. return arr.join('-');
  70. };
  71. var add_namespace = function (str) {
  72. var parts = str.split('-'),
  73. i = parts.length,
  74. arr = [];
  75. while (i--) {
  76. if (i !== 0) {
  77. arr.push(parts[i]);
  78. } else {
  79. if (this.namespace.length > 0) {
  80. arr.push(this.namespace, parts[i]);
  81. } else {
  82. arr.push(parts[i]);
  83. }
  84. }
  85. }
  86. return arr.reverse().join('-');
  87. };
  88. // Event binding and data-options updating.
  89. var bindings = function (method, options) {
  90. var self = this,
  91. bind = function(){
  92. var $this = S(this),
  93. should_bind_events = !$this.data(self.attr_name(true) + '-init');
  94. $this.data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options($this)));
  95. if (should_bind_events) {
  96. self.events(this);
  97. }
  98. };
  99. if (S(this.scope).is('[' + this.attr_name() +']')) {
  100. bind.call(this.scope);
  101. } else {
  102. S('[' + this.attr_name() +']', this.scope).each(bind);
  103. }
  104. // # Patch to fix #5043 to move this *after* the if/else clause in order for Backbone and similar frameworks to have improved control over event binding and data-options updating.
  105. if (typeof method === 'string') {
  106. return this[method].call(this, options);
  107. }
  108. };
  109. var single_image_loaded = function (image, callback) {
  110. function loaded () {
  111. callback(image[0]);
  112. }
  113. function bindLoad () {
  114. this.one('load', loaded);
  115. if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
  116. var src = this.attr( 'src' ),
  117. param = src.match( /\?/ ) ? '&' : '?';
  118. param += 'random=' + (new Date()).getTime();
  119. this.attr('src', src + param);
  120. }
  121. }
  122. if (!image.attr('src')) {
  123. loaded();
  124. return;
  125. }
  126. if (image[0].complete || image[0].readyState === 4) {
  127. loaded();
  128. } else {
  129. bindLoad.call(image);
  130. }
  131. };
  132. /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */
  133. window.matchMedia || (window.matchMedia = function() {
  134. "use strict";
  135. // For browsers that support matchMedium api such as IE 9 and webkit
  136. var styleMedia = (window.styleMedia || window.media);
  137. // For those that don't support matchMedium
  138. if (!styleMedia) {
  139. var style = document.createElement('style'),
  140. script = document.getElementsByTagName('script')[0],
  141. info = null;
  142. style.type = 'text/css';
  143. style.id = 'matchmediajs-test';
  144. script.parentNode.insertBefore(style, script);
  145. // 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers
  146. info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle;
  147. styleMedia = {
  148. matchMedium: function(media) {
  149. var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }';
  150. // 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers
  151. if (style.styleSheet) {
  152. style.styleSheet.cssText = text;
  153. } else {
  154. style.textContent = text;
  155. }
  156. // Test if media query is true or false
  157. return info.width === '1px';
  158. }
  159. };
  160. }
  161. return function(media) {
  162. return {
  163. matches: styleMedia.matchMedium(media || 'all'),
  164. media: media || 'all'
  165. };
  166. };
  167. }());
  168. /*
  169. * jquery.requestAnimationFrame
  170. * https://github.com/gnarf37/jquery-requestAnimationFrame
  171. * Requires jQuery 1.8+
  172. *
  173. * Copyright (c) 2012 Corey Frang
  174. * Licensed under the MIT license.
  175. */
  176. (function(jQuery) {
  177. // requestAnimationFrame polyfill adapted from Erik Möller
  178. // fixes from Paul Irish and Tino Zijdel
  179. // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
  180. // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
  181. var animating,
  182. lastTime = 0,
  183. vendors = ['webkit', 'moz'],
  184. requestAnimationFrame = window.requestAnimationFrame,
  185. cancelAnimationFrame = window.cancelAnimationFrame,
  186. jqueryFxAvailable = 'undefined' !== typeof jQuery.fx;
  187. for (; lastTime < vendors.length && !requestAnimationFrame; lastTime++) {
  188. requestAnimationFrame = window[ vendors[lastTime] + 'RequestAnimationFrame' ];
  189. cancelAnimationFrame = cancelAnimationFrame ||
  190. window[ vendors[lastTime] + 'CancelAnimationFrame' ] ||
  191. window[ vendors[lastTime] + 'CancelRequestAnimationFrame' ];
  192. }
  193. function raf() {
  194. if (animating) {
  195. requestAnimationFrame(raf);
  196. if (jqueryFxAvailable) {
  197. jQuery.fx.tick();
  198. }
  199. }
  200. }
  201. if (requestAnimationFrame) {
  202. // use rAF
  203. window.requestAnimationFrame = requestAnimationFrame;
  204. window.cancelAnimationFrame = cancelAnimationFrame;
  205. if (jqueryFxAvailable) {
  206. jQuery.fx.timer = function (timer) {
  207. if (timer() && jQuery.timers.push(timer) && !animating) {
  208. animating = true;
  209. raf();
  210. }
  211. };
  212. jQuery.fx.stop = function () {
  213. animating = false;
  214. };
  215. }
  216. } else {
  217. // polyfill
  218. window.requestAnimationFrame = function (callback) {
  219. var currTime = new Date().getTime(),
  220. timeToCall = Math.max(0, 16 - (currTime - lastTime)),
  221. id = window.setTimeout(function () {
  222. callback(currTime + timeToCall);
  223. }, timeToCall);
  224. lastTime = currTime + timeToCall;
  225. return id;
  226. };
  227. window.cancelAnimationFrame = function (id) {
  228. clearTimeout(id);
  229. };
  230. }
  231. }( $ ));
  232. function removeQuotes (string) {
  233. if (typeof string === 'string' || string instanceof String) {
  234. string = string.replace(/^['\\/"]+|(;\s?})+|['\\/"]+$/g, '');
  235. }
  236. return string;
  237. }
  238. function MediaQuery(selector) {
  239. this.selector = selector;
  240. this.query = '';
  241. }
  242. MediaQuery.prototype.toString = function () {
  243. return this.query || (this.query = S(this.selector).css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''));
  244. };
  245. window.Foundation = {
  246. name : 'Foundation',
  247. version : '5.5.3',
  248. media_queries : {
  249. 'small' : new MediaQuery('.foundation-mq-small'),
  250. 'small-only' : new MediaQuery('.foundation-mq-small-only'),
  251. 'medium' : new MediaQuery('.foundation-mq-medium'),
  252. 'medium-only' : new MediaQuery('.foundation-mq-medium-only'),
  253. 'large' : new MediaQuery('.foundation-mq-large'),
  254. 'large-only' : new MediaQuery('.foundation-mq-large-only'),
  255. 'xlarge' : new MediaQuery('.foundation-mq-xlarge'),
  256. 'xlarge-only' : new MediaQuery('.foundation-mq-xlarge-only'),
  257. 'xxlarge' : new MediaQuery('.foundation-mq-xxlarge')
  258. },
  259. stylesheet : $('<style></style>').appendTo('head')[0].sheet,
  260. global : {
  261. namespace : undefined
  262. },
  263. init : function (scope, libraries, method, options, response) {
  264. var args = [scope, method, options, response],
  265. responses = [];
  266. // check RTL
  267. this.rtl = /rtl/i.test(S('html').attr('dir'));
  268. // set foundation global scope
  269. this.scope = scope || this.scope;
  270. this.set_namespace();
  271. if (libraries && typeof libraries === 'string' && !/reflow/i.test(libraries)) {
  272. if (this.libs.hasOwnProperty(libraries)) {
  273. responses.push(this.init_lib(libraries, args));
  274. }
  275. } else {
  276. for (var lib in this.libs) {
  277. responses.push(this.init_lib(lib, libraries));
  278. }
  279. }
  280. S(window).load(function () {
  281. S(window)
  282. .trigger('resize.fndtn.clearing')
  283. .trigger('resize.fndtn.dropdown')
  284. .trigger('resize.fndtn.equalizer')
  285. .trigger('resize.fndtn.interchange')
  286. .trigger('resize.fndtn.joyride')
  287. .trigger('resize.fndtn.magellan')
  288. .trigger('resize.fndtn.topbar')
  289. .trigger('resize.fndtn.slider');
  290. });
  291. return scope;
  292. },
  293. init_lib : function (lib, args) {
  294. if (this.libs.hasOwnProperty(lib)) {
  295. this.patch(this.libs[lib]);
  296. if (args && args.hasOwnProperty(lib)) {
  297. if (typeof this.libs[lib].settings !== 'undefined') {
  298. $.extend(true, this.libs[lib].settings, args[lib]);
  299. } else if (typeof this.libs[lib].defaults !== 'undefined') {
  300. $.extend(true, this.libs[lib].defaults, args[lib]);
  301. }
  302. return this.libs[lib].init.apply(this.libs[lib], [this.scope, args[lib]]);
  303. }
  304. args = args instanceof Array ? args : new Array(args);
  305. return this.libs[lib].init.apply(this.libs[lib], args);
  306. }
  307. return function () {};
  308. },
  309. patch : function (lib) {
  310. lib.scope = this.scope;
  311. lib.namespace = this.global.namespace;
  312. lib.rtl = this.rtl;
  313. lib['data_options'] = this.utils.data_options;
  314. lib['attr_name'] = attr_name;
  315. lib['add_namespace'] = add_namespace;
  316. lib['bindings'] = bindings;
  317. lib['S'] = this.utils.S;
  318. },
  319. inherit : function (scope, methods) {
  320. var methods_arr = methods.split(' '),
  321. i = methods_arr.length;
  322. while (i--) {
  323. if (this.utils.hasOwnProperty(methods_arr[i])) {
  324. scope[methods_arr[i]] = this.utils[methods_arr[i]];
  325. }
  326. }
  327. },
  328. set_namespace : function () {
  329. // Description:
  330. // Don't bother reading the namespace out of the meta tag
  331. // if the namespace has been set globally in javascript
  332. //
  333. // Example:
  334. // Foundation.global.namespace = 'my-namespace';
  335. // or make it an empty string:
  336. // Foundation.global.namespace = '';
  337. //
  338. //
  339. // If the namespace has not been set (is undefined), try to read it out of the meta element.
  340. // Otherwise use the globally defined namespace, even if it's empty ('')
  341. var namespace = ( this.global.namespace === undefined ) ? $('.foundation-data-attribute-namespace').css('font-family') : this.global.namespace;
  342. // Finally, if the namsepace is either undefined or false, set it to an empty string.
  343. // Otherwise use the namespace value.
  344. this.global.namespace = ( namespace === undefined || /false/i.test(namespace) ) ? '' : namespace;
  345. },
  346. libs : {},
  347. // methods that can be inherited in libraries
  348. utils : {
  349. // Description:
  350. // Fast Selector wrapper returns jQuery object. Only use where getElementById
  351. // is not available.
  352. //
  353. // Arguments:
  354. // Selector (String): CSS selector describing the element(s) to be
  355. // returned as a jQuery object.
  356. //
  357. // Scope (String): CSS selector describing the area to be searched. Default
  358. // is document.
  359. //
  360. // Returns:
  361. // Element (jQuery Object): jQuery object containing elements matching the
  362. // selector within the scope.
  363. S : S,
  364. // Description:
  365. // Executes a function a max of once every n milliseconds
  366. //
  367. // Arguments:
  368. // Func (Function): Function to be throttled.
  369. //
  370. // Delay (Integer): Function execution threshold in milliseconds.
  371. //
  372. // Returns:
  373. // Lazy_function (Function): Function with throttling applied.
  374. throttle : function (func, delay) {
  375. var timer = null;
  376. return function () {
  377. var context = this, args = arguments;
  378. if (timer == null) {
  379. timer = setTimeout(function () {
  380. func.apply(context, args);
  381. timer = null;
  382. }, delay);
  383. }
  384. };
  385. },
  386. // Description:
  387. // Executes a function when it stops being invoked for n seconds
  388. // Modified version of _.debounce() http://underscorejs.org
  389. //
  390. // Arguments:
  391. // Func (Function): Function to be debounced.
  392. //
  393. // Delay (Integer): Function execution threshold in milliseconds.
  394. //
  395. // Immediate (Bool): Whether the function should be called at the beginning
  396. // of the delay instead of the end. Default is false.
  397. //
  398. // Returns:
  399. // Lazy_function (Function): Function with debouncing applied.
  400. debounce : function (func, delay, immediate) {
  401. var timeout, result;
  402. return function () {
  403. var context = this, args = arguments;
  404. var later = function () {
  405. timeout = null;
  406. if (!immediate) {
  407. result = func.apply(context, args);
  408. }
  409. };
  410. var callNow = immediate && !timeout;
  411. clearTimeout(timeout);
  412. timeout = setTimeout(later, delay);
  413. if (callNow) {
  414. result = func.apply(context, args);
  415. }
  416. return result;
  417. };
  418. },
  419. // Description:
  420. // Parses data-options attribute
  421. //
  422. // Arguments:
  423. // El (jQuery Object): Element to be parsed.
  424. //
  425. // Returns:
  426. // Options (Javascript Object): Contents of the element's data-options
  427. // attribute.
  428. data_options : function (el, data_attr_name) {
  429. data_attr_name = data_attr_name || 'options';
  430. var opts = {}, ii, p, opts_arr,
  431. data_options = function (el) {
  432. var namespace = Foundation.global.namespace;
  433. if (namespace.length > 0) {
  434. return el.data(namespace + '-' + data_attr_name);
  435. }
  436. return el.data(data_attr_name);
  437. };
  438. var cached_options = data_options(el);
  439. if (typeof cached_options === 'object') {
  440. return cached_options;
  441. }
  442. opts_arr = (cached_options || ':').split(';');
  443. ii = opts_arr.length;
  444. function isNumber (o) {
  445. return !isNaN (o - 0) && o !== null && o !== '' && o !== false && o !== true;
  446. }
  447. function trim (str) {
  448. if (typeof str === 'string') {
  449. return $.trim(str);
  450. }
  451. return str;
  452. }
  453. while (ii--) {
  454. p = opts_arr[ii].split(':');
  455. p = [p[0], p.slice(1).join(':')];
  456. if (/true/i.test(p[1])) {
  457. p[1] = true;
  458. }
  459. if (/false/i.test(p[1])) {
  460. p[1] = false;
  461. }
  462. if (isNumber(p[1])) {
  463. if (p[1].indexOf('.') === -1) {
  464. p[1] = parseInt(p[1], 10);
  465. } else {
  466. p[1] = parseFloat(p[1]);
  467. }
  468. }
  469. if (p.length === 2 && p[0].length > 0) {
  470. opts[trim(p[0])] = trim(p[1]);
  471. }
  472. }
  473. return opts;
  474. },
  475. // Description:
  476. // Adds JS-recognizable media queries
  477. //
  478. // Arguments:
  479. // Media (String): Key string for the media query to be stored as in
  480. // Foundation.media_queries
  481. //
  482. // Class (String): Class name for the generated <meta> tag
  483. register_media : function (media, media_class) {
  484. if (Foundation.media_queries[media] === undefined) {
  485. $('head').append('<meta class="' + media_class + '"/>');
  486. Foundation.media_queries[media] = removeQuotes($('.' + media_class).css('font-family'));
  487. }
  488. },
  489. // Description:
  490. // Add custom CSS within a JS-defined media query
  491. //
  492. // Arguments:
  493. // Rule (String): CSS rule to be appended to the document.
  494. //
  495. // Media (String): Optional media query string for the CSS rule to be
  496. // nested under.
  497. add_custom_rule : function (rule, media) {
  498. if (media === undefined && Foundation.stylesheet) {
  499. Foundation.stylesheet.insertRule(rule, Foundation.stylesheet.cssRules.length);
  500. } else {
  501. var query = Foundation.media_queries[media];
  502. if (query !== undefined) {
  503. Foundation.stylesheet.insertRule('@media ' +
  504. Foundation.media_queries[media] + '{ ' + rule + ' }', Foundation.stylesheet.cssRules.length);
  505. }
  506. }
  507. },
  508. // Description:
  509. // Performs a callback function when an image is fully loaded
  510. //
  511. // Arguments:
  512. // Image (jQuery Object): Image(s) to check if loaded.
  513. //
  514. // Callback (Function): Function to execute when image is fully loaded.
  515. image_loaded : function (images, callback) {
  516. var self = this,
  517. unloaded = images.length;
  518. function pictures_has_height(images) {
  519. var pictures_number = images.length;
  520. for (var i = pictures_number - 1; i >= 0; i--) {
  521. if(images.attr('height') === undefined) {
  522. return false;
  523. };
  524. };
  525. return true;
  526. }
  527. if (unloaded === 0 || pictures_has_height(images)) {
  528. callback(images);
  529. }
  530. images.each(function () {
  531. single_image_loaded(self.S(this), function () {
  532. unloaded -= 1;
  533. if (unloaded === 0) {
  534. callback(images);
  535. }
  536. });
  537. });
  538. },
  539. // Description:
  540. // Returns a random, alphanumeric string
  541. //
  542. // Arguments:
  543. // Length (Integer): Length of string to be generated. Defaults to random
  544. // integer.
  545. //
  546. // Returns:
  547. // Rand (String): Pseudo-random, alphanumeric string.
  548. random_str : function () {
  549. if (!this.fidx) {
  550. this.fidx = 0;
  551. }
  552. this.prefix = this.prefix || [(this.name || 'F'), (+new Date).toString(36)].join('-');
  553. return this.prefix + (this.fidx++).toString(36);
  554. },
  555. // Description:
  556. // Helper for window.matchMedia
  557. //
  558. // Arguments:
  559. // mq (String): Media query
  560. //
  561. // Returns:
  562. // (Boolean): Whether the media query passes or not
  563. match : function (mq) {
  564. return window.matchMedia(mq).matches;
  565. },
  566. // Description:
  567. // Helpers for checking Foundation default media queries with JS
  568. //
  569. // Returns:
  570. // (Boolean): Whether the media query passes or not
  571. is_small_up : function () {
  572. return this.match(Foundation.media_queries.small);
  573. },
  574. is_medium_up : function () {
  575. return this.match(Foundation.media_queries.medium);
  576. },
  577. is_large_up : function () {
  578. return this.match(Foundation.media_queries.large);
  579. },
  580. is_xlarge_up : function () {
  581. return this.match(Foundation.media_queries.xlarge);
  582. },
  583. is_xxlarge_up : function () {
  584. return this.match(Foundation.media_queries.xxlarge);
  585. },
  586. is_small_only : function () {
  587. return !this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
  588. },
  589. is_medium_only : function () {
  590. return this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
  591. },
  592. is_large_only : function () {
  593. return this.is_medium_up() && this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
  594. },
  595. is_xlarge_only : function () {
  596. return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && !this.is_xxlarge_up();
  597. },
  598. is_xxlarge_only : function () {
  599. return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && this.is_xxlarge_up();
  600. }
  601. }
  602. };
  603. $.fn.foundation = function () {
  604. var args = Array.prototype.slice.call(arguments, 0);
  605. return this.each(function () {
  606. Foundation.init.apply(Foundation, [this].concat(args));
  607. return this;
  608. });
  609. };
  610. }(jQuery, window, window.document));
  611. ;(function ($, window, document, undefined) {
  612. 'use strict';
  613. Foundation.libs.abide = {
  614. name : 'abide',
  615. version : '5.5.3',
  616. settings : {
  617. live_validate : true, // validate the form as you go
  618. validate_on_blur : true, // validate whenever you focus/blur on an input field
  619. // validate_on: 'tab', // tab (when user tabs between fields), change (input changes), manual (call custom events)
  620. focus_on_invalid : true, // automatically bring the focus to an invalid input field
  621. error_labels : true, // labels with a for="inputId" will receive an `error` class
  622. error_class : 'error', // labels with a for="inputId" will receive an `error` class
  623. // the amount of time Abide will take before it validates the form (in ms).
  624. // smaller time will result in faster validation
  625. timeout : 1000,
  626. patterns : {
  627. alpha : /^[a-zA-Z]+$/,
  628. alpha_numeric : /^[a-zA-Z0-9]+$/,
  629. integer : /^[-+]?\d+$/,
  630. number : /^[-+]?\d*(?:[\.\,]\d+)?$/,
  631. // amex, visa, diners
  632. card : /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,
  633. cvv : /^([0-9]){3,4}$/,
  634. // http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
  635. email : /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,
  636. // http://blogs.lse.ac.uk/lti/2008/04/23/a-regular-expression-to-match-any-url/
  637. url: /^(https?|ftp|file|ssh):\/\/([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((\/[-\+~%\/\.\w]+)?\??([-\+=&;%@\.\w]+)?#?([\w]+)?)?/,
  638. // abc.de
  639. domain : /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,8}$/,
  640. datetime : /^([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))$/,
  641. // YYYY-MM-DD
  642. date : /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))$/,
  643. // HH:MM:SS
  644. time : /^(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}$/,
  645. dateISO : /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/,
  646. // MM/DD/YYYY
  647. month_day_year : /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.]\d{4}$/,
  648. // DD/MM/YYYY
  649. day_month_year : /^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.]\d{4}$/,
  650. // #FFF or #FFFFFF
  651. color : /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
  652. },
  653. validators : {
  654. equalTo : function (el, required, parent) {
  655. var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
  656. to = el.value,
  657. valid = (from === to);
  658. return valid;
  659. }
  660. }
  661. },
  662. timer : null,
  663. init : function (scope, method, options) {
  664. this.bindings(method, options);
  665. },
  666. events : function (scope) {
  667. var self = this,
  668. form = self.S(scope).attr('novalidate', 'novalidate'),
  669. settings = form.data(this.attr_name(true) + '-init') || {};
  670. this.invalid_attr = this.add_namespace('data-invalid');
  671. function validate(originalSelf, e) {
  672. clearTimeout(self.timer);
  673. self.timer = setTimeout(function () {
  674. self.validate([originalSelf], e);
  675. }.bind(originalSelf), settings.timeout);
  676. }
  677. form
  678. .off('.abide')
  679. .on('submit.fndtn.abide', function (e) {
  680. var is_ajax = /ajax/i.test(self.S(this).attr(self.attr_name()));
  681. return self.validate(self.S(this).find('input, textarea, select').not(":hidden, [data-abide-ignore]").get(), e, is_ajax);
  682. })
  683. .on('validate.fndtn.abide', function (e) {
  684. if (settings.validate_on === 'manual') {
  685. self.validate([e.target], e);
  686. }
  687. })
  688. .on('reset', function (e) {
  689. return self.reset($(this), e);
  690. })
  691. .find('input, textarea, select').not(":hidden, [data-abide-ignore]")
  692. .off('.abide')
  693. .on('blur.fndtn.abide change.fndtn.abide', function (e) {
  694. var id = this.getAttribute('id'),
  695. eqTo = form.find('[data-equalto="'+ id +'"]');
  696. // old settings fallback
  697. // will be deprecated with F6 release
  698. if (settings.validate_on_blur && settings.validate_on_blur === true) {
  699. validate(this, e);
  700. }
  701. // checks if there is an equalTo equivalent related by id
  702. if(typeof eqTo.get(0) !== "undefined" && eqTo.val().length){
  703. validate(eqTo.get(0),e);
  704. }
  705. // new settings combining validate options into one setting
  706. if (settings.validate_on === 'change') {
  707. validate(this, e);
  708. }
  709. })
  710. .on('keydown.fndtn.abide', function (e) {
  711. var id = this.getAttribute('id'),
  712. eqTo = form.find('[data-equalto="'+ id +'"]');
  713. // old settings fallback
  714. // will be deprecated with F6 release
  715. if (settings.live_validate && settings.live_validate === true && e.which != 9) {
  716. validate(this, e);
  717. }
  718. // checks if there is an equalTo equivalent related by id
  719. if(typeof eqTo.get(0) !== "undefined" && eqTo.val().length){
  720. validate(eqTo.get(0),e);
  721. }
  722. // new settings combining validate options into one setting
  723. if (settings.validate_on === 'tab' && e.which === 9) {
  724. validate(this, e);
  725. }
  726. else if (settings.validate_on === 'change') {
  727. validate(this, e);
  728. }
  729. })
  730. .on('focus', function (e) {
  731. if (navigator.userAgent.match(/iPad|iPhone|Android|BlackBerry|Windows Phone|webOS/i)) {
  732. $('html, body').animate({
  733. scrollTop: $(e.target).offset().top
  734. }, 100);
  735. }
  736. });
  737. },
  738. reset : function (form, e) {
  739. var self = this;
  740. form.removeAttr(self.invalid_attr);
  741. $('[' + self.invalid_attr + ']', form).removeAttr(self.invalid_attr);
  742. $('.' + self.settings.error_class, form).not('small').removeClass(self.settings.error_class);
  743. $(':input', form).not(':button, :submit, :reset, :hidden, [data-abide-ignore]').val('').removeAttr(self.invalid_attr);
  744. },
  745. validate : function (els, e, is_ajax) {
  746. var validations = this.parse_patterns(els),
  747. validation_count = validations.length,
  748. form = this.S(els[0]).closest('form'),
  749. submit_event = /submit/.test(e.type);
  750. // Has to count up to make sure the focus gets applied to the top error
  751. for (var i = 0; i < validation_count; i++) {
  752. if (!validations[i] && (submit_event || is_ajax)) {
  753. if (this.settings.focus_on_invalid) {
  754. els[i].focus();
  755. }
  756. form.trigger('invalid.fndtn.abide');
  757. this.S(els[i]).closest('form').attr(this.invalid_attr, '');
  758. return false;
  759. }
  760. }
  761. if (submit_event || is_ajax) {
  762. form.trigger('valid.fndtn.abide');
  763. }
  764. form.removeAttr(this.invalid_attr);
  765. if (is_ajax) {
  766. return false;
  767. }
  768. return true;
  769. },
  770. parse_patterns : function (els) {
  771. var i = els.length,
  772. el_patterns = [];
  773. while (i--) {
  774. el_patterns.push(this.pattern(els[i]));
  775. }
  776. return this.check_validation_and_apply_styles(el_patterns);
  777. },
  778. pattern : function (el) {
  779. var type = el.getAttribute('type'),
  780. required = typeof el.getAttribute('required') === 'string';
  781. var pattern = el.getAttribute('pattern') || '';
  782. if (this.settings.patterns.hasOwnProperty(pattern) && pattern.length > 0) {
  783. return [el, this.settings.patterns[pattern], required];
  784. } else if (pattern.length > 0) {
  785. return [el, new RegExp(pattern), required];
  786. }
  787. if (this.settings.patterns.hasOwnProperty(type)) {
  788. return [el, this.settings.patterns[type], required];
  789. }
  790. pattern = /.*/;
  791. return [el, pattern, required];
  792. },
  793. // TODO: Break this up into smaller methods, getting hard to read.
  794. check_validation_and_apply_styles : function (el_patterns) {
  795. var i = el_patterns.length,
  796. validations = [];
  797. if (i == 0) {
  798. return validations;
  799. }
  800. var form = this.S(el_patterns[0][0]).closest('[data-' + this.attr_name(true) + ']'),
  801. settings = form.data(this.attr_name(true) + '-init') || {};
  802. while (i--) {
  803. var el = el_patterns[i][0],
  804. required = el_patterns[i][2],
  805. value = el.value.trim(),
  806. direct_parent = this.S(el).parent(),
  807. validator = el.getAttribute(this.add_namespace('data-abide-validator')),
  808. is_radio = el.type === 'radio',
  809. is_checkbox = el.type === 'checkbox',
  810. label = this.S('label[for="' + el.getAttribute('id') + '"]'),
  811. valid_length = (required) ? (el.value.length > 0) : true,
  812. el_validations = [];
  813. var parent, valid;
  814. // support old way to do equalTo validations
  815. if (el.getAttribute(this.add_namespace('data-equalto'))) { validator = 'equalTo' }
  816. if (!direct_parent.is('label')) {
  817. parent = direct_parent;
  818. } else {
  819. parent = direct_parent.parent();
  820. }
  821. if (is_radio && required) {
  822. el_validations.push(this.valid_radio(el, required));
  823. } else if (is_checkbox && required) {
  824. el_validations.push(this.valid_checkbox(el, required));
  825. } else if (validator) {
  826. // Validate using each of the specified (space-delimited) validators.
  827. var validators = validator.split(' ');
  828. var last_valid = true, all_valid = true;
  829. for (var iv = 0; iv < validators.length; iv++) {
  830. valid = this.settings.validators[validators[iv]].apply(this, [el, required, parent])
  831. el_validations.push(valid);
  832. all_valid = valid && last_valid;
  833. last_valid = valid;
  834. }
  835. if (all_valid) {
  836. this.S(el).removeAttr(this.invalid_attr);
  837. parent.removeClass('error');
  838. if (label.length > 0 && this.settings.error_labels) {
  839. label.removeClass(this.settings.error_class).removeAttr('role');
  840. }
  841. $(el).triggerHandler('valid');
  842. } else {
  843. this.S(el).attr(this.invalid_attr, '');
  844. parent.addClass('error');
  845. if (label.length > 0 && this.settings.error_labels) {
  846. label.addClass(this.settings.error_class).attr('role', 'alert');
  847. }
  848. $(el).triggerHandler('invalid');
  849. }
  850. } else {
  851. if (el_patterns[i][1].test(value) && valid_length ||
  852. !required && el.value.length < 1 || $(el).attr('disabled')) {
  853. el_validations.push(true);
  854. } else {
  855. el_validations.push(false);
  856. }
  857. el_validations = [el_validations.every(function (valid) {return valid;})];
  858. if (el_validations[0]) {
  859. this.S(el).removeAttr(this.invalid_attr);
  860. el.setAttribute('aria-invalid', 'false');
  861. el.removeAttribute('aria-describedby');
  862. parent.removeClass(this.settings.error_class);
  863. if (label.length > 0 && this.settings.error_labels) {
  864. label.removeClass(this.settings.error_class).removeAttr('role');
  865. }
  866. $(el).triggerHandler('valid');
  867. } else {
  868. this.S(el).attr(this.invalid_attr, '');
  869. el.setAttribute('aria-invalid', 'true');
  870. // Try to find the error associated with the input
  871. var errorElem = parent.find('small.' + this.settings.error_class, 'span.' + this.settings.error_class);
  872. var errorID = errorElem.length > 0 ? errorElem[0].id : '';
  873. if (errorID.length > 0) {
  874. el.setAttribute('aria-describedby', errorID);
  875. }
  876. // el.setAttribute('aria-describedby', $(el).find('.error')[0].id);
  877. parent.addClass(this.settings.error_class);
  878. if (label.length > 0 && this.settings.error_labels) {
  879. label.addClass(this.settings.error_class).attr('role', 'alert');
  880. }
  881. $(el).triggerHandler('invalid');
  882. }
  883. }
  884. validations = validations.concat(el_validations);
  885. }
  886. return validations;
  887. },
  888. valid_checkbox : function (el, required) {
  889. var el = this.S(el),
  890. valid = (el.is(':checked') || !required || el.get(0).getAttribute('disabled'));
  891. if (valid) {
  892. el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
  893. $(el).triggerHandler('valid');
  894. } else {
  895. el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
  896. $(el).triggerHandler('invalid');
  897. }
  898. return valid;
  899. },
  900. valid_radio : function (el, required) {
  901. var name = el.getAttribute('name'),
  902. group = this.S(el).closest('[data-' + this.attr_name(true) + ']').find("[name='" + name + "']"),
  903. count = group.length,
  904. valid = false,
  905. disabled = false;
  906. // Has to count up to make sure the focus gets applied to the top error
  907. for (var i=0; i < count; i++) {
  908. if( group[i].getAttribute('disabled') ){
  909. disabled=true;
  910. valid=true;
  911. } else {
  912. if (group[i].checked){
  913. valid = true;
  914. } else {
  915. if( disabled ){
  916. valid = false;
  917. }
  918. }
  919. }
  920. }
  921. // Has to count up to make sure the focus gets applied to the top error
  922. for (var i = 0; i < count; i++) {
  923. if (valid) {
  924. this.S(group[i]).removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
  925. $(group[i]).triggerHandler('valid');
  926. } else {
  927. this.S(group[i]).attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
  928. $(group[i]).triggerHandler('invalid');
  929. }
  930. }
  931. return valid;
  932. },
  933. valid_equal : function (el, required, parent) {
  934. var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
  935. to = el.value,
  936. valid = (from === to);
  937. if (valid) {
  938. this.S(el).removeAttr(this.invalid_attr);
  939. parent.removeClass(this.settings.error_class);
  940. if (label.length > 0 && settings.error_labels) {
  941. label.removeClass(this.settings.error_class);
  942. }
  943. } else {
  944. this.S(el).attr(this.invalid_attr, '');
  945. parent.addClass(this.settings.error_class);
  946. if (label.length > 0 && settings.error_labels) {
  947. label.addClass(this.settings.error_class);
  948. }
  949. }
  950. return valid;
  951. },
  952. valid_oneof : function (el, required, parent, doNotValidateOthers) {
  953. var el = this.S(el),
  954. others = this.S('[' + this.add_namespace('data-oneof') + ']'),
  955. valid = others.filter(':checked').length > 0;
  956. if (valid) {
  957. el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
  958. } else {
  959. el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
  960. }
  961. if (!doNotValidateOthers) {
  962. var _this = this;
  963. others.each(function () {
  964. _this.valid_oneof.call(_this, this, null, null, true);
  965. });
  966. }
  967. return valid;
  968. },
  969. reflow : function(scope, options) {
  970. var self = this,
  971. form = self.S('[' + this.attr_name() + ']').attr('novalidate', 'novalidate');
  972. self.S(form).each(function (idx, el) {
  973. self.events(el);
  974. });
  975. }
  976. };
  977. }(jQuery, window, window.document));
  978. ;(function ($, window, document, undefined) {
  979. 'use strict';
  980. Foundation.libs.accordion = {
  981. name : 'accordion',
  982. version : '5.5.3',
  983. settings : {
  984. content_class : 'content',
  985. active_class : 'active',
  986. multi_expand : false,
  987. toggleable : true,
  988. callback : function () {}
  989. },
  990. init : function (scope, method, options) {
  991. this.bindings(method, options);
  992. },
  993. events : function (instance) {
  994. var self = this;
  995. var S = this.S;
  996. self.create(this.S(instance));
  997. S(this.scope)
  998. .off('.fndtn.accordion')
  999. .on('click.fndtn.accordion', '[' + this.attr_name() + '] > dd > a, [' + this.attr_name() + '] > li > a', function (e) {
  1000. var accordion = S(this).closest('[' + self.attr_name() + ']'),
  1001. groupSelector = self.attr_name() + '=' + accordion.attr(self.attr_name()),
  1002. settings = accordion.data(self.attr_name(true) + '-init') || self.settings,
  1003. target = S('#' + this.href.split('#')[1]),
  1004. aunts = $('> dd, > li', accordion),
  1005. siblings = aunts.children('.' + settings.content_class),
  1006. active_content = siblings.filter('.' + settings.active_class);
  1007. e.preventDefault();
  1008. if (accordion.attr(self.attr_name())) {
  1009. siblings = siblings.add('[' + groupSelector + '] dd > ' + '.' + settings.content_class + ', [' + groupSelector + '] li > ' + '.' + settings.content_class);
  1010. aunts = aunts.add('[' + groupSelector + '] dd, [' + groupSelector + '] li');
  1011. }
  1012. if (settings.toggleable && target.is(active_content)) {
  1013. target.parent('dd, li').toggleClass(settings.active_class, false);
  1014. target.toggleClass(settings.active_class, false);
  1015. S(this).attr('aria-expanded', function(i, attr){
  1016. return attr === 'true' ? 'false' : 'true';
  1017. });
  1018. settings.callback(target);
  1019. target.triggerHandler('toggled', [accordion]);
  1020. accordion.triggerHandler('toggled', [target]);
  1021. return;
  1022. }
  1023. if (!settings.multi_expand) {
  1024. siblings.removeClass(settings.active_class);
  1025. aunts.removeClass(settings.active_class);
  1026. aunts.children('a').attr('aria-expanded','false');
  1027. }
  1028. target.addClass(settings.active_class).parent().addClass(settings.active_class);
  1029. settings.callback(target);
  1030. target.triggerHandler('toggled', [accordion]);
  1031. accordion.triggerHandler('toggled', [target]);
  1032. S(this).attr('aria-expanded','true');
  1033. });
  1034. },
  1035. create: function($instance) {
  1036. var self = this,
  1037. accordion = $instance,
  1038. aunts = $('> .accordion-navigation', accordion),
  1039. settings = accordion.data(self.attr_name(true) + '-init') || self.settings;
  1040. aunts.children('a').attr('aria-expanded','false');
  1041. aunts.has('.' + settings.content_class + '.' + settings.active_class).addClass(settings.active_class).children('a').attr('aria-expanded','true');
  1042. if (settings.multi_expand) {
  1043. $instance.attr('aria-multiselectable','true');
  1044. }
  1045. },
  1046. toggle : function(options) {
  1047. var options = typeof options !== 'undefined' ? options : {};
  1048. var selector = typeof options.selector !== 'undefined' ? options.selector : '';
  1049. var toggle_state = typeof options.toggle_state !== 'undefined' ? options.toggle_state : '';
  1050. var $accordion = typeof options.$accordion !== 'undefined' ? options.$accordion : this.S(this.scope).closest('[' + this.attr_name() + ']');
  1051. var $items = $accordion.find('> dd' + selector + ', > li' + selector);
  1052. if ( $items.length < 1 ) {
  1053. if ( window.console ) {
  1054. console.error('Selection not found.', selector);
  1055. }
  1056. return false;
  1057. }
  1058. var S = this.S;
  1059. var active_class = this.settings.active_class;
  1060. $items.each(function() {
  1061. var $item = S(this);
  1062. var is_active = $item.hasClass(active_class);
  1063. if ( ( is_active && toggle_state === 'close' ) || ( !is_active && toggle_state === 'open' ) || toggle_state === '' ) {
  1064. $item.find('> a').trigger('click.fndtn.accordion');
  1065. }
  1066. });
  1067. },
  1068. open : function(options) {
  1069. var options = typeof options !== 'undefined' ? options : {};
  1070. options.toggle_state = 'open';
  1071. this.toggle(options);
  1072. },
  1073. close : function(options) {
  1074. var options = typeof options !== 'undefined' ? options : {};
  1075. options.toggle_state = 'close';
  1076. this.toggle(options);
  1077. },
  1078. off : function () {},
  1079. reflow : function () {}
  1080. };
  1081. }(jQuery, window, window.document));
  1082. ;(function ($, window, document, undefined) {
  1083. 'use strict';
  1084. Foundation.libs.alert = {
  1085. name : 'alert',
  1086. version : '5.5.3',
  1087. settings : {
  1088. callback : function () {}
  1089. },
  1090. init : function (scope, method, options) {
  1091. this.bindings(method, options);
  1092. },
  1093. events : function () {
  1094. var self = this,
  1095. S = this.S;
  1096. $(this.scope).off('.alert').on('click.fndtn.alert', '[' + this.attr_name() + '] .close', function (e) {
  1097. var alertBox = S(this).closest('[' + self.attr_name() + ']'),
  1098. settings = alertBox.data(self.attr_name(true) + '-init') || self.settings;
  1099. e.preventDefault();
  1100. if (Modernizr.csstransitions) {
  1101. alertBox.addClass('alert-close');
  1102. alertBox.on('transitionend webkitTransitionEnd oTransitionEnd', function (e) {
  1103. S(this).trigger('close.fndtn.alert').remove();
  1104. settings.callback();
  1105. });
  1106. } else {
  1107. alertBox.fadeOut(300, function () {
  1108. S(this).trigger('close.fndtn.alert').remove();
  1109. settings.callback();
  1110. });
  1111. }
  1112. });
  1113. },
  1114. reflow : function () {}
  1115. };
  1116. }(jQuery, window, window.document));
  1117. ;(function ($, window, document, undefined) {
  1118. 'use strict';
  1119. Foundation.libs.clearing = {
  1120. name : 'clearing',
  1121. version : '5.5.3',
  1122. settings : {
  1123. templates : {
  1124. viewing : '<a href="#" class="clearing-close">&times;</a>' +
  1125. '<div class="visible-img" style="display: none"><div class="clearing-touch-label"></div><img src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D" alt="" />' +
  1126. '<p class="clearing-caption"></p><a href="#" class="clearing-main-prev"><span></span></a>' +
  1127. '<a href="#" class="clearing-main-next"><span></span></a></div>' +
  1128. '<img class="clearing-preload-next" style="display: none" src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D" alt="" />' +
  1129. '<img class="clearing-preload-prev" style="display: none" src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D" alt="" />'
  1130. },
  1131. // comma delimited list of selectors that, on click, will close clearing,
  1132. // add 'div.clearing-blackout, div.visible-img' to close on background click
  1133. close_selectors : '.clearing-close, div.clearing-blackout',
  1134. // Default to the entire li element.
  1135. open_selectors : '',
  1136. // Image will be skipped in carousel.
  1137. skip_selector : '',
  1138. touch_label : '',
  1139. // event initializer and locks
  1140. init : false,
  1141. locked : false
  1142. },
  1143. init : function (scope, method, options) {
  1144. var self = this;
  1145. Foundation.inherit(this, 'throttle image_loaded');
  1146. this.bindings(method, options);
  1147. if (self.S(this.scope).is('[' + this.attr_name() + ']')) {
  1148. this.assemble(self.S('li', this.scope));
  1149. } else {
  1150. self.S('[' + this.attr_name() + ']', this.scope).each(function () {
  1151. self.assemble(self.S('li', this));
  1152. });
  1153. }
  1154. },
  1155. events : function (scope) {
  1156. var self = this,
  1157. S = self.S,
  1158. $scroll_container = $('.scroll-container');
  1159. if ($scroll_container.length > 0) {
  1160. this.scope = $scroll_container;
  1161. }
  1162. S(this.scope)
  1163. .off('.clearing')
  1164. .on('click.fndtn.clearing', 'ul[' + this.attr_name() + '] li ' + this.settings.open_selectors,
  1165. function (e, current, target) {
  1166. var current = current || S(this),
  1167. target = target || current,
  1168. next = current.next('li'),
  1169. settings = current.closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init'),
  1170. image = S(e.target);
  1171. e.preventDefault();
  1172. if (!settings) {
  1173. self.init();
  1174. settings = current.closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init');
  1175. }
  1176. // if clearing is open and the current image is
  1177. // clicked, go to the next image in sequence
  1178. if (target.hasClass('visible') &&
  1179. current[0] === target[0] &&
  1180. next.length > 0 && self.is_open(current)) {
  1181. target = next;
  1182. image = S('img', target);
  1183. }
  1184. // set current and target to the clicked li if not otherwise defined.
  1185. self.open(image, current, target);
  1186. self.update_paddles(target);
  1187. })
  1188. .on('click.fndtn.clearing', '.clearing-main-next',
  1189. function (e) { self.nav(e, 'next') })
  1190. .on('click.fndtn.clearing', '.clearing-main-prev',
  1191. function (e) { self.nav(e, 'prev') })
  1192. .on('click.fndtn.clearing', this.settings.close_selectors,
  1193. function (e) { Foundation.libs.clearing.close(e, this) });
  1194. $(document).on('keydown.fndtn.clearing',
  1195. function (e) { self.keydown(e) });
  1196. S(window).off('.clearing').on('resize.fndtn.clearing',
  1197. function () { self.resize() });
  1198. this.swipe_events(scope);
  1199. },
  1200. swipe_events : function (scope) {
  1201. var self = this,
  1202. S = self.S;
  1203. S(this.scope)
  1204. .on('touchstart.fndtn.clearing', '.visible-img', function (e) {
  1205. if (!e.touches) { e = e.originalEvent; }
  1206. var data = {
  1207. start_page_x : e.touches[0].pageX,
  1208. start_page_y : e.touches[0].pageY,
  1209. start_time : (new Date()).getTime(),
  1210. delta_x : 0,
  1211. is_scrolling : undefined
  1212. };
  1213. S(this).data('swipe-transition', data);
  1214. e.stopPropagation();
  1215. })
  1216. .on('touchmove.fndtn.clearing', '.visible-img', function (e) {
  1217. if (!e.touches) {
  1218. e = e.originalEvent;
  1219. }
  1220. // Ignore pinch/zoom events
  1221. if (e.touches.length > 1 || e.scale && e.scale !== 1) {
  1222. return;
  1223. }
  1224. var data = S(this).data('swipe-transition');
  1225. if (typeof data === 'undefined') {
  1226. data = {};
  1227. }
  1228. data.delta_x = e.touches[0].pageX - data.start_page_x;
  1229. if (Foundation.rtl) {
  1230. data.delta_x = -data.delta_x;
  1231. }
  1232. if (typeof data.is_scrolling === 'undefined') {
  1233. data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
  1234. }
  1235. if (!data.is_scrolling && !data.active) {
  1236. e.preventDefault();
  1237. var direction = (data.delta_x < 0) ? 'next' : 'prev';
  1238. data.active = true;
  1239. self.nav(e, direction);
  1240. }
  1241. })
  1242. .on('touchend.fndtn.clearing', '.visible-img', function (e) {
  1243. S(this).data('swipe-transition', {});
  1244. e.stopPropagation();
  1245. });
  1246. },
  1247. assemble : function ($li) {
  1248. var $el = $li.parent();
  1249. if ($el.parent().hasClass('carousel')) {
  1250. return;
  1251. }
  1252. $el.after('<div id="foundationClearingHolder"></div>');
  1253. var grid = $el.detach(),
  1254. grid_outerHTML = '';
  1255. if (grid[0] == null) {
  1256. return;
  1257. } else {
  1258. grid_outerHTML = grid[0].outerHTML;
  1259. }
  1260. var holder = this.S('#foundationClearingHolder'),
  1261. settings = $el.data(this.attr_name(true) + '-init'),
  1262. data = {
  1263. grid : '<div class="carousel">' + grid_outerHTML + '</div>',
  1264. viewing : settings.templates.viewing
  1265. },
  1266. wrapper = '<div class="clearing-assembled"><div>' + data.viewing +
  1267. data.grid + '</div></div>',
  1268. touch_label = this.settings.touch_label;
  1269. if (Modernizr.touch) {
  1270. wrapper = $(wrapper).find('.clearing-touch-label').html(touch_label).end();
  1271. }
  1272. holder.after(wrapper).remove();
  1273. },
  1274. open : function ($image, current, target) {
  1275. var self = this,
  1276. body = $(document.body),
  1277. root = target.closest('.clearing-assembled'),
  1278. container = self.S('div', root).first(),
  1279. visible_image = self.S('.visible-img', container),
  1280. image = self.S('img', visible_image).not($image),
  1281. label = self.S('.clearing-touch-label', container),
  1282. error = false,
  1283. loaded = {};
  1284. // Event to disable scrolling on touch devices when Clearing is activated
  1285. $('body').on('touchmove', function (e) {
  1286. e.preventDefault();
  1287. });
  1288. image.error(function () {
  1289. error = true;
  1290. });
  1291. function startLoad() {
  1292. setTimeout(function () {
  1293. this.image_loaded(image, function () {
  1294. if (image.outerWidth() === 1 && !error) {
  1295. startLoad.call(this);
  1296. } else {
  1297. cb.call(this, image);
  1298. }
  1299. }.bind(this));
  1300. }.bind(this), 100);
  1301. }
  1302. function cb (image) {
  1303. var $image = $(image);
  1304. $image.css('visibility', 'visible');
  1305. $image.trigger('imageVisible');
  1306. // toggle the gallery
  1307. body.css('overflow', 'hidden');
  1308. root.addClass('clearing-blackout');
  1309. container.addClass('clearing-container');
  1310. visible_image.show();
  1311. this.fix_height(target)
  1312. .caption(self.S('.clearing-caption', visible_image), self.S('img', target))
  1313. .center_and_label(image, label)
  1314. .shift(current, target, function () {
  1315. target.closest('li').siblings().removeClass('visible');
  1316. target.closest('li').addClass('visible');
  1317. });
  1318. visible_image.trigger('opened.fndtn.clearing')
  1319. }
  1320. if (!this.locked()) {
  1321. visible_image.trigger('open.fndtn.clearing');
  1322. // set the image to the selected thumbnail
  1323. loaded = this.load($image);
  1324. if (loaded.interchange) {
  1325. image
  1326. .attr('data-interchange', loaded.interchange)
  1327. .foundation('interchange', 'reflow');
  1328. } else {
  1329. image
  1330. .attr('src', loaded.src)
  1331. .attr('data-interchange', '');
  1332. }
  1333. image.css('visibility', 'hidden');
  1334. startLoad.call(this);
  1335. }
  1336. },
  1337. close : function (e, el) {
  1338. e.preventDefault();
  1339. var root = (function (target) {
  1340. if (/blackout/.test(target.selector)) {
  1341. return target;
  1342. } else {
  1343. return target.closest('.clearing-blackout');
  1344. }
  1345. }($(el))),
  1346. body = $(document.body), container, visible_image;
  1347. if (el === e.target && root) {
  1348. body.css('overflow', '');
  1349. container = $('div', root).first();
  1350. visible_image = $('.visible-img', container);
  1351. visible_image.trigger('close.fndtn.clearing');
  1352. this.settings.prev_index = 0;
  1353. $('ul[' + this.attr_name() + ']', root)
  1354. .attr('style', '').closest('.clearing-blackout')
  1355. .removeClass('clearing-blackout');
  1356. container.removeClass('clearing-container');
  1357. visible_image.hide();
  1358. visible_image.trigger('closed.fndtn.clearing');
  1359. }
  1360. // Event to re-enable scrolling on touch devices
  1361. $('body').off('touchmove');
  1362. return false;
  1363. },
  1364. is_open : function (current) {
  1365. return current.parent().prop('style').length > 0;
  1366. },
  1367. keydown : function (e) {
  1368. var clearing = $('.clearing-blackout ul[' + this.attr_name() + ']'),
  1369. NEXT_KEY = this.rtl ? 37 : 39,
  1370. PREV_KEY = this.rtl ? 39 : 37,
  1371. ESC_KEY = 27;
  1372. if (e.which === NEXT_KEY) {
  1373. this.go(clearing, 'next');
  1374. }
  1375. if (e.which === PREV_KEY) {
  1376. this.go(clearing, 'prev');
  1377. }
  1378. if (e.which === ESC_KEY) {
  1379. this.S('a.clearing-close').trigger('click.fndtn.clearing');
  1380. }
  1381. },
  1382. nav : function (e, direction) {
  1383. var clearing = $('ul[' + this.attr_name() + ']', '.clearing-blackout');
  1384. e.preventDefault();
  1385. this.go(clearing, direction);
  1386. },
  1387. resize : function () {
  1388. var image = $('img', '.clearing-blackout .visible-img'),
  1389. label = $('.clearing-touch-label', '.clearing-blackout');
  1390. if (image.length) {
  1391. this.center_and_label(image, label);
  1392. image.trigger('resized.fndtn.clearing')
  1393. }
  1394. },
  1395. // visual adjustments
  1396. fix_height : function (target) {
  1397. var lis = target.parent().children(),
  1398. self = this;
  1399. lis.each(function () {
  1400. var li = self.S(this),
  1401. image = li.find('img');
  1402. if (li.height() > image.outerHeight()) {
  1403. li.addClass('fix-height');
  1404. }
  1405. })
  1406. .closest('ul')
  1407. .width(lis.length * 100 + '%');
  1408. return this;
  1409. },
  1410. update_paddles : function (target) {
  1411. target = target.closest('li');
  1412. var visible_image = target
  1413. .closest('.carousel')
  1414. .siblings('.visible-img');
  1415. if (target.next().length > 0) {
  1416. this.S('.clearing-main-next', visible_image).removeClass('disabled');
  1417. } else {
  1418. this.S('.clearing-main-next', visible_image).addClass('disabled');
  1419. }
  1420. if (target.prev().length > 0) {
  1421. this.S('.clearing-main-prev', visible_image).removeClass('disabled');
  1422. } else {
  1423. this.S('.clearing-main-prev', visible_image).addClass('disabled');
  1424. }
  1425. },
  1426. center_and_label : function (target, label) {
  1427. if (!this.rtl && label.length > 0) {
  1428. label.css({
  1429. marginLeft : -(label.outerWidth() / 2),
  1430. marginTop : -(target.outerHeight() / 2)-label.outerHeight()-10
  1431. });
  1432. } else {
  1433. label.css({
  1434. marginRight : -(label.outerWidth() / 2),
  1435. marginTop : -(target.outerHeight() / 2)-label.outerHeight()-10,
  1436. left: 'auto',
  1437. right: '50%'
  1438. });
  1439. }
  1440. return this;
  1441. },
  1442. // image loading and preloading
  1443. load : function ($image) {
  1444. var href,
  1445. interchange,
  1446. closest_a;
  1447. if ($image[0].nodeName === 'A') {
  1448. href = $image.attr('href');
  1449. interchange = $image.data('clearing-interchange');
  1450. } else {
  1451. closest_a = $image.closest('a');
  1452. href = closest_a.attr('href');
  1453. interchange = closest_a.data('clearing-interchange');
  1454. }
  1455. this.preload($image);
  1456. return {
  1457. 'src': href ? href : $image.attr('src'),
  1458. 'interchange': href ? interchange : $image.data('clearing-interchange')
  1459. }
  1460. },
  1461. preload : function ($image) {
  1462. this
  1463. .img($image.closest('li').next(), 'next')
  1464. .img($image.closest('li').prev(), 'prev');
  1465. },
  1466. img : function (img, sibling_type) {
  1467. if (img.length) {
  1468. var preload_img = $('.clearing-preload-' + sibling_type),
  1469. new_a = this.S('a', img),
  1470. src,
  1471. interchange,
  1472. image;
  1473. if (new_a.length) {
  1474. src = new_a.attr('href');
  1475. interchange = new_a.data('clearing-interchange');
  1476. } else {
  1477. image = this.S('img', img);
  1478. src = image.attr('src');
  1479. interchange = image.data('clearing-interchange');
  1480. }
  1481. if (interchange) {
  1482. preload_img.attr('data-interchange', interchange);
  1483. } else {
  1484. preload_img.attr('src', src);
  1485. preload_img.attr('data-interchange', '');
  1486. }
  1487. }
  1488. return this;
  1489. },
  1490. // image caption
  1491. caption : function (container, $image) {
  1492. var caption = $image.attr('data-caption');
  1493. if (caption) {
  1494. var containerPlain = container.get(0);
  1495. containerPlain.innerHTML = caption;
  1496. container.show();
  1497. } else {
  1498. container
  1499. .text('')
  1500. .hide();
  1501. }
  1502. return this;
  1503. },
  1504. // directional methods
  1505. go : function ($ul, direction) {
  1506. var current = this.S('.visible', $ul),
  1507. target = current[direction]();
  1508. // Check for skip selector.
  1509. if (this.settings.skip_selector && target.find(this.settings.skip_selector).length != 0) {
  1510. target = target[direction]();
  1511. }
  1512. if (target.length) {
  1513. this.S('img', target)
  1514. .trigger('click.fndtn.clearing', [current, target])
  1515. .trigger('change.fndtn.clearing');
  1516. }
  1517. },
  1518. shift : function (current, target, callback) {
  1519. var clearing = target.parent(),
  1520. old_index = this.settings.prev_index || target.index(),
  1521. direction = this.direction(clearing, current, target),
  1522. dir = this.rtl ? 'right' : 'left',
  1523. left = parseInt(clearing.css('left'), 10),
  1524. width = target.outerWidth(),
  1525. skip_shift;
  1526. var dir_obj = {};
  1527. // we use jQuery animate instead of CSS transitions because we
  1528. // need a callback to unlock the next animation
  1529. // needs support for RTL **
  1530. if (target.index() !== old_index && !/skip/.test(direction)) {
  1531. if (/left/.test(direction)) {
  1532. this.lock();
  1533. dir_obj[dir] = left + width;
  1534. clearing.animate(dir_obj, 300, this.unlock());
  1535. } else if (/right/.test(direction)) {
  1536. this.lock();
  1537. dir_obj[dir] = left - width;
  1538. clearing.animate(dir_obj, 300, this.unlock());
  1539. }
  1540. } else if (/skip/.test(direction)) {
  1541. // the target image is not adjacent to the current image, so
  1542. // do we scroll right or not
  1543. skip_shift = target.index() - this.settings.up_count;
  1544. this.lock();
  1545. if (skip_shift > 0) {
  1546. dir_obj[dir] = -(skip_shift * width);
  1547. clearing.animate(dir_obj, 300, this.unlock());
  1548. } else {
  1549. dir_obj[dir] = 0;
  1550. clearing.animate(dir_obj, 300, this.unlock());
  1551. }
  1552. }
  1553. callback();
  1554. },
  1555. direction : function ($el, current, target) {
  1556. var lis = this.S('li', $el),
  1557. li_width = lis.outerWidth() + (lis.outerWidth() / 4),
  1558. up_count = Math.floor(this.S('.clearing-container').outerWidth() / li_width) - 1,
  1559. target_index = lis.index(target),
  1560. response;
  1561. this.settings.up_count = up_count;
  1562. if (this.adjacent(this.settings.prev_index, target_index)) {
  1563. if ((target_index > up_count) && target_index > this.settings.prev_index) {
  1564. response = 'right';
  1565. } else if ((target_index > up_count - 1) && target_index <= this.settings.prev_index) {
  1566. response = 'left';
  1567. } else {
  1568. response = false;
  1569. }
  1570. } else {
  1571. response = 'skip';
  1572. }
  1573. this.settings.prev_index = target_index;
  1574. return response;
  1575. },
  1576. adjacent : function (current_index, target_index) {
  1577. for (var i = target_index + 1; i >= target_index - 1; i--) {
  1578. if (i === current_index) {
  1579. return true;
  1580. }
  1581. }
  1582. return false;
  1583. },
  1584. // lock management
  1585. lock : function () {
  1586. this.settings.locked = true;
  1587. },
  1588. unlock : function () {
  1589. this.settings.locked = false;
  1590. },
  1591. locked : function () {
  1592. return this.settings.locked;
  1593. },
  1594. off : function () {
  1595. this.S(this.scope).off('.fndtn.clearing');
  1596. this.S(window).off('.fndtn.clearing');
  1597. },
  1598. reflow : function () {
  1599. this.init();
  1600. }
  1601. };
  1602. }(jQuery, window, window.document));
  1603. ;(function ($, window, document, undefined) {
  1604. 'use strict';
  1605. Foundation.libs.dropdown = {
  1606. name : 'dropdown',
  1607. version : '5.5.3',
  1608. settings : {
  1609. active_class : 'open',
  1610. disabled_class : 'disabled',
  1611. mega_class : 'mega',
  1612. align : 'bottom',
  1613. is_hover : false,
  1614. hover_timeout : 150,
  1615. opened : function () {},
  1616. closed : function () {}
  1617. },
  1618. init : function (scope, method, options) {
  1619. Foundation.inherit(this, 'throttle');
  1620. $.extend(true, this.settings, method, options);
  1621. this.bindings(method, options);
  1622. },
  1623. events : function (scope) {
  1624. var self = this,
  1625. S = self.S;
  1626. S(this.scope)
  1627. .off('.dropdown')
  1628. .on('click.fndtn.dropdown', '[' + this.attr_name() + ']', function (e) {
  1629. var settings = S(this).data(self.attr_name(true) + '-init') || self.settings;
  1630. if (!settings.is_hover || Modernizr.touch) {
  1631. e.preventDefault();
  1632. if (S(this).parent('[data-reveal-id]').length) {
  1633. e.stopPropagation();
  1634. }
  1635. self.toggle($(this));
  1636. }
  1637. })
  1638. .on('mouseenter.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
  1639. var $this = S(this),
  1640. dropdown,
  1641. target;
  1642. clearTimeout(self.timeout);
  1643. if ($this.data(self.data_attr())) {
  1644. dropdown = S('#' + $this.data(self.data_attr()));
  1645. target = $this;
  1646. } else {
  1647. dropdown = $this;
  1648. target = S('[' + self.attr_name() + '="' + dropdown.attr('id') + '"]');
  1649. }
  1650. var settings = target.data(self.attr_name(true) + '-init') || self.settings;
  1651. if (S(e.currentTarget).data(self.data_attr()) && settings.is_hover) {
  1652. self.closeall.call(self);
  1653. }
  1654. if (settings.is_hover) {
  1655. self.open.apply(self, [dropdown, target]);
  1656. }
  1657. })
  1658. .on('mouseleave.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
  1659. var $this = S(this);
  1660. var settings;
  1661. if ($this.data(self.data_attr())) {
  1662. settings = $this.data(self.data_attr(true) + '-init') || self.settings;
  1663. } else {
  1664. var target = S('[' + self.attr_name() + '="' + S(this).attr('id') + '"]'),
  1665. settings = target.data(self.attr_name(true) + '-init') || self.settings;
  1666. }
  1667. self.timeout = setTimeout(function () {
  1668. if ($this.data(self.data_attr())) {
  1669. if (settings.is_hover) {
  1670. self.close.call(self, S('#' + $this.data(self.data_attr())));
  1671. }
  1672. } else {
  1673. if (settings.is_hover) {
  1674. self.close.call(self, $this);
  1675. }
  1676. }
  1677. }.bind(this), settings.hover_timeout);
  1678. })
  1679. .on('click.fndtn.dropdown', function (e) {
  1680. var parent = S(e.target).closest('[' + self.attr_name() + '-content]');
  1681. var links = parent.find('a');
  1682. if (links.length > 0 && parent.attr('aria-autoclose') !== 'false') {
  1683. self.close.call(self, S('[' + self.attr_name() + '-content]'));
  1684. }
  1685. if (e.target !== document && !$.contains(document.documentElement, e.target)) {
  1686. return;
  1687. }
  1688. if (S(e.target).closest('[' + self.attr_name() + ']').length > 0) {
  1689. return;
  1690. }
  1691. if (!(S(e.target).data('revealId')) &&
  1692. (parent.length > 0 && (S(e.target).is('[' + self.attr_name() + '-content]') ||
  1693. $.contains(parent.first()[0], e.target)))) {
  1694. e.stopPropagation();
  1695. return;
  1696. }
  1697. self.close.call(self, S('[' + self.attr_name() + '-content]'));
  1698. })
  1699. .on('opened.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
  1700. self.settings.opened.call(this);
  1701. })
  1702. .on('closed.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
  1703. self.settings.closed.call(this);
  1704. });
  1705. S(window)
  1706. .off('.dropdown')
  1707. .on('resize.fndtn.dropdown', self.throttle(function () {
  1708. self.resize.call(self);
  1709. }, 50));
  1710. this.resize();
  1711. },
  1712. close : function (dropdown) {
  1713. var self = this;
  1714. dropdown.each(function (idx) {
  1715. var original_target = $('[' + self.attr_name() + '=' + dropdown[idx].id + ']') || $('aria-controls=' + dropdown[idx].id + ']');
  1716. original_target.attr('aria-expanded', 'false');
  1717. if (self.S(this).hasClass(self.settings.active_class)) {
  1718. self.S(this)
  1719. .css(Foundation.rtl ? 'right' : 'left', '-99999px')
  1720. .attr('aria-hidden', 'true')
  1721. .removeClass(self.settings.active_class)
  1722. .prev('[' + self.attr_name() + ']')
  1723. .removeClass(self.settings.active_class)
  1724. .removeData('target');
  1725. self.S(this).trigger('closed.fndtn.dropdown', [dropdown]);
  1726. }
  1727. });
  1728. dropdown.removeClass('f-open-' + this.attr_name(true));
  1729. },
  1730. closeall : function () {
  1731. var self = this;
  1732. $.each(self.S('.f-open-' + this.attr_name(true)), function () {
  1733. self.close.call(self, self.S(this));
  1734. });
  1735. },
  1736. open : function (dropdown, target) {
  1737. this
  1738. .css(dropdown
  1739. .addClass(this.settings.active_class), target);
  1740. dropdown.prev('[' + this.attr_name() + ']').addClass(this.settings.active_class);
  1741. dropdown.data('target', target.get(0)).trigger('opened.fndtn.dropdown', [dropdown, target]);
  1742. dropdown.attr('aria-hidden', 'false');
  1743. target.attr('aria-expanded', 'true');
  1744. dropdown.focus();
  1745. dropdown.addClass('f-open-' + this.attr_name(true));
  1746. },
  1747. data_attr : function () {
  1748. if (this.namespace.length > 0) {
  1749. return this.namespace + '-' + this.name;
  1750. }
  1751. return this.name;
  1752. },
  1753. toggle : function (target) {
  1754. if (target.hasClass(this.settings.disabled_class)) {
  1755. return;
  1756. }
  1757. var dropdown = this.S('#' + target.data(this.data_attr()));
  1758. if (dropdown.length === 0) {
  1759. // No dropdown found, not continuing
  1760. return;
  1761. }
  1762. this.close.call(this, this.S('[' + this.attr_name() + '-content]').not(dropdown));
  1763. if (dropdown.hasClass(this.settings.active_class)) {
  1764. this.close.call(this, dropdown);
  1765. if (dropdown.data('target') !== target.get(0)) {
  1766. this.open.call(this, dropdown, target);
  1767. }
  1768. } else {
  1769. this.open.call(this, dropdown, target);
  1770. }
  1771. },
  1772. resize : function () {
  1773. var dropdown = this.S('[' + this.attr_name() + '-content].open');
  1774. var target = $(dropdown.data("target"));
  1775. if (dropdown.length && target.length) {
  1776. this.css(dropdown, target);
  1777. }
  1778. },
  1779. css : function (dropdown, target) {
  1780. var left_offset = Math.max((target.width() - dropdown.width()) / 2, 8),
  1781. settings = target.data(this.attr_name(true) + '-init') || this.settings,
  1782. parentOverflow = dropdown.parent().css('overflow-y') || dropdown.parent().css('overflow');
  1783. this.clear_idx();
  1784. if (this.small()) {
  1785. var p = this.dirs.bottom.call(dropdown, target, settings);
  1786. dropdown.attr('style', '').removeClass('drop-left drop-right drop-top').css({
  1787. position : 'absolute',
  1788. width : '95%',
  1789. 'max-width' : 'none',
  1790. top : p.top
  1791. });
  1792. dropdown.css(Foundation.rtl ? 'right' : 'left', left_offset);
  1793. }
  1794. // detect if dropdown is in an overflow container
  1795. else if (parentOverflow !== 'visible') {
  1796. var offset = target[0].offsetTop + target[0].offsetHeight;
  1797. dropdown.attr('style', '').css({
  1798. position : 'absolute',
  1799. top : offset
  1800. });
  1801. dropdown.css(Foundation.rtl ? 'right' : 'left', left_offset);
  1802. }
  1803. else {
  1804. this.style(dropdown, target, settings);
  1805. }
  1806. return dropdown;
  1807. },
  1808. style : function (dropdown, target, settings) {
  1809. var css = $.extend({position : 'absolute'},
  1810. this.dirs[settings.align].call(dropdown, target, settings));
  1811. dropdown.attr('style', '').css(css);
  1812. },
  1813. // return CSS property object
  1814. // `this` is the dropdown
  1815. dirs : {
  1816. // Calculate target offset
  1817. _base : function (t, s) {
  1818. var o_p = this.offsetParent(),
  1819. o = o_p.offset(),
  1820. p = t.offset();
  1821. p.top -= o.top;
  1822. p.left -= o.left;
  1823. //set some flags on the p object to pass along
  1824. p.missRight = false;
  1825. p.missTop = false;
  1826. p.missLeft = false;
  1827. p.leftRightFlag = false;
  1828. //lets see if the panel will be off the screen
  1829. //get the actual width of the page and store it
  1830. var actualBodyWidth;
  1831. var windowWidth = window.innerWidth;
  1832. if (document.getElementsByClassName('row')[0]) {
  1833. actualBodyWidth = document.getElementsByClassName('row')[0].clientWidth;
  1834. } else {
  1835. actualBodyWidth = windowWidth;
  1836. }
  1837. var actualMarginWidth = (windowWidth - actualBodyWidth) / 2;
  1838. var actualBoundary = actualBodyWidth;
  1839. if (!this.hasClass('mega') && !s.ignore_repositioning) {
  1840. var outerWidth = this.outerWidth();
  1841. var o_left = t.offset().left;
  1842. //miss top
  1843. if (t.offset().top <= this.outerHeight()) {
  1844. p.missTop = true;
  1845. actualBoundary = windowWidth - actualMarginWidth;
  1846. p.leftRightFlag = true;
  1847. }
  1848. //miss right
  1849. if (o_left + outerWidth > o_left + actualMarginWidth && o_left - actualMarginWidth > outerWidth) {
  1850. p.missRight = true;
  1851. p.missLeft = false;
  1852. }
  1853. //miss left
  1854. if (o_left - outerWidth <= 0) {
  1855. p.missLeft = true;
  1856. p.missRight = false;
  1857. }
  1858. }
  1859. return p;
  1860. },
  1861. top : function (t, s) {
  1862. var self = Foundation.libs.dropdown,
  1863. p = self.dirs._base.call(this, t, s);
  1864. this.addClass('drop-top');
  1865. if (p.missTop == true) {
  1866. p.top = p.top + t.outerHeight() + this.outerHeight();
  1867. this.removeClass('drop-top');
  1868. }
  1869. if (p.missRight == true) {
  1870. p.left = p.left - this.outerWidth() + t.outerWidth();
  1871. }
  1872. if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
  1873. self.adjust_pip(this, t, s, p);
  1874. }
  1875. if (Foundation.rtl) {
  1876. return {left : p.left - this.outerWidth() + t.outerWidth(),
  1877. top : p.top - this.outerHeight()};
  1878. }
  1879. return {left : p.left, top : p.top - this.outerHeight()};
  1880. },
  1881. bottom : function (t, s) {
  1882. var self = Foundation.libs.dropdown,
  1883. p = self.dirs._base.call(this, t, s);
  1884. if (p.missRight == true) {
  1885. p.left = p.left - this.outerWidth() + t.outerWidth();
  1886. }
  1887. if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
  1888. self.adjust_pip(this, t, s, p);
  1889. }
  1890. if (self.rtl) {
  1891. return {left : p.left - this.outerWidth() + t.outerWidth(), top : p.top + t.outerHeight()};
  1892. }
  1893. return {left : p.left, top : p.top + t.outerHeight()};
  1894. },
  1895. left : function (t, s) {
  1896. var p = Foundation.libs.dropdown.dirs._base.call(this, t, s);
  1897. this.addClass('drop-left');
  1898. if (p.missLeft == true) {
  1899. p.left = p.left + this.outerWidth();
  1900. p.top = p.top + t.outerHeight();
  1901. this.removeClass('drop-left');
  1902. }
  1903. return {left : p.left - this.outerWidth(), top : p.top};
  1904. },
  1905. right : function (t, s) {
  1906. var p = Foundation.libs.dropdown.dirs._base.call(this, t, s);
  1907. this.addClass('drop-right');
  1908. if (p.missRight == true) {
  1909. p.left = p.left - this.outerWidth();
  1910. p.top = p.top + t.outerHeight();
  1911. this.removeClass('drop-right');
  1912. } else {
  1913. p.triggeredRight = true;
  1914. }
  1915. var self = Foundation.libs.dropdown;
  1916. if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
  1917. self.adjust_pip(this, t, s, p);
  1918. }
  1919. return {left : p.left + t.outerWidth(), top : p.top};
  1920. }
  1921. },
  1922. // Insert rule to style psuedo elements
  1923. adjust_pip : function (dropdown, target, settings, position) {
  1924. var sheet = Foundation.stylesheet,
  1925. pip_offset_base = 8;
  1926. if (dropdown.hasClass(settings.mega_class)) {
  1927. pip_offset_base = position.left + (target.outerWidth() / 2) - 8;
  1928. } else if (this.small()) {
  1929. pip_offset_base += position.left - 8;
  1930. }
  1931. this.rule_idx = sheet.cssRules.length;
  1932. //default
  1933. var sel_before = '.f-dropdown.open:before',
  1934. sel_after = '.f-dropdown.open:after',
  1935. css_before = 'left: ' + pip_offset_base + 'px;',
  1936. css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
  1937. if (position.missRight == true) {
  1938. pip_offset_base = dropdown.outerWidth() - 23;
  1939. sel_before = '.f-dropdown.open:before',
  1940. sel_after = '.f-dropdown.open:after',
  1941. css_before = 'left: ' + pip_offset_base + 'px;',
  1942. css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
  1943. }
  1944. //just a case where right is fired, but its not missing right
  1945. if (position.triggeredRight == true) {
  1946. sel_before = '.f-dropdown.open:before',
  1947. sel_after = '.f-dropdown.open:after',
  1948. css_before = 'left:-12px;',
  1949. css_after = 'left:-14px;';
  1950. }
  1951. if (sheet.insertRule) {
  1952. sheet.insertRule([sel_before, '{', css_before, '}'].join(' '), this.rule_idx);
  1953. sheet.insertRule([sel_after, '{', css_after, '}'].join(' '), this.rule_idx + 1);
  1954. } else {
  1955. sheet.addRule(sel_before, css_before, this.rule_idx);
  1956. sheet.addRule(sel_after, css_after, this.rule_idx + 1);
  1957. }
  1958. },
  1959. // Remove old dropdown rule index
  1960. clear_idx : function () {
  1961. var sheet = Foundation.stylesheet;
  1962. if (typeof this.rule_idx !== 'undefined') {
  1963. sheet.deleteRule(this.rule_idx);
  1964. sheet.deleteRule(this.rule_idx);
  1965. delete this.rule_idx;
  1966. }
  1967. },
  1968. small : function () {
  1969. return matchMedia(Foundation.media_queries.small).matches &&
  1970. !matchMedia(Foundation.media_queries.medium).matches;
  1971. },
  1972. off : function () {
  1973. this.S(this.scope).off('.fndtn.dropdown');
  1974. this.S('html, body').off('.fndtn.dropdown');
  1975. this.S(window).off('.fndtn.dropdown');
  1976. this.S('[data-dropdown-content]').off('.fndtn.dropdown');
  1977. },
  1978. reflow : function () {}
  1979. };
  1980. }(jQuery, window, window.document));
  1981. ;(function ($, window, document, undefined) {
  1982. 'use strict';
  1983. Foundation.libs.equalizer = {
  1984. name : 'equalizer',
  1985. version : '5.5.3',
  1986. settings : {
  1987. use_tallest : true,
  1988. before_height_change : $.noop,
  1989. after_height_change : $.noop,
  1990. equalize_on_stack : false,
  1991. act_on_hidden_el: false
  1992. },
  1993. init : function (scope, method, options) {
  1994. Foundation.inherit(this, 'image_loaded');
  1995. this.bindings(method, options);
  1996. this.reflow();
  1997. },
  1998. events : function () {
  1999. this.S(window).off('.equalizer').on('resize.fndtn.equalizer', function (e) {
  2000. this.reflow();
  2001. }.bind(this));
  2002. },
  2003. equalize : function (equalizer) {
  2004. var isStacked = false,
  2005. group = equalizer.data('equalizer'),
  2006. settings = equalizer.data(this.attr_name(true)+'-init') || this.settings,
  2007. vals,
  2008. firstTopOffset;
  2009. if (settings.act_on_hidden_el) {
  2010. vals = group ? equalizer.find('['+this.attr_name()+'-watch="'+group+'"]') : equalizer.find('['+this.attr_name()+'-watch]');
  2011. }
  2012. else {
  2013. vals = group ? equalizer.find('['+this.attr_name()+'-watch="'+group+'"]:visible') : equalizer.find('['+this.attr_name()+'-watch]:visible');
  2014. }
  2015. if (vals.length === 0) {
  2016. return;
  2017. }
  2018. settings.before_height_change();
  2019. equalizer.trigger('before-height-change.fndth.equalizer');
  2020. vals.height('inherit');
  2021. if (settings.equalize_on_stack === false) {
  2022. firstTopOffset = vals.first().offset().top;
  2023. vals.each(function () {
  2024. if ($(this).offset().top !== firstTopOffset) {
  2025. isStacked = true;
  2026. return false;
  2027. }
  2028. });
  2029. if (isStacked) {
  2030. return;
  2031. }
  2032. }
  2033. var heights = vals.map(function () { return $(this).outerHeight(false) }).get();
  2034. if (settings.use_tallest) {
  2035. var max = Math.max.apply(null, heights);
  2036. vals.css('height', max);
  2037. } else {
  2038. var min = Math.min.apply(null, heights);
  2039. vals.css('height', min);
  2040. }
  2041. settings.after_height_change();
  2042. equalizer.trigger('after-height-change.fndtn.equalizer');
  2043. },
  2044. reflow : function () {
  2045. var self = this;
  2046. this.S('[' + this.attr_name() + ']', this.scope).each(function () {
  2047. var $eq_target = $(this),
  2048. media_query = $eq_target.data('equalizer-mq'),
  2049. ignore_media_query = true;
  2050. if (media_query) {
  2051. media_query = 'is_' + media_query.replace(/-/g, '_');
  2052. if (Foundation.utils.hasOwnProperty(media_query)) {
  2053. ignore_media_query = false;
  2054. }
  2055. }
  2056. self.image_loaded(self.S('img', this), function () {
  2057. if (ignore_media_query || Foundation.utils[media_query]()) {
  2058. self.equalize($eq_target)
  2059. } else {
  2060. var vals = $eq_target.find('[' + self.attr_name() + '-watch]:visible');
  2061. vals.css('height', 'auto');
  2062. }
  2063. });
  2064. });
  2065. }
  2066. };
  2067. })(jQuery, window, window.document);
  2068. ;(function ($, window, document, undefined) {
  2069. 'use strict';
  2070. Foundation.libs.interchange = {
  2071. name : 'interchange',
  2072. version : '5.5.3',
  2073. cache : {},
  2074. images_loaded : false,
  2075. nodes_loaded : false,
  2076. settings : {
  2077. load_attr : 'interchange',
  2078. named_queries : {
  2079. 'default' : 'only screen',
  2080. 'small' : Foundation.media_queries['small'],
  2081. 'small-only' : Foundation.media_queries['small-only'],
  2082. 'medium' : Foundation.media_queries['medium'],
  2083. 'medium-only' : Foundation.media_queries['medium-only'],
  2084. 'large' : Foundation.media_queries['large'],
  2085. 'large-only' : Foundation.media_queries['large-only'],
  2086. 'xlarge' : Foundation.media_queries['xlarge'],
  2087. 'xlarge-only' : Foundation.media_queries['xlarge-only'],
  2088. 'xxlarge' : Foundation.media_queries['xxlarge'],
  2089. 'landscape' : 'only screen and (orientation: landscape)',
  2090. 'portrait' : 'only screen and (orientation: portrait)',
  2091. 'retina' : 'only screen and (-webkit-min-device-pixel-ratio: 2),' +
  2092. 'only screen and (min--moz-device-pixel-ratio: 2),' +
  2093. 'only screen and (-o-min-device-pixel-ratio: 2/1),' +
  2094. 'only screen and (min-device-pixel-ratio: 2),' +
  2095. 'only screen and (min-resolution: 192dpi),' +
  2096. 'only screen and (min-resolution: 2dppx)'
  2097. },
  2098. directives : {
  2099. replace : function (el, path, trigger) {
  2100. // The trigger argument, if called within the directive, fires
  2101. // an event named after the directive on the element, passing
  2102. // any parameters along to the event that you pass to trigger.
  2103. //
  2104. // ex. trigger(), trigger([a, b, c]), or trigger(a, b, c)
  2105. //
  2106. // This allows you to bind a callback like so:
  2107. // $('#interchangeContainer').on('replace', function (e, a, b, c) {
  2108. // console.log($(this).html(), a, b, c);
  2109. // });
  2110. if (el !== null && /IMG/.test(el[0].nodeName)) {
  2111. var orig_path = $.each(el, function(){this.src = path;});
  2112. // var orig_path = el[0].src;
  2113. if (new RegExp(path, 'i').test(orig_path)) {
  2114. return;
  2115. }
  2116. el.attr("src", path);
  2117. return trigger(el[0].src);
  2118. }
  2119. var last_path = el.data(this.data_attr + '-last-path'),
  2120. self = this;
  2121. if (last_path == path) {
  2122. return;
  2123. }
  2124. if (/\.(gif|jpg|jpeg|tiff|png)([?#].*)?/i.test(path)) {
  2125. $(el).css('background-image', 'url(' + path + ')');
  2126. el.data('interchange-last-path', path);
  2127. return trigger(path);
  2128. }
  2129. return $.get(path, function (response) {
  2130. el.html(response);
  2131. el.data(self.data_attr + '-last-path', path);
  2132. trigger();
  2133. });
  2134. }
  2135. }
  2136. },
  2137. init : function (scope, method, options) {
  2138. Foundation.inherit(this, 'throttle random_str');
  2139. this.data_attr = this.set_data_attr();
  2140. $.extend(true, this.settings, method, options);
  2141. this.bindings(method, options);
  2142. this.reflow();
  2143. },
  2144. get_media_hash : function () {
  2145. var mediaHash = '';
  2146. for (var queryName in this.settings.named_queries ) {
  2147. mediaHash += matchMedia(this.settings.named_queries[queryName]).matches.toString();
  2148. }
  2149. return mediaHash;
  2150. },
  2151. events : function () {
  2152. var self = this, prevMediaHash;
  2153. $(window)
  2154. .off('.interchange')
  2155. .on('resize.fndtn.interchange', self.throttle(function () {
  2156. var currMediaHash = self.get_media_hash();
  2157. if (currMediaHash !== prevMediaHash) {
  2158. self.resize();
  2159. }
  2160. prevMediaHash = currMediaHash;
  2161. }, 50));
  2162. return this;
  2163. },
  2164. resize : function () {
  2165. var cache = this.cache;
  2166. if (!this.images_loaded || !this.nodes_loaded) {
  2167. setTimeout($.proxy(this.resize, this), 50);
  2168. return;
  2169. }
  2170. for (var uuid in cache) {
  2171. if (cache.hasOwnProperty(uuid)) {
  2172. var passed = this.results(uuid, cache[uuid]);
  2173. if (passed) {
  2174. this.settings.directives[passed
  2175. .scenario[1]].call(this, passed.el, passed.scenario[0], (function (passed) {
  2176. if (arguments[0] instanceof Array) {
  2177. var args = arguments[0];
  2178. } else {
  2179. var args = Array.prototype.slice.call(arguments, 0);
  2180. }
  2181. return function() {
  2182. passed.el.trigger(passed.scenario[1], args);
  2183. }
  2184. }(passed)));
  2185. }
  2186. }
  2187. }
  2188. },
  2189. results : function (uuid, scenarios) {
  2190. var count = scenarios.length;
  2191. if (count > 0) {
  2192. var el = this.S('[' + this.add_namespace('data-uuid') + '="' + uuid + '"]');
  2193. while (count--) {
  2194. var mq, rule = scenarios[count][2];
  2195. if (this.settings.named_queries.hasOwnProperty(rule)) {
  2196. mq = matchMedia(this.settings.named_queries[rule]);
  2197. } else {
  2198. mq = matchMedia(rule);
  2199. }
  2200. if (mq.matches) {
  2201. return {el : el, scenario : scenarios[count]};
  2202. }
  2203. }
  2204. }
  2205. return false;
  2206. },
  2207. load : function (type, force_update) {
  2208. if (typeof this['cached_' + type] === 'undefined' || force_update) {
  2209. this['update_' + type]();
  2210. }
  2211. return this['cached_' + type];
  2212. },
  2213. update_images : function () {
  2214. var images = this.S('img[' + this.data_attr + ']'),
  2215. count = images.length,
  2216. i = count,
  2217. loaded_count = 0,
  2218. data_attr = this.data_attr;
  2219. this.cache = {};
  2220. this.cached_images = [];
  2221. this.images_loaded = (count === 0);
  2222. while (i--) {
  2223. loaded_count++;
  2224. if (images[i]) {
  2225. var str = images[i].getAttribute(data_attr) || '';
  2226. if (str.length > 0) {
  2227. this.cached_images.push(images[i]);
  2228. }
  2229. }
  2230. if (loaded_count === count) {
  2231. this.images_loaded = true;
  2232. this.enhance('images');
  2233. }
  2234. }
  2235. return this;
  2236. },
  2237. update_nodes : function () {
  2238. var nodes = this.S('[' + this.data_attr + ']').not('img'),
  2239. count = nodes.length,
  2240. i = count,
  2241. loaded_count = 0,
  2242. data_attr = this.data_attr;
  2243. this.cached_nodes = [];
  2244. this.nodes_loaded = (count === 0);
  2245. while (i--) {
  2246. loaded_count++;
  2247. var str = nodes[i].getAttribute(data_attr) || '';
  2248. if (str.length > 0) {
  2249. this.cached_nodes.push(nodes[i]);
  2250. }
  2251. if (loaded_count === count) {
  2252. this.nodes_loaded = true;
  2253. this.enhance('nodes');
  2254. }
  2255. }
  2256. return this;
  2257. },
  2258. enhance : function (type) {
  2259. var i = this['cached_' + type].length;
  2260. while (i--) {
  2261. this.object($(this['cached_' + type][i]));
  2262. }
  2263. return $(window).trigger('resize.fndtn.interchange');
  2264. },
  2265. convert_directive : function (directive) {
  2266. var trimmed = this.trim(directive);
  2267. if (trimmed.length > 0) {
  2268. return trimmed;
  2269. }
  2270. return 'replace';
  2271. },
  2272. parse_scenario : function (scenario) {
  2273. // This logic had to be made more complex since some users were using commas in the url path
  2274. // So we cannot simply just split on a comma
  2275. var directive_match = scenario[0].match(/(.+),\s*(\w+)\s*$/),
  2276. // getting the mq has gotten a bit complicated since we started accounting for several use cases
  2277. // of URLs. For now we'll continue to match these scenarios, but we may consider having these scenarios
  2278. // as nested objects or arrays in F6.
  2279. // regex: match everything before close parenthesis for mq
  2280. media_query = scenario[1].match(/(.*)\)/);
  2281. if (directive_match) {
  2282. var path = directive_match[1],
  2283. directive = directive_match[2];
  2284. } else {
  2285. var cached_split = scenario[0].split(/,\s*$/),
  2286. path = cached_split[0],
  2287. directive = '';
  2288. }
  2289. return [this.trim(path), this.convert_directive(directive), this.trim(media_query[1])];
  2290. },
  2291. object : function (el) {
  2292. var raw_arr = this.parse_data_attr(el),
  2293. scenarios = [],
  2294. i = raw_arr.length;
  2295. if (i > 0) {
  2296. while (i--) {
  2297. // split array between comma delimited content and mq
  2298. // regex: comma, optional space, open parenthesis
  2299. var scenario = raw_arr[i].split(/,\s?\(/);
  2300. if (scenario.length > 1) {
  2301. var params = this.parse_scenario(scenario);
  2302. scenarios.push(params);
  2303. }
  2304. }
  2305. }
  2306. return this.store(el, scenarios);
  2307. },
  2308. store : function (el, scenarios) {
  2309. var uuid = this.random_str(),
  2310. current_uuid = el.data(this.add_namespace('uuid', true));
  2311. if (this.cache[current_uuid]) {
  2312. return this.cache[current_uuid];
  2313. }
  2314. el.attr(this.add_namespace('data-uuid'), uuid);
  2315. return this.cache[uuid] = scenarios;
  2316. },
  2317. trim : function (str) {
  2318. if (typeof str === 'string') {
  2319. return $.trim(str);
  2320. }
  2321. return str;
  2322. },
  2323. set_data_attr : function (init) {
  2324. if (init) {
  2325. if (this.namespace.length > 0) {
  2326. return this.namespace + '-' + this.settings.load_attr;
  2327. }
  2328. return this.settings.load_attr;
  2329. }
  2330. if (this.namespace.length > 0) {
  2331. return 'data-' + this.namespace + '-' + this.settings.load_attr;
  2332. }
  2333. return 'data-' + this.settings.load_attr;
  2334. },
  2335. parse_data_attr : function (el) {
  2336. var raw = el.attr(this.attr_name()).split(/\[(.*?)\]/),
  2337. i = raw.length,
  2338. output = [];
  2339. while (i--) {
  2340. if (raw[i].replace(/[\W\d]+/, '').length > 4) {
  2341. output.push(raw[i]);
  2342. }
  2343. }
  2344. return output;
  2345. },
  2346. reflow : function () {
  2347. this.load('images', true);
  2348. this.load('nodes', true);
  2349. }
  2350. };
  2351. }(jQuery, window, window.document));
  2352. ;(function ($, window, document, undefined) {
  2353. 'use strict';
  2354. var Modernizr = Modernizr || false;
  2355. Foundation.libs.joyride = {
  2356. name : 'joyride',
  2357. version : '5.5.3',
  2358. defaults : {
  2359. expose : false, // turn on or off the expose feature
  2360. modal : true, // Whether to cover page with modal during the tour
  2361. keyboard : true, // enable left, right and esc keystrokes
  2362. tip_location : 'bottom', // 'top', 'bottom', 'left' or 'right' in relation to parent
  2363. nub_position : 'auto', // override on a per tooltip bases
  2364. scroll_speed : 1500, // Page scrolling speed in milliseconds, 0 = no scroll animation
  2365. scroll_animation : 'linear', // supports 'swing' and 'linear', extend with jQuery UI.
  2366. timer : 0, // 0 = no timer , all other numbers = timer in milliseconds
  2367. start_timer_on_click : true, // true or false - true requires clicking the first button start the timer
  2368. start_offset : 0, // the index of the tooltip you want to start on (index of the li)
  2369. next_button : true, // true or false to control whether a next button is used
  2370. prev_button : true, // true or false to control whether a prev button is used
  2371. tip_animation : 'fade', // 'pop' or 'fade' in each tip
  2372. pause_after : [], // array of indexes where to pause the tour after
  2373. exposed : [], // array of expose elements
  2374. tip_animation_fade_speed : 300, // when tipAnimation = 'fade' this is speed in milliseconds for the transition
  2375. cookie_monster : false, // true or false to control whether cookies are used
  2376. cookie_name : 'joyride', // Name the cookie you'll use
  2377. cookie_domain : false, // Will this cookie be attached to a domain, ie. '.notableapp.com'
  2378. cookie_expires : 365, // set when you would like the cookie to expire.
  2379. tip_container : 'body', // Where will the tip be attached
  2380. abort_on_close : true, // When true, the close event will not fire any callback
  2381. tip_location_patterns : {
  2382. top : ['bottom'],
  2383. bottom : [], // bottom should not need to be repositioned
  2384. left : ['right', 'top', 'bottom'],
  2385. right : ['left', 'top', 'bottom']
  2386. },
  2387. post_ride_callback : function () {}, // A method to call once the tour closes (canceled or complete)
  2388. post_step_callback : function () {}, // A method to call after each step
  2389. pre_step_callback : function () {}, // A method to call before each step
  2390. pre_ride_callback : function () {}, // A method to call before the tour starts (passed index, tip, and cloned exposed element)
  2391. post_expose_callback : function () {}, // A method to call after an element has been exposed
  2392. template : { // HTML segments for tip layout
  2393. link : '<a href="#close" class="joyride-close-tip">&times;</a>',
  2394. timer : '<div class="joyride-timer-indicator-wrap"><span class="joyride-timer-indicator"></span></div>',
  2395. tip : '<div class="joyride-tip-guide"><span class="joyride-nub"></span></div>',
  2396. wrapper : '<div class="joyride-content-wrapper"></div>',
  2397. button : '<a href="#" class="small button joyride-next-tip"></a>',
  2398. prev_button : '<a href="#" class="small button joyride-prev-tip"></a>',
  2399. modal : '<div class="joyride-modal-bg"></div>',
  2400. expose : '<div class="joyride-expose-wrapper"></div>',
  2401. expose_cover : '<div class="joyride-expose-cover"></div>'
  2402. },
  2403. expose_add_class : '' // One or more space-separated class names to be added to exposed element
  2404. },
  2405. init : function (scope, method, options) {
  2406. Foundation.inherit(this, 'throttle random_str');
  2407. this.settings = this.settings || $.extend({}, this.defaults, (options || method));
  2408. this.bindings(method, options)
  2409. },
  2410. go_next : function () {
  2411. if (this.settings.$li.next().length < 1) {
  2412. this.end();
  2413. } else if (this.settings.timer > 0) {
  2414. clearTimeout(this.settings.automate);
  2415. this.hide();
  2416. this.show();
  2417. this.startTimer();
  2418. } else {
  2419. this.hide();
  2420. this.show();
  2421. }
  2422. },
  2423. go_prev : function () {
  2424. if (this.settings.$li.prev().length < 1) {
  2425. // Do nothing if there are no prev element
  2426. } else if (this.settings.timer > 0) {
  2427. clearTimeout(this.settings.automate);
  2428. this.hide();
  2429. this.show(null, true);
  2430. this.startTimer();
  2431. } else {
  2432. this.hide();
  2433. this.show(null, true);
  2434. }
  2435. },
  2436. events : function () {
  2437. var self = this;
  2438. $(this.scope)
  2439. .off('.joyride')
  2440. .on('click.fndtn.joyride', '.joyride-next-tip, .joyride-modal-bg', function (e) {
  2441. e.preventDefault();
  2442. this.go_next()
  2443. }.bind(this))
  2444. .on('click.fndtn.joyride', '.joyride-prev-tip', function (e) {
  2445. e.preventDefault();
  2446. this.go_prev();
  2447. }.bind(this))
  2448. .on('click.fndtn.joyride', '.joyride-close-tip', function (e) {
  2449. e.preventDefault();
  2450. this.end(this.settings.abort_on_close);
  2451. }.bind(this))
  2452. .on('keyup.fndtn.joyride', function (e) {
  2453. // Don't do anything if keystrokes are disabled
  2454. // or if the joyride is not being shown
  2455. if (!this.settings.keyboard || !this.settings.riding) {
  2456. return;
  2457. }
  2458. switch (e.which) {
  2459. case 39: // right arrow
  2460. e.preventDefault();
  2461. this.go_next();
  2462. break;
  2463. case 37: // left arrow
  2464. e.preventDefault();
  2465. this.go_prev();
  2466. break;
  2467. case 27: // escape
  2468. e.preventDefault();
  2469. this.end(this.settings.abort_on_close);
  2470. }
  2471. }.bind(this));
  2472. $(window)
  2473. .off('.joyride')
  2474. .on('resize.fndtn.joyride', self.throttle(function () {
  2475. if ($('[' + self.attr_name() + ']').length > 0 && self.settings.$next_tip && self.settings.riding) {
  2476. if (self.settings.exposed.length > 0) {
  2477. var $els = $(self.settings.exposed);
  2478. $els.each(function () {
  2479. var $this = $(this);
  2480. self.un_expose($this);
  2481. self.expose($this);
  2482. });
  2483. }
  2484. if (self.is_phone()) {
  2485. self.pos_phone();
  2486. } else {
  2487. self.pos_default(false);
  2488. }
  2489. }
  2490. }, 100));
  2491. },
  2492. start : function () {
  2493. var self = this,
  2494. $this = $('[' + this.attr_name() + ']', this.scope),
  2495. integer_settings = ['timer', 'scrollSpeed', 'startOffset', 'tipAnimationFadeSpeed', 'cookieExpires'],
  2496. int_settings_count = integer_settings.length;
  2497. if (!$this.length > 0) {
  2498. return;
  2499. }
  2500. if (!this.settings.init) {
  2501. this.events();
  2502. }
  2503. this.settings = $this.data(this.attr_name(true) + '-init');
  2504. // non configureable settings
  2505. this.settings.$content_el = $this;
  2506. this.settings.$body = $(this.settings.tip_container);
  2507. this.settings.body_offset = $(this.settings.tip_container).position();
  2508. this.settings.$tip_content = this.settings.$content_el.find('> li');
  2509. this.settings.paused = false;
  2510. this.settings.attempts = 0;
  2511. this.settings.riding = true;
  2512. // can we create cookies?
  2513. if (typeof $.cookie !== 'function') {
  2514. this.settings.cookie_monster = false;
  2515. }
  2516. // generate the tips and insert into dom.
  2517. if (!this.settings.cookie_monster || this.settings.cookie_monster && !$.cookie(this.settings.cookie_name)) {
  2518. this.settings.$tip_content.each(function (index) {
  2519. var $this = $(this);
  2520. this.settings = $.extend({}, self.defaults, self.data_options($this));
  2521. // Make sure that settings parsed from data_options are integers where necessary
  2522. var i = int_settings_count;
  2523. while (i--) {
  2524. self.settings[integer_settings[i]] = parseInt(self.settings[integer_settings[i]], 10);
  2525. }
  2526. self.create({$li : $this, index : index});
  2527. });
  2528. // show first tip
  2529. if (!this.settings.start_timer_on_click && this.settings.timer > 0) {
  2530. this.show('init');
  2531. this.startTimer();
  2532. } else {
  2533. this.show('init');
  2534. }
  2535. }
  2536. },
  2537. resume : function () {
  2538. this.set_li();
  2539. this.show();
  2540. },
  2541. tip_template : function (opts) {
  2542. var $blank, content;
  2543. opts.tip_class = opts.tip_class || '';
  2544. $blank = $(this.settings.template.tip).addClass(opts.tip_class);
  2545. content = $.trim($(opts.li).html()) +
  2546. this.prev_button_text(opts.prev_button_text, opts.index) +
  2547. this.button_text(opts.button_text) +
  2548. this.settings.template.link +
  2549. this.timer_instance(opts.index);
  2550. $blank.append($(this.settings.template.wrapper));
  2551. $blank.first().attr(this.add_namespace('data-index'), opts.index);
  2552. $('.joyride-content-wrapper', $blank).append(content);
  2553. return $blank[0];
  2554. },
  2555. timer_instance : function (index) {
  2556. var txt;
  2557. if ((index === 0 && this.settings.start_timer_on_click && this.settings.timer > 0) || this.settings.timer === 0) {
  2558. txt = '';
  2559. } else {
  2560. txt = $(this.settings.template.timer)[0].outerHTML;
  2561. }
  2562. return txt;
  2563. },
  2564. button_text : function (txt) {
  2565. if (this.settings.tip_settings.next_button) {
  2566. txt = $.trim(txt) || 'Next';
  2567. txt = $(this.settings.template.button).append(txt)[0].outerHTML;
  2568. } else {
  2569. txt = '';
  2570. }
  2571. return txt;
  2572. },
  2573. prev_button_text : function (txt, idx) {
  2574. if (this.settings.tip_settings.prev_button) {
  2575. txt = $.trim(txt) || 'Previous';
  2576. // Add the disabled class to the button if it's the first element
  2577. if (idx == 0) {
  2578. txt = $(this.settings.template.prev_button).append(txt).addClass('disabled')[0].outerHTML;
  2579. } else {
  2580. txt = $(this.settings.template.prev_button).append(txt)[0].outerHTML;
  2581. }
  2582. } else {
  2583. txt = '';
  2584. }
  2585. return txt;
  2586. },
  2587. create : function (opts) {
  2588. this.settings.tip_settings = $.extend({}, this.settings, this.data_options(opts.$li));
  2589. var buttonText = opts.$li.attr(this.add_namespace('data-button')) || opts.$li.attr(this.add_namespace('data-text')),
  2590. prevButtonText = opts.$li.attr(this.add_namespace('data-button-prev')) || opts.$li.attr(this.add_namespace('data-prev-text')),
  2591. tipClass = opts.$li.attr('class'),
  2592. $tip_content = $(this.tip_template({
  2593. tip_class : tipClass,
  2594. index : opts.index,
  2595. button_text : buttonText,
  2596. prev_button_text : prevButtonText,
  2597. li : opts.$li
  2598. }));
  2599. $(this.settings.tip_container).append($tip_content);
  2600. },
  2601. show : function (init, is_prev) {
  2602. var $timer = null;
  2603. // are we paused?
  2604. if (this.settings.$li === undefined || ($.inArray(this.settings.$li.index(), this.settings.pause_after) === -1)) {
  2605. // don't go to the next li if the tour was paused
  2606. if (this.settings.paused) {
  2607. this.settings.paused = false;
  2608. } else {
  2609. this.set_li(init, is_prev);
  2610. }
  2611. this.settings.attempts = 0;
  2612. if (this.settings.$li.length && this.settings.$target.length > 0) {
  2613. if (init) { //run when we first start
  2614. this.settings.pre_ride_callback(this.settings.$li.index(), this.settings.$next_tip);
  2615. if (this.settings.modal) {
  2616. this.show_modal();
  2617. }
  2618. }
  2619. this.settings.pre_step_callback(this.settings.$li.index(), this.settings.$next_tip);
  2620. if (this.settings.modal && this.settings.expose) {
  2621. this.expose();
  2622. }
  2623. this.settings.tip_settings = $.extend({}, this.settings, this.data_options(this.settings.$li));
  2624. this.settings.timer = parseInt(this.settings.timer, 10);
  2625. this.settings.tip_settings.tip_location_pattern = this.settings.tip_location_patterns[this.settings.tip_settings.tip_location];
  2626. // scroll and hide bg if not modal and not expose
  2627. if (!/body/i.test(this.settings.$target.selector) && !this.settings.expose) {
  2628. var joyridemodalbg = $('.joyride-modal-bg');
  2629. if (/pop/i.test(this.settings.tipAnimation)) {
  2630. joyridemodalbg.hide();
  2631. } else {
  2632. joyridemodalbg.fadeOut(this.settings.tipAnimationFadeSpeed);
  2633. }
  2634. this.scroll_to();
  2635. }
  2636. if (this.is_phone()) {
  2637. this.pos_phone(true);
  2638. } else {
  2639. this.pos_default(true);
  2640. }
  2641. $timer = this.settings.$next_tip.find('.joyride-timer-indicator');
  2642. if (/pop/i.test(this.settings.tip_animation)) {
  2643. $timer.width(0);
  2644. if (this.settings.timer > 0) {
  2645. this.settings.$next_tip.show();
  2646. setTimeout(function () {
  2647. $timer.animate({
  2648. width : $timer.parent().width()
  2649. }, this.settings.timer, 'linear');
  2650. }.bind(this), this.settings.tip_animation_fade_speed);
  2651. } else {
  2652. this.settings.$next_tip.show();
  2653. }
  2654. } else if (/fade/i.test(this.settings.tip_animation)) {
  2655. $timer.width(0);
  2656. if (this.settings.timer > 0) {
  2657. this.settings.$next_tip
  2658. .fadeIn(this.settings.tip_animation_fade_speed)
  2659. .show();
  2660. setTimeout(function () {
  2661. $timer.animate({
  2662. width : $timer.parent().width()
  2663. }, this.settings.timer, 'linear');
  2664. }.bind(this), this.settings.tip_animation_fade_speed);
  2665. } else {
  2666. this.settings.$next_tip.fadeIn(this.settings.tip_animation_fade_speed);
  2667. }
  2668. }
  2669. this.settings.$current_tip = this.settings.$next_tip;
  2670. // skip non-existant targets
  2671. } else if (this.settings.$li && this.settings.$target.length < 1) {
  2672. this.show(init, is_prev);
  2673. } else {
  2674. this.end();
  2675. }
  2676. } else {
  2677. this.settings.paused = true;
  2678. }
  2679. },
  2680. is_phone : function () {
  2681. return matchMedia(Foundation.media_queries.small).matches &&
  2682. !matchMedia(Foundation.media_queries.medium).matches;
  2683. },
  2684. hide : function () {
  2685. if (this.settings.modal && this.settings.expose) {
  2686. this.un_expose();
  2687. }
  2688. if (!this.settings.modal) {
  2689. $('.joyride-modal-bg').hide();
  2690. }
  2691. // Prevent scroll bouncing...wait to remove from layout
  2692. this.settings.$current_tip.css('visibility', 'hidden');
  2693. setTimeout($.proxy(function () {
  2694. this.hide();
  2695. this.css('visibility', 'visible');
  2696. }, this.settings.$current_tip), 0);
  2697. this.settings.post_step_callback(this.settings.$li.index(),
  2698. this.settings.$current_tip);
  2699. },
  2700. set_li : function (init, is_prev) {
  2701. if (init) {
  2702. this.settings.$li = this.settings.$tip_content.eq(this.settings.start_offset);
  2703. this.set_next_tip();
  2704. this.settings.$current_tip = this.settings.$next_tip;
  2705. } else {
  2706. if (is_prev) {
  2707. this.settings.$li = this.settings.$li.prev();
  2708. } else {
  2709. this.settings.$li = this.settings.$li.next();
  2710. }
  2711. this.set_next_tip();
  2712. }
  2713. this.set_target();
  2714. },
  2715. set_next_tip : function () {
  2716. this.settings.$next_tip = $('.joyride-tip-guide').eq(this.settings.$li.index());
  2717. this.settings.$next_tip.data('closed', '');
  2718. },
  2719. set_target : function () {
  2720. var cl = this.settings.$li.attr(this.add_namespace('data-class')),
  2721. id = this.settings.$li.attr(this.add_namespace('data-id')),
  2722. $sel = function () {
  2723. if (id) {
  2724. return $(document.getElementById(id));
  2725. } else if (cl) {
  2726. return $('.' + cl).first();
  2727. } else {
  2728. return $('body');
  2729. }
  2730. };
  2731. this.settings.$target = $sel();
  2732. },
  2733. scroll_to : function () {
  2734. var window_half, tipOffset;
  2735. window_half = $(window).height() / 2;
  2736. tipOffset = Math.ceil(this.settings.$target.offset().top - window_half + this.settings.$next_tip.outerHeight());
  2737. if (tipOffset != 0) {
  2738. $('html, body').stop().animate({
  2739. scrollTop : tipOffset
  2740. }, this.settings.scroll_speed, 'swing');
  2741. }
  2742. },
  2743. paused : function () {
  2744. return ($.inArray((this.settings.$li.index() + 1), this.settings.pause_after) === -1);
  2745. },
  2746. restart : function () {
  2747. this.hide();
  2748. this.settings.$li = undefined;
  2749. this.show('init');
  2750. },
  2751. pos_default : function (init) {
  2752. var $nub = this.settings.$next_tip.find('.joyride-nub'),
  2753. nub_width = Math.ceil($nub.outerWidth() / 2),
  2754. nub_height = Math.ceil($nub.outerHeight() / 2),
  2755. toggle = init || false;
  2756. // tip must not be "display: none" to calculate position
  2757. if (toggle) {
  2758. this.settings.$next_tip.css('visibility', 'hidden');
  2759. this.settings.$next_tip.show();
  2760. }
  2761. if (!/body/i.test(this.settings.$target.selector)) {
  2762. var topAdjustment = this.settings.tip_settings.tipAdjustmentY ? parseInt(this.settings.tip_settings.tipAdjustmentY) : 0,
  2763. leftAdjustment = this.settings.tip_settings.tipAdjustmentX ? parseInt(this.settings.tip_settings.tipAdjustmentX) : 0;
  2764. if (this.bottom()) {
  2765. if (this.rtl) {
  2766. this.settings.$next_tip.css({
  2767. top : (this.settings.$target.offset().top + nub_height + this.settings.$target.outerHeight() + topAdjustment),
  2768. left : this.settings.$target.offset().left + this.settings.$target.outerWidth() - this.settings.$next_tip.outerWidth() + leftAdjustment});
  2769. } else {
  2770. this.settings.$next_tip.css({
  2771. top : (this.settings.$target.offset().top + nub_height + this.settings.$target.outerHeight() + topAdjustment),
  2772. left : this.settings.$target.offset().left + leftAdjustment});
  2773. }
  2774. this.nub_position($nub, this.settings.tip_settings.nub_position, 'top');
  2775. } else if (this.top()) {
  2776. if (this.rtl) {
  2777. this.settings.$next_tip.css({
  2778. top : (this.settings.$target.offset().top - this.settings.$next_tip.outerHeight() - nub_height + topAdjustment),
  2779. left : this.settings.$target.offset().left + this.settings.$target.outerWidth() - this.settings.$next_tip.outerWidth()});
  2780. } else {
  2781. this.settings.$next_tip.css({
  2782. top : (this.settings.$target.offset().top - this.settings.$next_tip.outerHeight() - nub_height + topAdjustment),
  2783. left : this.settings.$target.offset().left + leftAdjustment});
  2784. }
  2785. this.nub_position($nub, this.settings.tip_settings.nub_position, 'bottom');
  2786. } else if (this.right()) {
  2787. this.settings.$next_tip.css({
  2788. top : this.settings.$target.offset().top + topAdjustment,
  2789. left : (this.settings.$target.outerWidth() + this.settings.$target.offset().left + nub_width + leftAdjustment)});
  2790. this.nub_position($nub, this.settings.tip_settings.nub_position, 'left');
  2791. } else if (this.left()) {
  2792. this.settings.$next_tip.css({
  2793. top : this.settings.$target.offset().top + topAdjustment,
  2794. left : (this.settings.$target.offset().left - this.settings.$next_tip.outerWidth() - nub_width + leftAdjustment)});
  2795. this.nub_position($nub, this.settings.tip_settings.nub_position, 'right');
  2796. }
  2797. if (!this.visible(this.corners(this.settings.$next_tip)) && this.settings.attempts < this.settings.tip_settings.tip_location_pattern.length) {
  2798. $nub.removeClass('bottom')
  2799. .removeClass('top')
  2800. .removeClass('right')
  2801. .removeClass('left');
  2802. this.settings.tip_settings.tip_location = this.settings.tip_settings.tip_location_pattern[this.settings.attempts];
  2803. this.settings.attempts++;
  2804. this.pos_default();
  2805. }
  2806. } else if (this.settings.$li.length) {
  2807. this.pos_modal($nub);
  2808. }
  2809. if (toggle) {
  2810. this.settings.$next_tip.hide();
  2811. this.settings.$next_tip.css('visibility', 'visible');
  2812. }
  2813. },
  2814. pos_phone : function (init) {
  2815. var tip_height = this.settings.$next_tip.outerHeight(),
  2816. tip_offset = this.settings.$next_tip.offset(),
  2817. target_height = this.settings.$target.outerHeight(),
  2818. $nub = $('.joyride-nub', this.settings.$next_tip),
  2819. nub_height = Math.ceil($nub.outerHeight() / 2),
  2820. toggle = init || false;
  2821. $nub.removeClass('bottom')
  2822. .removeClass('top')
  2823. .removeClass('right')
  2824. .removeClass('left');
  2825. if (toggle) {
  2826. this.settings.$next_tip.css('visibility', 'hidden');
  2827. this.settings.$next_tip.show();
  2828. }
  2829. if (!/body/i.test(this.settings.$target.selector)) {
  2830. if (this.top()) {
  2831. this.settings.$next_tip.offset({top : this.settings.$target.offset().top - tip_height - nub_height});
  2832. $nub.addClass('bottom');
  2833. } else {
  2834. this.settings.$next_tip.offset({top : this.settings.$target.offset().top + target_height + nub_height});
  2835. $nub.addClass('top');
  2836. }
  2837. } else if (this.settings.$li.length) {
  2838. this.pos_modal($nub);
  2839. }
  2840. if (toggle) {
  2841. this.settings.$next_tip.hide();
  2842. this.settings.$next_tip.css('visibility', 'visible');
  2843. }
  2844. },
  2845. pos_modal : function ($nub) {
  2846. this.center();
  2847. $nub.hide();
  2848. this.show_modal();
  2849. },
  2850. show_modal : function () {
  2851. if (!this.settings.$next_tip.data('closed')) {
  2852. var joyridemodalbg = $('.joyride-modal-bg');
  2853. if (joyridemodalbg.length < 1) {
  2854. var joyridemodalbg = $(this.settings.template.modal);
  2855. joyridemodalbg.appendTo('body');
  2856. }
  2857. if (/pop/i.test(this.settings.tip_animation)) {
  2858. joyridemodalbg.show();
  2859. } else {
  2860. joyridemodalbg.fadeIn(this.settings.tip_animation_fade_speed);
  2861. }
  2862. }
  2863. },
  2864. expose : function () {
  2865. var expose,
  2866. exposeCover,
  2867. el,
  2868. origCSS,
  2869. origClasses,
  2870. randId = 'expose-' + this.random_str(6);
  2871. if (arguments.length > 0 && arguments[0] instanceof $) {
  2872. el = arguments[0];
  2873. } else if (this.settings.$target && !/body/i.test(this.settings.$target.selector)) {
  2874. el = this.settings.$target;
  2875. } else {
  2876. return false;
  2877. }
  2878. if (el.length < 1) {
  2879. if (window.console) {
  2880. console.error('element not valid', el);
  2881. }
  2882. return false;
  2883. }
  2884. expose = $(this.settings.template.expose);
  2885. this.settings.$body.append(expose);
  2886. expose.css({
  2887. top : el.offset().top,
  2888. left : el.offset().left,
  2889. width : el.outerWidth(true),
  2890. height : el.outerHeight(true)
  2891. });
  2892. exposeCover = $(this.settings.template.expose_cover);
  2893. origCSS = {
  2894. zIndex : el.css('z-index'),
  2895. position : el.css('position')
  2896. };
  2897. origClasses = el.attr('class') == null ? '' : el.attr('class');
  2898. el.css('z-index', parseInt(expose.css('z-index')) + 1);
  2899. if (origCSS.position == 'static') {
  2900. el.css('position', 'relative');
  2901. }
  2902. el.data('expose-css', origCSS);
  2903. el.data('orig-class', origClasses);
  2904. el.attr('class', origClasses + ' ' + this.settings.expose_add_class);
  2905. exposeCover.css({
  2906. top : el.offset().top,
  2907. left : el.offset().left,
  2908. width : el.outerWidth(true),
  2909. height : el.outerHeight(true)
  2910. });
  2911. if (this.settings.modal) {
  2912. this.show_modal();
  2913. }
  2914. this.settings.$body.append(exposeCover);
  2915. expose.addClass(randId);
  2916. exposeCover.addClass(randId);
  2917. el.data('expose', randId);
  2918. this.settings.post_expose_callback(this.settings.$li.index(), this.settings.$next_tip, el);
  2919. this.add_exposed(el);
  2920. },
  2921. un_expose : function () {
  2922. var exposeId,
  2923. el,
  2924. expose,
  2925. origCSS,
  2926. origClasses,
  2927. clearAll = false;
  2928. if (arguments.length > 0 && arguments[0] instanceof $) {
  2929. el = arguments[0];
  2930. } else if (this.settings.$target && !/body/i.test(this.settings.$target.selector)) {
  2931. el = this.settings.$target;
  2932. } else {
  2933. return false;
  2934. }
  2935. if (el.length < 1) {
  2936. if (window.console) {
  2937. console.error('element not valid', el);
  2938. }
  2939. return false;
  2940. }
  2941. exposeId = el.data('expose');
  2942. expose = $('.' + exposeId);
  2943. if (arguments.length > 1) {
  2944. clearAll = arguments[1];
  2945. }
  2946. if (clearAll === true) {
  2947. $('.joyride-expose-wrapper,.joyride-expose-cover').remove();
  2948. } else {
  2949. expose.remove();
  2950. }
  2951. origCSS = el.data('expose-css');
  2952. if (origCSS.zIndex == 'auto') {
  2953. el.css('z-index', '');
  2954. } else {
  2955. el.css('z-index', origCSS.zIndex);
  2956. }
  2957. if (origCSS.position != el.css('position')) {
  2958. if (origCSS.position == 'static') {// this is default, no need to set it.
  2959. el.css('position', '');
  2960. } else {
  2961. el.css('position', origCSS.position);
  2962. }
  2963. }
  2964. origClasses = el.data('orig-class');
  2965. el.attr('class', origClasses);
  2966. el.removeData('orig-classes');
  2967. el.removeData('expose');
  2968. el.removeData('expose-z-index');
  2969. this.remove_exposed(el);
  2970. },
  2971. add_exposed : function (el) {
  2972. this.settings.exposed = this.settings.exposed || [];
  2973. if (el instanceof $ || typeof el === 'object') {
  2974. this.settings.exposed.push(el[0]);
  2975. } else if (typeof el == 'string') {
  2976. this.settings.exposed.push(el);
  2977. }
  2978. },
  2979. remove_exposed : function (el) {
  2980. var search, i;
  2981. if (el instanceof $) {
  2982. search = el[0]
  2983. } else if (typeof el == 'string') {
  2984. search = el;
  2985. }
  2986. this.settings.exposed = this.settings.exposed || [];
  2987. i = this.settings.exposed.length;
  2988. while (i--) {
  2989. if (this.settings.exposed[i] == search) {
  2990. this.settings.exposed.splice(i, 1);
  2991. return;
  2992. }
  2993. }
  2994. },
  2995. center : function () {
  2996. var $w = $(window);
  2997. this.settings.$next_tip.css({
  2998. top : ((($w.height() - this.settings.$next_tip.outerHeight()) / 2) + $w.scrollTop()),
  2999. left : ((($w.width() - this.settings.$next_tip.outerWidth()) / 2) + $w.scrollLeft())
  3000. });
  3001. return true;
  3002. },
  3003. bottom : function () {
  3004. return /bottom/i.test(this.settings.tip_settings.tip_location);
  3005. },
  3006. top : function () {
  3007. return /top/i.test(this.settings.tip_settings.tip_location);
  3008. },
  3009. right : function () {
  3010. return /right/i.test(this.settings.tip_settings.tip_location);
  3011. },
  3012. left : function () {
  3013. return /left/i.test(this.settings.tip_settings.tip_location);
  3014. },
  3015. corners : function (el) {
  3016. if (el.length === 0) {
  3017. return [false, false, false, false];
  3018. }
  3019. var w = $(window),
  3020. window_half = w.height() / 2,
  3021. //using this to calculate since scroll may not have finished yet.
  3022. tipOffset = Math.ceil(this.settings.$target.offset().top - window_half + this.settings.$next_tip.outerHeight()),
  3023. right = w.width() + w.scrollLeft(),
  3024. offsetBottom = w.height() + tipOffset,
  3025. bottom = w.height() + w.scrollTop(),
  3026. top = w.scrollTop();
  3027. if (tipOffset < top) {
  3028. if (tipOffset < 0) {
  3029. top = 0;
  3030. } else {
  3031. top = tipOffset;
  3032. }
  3033. }
  3034. if (offsetBottom > bottom) {
  3035. bottom = offsetBottom;
  3036. }
  3037. return [
  3038. el.offset().top < top,
  3039. right < el.offset().left + el.outerWidth(),
  3040. bottom < el.offset().top + el.outerHeight(),
  3041. w.scrollLeft() > el.offset().left
  3042. ];
  3043. },
  3044. visible : function (hidden_corners) {
  3045. var i = hidden_corners.length;
  3046. while (i--) {
  3047. if (hidden_corners[i]) {
  3048. return false;
  3049. }
  3050. }
  3051. return true;
  3052. },
  3053. nub_position : function (nub, pos, def) {
  3054. if (pos === 'auto') {
  3055. nub.addClass(def);
  3056. } else {
  3057. nub.addClass(pos);
  3058. }
  3059. },
  3060. startTimer : function () {
  3061. if (this.settings.$li.length) {
  3062. this.settings.automate = setTimeout(function () {
  3063. this.hide();
  3064. this.show();
  3065. this.startTimer();
  3066. }.bind(this), this.settings.timer);
  3067. } else {
  3068. clearTimeout(this.settings.automate);
  3069. }
  3070. },
  3071. end : function (abort) {
  3072. if (this.settings.cookie_monster) {
  3073. $.cookie(this.settings.cookie_name, 'ridden', {expires : this.settings.cookie_expires, domain : this.settings.cookie_domain});
  3074. }
  3075. if (this.settings.timer > 0) {
  3076. clearTimeout(this.settings.automate);
  3077. }
  3078. if (this.settings.modal && this.settings.expose) {
  3079. this.un_expose();
  3080. }
  3081. // Unplug keystrokes listener
  3082. $(this.scope).off('keyup.joyride')
  3083. this.settings.$next_tip.data('closed', true);
  3084. this.settings.riding = false;
  3085. $('.joyride-modal-bg').hide();
  3086. this.settings.$current_tip.hide();
  3087. if (typeof abort === 'undefined' || abort === false) {
  3088. this.settings.post_step_callback(this.settings.$li.index(), this.settings.$current_tip);
  3089. this.settings.post_ride_callback(this.settings.$li.index(), this.settings.$current_tip);
  3090. }
  3091. $('.joyride-tip-guide').remove();
  3092. },
  3093. off : function () {
  3094. $(this.scope).off('.joyride');
  3095. $(window).off('.joyride');
  3096. $('.joyride-close-tip, .joyride-next-tip, .joyride-modal-bg').off('.joyride');
  3097. $('.joyride-tip-guide, .joyride-modal-bg').remove();
  3098. clearTimeout(this.settings.automate);
  3099. },
  3100. reflow : function () {}
  3101. };
  3102. }(jQuery, window, window.document));
  3103. ;(function ($, window, document, undefined) {
  3104. 'use strict';
  3105. Foundation.libs['magellan-expedition'] = {
  3106. name : 'magellan-expedition',
  3107. version : '5.5.3',
  3108. settings : {
  3109. active_class : 'active',
  3110. threshold : 0, // pixels from the top of the expedition for it to become fixes
  3111. destination_threshold : 20, // pixels from the top of destination for it to be considered active
  3112. throttle_delay : 30, // calculation throttling to increase framerate
  3113. fixed_top : 0, // top distance in pixels assigend to the fixed element on scroll
  3114. offset_by_height : true, // whether to offset the destination by the expedition height. Usually you want this to be true, unless your expedition is on the side.
  3115. duration : 700, // animation duration time
  3116. easing : 'swing' // animation easing
  3117. },
  3118. init : function (scope, method, options) {
  3119. Foundation.inherit(this, 'throttle');
  3120. this.bindings(method, options);
  3121. },
  3122. events : function () {
  3123. var self = this,
  3124. S = self.S,
  3125. settings = self.settings;
  3126. // initialize expedition offset
  3127. self.set_expedition_position();
  3128. S(self.scope)
  3129. .off('.magellan')
  3130. .on('click.fndtn.magellan', '[' + self.add_namespace('data-magellan-arrival') + '] a[href*=#]', function (e) {
  3131. var sameHost = ((this.hostname === location.hostname) || !this.hostname),
  3132. samePath = self.filterPathname(location.pathname) === self.filterPathname(this.pathname),
  3133. testHash = this.hash.replace(/(:|\.|\/)/g, '\\$1'),
  3134. anchor = this;
  3135. if (sameHost && samePath && testHash) {
  3136. e.preventDefault();
  3137. var expedition = $(this).closest('[' + self.attr_name() + ']'),
  3138. settings = expedition.data('magellan-expedition-init'),
  3139. hash = this.hash.split('#').join(''),
  3140. target = $('a[name="' + hash + '"]');
  3141. if (target.length === 0) {
  3142. target = $('#' + hash);
  3143. }
  3144. // Account for expedition height if fixed position
  3145. var scroll_top = target.offset().top - settings.destination_threshold + 1;
  3146. if (settings.offset_by_height) {
  3147. scroll_top = scroll_top - expedition.outerHeight();
  3148. }
  3149. $('html, body').stop().animate({
  3150. 'scrollTop' : scroll_top
  3151. }, settings.duration, settings.easing, function () {
  3152. if (history.pushState) {
  3153. history.pushState(null, null, anchor.pathname + anchor.search + '#' + hash);
  3154. } else {
  3155. location.hash = anchor.pathname + anchor.search + '#' + hash;
  3156. }
  3157. });
  3158. }
  3159. })
  3160. .on('scroll.fndtn.magellan', self.throttle(this.check_for_arrivals.bind(this), settings.throttle_delay));
  3161. },
  3162. check_for_arrivals : function () {
  3163. var self = this;
  3164. self.update_arrivals();
  3165. self.update_expedition_positions();
  3166. },
  3167. set_expedition_position : function () {
  3168. var self = this;
  3169. $('[' + this.attr_name() + '=fixed]', self.scope).each(function (idx, el) {
  3170. var expedition = $(this),
  3171. settings = expedition.data('magellan-expedition-init'),
  3172. styles = expedition.attr('styles'), // save styles
  3173. top_offset, fixed_top;
  3174. expedition.attr('style', '');
  3175. top_offset = expedition.offset().top + settings.threshold;
  3176. //set fixed-top by attribute
  3177. fixed_top = parseInt(expedition.data('magellan-fixed-top'));
  3178. if (!isNaN(fixed_top)) {
  3179. self.settings.fixed_top = fixed_top;
  3180. }
  3181. expedition.data(self.data_attr('magellan-top-offset'), top_offset);
  3182. expedition.attr('style', styles);
  3183. });
  3184. },
  3185. update_expedition_positions : function () {
  3186. var self = this,
  3187. window_top_offset = $(window).scrollTop();
  3188. $('[' + this.attr_name() + '=fixed]', self.scope).each(function () {
  3189. var expedition = $(this),
  3190. settings = expedition.data('magellan-expedition-init'),
  3191. styles = expedition.attr('style'), // save styles
  3192. top_offset = expedition.data('magellan-top-offset');
  3193. //scroll to the top distance
  3194. if (window_top_offset + self.settings.fixed_top >= top_offset) {
  3195. // Placeholder allows height calculations to be consistent even when
  3196. // appearing to switch between fixed/non-fixed placement
  3197. var placeholder = expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']');
  3198. if (placeholder.length === 0) {
  3199. placeholder = expedition.clone();
  3200. placeholder.removeAttr(self.attr_name());
  3201. placeholder.attr(self.add_namespace('data-magellan-expedition-clone'), '');
  3202. expedition.before(placeholder);
  3203. }
  3204. expedition.css({position :'fixed', top : settings.fixed_top}).addClass('fixed');
  3205. } else {
  3206. expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']').remove();
  3207. expedition.attr('style', styles).css('position', '').css('top', '').removeClass('fixed');
  3208. }
  3209. });
  3210. },
  3211. update_arrivals : function () {
  3212. var self = this,
  3213. window_top_offset = $(window).scrollTop();
  3214. $('[' + this.attr_name() + ']', self.scope).each(function () {
  3215. var expedition = $(this),
  3216. settings = expedition.data(self.attr_name(true) + '-init'),
  3217. offsets = self.offsets(expedition, window_top_offset),
  3218. arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']'),
  3219. active_item = false;
  3220. offsets.each(function (idx, item) {
  3221. if (item.viewport_offset >= item.top_offset) {
  3222. var arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']');
  3223. arrivals.not(item.arrival).removeClass(settings.active_class);
  3224. item.arrival.addClass(settings.active_class);
  3225. active_item = true;
  3226. return true;
  3227. }
  3228. });
  3229. if (!active_item) {
  3230. arrivals.removeClass(settings.active_class);
  3231. }
  3232. });
  3233. },
  3234. offsets : function (expedition, window_offset) {
  3235. var self = this,
  3236. settings = expedition.data(self.attr_name(true) + '-init'),
  3237. viewport_offset = window_offset;
  3238. return expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']').map(function (idx, el) {
  3239. var name = $(this).data(self.data_attr('magellan-arrival')),
  3240. dest = $('[' + self.add_namespace('data-magellan-destination') + '=' + name + ']');
  3241. if (dest.length > 0) {
  3242. var top_offset = dest.offset().top - settings.destination_threshold;
  3243. if (settings.offset_by_height) {
  3244. top_offset = top_offset - expedition.outerHeight();
  3245. }
  3246. top_offset = Math.floor(top_offset);
  3247. return {
  3248. destination : dest,
  3249. arrival : $(this),
  3250. top_offset : top_offset,
  3251. viewport_offset : viewport_offset
  3252. }
  3253. }
  3254. }).sort(function (a, b) {
  3255. if (a.top_offset < b.top_offset) {
  3256. return -1;
  3257. }
  3258. if (a.top_offset > b.top_offset) {
  3259. return 1;
  3260. }
  3261. return 0;
  3262. });
  3263. },
  3264. data_attr : function (str) {
  3265. if (this.namespace.length > 0) {
  3266. return this.namespace + '-' + str;
  3267. }
  3268. return str;
  3269. },
  3270. off : function () {
  3271. this.S(this.scope).off('.magellan');
  3272. this.S(window).off('.magellan');
  3273. },
  3274. filterPathname : function (pathname) {
  3275. pathname = pathname || '';
  3276. return pathname
  3277. .replace(/^\//,'')
  3278. .replace(/(?:index|default).[a-zA-Z]{3,4}$/,'')
  3279. .replace(/\/$/,'');
  3280. },
  3281. reflow : function () {
  3282. var self = this;
  3283. // remove placeholder expeditions used for height calculation purposes
  3284. $('[' + self.add_namespace('data-magellan-expedition-clone') + ']', self.scope).remove();
  3285. }
  3286. };
  3287. }(jQuery, window, window.document));
  3288. ;(function ($, window, document, undefined) {
  3289. 'use strict';
  3290. Foundation.libs.offcanvas = {
  3291. name : 'offcanvas',
  3292. version : '5.5.3',
  3293. settings : {
  3294. open_method : 'move',
  3295. close_on_click : false
  3296. },
  3297. init : function (scope, method, options) {
  3298. this.bindings(method, options);
  3299. },
  3300. events : function () {
  3301. var self = this,
  3302. S = self.S,
  3303. move_class = '',
  3304. right_postfix = '',
  3305. left_postfix = '',
  3306. top_postfix = '',
  3307. bottom_postfix = '';
  3308. if (this.settings.open_method === 'move') {
  3309. move_class = 'move-';
  3310. right_postfix = 'right';
  3311. left_postfix = 'left';
  3312. top_postfix = 'top';
  3313. bottom_postfix = 'bottom';
  3314. } else if (this.settings.open_method === 'overlap_single') {
  3315. move_class = 'offcanvas-overlap-';
  3316. right_postfix = 'right';
  3317. left_postfix = 'left';
  3318. top_postfix = 'top';
  3319. bottom_postfix = 'bottom';
  3320. } else if (this.settings.open_method === 'overlap') {
  3321. move_class = 'offcanvas-overlap';
  3322. }
  3323. S(this.scope).off('.offcanvas')
  3324. .on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) {
  3325. self.click_toggle_class(e, move_class + right_postfix);
  3326. if (self.settings.open_method !== 'overlap') {
  3327. S('.left-submenu').removeClass(move_class + right_postfix);
  3328. }
  3329. $('.left-off-canvas-toggle').attr('aria-expanded', 'true');
  3330. })
  3331. .on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) {
  3332. var settings = self.get_settings(e);
  3333. var parent = S(this).parent();
  3334. if (settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')) {
  3335. self.hide.call(self, move_class + right_postfix, self.get_wrapper(e));
  3336. parent.parent().removeClass(move_class + right_postfix);
  3337. } else if (S(this).parent().hasClass('has-submenu')) {
  3338. e.preventDefault();
  3339. S(this).siblings('.left-submenu').toggleClass(move_class + right_postfix);
  3340. } else if (parent.hasClass('back')) {
  3341. e.preventDefault();
  3342. parent.parent().removeClass(move_class + right_postfix);
  3343. }
  3344. $('.left-off-canvas-toggle').attr('aria-expanded', 'true');
  3345. })
  3346. //end of left canvas
  3347. .on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
  3348. self.click_toggle_class(e, move_class + left_postfix);
  3349. if (self.settings.open_method !== 'overlap') {
  3350. S('.right-submenu').removeClass(move_class + left_postfix);
  3351. }
  3352. $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
  3353. })
  3354. .on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) {
  3355. var settings = self.get_settings(e);
  3356. var parent = S(this).parent();
  3357. if (settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')) {
  3358. self.hide.call(self, move_class + left_postfix, self.get_wrapper(e));
  3359. parent.parent().removeClass(move_class + left_postfix);
  3360. } else if (S(this).parent().hasClass('has-submenu')) {
  3361. e.preventDefault();
  3362. S(this).siblings('.right-submenu').toggleClass(move_class + left_postfix);
  3363. } else if (parent.hasClass('back')) {
  3364. e.preventDefault();
  3365. parent.parent().removeClass(move_class + left_postfix);
  3366. }
  3367. $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
  3368. })
  3369. //end of right canvas
  3370. .on('click.fndtn.offcanvas', '.top-off-canvas-toggle', function (e) {
  3371. self.click_toggle_class(e, move_class + bottom_postfix);
  3372. if (self.settings.open_method !== 'overlap') {
  3373. S('.top-submenu').removeClass(move_class + bottom_postfix);
  3374. }
  3375. $('.top-off-canvas-toggle').attr('aria-expanded', 'true');
  3376. })
  3377. .on('click.fndtn.offcanvas', '.top-off-canvas-menu a', function (e) {
  3378. var settings = self.get_settings(e);
  3379. var parent = S(this).parent();
  3380. if (settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')) {
  3381. self.hide.call(self, move_class + bottom_postfix, self.get_wrapper(e));
  3382. parent.parent().removeClass(move_class + bottom_postfix);
  3383. } else if (S(this).parent().hasClass('has-submenu')) {
  3384. e.preventDefault();
  3385. S(this).siblings('.top-submenu').toggleClass(move_class + bottom_postfix);
  3386. } else if (parent.hasClass('back')) {
  3387. e.preventDefault();
  3388. parent.parent().removeClass(move_class + bottom_postfix);
  3389. }
  3390. $('.top-off-canvas-toggle').attr('aria-expanded', 'true');
  3391. })
  3392. //end of top canvas
  3393. .on('click.fndtn.offcanvas', '.bottom-off-canvas-toggle', function (e) {
  3394. self.click_toggle_class(e, move_class + top_postfix);
  3395. if (self.settings.open_method !== 'overlap') {
  3396. S('.bottom-submenu').removeClass(move_class + top_postfix);
  3397. }
  3398. $('.bottom-off-canvas-toggle').attr('aria-expanded', 'true');
  3399. })
  3400. .on('click.fndtn.offcanvas', '.bottom-off-canvas-menu a', function (e) {
  3401. var settings = self.get_settings(e);
  3402. var parent = S(this).parent();
  3403. if (settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')) {
  3404. self.hide.call(self, move_class + top_postfix, self.get_wrapper(e));
  3405. parent.parent().removeClass(move_class + top_postfix);
  3406. } else if (S(this).parent().hasClass('has-submenu')) {
  3407. e.preventDefault();
  3408. S(this).siblings('.bottom-submenu').toggleClass(move_class + top_postfix);
  3409. } else if (parent.hasClass('back')) {
  3410. e.preventDefault();
  3411. parent.parent().removeClass(move_class + top_postfix);
  3412. }
  3413. $('.bottom-off-canvas-toggle').attr('aria-expanded', 'true');
  3414. })
  3415. //end of bottom
  3416. .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
  3417. self.click_remove_class(e, move_class + left_postfix);
  3418. S('.right-submenu').removeClass(move_class + left_postfix);
  3419. if (right_postfix) {
  3420. self.click_remove_class(e, move_class + right_postfix);
  3421. S('.left-submenu').removeClass(move_class + left_postfix);
  3422. }
  3423. $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
  3424. })
  3425. .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
  3426. self.click_remove_class(e, move_class + left_postfix);
  3427. $('.left-off-canvas-toggle').attr('aria-expanded', 'false');
  3428. if (right_postfix) {
  3429. self.click_remove_class(e, move_class + right_postfix);
  3430. $('.right-off-canvas-toggle').attr('aria-expanded', 'false');
  3431. }
  3432. })
  3433. .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
  3434. self.click_remove_class(e, move_class + top_postfix);
  3435. S('.bottom-submenu').removeClass(move_class + top_postfix);
  3436. if (bottom_postfix) {
  3437. self.click_remove_class(e, move_class + bottom_postfix);
  3438. S('.top-submenu').removeClass(move_class + top_postfix);
  3439. }
  3440. $('.bottom-off-canvas-toggle').attr('aria-expanded', 'true');
  3441. })
  3442. .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
  3443. self.click_remove_class(e, move_class + top_postfix);
  3444. $('.top-off-canvas-toggle').attr('aria-expanded', 'false');
  3445. if (bottom_postfix) {
  3446. self.click_remove_class(e, move_class + bottom_postfix);
  3447. $('.bottom-off-canvas-toggle').attr('aria-expanded', 'false');
  3448. }
  3449. });
  3450. },
  3451. toggle : function (class_name, $off_canvas) {
  3452. $off_canvas = $off_canvas || this.get_wrapper();
  3453. if ($off_canvas.is('.' + class_name)) {
  3454. this.hide(class_name, $off_canvas);
  3455. } else {
  3456. this.show(class_name, $off_canvas);
  3457. }
  3458. },
  3459. show : function (class_name, $off_canvas) {
  3460. $off_canvas = $off_canvas || this.get_wrapper();
  3461. $off_canvas.trigger('open.fndtn.offcanvas');
  3462. $off_canvas.addClass(class_name);
  3463. },
  3464. hide : function (class_name, $off_canvas) {
  3465. $off_canvas = $off_canvas || this.get_wrapper();
  3466. $off_canvas.trigger('close.fndtn.offcanvas');
  3467. $off_canvas.removeClass(class_name);
  3468. },
  3469. click_toggle_class : function (e, class_name) {
  3470. e.preventDefault();
  3471. var $off_canvas = this.get_wrapper(e);
  3472. this.toggle(class_name, $off_canvas);
  3473. },
  3474. click_remove_class : function (e, class_name) {
  3475. e.preventDefault();
  3476. var $off_canvas = this.get_wrapper(e);
  3477. this.hide(class_name, $off_canvas);
  3478. },
  3479. get_settings : function (e) {
  3480. var offcanvas = this.S(e.target).closest('[' + this.attr_name() + ']');
  3481. return offcanvas.data(this.attr_name(true) + '-init') || this.settings;
  3482. },
  3483. get_wrapper : function (e) {
  3484. var $off_canvas = this.S(e ? e.target : this.scope).closest('.off-canvas-wrap');
  3485. if ($off_canvas.length === 0) {
  3486. $off_canvas = this.S('.off-canvas-wrap');
  3487. }
  3488. return $off_canvas;
  3489. },
  3490. reflow : function () {}
  3491. };
  3492. }(jQuery, window, window.document));
  3493. ;(function ($, window, document, undefined) {
  3494. 'use strict';
  3495. var noop = function () {};
  3496. var Orbit = function (el, settings) {
  3497. // Don't reinitialize plugin
  3498. if (el.hasClass(settings.slides_container_class)) {
  3499. return this;
  3500. }
  3501. var self = this,
  3502. container,
  3503. slides_container = el,
  3504. number_container,
  3505. bullets_container,
  3506. timer_container,
  3507. idx = 0,
  3508. animate,
  3509. timer,
  3510. locked = false,
  3511. adjust_height_after = false;
  3512. self.slides = function () {
  3513. return slides_container.children(settings.slide_selector);
  3514. };
  3515. self.slides().first().addClass(settings.active_slide_class);
  3516. self.update_slide_number = function (index) {
  3517. if (settings.slide_number) {
  3518. number_container.find('span:first').text(parseInt(index) + 1);
  3519. number_container.find('span:last').text(self.slides().length);
  3520. }
  3521. if (settings.bullets) {
  3522. bullets_container.children().removeClass(settings.bullets_active_class);
  3523. $(bullets_container.children().get(index)).addClass(settings.bullets_active_class);
  3524. }
  3525. };
  3526. self.update_active_link = function (index) {
  3527. var link = $('[data-orbit-link="' + self.slides().eq(index).attr('data-orbit-slide') + '"]');
  3528. link.siblings().removeClass(settings.bullets_active_class);
  3529. link.addClass(settings.bullets_active_class);
  3530. };
  3531. self.build_markup = function () {
  3532. slides_container.wrap('<div class="' + settings.container_class + '"></div>');
  3533. container = slides_container.parent();
  3534. slides_container.addClass(settings.slides_container_class);
  3535. if (settings.stack_on_small) {
  3536. container.addClass(settings.stack_on_small_class);
  3537. }
  3538. if (settings.navigation_arrows) {
  3539. container.append($('<a href="#"><span></span></a>').addClass(settings.prev_class));
  3540. container.append($('<a href="#"><span></span></a>').addClass(settings.next_class));
  3541. }
  3542. if (settings.timer) {
  3543. timer_container = $('<div>').addClass(settings.timer_container_class);
  3544. timer_container.append('<span>');
  3545. timer_container.append($('<div>').addClass(settings.timer_progress_class));
  3546. timer_container.addClass(settings.timer_paused_class);
  3547. container.append(timer_container);
  3548. }
  3549. if (settings.slide_number) {
  3550. number_container = $('<div>').addClass(settings.slide_number_class);
  3551. number_container.append('<span></span> ' + settings.slide_number_text + ' <span></span>');
  3552. container.append(number_container);
  3553. }
  3554. if (settings.bullets) {
  3555. bullets_container = $('<ol>').addClass(settings.bullets_container_class);
  3556. container.append(bullets_container);
  3557. bullets_container.wrap('<div class="orbit-bullets-container"></div>');
  3558. self.slides().each(function (idx, el) {
  3559. var bullet = $('<li>').attr('data-orbit-slide', idx).on('click', self.link_bullet);;
  3560. bullets_container.append(bullet);
  3561. });
  3562. }
  3563. };
  3564. self._goto = function (next_idx, start_timer) {
  3565. // if (locked) {return false;}
  3566. if (next_idx === idx) {return false;}
  3567. if (typeof timer === 'object') {timer.restart();}
  3568. var slides = self.slides();
  3569. var dir = 'next';
  3570. locked = true;
  3571. if (next_idx < idx) {dir = 'prev';}
  3572. if (next_idx >= slides.length) {
  3573. if (!settings.circular) {
  3574. return false;
  3575. }
  3576. next_idx = 0;
  3577. } else if (next_idx < 0) {
  3578. if (!settings.circular) {
  3579. return false;
  3580. }
  3581. next_idx = slides.length - 1;
  3582. }
  3583. var current = $(slides.get(idx));
  3584. var next = $(slides.get(next_idx));
  3585. current.css('zIndex', 2);
  3586. current.removeClass(settings.active_slide_class);
  3587. next.css('zIndex', 4).addClass(settings.active_slide_class);
  3588. slides_container.trigger('before-slide-change.fndtn.orbit');
  3589. settings.before_slide_change();
  3590. self.update_active_link(next_idx);
  3591. var callback = function () {
  3592. var unlock = function () {
  3593. idx = next_idx;
  3594. locked = false;
  3595. if (start_timer === true) {timer = self.create_timer(); timer.start();}
  3596. self.update_slide_number(idx);
  3597. slides_container.trigger('after-slide-change.fndtn.orbit', [{slide_number : idx, total_slides : slides.length}]);
  3598. settings.after_slide_change(idx, slides.length);
  3599. };
  3600. if (slides_container.outerHeight() != next.outerHeight() && settings.variable_height) {
  3601. slides_container.animate({'height': next.outerHeight()}, 250, 'linear', unlock);
  3602. } else {
  3603. unlock();
  3604. }
  3605. };
  3606. if (slides.length === 1) {callback(); return false;}
  3607. var start_animation = function () {
  3608. if (dir === 'next') {animate.next(current, next, callback);}
  3609. if (dir === 'prev') {animate.prev(current, next, callback);}
  3610. };
  3611. if (next.outerHeight() > slides_container.outerHeight() && settings.variable_height) {
  3612. slides_container.animate({'height': next.outerHeight()}, 250, 'linear', start_animation);
  3613. } else {
  3614. start_animation();
  3615. }
  3616. };
  3617. self.next = function (e) {
  3618. e.stopImmediatePropagation();
  3619. e.preventDefault();
  3620. self._goto(idx + 1);
  3621. };
  3622. self.prev = function (e) {
  3623. e.stopImmediatePropagation();
  3624. e.preventDefault();
  3625. self._goto(idx - 1);
  3626. };
  3627. self.link_custom = function (e) {
  3628. e.preventDefault();
  3629. var link = $(this).attr('data-orbit-link');
  3630. if ((typeof link === 'string') && (link = $.trim(link)) != '') {
  3631. var slide = container.find('[data-orbit-slide=' + link + ']');
  3632. if (slide.index() != -1) {self._goto(slide.index());}
  3633. }
  3634. };
  3635. self.link_bullet = function (e) {
  3636. var index = $(this).attr('data-orbit-slide');
  3637. if ((typeof index === 'string') && (index = $.trim(index)) != '') {
  3638. if (isNaN(parseInt(index))) {
  3639. var slide = container.find('[data-orbit-slide=' + index + ']');
  3640. if (slide.index() != -1) {self._goto(slide.index() + 1);}
  3641. } else {
  3642. self._goto(parseInt(index));
  3643. }
  3644. }
  3645. }
  3646. self.timer_callback = function () {
  3647. self._goto(idx + 1, true);
  3648. }
  3649. self.compute_dimensions = function () {
  3650. var current = $(self.slides().get(idx));
  3651. var h = current.outerHeight();
  3652. if (!settings.variable_height) {
  3653. self.slides().each(function(){
  3654. if ($(this).outerHeight() > h) { h = $(this).outerHeight(); }
  3655. });
  3656. }
  3657. slides_container.height(h);
  3658. };
  3659. self.create_timer = function () {
  3660. var t = new Timer(
  3661. container.find('.' + settings.timer_container_class),
  3662. settings,
  3663. self.timer_callback
  3664. );
  3665. return t;
  3666. };
  3667. self.stop_timer = function () {
  3668. if (typeof timer === 'object') {
  3669. timer.stop();
  3670. }
  3671. };
  3672. self.toggle_timer = function () {
  3673. var t = container.find('.' + settings.timer_container_class);
  3674. if (t.hasClass(settings.timer_paused_class)) {
  3675. if (typeof timer === 'undefined') {timer = self.create_timer();}
  3676. timer.start();
  3677. } else {
  3678. if (typeof timer === 'object') {timer.stop();}
  3679. }
  3680. };
  3681. self.init = function () {
  3682. self.build_markup();
  3683. if (settings.timer) {
  3684. timer = self.create_timer();
  3685. Foundation.utils.image_loaded(this.slides().children('img'), timer.start);
  3686. }
  3687. animate = new FadeAnimation(settings, slides_container);
  3688. if (settings.animation === 'slide') {
  3689. animate = new SlideAnimation(settings, slides_container);
  3690. }
  3691. container.on('click', '.' + settings.next_class, self.next);
  3692. container.on('click', '.' + settings.prev_class, self.prev);
  3693. if (settings.next_on_click) {
  3694. container.on('click', '.' + settings.slides_container_class + ' [data-orbit-slide]', self.link_bullet);
  3695. }
  3696. container.on('click', self.toggle_timer);
  3697. if (settings.swipe) {
  3698. container.on('touchstart.fndtn.orbit', function (e) {
  3699. if (!e.touches) {e = e.originalEvent;}
  3700. var data = {
  3701. start_page_x : e.touches[0].pageX,
  3702. start_page_y : e.touches[0].pageY,
  3703. start_time : (new Date()).getTime(),
  3704. delta_x : 0,
  3705. is_scrolling : undefined
  3706. };
  3707. container.data('swipe-transition', data);
  3708. e.stopPropagation();
  3709. })
  3710. .on('touchmove.fndtn.orbit', function (e) {
  3711. if (!e.touches) {
  3712. e = e.originalEvent;
  3713. }
  3714. // Ignore pinch/zoom events
  3715. if (e.touches.length > 1 || e.scale && e.scale !== 1) {
  3716. return;
  3717. }
  3718. var data = container.data('swipe-transition');
  3719. if (typeof data === 'undefined') {data = {};}
  3720. data.delta_x = e.touches[0].pageX - data.start_page_x;
  3721. if ( typeof data.is_scrolling === 'undefined') {
  3722. data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
  3723. }
  3724. if (!data.is_scrolling && !data.active) {
  3725. e.preventDefault();
  3726. var direction = (data.delta_x < 0) ? (idx + 1) : (idx - 1);
  3727. data.active = true;
  3728. self._goto(direction);
  3729. }
  3730. })
  3731. .on('touchend.fndtn.orbit', function (e) {
  3732. container.data('swipe-transition', {});
  3733. e.stopPropagation();
  3734. })
  3735. }
  3736. container.on('mouseenter.fndtn.orbit', function (e) {
  3737. if (settings.timer && settings.pause_on_hover) {
  3738. self.stop_timer();
  3739. }
  3740. })
  3741. .on('mouseleave.fndtn.orbit', function (e) {
  3742. if (settings.timer && settings.resume_on_mouseout) {
  3743. timer.start();
  3744. }
  3745. });
  3746. $(document).on('click', '[data-orbit-link]', self.link_custom);
  3747. $(window).on('load resize', self.compute_dimensions);
  3748. Foundation.utils.image_loaded(this.slides().children('img'), self.compute_dimensions);
  3749. Foundation.utils.image_loaded(this.slides().children('img'), function () {
  3750. container.prev('.' + settings.preloader_class).css('display', 'none');
  3751. self.update_slide_number(0);
  3752. self.update_active_link(0);
  3753. slides_container.trigger('ready.fndtn.orbit');
  3754. });
  3755. };
  3756. self.init();
  3757. };
  3758. var Timer = function (el, settings, callback) {
  3759. var self = this,
  3760. duration = settings.timer_speed,
  3761. progress = el.find('.' + settings.timer_progress_class),
  3762. start,
  3763. timeout,
  3764. left = -1;
  3765. this.update_progress = function (w) {
  3766. var new_progress = progress.clone();
  3767. new_progress.attr('style', '');
  3768. new_progress.css('width', w + '%');
  3769. progress.replaceWith(new_progress);
  3770. progress = new_progress;
  3771. };
  3772. this.restart = function () {
  3773. clearTimeout(timeout);
  3774. el.addClass(settings.timer_paused_class);
  3775. left = -1;
  3776. self.update_progress(0);
  3777. };
  3778. this.start = function () {
  3779. if (!el.hasClass(settings.timer_paused_class)) {return true;}
  3780. left = (left === -1) ? duration : left;
  3781. el.removeClass(settings.timer_paused_class);
  3782. start = new Date().getTime();
  3783. progress.animate({'width' : '100%'}, left, 'linear');
  3784. timeout = setTimeout(function () {
  3785. self.restart();
  3786. callback();
  3787. }, left);
  3788. el.trigger('timer-started.fndtn.orbit')
  3789. };
  3790. this.stop = function () {
  3791. if (el.hasClass(settings.timer_paused_class)) {return true;}
  3792. clearTimeout(timeout);
  3793. el.addClass(settings.timer_paused_class);
  3794. var end = new Date().getTime();
  3795. left = left - (end - start);
  3796. var w = 100 - ((left / duration) * 100);
  3797. self.update_progress(w);
  3798. el.trigger('timer-stopped.fndtn.orbit');
  3799. };
  3800. };
  3801. var SlideAnimation = function (settings, container) {
  3802. var duration = settings.animation_speed;
  3803. var is_rtl = ($('html[dir=rtl]').length === 1);
  3804. var margin = is_rtl ? 'marginRight' : 'marginLeft';
  3805. var animMargin = {};
  3806. animMargin[margin] = '0%';
  3807. this.next = function (current, next, callback) {
  3808. current.animate({marginLeft : '-100%'}, duration);
  3809. next.animate(animMargin, duration, function () {
  3810. current.css(margin, '100%');
  3811. callback();
  3812. });
  3813. };
  3814. this.prev = function (current, prev, callback) {
  3815. current.animate({marginLeft : '100%'}, duration);
  3816. prev.css(margin, '-100%');
  3817. prev.animate(animMargin, duration, function () {
  3818. current.css(margin, '100%');
  3819. callback();
  3820. });
  3821. };
  3822. };
  3823. var FadeAnimation = function (settings, container) {
  3824. var duration = settings.animation_speed;
  3825. var is_rtl = ($('html[dir=rtl]').length === 1);
  3826. var margin = is_rtl ? 'marginRight' : 'marginLeft';
  3827. this.next = function (current, next, callback) {
  3828. next.css({'margin' : '0%', 'opacity' : '0.01'});
  3829. next.animate({'opacity' :'1'}, duration, 'linear', function () {
  3830. current.css('margin', '100%');
  3831. callback();
  3832. });
  3833. };
  3834. this.prev = function (current, prev, callback) {
  3835. prev.css({'margin' : '0%', 'opacity' : '0.01'});
  3836. prev.animate({'opacity' : '1'}, duration, 'linear', function () {
  3837. current.css('margin', '100%');
  3838. callback();
  3839. });
  3840. };
  3841. };
  3842. Foundation.libs = Foundation.libs || {};
  3843. Foundation.libs.orbit = {
  3844. name : 'orbit',
  3845. version : '5.5.3',
  3846. settings : {
  3847. animation : 'slide',
  3848. timer_speed : 10000,
  3849. pause_on_hover : true,
  3850. resume_on_mouseout : false,
  3851. next_on_click : true,
  3852. animation_speed : 500,
  3853. stack_on_small : false,
  3854. navigation_arrows : true,
  3855. slide_number : true,
  3856. slide_number_text : 'of',
  3857. container_class : 'orbit-container',
  3858. stack_on_small_class : 'orbit-stack-on-small',
  3859. next_class : 'orbit-next',
  3860. prev_class : 'orbit-prev',
  3861. timer_container_class : 'orbit-timer',
  3862. timer_paused_class : 'paused',
  3863. timer_progress_class : 'orbit-progress',
  3864. slides_container_class : 'orbit-slides-container',
  3865. preloader_class : 'preloader',
  3866. slide_selector : '*',
  3867. bullets_container_class : 'orbit-bullets',
  3868. bullets_active_class : 'active',
  3869. slide_number_class : 'orbit-slide-number',
  3870. caption_class : 'orbit-caption',
  3871. active_slide_class : 'active',
  3872. orbit_transition_class : 'orbit-transitioning',
  3873. bullets : true,
  3874. circular : true,
  3875. timer : true,
  3876. variable_height : false,
  3877. swipe : true,
  3878. before_slide_change : noop,
  3879. after_slide_change : noop
  3880. },
  3881. init : function (scope, method, options) {
  3882. var self = this;
  3883. this.bindings(method, options);
  3884. },
  3885. events : function (instance) {
  3886. var orbit_instance = new Orbit(this.S(instance), this.S(instance).data('orbit-init'));
  3887. this.S(instance).data(this.name + '-instance', orbit_instance);
  3888. },
  3889. reflow : function () {
  3890. var self = this;
  3891. if (self.S(self.scope).is('[data-orbit]')) {
  3892. var $el = self.S(self.scope);
  3893. var instance = $el.data(self.name + '-instance');
  3894. instance.compute_dimensions();
  3895. } else {
  3896. self.S('[data-orbit]', self.scope).each(function (idx, el) {
  3897. var $el = self.S(el);
  3898. var opts = self.data_options($el);
  3899. var instance = $el.data(self.name + '-instance');
  3900. instance.compute_dimensions();
  3901. });
  3902. }
  3903. }
  3904. };
  3905. }(jQuery, window, window.document));
  3906. ;(function ($, window, document, undefined) {
  3907. 'use strict';
  3908. var openModals = [];
  3909. Foundation.libs.reveal = {
  3910. name : 'reveal',
  3911. version : '5.5.3',
  3912. locked : false,
  3913. settings : {
  3914. animation : 'fadeAndPop',
  3915. animation_speed : 250,
  3916. close_on_background_click : true,
  3917. close_on_esc : true,
  3918. dismiss_modal_class : 'close-reveal-modal',
  3919. multiple_opened : false,
  3920. bg_class : 'reveal-modal-bg',
  3921. root_element : 'body',
  3922. open : function(){},
  3923. opened : function(){},
  3924. close : function(){},
  3925. closed : function(){},
  3926. on_ajax_error: $.noop,
  3927. bg : $('.reveal-modal-bg'),
  3928. css : {
  3929. open : {
  3930. 'opacity' : 0,
  3931. 'visibility' : 'visible',
  3932. 'display' : 'block'
  3933. },
  3934. close : {
  3935. 'opacity' : 1,
  3936. 'visibility' : 'hidden',
  3937. 'display' : 'none'
  3938. }
  3939. }
  3940. },
  3941. init : function (scope, method, options) {
  3942. $.extend(true, this.settings, method, options);
  3943. this.bindings(method, options);
  3944. },
  3945. events : function (scope) {
  3946. var self = this,
  3947. S = self.S;
  3948. S(this.scope)
  3949. .off('.reveal')
  3950. .on('click.fndtn.reveal', '[' + this.add_namespace('data-reveal-id') + ']:not([disabled])', function (e) {
  3951. e.preventDefault();
  3952. if (!self.locked) {
  3953. var element = S(this),
  3954. ajax = element.data(self.data_attr('reveal-ajax')),
  3955. replaceContentSel = element.data(self.data_attr('reveal-replace-content'));
  3956. self.locked = true;
  3957. if (typeof ajax === 'undefined') {
  3958. self.open.call(self, element);
  3959. } else {
  3960. var url = ajax === true ? element.attr('href') : ajax;
  3961. self.open.call(self, element, {url : url}, { replaceContentSel : replaceContentSel });
  3962. }
  3963. }
  3964. });
  3965. S(document)
  3966. .on('click.fndtn.reveal', this.close_targets(), function (e) {
  3967. e.preventDefault();
  3968. if (!self.locked) {
  3969. var settings = S('[' + self.attr_name() + '].open').data(self.attr_name(true) + '-init') || self.settings,
  3970. bg_clicked = S(e.target)[0] === S('.' + settings.bg_class)[0];
  3971. if (bg_clicked) {
  3972. if (settings.close_on_background_click) {
  3973. e.stopPropagation();
  3974. } else {
  3975. return;
  3976. }
  3977. }
  3978. self.locked = true;
  3979. self.close.call(self, bg_clicked ? S('[' + self.attr_name() + '].open:not(.toback)') : S(this).closest('[' + self.attr_name() + ']'));
  3980. }
  3981. });
  3982. if (S('[' + self.attr_name() + ']', this.scope).length > 0) {
  3983. S(this.scope)
  3984. // .off('.reveal')
  3985. .on('open.fndtn.reveal', this.settings.open)
  3986. .on('opened.fndtn.reveal', this.settings.opened)
  3987. .on('opened.fndtn.reveal', this.open_video)
  3988. .on('close.fndtn.reveal', this.settings.close)
  3989. .on('closed.fndtn.reveal', this.settings.closed)
  3990. .on('closed.fndtn.reveal', this.close_video);
  3991. } else {
  3992. S(this.scope)
  3993. // .off('.reveal')
  3994. .on('open.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.open)
  3995. .on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.opened)
  3996. .on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.open_video)
  3997. .on('close.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.close)
  3998. .on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.closed)
  3999. .on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.close_video);
  4000. }
  4001. return true;
  4002. },
  4003. // PATCH #3: turning on key up capture only when a reveal window is open
  4004. key_up_on : function (scope) {
  4005. var self = this;
  4006. // PATCH #1: fixing multiple keyup event trigger from single key press
  4007. self.S('body').off('keyup.fndtn.reveal').on('keyup.fndtn.reveal', function ( event ) {
  4008. var open_modal = self.S('[' + self.attr_name() + '].open'),
  4009. settings = open_modal.data(self.attr_name(true) + '-init') || self.settings ;
  4010. // PATCH #2: making sure that the close event can be called only while unlocked,
  4011. // so that multiple keyup.fndtn.reveal events don't prevent clean closing of the reveal window.
  4012. if ( settings && event.which === 27 && settings.close_on_esc && !self.locked) { // 27 is the keycode for the Escape key
  4013. self.close.call(self, open_modal);
  4014. }
  4015. });
  4016. return true;
  4017. },
  4018. // PATCH #3: turning on key up capture only when a reveal window is open
  4019. key_up_off : function (scope) {
  4020. this.S('body').off('keyup.fndtn.reveal');
  4021. return true;
  4022. },
  4023. open : function (target, ajax_settings) {
  4024. var self = this,
  4025. modal;
  4026. if (target) {
  4027. if (typeof target.selector !== 'undefined') {
  4028. // Find the named node; only use the first one found, since the rest of the code assumes there's only one node
  4029. modal = self.S('#' + target.data(self.data_attr('reveal-id'))).first();
  4030. } else {
  4031. modal = self.S(this.scope);
  4032. ajax_settings = target;
  4033. }
  4034. } else {
  4035. modal = self.S(this.scope);
  4036. }
  4037. var settings = modal.data(self.attr_name(true) + '-init');
  4038. settings = settings || this.settings;
  4039. if (modal.hasClass('open') && target !== undefined && target.attr('data-reveal-id') == modal.attr('id')) {
  4040. return self.close(modal);
  4041. }
  4042. if (!modal.hasClass('open')) {
  4043. var open_modal = self.S('[' + self.attr_name() + '].open');
  4044. if (typeof modal.data('css-top') === 'undefined') {
  4045. modal.data('css-top', parseInt(modal.css('top'), 10))
  4046. .data('offset', this.cache_offset(modal));
  4047. }
  4048. modal.attr('tabindex','0').attr('aria-hidden','false');
  4049. this.key_up_on(modal); // PATCH #3: turning on key up capture only when a reveal window is open
  4050. // Prevent namespace event from triggering twice
  4051. modal.on('open.fndtn.reveal', function(e) {
  4052. if (e.namespace !== 'fndtn.reveal') return;
  4053. });
  4054. modal.on('open.fndtn.reveal').trigger('open.fndtn.reveal');
  4055. if (open_modal.length < 1) {
  4056. this.toggle_bg(modal, true);
  4057. }
  4058. if (typeof ajax_settings === 'string') {
  4059. ajax_settings = {
  4060. url : ajax_settings
  4061. };
  4062. }
  4063. var openModal = function() {
  4064. if(open_modal.length > 0) {
  4065. if(settings.multiple_opened) {
  4066. self.to_back(open_modal);
  4067. } else {
  4068. self.hide(open_modal, settings.css.close);
  4069. }
  4070. }
  4071. // bl: add the open_modal that isn't already in the background to the openModals array
  4072. if(settings.multiple_opened) {
  4073. openModals.push(modal);
  4074. }
  4075. self.show(modal, settings.css.open);
  4076. };
  4077. if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
  4078. openModal();
  4079. } else {
  4080. var old_success = typeof ajax_settings.success !== 'undefined' ? ajax_settings.success : null;
  4081. $.extend(ajax_settings, {
  4082. success : function (data, textStatus, jqXHR) {
  4083. if ( $.isFunction(old_success) ) {
  4084. var result = old_success(data, textStatus, jqXHR);
  4085. if (typeof result == 'string') {
  4086. data = result;
  4087. }
  4088. }
  4089. if (typeof options !== 'undefined' && typeof options.replaceContentSel !== 'undefined') {
  4090. modal.find(options.replaceContentSel).html(data);
  4091. } else {
  4092. modal.html(data);
  4093. }
  4094. self.S(modal).foundation('section', 'reflow');
  4095. self.S(modal).children().foundation();
  4096. openModal();
  4097. }
  4098. });
  4099. // check for if user initalized with error callback
  4100. if (settings.on_ajax_error !== $.noop) {
  4101. $.extend(ajax_settings, {
  4102. error : settings.on_ajax_error
  4103. });
  4104. }
  4105. $.ajax(ajax_settings);
  4106. }
  4107. }
  4108. self.S(window).trigger('resize');
  4109. },
  4110. close : function (modal) {
  4111. var modal = modal && modal.length ? modal : this.S(this.scope),
  4112. open_modals = this.S('[' + this.attr_name() + '].open'),
  4113. settings = modal.data(this.attr_name(true) + '-init') || this.settings,
  4114. self = this;
  4115. if (open_modals.length > 0) {
  4116. modal.removeAttr('tabindex','0').attr('aria-hidden','true');
  4117. this.locked = true;
  4118. this.key_up_off(modal); // PATCH #3: turning on key up capture only when a reveal window is open
  4119. modal.trigger('close.fndtn.reveal');
  4120. if ((settings.multiple_opened && open_modals.length === 1) || !settings.multiple_opened || modal.length > 1) {
  4121. self.toggle_bg(modal, false);
  4122. self.to_front(modal);
  4123. }
  4124. if (settings.multiple_opened) {
  4125. var isCurrent = modal.is(':not(.toback)');
  4126. self.hide(modal, settings.css.close, settings);
  4127. if(isCurrent) {
  4128. // remove the last modal since it is now closed
  4129. openModals.pop();
  4130. } else {
  4131. // if this isn't the current modal, then find it in the array and remove it
  4132. openModals = $.grep(openModals, function(elt) {
  4133. var isThis = elt[0]===modal[0];
  4134. if(isThis) {
  4135. // since it's not currently in the front, put it in the front now that it is hidden
  4136. // so that if it's re-opened, it won't be .toback
  4137. self.to_front(modal);
  4138. }
  4139. return !isThis;
  4140. });
  4141. }
  4142. // finally, show the next modal in the stack, if there is one
  4143. if(openModals.length>0) {
  4144. self.to_front(openModals[openModals.length - 1]);
  4145. }
  4146. } else {
  4147. self.hide(open_modals, settings.css.close, settings);
  4148. }
  4149. }
  4150. },
  4151. close_targets : function () {
  4152. var base = '.' + this.settings.dismiss_modal_class;
  4153. if (this.settings.close_on_background_click) {
  4154. return base + ', .' + this.settings.bg_class;
  4155. }
  4156. return base;
  4157. },
  4158. toggle_bg : function (modal, state) {
  4159. if (this.S('.' + this.settings.bg_class).length === 0) {
  4160. this.settings.bg = $('<div />', {'class': this.settings.bg_class})
  4161. .appendTo('body').hide();
  4162. }
  4163. var visible = this.settings.bg.filter(':visible').length > 0;
  4164. if ( state != visible ) {
  4165. if ( state == undefined ? visible : !state ) {
  4166. this.hide(this.settings.bg);
  4167. } else {
  4168. this.show(this.settings.bg);
  4169. }
  4170. }
  4171. },
  4172. show : function (el, css) {
  4173. // is modal
  4174. if (css) {
  4175. var settings = el.data(this.attr_name(true) + '-init') || this.settings,
  4176. root_element = settings.root_element,
  4177. context = this;
  4178. if (el.parent(root_element).length === 0) {
  4179. var placeholder = el.wrap('<div style="display: none;" />').parent();
  4180. el.on('closed.fndtn.reveal.wrapped', function () {
  4181. el.detach().appendTo(placeholder);
  4182. el.unwrap().unbind('closed.fndtn.reveal.wrapped');
  4183. });
  4184. el.detach().appendTo(root_element);
  4185. }
  4186. var animData = getAnimationData(settings.animation);
  4187. if (!animData.animate) {
  4188. this.locked = false;
  4189. }
  4190. if (animData.pop) {
  4191. css.top = $(window).scrollTop() - el.data('offset') + 'px';
  4192. var end_css = {
  4193. top: $(window).scrollTop() + el.data('css-top') + 'px',
  4194. opacity: 1
  4195. };
  4196. return setTimeout(function () {
  4197. return el
  4198. .css(css)
  4199. .animate(end_css, settings.animation_speed, 'linear', function () {
  4200. context.locked = false;
  4201. el.trigger('opened.fndtn.reveal');
  4202. })
  4203. .addClass('open');
  4204. }, settings.animation_speed / 2);
  4205. }
  4206. css.top = $(window).scrollTop() + el.data('css-top') + 'px';
  4207. if (animData.fade) {
  4208. var end_css = {opacity: 1};
  4209. return setTimeout(function () {
  4210. return el
  4211. .css(css)
  4212. .animate(end_css, settings.animation_speed, 'linear', function () {
  4213. context.locked = false;
  4214. el.trigger('opened.fndtn.reveal');
  4215. })
  4216. .addClass('open');
  4217. }, settings.animation_speed / 2);
  4218. }
  4219. return el.css(css).show().css({opacity : 1}).addClass('open').trigger('opened.fndtn.reveal');
  4220. }
  4221. var settings = this.settings;
  4222. // should we animate the background?
  4223. if (getAnimationData(settings.animation).fade) {
  4224. return el.fadeIn(settings.animation_speed / 2);
  4225. }
  4226. this.locked = false;
  4227. return el.show();
  4228. },
  4229. to_back : function(el) {
  4230. el.addClass('toback');
  4231. },
  4232. to_front : function(el) {
  4233. el.removeClass('toback');
  4234. },
  4235. hide : function (el, css) {
  4236. // is modal
  4237. if (css) {
  4238. var settings = el.data(this.attr_name(true) + '-init'),
  4239. context = this;
  4240. settings = settings || this.settings;
  4241. var animData = getAnimationData(settings.animation);
  4242. if (!animData.animate) {
  4243. this.locked = false;
  4244. }
  4245. if (animData.pop) {
  4246. var end_css = {
  4247. top: - $(window).scrollTop() - el.data('offset') + 'px',
  4248. opacity: 0
  4249. };
  4250. return setTimeout(function () {
  4251. return el
  4252. .animate(end_css, settings.animation_speed, 'linear', function () {
  4253. context.locked = false;
  4254. el.css(css).trigger('closed.fndtn.reveal');
  4255. })
  4256. .removeClass('open');
  4257. }, settings.animation_speed / 2);
  4258. }
  4259. if (animData.fade) {
  4260. var end_css = {opacity : 0};
  4261. return setTimeout(function () {
  4262. return el
  4263. .animate(end_css, settings.animation_speed, 'linear', function () {
  4264. context.locked = false;
  4265. el.css(css).trigger('closed.fndtn.reveal');
  4266. })
  4267. .removeClass('open');
  4268. }, settings.animation_speed / 2);
  4269. }
  4270. return el.hide().css(css).removeClass('open').trigger('closed.fndtn.reveal');
  4271. }
  4272. var settings = this.settings;
  4273. // should we animate the background?
  4274. if (getAnimationData(settings.animation).fade) {
  4275. return el.fadeOut(settings.animation_speed / 2);
  4276. }
  4277. return el.hide();
  4278. },
  4279. close_video : function (e) {
  4280. var video = $('.flex-video', e.target),
  4281. iframe = $('iframe', video);
  4282. if (iframe.length > 0) {
  4283. iframe.attr('data-src', iframe[0].src);
  4284. iframe.attr('src', iframe.attr('src'));
  4285. video.hide();
  4286. }
  4287. },
  4288. open_video : function (e) {
  4289. var video = $('.flex-video', e.target),
  4290. iframe = video.find('iframe');
  4291. if (iframe.length > 0) {
  4292. var data_src = iframe.attr('data-src');
  4293. if (typeof data_src === 'string') {
  4294. iframe[0].src = iframe.attr('data-src');
  4295. } else {
  4296. var src = iframe[0].src;
  4297. iframe[0].src = undefined;
  4298. iframe[0].src = src;
  4299. }
  4300. video.show();
  4301. }
  4302. },
  4303. data_attr : function (str) {
  4304. if (this.namespace.length > 0) {
  4305. return this.namespace + '-' + str;
  4306. }
  4307. return str;
  4308. },
  4309. cache_offset : function (modal) {
  4310. var offset = modal.show().height() + parseInt(modal.css('top'), 10) + modal.scrollY;
  4311. modal.hide();
  4312. return offset;
  4313. },
  4314. off : function () {
  4315. $(this.scope).off('.fndtn.reveal');
  4316. },
  4317. reflow : function () {}
  4318. };
  4319. /*
  4320. * getAnimationData('popAndFade') // {animate: true, pop: true, fade: true}
  4321. * getAnimationData('fade') // {animate: true, pop: false, fade: true}
  4322. * getAnimationData('pop') // {animate: true, pop: true, fade: false}
  4323. * getAnimationData('foo') // {animate: false, pop: false, fade: false}
  4324. * getAnimationData(null) // {animate: false, pop: false, fade: false}
  4325. */
  4326. function getAnimationData(str) {
  4327. var fade = /fade/i.test(str);
  4328. var pop = /pop/i.test(str);
  4329. return {
  4330. animate : fade || pop,
  4331. pop : pop,
  4332. fade : fade
  4333. };
  4334. }
  4335. }(jQuery, window, window.document));
  4336. ;(function ($, window, document, undefined) {
  4337. 'use strict';
  4338. Foundation.libs.slider = {
  4339. name : 'slider',
  4340. version : '5.5.3',
  4341. settings : {
  4342. start : 0,
  4343. end : 100,
  4344. step : 1,
  4345. precision : 2,
  4346. initial : null,
  4347. display_selector : '',
  4348. vertical : false,
  4349. trigger_input_change : false,
  4350. on_change : function () {}
  4351. },
  4352. cache : {},
  4353. init : function (scope, method, options) {
  4354. Foundation.inherit(this, 'throttle');
  4355. this.bindings(method, options);
  4356. this.reflow();
  4357. },
  4358. events : function () {
  4359. var self = this;
  4360. $(this.scope)
  4361. .off('.slider')
  4362. .on('mousedown.fndtn.slider touchstart.fndtn.slider pointerdown.fndtn.slider',
  4363. '[' + self.attr_name() + ']:not(.disabled, [disabled]) .range-slider-handle', function (e) {
  4364. if (!self.cache.active) {
  4365. e.preventDefault();
  4366. self.set_active_slider($(e.target));
  4367. }
  4368. })
  4369. .on('mousemove.fndtn.slider touchmove.fndtn.slider pointermove.fndtn.slider', function (e) {
  4370. if (!!self.cache.active) {
  4371. e.preventDefault();
  4372. if ($.data(self.cache.active[0], 'settings').vertical) {
  4373. var scroll_offset = 0;
  4374. if (!e.pageY) {
  4375. scroll_offset = window.scrollY;
  4376. }
  4377. self.calculate_position(self.cache.active, self.get_cursor_position(e, 'y') + scroll_offset);
  4378. } else {
  4379. self.calculate_position(self.cache.active, self.get_cursor_position(e, 'x'));
  4380. }
  4381. }
  4382. })
  4383. .on('mouseup.fndtn.slider touchend.fndtn.slider pointerup.fndtn.slider', function (e) {
  4384. if(!self.cache.active) {
  4385. // if the user has just clicked into the slider without starting to drag the handle
  4386. var slider = $(e.target).attr('role') === 'slider' ? $(e.target) : $(e.target).closest('.range-slider').find("[role='slider']");
  4387. if (slider.length && (!slider.parent().hasClass('disabled') && !slider.parent().attr('disabled'))) {
  4388. self.set_active_slider(slider);
  4389. if ($.data(self.cache.active[0], 'settings').vertical) {
  4390. var scroll_offset = 0;
  4391. if (!e.pageY) {
  4392. scroll_offset = window.scrollY;
  4393. }
  4394. self.calculate_position(self.cache.active, self.get_cursor_position(e, 'y') + scroll_offset);
  4395. } else {
  4396. self.calculate_position(self.cache.active, self.get_cursor_position(e, 'x'));
  4397. }
  4398. }
  4399. }
  4400. self.remove_active_slider();
  4401. })
  4402. .on('change.fndtn.slider', function (e) {
  4403. self.settings.on_change();
  4404. });
  4405. self.S(window)
  4406. .on('resize.fndtn.slider', self.throttle(function (e) {
  4407. self.reflow();
  4408. }, 300));
  4409. // update slider value as users change input value
  4410. this.S('[' + this.attr_name() + ']').each(function () {
  4411. var slider = $(this),
  4412. handle = slider.children('.range-slider-handle')[0],
  4413. settings = self.initialize_settings(handle);
  4414. if (settings.display_selector != '') {
  4415. $(settings.display_selector).each(function(){
  4416. if ($(this).attr('value')) {
  4417. $(this).off('change').on('change', function () {
  4418. slider.foundation("slider", "set_value", $(this).val());
  4419. });
  4420. }
  4421. });
  4422. }
  4423. });
  4424. },
  4425. get_cursor_position : function (e, xy) {
  4426. var pageXY = 'page' + xy.toUpperCase(),
  4427. clientXY = 'client' + xy.toUpperCase(),
  4428. position;
  4429. if (typeof e[pageXY] !== 'undefined') {
  4430. position = e[pageXY];
  4431. } else if (typeof e.originalEvent[clientXY] !== 'undefined') {
  4432. position = e.originalEvent[clientXY];
  4433. } else if (e.originalEvent.touches && e.originalEvent.touches[0] && typeof e.originalEvent.touches[0][clientXY] !== 'undefined') {
  4434. position = e.originalEvent.touches[0][clientXY];
  4435. } else if (e.currentPoint && typeof e.currentPoint[xy] !== 'undefined') {
  4436. position = e.currentPoint[xy];
  4437. }
  4438. return position;
  4439. },
  4440. set_active_slider : function ($handle) {
  4441. this.cache.active = $handle;
  4442. },
  4443. remove_active_slider : function () {
  4444. this.cache.active = null;
  4445. },
  4446. calculate_position : function ($handle, cursor_x) {
  4447. var self = this,
  4448. settings = $.data($handle[0], 'settings'),
  4449. handle_l = $.data($handle[0], 'handle_l'),
  4450. handle_o = $.data($handle[0], 'handle_o'),
  4451. bar_l = $.data($handle[0], 'bar_l'),
  4452. bar_o = $.data($handle[0], 'bar_o');
  4453. requestAnimationFrame(function () {
  4454. var pct;
  4455. if (Foundation.rtl && !settings.vertical) {
  4456. pct = self.limit_to(((bar_o + bar_l - cursor_x) / bar_l), 0, 1);
  4457. } else {
  4458. pct = self.limit_to(((cursor_x - bar_o) / bar_l), 0, 1);
  4459. }
  4460. pct = settings.vertical ? 1 - pct : pct;
  4461. var norm = self.normalized_value(pct, settings.start, settings.end, settings.step, settings.precision);
  4462. self.set_ui($handle, norm);
  4463. });
  4464. },
  4465. set_ui : function ($handle, value) {
  4466. var settings = $.data($handle[0], 'settings'),
  4467. handle_l = $.data($handle[0], 'handle_l'),
  4468. bar_l = $.data($handle[0], 'bar_l'),
  4469. norm_pct = this.normalized_percentage(value, settings.start, settings.end),
  4470. handle_offset = norm_pct * (bar_l - handle_l) - 1,
  4471. progress_bar_length = norm_pct * 100,
  4472. $handle_parent = $handle.parent(),
  4473. $hidden_inputs = $handle.parent().children('input[type=hidden]');
  4474. if (Foundation.rtl && !settings.vertical) {
  4475. handle_offset = -handle_offset;
  4476. }
  4477. handle_offset = settings.vertical ? -handle_offset + bar_l - handle_l + 1 : handle_offset;
  4478. this.set_translate($handle, handle_offset, settings.vertical);
  4479. if (settings.vertical) {
  4480. $handle.siblings('.range-slider-active-segment').css('height', progress_bar_length + '%');
  4481. } else {
  4482. $handle.siblings('.range-slider-active-segment').css('width', progress_bar_length + '%');
  4483. }
  4484. $handle_parent.attr(this.attr_name(), value).trigger('change.fndtn.slider');
  4485. $hidden_inputs.val(value);
  4486. if (settings.trigger_input_change) {
  4487. $hidden_inputs.trigger('change.fndtn.slider');
  4488. }
  4489. if (!$handle[0].hasAttribute('aria-valuemin')) {
  4490. $handle.attr({
  4491. 'aria-valuemin' : settings.start,
  4492. 'aria-valuemax' : settings.end
  4493. });
  4494. }
  4495. $handle.attr('aria-valuenow', value);
  4496. if (settings.display_selector != '') {
  4497. $(settings.display_selector).each(function () {
  4498. if (this.hasAttribute('value')) {
  4499. $(this).val(value);
  4500. } else {
  4501. $(this).text(value);
  4502. }
  4503. });
  4504. }
  4505. },
  4506. normalized_percentage : function (val, start, end) {
  4507. return Math.min(1, (val - start) / (end - start));
  4508. },
  4509. normalized_value : function (val, start, end, step, precision) {
  4510. var range = end - start,
  4511. point = val * range,
  4512. mod = (point - (point % step)) / step,
  4513. rem = point % step,
  4514. round = ( rem >= step * 0.5 ? step : 0);
  4515. return ((mod * step + round) + start).toFixed(precision);
  4516. },
  4517. set_translate : function (ele, offset, vertical) {
  4518. if (vertical) {
  4519. $(ele)
  4520. .css('-webkit-transform', 'translateY(' + offset + 'px)')
  4521. .css('-moz-transform', 'translateY(' + offset + 'px)')
  4522. .css('-ms-transform', 'translateY(' + offset + 'px)')
  4523. .css('-o-transform', 'translateY(' + offset + 'px)')
  4524. .css('transform', 'translateY(' + offset + 'px)');
  4525. } else {
  4526. $(ele)
  4527. .css('-webkit-transform', 'translateX(' + offset + 'px)')
  4528. .css('-moz-transform', 'translateX(' + offset + 'px)')
  4529. .css('-ms-transform', 'translateX(' + offset + 'px)')
  4530. .css('-o-transform', 'translateX(' + offset + 'px)')
  4531. .css('transform', 'translateX(' + offset + 'px)');
  4532. }
  4533. },
  4534. limit_to : function (val, min, max) {
  4535. return Math.min(Math.max(val, min), max);
  4536. },
  4537. initialize_settings : function (handle) {
  4538. var settings = $.extend({}, this.settings, this.data_options($(handle).parent())),
  4539. decimal_places_match_result;
  4540. if (settings.precision === null) {
  4541. decimal_places_match_result = ('' + settings.step).match(/\.([\d]*)/);
  4542. settings.precision = decimal_places_match_result && decimal_places_match_result[1] ? decimal_places_match_result[1].length : 0;
  4543. }
  4544. if (settings.vertical) {
  4545. $.data(handle, 'bar_o', $(handle).parent().offset().top);
  4546. $.data(handle, 'bar_l', $(handle).parent().outerHeight());
  4547. $.data(handle, 'handle_o', $(handle).offset().top);
  4548. $.data(handle, 'handle_l', $(handle).outerHeight());
  4549. } else {
  4550. $.data(handle, 'bar_o', $(handle).parent().offset().left);
  4551. $.data(handle, 'bar_l', $(handle).parent().outerWidth());
  4552. $.data(handle, 'handle_o', $(handle).offset().left);
  4553. $.data(handle, 'handle_l', $(handle).outerWidth());
  4554. }
  4555. $.data(handle, 'bar', $(handle).parent());
  4556. return $.data(handle, 'settings', settings);
  4557. },
  4558. set_initial_position : function ($ele) {
  4559. var settings = $.data($ele.children('.range-slider-handle')[0], 'settings'),
  4560. initial = ((typeof settings.initial == 'number' && !isNaN(settings.initial)) ? settings.initial : Math.floor((settings.end - settings.start) * 0.5 / settings.step) * settings.step + settings.start),
  4561. $handle = $ele.children('.range-slider-handle');
  4562. this.set_ui($handle, initial);
  4563. },
  4564. set_value : function (value) {
  4565. var self = this;
  4566. $('[' + self.attr_name() + ']', this.scope).each(function () {
  4567. $(this).attr(self.attr_name(), value);
  4568. });
  4569. if (!!$(this.scope).attr(self.attr_name())) {
  4570. $(this.scope).attr(self.attr_name(), value);
  4571. }
  4572. self.reflow();
  4573. },
  4574. reflow : function () {
  4575. var self = this;
  4576. self.S('[' + this.attr_name() + ']').each(function () {
  4577. var handle = $(this).children('.range-slider-handle')[0],
  4578. val = $(this).attr(self.attr_name());
  4579. self.initialize_settings(handle);
  4580. if (val) {
  4581. self.set_ui($(handle), parseFloat(val));
  4582. } else {
  4583. self.set_initial_position($(this));
  4584. }
  4585. });
  4586. }
  4587. };
  4588. }(jQuery, window, window.document));
  4589. ;(function ($, window, document, undefined) {
  4590. 'use strict';
  4591. Foundation.libs.tab = {
  4592. name : 'tab',
  4593. version : '5.5.3',
  4594. settings : {
  4595. active_class : 'active',
  4596. callback : function () {},
  4597. deep_linking : false,
  4598. scroll_to_content : true,
  4599. is_hover : false
  4600. },
  4601. default_tab_hashes : [],
  4602. init : function (scope, method, options) {
  4603. var self = this,
  4604. S = this.S;
  4605. // Store the default active tabs which will be referenced when the
  4606. // location hash is absent, as in the case of navigating the tabs and
  4607. // returning to the first viewing via the browser Back button.
  4608. S('[' + this.attr_name() + '] > .active > a', this.scope).each(function () {
  4609. self.default_tab_hashes.push(this.hash);
  4610. });
  4611. this.bindings(method, options);
  4612. this.handle_location_hash_change();
  4613. },
  4614. events : function () {
  4615. var self = this,
  4616. S = this.S;
  4617. var usual_tab_behavior = function (e, target) {
  4618. var settings = S(target).closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init');
  4619. if (!settings.is_hover || Modernizr.touch) {
  4620. // if user did not pressed tab key, prevent default action
  4621. var keyCode = e.keyCode || e.which;
  4622. if (keyCode !== 9) {
  4623. e.preventDefault();
  4624. e.stopPropagation();
  4625. }
  4626. self.toggle_active_tab(S(target).parent());
  4627. }
  4628. };
  4629. S(this.scope)
  4630. .off('.tab')
  4631. // Key event: focus/tab key
  4632. .on('keydown.fndtn.tab', '[' + this.attr_name() + '] > * > a', function(e) {
  4633. var keyCode = e.keyCode || e.which;
  4634. // if user pressed tab key
  4635. if (keyCode === 13 || keyCode === 32) { // enter or space
  4636. var el = this;
  4637. usual_tab_behavior(e, el);
  4638. }
  4639. })
  4640. // Click event: tab title
  4641. .on('click.fndtn.tab', '[' + this.attr_name() + '] > * > a', function(e) {
  4642. var el = this;
  4643. usual_tab_behavior(e, el);
  4644. })
  4645. // Hover event: tab title
  4646. .on('mouseenter.fndtn.tab', '[' + this.attr_name() + '] > * > a', function (e) {
  4647. var settings = S(this).closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init');
  4648. if (settings.is_hover) {
  4649. self.toggle_active_tab(S(this).parent());
  4650. }
  4651. });
  4652. // Location hash change event
  4653. S(window).on('hashchange.fndtn.tab', function (e) {
  4654. e.preventDefault();
  4655. self.handle_location_hash_change();
  4656. });
  4657. },
  4658. handle_location_hash_change : function () {
  4659. var self = this,
  4660. S = this.S;
  4661. S('[' + this.attr_name() + ']', this.scope).each(function () {
  4662. var settings = S(this).data(self.attr_name(true) + '-init');
  4663. if (settings.deep_linking) {
  4664. // Match the location hash to a label
  4665. var hash;
  4666. if (settings.scroll_to_content) {
  4667. hash = self.scope.location.hash;
  4668. } else {
  4669. // prefix the hash to prevent anchor scrolling
  4670. hash = self.scope.location.hash.replace('fndtn-', '');
  4671. }
  4672. if (hash != '') {
  4673. // Check whether the location hash references a tab content div or
  4674. // another element on the page (inside or outside the tab content div)
  4675. var hash_element = S(hash);
  4676. if (hash_element.hasClass('content') && hash_element.parent().hasClass('tabs-content')) {
  4677. // Tab content div
  4678. self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=' + hash + ']').parent());
  4679. } else {
  4680. // Not the tab content div. If inside the tab content, find the
  4681. // containing tab and toggle it as active.
  4682. var hash_tab_container_id = hash_element.closest('.content').attr('id');
  4683. if (hash_tab_container_id != undefined) {
  4684. self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=#' + hash_tab_container_id + ']').parent(), hash);
  4685. }
  4686. }
  4687. } else {
  4688. // Reference the default tab hashes which were initialized in the init function
  4689. for (var ind = 0; ind < self.default_tab_hashes.length; ind++) {
  4690. self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=' + self.default_tab_hashes[ind] + ']').parent());
  4691. }
  4692. }
  4693. }
  4694. });
  4695. },
  4696. toggle_active_tab : function (tab, location_hash) {
  4697. var self = this,
  4698. S = self.S,
  4699. tabs = tab.closest('[' + this.attr_name() + ']'),
  4700. tab_link = tab.find('a'),
  4701. anchor = tab.children('a').first(),
  4702. target_hash = '#' + anchor.attr('href').split('#')[1],
  4703. target = S(target_hash),
  4704. siblings = tab.siblings(),
  4705. settings = tabs.data(this.attr_name(true) + '-init'),
  4706. interpret_keyup_action = function (e) {
  4707. // Light modification of Heydon Pickering's Practical ARIA Examples: http://heydonworks.com/practical_aria_examples/js/a11y.js
  4708. // define current, previous and next (possible) tabs
  4709. var $original = $(this);
  4710. var $prev = $(this).parents('li').prev().children('[role="tab"]');
  4711. var $next = $(this).parents('li').next().children('[role="tab"]');
  4712. var $target;
  4713. // find the direction (prev or next)
  4714. switch (e.keyCode) {
  4715. case 37:
  4716. $target = $prev;
  4717. break;
  4718. case 39:
  4719. $target = $next;
  4720. break;
  4721. default:
  4722. $target = false
  4723. break;
  4724. }
  4725. if ($target.length) {
  4726. $original.attr({
  4727. 'tabindex' : '-1',
  4728. 'aria-selected' : null
  4729. });
  4730. $target.attr({
  4731. 'tabindex' : '0',
  4732. 'aria-selected' : true
  4733. }).focus();
  4734. }
  4735. // Hide panels
  4736. $('[role="tabpanel"]')
  4737. .attr('aria-hidden', 'true');
  4738. // Show panel which corresponds to target
  4739. $('#' + $(document.activeElement).attr('href').substring(1))
  4740. .attr('aria-hidden', null);
  4741. },
  4742. go_to_hash = function(hash) {
  4743. // This function allows correct behaviour of the browser's back button when deep linking is enabled. Without it
  4744. // the user would get continually redirected to the default hash.
  4745. var default_hash = settings.scroll_to_content ? self.default_tab_hashes[0] : 'fndtn-' + self.default_tab_hashes[0].replace('#', '');
  4746. if (hash !== default_hash || window.location.hash) {
  4747. window.location.hash = hash;
  4748. }
  4749. };
  4750. // allow usage of data-tab-content attribute instead of href
  4751. if (anchor.data('tab-content')) {
  4752. target_hash = '#' + anchor.data('tab-content').split('#')[1];
  4753. target = S(target_hash);
  4754. }
  4755. if (settings.deep_linking) {
  4756. if (settings.scroll_to_content) {
  4757. // retain current hash to scroll to content
  4758. go_to_hash(location_hash || target_hash);
  4759. if (location_hash == undefined || location_hash == target_hash) {
  4760. tab.parent()[0].scrollIntoView();
  4761. } else {
  4762. S(target_hash)[0].scrollIntoView();
  4763. }
  4764. } else {
  4765. // prefix the hashes so that the browser doesn't scroll down
  4766. if (location_hash != undefined) {
  4767. go_to_hash('fndtn-' + location_hash.replace('#', ''));
  4768. } else {
  4769. go_to_hash('fndtn-' + target_hash.replace('#', ''));
  4770. }
  4771. }
  4772. }
  4773. // WARNING: The activation and deactivation of the tab content must
  4774. // occur after the deep linking in order to properly refresh the browser
  4775. // window (notably in Chrome).
  4776. // Clean up multiple attr instances to done once
  4777. tab.addClass(settings.active_class).triggerHandler('opened');
  4778. tab_link.attr({'aria-selected' : 'true', tabindex : 0});
  4779. siblings.removeClass(settings.active_class)
  4780. siblings.find('a').attr({'aria-selected' : 'false'/*, tabindex : -1*/});
  4781. target.siblings().removeClass(settings.active_class).attr({'aria-hidden' : 'true'/*, tabindex : -1*/});
  4782. target.addClass(settings.active_class).attr('aria-hidden', 'false').removeAttr('tabindex');
  4783. settings.callback(tab);
  4784. target.triggerHandler('toggled', [target]);
  4785. tabs.triggerHandler('toggled', [tab]);
  4786. tab_link.off('keydown').on('keydown', interpret_keyup_action );
  4787. },
  4788. data_attr : function (str) {
  4789. if (this.namespace.length > 0) {
  4790. return this.namespace + '-' + str;
  4791. }
  4792. return str;
  4793. },
  4794. off : function () {},
  4795. reflow : function () {}
  4796. };
  4797. }(jQuery, window, window.document));
  4798. ;(function ($, window, document, undefined) {
  4799. 'use strict';
  4800. Foundation.libs.tooltip = {
  4801. name : 'tooltip',
  4802. version : '5.5.3',
  4803. settings : {
  4804. additional_inheritable_classes : [],
  4805. tooltip_class : '.tooltip',
  4806. append_to : 'body',
  4807. touch_close_text : 'Tap To Close',
  4808. disable_for_touch : false,
  4809. hover_delay : 200,
  4810. fade_in_duration : 150,
  4811. fade_out_duration : 150,
  4812. show_on : 'all',
  4813. tip_template : function (selector, content) {
  4814. return '<span data-selector="' + selector + '" id="' + selector + '" class="'
  4815. + Foundation.libs.tooltip.settings.tooltip_class.substring(1)
  4816. + '" role="tooltip">' + content + '<span class="nub"></span></span>';
  4817. }
  4818. },
  4819. cache : {},
  4820. init : function (scope, method, options) {
  4821. Foundation.inherit(this, 'random_str');
  4822. this.bindings(method, options);
  4823. },
  4824. should_show : function (target, tip) {
  4825. var settings = $.extend({}, this.settings, this.data_options(target));
  4826. if (settings.show_on === 'all') {
  4827. return true;
  4828. } else if (this.small() && settings.show_on === 'small') {
  4829. return true;
  4830. } else if (this.medium() && settings.show_on === 'medium') {
  4831. return true;
  4832. } else if (this.large() && settings.show_on === 'large') {
  4833. return true;
  4834. }
  4835. return false;
  4836. },
  4837. medium : function () {
  4838. return matchMedia(Foundation.media_queries['medium']).matches;
  4839. },
  4840. large : function () {
  4841. return matchMedia(Foundation.media_queries['large']).matches;
  4842. },
  4843. events : function (instance) {
  4844. var self = this,
  4845. S = self.S;
  4846. self.create(this.S(instance));
  4847. function _startShow(elt, $this, immediate) {
  4848. if (elt.timer) {
  4849. return;
  4850. }
  4851. if (immediate) {
  4852. elt.timer = null;
  4853. self.showTip($this);
  4854. } else {
  4855. elt.timer = setTimeout(function () {
  4856. elt.timer = null;
  4857. self.showTip($this);
  4858. }.bind(elt), self.settings.hover_delay);
  4859. }
  4860. }
  4861. function _startHide(elt, $this) {
  4862. if (elt.timer) {
  4863. clearTimeout(elt.timer);
  4864. elt.timer = null;
  4865. }
  4866. self.hide($this);
  4867. }
  4868. $(this.scope)
  4869. .off('.tooltip')
  4870. .on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip',
  4871. '[' + this.attr_name() + ']', function (e) {
  4872. var $this = S(this),
  4873. settings = $.extend({}, self.settings, self.data_options($this)),
  4874. is_touch = false;
  4875. if (Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type) && S(e.target).is('a')) {
  4876. return false;
  4877. }
  4878. if (/mouse/i.test(e.type) && self.ie_touch(e)) {
  4879. return false;
  4880. }
  4881. if ($this.hasClass('open')) {
  4882. if (Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
  4883. e.preventDefault();
  4884. }
  4885. self.hide($this);
  4886. } else {
  4887. if (settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
  4888. return;
  4889. } else if (!settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
  4890. e.preventDefault();
  4891. S(settings.tooltip_class + '.open').hide();
  4892. is_touch = true;
  4893. // close other open tooltips on touch
  4894. if ($('.open[' + self.attr_name() + ']').length > 0) {
  4895. var prevOpen = S($('.open[' + self.attr_name() + ']')[0]);
  4896. self.hide(prevOpen);
  4897. }
  4898. }
  4899. if (/enter|over/i.test(e.type)) {
  4900. _startShow(this, $this);
  4901. } else if (e.type === 'mouseout' || e.type === 'mouseleave') {
  4902. _startHide(this, $this);
  4903. } else {
  4904. _startShow(this, $this, true);
  4905. }
  4906. }
  4907. })
  4908. .on('mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', '[' + this.attr_name() + '].open', function (e) {
  4909. if (/mouse/i.test(e.type) && self.ie_touch(e)) {
  4910. return false;
  4911. }
  4912. if ($(this).data('tooltip-open-event-type') == 'touch' && e.type == 'mouseleave') {
  4913. return;
  4914. } else if ($(this).data('tooltip-open-event-type') == 'mouse' && /MSPointerDown|touchstart/i.test(e.type)) {
  4915. self.convert_to_touch($(this));
  4916. } else {
  4917. _startHide(this, $(this));
  4918. }
  4919. })
  4920. .on('DOMNodeRemoved DOMAttrModified', '[' + this.attr_name() + ']:not(a)', function (e) {
  4921. _startHide(this, S(this));
  4922. });
  4923. },
  4924. ie_touch : function (e) {
  4925. // How do I distinguish between IE11 and Windows Phone 8?????
  4926. return false;
  4927. },
  4928. showTip : function ($target) {
  4929. var $tip = this.getTip($target);
  4930. if (this.should_show($target, $tip)) {
  4931. return this.show($target);
  4932. }
  4933. return;
  4934. },
  4935. getTip : function ($target) {
  4936. var selector = this.selector($target),
  4937. settings = $.extend({}, this.settings, this.data_options($target)),
  4938. tip = null;
  4939. if (selector) {
  4940. tip = this.S('span[data-selector="' + selector + '"]' + settings.tooltip_class);
  4941. }
  4942. return (typeof tip === 'object') ? tip : false;
  4943. },
  4944. selector : function ($target) {
  4945. var dataSelector = $target.attr(this.attr_name()) || $target.attr('data-selector');
  4946. if (typeof dataSelector != 'string') {
  4947. dataSelector = this.random_str(6);
  4948. $target
  4949. .attr('data-selector', dataSelector)
  4950. .attr('aria-describedby', dataSelector);
  4951. }
  4952. return dataSelector;
  4953. },
  4954. create : function ($target) {
  4955. var self = this,
  4956. settings = $.extend({}, this.settings, this.data_options($target)),
  4957. tip_template = this.settings.tip_template;
  4958. if (typeof settings.tip_template === 'string' && window.hasOwnProperty(settings.tip_template)) {
  4959. tip_template = window[settings.tip_template];
  4960. }
  4961. var $tip = $(tip_template(this.selector($target), $('<div></div>').html($target.attr('title')).html())),
  4962. classes = this.inheritable_classes($target);
  4963. $tip.addClass(classes).appendTo(settings.append_to);
  4964. if (Modernizr.touch) {
  4965. $tip.append('<span class="tap-to-close">' + settings.touch_close_text + '</span>');
  4966. $tip.on('touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', function (e) {
  4967. self.hide($target);
  4968. });
  4969. }
  4970. $target.removeAttr('title').attr('title', '');
  4971. },
  4972. reposition : function (target, tip, classes) {
  4973. var width, nub, nubHeight, nubWidth, objPos;
  4974. tip.css('visibility', 'hidden').show();
  4975. width = target.data('width');
  4976. nub = tip.children('.nub');
  4977. nubHeight = nub.outerHeight();
  4978. nubWidth = nub.outerWidth();
  4979. if (this.small()) {
  4980. tip.css({'width' : '100%'});
  4981. } else {
  4982. tip.css({'width' : (width) ? width : 'auto'});
  4983. }
  4984. objPos = function (obj, top, right, bottom, left, width) {
  4985. return obj.css({
  4986. 'top' : (top) ? top : 'auto',
  4987. 'bottom' : (bottom) ? bottom : 'auto',
  4988. 'left' : (left) ? left : 'auto',
  4989. 'right' : (right) ? right : 'auto'
  4990. }).end();
  4991. };
  4992. var o_top = target.offset().top;
  4993. var o_left = target.offset().left;
  4994. var outerHeight = target.outerHeight();
  4995. objPos(tip, (o_top + outerHeight + 10), 'auto', 'auto', o_left);
  4996. if (this.small()) {
  4997. objPos(tip, (o_top + outerHeight + 10), 'auto', 'auto', 12.5, $(this.scope).width());
  4998. tip.addClass('tip-override');
  4999. objPos(nub, -nubHeight, 'auto', 'auto', o_left);
  5000. } else {
  5001. if (Foundation.rtl) {
  5002. nub.addClass('rtl');
  5003. o_left = o_left + target.outerWidth() - tip.outerWidth();
  5004. }
  5005. objPos(tip, (o_top + outerHeight + 10), 'auto', 'auto', o_left);
  5006. // reset nub from small styles, if they've been applied
  5007. if (nub.attr('style')) {
  5008. nub.removeAttr('style');
  5009. }
  5010. tip.removeClass('tip-override');
  5011. var tip_outerHeight = tip.outerHeight();
  5012. if (classes && classes.indexOf('tip-top') > -1) {
  5013. if (Foundation.rtl) {
  5014. nub.addClass('rtl');
  5015. }
  5016. objPos(tip, (o_top - tip_outerHeight), 'auto', 'auto', o_left)
  5017. .removeClass('tip-override');
  5018. } else if (classes && classes.indexOf('tip-left') > -1) {
  5019. objPos(tip, (o_top + (outerHeight / 2) - (tip_outerHeight / 2)), 'auto', 'auto', (o_left - tip.outerWidth() - nubHeight))
  5020. .removeClass('tip-override');
  5021. nub.removeClass('rtl');
  5022. } else if (classes && classes.indexOf('tip-right') > -1) {
  5023. objPos(tip, (o_top + (outerHeight / 2) - (tip_outerHeight / 2)), 'auto', 'auto', (o_left + target.outerWidth() + nubHeight))
  5024. .removeClass('tip-override');
  5025. nub.removeClass('rtl');
  5026. }
  5027. }
  5028. tip.css('visibility', 'visible').hide();
  5029. },
  5030. small : function () {
  5031. return matchMedia(Foundation.media_queries.small).matches &&
  5032. !matchMedia(Foundation.media_queries.medium).matches;
  5033. },
  5034. inheritable_classes : function ($target) {
  5035. var settings = $.extend({}, this.settings, this.data_options($target)),
  5036. inheritables = ['tip-top', 'tip-left', 'tip-bottom', 'tip-right', 'radius', 'round'].concat(settings.additional_inheritable_classes),
  5037. classes = $target.attr('class'),
  5038. filtered = classes ? $.map(classes.split(' '), function (el, i) {
  5039. if ($.inArray(el, inheritables) !== -1) {
  5040. return el;
  5041. }
  5042. }).join(' ') : '';
  5043. return $.trim(filtered);
  5044. },
  5045. convert_to_touch : function ($target) {
  5046. var self = this,
  5047. $tip = self.getTip($target),
  5048. settings = $.extend({}, self.settings, self.data_options($target));
  5049. if ($tip.find('.tap-to-close').length === 0) {
  5050. $tip.append('<span class="tap-to-close">' + settings.touch_close_text + '</span>');
  5051. $tip.on('click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose MSPointerDown.fndtn.tooltip.tapclose', function (e) {
  5052. self.hide($target);
  5053. });
  5054. }
  5055. $target.data('tooltip-open-event-type', 'touch');
  5056. },
  5057. show : function ($target) {
  5058. var $tip = this.getTip($target);
  5059. if ($target.data('tooltip-open-event-type') == 'touch') {
  5060. this.convert_to_touch($target);
  5061. }
  5062. this.reposition($target, $tip, $target.attr('class'));
  5063. $target.addClass('open');
  5064. $tip.fadeIn(this.settings.fade_in_duration);
  5065. },
  5066. hide : function ($target) {
  5067. var $tip = this.getTip($target);
  5068. $tip.fadeOut(this.settings.fade_out_duration, function () {
  5069. $tip.find('.tap-to-close').remove();
  5070. $tip.off('click.fndtn.tooltip.tapclose MSPointerDown.fndtn.tapclose');
  5071. $target.removeClass('open');
  5072. });
  5073. },
  5074. off : function () {
  5075. var self = this;
  5076. this.S(this.scope).off('.fndtn.tooltip');
  5077. this.S(this.settings.tooltip_class).each(function (i) {
  5078. $('[' + self.attr_name() + ']').eq(i).attr('title', $(this).text());
  5079. }).remove();
  5080. },
  5081. reflow : function () {}
  5082. };
  5083. }(jQuery, window, window.document));
  5084. ;(function ($, window, document, undefined) {
  5085. 'use strict';
  5086. Foundation.libs.topbar = {
  5087. name : 'topbar',
  5088. version : '5.5.3',
  5089. settings : {
  5090. index : 0,
  5091. start_offset : 0,
  5092. sticky_class : 'sticky',
  5093. custom_back_text : true,
  5094. back_text : 'Back',
  5095. mobile_show_parent_link : true,
  5096. is_hover : true,
  5097. scrolltop : true, // jump to top when sticky nav menu toggle is clicked
  5098. sticky_on : 'all',
  5099. dropdown_autoclose: true
  5100. },
  5101. init : function (section, method, options) {
  5102. Foundation.inherit(this, 'add_custom_rule register_media throttle');
  5103. var self = this;
  5104. self.register_media('topbar', 'foundation-mq-topbar');
  5105. this.bindings(method, options);
  5106. self.S('[' + this.attr_name() + ']', this.scope).each(function () {
  5107. var topbar = $(this),
  5108. settings = topbar.data(self.attr_name(true) + '-init'),
  5109. section = self.S('section, .top-bar-section', this);
  5110. topbar.data('index', 0);
  5111. var topbarContainer = topbar.parent();
  5112. if (topbarContainer.hasClass('fixed') || self.is_sticky(topbar, topbarContainer, settings) ) {
  5113. self.settings.sticky_class = settings.sticky_class;
  5114. self.settings.sticky_topbar = topbar;
  5115. topbar.data('height', topbarContainer.outerHeight());
  5116. topbar.data('stickyoffset', topbarContainer.offset().top);
  5117. } else {
  5118. topbar.data('height', topbar.outerHeight());
  5119. }
  5120. if (!settings.assembled) {
  5121. self.assemble(topbar);
  5122. }
  5123. if (settings.is_hover) {
  5124. self.S('.has-dropdown', topbar).addClass('not-click');
  5125. } else {
  5126. self.S('.has-dropdown', topbar).removeClass('not-click');
  5127. }
  5128. // Pad body when sticky (scrolled) or fixed.
  5129. self.add_custom_rule('.f-topbar-fixed { padding-top: ' + topbar.data('height') + 'px }');
  5130. if (topbarContainer.hasClass('fixed')) {
  5131. self.S('body').addClass('f-topbar-fixed');
  5132. }
  5133. });
  5134. },
  5135. is_sticky : function (topbar, topbarContainer, settings) {
  5136. var sticky = topbarContainer.hasClass(settings.sticky_class);
  5137. var smallMatch = matchMedia(Foundation.media_queries.small).matches;
  5138. var medMatch = matchMedia(Foundation.media_queries.medium).matches;
  5139. var lrgMatch = matchMedia(Foundation.media_queries.large).matches;
  5140. if (sticky && settings.sticky_on === 'all') {
  5141. return true;
  5142. }
  5143. if (sticky && this.small() && settings.sticky_on.indexOf('small') !== -1) {
  5144. if (smallMatch && !medMatch && !lrgMatch) { return true; }
  5145. }
  5146. if (sticky && this.medium() && settings.sticky_on.indexOf('medium') !== -1) {
  5147. if (smallMatch && medMatch && !lrgMatch) { return true; }
  5148. }
  5149. if (sticky && this.large() && settings.sticky_on.indexOf('large') !== -1) {
  5150. if (smallMatch && medMatch && lrgMatch) { return true; }
  5151. }
  5152. return false;
  5153. },
  5154. toggle : function (toggleEl) {
  5155. var self = this,
  5156. topbar;
  5157. if (toggleEl) {
  5158. topbar = self.S(toggleEl).closest('[' + this.attr_name() + ']');
  5159. } else {
  5160. topbar = self.S('[' + this.attr_name() + ']');
  5161. }
  5162. var settings = topbar.data(this.attr_name(true) + '-init');
  5163. var section = self.S('section, .top-bar-section', topbar);
  5164. if (self.breakpoint()) {
  5165. if (!self.rtl) {
  5166. section.css({left : '0%'});
  5167. $('>.name', section).css({left : '100%'});
  5168. } else {
  5169. section.css({right : '0%'});
  5170. $('>.name', section).css({right : '100%'});
  5171. }
  5172. self.S('li.moved', section).removeClass('moved');
  5173. topbar.data('index', 0);
  5174. topbar
  5175. .toggleClass('expanded')
  5176. .css('height', '');
  5177. }
  5178. if (settings.scrolltop) {
  5179. if (!topbar.hasClass('expanded')) {
  5180. if (topbar.hasClass('fixed')) {
  5181. topbar.parent().addClass('fixed');
  5182. topbar.removeClass('fixed');
  5183. self.S('body').addClass('f-topbar-fixed');
  5184. }
  5185. } else if (topbar.parent().hasClass('fixed')) {
  5186. if (settings.scrolltop) {
  5187. topbar.parent().removeClass('fixed');
  5188. topbar.addClass('fixed');
  5189. self.S('body').removeClass('f-topbar-fixed');
  5190. window.scrollTo(0, 0);
  5191. } else {
  5192. topbar.parent().removeClass('expanded');
  5193. }
  5194. }
  5195. } else {
  5196. if (self.is_sticky(topbar, topbar.parent(), settings)) {
  5197. topbar.parent().addClass('fixed');
  5198. }
  5199. if (topbar.parent().hasClass('fixed')) {
  5200. if (!topbar.hasClass('expanded')) {
  5201. topbar.removeClass('fixed');
  5202. topbar.parent().removeClass('expanded');
  5203. self.update_sticky_positioning();
  5204. } else {
  5205. topbar.addClass('fixed');
  5206. topbar.parent().addClass('expanded');
  5207. self.S('body').addClass('f-topbar-fixed');
  5208. }
  5209. }
  5210. }
  5211. },
  5212. timer : null,
  5213. events : function (bar) {
  5214. var self = this,
  5215. S = this.S;
  5216. S(this.scope)
  5217. .off('.topbar')
  5218. .on('click.fndtn.topbar', '[' + this.attr_name() + '] .toggle-topbar', function (e) {
  5219. e.preventDefault();
  5220. self.toggle(this);
  5221. })
  5222. .on('click.fndtn.topbar contextmenu.fndtn.topbar', '.top-bar .top-bar-section li a[href^="#"],[' + this.attr_name() + '] .top-bar-section li a[href^="#"]', function (e) {
  5223. var li = $(this).closest('li'),
  5224. topbar = li.closest('[' + self.attr_name() + ']'),
  5225. settings = topbar.data(self.attr_name(true) + '-init');
  5226. if (settings.dropdown_autoclose && settings.is_hover) {
  5227. var hoverLi = $(this).closest('.hover');
  5228. hoverLi.removeClass('hover');
  5229. }
  5230. if (self.breakpoint() && !li.hasClass('back') && !li.hasClass('has-dropdown')) {
  5231. self.toggle();
  5232. }
  5233. })
  5234. .on('click.fndtn.topbar', '[' + this.attr_name() + '] li.has-dropdown', function (e) {
  5235. var li = S(this),
  5236. target = S(e.target),
  5237. topbar = li.closest('[' + self.attr_name() + ']'),
  5238. settings = topbar.data(self.attr_name(true) + '-init');
  5239. if (target.data('revealId')) {
  5240. self.toggle();
  5241. return;
  5242. }
  5243. if (self.breakpoint()) {
  5244. return;
  5245. }
  5246. if (settings.is_hover && !Modernizr.touch) {
  5247. return;
  5248. }
  5249. e.stopImmediatePropagation();
  5250. if (li.hasClass('hover')) {
  5251. li
  5252. .removeClass('hover')
  5253. .find('li')
  5254. .removeClass('hover');
  5255. li.parents('li.hover')
  5256. .removeClass('hover');
  5257. } else {
  5258. li.addClass('hover');
  5259. $(li).siblings().removeClass('hover');
  5260. if (target[0].nodeName === 'A' && target.parent().hasClass('has-dropdown')) {
  5261. e.preventDefault();
  5262. }
  5263. }
  5264. })
  5265. .on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown>a', function (e) {
  5266. if (self.breakpoint()) {
  5267. e.preventDefault();
  5268. var $this = S(this),
  5269. topbar = $this.closest('[' + self.attr_name() + ']'),
  5270. section = topbar.find('section, .top-bar-section'),
  5271. dropdownHeight = $this.next('.dropdown').outerHeight(),
  5272. $selectedLi = $this.closest('li');
  5273. topbar.data('index', topbar.data('index') + 1);
  5274. $selectedLi.addClass('moved');
  5275. if (!self.rtl) {
  5276. section.css({left : -(100 * topbar.data('index')) + '%'});
  5277. section.find('>.name').css({left : 100 * topbar.data('index') + '%'});
  5278. } else {
  5279. section.css({right : -(100 * topbar.data('index')) + '%'});
  5280. section.find('>.name').css({right : 100 * topbar.data('index') + '%'});
  5281. }
  5282. topbar.css('height', $this.siblings('ul').outerHeight(true) + topbar.data('height'));
  5283. }
  5284. });
  5285. S(window).off('.topbar').on('resize.fndtn.topbar', self.throttle(function () {
  5286. self.resize.call(self);
  5287. }, 50)).trigger('resize.fndtn.topbar').load(function () {
  5288. // Ensure that the offset is calculated after all of the pages resources have loaded
  5289. S(this).trigger('resize.fndtn.topbar');
  5290. });
  5291. S('body').off('.topbar').on('click.fndtn.topbar', function (e) {
  5292. var parent = S(e.target).closest('li').closest('li.hover');
  5293. if (parent.length > 0) {
  5294. return;
  5295. }
  5296. S('[' + self.attr_name() + '] li.hover').removeClass('hover');
  5297. });
  5298. // Go up a level on Click
  5299. S(this.scope).on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown .back', function (e) {
  5300. e.preventDefault();
  5301. var $this = S(this),
  5302. topbar = $this.closest('[' + self.attr_name() + ']'),
  5303. section = topbar.find('section, .top-bar-section'),
  5304. settings = topbar.data(self.attr_name(true) + '-init'),
  5305. $movedLi = $this.closest('li.moved'),
  5306. $previousLevelUl = $movedLi.parent();
  5307. topbar.data('index', topbar.data('index') - 1);
  5308. if (!self.rtl) {
  5309. section.css({left : -(100 * topbar.data('index')) + '%'});
  5310. section.find('>.name').css({left : 100 * topbar.data('index') + '%'});
  5311. } else {
  5312. section.css({right : -(100 * topbar.data('index')) + '%'});
  5313. section.find('>.name').css({right : 100 * topbar.data('index') + '%'});
  5314. }
  5315. if (topbar.data('index') === 0) {
  5316. topbar.css('height', '');
  5317. } else {
  5318. topbar.css('height', $previousLevelUl.outerHeight(true) + topbar.data('height'));
  5319. }
  5320. setTimeout(function () {
  5321. $movedLi.removeClass('moved');
  5322. }, 300);
  5323. });
  5324. // Show dropdown menus when their items are focused
  5325. S(this.scope).find('.dropdown a')
  5326. .focus(function () {
  5327. $(this).parents('.has-dropdown').addClass('hover');
  5328. })
  5329. .blur(function () {
  5330. $(this).parents('.has-dropdown').removeClass('hover');
  5331. });
  5332. },
  5333. resize : function () {
  5334. var self = this;
  5335. self.S('[' + this.attr_name() + ']').each(function () {
  5336. var topbar = self.S(this),
  5337. settings = topbar.data(self.attr_name(true) + '-init');
  5338. var stickyContainer = topbar.parent('.' + self.settings.sticky_class);
  5339. var stickyOffset;
  5340. if (!self.breakpoint()) {
  5341. var doToggle = topbar.hasClass('expanded');
  5342. topbar
  5343. .css('height', '')
  5344. .removeClass('expanded')
  5345. .find('li')
  5346. .removeClass('hover');
  5347. if (doToggle) {
  5348. self.toggle(topbar);
  5349. }
  5350. }
  5351. if (self.is_sticky(topbar, stickyContainer, settings)) {
  5352. if (stickyContainer.hasClass('fixed')) {
  5353. // Remove the fixed to allow for correct calculation of the offset.
  5354. stickyContainer.removeClass('fixed');
  5355. stickyOffset = stickyContainer.offset().top;
  5356. if (self.S(document.body).hasClass('f-topbar-fixed')) {
  5357. stickyOffset -= topbar.data('height');
  5358. }
  5359. topbar.data('stickyoffset', stickyOffset);
  5360. stickyContainer.addClass('fixed');
  5361. } else {
  5362. stickyOffset = stickyContainer.offset().top;
  5363. topbar.data('stickyoffset', stickyOffset);
  5364. }
  5365. }
  5366. });
  5367. },
  5368. breakpoint : function () {
  5369. return !matchMedia(Foundation.media_queries['topbar']).matches;
  5370. },
  5371. small : function () {
  5372. return matchMedia(Foundation.media_queries['small']).matches;
  5373. },
  5374. medium : function () {
  5375. return matchMedia(Foundation.media_queries['medium']).matches;
  5376. },
  5377. large : function () {
  5378. return matchMedia(Foundation.media_queries['large']).matches;
  5379. },
  5380. assemble : function (topbar) {
  5381. var self = this,
  5382. settings = topbar.data(this.attr_name(true) + '-init'),
  5383. section = self.S('section, .top-bar-section', topbar);
  5384. // Pull element out of the DOM for manipulation
  5385. section.detach();
  5386. self.S('.has-dropdown>a', section).each(function () {
  5387. var $link = self.S(this),
  5388. $dropdown = $link.siblings('.dropdown'),
  5389. url = $link.attr('href'),
  5390. $titleLi;
  5391. if (!$dropdown.find('.title.back').length) {
  5392. if (settings.mobile_show_parent_link == true && url) {
  5393. $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li class="parent-link hide-for-medium-up"><a class="parent-link js-generated" href="' + url + '">' + $link.html() +'</a></li>');
  5394. } else {
  5395. $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5>');
  5396. }
  5397. // Copy link to subnav
  5398. if (settings.custom_back_text == true) {
  5399. $('h5>a', $titleLi).html(settings.back_text);
  5400. } else {
  5401. $('h5>a', $titleLi).html('&laquo; ' + $link.html());
  5402. }
  5403. $dropdown.prepend($titleLi);
  5404. }
  5405. });
  5406. // Put element back in the DOM
  5407. section.appendTo(topbar);
  5408. // check for sticky
  5409. this.sticky();
  5410. this.assembled(topbar);
  5411. },
  5412. assembled : function (topbar) {
  5413. topbar.data(this.attr_name(true), $.extend({}, topbar.data(this.attr_name(true)), {assembled : true}));
  5414. },
  5415. height : function (ul) {
  5416. var total = 0,
  5417. self = this;
  5418. $('> li', ul).each(function () {
  5419. total += self.S(this).outerHeight(true);
  5420. });
  5421. return total;
  5422. },
  5423. sticky : function () {
  5424. var self = this;
  5425. this.S(window).on('scroll', function () {
  5426. self.update_sticky_positioning();
  5427. });
  5428. },
  5429. update_sticky_positioning : function () {
  5430. var klass = '.' + this.settings.sticky_class,
  5431. $window = this.S(window),
  5432. self = this;
  5433. if (self.settings.sticky_topbar && self.is_sticky(this.settings.sticky_topbar,this.settings.sticky_topbar.parent(), this.settings)) {
  5434. var distance = this.settings.sticky_topbar.data('stickyoffset') + this.settings.start_offset;
  5435. if (!self.S(klass).hasClass('expanded')) {
  5436. if ($window.scrollTop() > (distance)) {
  5437. if (!self.S(klass).hasClass('fixed')) {
  5438. self.S(klass).addClass('fixed');
  5439. self.S('body').addClass('f-topbar-fixed');
  5440. }
  5441. } else if ($window.scrollTop() <= distance) {
  5442. if (self.S(klass).hasClass('fixed')) {
  5443. self.S(klass).removeClass('fixed');
  5444. self.S('body').removeClass('f-topbar-fixed');
  5445. }
  5446. }
  5447. }
  5448. }
  5449. },
  5450. off : function () {
  5451. this.S(this.scope).off('.fndtn.topbar');
  5452. this.S(window).off('.fndtn.topbar');
  5453. },
  5454. reflow : function () {}
  5455. };
  5456. }(jQuery, window, window.document));