foundation.js 194 KB

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