materialize.js 362 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360
  1. /*!
  2. * Materialize v1.0.0-rc.2 (http://materializecss.com)
  3. * Copyright 2014-2017 Materialize
  4. * MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE)
  5. */
  6. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  7. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  10. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11. /*! cash-dom 1.3.5, https://github.com/kenwheeler/cash @license MIT */
  12. (function (factory) {
  13. window.cash = factory();
  14. })(function () {
  15. var doc = document,
  16. win = window,
  17. ArrayProto = Array.prototype,
  18. slice = ArrayProto.slice,
  19. filter = ArrayProto.filter,
  20. push = ArrayProto.push;
  21. var noop = function () {},
  22. isFunction = function (item) {
  23. // @see https://crbug.com/568448
  24. return typeof item === typeof noop && item.call;
  25. },
  26. isString = function (item) {
  27. return typeof item === typeof "";
  28. };
  29. var idMatch = /^#[\w-]*$/,
  30. classMatch = /^\.[\w-]*$/,
  31. htmlMatch = /<.+>/,
  32. singlet = /^\w+$/;
  33. function find(selector, context) {
  34. context = context || doc;
  35. var elems = classMatch.test(selector) ? context.getElementsByClassName(selector.slice(1)) : singlet.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector);
  36. return elems;
  37. }
  38. var frag;
  39. function parseHTML(str) {
  40. if (!frag) {
  41. frag = doc.implementation.createHTMLDocument(null);
  42. var base = frag.createElement("base");
  43. base.href = doc.location.href;
  44. frag.head.appendChild(base);
  45. }
  46. frag.body.innerHTML = str;
  47. return frag.body.childNodes;
  48. }
  49. function onReady(fn) {
  50. if (doc.readyState !== "loading") {
  51. fn();
  52. } else {
  53. doc.addEventListener("DOMContentLoaded", fn);
  54. }
  55. }
  56. function Init(selector, context) {
  57. if (!selector) {
  58. return this;
  59. }
  60. // If already a cash collection, don't do any further processing
  61. if (selector.cash && selector !== win) {
  62. return selector;
  63. }
  64. var elems = selector,
  65. i = 0,
  66. length;
  67. if (isString(selector)) {
  68. elems = idMatch.test(selector) ?
  69. // If an ID use the faster getElementById check
  70. doc.getElementById(selector.slice(1)) : htmlMatch.test(selector) ?
  71. // If HTML, parse it into real elements
  72. parseHTML(selector) :
  73. // else use `find`
  74. find(selector, context);
  75. // If function, use as shortcut for DOM ready
  76. } else if (isFunction(selector)) {
  77. onReady(selector);return this;
  78. }
  79. if (!elems) {
  80. return this;
  81. }
  82. // If a single DOM element is passed in or received via ID, return the single element
  83. if (elems.nodeType || elems === win) {
  84. this[0] = elems;
  85. this.length = 1;
  86. } else {
  87. // Treat like an array and loop through each item.
  88. length = this.length = elems.length;
  89. for (; i < length; i++) {
  90. this[i] = elems[i];
  91. }
  92. }
  93. return this;
  94. }
  95. function cash(selector, context) {
  96. return new Init(selector, context);
  97. }
  98. var fn = cash.fn = cash.prototype = Init.prototype = { // jshint ignore:line
  99. cash: true,
  100. length: 0,
  101. push: push,
  102. splice: ArrayProto.splice,
  103. map: ArrayProto.map,
  104. init: Init
  105. };
  106. Object.defineProperty(fn, "constructor", { value: cash });
  107. cash.parseHTML = parseHTML;
  108. cash.noop = noop;
  109. cash.isFunction = isFunction;
  110. cash.isString = isString;
  111. cash.extend = fn.extend = function (target) {
  112. target = target || {};
  113. var args = slice.call(arguments),
  114. length = args.length,
  115. i = 1;
  116. if (args.length === 1) {
  117. target = this;
  118. i = 0;
  119. }
  120. for (; i < length; i++) {
  121. if (!args[i]) {
  122. continue;
  123. }
  124. for (var key in args[i]) {
  125. if (args[i].hasOwnProperty(key)) {
  126. target[key] = args[i][key];
  127. }
  128. }
  129. }
  130. return target;
  131. };
  132. function each(collection, callback) {
  133. var l = collection.length,
  134. i = 0;
  135. for (; i < l; i++) {
  136. if (callback.call(collection[i], collection[i], i, collection) === false) {
  137. break;
  138. }
  139. }
  140. }
  141. function matches(el, selector) {
  142. var m = el && (el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector || el.oMatchesSelector);
  143. return !!m && m.call(el, selector);
  144. }
  145. function getCompareFunction(selector) {
  146. return (
  147. /* Use browser's `matches` function if string */
  148. isString(selector) ? matches :
  149. /* Match a cash element */
  150. selector.cash ? function (el) {
  151. return selector.is(el);
  152. } :
  153. /* Direct comparison */
  154. function (el, selector) {
  155. return el === selector;
  156. }
  157. );
  158. }
  159. function unique(collection) {
  160. return cash(slice.call(collection).filter(function (item, index, self) {
  161. return self.indexOf(item) === index;
  162. }));
  163. }
  164. cash.extend({
  165. merge: function (first, second) {
  166. var len = +second.length,
  167. i = first.length,
  168. j = 0;
  169. for (; j < len; i++, j++) {
  170. first[i] = second[j];
  171. }
  172. first.length = i;
  173. return first;
  174. },
  175. each: each,
  176. matches: matches,
  177. unique: unique,
  178. isArray: Array.isArray,
  179. isNumeric: function (n) {
  180. return !isNaN(parseFloat(n)) && isFinite(n);
  181. }
  182. });
  183. var uid = cash.uid = "_cash" + Date.now();
  184. function getDataCache(node) {
  185. return node[uid] = node[uid] || {};
  186. }
  187. function setData(node, key, value) {
  188. return getDataCache(node)[key] = value;
  189. }
  190. function getData(node, key) {
  191. var c = getDataCache(node);
  192. if (c[key] === undefined) {
  193. c[key] = node.dataset ? node.dataset[key] : cash(node).attr("data-" + key);
  194. }
  195. return c[key];
  196. }
  197. function removeData(node, key) {
  198. var c = getDataCache(node);
  199. if (c) {
  200. delete c[key];
  201. } else if (node.dataset) {
  202. delete node.dataset[key];
  203. } else {
  204. cash(node).removeAttr("data-" + name);
  205. }
  206. }
  207. fn.extend({
  208. data: function (name, value) {
  209. if (isString(name)) {
  210. return value === undefined ? getData(this[0], name) : this.each(function (v) {
  211. return setData(v, name, value);
  212. });
  213. }
  214. for (var key in name) {
  215. this.data(key, name[key]);
  216. }
  217. return this;
  218. },
  219. removeData: function (key) {
  220. return this.each(function (v) {
  221. return removeData(v, key);
  222. });
  223. }
  224. });
  225. var notWhiteMatch = /\S+/g;
  226. function getClasses(c) {
  227. return isString(c) && c.match(notWhiteMatch);
  228. }
  229. function hasClass(v, c) {
  230. return v.classList ? v.classList.contains(c) : new RegExp("(^| )" + c + "( |$)", "gi").test(v.className);
  231. }
  232. function addClass(v, c, spacedName) {
  233. if (v.classList) {
  234. v.classList.add(c);
  235. } else if (spacedName.indexOf(" " + c + " ")) {
  236. v.className += " " + c;
  237. }
  238. }
  239. function removeClass(v, c) {
  240. if (v.classList) {
  241. v.classList.remove(c);
  242. } else {
  243. v.className = v.className.replace(c, "");
  244. }
  245. }
  246. fn.extend({
  247. addClass: function (c) {
  248. var classes = getClasses(c);
  249. return classes ? this.each(function (v) {
  250. var spacedName = " " + v.className + " ";
  251. each(classes, function (c) {
  252. addClass(v, c, spacedName);
  253. });
  254. }) : this;
  255. },
  256. attr: function (name, value) {
  257. if (!name) {
  258. return undefined;
  259. }
  260. if (isString(name)) {
  261. if (value === undefined) {
  262. return this[0] ? this[0].getAttribute ? this[0].getAttribute(name) : this[0][name] : undefined;
  263. }
  264. return this.each(function (v) {
  265. if (v.setAttribute) {
  266. v.setAttribute(name, value);
  267. } else {
  268. v[name] = value;
  269. }
  270. });
  271. }
  272. for (var key in name) {
  273. this.attr(key, name[key]);
  274. }
  275. return this;
  276. },
  277. hasClass: function (c) {
  278. var check = false,
  279. classes = getClasses(c);
  280. if (classes && classes.length) {
  281. this.each(function (v) {
  282. check = hasClass(v, classes[0]);
  283. return !check;
  284. });
  285. }
  286. return check;
  287. },
  288. prop: function (name, value) {
  289. if (isString(name)) {
  290. return value === undefined ? this[0][name] : this.each(function (v) {
  291. v[name] = value;
  292. });
  293. }
  294. for (var key in name) {
  295. this.prop(key, name[key]);
  296. }
  297. return this;
  298. },
  299. removeAttr: function (name) {
  300. return this.each(function (v) {
  301. if (v.removeAttribute) {
  302. v.removeAttribute(name);
  303. } else {
  304. delete v[name];
  305. }
  306. });
  307. },
  308. removeClass: function (c) {
  309. if (!arguments.length) {
  310. return this.attr("class", "");
  311. }
  312. var classes = getClasses(c);
  313. return classes ? this.each(function (v) {
  314. each(classes, function (c) {
  315. removeClass(v, c);
  316. });
  317. }) : this;
  318. },
  319. removeProp: function (name) {
  320. return this.each(function (v) {
  321. delete v[name];
  322. });
  323. },
  324. toggleClass: function (c, state) {
  325. if (state !== undefined) {
  326. return this[state ? "addClass" : "removeClass"](c);
  327. }
  328. var classes = getClasses(c);
  329. return classes ? this.each(function (v) {
  330. var spacedName = " " + v.className + " ";
  331. each(classes, function (c) {
  332. if (hasClass(v, c)) {
  333. removeClass(v, c);
  334. } else {
  335. addClass(v, c, spacedName);
  336. }
  337. });
  338. }) : this;
  339. } });
  340. fn.extend({
  341. add: function (selector, context) {
  342. return unique(cash.merge(this, cash(selector, context)));
  343. },
  344. each: function (callback) {
  345. each(this, callback);
  346. return this;
  347. },
  348. eq: function (index) {
  349. return cash(this.get(index));
  350. },
  351. filter: function (selector) {
  352. if (!selector) {
  353. return this;
  354. }
  355. var comparator = isFunction(selector) ? selector : getCompareFunction(selector);
  356. return cash(filter.call(this, function (e) {
  357. return comparator(e, selector);
  358. }));
  359. },
  360. first: function () {
  361. return this.eq(0);
  362. },
  363. get: function (index) {
  364. if (index === undefined) {
  365. return slice.call(this);
  366. }
  367. return index < 0 ? this[index + this.length] : this[index];
  368. },
  369. index: function (elem) {
  370. var child = elem ? cash(elem)[0] : this[0],
  371. collection = elem ? this : cash(child).parent().children();
  372. return slice.call(collection).indexOf(child);
  373. },
  374. last: function () {
  375. return this.eq(-1);
  376. }
  377. });
  378. var camelCase = function () {
  379. var camelRegex = /(?:^\w|[A-Z]|\b\w)/g,
  380. whiteSpace = /[\s-_]+/g;
  381. return function (str) {
  382. return str.replace(camelRegex, function (letter, index) {
  383. return letter[index === 0 ? "toLowerCase" : "toUpperCase"]();
  384. }).replace(whiteSpace, "");
  385. };
  386. }();
  387. var getPrefixedProp = function () {
  388. var cache = {},
  389. doc = document,
  390. div = doc.createElement("div"),
  391. style = div.style;
  392. return function (prop) {
  393. prop = camelCase(prop);
  394. if (cache[prop]) {
  395. return cache[prop];
  396. }
  397. var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1),
  398. prefixes = ["webkit", "moz", "ms", "o"],
  399. props = (prop + " " + prefixes.join(ucProp + " ") + ucProp).split(" ");
  400. each(props, function (p) {
  401. if (p in style) {
  402. cache[p] = prop = cache[prop] = p;
  403. return false;
  404. }
  405. });
  406. return cache[prop];
  407. };
  408. }();
  409. cash.prefixedProp = getPrefixedProp;
  410. cash.camelCase = camelCase;
  411. fn.extend({
  412. css: function (prop, value) {
  413. if (isString(prop)) {
  414. prop = getPrefixedProp(prop);
  415. return arguments.length > 1 ? this.each(function (v) {
  416. return v.style[prop] = value;
  417. }) : win.getComputedStyle(this[0])[prop];
  418. }
  419. for (var key in prop) {
  420. this.css(key, prop[key]);
  421. }
  422. return this;
  423. }
  424. });
  425. function compute(el, prop) {
  426. return parseInt(win.getComputedStyle(el[0], null)[prop], 10) || 0;
  427. }
  428. each(["Width", "Height"], function (v) {
  429. var lower = v.toLowerCase();
  430. fn[lower] = function () {
  431. return this[0].getBoundingClientRect()[lower];
  432. };
  433. fn["inner" + v] = function () {
  434. return this[0]["client" + v];
  435. };
  436. fn["outer" + v] = function (margins) {
  437. return this[0]["offset" + v] + (margins ? compute(this, "margin" + (v === "Width" ? "Left" : "Top")) + compute(this, "margin" + (v === "Width" ? "Right" : "Bottom")) : 0);
  438. };
  439. });
  440. function registerEvent(node, eventName, callback) {
  441. var eventCache = getData(node, "_cashEvents") || setData(node, "_cashEvents", {});
  442. eventCache[eventName] = eventCache[eventName] || [];
  443. eventCache[eventName].push(callback);
  444. node.addEventListener(eventName, callback);
  445. }
  446. function removeEvent(node, eventName, callback) {
  447. var events = getData(node, "_cashEvents"),
  448. eventCache = events && events[eventName],
  449. index;
  450. if (!eventCache) {
  451. return;
  452. }
  453. if (callback) {
  454. node.removeEventListener(eventName, callback);
  455. index = eventCache.indexOf(callback);
  456. if (index >= 0) {
  457. eventCache.splice(index, 1);
  458. }
  459. } else {
  460. each(eventCache, function (event) {
  461. node.removeEventListener(eventName, event);
  462. });
  463. eventCache = [];
  464. }
  465. }
  466. fn.extend({
  467. off: function (eventName, callback) {
  468. return this.each(function (v) {
  469. return removeEvent(v, eventName, callback);
  470. });
  471. },
  472. on: function (eventName, delegate, callback, runOnce) {
  473. // jshint ignore:line
  474. var originalCallback;
  475. if (!isString(eventName)) {
  476. for (var key in eventName) {
  477. this.on(key, delegate, eventName[key]);
  478. }
  479. return this;
  480. }
  481. if (isFunction(delegate)) {
  482. callback = delegate;
  483. delegate = null;
  484. }
  485. if (eventName === "ready") {
  486. onReady(callback);
  487. return this;
  488. }
  489. if (delegate) {
  490. originalCallback = callback;
  491. callback = function (e) {
  492. var t = e.target;
  493. while (!matches(t, delegate)) {
  494. if (t === this || t === null) {
  495. return t = false;
  496. }
  497. t = t.parentNode;
  498. }
  499. if (t) {
  500. originalCallback.call(t, e);
  501. }
  502. };
  503. }
  504. return this.each(function (v) {
  505. var finalCallback = callback;
  506. if (runOnce) {
  507. finalCallback = function () {
  508. callback.apply(this, arguments);
  509. removeEvent(v, eventName, finalCallback);
  510. };
  511. }
  512. registerEvent(v, eventName, finalCallback);
  513. });
  514. },
  515. one: function (eventName, delegate, callback) {
  516. return this.on(eventName, delegate, callback, true);
  517. },
  518. ready: onReady,
  519. /**
  520. * Modified
  521. * Triggers browser event
  522. * @param String eventName
  523. * @param Object data - Add properties to event object
  524. */
  525. trigger: function (eventName, data) {
  526. if (document.createEvent) {
  527. var evt = document.createEvent('HTMLEvents');
  528. evt.initEvent(eventName, true, false);
  529. evt = this.extend(evt, data);
  530. return this.each(function (v) {
  531. return v.dispatchEvent(evt);
  532. });
  533. }
  534. }
  535. });
  536. function encode(name, value) {
  537. return "&" + encodeURIComponent(name) + "=" + encodeURIComponent(value).replace(/%20/g, "+");
  538. }
  539. function getSelectMultiple_(el) {
  540. var values = [];
  541. each(el.options, function (o) {
  542. if (o.selected) {
  543. values.push(o.value);
  544. }
  545. });
  546. return values.length ? values : null;
  547. }
  548. function getSelectSingle_(el) {
  549. var selectedIndex = el.selectedIndex;
  550. return selectedIndex >= 0 ? el.options[selectedIndex].value : null;
  551. }
  552. function getValue(el) {
  553. var type = el.type;
  554. if (!type) {
  555. return null;
  556. }
  557. switch (type.toLowerCase()) {
  558. case "select-one":
  559. return getSelectSingle_(el);
  560. case "select-multiple":
  561. return getSelectMultiple_(el);
  562. case "radio":
  563. return el.checked ? el.value : null;
  564. case "checkbox":
  565. return el.checked ? el.value : null;
  566. default:
  567. return el.value ? el.value : null;
  568. }
  569. }
  570. fn.extend({
  571. serialize: function () {
  572. var query = "";
  573. each(this[0].elements || this, function (el) {
  574. if (el.disabled || el.tagName === "FIELDSET") {
  575. return;
  576. }
  577. var name = el.name;
  578. switch (el.type.toLowerCase()) {
  579. case "file":
  580. case "reset":
  581. case "submit":
  582. case "button":
  583. break;
  584. case "select-multiple":
  585. var values = getValue(el);
  586. if (values !== null) {
  587. each(values, function (value) {
  588. query += encode(name, value);
  589. });
  590. }
  591. break;
  592. default:
  593. var value = getValue(el);
  594. if (value !== null) {
  595. query += encode(name, value);
  596. }
  597. }
  598. });
  599. return query.substr(1);
  600. },
  601. val: function (value) {
  602. if (value === undefined) {
  603. return getValue(this[0]);
  604. }
  605. return this.each(function (v) {
  606. return v.value = value;
  607. });
  608. }
  609. });
  610. function insertElement(el, child, prepend) {
  611. if (prepend) {
  612. var first = el.childNodes[0];
  613. el.insertBefore(child, first);
  614. } else {
  615. el.appendChild(child);
  616. }
  617. }
  618. function insertContent(parent, child, prepend) {
  619. var str = isString(child);
  620. if (!str && child.length) {
  621. each(child, function (v) {
  622. return insertContent(parent, v, prepend);
  623. });
  624. return;
  625. }
  626. each(parent, str ? function (v) {
  627. return v.insertAdjacentHTML(prepend ? "afterbegin" : "beforeend", child);
  628. } : function (v, i) {
  629. return insertElement(v, i === 0 ? child : child.cloneNode(true), prepend);
  630. });
  631. }
  632. fn.extend({
  633. after: function (selector) {
  634. cash(selector).insertAfter(this);
  635. return this;
  636. },
  637. append: function (content) {
  638. insertContent(this, content);
  639. return this;
  640. },
  641. appendTo: function (parent) {
  642. insertContent(cash(parent), this);
  643. return this;
  644. },
  645. before: function (selector) {
  646. cash(selector).insertBefore(this);
  647. return this;
  648. },
  649. clone: function () {
  650. return cash(this.map(function (v) {
  651. return v.cloneNode(true);
  652. }));
  653. },
  654. empty: function () {
  655. this.html("");
  656. return this;
  657. },
  658. html: function (content) {
  659. if (content === undefined) {
  660. return this[0].innerHTML;
  661. }
  662. var source = content.nodeType ? content[0].outerHTML : content;
  663. return this.each(function (v) {
  664. return v.innerHTML = source;
  665. });
  666. },
  667. insertAfter: function (selector) {
  668. var _this = this;
  669. cash(selector).each(function (el, i) {
  670. var parent = el.parentNode,
  671. sibling = el.nextSibling;
  672. _this.each(function (v) {
  673. parent.insertBefore(i === 0 ? v : v.cloneNode(true), sibling);
  674. });
  675. });
  676. return this;
  677. },
  678. insertBefore: function (selector) {
  679. var _this2 = this;
  680. cash(selector).each(function (el, i) {
  681. var parent = el.parentNode;
  682. _this2.each(function (v) {
  683. parent.insertBefore(i === 0 ? v : v.cloneNode(true), el);
  684. });
  685. });
  686. return this;
  687. },
  688. prepend: function (content) {
  689. insertContent(this, content, true);
  690. return this;
  691. },
  692. prependTo: function (parent) {
  693. insertContent(cash(parent), this, true);
  694. return this;
  695. },
  696. remove: function () {
  697. return this.each(function (v) {
  698. if (!!v.parentNode) {
  699. return v.parentNode.removeChild(v);
  700. }
  701. });
  702. },
  703. text: function (content) {
  704. if (content === undefined) {
  705. return this[0].textContent;
  706. }
  707. return this.each(function (v) {
  708. return v.textContent = content;
  709. });
  710. }
  711. });
  712. var docEl = doc.documentElement;
  713. fn.extend({
  714. position: function () {
  715. var el = this[0];
  716. return {
  717. left: el.offsetLeft,
  718. top: el.offsetTop
  719. };
  720. },
  721. offset: function () {
  722. var rect = this[0].getBoundingClientRect();
  723. return {
  724. top: rect.top + win.pageYOffset - docEl.clientTop,
  725. left: rect.left + win.pageXOffset - docEl.clientLeft
  726. };
  727. },
  728. offsetParent: function () {
  729. return cash(this[0].offsetParent);
  730. }
  731. });
  732. fn.extend({
  733. children: function (selector) {
  734. var elems = [];
  735. this.each(function (el) {
  736. push.apply(elems, el.children);
  737. });
  738. elems = unique(elems);
  739. return !selector ? elems : elems.filter(function (v) {
  740. return matches(v, selector);
  741. });
  742. },
  743. closest: function (selector) {
  744. if (!selector || this.length < 1) {
  745. return cash();
  746. }
  747. if (this.is(selector)) {
  748. return this.filter(selector);
  749. }
  750. return this.parent().closest(selector);
  751. },
  752. is: function (selector) {
  753. if (!selector) {
  754. return false;
  755. }
  756. var match = false,
  757. comparator = getCompareFunction(selector);
  758. this.each(function (el) {
  759. match = comparator(el, selector);
  760. return !match;
  761. });
  762. return match;
  763. },
  764. find: function (selector) {
  765. if (!selector || selector.nodeType) {
  766. return cash(selector && this.has(selector).length ? selector : null);
  767. }
  768. var elems = [];
  769. this.each(function (el) {
  770. push.apply(elems, find(selector, el));
  771. });
  772. return unique(elems);
  773. },
  774. has: function (selector) {
  775. var comparator = isString(selector) ? function (el) {
  776. return find(selector, el).length !== 0;
  777. } : function (el) {
  778. return el.contains(selector);
  779. };
  780. return this.filter(comparator);
  781. },
  782. next: function () {
  783. return cash(this[0].nextElementSibling);
  784. },
  785. not: function (selector) {
  786. if (!selector) {
  787. return this;
  788. }
  789. var comparator = getCompareFunction(selector);
  790. return this.filter(function (el) {
  791. return !comparator(el, selector);
  792. });
  793. },
  794. parent: function () {
  795. var result = [];
  796. this.each(function (item) {
  797. if (item && item.parentNode) {
  798. result.push(item.parentNode);
  799. }
  800. });
  801. return unique(result);
  802. },
  803. parents: function (selector) {
  804. var last,
  805. result = [];
  806. this.each(function (item) {
  807. last = item;
  808. while (last && last.parentNode && last !== doc.body.parentNode) {
  809. last = last.parentNode;
  810. if (!selector || selector && matches(last, selector)) {
  811. result.push(last);
  812. }
  813. }
  814. });
  815. return unique(result);
  816. },
  817. prev: function () {
  818. return cash(this[0].previousElementSibling);
  819. },
  820. siblings: function (selector) {
  821. var collection = this.parent().children(selector),
  822. el = this[0];
  823. return collection.filter(function (i) {
  824. return i !== el;
  825. });
  826. }
  827. });
  828. return cash;
  829. });
  830. ;
  831. var Component = function () {
  832. /**
  833. * Generic constructor for all components
  834. * @constructor
  835. * @param {Element} el
  836. * @param {Object} options
  837. */
  838. function Component(classDef, el, options) {
  839. _classCallCheck(this, Component);
  840. // Display error if el is valid HTML Element
  841. if (!(el instanceof Element)) {
  842. console.error(Error(el + ' is not an HTML Element'));
  843. }
  844. // If exists, destroy and reinitialize in child
  845. var ins = classDef.getInstance(el);
  846. if (!!ins) {
  847. ins.destroy();
  848. }
  849. this.el = el;
  850. this.$el = cash(el);
  851. }
  852. /**
  853. * Initializes components
  854. * @param {class} classDef
  855. * @param {Element | NodeList | jQuery} els
  856. * @param {Object} options
  857. */
  858. _createClass(Component, null, [{
  859. key: "init",
  860. value: function init(classDef, els, options) {
  861. var instances = null;
  862. if (els instanceof Element) {
  863. instances = new classDef(els, options);
  864. } else if (!!els && (els.jquery || els.cash || els instanceof NodeList)) {
  865. var instancesArr = [];
  866. for (var i = 0; i < els.length; i++) {
  867. instancesArr.push(new classDef(els[i], options));
  868. }
  869. instances = instancesArr;
  870. }
  871. return instances;
  872. }
  873. }]);
  874. return Component;
  875. }();
  876. ; // Required for Meteor package, the use of window prevents export by Meteor
  877. (function (window) {
  878. if (window.Package) {
  879. M = {};
  880. } else {
  881. window.M = {};
  882. }
  883. // Check for jQuery
  884. M.jQueryLoaded = !!window.jQuery;
  885. })(window);
  886. // AMD
  887. if (typeof define === 'function' && define.amd) {
  888. define('M', [], function () {
  889. return M;
  890. });
  891. // Common JS
  892. } else if (typeof exports !== 'undefined' && !exports.nodeType) {
  893. if (typeof module !== 'undefined' && !module.nodeType && module.exports) {
  894. exports = module.exports = M;
  895. }
  896. exports.default = M;
  897. }
  898. M.keys = {
  899. TAB: 9,
  900. ENTER: 13,
  901. ESC: 27,
  902. ARROW_UP: 38,
  903. ARROW_DOWN: 40
  904. };
  905. /**
  906. * TabPress Keydown handler
  907. */
  908. M.tabPressed = false;
  909. M.keyDown = false;
  910. var docHandleKeydown = function (e) {
  911. M.keyDown = true;
  912. if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) {
  913. M.tabPressed = true;
  914. }
  915. };
  916. var docHandleKeyup = function (e) {
  917. M.keyDown = false;
  918. if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) {
  919. M.tabPressed = false;
  920. }
  921. };
  922. var docHandleFocus = function (e) {
  923. if (M.keyDown) {
  924. document.body.classList.add('keyboard-focused');
  925. }
  926. };
  927. var docHandleBlur = function (e) {
  928. document.body.classList.remove('keyboard-focused');
  929. };
  930. document.addEventListener('keydown', docHandleKeydown, true);
  931. document.addEventListener('keyup', docHandleKeyup, true);
  932. document.addEventListener('focus', docHandleFocus, true);
  933. document.addEventListener('blur', docHandleBlur, true);
  934. /**
  935. * Initialize jQuery wrapper for plugin
  936. * @param {Class} plugin javascript class
  937. * @param {string} pluginName jQuery plugin name
  938. * @param {string} classRef Class reference name
  939. */
  940. M.initializeJqueryWrapper = function (plugin, pluginName, classRef) {
  941. jQuery.fn[pluginName] = function (methodOrOptions) {
  942. // Call plugin method if valid method name is passed in
  943. if (plugin.prototype[methodOrOptions]) {
  944. var params = Array.prototype.slice.call(arguments, 1);
  945. // Getter methods
  946. if (methodOrOptions.slice(0, 3) === 'get') {
  947. var instance = this.first()[0][classRef];
  948. return instance[methodOrOptions].apply(instance, params);
  949. }
  950. // Void methods
  951. return this.each(function () {
  952. var instance = this[classRef];
  953. instance[methodOrOptions].apply(instance, params);
  954. });
  955. // Initialize plugin if options or no argument is passed in
  956. } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
  957. plugin.init(this, arguments[0]);
  958. return this;
  959. }
  960. // Return error if an unrecognized method name is passed in
  961. jQuery.error("Method " + methodOrOptions + " does not exist on jQuery." + pluginName);
  962. };
  963. };
  964. /**
  965. * Automatically initialize components
  966. * @param {Element} context DOM Element to search within for components
  967. */
  968. M.AutoInit = function (context) {
  969. // Use document.body if no context is given
  970. var root = !!context ? context : document.body;
  971. var registry = {
  972. Autocomplete: root.querySelectorAll('.autocomplete:not(.no-autoinit)'),
  973. Carousel: root.querySelectorAll('.carousel:not(.no-autoinit)'),
  974. Chips: root.querySelectorAll('.chips:not(.no-autoinit)'),
  975. Collapsible: root.querySelectorAll('.collapsible:not(.no-autoinit)'),
  976. Datepicker: root.querySelectorAll('.datepicker:not(.no-autoinit)'),
  977. Dropdown: root.querySelectorAll('.dropdown-trigger:not(.no-autoinit)'),
  978. Materialbox: root.querySelectorAll('.materialboxed:not(.no-autoinit)'),
  979. Modal: root.querySelectorAll('.modal:not(.no-autoinit)'),
  980. Parallax: root.querySelectorAll('.parallax:not(.no-autoinit)'),
  981. Pushpin: root.querySelectorAll('.pushpin:not(.no-autoinit)'),
  982. ScrollSpy: root.querySelectorAll('.scrollspy:not(.no-autoinit)'),
  983. FormSelect: root.querySelectorAll('select:not(.no-autoinit)'),
  984. Sidenav: root.querySelectorAll('.sidenav:not(.no-autoinit)'),
  985. Tabs: root.querySelectorAll('.tabs:not(.no-autoinit)'),
  986. TapTarget: root.querySelectorAll('.tap-target:not(.no-autoinit)'),
  987. Timepicker: root.querySelectorAll('.timepicker:not(.no-autoinit)'),
  988. Tooltip: root.querySelectorAll('.tooltipped:not(.no-autoinit)'),
  989. FloatingActionButton: root.querySelectorAll('.fixed-action-btn:not(.no-autoinit)')
  990. };
  991. for (var pluginName in registry) {
  992. var plugin = M[pluginName];
  993. plugin.init(registry[pluginName]);
  994. }
  995. };
  996. /**
  997. * Generate approximated selector string for a jQuery object
  998. * @param {jQuery} obj jQuery object to be parsed
  999. * @returns {string}
  1000. */
  1001. M.objectSelectorString = function (obj) {
  1002. var tagStr = obj.prop('tagName') || '';
  1003. var idStr = obj.attr('id') || '';
  1004. var classStr = obj.attr('class') || '';
  1005. return (tagStr + idStr + classStr).replace(/\s/g, '');
  1006. };
  1007. // Unique Random ID
  1008. M.guid = function () {
  1009. function s4() {
  1010. return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  1011. }
  1012. return function () {
  1013. return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
  1014. };
  1015. }();
  1016. /**
  1017. * Escapes hash from special characters
  1018. * @param {string} hash String returned from this.hash
  1019. * @returns {string}
  1020. */
  1021. M.escapeHash = function (hash) {
  1022. return hash.replace(/(:|\.|\[|\]|,|=|\/)/g, '\\$1');
  1023. };
  1024. M.elementOrParentIsFixed = function (element) {
  1025. var $element = $(element);
  1026. var $checkElements = $element.add($element.parents());
  1027. var isFixed = false;
  1028. $checkElements.each(function () {
  1029. if ($(this).css('position') === 'fixed') {
  1030. isFixed = true;
  1031. return false;
  1032. }
  1033. });
  1034. return isFixed;
  1035. };
  1036. /**
  1037. * @typedef {Object} Edges
  1038. * @property {Boolean} top If the top edge was exceeded
  1039. * @property {Boolean} right If the right edge was exceeded
  1040. * @property {Boolean} bottom If the bottom edge was exceeded
  1041. * @property {Boolean} left If the left edge was exceeded
  1042. */
  1043. /**
  1044. * @typedef {Object} Bounding
  1045. * @property {Number} left left offset coordinate
  1046. * @property {Number} top top offset coordinate
  1047. * @property {Number} width
  1048. * @property {Number} height
  1049. */
  1050. /**
  1051. * Escapes hash from special characters
  1052. * @param {Element} container Container element that acts as the boundary
  1053. * @param {Bounding} bounding element bounding that is being checked
  1054. * @param {Number} offset offset from edge that counts as exceeding
  1055. * @returns {Edges}
  1056. */
  1057. M.checkWithinContainer = function (container, bounding, offset) {
  1058. var edges = {
  1059. top: false,
  1060. right: false,
  1061. bottom: false,
  1062. left: false
  1063. };
  1064. var containerRect = container.getBoundingClientRect();
  1065. // If body element is smaller than viewport, use viewport height instead.
  1066. var containerBottom = container === document.body ? Math.max(containerRect.bottom, window.innerHeight) : containerRect.bottom;
  1067. var scrollLeft = container.scrollLeft;
  1068. var scrollTop = container.scrollTop;
  1069. var scrolledX = bounding.left - scrollLeft;
  1070. var scrolledY = bounding.top - scrollTop;
  1071. // Check for container and viewport for each edge
  1072. if (scrolledX < containerRect.left + offset || scrolledX < offset) {
  1073. edges.left = true;
  1074. }
  1075. if (scrolledX + bounding.width > containerRect.right - offset || scrolledX + bounding.width > window.innerWidth - offset) {
  1076. edges.right = true;
  1077. }
  1078. if (scrolledY < containerRect.top + offset || scrolledY < offset) {
  1079. edges.top = true;
  1080. }
  1081. if (scrolledY + bounding.height > containerBottom - offset || scrolledY + bounding.height > window.innerHeight - offset) {
  1082. edges.bottom = true;
  1083. }
  1084. return edges;
  1085. };
  1086. M.checkPossibleAlignments = function (el, container, bounding, offset) {
  1087. var canAlign = {
  1088. top: true,
  1089. right: true,
  1090. bottom: true,
  1091. left: true,
  1092. spaceOnTop: null,
  1093. spaceOnRight: null,
  1094. spaceOnBottom: null,
  1095. spaceOnLeft: null
  1096. };
  1097. var containerAllowsOverflow = getComputedStyle(container).overflow === 'visible';
  1098. var containerRect = container.getBoundingClientRect();
  1099. var containerHeight = Math.min(containerRect.height, window.innerHeight);
  1100. var containerWidth = Math.min(containerRect.width, window.innerWidth);
  1101. var elOffsetRect = el.getBoundingClientRect();
  1102. var scrollLeft = container.scrollLeft;
  1103. var scrollTop = container.scrollTop;
  1104. var scrolledX = bounding.left - scrollLeft;
  1105. var scrolledYTopEdge = bounding.top - scrollTop;
  1106. var scrolledYBottomEdge = bounding.top + elOffsetRect.height - scrollTop;
  1107. // Check for container and viewport for left
  1108. canAlign.spaceOnRight = !containerAllowsOverflow ? containerWidth - (scrolledX + bounding.width) : window.innerWidth - (elOffsetRect.left + bounding.width);
  1109. if (canAlign.spaceOnRight < 0) {
  1110. canAlign.left = false;
  1111. }
  1112. // Check for container and viewport for Right
  1113. canAlign.spaceOnLeft = !containerAllowsOverflow ? scrolledX - bounding.width + elOffsetRect.width : elOffsetRect.right - bounding.width;
  1114. if (canAlign.spaceOnLeft < 0) {
  1115. canAlign.right = false;
  1116. }
  1117. // Check for container and viewport for Top
  1118. canAlign.spaceOnBottom = !containerAllowsOverflow ? containerHeight - (scrolledYTopEdge + bounding.height + offset) : window.innerHeight - (elOffsetRect.top + bounding.height + offset);
  1119. if (canAlign.spaceOnBottom < 0) {
  1120. canAlign.top = false;
  1121. }
  1122. // Check for container and viewport for Bottom
  1123. canAlign.spaceOnTop = !containerAllowsOverflow ? scrolledYBottomEdge - (bounding.height - offset) : elOffsetRect.bottom - (bounding.height + offset);
  1124. if (canAlign.spaceOnTop < 0) {
  1125. canAlign.bottom = false;
  1126. }
  1127. return canAlign;
  1128. };
  1129. M.getOverflowParent = function (element) {
  1130. if (element == null) {
  1131. return null;
  1132. }
  1133. if (element === document.body || getComputedStyle(element).overflow !== 'visible') {
  1134. return element;
  1135. }
  1136. return M.getOverflowParent(element.parentElement);
  1137. };
  1138. /**
  1139. * Gets id of component from a trigger
  1140. * @param {Element} trigger trigger
  1141. * @returns {string}
  1142. */
  1143. M.getIdFromTrigger = function (trigger) {
  1144. var id = trigger.getAttribute('data-target');
  1145. if (!id) {
  1146. id = trigger.getAttribute('href');
  1147. if (id) {
  1148. id = id.slice(1);
  1149. } else {
  1150. id = '';
  1151. }
  1152. }
  1153. return id;
  1154. };
  1155. /**
  1156. * Multi browser support for document scroll top
  1157. * @returns {Number}
  1158. */
  1159. M.getDocumentScrollTop = function () {
  1160. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  1161. };
  1162. /**
  1163. * Multi browser support for document scroll left
  1164. * @returns {Number}
  1165. */
  1166. M.getDocumentScrollLeft = function () {
  1167. return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
  1168. };
  1169. /**
  1170. * @typedef {Object} Edges
  1171. * @property {Boolean} top If the top edge was exceeded
  1172. * @property {Boolean} right If the right edge was exceeded
  1173. * @property {Boolean} bottom If the bottom edge was exceeded
  1174. * @property {Boolean} left If the left edge was exceeded
  1175. */
  1176. /**
  1177. * @typedef {Object} Bounding
  1178. * @property {Number} left left offset coordinate
  1179. * @property {Number} top top offset coordinate
  1180. * @property {Number} width
  1181. * @property {Number} height
  1182. */
  1183. /**
  1184. * Get time in ms
  1185. * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
  1186. * @type {function}
  1187. * @return {number}
  1188. */
  1189. var getTime = Date.now || function () {
  1190. return new Date().getTime();
  1191. };
  1192. /**
  1193. * Returns a function, that, when invoked, will only be triggered at most once
  1194. * during a given window of time. Normally, the throttled function will run
  1195. * as much as it can, without ever going more than once per `wait` duration;
  1196. * but if you'd like to disable the execution on the leading edge, pass
  1197. * `{leading: false}`. To disable execution on the trailing edge, ditto.
  1198. * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
  1199. * @param {function} func
  1200. * @param {number} wait
  1201. * @param {Object=} options
  1202. * @returns {Function}
  1203. */
  1204. M.throttle = function (func, wait, options) {
  1205. var context = void 0,
  1206. args = void 0,
  1207. result = void 0;
  1208. var timeout = null;
  1209. var previous = 0;
  1210. options || (options = {});
  1211. var later = function () {
  1212. previous = options.leading === false ? 0 : getTime();
  1213. timeout = null;
  1214. result = func.apply(context, args);
  1215. context = args = null;
  1216. };
  1217. return function () {
  1218. var now = getTime();
  1219. if (!previous && options.leading === false) previous = now;
  1220. var remaining = wait - (now - previous);
  1221. context = this;
  1222. args = arguments;
  1223. if (remaining <= 0) {
  1224. clearTimeout(timeout);
  1225. timeout = null;
  1226. previous = now;
  1227. result = func.apply(context, args);
  1228. context = args = null;
  1229. } else if (!timeout && options.trailing !== false) {
  1230. timeout = setTimeout(later, remaining);
  1231. }
  1232. return result;
  1233. };
  1234. };
  1235. ; /*
  1236. v2.2.0
  1237. 2017 Julian Garnier
  1238. Released under the MIT license
  1239. */
  1240. var $jscomp = { scope: {} };$jscomp.defineProperty = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, r, p) {
  1241. if (p.get || p.set) throw new TypeError("ES3 does not support getters and setters.");e != Array.prototype && e != Object.prototype && (e[r] = p.value);
  1242. };$jscomp.getGlobal = function (e) {
  1243. return "undefined" != typeof window && window === e ? e : "undefined" != typeof global && null != global ? global : e;
  1244. };$jscomp.global = $jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX = "jscomp_symbol_";
  1245. $jscomp.initSymbol = function () {
  1246. $jscomp.initSymbol = function () {};$jscomp.global.Symbol || ($jscomp.global.Symbol = $jscomp.Symbol);
  1247. };$jscomp.symbolCounter_ = 0;$jscomp.Symbol = function (e) {
  1248. return $jscomp.SYMBOL_PREFIX + (e || "") + $jscomp.symbolCounter_++;
  1249. };
  1250. $jscomp.initSymbolIterator = function () {
  1251. $jscomp.initSymbol();var e = $jscomp.global.Symbol.iterator;e || (e = $jscomp.global.Symbol.iterator = $jscomp.global.Symbol("iterator"));"function" != typeof Array.prototype[e] && $jscomp.defineProperty(Array.prototype, e, { configurable: !0, writable: !0, value: function () {
  1252. return $jscomp.arrayIterator(this);
  1253. } });$jscomp.initSymbolIterator = function () {};
  1254. };$jscomp.arrayIterator = function (e) {
  1255. var r = 0;return $jscomp.iteratorPrototype(function () {
  1256. return r < e.length ? { done: !1, value: e[r++] } : { done: !0 };
  1257. });
  1258. };
  1259. $jscomp.iteratorPrototype = function (e) {
  1260. $jscomp.initSymbolIterator();e = { next: e };e[$jscomp.global.Symbol.iterator] = function () {
  1261. return this;
  1262. };return e;
  1263. };$jscomp.array = $jscomp.array || {};$jscomp.iteratorFromArray = function (e, r) {
  1264. $jscomp.initSymbolIterator();e instanceof String && (e += "");var p = 0,
  1265. m = { next: function () {
  1266. if (p < e.length) {
  1267. var u = p++;return { value: r(u, e[u]), done: !1 };
  1268. }m.next = function () {
  1269. return { done: !0, value: void 0 };
  1270. };return m.next();
  1271. } };m[Symbol.iterator] = function () {
  1272. return m;
  1273. };return m;
  1274. };
  1275. $jscomp.polyfill = function (e, r, p, m) {
  1276. if (r) {
  1277. p = $jscomp.global;e = e.split(".");for (m = 0; m < e.length - 1; m++) {
  1278. var u = e[m];u in p || (p[u] = {});p = p[u];
  1279. }e = e[e.length - 1];m = p[e];r = r(m);r != m && null != r && $jscomp.defineProperty(p, e, { configurable: !0, writable: !0, value: r });
  1280. }
  1281. };$jscomp.polyfill("Array.prototype.keys", function (e) {
  1282. return e ? e : function () {
  1283. return $jscomp.iteratorFromArray(this, function (e) {
  1284. return e;
  1285. });
  1286. };
  1287. }, "es6-impl", "es3");var $jscomp$this = this;
  1288. (function (r) {
  1289. M.anime = r();
  1290. })(function () {
  1291. function e(a) {
  1292. if (!h.col(a)) try {
  1293. return document.querySelectorAll(a);
  1294. } catch (c) {}
  1295. }function r(a, c) {
  1296. for (var d = a.length, b = 2 <= arguments.length ? arguments[1] : void 0, f = [], n = 0; n < d; n++) {
  1297. if (n in a) {
  1298. var k = a[n];c.call(b, k, n, a) && f.push(k);
  1299. }
  1300. }return f;
  1301. }function p(a) {
  1302. return a.reduce(function (a, d) {
  1303. return a.concat(h.arr(d) ? p(d) : d);
  1304. }, []);
  1305. }function m(a) {
  1306. if (h.arr(a)) return a;
  1307. h.str(a) && (a = e(a) || a);return a instanceof NodeList || a instanceof HTMLCollection ? [].slice.call(a) : [a];
  1308. }function u(a, c) {
  1309. return a.some(function (a) {
  1310. return a === c;
  1311. });
  1312. }function C(a) {
  1313. var c = {},
  1314. d;for (d in a) {
  1315. c[d] = a[d];
  1316. }return c;
  1317. }function D(a, c) {
  1318. var d = C(a),
  1319. b;for (b in a) {
  1320. d[b] = c.hasOwnProperty(b) ? c[b] : a[b];
  1321. }return d;
  1322. }function z(a, c) {
  1323. var d = C(a),
  1324. b;for (b in c) {
  1325. d[b] = h.und(a[b]) ? c[b] : a[b];
  1326. }return d;
  1327. }function T(a) {
  1328. a = a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (a, c, d, k) {
  1329. return c + c + d + d + k + k;
  1330. });var c = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);
  1331. a = parseInt(c[1], 16);var d = parseInt(c[2], 16),
  1332. c = parseInt(c[3], 16);return "rgba(" + a + "," + d + "," + c + ",1)";
  1333. }function U(a) {
  1334. function c(a, c, b) {
  1335. 0 > b && (b += 1);1 < b && --b;return b < 1 / 6 ? a + 6 * (c - a) * b : .5 > b ? c : b < 2 / 3 ? a + (c - a) * (2 / 3 - b) * 6 : a;
  1336. }var d = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(a) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(a);a = parseInt(d[1]) / 360;var b = parseInt(d[2]) / 100,
  1337. f = parseInt(d[3]) / 100,
  1338. d = d[4] || 1;if (0 == b) f = b = a = f;else {
  1339. var n = .5 > f ? f * (1 + b) : f + b - f * b,
  1340. k = 2 * f - n,
  1341. f = c(k, n, a + 1 / 3),
  1342. b = c(k, n, a);a = c(k, n, a - 1 / 3);
  1343. }return "rgba(" + 255 * f + "," + 255 * b + "," + 255 * a + "," + d + ")";
  1344. }function y(a) {
  1345. if (a = /([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(a)) return a[2];
  1346. }function V(a) {
  1347. if (-1 < a.indexOf("translate") || "perspective" === a) return "px";if (-1 < a.indexOf("rotate") || -1 < a.indexOf("skew")) return "deg";
  1348. }function I(a, c) {
  1349. return h.fnc(a) ? a(c.target, c.id, c.total) : a;
  1350. }function E(a, c) {
  1351. if (c in a.style) return getComputedStyle(a).getPropertyValue(c.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()) || "0";
  1352. }function J(a, c) {
  1353. if (h.dom(a) && u(W, c)) return "transform";if (h.dom(a) && (a.getAttribute(c) || h.svg(a) && a[c])) return "attribute";if (h.dom(a) && "transform" !== c && E(a, c)) return "css";if (null != a[c]) return "object";
  1354. }function X(a, c) {
  1355. var d = V(c),
  1356. d = -1 < c.indexOf("scale") ? 1 : 0 + d;a = a.style.transform;if (!a) return d;for (var b = [], f = [], n = [], k = /(\w+)\((.+?)\)/g; b = k.exec(a);) {
  1357. f.push(b[1]), n.push(b[2]);
  1358. }a = r(n, function (a, b) {
  1359. return f[b] === c;
  1360. });return a.length ? a[0] : d;
  1361. }function K(a, c) {
  1362. switch (J(a, c)) {case "transform":
  1363. return X(a, c);case "css":
  1364. return E(a, c);case "attribute":
  1365. return a.getAttribute(c);}return a[c] || 0;
  1366. }function L(a, c) {
  1367. var d = /^(\*=|\+=|-=)/.exec(a);if (!d) return a;var b = y(a) || 0;c = parseFloat(c);a = parseFloat(a.replace(d[0], ""));switch (d[0][0]) {case "+":
  1368. return c + a + b;case "-":
  1369. return c - a + b;case "*":
  1370. return c * a + b;}
  1371. }function F(a, c) {
  1372. return Math.sqrt(Math.pow(c.x - a.x, 2) + Math.pow(c.y - a.y, 2));
  1373. }function M(a) {
  1374. a = a.points;for (var c = 0, d, b = 0; b < a.numberOfItems; b++) {
  1375. var f = a.getItem(b);0 < b && (c += F(d, f));d = f;
  1376. }return c;
  1377. }function N(a) {
  1378. if (a.getTotalLength) return a.getTotalLength();switch (a.tagName.toLowerCase()) {case "circle":
  1379. return 2 * Math.PI * a.getAttribute("r");case "rect":
  1380. return 2 * a.getAttribute("width") + 2 * a.getAttribute("height");case "line":
  1381. return F({ x: a.getAttribute("x1"), y: a.getAttribute("y1") }, { x: a.getAttribute("x2"), y: a.getAttribute("y2") });case "polyline":
  1382. return M(a);case "polygon":
  1383. var c = a.points;return M(a) + F(c.getItem(c.numberOfItems - 1), c.getItem(0));}
  1384. }function Y(a, c) {
  1385. function d(b) {
  1386. b = void 0 === b ? 0 : b;return a.el.getPointAtLength(1 <= c + b ? c + b : 0);
  1387. }var b = d(),
  1388. f = d(-1),
  1389. n = d(1);switch (a.property) {case "x":
  1390. return b.x;case "y":
  1391. return b.y;
  1392. case "angle":
  1393. return 180 * Math.atan2(n.y - f.y, n.x - f.x) / Math.PI;}
  1394. }function O(a, c) {
  1395. var d = /-?\d*\.?\d+/g,
  1396. b;b = h.pth(a) ? a.totalLength : a;if (h.col(b)) {
  1397. if (h.rgb(b)) {
  1398. var f = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(b);b = f ? "rgba(" + f[1] + ",1)" : b;
  1399. } else b = h.hex(b) ? T(b) : h.hsl(b) ? U(b) : void 0;
  1400. } else f = (f = y(b)) ? b.substr(0, b.length - f.length) : b, b = c && !/\s/g.test(b) ? f + c : f;b += "";return { original: b, numbers: b.match(d) ? b.match(d).map(Number) : [0], strings: h.str(a) || c ? b.split(d) : [] };
  1401. }function P(a) {
  1402. a = a ? p(h.arr(a) ? a.map(m) : m(a)) : [];return r(a, function (a, d, b) {
  1403. return b.indexOf(a) === d;
  1404. });
  1405. }function Z(a) {
  1406. var c = P(a);return c.map(function (a, b) {
  1407. return { target: a, id: b, total: c.length };
  1408. });
  1409. }function aa(a, c) {
  1410. var d = C(c);if (h.arr(a)) {
  1411. var b = a.length;2 !== b || h.obj(a[0]) ? h.fnc(c.duration) || (d.duration = c.duration / b) : a = { value: a };
  1412. }return m(a).map(function (a, b) {
  1413. b = b ? 0 : c.delay;a = h.obj(a) && !h.pth(a) ? a : { value: a };h.und(a.delay) && (a.delay = b);return a;
  1414. }).map(function (a) {
  1415. return z(a, d);
  1416. });
  1417. }function ba(a, c) {
  1418. var d = {},
  1419. b;for (b in a) {
  1420. var f = I(a[b], c);h.arr(f) && (f = f.map(function (a) {
  1421. return I(a, c);
  1422. }), 1 === f.length && (f = f[0]));d[b] = f;
  1423. }d.duration = parseFloat(d.duration);d.delay = parseFloat(d.delay);return d;
  1424. }function ca(a) {
  1425. return h.arr(a) ? A.apply(this, a) : Q[a];
  1426. }function da(a, c) {
  1427. var d;return a.tweens.map(function (b) {
  1428. b = ba(b, c);var f = b.value,
  1429. e = K(c.target, a.name),
  1430. k = d ? d.to.original : e,
  1431. k = h.arr(f) ? f[0] : k,
  1432. w = L(h.arr(f) ? f[1] : f, k),
  1433. e = y(w) || y(k) || y(e);b.from = O(k, e);b.to = O(w, e);b.start = d ? d.end : a.offset;b.end = b.start + b.delay + b.duration;b.easing = ca(b.easing);b.elasticity = (1E3 - Math.min(Math.max(b.elasticity, 1), 999)) / 1E3;b.isPath = h.pth(f);b.isColor = h.col(b.from.original);b.isColor && (b.round = 1);return d = b;
  1434. });
  1435. }function ea(a, c) {
  1436. return r(p(a.map(function (a) {
  1437. return c.map(function (b) {
  1438. var c = J(a.target, b.name);if (c) {
  1439. var d = da(b, a);b = { type: c, property: b.name, animatable: a, tweens: d, duration: d[d.length - 1].end, delay: d[0].delay };
  1440. } else b = void 0;return b;
  1441. });
  1442. })), function (a) {
  1443. return !h.und(a);
  1444. });
  1445. }function R(a, c, d, b) {
  1446. var f = "delay" === a;return c.length ? (f ? Math.min : Math.max).apply(Math, c.map(function (b) {
  1447. return b[a];
  1448. })) : f ? b.delay : d.offset + b.delay + b.duration;
  1449. }function fa(a) {
  1450. var c = D(ga, a),
  1451. d = D(S, a),
  1452. b = Z(a.targets),
  1453. f = [],
  1454. e = z(c, d),
  1455. k;for (k in a) {
  1456. e.hasOwnProperty(k) || "targets" === k || f.push({ name: k, offset: e.offset, tweens: aa(a[k], d) });
  1457. }a = ea(b, f);return z(c, { children: [], animatables: b, animations: a, duration: R("duration", a, c, d), delay: R("delay", a, c, d) });
  1458. }function q(a) {
  1459. function c() {
  1460. return window.Promise && new Promise(function (a) {
  1461. return p = a;
  1462. });
  1463. }function d(a) {
  1464. return g.reversed ? g.duration - a : a;
  1465. }function b(a) {
  1466. for (var b = 0, c = {}, d = g.animations, f = d.length; b < f;) {
  1467. var e = d[b],
  1468. k = e.animatable,
  1469. h = e.tweens,
  1470. n = h.length - 1,
  1471. l = h[n];n && (l = r(h, function (b) {
  1472. return a < b.end;
  1473. })[0] || l);for (var h = Math.min(Math.max(a - l.start - l.delay, 0), l.duration) / l.duration, w = isNaN(h) ? 1 : l.easing(h, l.elasticity), h = l.to.strings, p = l.round, n = [], m = void 0, m = l.to.numbers.length, t = 0; t < m; t++) {
  1474. var x = void 0,
  1475. x = l.to.numbers[t],
  1476. q = l.from.numbers[t],
  1477. x = l.isPath ? Y(l.value, w * x) : q + w * (x - q);p && (l.isColor && 2 < t || (x = Math.round(x * p) / p));n.push(x);
  1478. }if (l = h.length) for (m = h[0], w = 0; w < l; w++) {
  1479. p = h[w + 1], t = n[w], isNaN(t) || (m = p ? m + (t + p) : m + (t + " "));
  1480. } else m = n[0];ha[e.type](k.target, e.property, m, c, k.id);e.currentValue = m;b++;
  1481. }if (b = Object.keys(c).length) for (d = 0; d < b; d++) {
  1482. H || (H = E(document.body, "transform") ? "transform" : "-webkit-transform"), g.animatables[d].target.style[H] = c[d].join(" ");
  1483. }g.currentTime = a;g.progress = a / g.duration * 100;
  1484. }function f(a) {
  1485. if (g[a]) g[a](g);
  1486. }function e() {
  1487. g.remaining && !0 !== g.remaining && g.remaining--;
  1488. }function k(a) {
  1489. var k = g.duration,
  1490. n = g.offset,
  1491. w = n + g.delay,
  1492. r = g.currentTime,
  1493. x = g.reversed,
  1494. q = d(a);if (g.children.length) {
  1495. var u = g.children,
  1496. v = u.length;
  1497. if (q >= g.currentTime) for (var G = 0; G < v; G++) {
  1498. u[G].seek(q);
  1499. } else for (; v--;) {
  1500. u[v].seek(q);
  1501. }
  1502. }if (q >= w || !k) g.began || (g.began = !0, f("begin")), f("run");if (q > n && q < k) b(q);else if (q <= n && 0 !== r && (b(0), x && e()), q >= k && r !== k || !k) b(k), x || e();f("update");a >= k && (g.remaining ? (t = h, "alternate" === g.direction && (g.reversed = !g.reversed)) : (g.pause(), g.completed || (g.completed = !0, f("complete"), "Promise" in window && (p(), m = c()))), l = 0);
  1503. }a = void 0 === a ? {} : a;var h,
  1504. t,
  1505. l = 0,
  1506. p = null,
  1507. m = c(),
  1508. g = fa(a);g.reset = function () {
  1509. var a = g.direction,
  1510. c = g.loop;g.currentTime = 0;g.progress = 0;g.paused = !0;g.began = !1;g.completed = !1;g.reversed = "reverse" === a;g.remaining = "alternate" === a && 1 === c ? 2 : c;b(0);for (a = g.children.length; a--;) {
  1511. g.children[a].reset();
  1512. }
  1513. };g.tick = function (a) {
  1514. h = a;t || (t = h);k((l + h - t) * q.speed);
  1515. };g.seek = function (a) {
  1516. k(d(a));
  1517. };g.pause = function () {
  1518. var a = v.indexOf(g);-1 < a && v.splice(a, 1);g.paused = !0;
  1519. };g.play = function () {
  1520. g.paused && (g.paused = !1, t = 0, l = d(g.currentTime), v.push(g), B || ia());
  1521. };g.reverse = function () {
  1522. g.reversed = !g.reversed;t = 0;l = d(g.currentTime);
  1523. };g.restart = function () {
  1524. g.pause();
  1525. g.reset();g.play();
  1526. };g.finished = m;g.reset();g.autoplay && g.play();return g;
  1527. }var ga = { update: void 0, begin: void 0, run: void 0, complete: void 0, loop: 1, direction: "normal", autoplay: !0, offset: 0 },
  1528. S = { duration: 1E3, delay: 0, easing: "easeOutElastic", elasticity: 500, round: 0 },
  1529. W = "translateX translateY translateZ rotate rotateX rotateY rotateZ scale scaleX scaleY scaleZ skewX skewY perspective".split(" "),
  1530. H,
  1531. h = { arr: function (a) {
  1532. return Array.isArray(a);
  1533. }, obj: function (a) {
  1534. return -1 < Object.prototype.toString.call(a).indexOf("Object");
  1535. },
  1536. pth: function (a) {
  1537. return h.obj(a) && a.hasOwnProperty("totalLength");
  1538. }, svg: function (a) {
  1539. return a instanceof SVGElement;
  1540. }, dom: function (a) {
  1541. return a.nodeType || h.svg(a);
  1542. }, str: function (a) {
  1543. return "string" === typeof a;
  1544. }, fnc: function (a) {
  1545. return "function" === typeof a;
  1546. }, und: function (a) {
  1547. return "undefined" === typeof a;
  1548. }, hex: function (a) {
  1549. return (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a)
  1550. );
  1551. }, rgb: function (a) {
  1552. return (/^rgb/.test(a)
  1553. );
  1554. }, hsl: function (a) {
  1555. return (/^hsl/.test(a)
  1556. );
  1557. }, col: function (a) {
  1558. return h.hex(a) || h.rgb(a) || h.hsl(a);
  1559. } },
  1560. A = function () {
  1561. function a(a, d, b) {
  1562. return (((1 - 3 * b + 3 * d) * a + (3 * b - 6 * d)) * a + 3 * d) * a;
  1563. }return function (c, d, b, f) {
  1564. if (0 <= c && 1 >= c && 0 <= b && 1 >= b) {
  1565. var e = new Float32Array(11);if (c !== d || b !== f) for (var k = 0; 11 > k; ++k) {
  1566. e[k] = a(.1 * k, c, b);
  1567. }return function (k) {
  1568. if (c === d && b === f) return k;if (0 === k) return 0;if (1 === k) return 1;for (var h = 0, l = 1; 10 !== l && e[l] <= k; ++l) {
  1569. h += .1;
  1570. }--l;var l = h + (k - e[l]) / (e[l + 1] - e[l]) * .1,
  1571. n = 3 * (1 - 3 * b + 3 * c) * l * l + 2 * (3 * b - 6 * c) * l + 3 * c;if (.001 <= n) {
  1572. for (h = 0; 4 > h; ++h) {
  1573. n = 3 * (1 - 3 * b + 3 * c) * l * l + 2 * (3 * b - 6 * c) * l + 3 * c;if (0 === n) break;var m = a(l, c, b) - k,
  1574. l = l - m / n;
  1575. }k = l;
  1576. } else if (0 === n) k = l;else {
  1577. var l = h,
  1578. h = h + .1,
  1579. g = 0;do {
  1580. m = l + (h - l) / 2, n = a(m, c, b) - k, 0 < n ? h = m : l = m;
  1581. } while (1e-7 < Math.abs(n) && 10 > ++g);k = m;
  1582. }return a(k, d, f);
  1583. };
  1584. }
  1585. };
  1586. }(),
  1587. Q = function () {
  1588. function a(a, b) {
  1589. return 0 === a || 1 === a ? a : -Math.pow(2, 10 * (a - 1)) * Math.sin(2 * (a - 1 - b / (2 * Math.PI) * Math.asin(1)) * Math.PI / b);
  1590. }var c = "Quad Cubic Quart Quint Sine Expo Circ Back Elastic".split(" "),
  1591. d = { In: [[.55, .085, .68, .53], [.55, .055, .675, .19], [.895, .03, .685, .22], [.755, .05, .855, .06], [.47, 0, .745, .715], [.95, .05, .795, .035], [.6, .04, .98, .335], [.6, -.28, .735, .045], a], Out: [[.25, .46, .45, .94], [.215, .61, .355, 1], [.165, .84, .44, 1], [.23, 1, .32, 1], [.39, .575, .565, 1], [.19, 1, .22, 1], [.075, .82, .165, 1], [.175, .885, .32, 1.275], function (b, c) {
  1592. return 1 - a(1 - b, c);
  1593. }], InOut: [[.455, .03, .515, .955], [.645, .045, .355, 1], [.77, 0, .175, 1], [.86, 0, .07, 1], [.445, .05, .55, .95], [1, 0, 0, 1], [.785, .135, .15, .86], [.68, -.55, .265, 1.55], function (b, c) {
  1594. return .5 > b ? a(2 * b, c) / 2 : 1 - a(-2 * b + 2, c) / 2;
  1595. }] },
  1596. b = { linear: A(.25, .25, .75, .75) },
  1597. f = {},
  1598. e;for (e in d) {
  1599. f.type = e, d[f.type].forEach(function (a) {
  1600. return function (d, f) {
  1601. b["ease" + a.type + c[f]] = h.fnc(d) ? d : A.apply($jscomp$this, d);
  1602. };
  1603. }(f)), f = { type: f.type };
  1604. }return b;
  1605. }(),
  1606. ha = { css: function (a, c, d) {
  1607. return a.style[c] = d;
  1608. }, attribute: function (a, c, d) {
  1609. return a.setAttribute(c, d);
  1610. }, object: function (a, c, d) {
  1611. return a[c] = d;
  1612. }, transform: function (a, c, d, b, f) {
  1613. b[f] || (b[f] = []);b[f].push(c + "(" + d + ")");
  1614. } },
  1615. v = [],
  1616. B = 0,
  1617. ia = function () {
  1618. function a() {
  1619. B = requestAnimationFrame(c);
  1620. }function c(c) {
  1621. var b = v.length;if (b) {
  1622. for (var d = 0; d < b;) {
  1623. v[d] && v[d].tick(c), d++;
  1624. }a();
  1625. } else cancelAnimationFrame(B), B = 0;
  1626. }return a;
  1627. }();q.version = "2.2.0";q.speed = 1;q.running = v;q.remove = function (a) {
  1628. a = P(a);for (var c = v.length; c--;) {
  1629. for (var d = v[c], b = d.animations, f = b.length; f--;) {
  1630. u(a, b[f].animatable.target) && (b.splice(f, 1), b.length || d.pause());
  1631. }
  1632. }
  1633. };q.getValue = K;q.path = function (a, c) {
  1634. var d = h.str(a) ? e(a)[0] : a,
  1635. b = c || 100;return function (a) {
  1636. return { el: d, property: a, totalLength: N(d) * (b / 100) };
  1637. };
  1638. };q.setDashoffset = function (a) {
  1639. var c = N(a);a.setAttribute("stroke-dasharray", c);return c;
  1640. };q.bezier = A;q.easings = Q;q.timeline = function (a) {
  1641. var c = q(a);c.pause();c.duration = 0;c.add = function (d) {
  1642. c.children.forEach(function (a) {
  1643. a.began = !0;a.completed = !0;
  1644. });m(d).forEach(function (b) {
  1645. var d = z(b, D(S, a || {}));d.targets = d.targets || a.targets;b = c.duration;var e = d.offset;d.autoplay = !1;d.direction = c.direction;d.offset = h.und(e) ? b : L(e, b);c.began = !0;c.completed = !0;c.seek(d.offset);d = q(d);d.began = !0;d.completed = !0;d.duration > b && (c.duration = d.duration);c.children.push(d);
  1646. });c.seek(0);c.reset();c.autoplay && c.restart();return c;
  1647. };return c;
  1648. };q.random = function (a, c) {
  1649. return Math.floor(Math.random() * (c - a + 1)) + a;
  1650. };return q;
  1651. });
  1652. ;(function ($, anim) {
  1653. 'use strict';
  1654. var _defaults = {
  1655. accordion: true,
  1656. onOpenStart: undefined,
  1657. onOpenEnd: undefined,
  1658. onCloseStart: undefined,
  1659. onCloseEnd: undefined,
  1660. inDuration: 300,
  1661. outDuration: 300
  1662. };
  1663. /**
  1664. * @class
  1665. *
  1666. */
  1667. var Collapsible = function (_Component) {
  1668. _inherits(Collapsible, _Component);
  1669. /**
  1670. * Construct Collapsible instance
  1671. * @constructor
  1672. * @param {Element} el
  1673. * @param {Object} options
  1674. */
  1675. function Collapsible(el, options) {
  1676. _classCallCheck(this, Collapsible);
  1677. var _this3 = _possibleConstructorReturn(this, (Collapsible.__proto__ || Object.getPrototypeOf(Collapsible)).call(this, Collapsible, el, options));
  1678. _this3.el.M_Collapsible = _this3;
  1679. /**
  1680. * Options for the collapsible
  1681. * @member Collapsible#options
  1682. * @prop {Boolean} [accordion=false] - Type of the collapsible
  1683. * @prop {Function} onOpenStart - Callback function called before collapsible is opened
  1684. * @prop {Function} onOpenEnd - Callback function called after collapsible is opened
  1685. * @prop {Function} onCloseStart - Callback function called before collapsible is closed
  1686. * @prop {Function} onCloseEnd - Callback function called after collapsible is closed
  1687. * @prop {Number} inDuration - Transition in duration in milliseconds.
  1688. * @prop {Number} outDuration - Transition duration in milliseconds.
  1689. */
  1690. _this3.options = $.extend({}, Collapsible.defaults, options);
  1691. // Setup tab indices
  1692. _this3.$headers = _this3.$el.children('li').children('.collapsible-header');
  1693. _this3.$headers.attr('tabindex', 0);
  1694. _this3._setupEventHandlers();
  1695. // Open first active
  1696. var $activeBodies = _this3.$el.children('li.active').children('.collapsible-body');
  1697. if (_this3.options.accordion) {
  1698. // Handle Accordion
  1699. $activeBodies.first().css('display', 'block');
  1700. } else {
  1701. // Handle Expandables
  1702. $activeBodies.css('display', 'block');
  1703. }
  1704. return _this3;
  1705. }
  1706. _createClass(Collapsible, [{
  1707. key: "destroy",
  1708. /**
  1709. * Teardown component
  1710. */
  1711. value: function destroy() {
  1712. this._removeEventHandlers();
  1713. this.el.M_Collapsible = undefined;
  1714. }
  1715. /**
  1716. * Setup Event Handlers
  1717. */
  1718. }, {
  1719. key: "_setupEventHandlers",
  1720. value: function _setupEventHandlers() {
  1721. var _this4 = this;
  1722. this._handleCollapsibleClickBound = this._handleCollapsibleClick.bind(this);
  1723. this._handleCollapsibleKeydownBound = this._handleCollapsibleKeydown.bind(this);
  1724. this.el.addEventListener('click', this._handleCollapsibleClickBound);
  1725. this.$headers.each(function (header) {
  1726. header.addEventListener('keydown', _this4._handleCollapsibleKeydownBound);
  1727. });
  1728. }
  1729. /**
  1730. * Remove Event Handlers
  1731. */
  1732. }, {
  1733. key: "_removeEventHandlers",
  1734. value: function _removeEventHandlers() {
  1735. var _this5 = this;
  1736. this.el.removeEventListener('click', this._handleCollapsibleClickBound);
  1737. this.$headers.each(function (header) {
  1738. header.removeEventListener('keydown', _this5._handleCollapsibleKeydownBound);
  1739. });
  1740. }
  1741. /**
  1742. * Handle Collapsible Click
  1743. * @param {Event} e
  1744. */
  1745. }, {
  1746. key: "_handleCollapsibleClick",
  1747. value: function _handleCollapsibleClick(e) {
  1748. var $header = $(e.target).closest('.collapsible-header');
  1749. if (e.target && $header.length) {
  1750. var $collapsible = $header.closest('.collapsible');
  1751. if ($collapsible[0] === this.el) {
  1752. var $collapsibleLi = $header.closest('li');
  1753. var $collapsibleLis = $collapsible.children('li');
  1754. var isActive = $collapsibleLi[0].classList.contains('active');
  1755. var index = $collapsibleLis.index($collapsibleLi);
  1756. if (isActive) {
  1757. this.close(index);
  1758. } else {
  1759. this.open(index);
  1760. }
  1761. }
  1762. }
  1763. }
  1764. /**
  1765. * Handle Collapsible Keydown
  1766. * @param {Event} e
  1767. */
  1768. }, {
  1769. key: "_handleCollapsibleKeydown",
  1770. value: function _handleCollapsibleKeydown(e) {
  1771. if (e.keyCode === 13) {
  1772. this._handleCollapsibleClickBound(e);
  1773. }
  1774. }
  1775. /**
  1776. * Animate in collapsible slide
  1777. * @param {Number} index - 0th index of slide
  1778. */
  1779. }, {
  1780. key: "_animateIn",
  1781. value: function _animateIn(index) {
  1782. var _this6 = this;
  1783. var $collapsibleLi = this.$el.children('li').eq(index);
  1784. if ($collapsibleLi.length) {
  1785. var $body = $collapsibleLi.children('.collapsible-body');
  1786. anim.remove($body[0]);
  1787. $body.css({
  1788. display: 'block',
  1789. overflow: 'hidden',
  1790. height: 0,
  1791. paddingTop: '',
  1792. paddingBottom: ''
  1793. });
  1794. var pTop = $body.css('padding-top');
  1795. var pBottom = $body.css('padding-bottom');
  1796. var finalHeight = $body[0].scrollHeight;
  1797. $body.css({
  1798. paddingTop: 0,
  1799. paddingBottom: 0
  1800. });
  1801. anim({
  1802. targets: $body[0],
  1803. height: finalHeight,
  1804. paddingTop: pTop,
  1805. paddingBottom: pBottom,
  1806. duration: this.options.inDuration,
  1807. easing: 'easeInOutCubic',
  1808. complete: function (anim) {
  1809. $body.css({
  1810. overflow: '',
  1811. paddingTop: '',
  1812. paddingBottom: '',
  1813. height: ''
  1814. });
  1815. // onOpenEnd callback
  1816. if (typeof _this6.options.onOpenEnd === 'function') {
  1817. _this6.options.onOpenEnd.call(_this6, $collapsibleLi[0]);
  1818. }
  1819. }
  1820. });
  1821. }
  1822. }
  1823. /**
  1824. * Animate out collapsible slide
  1825. * @param {Number} index - 0th index of slide to open
  1826. */
  1827. }, {
  1828. key: "_animateOut",
  1829. value: function _animateOut(index) {
  1830. var _this7 = this;
  1831. var $collapsibleLi = this.$el.children('li').eq(index);
  1832. if ($collapsibleLi.length) {
  1833. var $body = $collapsibleLi.children('.collapsible-body');
  1834. anim.remove($body[0]);
  1835. $body.css('overflow', 'hidden');
  1836. anim({
  1837. targets: $body[0],
  1838. height: 0,
  1839. paddingTop: 0,
  1840. paddingBottom: 0,
  1841. duration: this.options.outDuration,
  1842. easing: 'easeInOutCubic',
  1843. complete: function () {
  1844. $body.css({
  1845. height: '',
  1846. overflow: '',
  1847. padding: '',
  1848. display: ''
  1849. });
  1850. // onCloseEnd callback
  1851. if (typeof _this7.options.onCloseEnd === 'function') {
  1852. _this7.options.onCloseEnd.call(_this7, $collapsibleLi[0]);
  1853. }
  1854. }
  1855. });
  1856. }
  1857. }
  1858. /**
  1859. * Open Collapsible
  1860. * @param {Number} index - 0th index of slide
  1861. */
  1862. }, {
  1863. key: "open",
  1864. value: function open(index) {
  1865. var _this8 = this;
  1866. var $collapsibleLi = this.$el.children('li').eq(index);
  1867. if ($collapsibleLi.length && !$collapsibleLi[0].classList.contains('active')) {
  1868. // onOpenStart callback
  1869. if (typeof this.options.onOpenStart === 'function') {
  1870. this.options.onOpenStart.call(this, $collapsibleLi[0]);
  1871. }
  1872. // Handle accordion behavior
  1873. if (this.options.accordion) {
  1874. var $collapsibleLis = this.$el.children('li');
  1875. var $activeLis = this.$el.children('li.active');
  1876. $activeLis.each(function (el) {
  1877. var index = $collapsibleLis.index($(el));
  1878. _this8.close(index);
  1879. });
  1880. }
  1881. // Animate in
  1882. $collapsibleLi[0].classList.add('active');
  1883. this._animateIn(index);
  1884. }
  1885. }
  1886. /**
  1887. * Close Collapsible
  1888. * @param {Number} index - 0th index of slide
  1889. */
  1890. }, {
  1891. key: "close",
  1892. value: function close(index) {
  1893. var $collapsibleLi = this.$el.children('li').eq(index);
  1894. if ($collapsibleLi.length && $collapsibleLi[0].classList.contains('active')) {
  1895. // onCloseStart callback
  1896. if (typeof this.options.onCloseStart === 'function') {
  1897. this.options.onCloseStart.call(this, $collapsibleLi[0]);
  1898. }
  1899. // Animate out
  1900. $collapsibleLi[0].classList.remove('active');
  1901. this._animateOut(index);
  1902. }
  1903. }
  1904. }], [{
  1905. key: "init",
  1906. value: function init(els, options) {
  1907. return _get(Collapsible.__proto__ || Object.getPrototypeOf(Collapsible), "init", this).call(this, this, els, options);
  1908. }
  1909. /**
  1910. * Get Instance
  1911. */
  1912. }, {
  1913. key: "getInstance",
  1914. value: function getInstance(el) {
  1915. var domElem = !!el.jquery ? el[0] : el;
  1916. return domElem.M_Collapsible;
  1917. }
  1918. }, {
  1919. key: "defaults",
  1920. get: function () {
  1921. return _defaults;
  1922. }
  1923. }]);
  1924. return Collapsible;
  1925. }(Component);
  1926. M.Collapsible = Collapsible;
  1927. if (M.jQueryLoaded) {
  1928. M.initializeJqueryWrapper(Collapsible, 'collapsible', 'M_Collapsible');
  1929. }
  1930. })(cash, M.anime);
  1931. ;(function ($, anim) {
  1932. 'use strict';
  1933. var _defaults = {
  1934. alignment: 'left',
  1935. autoFocus: true,
  1936. constrainWidth: true,
  1937. container: null,
  1938. coverTrigger: true,
  1939. closeOnClick: true,
  1940. hover: false,
  1941. inDuration: 150,
  1942. outDuration: 250,
  1943. onOpenStart: null,
  1944. onOpenEnd: null,
  1945. onCloseStart: null,
  1946. onCloseEnd: null,
  1947. onItemClick: null
  1948. };
  1949. /**
  1950. * @class
  1951. */
  1952. var Dropdown = function (_Component2) {
  1953. _inherits(Dropdown, _Component2);
  1954. function Dropdown(el, options) {
  1955. _classCallCheck(this, Dropdown);
  1956. var _this9 = _possibleConstructorReturn(this, (Dropdown.__proto__ || Object.getPrototypeOf(Dropdown)).call(this, Dropdown, el, options));
  1957. _this9.el.M_Dropdown = _this9;
  1958. Dropdown._dropdowns.push(_this9);
  1959. _this9.id = M.getIdFromTrigger(el);
  1960. _this9.dropdownEl = document.getElementById(_this9.id);
  1961. _this9.$dropdownEl = $(_this9.dropdownEl);
  1962. /**
  1963. * Options for the dropdown
  1964. * @member Dropdown#options
  1965. * @prop {String} [alignment='left'] - Edge which the dropdown is aligned to
  1966. * @prop {Boolean} [autoFocus=true] - Automatically focus dropdown el for keyboard
  1967. * @prop {Boolean} [constrainWidth=true] - Constrain width to width of the button
  1968. * @prop {Element} container - Container element to attach dropdown to (optional)
  1969. * @prop {Boolean} [coverTrigger=true] - Place dropdown over trigger
  1970. * @prop {Boolean} [closeOnClick=true] - Close on click of dropdown item
  1971. * @prop {Boolean} [hover=false] - Open dropdown on hover
  1972. * @prop {Number} [inDuration=150] - Duration of open animation in ms
  1973. * @prop {Number} [outDuration=250] - Duration of close animation in ms
  1974. * @prop {Function} onOpenStart - Function called when dropdown starts opening
  1975. * @prop {Function} onOpenEnd - Function called when dropdown finishes opening
  1976. * @prop {Function} onCloseStart - Function called when dropdown starts closing
  1977. * @prop {Function} onCloseEnd - Function called when dropdown finishes closing
  1978. */
  1979. _this9.options = $.extend({}, Dropdown.defaults, options);
  1980. /**
  1981. * Describes open/close state of dropdown
  1982. * @type {Boolean}
  1983. */
  1984. _this9.isOpen = false;
  1985. /**
  1986. * Describes if dropdown content is scrollable
  1987. * @type {Boolean}
  1988. */
  1989. _this9.isScrollable = false;
  1990. /**
  1991. * Describes if touch moving on dropdown content
  1992. * @type {Boolean}
  1993. */
  1994. _this9.isTouchMoving = false;
  1995. _this9.focusedIndex = -1;
  1996. _this9.filterQuery = [];
  1997. // Move dropdown-content after dropdown-trigger
  1998. if (!!_this9.options.container) {
  1999. $(_this9.options.container).append(_this9.dropdownEl);
  2000. } else {
  2001. _this9.$el.after(_this9.dropdownEl);
  2002. }
  2003. _this9._makeDropdownFocusable();
  2004. _this9._resetFilterQueryBound = _this9._resetFilterQuery.bind(_this9);
  2005. _this9._handleDocumentClickBound = _this9._handleDocumentClick.bind(_this9);
  2006. _this9._handleDocumentTouchmoveBound = _this9._handleDocumentTouchmove.bind(_this9);
  2007. _this9._handleDropdownClickBound = _this9._handleDropdownClick.bind(_this9);
  2008. _this9._handleDropdownKeydownBound = _this9._handleDropdownKeydown.bind(_this9);
  2009. _this9._handleTriggerKeydownBound = _this9._handleTriggerKeydown.bind(_this9);
  2010. _this9._setupEventHandlers();
  2011. return _this9;
  2012. }
  2013. _createClass(Dropdown, [{
  2014. key: "destroy",
  2015. /**
  2016. * Teardown component
  2017. */
  2018. value: function destroy() {
  2019. this._resetDropdownStyles();
  2020. this._removeEventHandlers();
  2021. Dropdown._dropdowns.splice(Dropdown._dropdowns.indexOf(this), 1);
  2022. this.el.M_Dropdown = undefined;
  2023. }
  2024. /**
  2025. * Setup Event Handlers
  2026. */
  2027. }, {
  2028. key: "_setupEventHandlers",
  2029. value: function _setupEventHandlers() {
  2030. // Trigger keydown handler
  2031. this.el.addEventListener('keydown', this._handleTriggerKeydownBound);
  2032. // Item click handler
  2033. this.dropdownEl.addEventListener('click', this._handleDropdownClickBound);
  2034. // Hover event handlers
  2035. if (this.options.hover) {
  2036. this._handleMouseEnterBound = this._handleMouseEnter.bind(this);
  2037. this.el.addEventListener('mouseenter', this._handleMouseEnterBound);
  2038. this._handleMouseLeaveBound = this._handleMouseLeave.bind(this);
  2039. this.el.addEventListener('mouseleave', this._handleMouseLeaveBound);
  2040. this.dropdownEl.addEventListener('mouseleave', this._handleMouseLeaveBound);
  2041. // Click event handlers
  2042. } else {
  2043. this._handleClickBound = this._handleClick.bind(this);
  2044. this.el.addEventListener('click', this._handleClickBound);
  2045. }
  2046. }
  2047. /**
  2048. * Remove Event Handlers
  2049. */
  2050. }, {
  2051. key: "_removeEventHandlers",
  2052. value: function _removeEventHandlers() {
  2053. this.el.removeEventListener('keydown', this._handleTriggerKeydownBound);
  2054. this.dropdownEl.removeEventListener('click', this._handleDropdownClickBound);
  2055. if (this.options.hover) {
  2056. this.el.removeEventListener('mouseenter', this._handleMouseEnterBound);
  2057. this.el.removeEventListener('mouseleave', this._handleMouseLeaveBound);
  2058. this.dropdownEl.removeEventListener('mouseleave', this._handleMouseLeaveBound);
  2059. } else {
  2060. this.el.removeEventListener('click', this._handleClickBound);
  2061. }
  2062. }
  2063. }, {
  2064. key: "_setupTemporaryEventHandlers",
  2065. value: function _setupTemporaryEventHandlers() {
  2066. // Use capture phase event handler to prevent click
  2067. document.body.addEventListener('click', this._handleDocumentClickBound, true);
  2068. document.body.addEventListener('touchend', this._handleDocumentClickBound);
  2069. document.body.addEventListener('touchmove', this._handleDocumentTouchmoveBound);
  2070. this.dropdownEl.addEventListener('keydown', this._handleDropdownKeydownBound);
  2071. }
  2072. }, {
  2073. key: "_removeTemporaryEventHandlers",
  2074. value: function _removeTemporaryEventHandlers() {
  2075. // Use capture phase event handler to prevent click
  2076. document.body.removeEventListener('click', this._handleDocumentClickBound, true);
  2077. document.body.removeEventListener('touchend', this._handleDocumentClickBound);
  2078. document.body.removeEventListener('touchmove', this._handleDocumentTouchmoveBound);
  2079. this.dropdownEl.removeEventListener('keydown', this._handleDropdownKeydownBound);
  2080. }
  2081. }, {
  2082. key: "_handleClick",
  2083. value: function _handleClick(e) {
  2084. e.preventDefault();
  2085. this.open();
  2086. }
  2087. }, {
  2088. key: "_handleMouseEnter",
  2089. value: function _handleMouseEnter() {
  2090. this.open();
  2091. }
  2092. }, {
  2093. key: "_handleMouseLeave",
  2094. value: function _handleMouseLeave(e) {
  2095. var toEl = e.toElement || e.relatedTarget;
  2096. var leaveToDropdownContent = !!$(toEl).closest('.dropdown-content').length;
  2097. var leaveToActiveDropdownTrigger = false;
  2098. var $closestTrigger = $(toEl).closest('.dropdown-trigger');
  2099. if ($closestTrigger.length && !!$closestTrigger[0].M_Dropdown && $closestTrigger[0].M_Dropdown.isOpen) {
  2100. leaveToActiveDropdownTrigger = true;
  2101. }
  2102. // Close hover dropdown if mouse did not leave to either active dropdown-trigger or dropdown-content
  2103. if (!leaveToActiveDropdownTrigger && !leaveToDropdownContent) {
  2104. this.close();
  2105. }
  2106. }
  2107. }, {
  2108. key: "_handleDocumentClick",
  2109. value: function _handleDocumentClick(e) {
  2110. var _this10 = this;
  2111. var $target = $(e.target);
  2112. if (this.options.closeOnClick && $target.closest('.dropdown-content').length && !this.isTouchMoving) {
  2113. // isTouchMoving to check if scrolling on mobile.
  2114. setTimeout(function () {
  2115. _this10.close();
  2116. }, 0);
  2117. } else if ($target.closest('.dropdown-trigger').length || !$target.closest('.dropdown-content').length) {
  2118. setTimeout(function () {
  2119. _this10.close();
  2120. }, 0);
  2121. }
  2122. this.isTouchMoving = false;
  2123. }
  2124. }, {
  2125. key: "_handleTriggerKeydown",
  2126. value: function _handleTriggerKeydown(e) {
  2127. // ARROW DOWN OR ENTER WHEN SELECT IS CLOSED - open Dropdown
  2128. if ((e.which === M.keys.ARROW_DOWN || e.which === M.keys.ENTER) && !this.isOpen) {
  2129. e.preventDefault();
  2130. this.open();
  2131. }
  2132. }
  2133. /**
  2134. * Handle Document Touchmove
  2135. * @param {Event} e
  2136. */
  2137. }, {
  2138. key: "_handleDocumentTouchmove",
  2139. value: function _handleDocumentTouchmove(e) {
  2140. var $target = $(e.target);
  2141. if ($target.closest('.dropdown-content').length) {
  2142. this.isTouchMoving = true;
  2143. }
  2144. }
  2145. /**
  2146. * Handle Dropdown Click
  2147. * @param {Event} e
  2148. */
  2149. }, {
  2150. key: "_handleDropdownClick",
  2151. value: function _handleDropdownClick(e) {
  2152. // onItemClick callback
  2153. if (typeof this.options.onItemClick === 'function') {
  2154. var itemEl = $(e.target).closest('li')[0];
  2155. this.options.onItemClick.call(this, itemEl);
  2156. }
  2157. }
  2158. /**
  2159. * Handle Dropdown Keydown
  2160. * @param {Event} e
  2161. */
  2162. }, {
  2163. key: "_handleDropdownKeydown",
  2164. value: function _handleDropdownKeydown(e) {
  2165. if (e.which === M.keys.TAB) {
  2166. e.preventDefault();
  2167. this.close();
  2168. // Navigate down dropdown list
  2169. } else if ((e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) && this.isOpen) {
  2170. e.preventDefault();
  2171. var direction = e.which === M.keys.ARROW_DOWN ? 1 : -1;
  2172. var newFocusedIndex = this.focusedIndex;
  2173. var foundNewIndex = false;
  2174. do {
  2175. newFocusedIndex = newFocusedIndex + direction;
  2176. if (!!this.dropdownEl.children[newFocusedIndex] && this.dropdownEl.children[newFocusedIndex].tabIndex !== -1) {
  2177. foundNewIndex = true;
  2178. break;
  2179. }
  2180. } while (newFocusedIndex < this.dropdownEl.children.length && newFocusedIndex >= 0);
  2181. if (foundNewIndex) {
  2182. this.focusedIndex = newFocusedIndex;
  2183. this._focusFocusedItem();
  2184. }
  2185. // ENTER selects choice on focused item
  2186. } else if (e.which === M.keys.ENTER && this.isOpen) {
  2187. // Search for <a> and <button>
  2188. var focusedElement = this.dropdownEl.children[this.focusedIndex];
  2189. var $activatableElement = $(focusedElement).find('a, button').first();
  2190. // Click a or button tag if exists, otherwise click li tag
  2191. !!$activatableElement.length ? $activatableElement[0].click() : focusedElement.click();
  2192. // Close dropdown on ESC
  2193. } else if (e.which === M.keys.ESC && this.isOpen) {
  2194. e.preventDefault();
  2195. this.close();
  2196. }
  2197. // CASE WHEN USER TYPE LETTERS
  2198. var letter = String.fromCharCode(e.which).toLowerCase(),
  2199. nonLetters = [9, 13, 27, 38, 40];
  2200. if (letter && nonLetters.indexOf(e.which) === -1) {
  2201. this.filterQuery.push(letter);
  2202. var string = this.filterQuery.join(''),
  2203. newOptionEl = $(this.dropdownEl).find('li').filter(function (el) {
  2204. return $(el).text().toLowerCase().indexOf(string) === 0;
  2205. })[0];
  2206. if (newOptionEl) {
  2207. this.focusedIndex = $(newOptionEl).index();
  2208. this._focusFocusedItem();
  2209. }
  2210. }
  2211. this.filterTimeout = setTimeout(this._resetFilterQueryBound, 1000);
  2212. }
  2213. /**
  2214. * Setup dropdown
  2215. */
  2216. }, {
  2217. key: "_resetFilterQuery",
  2218. value: function _resetFilterQuery() {
  2219. this.filterQuery = [];
  2220. }
  2221. }, {
  2222. key: "_resetDropdownStyles",
  2223. value: function _resetDropdownStyles() {
  2224. this.$dropdownEl.css({
  2225. display: '',
  2226. width: '',
  2227. height: '',
  2228. left: '',
  2229. top: '',
  2230. 'transform-origin': '',
  2231. transform: '',
  2232. opacity: ''
  2233. });
  2234. }
  2235. }, {
  2236. key: "_makeDropdownFocusable",
  2237. value: function _makeDropdownFocusable() {
  2238. // Needed for arrow key navigation
  2239. this.dropdownEl.tabIndex = 0;
  2240. // Only set tabindex if it hasn't been set by user
  2241. $(this.dropdownEl).children().each(function (el) {
  2242. if (!el.getAttribute('tabindex')) {
  2243. el.setAttribute('tabindex', 0);
  2244. }
  2245. });
  2246. }
  2247. }, {
  2248. key: "_focusFocusedItem",
  2249. value: function _focusFocusedItem() {
  2250. if (this.focusedIndex >= 0 && this.focusedIndex < this.dropdownEl.children.length && this.options.autoFocus) {
  2251. this.dropdownEl.children[this.focusedIndex].focus();
  2252. }
  2253. }
  2254. }, {
  2255. key: "_getDropdownPosition",
  2256. value: function _getDropdownPosition() {
  2257. var offsetParentBRect = this.el.offsetParent.getBoundingClientRect();
  2258. var triggerBRect = this.el.getBoundingClientRect();
  2259. var dropdownBRect = this.dropdownEl.getBoundingClientRect();
  2260. var idealHeight = dropdownBRect.height;
  2261. var idealWidth = dropdownBRect.width;
  2262. var idealXPos = triggerBRect.left - dropdownBRect.left;
  2263. var idealYPos = triggerBRect.top - dropdownBRect.top;
  2264. var dropdownBounds = {
  2265. left: idealXPos,
  2266. top: idealYPos,
  2267. height: idealHeight,
  2268. width: idealWidth
  2269. };
  2270. // Countainer here will be closest ancestor with overflow: hidden
  2271. var closestOverflowParent = !!this.dropdownEl.offsetParent ? this.dropdownEl.offsetParent : this.dropdownEl.parentNode;
  2272. var alignments = M.checkPossibleAlignments(this.el, closestOverflowParent, dropdownBounds, this.options.coverTrigger ? 0 : triggerBRect.height);
  2273. var verticalAlignment = 'top';
  2274. var horizontalAlignment = this.options.alignment;
  2275. idealYPos += this.options.coverTrigger ? 0 : triggerBRect.height;
  2276. // Reset isScrollable
  2277. this.isScrollable = false;
  2278. if (!alignments.top) {
  2279. if (alignments.bottom) {
  2280. verticalAlignment = 'bottom';
  2281. } else {
  2282. this.isScrollable = true;
  2283. // Determine which side has most space and cutoff at correct height
  2284. if (alignments.spaceOnTop > alignments.spaceOnBottom) {
  2285. verticalAlignment = 'bottom';
  2286. idealHeight += alignments.spaceOnTop;
  2287. idealYPos -= alignments.spaceOnTop;
  2288. } else {
  2289. idealHeight += alignments.spaceOnBottom;
  2290. }
  2291. }
  2292. }
  2293. // If preferred horizontal alignment is possible
  2294. if (!alignments[horizontalAlignment]) {
  2295. var oppositeAlignment = horizontalAlignment === 'left' ? 'right' : 'left';
  2296. if (alignments[oppositeAlignment]) {
  2297. horizontalAlignment = oppositeAlignment;
  2298. } else {
  2299. // Determine which side has most space and cutoff at correct height
  2300. if (alignments.spaceOnLeft > alignments.spaceOnRight) {
  2301. horizontalAlignment = 'right';
  2302. idealWidth += alignments.spaceOnLeft;
  2303. idealXPos -= alignments.spaceOnLeft;
  2304. } else {
  2305. horizontalAlignment = 'left';
  2306. idealWidth += alignments.spaceOnRight;
  2307. }
  2308. }
  2309. }
  2310. if (verticalAlignment === 'bottom') {
  2311. idealYPos = idealYPos - dropdownBRect.height + (this.options.coverTrigger ? triggerBRect.height : 0);
  2312. }
  2313. if (horizontalAlignment === 'right') {
  2314. idealXPos = idealXPos - dropdownBRect.width + triggerBRect.width;
  2315. }
  2316. return {
  2317. x: idealXPos,
  2318. y: idealYPos,
  2319. verticalAlignment: verticalAlignment,
  2320. horizontalAlignment: horizontalAlignment,
  2321. height: idealHeight,
  2322. width: idealWidth
  2323. };
  2324. }
  2325. /**
  2326. * Animate in dropdown
  2327. */
  2328. }, {
  2329. key: "_animateIn",
  2330. value: function _animateIn() {
  2331. var _this11 = this;
  2332. anim.remove(this.dropdownEl);
  2333. anim({
  2334. targets: this.dropdownEl,
  2335. opacity: {
  2336. value: [0, 1],
  2337. easing: 'easeOutQuad'
  2338. },
  2339. scaleX: [0.3, 1],
  2340. scaleY: [0.3, 1],
  2341. duration: this.options.inDuration,
  2342. easing: 'easeOutQuint',
  2343. complete: function (anim) {
  2344. if (_this11.options.autoFocus) {
  2345. _this11.dropdownEl.focus();
  2346. }
  2347. // onOpenEnd callback
  2348. if (typeof _this11.options.onOpenEnd === 'function') {
  2349. var elem = anim.animatables[0].target;
  2350. _this11.options.onOpenEnd.call(elem, _this11.el);
  2351. }
  2352. }
  2353. });
  2354. }
  2355. /**
  2356. * Animate out dropdown
  2357. */
  2358. }, {
  2359. key: "_animateOut",
  2360. value: function _animateOut() {
  2361. var _this12 = this;
  2362. anim.remove(this.dropdownEl);
  2363. anim({
  2364. targets: this.dropdownEl,
  2365. opacity: {
  2366. value: 0,
  2367. easing: 'easeOutQuint'
  2368. },
  2369. scaleX: 0.3,
  2370. scaleY: 0.3,
  2371. duration: this.options.outDuration,
  2372. easing: 'easeOutQuint',
  2373. complete: function (anim) {
  2374. _this12._resetDropdownStyles();
  2375. // onCloseEnd callback
  2376. if (typeof _this12.options.onCloseEnd === 'function') {
  2377. var elem = anim.animatables[0].target;
  2378. _this12.options.onCloseEnd.call(_this12, _this12.el);
  2379. }
  2380. }
  2381. });
  2382. }
  2383. /**
  2384. * Place dropdown
  2385. */
  2386. }, {
  2387. key: "_placeDropdown",
  2388. value: function _placeDropdown() {
  2389. // Set width before calculating positionInfo
  2390. var idealWidth = this.options.constrainWidth ? this.el.getBoundingClientRect().width : this.dropdownEl.getBoundingClientRect().width;
  2391. this.dropdownEl.style.width = idealWidth + 'px';
  2392. var positionInfo = this._getDropdownPosition();
  2393. this.dropdownEl.style.left = positionInfo.x + 'px';
  2394. this.dropdownEl.style.top = positionInfo.y + 'px';
  2395. this.dropdownEl.style.height = positionInfo.height + 'px';
  2396. this.dropdownEl.style.width = positionInfo.width + 'px';
  2397. this.dropdownEl.style.transformOrigin = (positionInfo.horizontalAlignment === 'left' ? '0' : '100%') + " " + (positionInfo.verticalAlignment === 'top' ? '0' : '100%');
  2398. }
  2399. /**
  2400. * Open Dropdown
  2401. */
  2402. }, {
  2403. key: "open",
  2404. value: function open() {
  2405. if (this.isOpen) {
  2406. return;
  2407. }
  2408. this.isOpen = true;
  2409. // onOpenStart callback
  2410. if (typeof this.options.onOpenStart === 'function') {
  2411. this.options.onOpenStart.call(this, this.el);
  2412. }
  2413. // Reset styles
  2414. this._resetDropdownStyles();
  2415. this.dropdownEl.style.display = 'block';
  2416. this._placeDropdown();
  2417. this._animateIn();
  2418. this._setupTemporaryEventHandlers();
  2419. }
  2420. /**
  2421. * Close Dropdown
  2422. */
  2423. }, {
  2424. key: "close",
  2425. value: function close() {
  2426. if (!this.isOpen) {
  2427. return;
  2428. }
  2429. this.isOpen = false;
  2430. this.focusedIndex = -1;
  2431. // onCloseStart callback
  2432. if (typeof this.options.onCloseStart === 'function') {
  2433. this.options.onCloseStart.call(this, this.el);
  2434. }
  2435. this._animateOut();
  2436. this._removeTemporaryEventHandlers();
  2437. if (this.options.autoFocus) {
  2438. this.el.focus();
  2439. }
  2440. }
  2441. /**
  2442. * Recalculate dimensions
  2443. */
  2444. }, {
  2445. key: "recalculateDimensions",
  2446. value: function recalculateDimensions() {
  2447. if (this.isOpen) {
  2448. this.$dropdownEl.css({
  2449. width: '',
  2450. height: '',
  2451. left: '',
  2452. top: '',
  2453. 'transform-origin': ''
  2454. });
  2455. this._placeDropdown();
  2456. }
  2457. }
  2458. }], [{
  2459. key: "init",
  2460. value: function init(els, options) {
  2461. return _get(Dropdown.__proto__ || Object.getPrototypeOf(Dropdown), "init", this).call(this, this, els, options);
  2462. }
  2463. /**
  2464. * Get Instance
  2465. */
  2466. }, {
  2467. key: "getInstance",
  2468. value: function getInstance(el) {
  2469. var domElem = !!el.jquery ? el[0] : el;
  2470. return domElem.M_Dropdown;
  2471. }
  2472. }, {
  2473. key: "defaults",
  2474. get: function () {
  2475. return _defaults;
  2476. }
  2477. }]);
  2478. return Dropdown;
  2479. }(Component);
  2480. /**
  2481. * @static
  2482. * @memberof Dropdown
  2483. */
  2484. Dropdown._dropdowns = [];
  2485. window.M.Dropdown = Dropdown;
  2486. if (M.jQueryLoaded) {
  2487. M.initializeJqueryWrapper(Dropdown, 'dropdown', 'M_Dropdown');
  2488. }
  2489. })(cash, M.anime);
  2490. ;(function ($, anim) {
  2491. 'use strict';
  2492. var _defaults = {
  2493. opacity: 0.5,
  2494. inDuration: 250,
  2495. outDuration: 250,
  2496. onOpenStart: null,
  2497. onOpenEnd: null,
  2498. onCloseStart: null,
  2499. onCloseEnd: null,
  2500. preventScrolling: true,
  2501. dismissible: true,
  2502. startingTop: '4%',
  2503. endingTop: '10%'
  2504. };
  2505. /**
  2506. * @class
  2507. *
  2508. */
  2509. var Modal = function (_Component3) {
  2510. _inherits(Modal, _Component3);
  2511. /**
  2512. * Construct Modal instance and set up overlay
  2513. * @constructor
  2514. * @param {Element} el
  2515. * @param {Object} options
  2516. */
  2517. function Modal(el, options) {
  2518. _classCallCheck(this, Modal);
  2519. var _this13 = _possibleConstructorReturn(this, (Modal.__proto__ || Object.getPrototypeOf(Modal)).call(this, Modal, el, options));
  2520. _this13.el.M_Modal = _this13;
  2521. /**
  2522. * Options for the modal
  2523. * @member Modal#options
  2524. * @prop {Number} [opacity=0.5] - Opacity of the modal overlay
  2525. * @prop {Number} [inDuration=250] - Length in ms of enter transition
  2526. * @prop {Number} [outDuration=250] - Length in ms of exit transition
  2527. * @prop {Function} onOpenStart - Callback function called before modal is opened
  2528. * @prop {Function} onOpenEnd - Callback function called after modal is opened
  2529. * @prop {Function} onCloseStart - Callback function called before modal is closed
  2530. * @prop {Function} onCloseEnd - Callback function called after modal is closed
  2531. * @prop {Boolean} [dismissible=true] - Allow modal to be dismissed by keyboard or overlay click
  2532. * @prop {String} [startingTop='4%'] - startingTop
  2533. * @prop {String} [endingTop='10%'] - endingTop
  2534. */
  2535. _this13.options = $.extend({}, Modal.defaults, options);
  2536. /**
  2537. * Describes open/close state of modal
  2538. * @type {Boolean}
  2539. */
  2540. _this13.isOpen = false;
  2541. _this13.id = _this13.$el.attr('id');
  2542. _this13._openingTrigger = undefined;
  2543. _this13.$overlay = $('<div class="modal-overlay"></div>');
  2544. _this13.el.tabIndex = 0;
  2545. _this13._nthModalOpened = 0;
  2546. Modal._count++;
  2547. _this13._setupEventHandlers();
  2548. return _this13;
  2549. }
  2550. _createClass(Modal, [{
  2551. key: "destroy",
  2552. /**
  2553. * Teardown component
  2554. */
  2555. value: function destroy() {
  2556. Modal._count--;
  2557. this._removeEventHandlers();
  2558. this.el.removeAttribute('style');
  2559. this.$overlay.remove();
  2560. this.el.M_Modal = undefined;
  2561. }
  2562. /**
  2563. * Setup Event Handlers
  2564. */
  2565. }, {
  2566. key: "_setupEventHandlers",
  2567. value: function _setupEventHandlers() {
  2568. this._handleOverlayClickBound = this._handleOverlayClick.bind(this);
  2569. this._handleModalCloseClickBound = this._handleModalCloseClick.bind(this);
  2570. if (Modal._count === 1) {
  2571. document.body.addEventListener('click', this._handleTriggerClick);
  2572. }
  2573. this.$overlay[0].addEventListener('click', this._handleOverlayClickBound);
  2574. this.el.addEventListener('click', this._handleModalCloseClickBound);
  2575. }
  2576. /**
  2577. * Remove Event Handlers
  2578. */
  2579. }, {
  2580. key: "_removeEventHandlers",
  2581. value: function _removeEventHandlers() {
  2582. if (Modal._count === 0) {
  2583. document.body.removeEventListener('click', this._handleTriggerClick);
  2584. }
  2585. this.$overlay[0].removeEventListener('click', this._handleOverlayClickBound);
  2586. this.el.removeEventListener('click', this._handleModalCloseClickBound);
  2587. }
  2588. /**
  2589. * Handle Trigger Click
  2590. * @param {Event} e
  2591. */
  2592. }, {
  2593. key: "_handleTriggerClick",
  2594. value: function _handleTriggerClick(e) {
  2595. var $trigger = $(e.target).closest('.modal-trigger');
  2596. if ($trigger.length) {
  2597. var modalId = M.getIdFromTrigger($trigger[0]);
  2598. var modalInstance = document.getElementById(modalId).M_Modal;
  2599. if (modalInstance) {
  2600. modalInstance.open($trigger);
  2601. }
  2602. e.preventDefault();
  2603. }
  2604. }
  2605. /**
  2606. * Handle Overlay Click
  2607. */
  2608. }, {
  2609. key: "_handleOverlayClick",
  2610. value: function _handleOverlayClick() {
  2611. if (this.options.dismissible) {
  2612. this.close();
  2613. }
  2614. }
  2615. /**
  2616. * Handle Modal Close Click
  2617. * @param {Event} e
  2618. */
  2619. }, {
  2620. key: "_handleModalCloseClick",
  2621. value: function _handleModalCloseClick(e) {
  2622. var $closeTrigger = $(e.target).closest('.modal-close');
  2623. if ($closeTrigger.length) {
  2624. this.close();
  2625. }
  2626. }
  2627. /**
  2628. * Handle Keydown
  2629. * @param {Event} e
  2630. */
  2631. }, {
  2632. key: "_handleKeydown",
  2633. value: function _handleKeydown(e) {
  2634. // ESC key
  2635. if (e.keyCode === 27 && this.options.dismissible) {
  2636. this.close();
  2637. }
  2638. }
  2639. /**
  2640. * Handle Focus
  2641. * @param {Event} e
  2642. */
  2643. }, {
  2644. key: "_handleFocus",
  2645. value: function _handleFocus(e) {
  2646. // Only trap focus if this modal is the last model opened (prevents loops in nested modals).
  2647. if (!this.el.contains(e.target) && this._nthModalOpened === Modal._modalsOpen) {
  2648. this.el.focus();
  2649. }
  2650. }
  2651. /**
  2652. * Animate in modal
  2653. */
  2654. }, {
  2655. key: "_animateIn",
  2656. value: function _animateIn() {
  2657. var _this14 = this;
  2658. // Set initial styles
  2659. $.extend(this.el.style, {
  2660. display: 'block',
  2661. opacity: 0
  2662. });
  2663. $.extend(this.$overlay[0].style, {
  2664. display: 'block',
  2665. opacity: 0
  2666. });
  2667. // Animate overlay
  2668. anim({
  2669. targets: this.$overlay[0],
  2670. opacity: this.options.opacity,
  2671. duration: this.options.inDuration,
  2672. easing: 'easeOutQuad'
  2673. });
  2674. // Define modal animation options
  2675. var enterAnimOptions = {
  2676. targets: this.el,
  2677. duration: this.options.inDuration,
  2678. easing: 'easeOutCubic',
  2679. // Handle modal onOpenEnd callback
  2680. complete: function () {
  2681. if (typeof _this14.options.onOpenEnd === 'function') {
  2682. _this14.options.onOpenEnd.call(_this14, _this14.el, _this14._openingTrigger);
  2683. }
  2684. }
  2685. };
  2686. // Bottom sheet animation
  2687. if (this.el.classList.contains('bottom-sheet')) {
  2688. $.extend(enterAnimOptions, {
  2689. bottom: 0,
  2690. opacity: 1
  2691. });
  2692. anim(enterAnimOptions);
  2693. // Normal modal animation
  2694. } else {
  2695. $.extend(enterAnimOptions, {
  2696. top: [this.options.startingTop, this.options.endingTop],
  2697. opacity: 1,
  2698. scaleX: [0.8, 1],
  2699. scaleY: [0.8, 1]
  2700. });
  2701. anim(enterAnimOptions);
  2702. }
  2703. }
  2704. /**
  2705. * Animate out modal
  2706. */
  2707. }, {
  2708. key: "_animateOut",
  2709. value: function _animateOut() {
  2710. var _this15 = this;
  2711. // Animate overlay
  2712. anim({
  2713. targets: this.$overlay[0],
  2714. opacity: 0,
  2715. duration: this.options.outDuration,
  2716. easing: 'easeOutQuart'
  2717. });
  2718. // Define modal animation options
  2719. var exitAnimOptions = {
  2720. targets: this.el,
  2721. duration: this.options.outDuration,
  2722. easing: 'easeOutCubic',
  2723. // Handle modal ready callback
  2724. complete: function () {
  2725. _this15.el.style.display = 'none';
  2726. _this15.$overlay.remove();
  2727. // Call onCloseEnd callback
  2728. if (typeof _this15.options.onCloseEnd === 'function') {
  2729. _this15.options.onCloseEnd.call(_this15, _this15.el);
  2730. }
  2731. }
  2732. };
  2733. // Bottom sheet animation
  2734. if (this.el.classList.contains('bottom-sheet')) {
  2735. $.extend(exitAnimOptions, {
  2736. bottom: '-100%',
  2737. opacity: 0
  2738. });
  2739. anim(exitAnimOptions);
  2740. // Normal modal animation
  2741. } else {
  2742. $.extend(exitAnimOptions, {
  2743. top: [this.options.endingTop, this.options.startingTop],
  2744. opacity: 0,
  2745. scaleX: 0.8,
  2746. scaleY: 0.8
  2747. });
  2748. anim(exitAnimOptions);
  2749. }
  2750. }
  2751. /**
  2752. * Open Modal
  2753. * @param {cash} [$trigger]
  2754. */
  2755. }, {
  2756. key: "open",
  2757. value: function open($trigger) {
  2758. if (this.isOpen) {
  2759. return;
  2760. }
  2761. this.isOpen = true;
  2762. Modal._modalsOpen++;
  2763. this._nthModalOpened = Modal._modalsOpen;
  2764. // Set Z-Index based on number of currently open modals
  2765. this.$overlay[0].style.zIndex = 1000 + Modal._modalsOpen * 2;
  2766. this.el.style.zIndex = 1000 + Modal._modalsOpen * 2 + 1;
  2767. // Set opening trigger, undefined indicates modal was opened by javascript
  2768. this._openingTrigger = !!$trigger ? $trigger[0] : undefined;
  2769. // onOpenStart callback
  2770. if (typeof this.options.onOpenStart === 'function') {
  2771. this.options.onOpenStart.call(this, this.el, this._openingTrigger);
  2772. }
  2773. if (this.options.preventScrolling) {
  2774. document.body.style.overflow = 'hidden';
  2775. }
  2776. this.el.classList.add('open');
  2777. this.el.insertAdjacentElement('afterend', this.$overlay[0]);
  2778. if (this.options.dismissible) {
  2779. this._handleKeydownBound = this._handleKeydown.bind(this);
  2780. this._handleFocusBound = this._handleFocus.bind(this);
  2781. document.addEventListener('keydown', this._handleKeydownBound);
  2782. document.addEventListener('focus', this._handleFocusBound, true);
  2783. }
  2784. anim.remove(this.el);
  2785. anim.remove(this.$overlay[0]);
  2786. this._animateIn();
  2787. // Focus modal
  2788. this.el.focus();
  2789. return this;
  2790. }
  2791. /**
  2792. * Close Modal
  2793. */
  2794. }, {
  2795. key: "close",
  2796. value: function close() {
  2797. if (!this.isOpen) {
  2798. return;
  2799. }
  2800. this.isOpen = false;
  2801. Modal._modalsOpen--;
  2802. this._nthModalOpened = 0;
  2803. // Call onCloseStart callback
  2804. if (typeof this.options.onCloseStart === 'function') {
  2805. this.options.onCloseStart.call(this, this.el);
  2806. }
  2807. this.el.classList.remove('open');
  2808. // Enable body scrolling only if there are no more modals open.
  2809. if (Modal._modalsOpen === 0) {
  2810. document.body.style.overflow = '';
  2811. }
  2812. if (this.options.dismissible) {
  2813. document.removeEventListener('keydown', this._handleKeydownBound);
  2814. document.removeEventListener('focus', this._handleFocusBound, true);
  2815. }
  2816. anim.remove(this.el);
  2817. anim.remove(this.$overlay[0]);
  2818. this._animateOut();
  2819. return this;
  2820. }
  2821. }], [{
  2822. key: "init",
  2823. value: function init(els, options) {
  2824. return _get(Modal.__proto__ || Object.getPrototypeOf(Modal), "init", this).call(this, this, els, options);
  2825. }
  2826. /**
  2827. * Get Instance
  2828. */
  2829. }, {
  2830. key: "getInstance",
  2831. value: function getInstance(el) {
  2832. var domElem = !!el.jquery ? el[0] : el;
  2833. return domElem.M_Modal;
  2834. }
  2835. }, {
  2836. key: "defaults",
  2837. get: function () {
  2838. return _defaults;
  2839. }
  2840. }]);
  2841. return Modal;
  2842. }(Component);
  2843. /**
  2844. * @static
  2845. * @memberof Modal
  2846. */
  2847. Modal._modalsOpen = 0;
  2848. /**
  2849. * @static
  2850. * @memberof Modal
  2851. */
  2852. Modal._count = 0;
  2853. M.Modal = Modal;
  2854. if (M.jQueryLoaded) {
  2855. M.initializeJqueryWrapper(Modal, 'modal', 'M_Modal');
  2856. }
  2857. })(cash, M.anime);
  2858. ;(function ($, anim) {
  2859. 'use strict';
  2860. var _defaults = {
  2861. inDuration: 275,
  2862. outDuration: 200,
  2863. onOpenStart: null,
  2864. onOpenEnd: null,
  2865. onCloseStart: null,
  2866. onCloseEnd: null
  2867. };
  2868. /**
  2869. * @class
  2870. *
  2871. */
  2872. var Materialbox = function (_Component4) {
  2873. _inherits(Materialbox, _Component4);
  2874. /**
  2875. * Construct Materialbox instance
  2876. * @constructor
  2877. * @param {Element} el
  2878. * @param {Object} options
  2879. */
  2880. function Materialbox(el, options) {
  2881. _classCallCheck(this, Materialbox);
  2882. var _this16 = _possibleConstructorReturn(this, (Materialbox.__proto__ || Object.getPrototypeOf(Materialbox)).call(this, Materialbox, el, options));
  2883. _this16.el.M_Materialbox = _this16;
  2884. /**
  2885. * Options for the modal
  2886. * @member Materialbox#options
  2887. * @prop {Number} [inDuration=275] - Length in ms of enter transition
  2888. * @prop {Number} [outDuration=200] - Length in ms of exit transition
  2889. * @prop {Function} onOpenStart - Callback function called before materialbox is opened
  2890. * @prop {Function} onOpenEnd - Callback function called after materialbox is opened
  2891. * @prop {Function} onCloseStart - Callback function called before materialbox is closed
  2892. * @prop {Function} onCloseEnd - Callback function called after materialbox is closed
  2893. */
  2894. _this16.options = $.extend({}, Materialbox.defaults, options);
  2895. _this16.overlayActive = false;
  2896. _this16.doneAnimating = true;
  2897. _this16.placeholder = $('<div></div>').addClass('material-placeholder');
  2898. _this16.originalWidth = 0;
  2899. _this16.originalHeight = 0;
  2900. _this16.originInlineStyles = _this16.$el.attr('style');
  2901. _this16.caption = _this16.el.getAttribute('data-caption') || '';
  2902. // Wrap
  2903. _this16.$el.before(_this16.placeholder);
  2904. _this16.placeholder.append(_this16.$el);
  2905. _this16._setupEventHandlers();
  2906. return _this16;
  2907. }
  2908. _createClass(Materialbox, [{
  2909. key: "destroy",
  2910. /**
  2911. * Teardown component
  2912. */
  2913. value: function destroy() {
  2914. this._removeEventHandlers();
  2915. this.el.M_Materialbox = undefined;
  2916. // Unwrap image
  2917. $(this.placeholder).after(this.el).remove();
  2918. this.$el.removeAttr('style');
  2919. }
  2920. /**
  2921. * Setup Event Handlers
  2922. */
  2923. }, {
  2924. key: "_setupEventHandlers",
  2925. value: function _setupEventHandlers() {
  2926. this._handleMaterialboxClickBound = this._handleMaterialboxClick.bind(this);
  2927. this.el.addEventListener('click', this._handleMaterialboxClickBound);
  2928. }
  2929. /**
  2930. * Remove Event Handlers
  2931. */
  2932. }, {
  2933. key: "_removeEventHandlers",
  2934. value: function _removeEventHandlers() {
  2935. this.el.removeEventListener('click', this._handleMaterialboxClickBound);
  2936. }
  2937. /**
  2938. * Handle Materialbox Click
  2939. * @param {Event} e
  2940. */
  2941. }, {
  2942. key: "_handleMaterialboxClick",
  2943. value: function _handleMaterialboxClick(e) {
  2944. // If already modal, return to original
  2945. if (this.doneAnimating === false || this.overlayActive && this.doneAnimating) {
  2946. this.close();
  2947. } else {
  2948. this.open();
  2949. }
  2950. }
  2951. /**
  2952. * Handle Window Scroll
  2953. */
  2954. }, {
  2955. key: "_handleWindowScroll",
  2956. value: function _handleWindowScroll() {
  2957. if (this.overlayActive) {
  2958. this.close();
  2959. }
  2960. }
  2961. /**
  2962. * Handle Window Resize
  2963. */
  2964. }, {
  2965. key: "_handleWindowResize",
  2966. value: function _handleWindowResize() {
  2967. if (this.overlayActive) {
  2968. this.close();
  2969. }
  2970. }
  2971. /**
  2972. * Handle Window Resize
  2973. * @param {Event} e
  2974. */
  2975. }, {
  2976. key: "_handleWindowEscape",
  2977. value: function _handleWindowEscape(e) {
  2978. // ESC key
  2979. if (e.keyCode === 27 && this.doneAnimating && this.overlayActive) {
  2980. this.close();
  2981. }
  2982. }
  2983. /**
  2984. * Find ancestors with overflow: hidden; and make visible
  2985. */
  2986. }, {
  2987. key: "_makeAncestorsOverflowVisible",
  2988. value: function _makeAncestorsOverflowVisible() {
  2989. this.ancestorsChanged = $();
  2990. var ancestor = this.placeholder[0].parentNode;
  2991. while (ancestor !== null && !$(ancestor).is(document)) {
  2992. var curr = $(ancestor);
  2993. if (curr.css('overflow') !== 'visible') {
  2994. curr.css('overflow', 'visible');
  2995. if (this.ancestorsChanged === undefined) {
  2996. this.ancestorsChanged = curr;
  2997. } else {
  2998. this.ancestorsChanged = this.ancestorsChanged.add(curr);
  2999. }
  3000. }
  3001. ancestor = ancestor.parentNode;
  3002. }
  3003. }
  3004. /**
  3005. * Animate image in
  3006. */
  3007. }, {
  3008. key: "_animateImageIn",
  3009. value: function _animateImageIn() {
  3010. var _this17 = this;
  3011. var animOptions = {
  3012. targets: this.el,
  3013. height: [this.originalHeight, this.newHeight],
  3014. width: [this.originalWidth, this.newWidth],
  3015. left: M.getDocumentScrollLeft() + this.windowWidth / 2 - this.placeholder.offset().left - this.newWidth / 2,
  3016. top: M.getDocumentScrollTop() + this.windowHeight / 2 - this.placeholder.offset().top - this.newHeight / 2,
  3017. duration: this.options.inDuration,
  3018. easing: 'easeOutQuad',
  3019. complete: function () {
  3020. _this17.doneAnimating = true;
  3021. // onOpenEnd callback
  3022. if (typeof _this17.options.onOpenEnd === 'function') {
  3023. _this17.options.onOpenEnd.call(_this17, _this17.el);
  3024. }
  3025. }
  3026. };
  3027. // Override max-width or max-height if needed
  3028. this.maxWidth = this.$el.css('max-width');
  3029. this.maxHeight = this.$el.css('max-height');
  3030. if (this.maxWidth !== 'none') {
  3031. animOptions.maxWidth = this.newWidth;
  3032. }
  3033. if (this.maxHeight !== 'none') {
  3034. animOptions.maxHeight = this.newHeight;
  3035. }
  3036. anim(animOptions);
  3037. }
  3038. /**
  3039. * Animate image out
  3040. */
  3041. }, {
  3042. key: "_animateImageOut",
  3043. value: function _animateImageOut() {
  3044. var _this18 = this;
  3045. var animOptions = {
  3046. targets: this.el,
  3047. width: this.originalWidth,
  3048. height: this.originalHeight,
  3049. left: 0,
  3050. top: 0,
  3051. duration: this.options.outDuration,
  3052. easing: 'easeOutQuad',
  3053. complete: function () {
  3054. _this18.placeholder.css({
  3055. height: '',
  3056. width: '',
  3057. position: '',
  3058. top: '',
  3059. left: ''
  3060. });
  3061. // Revert to width or height attribute
  3062. if (_this18.attrWidth) {
  3063. _this18.$el.attr('width', _this18.attrWidth);
  3064. }
  3065. if (_this18.attrHeight) {
  3066. _this18.$el.attr('height', _this18.attrHeight);
  3067. }
  3068. _this18.$el.removeAttr('style');
  3069. _this18.originInlineStyles && _this18.$el.attr('style', _this18.originInlineStyles);
  3070. // Remove class
  3071. _this18.$el.removeClass('active');
  3072. _this18.doneAnimating = true;
  3073. // Remove overflow overrides on ancestors
  3074. if (_this18.ancestorsChanged.length) {
  3075. _this18.ancestorsChanged.css('overflow', '');
  3076. }
  3077. // onCloseEnd callback
  3078. if (typeof _this18.options.onCloseEnd === 'function') {
  3079. _this18.options.onCloseEnd.call(_this18, _this18.el);
  3080. }
  3081. }
  3082. };
  3083. anim(animOptions);
  3084. }
  3085. /**
  3086. * Update open and close vars
  3087. */
  3088. }, {
  3089. key: "_updateVars",
  3090. value: function _updateVars() {
  3091. this.windowWidth = window.innerWidth;
  3092. this.windowHeight = window.innerHeight;
  3093. this.caption = this.el.getAttribute('data-caption') || '';
  3094. }
  3095. /**
  3096. * Open Materialbox
  3097. */
  3098. }, {
  3099. key: "open",
  3100. value: function open() {
  3101. var _this19 = this;
  3102. this._updateVars();
  3103. this.originalWidth = this.el.getBoundingClientRect().width;
  3104. this.originalHeight = this.el.getBoundingClientRect().height;
  3105. // Set states
  3106. this.doneAnimating = false;
  3107. this.$el.addClass('active');
  3108. this.overlayActive = true;
  3109. // onOpenStart callback
  3110. if (typeof this.options.onOpenStart === 'function') {
  3111. this.options.onOpenStart.call(this, this.el);
  3112. }
  3113. // Set positioning for placeholder
  3114. this.placeholder.css({
  3115. width: this.placeholder[0].getBoundingClientRect().width + 'px',
  3116. height: this.placeholder[0].getBoundingClientRect().height + 'px',
  3117. position: 'relative',
  3118. top: 0,
  3119. left: 0
  3120. });
  3121. this._makeAncestorsOverflowVisible();
  3122. // Set css on origin
  3123. this.$el.css({
  3124. position: 'absolute',
  3125. 'z-index': 1000,
  3126. 'will-change': 'left, top, width, height'
  3127. });
  3128. // Change from width or height attribute to css
  3129. this.attrWidth = this.$el.attr('width');
  3130. this.attrHeight = this.$el.attr('height');
  3131. if (this.attrWidth) {
  3132. this.$el.css('width', this.attrWidth + 'px');
  3133. this.$el.removeAttr('width');
  3134. }
  3135. if (this.attrHeight) {
  3136. this.$el.css('width', this.attrHeight + 'px');
  3137. this.$el.removeAttr('height');
  3138. }
  3139. // Add overlay
  3140. this.$overlay = $('<div id="materialbox-overlay"></div>').css({
  3141. opacity: 0
  3142. }).one('click', function () {
  3143. if (_this19.doneAnimating) {
  3144. _this19.close();
  3145. }
  3146. });
  3147. // Put before in origin image to preserve z-index layering.
  3148. this.$el.before(this.$overlay);
  3149. // Set dimensions if needed
  3150. var overlayOffset = this.$overlay[0].getBoundingClientRect();
  3151. this.$overlay.css({
  3152. width: this.windowWidth + 'px',
  3153. height: this.windowHeight + 'px',
  3154. left: -1 * overlayOffset.left + 'px',
  3155. top: -1 * overlayOffset.top + 'px'
  3156. });
  3157. anim.remove(this.el);
  3158. anim.remove(this.$overlay[0]);
  3159. // Animate Overlay
  3160. anim({
  3161. targets: this.$overlay[0],
  3162. opacity: 1,
  3163. duration: this.options.inDuration,
  3164. easing: 'easeOutQuad'
  3165. });
  3166. // Add and animate caption if it exists
  3167. if (this.caption !== '') {
  3168. if (this.$photocaption) {
  3169. anim.remove(this.$photoCaption[0]);
  3170. }
  3171. this.$photoCaption = $('<div class="materialbox-caption"></div>');
  3172. this.$photoCaption.text(this.caption);
  3173. $('body').append(this.$photoCaption);
  3174. this.$photoCaption.css({ display: 'inline' });
  3175. anim({
  3176. targets: this.$photoCaption[0],
  3177. opacity: 1,
  3178. duration: this.options.inDuration,
  3179. easing: 'easeOutQuad'
  3180. });
  3181. }
  3182. // Resize Image
  3183. var ratio = 0;
  3184. var widthPercent = this.originalWidth / this.windowWidth;
  3185. var heightPercent = this.originalHeight / this.windowHeight;
  3186. this.newWidth = 0;
  3187. this.newHeight = 0;
  3188. if (widthPercent > heightPercent) {
  3189. ratio = this.originalHeight / this.originalWidth;
  3190. this.newWidth = this.windowWidth * 0.9;
  3191. this.newHeight = this.windowWidth * 0.9 * ratio;
  3192. } else {
  3193. ratio = this.originalWidth / this.originalHeight;
  3194. this.newWidth = this.windowHeight * 0.9 * ratio;
  3195. this.newHeight = this.windowHeight * 0.9;
  3196. }
  3197. this._animateImageIn();
  3198. // Handle Exit triggers
  3199. this._handleWindowScrollBound = this._handleWindowScroll.bind(this);
  3200. this._handleWindowResizeBound = this._handleWindowResize.bind(this);
  3201. this._handleWindowEscapeBound = this._handleWindowEscape.bind(this);
  3202. window.addEventListener('scroll', this._handleWindowScrollBound);
  3203. window.addEventListener('resize', this._handleWindowResizeBound);
  3204. window.addEventListener('keyup', this._handleWindowEscapeBound);
  3205. }
  3206. /**
  3207. * Close Materialbox
  3208. */
  3209. }, {
  3210. key: "close",
  3211. value: function close() {
  3212. var _this20 = this;
  3213. this._updateVars();
  3214. this.doneAnimating = false;
  3215. // onCloseStart callback
  3216. if (typeof this.options.onCloseStart === 'function') {
  3217. this.options.onCloseStart.call(this, this.el);
  3218. }
  3219. anim.remove(this.el);
  3220. anim.remove(this.$overlay[0]);
  3221. if (this.caption !== '') {
  3222. anim.remove(this.$photoCaption[0]);
  3223. }
  3224. // disable exit handlers
  3225. window.removeEventListener('scroll', this._handleWindowScrollBound);
  3226. window.removeEventListener('resize', this._handleWindowResizeBound);
  3227. window.removeEventListener('keyup', this._handleWindowEscapeBound);
  3228. anim({
  3229. targets: this.$overlay[0],
  3230. opacity: 0,
  3231. duration: this.options.outDuration,
  3232. easing: 'easeOutQuad',
  3233. complete: function () {
  3234. _this20.overlayActive = false;
  3235. _this20.$overlay.remove();
  3236. }
  3237. });
  3238. this._animateImageOut();
  3239. // Remove Caption + reset css settings on image
  3240. if (this.caption !== '') {
  3241. anim({
  3242. targets: this.$photoCaption[0],
  3243. opacity: 0,
  3244. duration: this.options.outDuration,
  3245. easing: 'easeOutQuad',
  3246. complete: function () {
  3247. _this20.$photoCaption.remove();
  3248. }
  3249. });
  3250. }
  3251. }
  3252. }], [{
  3253. key: "init",
  3254. value: function init(els, options) {
  3255. return _get(Materialbox.__proto__ || Object.getPrototypeOf(Materialbox), "init", this).call(this, this, els, options);
  3256. }
  3257. /**
  3258. * Get Instance
  3259. */
  3260. }, {
  3261. key: "getInstance",
  3262. value: function getInstance(el) {
  3263. var domElem = !!el.jquery ? el[0] : el;
  3264. return domElem.M_Materialbox;
  3265. }
  3266. }, {
  3267. key: "defaults",
  3268. get: function () {
  3269. return _defaults;
  3270. }
  3271. }]);
  3272. return Materialbox;
  3273. }(Component);
  3274. M.Materialbox = Materialbox;
  3275. if (M.jQueryLoaded) {
  3276. M.initializeJqueryWrapper(Materialbox, 'materialbox', 'M_Materialbox');
  3277. }
  3278. })(cash, M.anime);
  3279. ;(function ($) {
  3280. 'use strict';
  3281. var _defaults = {
  3282. responsiveThreshold: 0 // breakpoint for swipeable
  3283. };
  3284. var Parallax = function (_Component5) {
  3285. _inherits(Parallax, _Component5);
  3286. function Parallax(el, options) {
  3287. _classCallCheck(this, Parallax);
  3288. var _this21 = _possibleConstructorReturn(this, (Parallax.__proto__ || Object.getPrototypeOf(Parallax)).call(this, Parallax, el, options));
  3289. _this21.el.M_Parallax = _this21;
  3290. /**
  3291. * Options for the Parallax
  3292. * @member Parallax#options
  3293. * @prop {Number} responsiveThreshold
  3294. */
  3295. _this21.options = $.extend({}, Parallax.defaults, options);
  3296. _this21._enabled = window.innerWidth > _this21.options.responsiveThreshold;
  3297. _this21.$img = _this21.$el.find('img').first();
  3298. _this21.$img.each(function () {
  3299. var el = this;
  3300. if (el.complete) $(el).trigger('load');
  3301. });
  3302. _this21._updateParallax();
  3303. _this21._setupEventHandlers();
  3304. _this21._setupStyles();
  3305. Parallax._parallaxes.push(_this21);
  3306. return _this21;
  3307. }
  3308. _createClass(Parallax, [{
  3309. key: "destroy",
  3310. /**
  3311. * Teardown component
  3312. */
  3313. value: function destroy() {
  3314. Parallax._parallaxes.splice(Parallax._parallaxes.indexOf(this), 1);
  3315. this.$img[0].style.transform = '';
  3316. this._removeEventHandlers();
  3317. this.$el[0].M_Parallax = undefined;
  3318. }
  3319. }, {
  3320. key: "_setupEventHandlers",
  3321. value: function _setupEventHandlers() {
  3322. this._handleImageLoadBound = this._handleImageLoad.bind(this);
  3323. this.$img[0].addEventListener('load', this._handleImageLoadBound);
  3324. if (Parallax._parallaxes.length === 0) {
  3325. Parallax._handleScrollThrottled = M.throttle(Parallax._handleScroll, 5);
  3326. window.addEventListener('scroll', Parallax._handleScrollThrottled);
  3327. Parallax._handleWindowResizeThrottled = M.throttle(Parallax._handleWindowResize, 5);
  3328. window.addEventListener('resize', Parallax._handleWindowResizeThrottled);
  3329. }
  3330. }
  3331. }, {
  3332. key: "_removeEventHandlers",
  3333. value: function _removeEventHandlers() {
  3334. this.$img[0].removeEventListener('load', this._handleImageLoadBound);
  3335. if (Parallax._parallaxes.length === 0) {
  3336. window.removeEventListener('scroll', Parallax._handleScrollThrottled);
  3337. window.removeEventListener('resize', Parallax._handleWindowResizeThrottled);
  3338. }
  3339. }
  3340. }, {
  3341. key: "_setupStyles",
  3342. value: function _setupStyles() {
  3343. this.$img[0].style.opacity = 1;
  3344. }
  3345. }, {
  3346. key: "_handleImageLoad",
  3347. value: function _handleImageLoad() {
  3348. this._updateParallax();
  3349. }
  3350. }, {
  3351. key: "_updateParallax",
  3352. value: function _updateParallax() {
  3353. var containerHeight = this.$el.height() > 0 ? this.el.parentNode.offsetHeight : 500;
  3354. var imgHeight = this.$img[0].offsetHeight;
  3355. var parallaxDist = imgHeight - containerHeight;
  3356. var bottom = this.$el.offset().top + containerHeight;
  3357. var top = this.$el.offset().top;
  3358. var scrollTop = M.getDocumentScrollTop();
  3359. var windowHeight = window.innerHeight;
  3360. var windowBottom = scrollTop + windowHeight;
  3361. var percentScrolled = (windowBottom - top) / (containerHeight + windowHeight);
  3362. var parallax = parallaxDist * percentScrolled;
  3363. if (!this._enabled) {
  3364. this.$img[0].style.transform = '';
  3365. } else if (bottom > scrollTop && top < scrollTop + windowHeight) {
  3366. this.$img[0].style.transform = "translate3D(-50%, " + parallax + "px, 0)";
  3367. }
  3368. }
  3369. }], [{
  3370. key: "init",
  3371. value: function init(els, options) {
  3372. return _get(Parallax.__proto__ || Object.getPrototypeOf(Parallax), "init", this).call(this, this, els, options);
  3373. }
  3374. /**
  3375. * Get Instance
  3376. */
  3377. }, {
  3378. key: "getInstance",
  3379. value: function getInstance(el) {
  3380. var domElem = !!el.jquery ? el[0] : el;
  3381. return domElem.M_Parallax;
  3382. }
  3383. }, {
  3384. key: "_handleScroll",
  3385. value: function _handleScroll() {
  3386. for (var i = 0; i < Parallax._parallaxes.length; i++) {
  3387. var parallaxInstance = Parallax._parallaxes[i];
  3388. parallaxInstance._updateParallax.call(parallaxInstance);
  3389. }
  3390. }
  3391. }, {
  3392. key: "_handleWindowResize",
  3393. value: function _handleWindowResize() {
  3394. for (var i = 0; i < Parallax._parallaxes.length; i++) {
  3395. var parallaxInstance = Parallax._parallaxes[i];
  3396. parallaxInstance._enabled = window.innerWidth > parallaxInstance.options.responsiveThreshold;
  3397. }
  3398. }
  3399. }, {
  3400. key: "defaults",
  3401. get: function () {
  3402. return _defaults;
  3403. }
  3404. }]);
  3405. return Parallax;
  3406. }(Component);
  3407. /**
  3408. * @static
  3409. * @memberof Parallax
  3410. */
  3411. Parallax._parallaxes = [];
  3412. M.Parallax = Parallax;
  3413. if (M.jQueryLoaded) {
  3414. M.initializeJqueryWrapper(Parallax, 'parallax', 'M_Parallax');
  3415. }
  3416. })(cash);
  3417. ;(function ($, anim) {
  3418. 'use strict';
  3419. var _defaults = {
  3420. duration: 300,
  3421. onShow: null,
  3422. swipeable: false,
  3423. responsiveThreshold: Infinity // breakpoint for swipeable
  3424. };
  3425. /**
  3426. * @class
  3427. *
  3428. */
  3429. var Tabs = function (_Component6) {
  3430. _inherits(Tabs, _Component6);
  3431. /**
  3432. * Construct Tabs instance
  3433. * @constructor
  3434. * @param {Element} el
  3435. * @param {Object} options
  3436. */
  3437. function Tabs(el, options) {
  3438. _classCallCheck(this, Tabs);
  3439. var _this22 = _possibleConstructorReturn(this, (Tabs.__proto__ || Object.getPrototypeOf(Tabs)).call(this, Tabs, el, options));
  3440. _this22.el.M_Tabs = _this22;
  3441. /**
  3442. * Options for the Tabs
  3443. * @member Tabs#options
  3444. * @prop {Number} duration
  3445. * @prop {Function} onShow
  3446. * @prop {Boolean} swipeable
  3447. * @prop {Number} responsiveThreshold
  3448. */
  3449. _this22.options = $.extend({}, Tabs.defaults, options);
  3450. // Setup
  3451. _this22.$tabLinks = _this22.$el.children('li.tab').children('a');
  3452. _this22.index = 0;
  3453. _this22._setupActiveTabLink();
  3454. // Setup tabs content
  3455. if (_this22.options.swipeable) {
  3456. _this22._setupSwipeableTabs();
  3457. } else {
  3458. _this22._setupNormalTabs();
  3459. }
  3460. // Setup tabs indicator after content to ensure accurate widths
  3461. _this22._setTabsAndTabWidth();
  3462. _this22._createIndicator();
  3463. _this22._setupEventHandlers();
  3464. return _this22;
  3465. }
  3466. _createClass(Tabs, [{
  3467. key: "destroy",
  3468. /**
  3469. * Teardown component
  3470. */
  3471. value: function destroy() {
  3472. this._removeEventHandlers();
  3473. this._indicator.parentNode.removeChild(this._indicator);
  3474. if (this.options.swipeable) {
  3475. this._teardownSwipeableTabs();
  3476. } else {
  3477. this._teardownNormalTabs();
  3478. }
  3479. this.$el[0].M_Tabs = undefined;
  3480. }
  3481. /**
  3482. * Setup Event Handlers
  3483. */
  3484. }, {
  3485. key: "_setupEventHandlers",
  3486. value: function _setupEventHandlers() {
  3487. this._handleWindowResizeBound = this._handleWindowResize.bind(this);
  3488. window.addEventListener('resize', this._handleWindowResizeBound);
  3489. this._handleTabClickBound = this._handleTabClick.bind(this);
  3490. this.el.addEventListener('click', this._handleTabClickBound);
  3491. }
  3492. /**
  3493. * Remove Event Handlers
  3494. */
  3495. }, {
  3496. key: "_removeEventHandlers",
  3497. value: function _removeEventHandlers() {
  3498. window.removeEventListener('resize', this._handleWindowResizeBound);
  3499. this.el.removeEventListener('click', this._handleTabClickBound);
  3500. }
  3501. /**
  3502. * Handle window Resize
  3503. */
  3504. }, {
  3505. key: "_handleWindowResize",
  3506. value: function _handleWindowResize() {
  3507. this._setTabsAndTabWidth();
  3508. if (this.tabWidth !== 0 && this.tabsWidth !== 0) {
  3509. this._indicator.style.left = this._calcLeftPos(this.$activeTabLink) + 'px';
  3510. this._indicator.style.right = this._calcRightPos(this.$activeTabLink) + 'px';
  3511. }
  3512. }
  3513. /**
  3514. * Handle tab click
  3515. * @param {Event} e
  3516. */
  3517. }, {
  3518. key: "_handleTabClick",
  3519. value: function _handleTabClick(e) {
  3520. var _this23 = this;
  3521. var tab = $(e.target).closest('li.tab');
  3522. var tabLink = $(e.target).closest('a');
  3523. // Handle click on tab link only
  3524. if (!tabLink.length || !tabLink.parent().hasClass('tab')) {
  3525. return;
  3526. }
  3527. if (tab.hasClass('disabled')) {
  3528. e.preventDefault();
  3529. return;
  3530. }
  3531. // Act as regular link if target attribute is specified.
  3532. if (!!tabLink.attr('target')) {
  3533. return;
  3534. }
  3535. // Make the old tab inactive.
  3536. this.$activeTabLink.removeClass('active');
  3537. var $oldContent = this.$content;
  3538. // Update the variables with the new link and content
  3539. this.$activeTabLink = tabLink;
  3540. this.$content = $(M.escapeHash(tabLink[0].hash));
  3541. this.$tabLinks = this.$el.children('li.tab').children('a');
  3542. // Make the tab active.
  3543. this.$activeTabLink.addClass('active');
  3544. var prevIndex = this.index;
  3545. this.index = Math.max(this.$tabLinks.index(tabLink), 0);
  3546. // Swap content
  3547. if (this.options.swipeable) {
  3548. if (this._tabsCarousel) {
  3549. this._tabsCarousel.set(this.index, function () {
  3550. if (typeof _this23.options.onShow === 'function') {
  3551. _this23.options.onShow.call(_this23, _this23.$content[0]);
  3552. }
  3553. });
  3554. }
  3555. } else {
  3556. if (this.$content.length) {
  3557. this.$content[0].style.display = 'block';
  3558. this.$content.addClass('active');
  3559. if (typeof this.options.onShow === 'function') {
  3560. this.options.onShow.call(this, this.$content[0]);
  3561. }
  3562. if ($oldContent.length && !$oldContent.is(this.$content)) {
  3563. $oldContent[0].style.display = 'none';
  3564. $oldContent.removeClass('active');
  3565. }
  3566. }
  3567. }
  3568. // Update widths after content is swapped (scrollbar bugfix)
  3569. this._setTabsAndTabWidth();
  3570. // Update indicator
  3571. this._animateIndicator(prevIndex);
  3572. // Prevent the anchor's default click action
  3573. e.preventDefault();
  3574. }
  3575. /**
  3576. * Generate elements for tab indicator.
  3577. */
  3578. }, {
  3579. key: "_createIndicator",
  3580. value: function _createIndicator() {
  3581. var _this24 = this;
  3582. var indicator = document.createElement('li');
  3583. indicator.classList.add('indicator');
  3584. this.el.appendChild(indicator);
  3585. this._indicator = indicator;
  3586. setTimeout(function () {
  3587. _this24._indicator.style.left = _this24._calcLeftPos(_this24.$activeTabLink) + 'px';
  3588. _this24._indicator.style.right = _this24._calcRightPos(_this24.$activeTabLink) + 'px';
  3589. }, 0);
  3590. }
  3591. /**
  3592. * Setup first active tab link.
  3593. */
  3594. }, {
  3595. key: "_setupActiveTabLink",
  3596. value: function _setupActiveTabLink() {
  3597. // If the location.hash matches one of the links, use that as the active tab.
  3598. this.$activeTabLink = $(this.$tabLinks.filter('[href="' + location.hash + '"]'));
  3599. // If no match is found, use the first link or any with class 'active' as the initial active tab.
  3600. if (this.$activeTabLink.length === 0) {
  3601. this.$activeTabLink = this.$el.children('li.tab').children('a.active').first();
  3602. }
  3603. if (this.$activeTabLink.length === 0) {
  3604. this.$activeTabLink = this.$el.children('li.tab').children('a').first();
  3605. }
  3606. this.$tabLinks.removeClass('active');
  3607. this.$activeTabLink[0].classList.add('active');
  3608. this.index = Math.max(this.$tabLinks.index(this.$activeTabLink), 0);
  3609. if (this.$activeTabLink.length) {
  3610. this.$content = $(M.escapeHash(this.$activeTabLink[0].hash));
  3611. this.$content.addClass('active');
  3612. }
  3613. }
  3614. /**
  3615. * Setup swipeable tabs
  3616. */
  3617. }, {
  3618. key: "_setupSwipeableTabs",
  3619. value: function _setupSwipeableTabs() {
  3620. var _this25 = this;
  3621. // Change swipeable according to responsive threshold
  3622. if (window.innerWidth > this.options.responsiveThreshold) {
  3623. this.options.swipeable = false;
  3624. }
  3625. var $tabsContent = $();
  3626. this.$tabLinks.each(function (link) {
  3627. var $currContent = $(M.escapeHash(link.hash));
  3628. $currContent.addClass('carousel-item');
  3629. $tabsContent = $tabsContent.add($currContent);
  3630. });
  3631. var $tabsWrapper = $('<div class="tabs-content carousel carousel-slider"></div>');
  3632. $tabsContent.first().before($tabsWrapper);
  3633. $tabsWrapper.append($tabsContent);
  3634. $tabsContent[0].style.display = '';
  3635. // Keep active tab index to set initial carousel slide
  3636. var activeTabIndex = this.$activeTabLink.closest('.tab').index();
  3637. this._tabsCarousel = M.Carousel.init($tabsWrapper[0], {
  3638. fullWidth: true,
  3639. noWrap: true,
  3640. onCycleTo: function (item) {
  3641. var prevIndex = _this25.index;
  3642. _this25.index = $(item).index();
  3643. _this25.$activeTabLink.removeClass('active');
  3644. _this25.$activeTabLink = _this25.$tabLinks.eq(_this25.index);
  3645. _this25.$activeTabLink.addClass('active');
  3646. _this25._animateIndicator(prevIndex);
  3647. if (typeof _this25.options.onShow === 'function') {
  3648. _this25.options.onShow.call(_this25, _this25.$content[0]);
  3649. }
  3650. }
  3651. });
  3652. // Set initial carousel slide to active tab
  3653. this._tabsCarousel.set(activeTabIndex);
  3654. }
  3655. /**
  3656. * Teardown normal tabs.
  3657. */
  3658. }, {
  3659. key: "_teardownSwipeableTabs",
  3660. value: function _teardownSwipeableTabs() {
  3661. var $tabsWrapper = this._tabsCarousel.$el;
  3662. this._tabsCarousel.destroy();
  3663. // Unwrap
  3664. $tabsWrapper.after($tabsWrapper.children());
  3665. $tabsWrapper.remove();
  3666. }
  3667. /**
  3668. * Setup normal tabs.
  3669. */
  3670. }, {
  3671. key: "_setupNormalTabs",
  3672. value: function _setupNormalTabs() {
  3673. // Hide Tabs Content
  3674. this.$tabLinks.not(this.$activeTabLink).each(function (link) {
  3675. if (!!link.hash) {
  3676. var $currContent = $(M.escapeHash(link.hash));
  3677. if ($currContent.length) {
  3678. $currContent[0].style.display = 'none';
  3679. }
  3680. }
  3681. });
  3682. }
  3683. /**
  3684. * Teardown normal tabs.
  3685. */
  3686. }, {
  3687. key: "_teardownNormalTabs",
  3688. value: function _teardownNormalTabs() {
  3689. // show Tabs Content
  3690. this.$tabLinks.each(function (link) {
  3691. if (!!link.hash) {
  3692. var $currContent = $(M.escapeHash(link.hash));
  3693. if ($currContent.length) {
  3694. $currContent[0].style.display = '';
  3695. }
  3696. }
  3697. });
  3698. }
  3699. /**
  3700. * set tabs and tab width
  3701. */
  3702. }, {
  3703. key: "_setTabsAndTabWidth",
  3704. value: function _setTabsAndTabWidth() {
  3705. this.tabsWidth = this.$el.width();
  3706. this.tabWidth = Math.max(this.tabsWidth, this.el.scrollWidth) / this.$tabLinks.length;
  3707. }
  3708. /**
  3709. * Finds right attribute for indicator based on active tab.
  3710. * @param {cash} el
  3711. */
  3712. }, {
  3713. key: "_calcRightPos",
  3714. value: function _calcRightPos(el) {
  3715. return Math.ceil(this.tabsWidth - el.position().left - el[0].getBoundingClientRect().width);
  3716. }
  3717. /**
  3718. * Finds left attribute for indicator based on active tab.
  3719. * @param {cash} el
  3720. */
  3721. }, {
  3722. key: "_calcLeftPos",
  3723. value: function _calcLeftPos(el) {
  3724. return Math.floor(el.position().left);
  3725. }
  3726. }, {
  3727. key: "updateTabIndicator",
  3728. value: function updateTabIndicator() {
  3729. this._setTabsAndTabWidth();
  3730. this._animateIndicator(this.index);
  3731. }
  3732. /**
  3733. * Animates Indicator to active tab.
  3734. * @param {Number} prevIndex
  3735. */
  3736. }, {
  3737. key: "_animateIndicator",
  3738. value: function _animateIndicator(prevIndex) {
  3739. var leftDelay = 0,
  3740. rightDelay = 0;
  3741. if (this.index - prevIndex >= 0) {
  3742. leftDelay = 90;
  3743. } else {
  3744. rightDelay = 90;
  3745. }
  3746. // Animate
  3747. var animOptions = {
  3748. targets: this._indicator,
  3749. left: {
  3750. value: this._calcLeftPos(this.$activeTabLink),
  3751. delay: leftDelay
  3752. },
  3753. right: {
  3754. value: this._calcRightPos(this.$activeTabLink),
  3755. delay: rightDelay
  3756. },
  3757. duration: this.options.duration,
  3758. easing: 'easeOutQuad'
  3759. };
  3760. anim.remove(this._indicator);
  3761. anim(animOptions);
  3762. }
  3763. /**
  3764. * Select tab.
  3765. * @param {String} tabId
  3766. */
  3767. }, {
  3768. key: "select",
  3769. value: function select(tabId) {
  3770. var tab = this.$tabLinks.filter('[href="#' + tabId + '"]');
  3771. if (tab.length) {
  3772. tab.trigger('click');
  3773. }
  3774. }
  3775. }], [{
  3776. key: "init",
  3777. value: function init(els, options) {
  3778. return _get(Tabs.__proto__ || Object.getPrototypeOf(Tabs), "init", this).call(this, this, els, options);
  3779. }
  3780. /**
  3781. * Get Instance
  3782. */
  3783. }, {
  3784. key: "getInstance",
  3785. value: function getInstance(el) {
  3786. var domElem = !!el.jquery ? el[0] : el;
  3787. return domElem.M_Tabs;
  3788. }
  3789. }, {
  3790. key: "defaults",
  3791. get: function () {
  3792. return _defaults;
  3793. }
  3794. }]);
  3795. return Tabs;
  3796. }(Component);
  3797. window.M.Tabs = Tabs;
  3798. if (M.jQueryLoaded) {
  3799. M.initializeJqueryWrapper(Tabs, 'tabs', 'M_Tabs');
  3800. }
  3801. })(cash, M.anime);
  3802. ;(function ($, anim) {
  3803. 'use strict';
  3804. var _defaults = {
  3805. exitDelay: 200,
  3806. enterDelay: 0,
  3807. html: null,
  3808. margin: 5,
  3809. inDuration: 250,
  3810. outDuration: 200,
  3811. position: 'bottom',
  3812. transitionMovement: 10
  3813. };
  3814. /**
  3815. * @class
  3816. *
  3817. */
  3818. var Tooltip = function (_Component7) {
  3819. _inherits(Tooltip, _Component7);
  3820. /**
  3821. * Construct Tooltip instance
  3822. * @constructor
  3823. * @param {Element} el
  3824. * @param {Object} options
  3825. */
  3826. function Tooltip(el, options) {
  3827. _classCallCheck(this, Tooltip);
  3828. var _this26 = _possibleConstructorReturn(this, (Tooltip.__proto__ || Object.getPrototypeOf(Tooltip)).call(this, Tooltip, el, options));
  3829. _this26.el.M_Tooltip = _this26;
  3830. _this26.options = $.extend({}, Tooltip.defaults, options);
  3831. _this26.isOpen = false;
  3832. _this26.isHovered = false;
  3833. _this26.isFocused = false;
  3834. _this26._appendTooltipEl();
  3835. _this26._setupEventHandlers();
  3836. return _this26;
  3837. }
  3838. _createClass(Tooltip, [{
  3839. key: "destroy",
  3840. /**
  3841. * Teardown component
  3842. */
  3843. value: function destroy() {
  3844. $(this.tooltipEl).remove();
  3845. this._removeEventHandlers();
  3846. this.el.M_Tooltip = undefined;
  3847. }
  3848. }, {
  3849. key: "_appendTooltipEl",
  3850. value: function _appendTooltipEl() {
  3851. var tooltipEl = document.createElement('div');
  3852. tooltipEl.classList.add('material-tooltip');
  3853. this.tooltipEl = tooltipEl;
  3854. var tooltipContentEl = document.createElement('div');
  3855. tooltipContentEl.classList.add('tooltip-content');
  3856. tooltipContentEl.innerHTML = this.options.html;
  3857. tooltipEl.appendChild(tooltipContentEl);
  3858. document.body.appendChild(tooltipEl);
  3859. }
  3860. }, {
  3861. key: "_updateTooltipContent",
  3862. value: function _updateTooltipContent() {
  3863. this.tooltipEl.querySelector('.tooltip-content').innerHTML = this.options.html;
  3864. }
  3865. }, {
  3866. key: "_setupEventHandlers",
  3867. value: function _setupEventHandlers() {
  3868. this._handleMouseEnterBound = this._handleMouseEnter.bind(this);
  3869. this._handleMouseLeaveBound = this._handleMouseLeave.bind(this);
  3870. this._handleFocusBound = this._handleFocus.bind(this);
  3871. this._handleBlurBound = this._handleBlur.bind(this);
  3872. this.el.addEventListener('mouseenter', this._handleMouseEnterBound);
  3873. this.el.addEventListener('mouseleave', this._handleMouseLeaveBound);
  3874. this.el.addEventListener('focus', this._handleFocusBound, true);
  3875. this.el.addEventListener('blur', this._handleBlurBound, true);
  3876. }
  3877. }, {
  3878. key: "_removeEventHandlers",
  3879. value: function _removeEventHandlers() {
  3880. this.el.removeEventListener('mouseenter', this._handleMouseEnterBound);
  3881. this.el.removeEventListener('mouseleave', this._handleMouseLeaveBound);
  3882. this.el.removeEventListener('focus', this._handleFocusBound, true);
  3883. this.el.removeEventListener('blur', this._handleBlurBound, true);
  3884. }
  3885. }, {
  3886. key: "open",
  3887. value: function open(isManual) {
  3888. if (this.isOpen) {
  3889. return;
  3890. }
  3891. isManual = isManual === undefined ? true : undefined; // Default value true
  3892. this.isOpen = true;
  3893. // Update tooltip content with HTML attribute options
  3894. this.options = $.extend({}, this.options, this._getAttributeOptions());
  3895. this._updateTooltipContent();
  3896. this._setEnterDelayTimeout(isManual);
  3897. }
  3898. }, {
  3899. key: "close",
  3900. value: function close() {
  3901. if (!this.isOpen) {
  3902. return;
  3903. }
  3904. this.isHovered = false;
  3905. this.isFocused = false;
  3906. this.isOpen = false;
  3907. this._setExitDelayTimeout();
  3908. }
  3909. /**
  3910. * Create timeout which delays when the tooltip closes
  3911. */
  3912. }, {
  3913. key: "_setExitDelayTimeout",
  3914. value: function _setExitDelayTimeout() {
  3915. var _this27 = this;
  3916. clearTimeout(this._exitDelayTimeout);
  3917. this._exitDelayTimeout = setTimeout(function () {
  3918. if (_this27.isHovered || _this27.isFocused) {
  3919. return;
  3920. }
  3921. _this27._animateOut();
  3922. }, this.options.exitDelay);
  3923. }
  3924. /**
  3925. * Create timeout which delays when the toast closes
  3926. */
  3927. }, {
  3928. key: "_setEnterDelayTimeout",
  3929. value: function _setEnterDelayTimeout(isManual) {
  3930. var _this28 = this;
  3931. clearTimeout(this._enterDelayTimeout);
  3932. this._enterDelayTimeout = setTimeout(function () {
  3933. if (!_this28.isHovered && !_this28.isFocused && !isManual) {
  3934. return;
  3935. }
  3936. _this28._animateIn();
  3937. }, this.options.enterDelay);
  3938. }
  3939. }, {
  3940. key: "_positionTooltip",
  3941. value: function _positionTooltip() {
  3942. var origin = this.el,
  3943. tooltip = this.tooltipEl,
  3944. originHeight = origin.offsetHeight,
  3945. originWidth = origin.offsetWidth,
  3946. tooltipHeight = tooltip.offsetHeight,
  3947. tooltipWidth = tooltip.offsetWidth,
  3948. newCoordinates = void 0,
  3949. margin = this.options.margin,
  3950. targetTop = void 0,
  3951. targetLeft = void 0;
  3952. this.xMovement = 0, this.yMovement = 0;
  3953. targetTop = origin.getBoundingClientRect().top + M.getDocumentScrollTop();
  3954. targetLeft = origin.getBoundingClientRect().left + M.getDocumentScrollLeft();
  3955. if (this.options.position === 'top') {
  3956. targetTop += -tooltipHeight - margin;
  3957. targetLeft += originWidth / 2 - tooltipWidth / 2;
  3958. this.yMovement = -this.options.transitionMovement;
  3959. } else if (this.options.position === 'right') {
  3960. targetTop += originHeight / 2 - tooltipHeight / 2;
  3961. targetLeft += originWidth + margin;
  3962. this.xMovement = this.options.transitionMovement;
  3963. } else if (this.options.position === 'left') {
  3964. targetTop += originHeight / 2 - tooltipHeight / 2;
  3965. targetLeft += -tooltipWidth - margin;
  3966. this.xMovement = -this.options.transitionMovement;
  3967. } else {
  3968. targetTop += originHeight + margin;
  3969. targetLeft += originWidth / 2 - tooltipWidth / 2;
  3970. this.yMovement = this.options.transitionMovement;
  3971. }
  3972. newCoordinates = this._repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
  3973. $(tooltip).css({
  3974. top: newCoordinates.y + 'px',
  3975. left: newCoordinates.x + 'px'
  3976. });
  3977. }
  3978. }, {
  3979. key: "_repositionWithinScreen",
  3980. value: function _repositionWithinScreen(x, y, width, height) {
  3981. var scrollLeft = M.getDocumentScrollLeft();
  3982. var scrollTop = M.getDocumentScrollTop();
  3983. var newX = x - scrollLeft;
  3984. var newY = y - scrollTop;
  3985. var bounding = {
  3986. left: newX,
  3987. top: newY,
  3988. width: width,
  3989. height: height
  3990. };
  3991. var offset = this.options.margin + this.options.transitionMovement;
  3992. var edges = M.checkWithinContainer(document.body, bounding, offset);
  3993. if (edges.left) {
  3994. newX = offset;
  3995. } else if (edges.right) {
  3996. newX -= newX + width - window.innerWidth;
  3997. }
  3998. if (edges.top) {
  3999. newY = offset;
  4000. } else if (edges.bottom) {
  4001. newY -= newY + height - window.innerHeight;
  4002. }
  4003. return {
  4004. x: newX + scrollLeft,
  4005. y: newY + scrollTop
  4006. };
  4007. }
  4008. }, {
  4009. key: "_animateIn",
  4010. value: function _animateIn() {
  4011. this._positionTooltip();
  4012. this.tooltipEl.style.visibility = 'visible';
  4013. anim.remove(this.tooltipEl);
  4014. anim({
  4015. targets: this.tooltipEl,
  4016. opacity: 1,
  4017. translateX: this.xMovement,
  4018. translateY: this.yMovement,
  4019. duration: this.options.inDuration,
  4020. easing: 'easeOutCubic'
  4021. });
  4022. }
  4023. }, {
  4024. key: "_animateOut",
  4025. value: function _animateOut() {
  4026. anim.remove(this.tooltipEl);
  4027. anim({
  4028. targets: this.tooltipEl,
  4029. opacity: 0,
  4030. translateX: 0,
  4031. translateY: 0,
  4032. duration: this.options.outDuration,
  4033. easing: 'easeOutCubic'
  4034. });
  4035. }
  4036. }, {
  4037. key: "_handleMouseEnter",
  4038. value: function _handleMouseEnter() {
  4039. this.isHovered = true;
  4040. this.isFocused = false; // Allows close of tooltip when opened by focus.
  4041. this.open(false);
  4042. }
  4043. }, {
  4044. key: "_handleMouseLeave",
  4045. value: function _handleMouseLeave() {
  4046. this.isHovered = false;
  4047. this.isFocused = false; // Allows close of tooltip when opened by focus.
  4048. this.close();
  4049. }
  4050. }, {
  4051. key: "_handleFocus",
  4052. value: function _handleFocus() {
  4053. if (M.tabPressed) {
  4054. this.isFocused = true;
  4055. this.open(false);
  4056. }
  4057. }
  4058. }, {
  4059. key: "_handleBlur",
  4060. value: function _handleBlur() {
  4061. this.isFocused = false;
  4062. this.close();
  4063. }
  4064. }, {
  4065. key: "_getAttributeOptions",
  4066. value: function _getAttributeOptions() {
  4067. var attributeOptions = {};
  4068. var tooltipTextOption = this.el.getAttribute('data-tooltip');
  4069. var positionOption = this.el.getAttribute('data-position');
  4070. if (tooltipTextOption) {
  4071. attributeOptions.html = tooltipTextOption;
  4072. }
  4073. if (positionOption) {
  4074. attributeOptions.position = positionOption;
  4075. }
  4076. return attributeOptions;
  4077. }
  4078. }], [{
  4079. key: "init",
  4080. value: function init(els, options) {
  4081. return _get(Tooltip.__proto__ || Object.getPrototypeOf(Tooltip), "init", this).call(this, this, els, options);
  4082. }
  4083. /**
  4084. * Get Instance
  4085. */
  4086. }, {
  4087. key: "getInstance",
  4088. value: function getInstance(el) {
  4089. var domElem = !!el.jquery ? el[0] : el;
  4090. return domElem.M_Tooltip;
  4091. }
  4092. }, {
  4093. key: "defaults",
  4094. get: function () {
  4095. return _defaults;
  4096. }
  4097. }]);
  4098. return Tooltip;
  4099. }(Component);
  4100. M.Tooltip = Tooltip;
  4101. if (M.jQueryLoaded) {
  4102. M.initializeJqueryWrapper(Tooltip, 'tooltip', 'M_Tooltip');
  4103. }
  4104. })(cash, M.anime);
  4105. ; /*!
  4106. * Waves v0.6.4
  4107. * http://fian.my.id/Waves
  4108. *
  4109. * Copyright 2014 Alfiana E. Sibuea and other contributors
  4110. * Released under the MIT license
  4111. * https://github.com/fians/Waves/blob/master/LICENSE
  4112. */
  4113. ;(function (window) {
  4114. 'use strict';
  4115. var Waves = Waves || {};
  4116. var $$ = document.querySelectorAll.bind(document);
  4117. // Find exact position of element
  4118. function isWindow(obj) {
  4119. return obj !== null && obj === obj.window;
  4120. }
  4121. function getWindow(elem) {
  4122. return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
  4123. }
  4124. function offset(elem) {
  4125. var docElem,
  4126. win,
  4127. box = { top: 0, left: 0 },
  4128. doc = elem && elem.ownerDocument;
  4129. docElem = doc.documentElement;
  4130. if (typeof elem.getBoundingClientRect !== typeof undefined) {
  4131. box = elem.getBoundingClientRect();
  4132. }
  4133. win = getWindow(doc);
  4134. return {
  4135. top: box.top + win.pageYOffset - docElem.clientTop,
  4136. left: box.left + win.pageXOffset - docElem.clientLeft
  4137. };
  4138. }
  4139. function convertStyle(obj) {
  4140. var style = '';
  4141. for (var a in obj) {
  4142. if (obj.hasOwnProperty(a)) {
  4143. style += a + ':' + obj[a] + ';';
  4144. }
  4145. }
  4146. return style;
  4147. }
  4148. var Effect = {
  4149. // Effect delay
  4150. duration: 750,
  4151. show: function (e, element) {
  4152. // Disable right click
  4153. if (e.button === 2) {
  4154. return false;
  4155. }
  4156. var el = element || this;
  4157. // Create ripple
  4158. var ripple = document.createElement('div');
  4159. ripple.className = 'waves-ripple';
  4160. el.appendChild(ripple);
  4161. // Get click coordinate and element witdh
  4162. var pos = offset(el);
  4163. var relativeY = e.pageY - pos.top;
  4164. var relativeX = e.pageX - pos.left;
  4165. var scale = 'scale(' + el.clientWidth / 100 * 10 + ')';
  4166. // Support for touch devices
  4167. if ('touches' in e) {
  4168. relativeY = e.touches[0].pageY - pos.top;
  4169. relativeX = e.touches[0].pageX - pos.left;
  4170. }
  4171. // Attach data to element
  4172. ripple.setAttribute('data-hold', Date.now());
  4173. ripple.setAttribute('data-scale', scale);
  4174. ripple.setAttribute('data-x', relativeX);
  4175. ripple.setAttribute('data-y', relativeY);
  4176. // Set ripple position
  4177. var rippleStyle = {
  4178. 'top': relativeY + 'px',
  4179. 'left': relativeX + 'px'
  4180. };
  4181. ripple.className = ripple.className + ' waves-notransition';
  4182. ripple.setAttribute('style', convertStyle(rippleStyle));
  4183. ripple.className = ripple.className.replace('waves-notransition', '');
  4184. // Scale the ripple
  4185. rippleStyle['-webkit-transform'] = scale;
  4186. rippleStyle['-moz-transform'] = scale;
  4187. rippleStyle['-ms-transform'] = scale;
  4188. rippleStyle['-o-transform'] = scale;
  4189. rippleStyle.transform = scale;
  4190. rippleStyle.opacity = '1';
  4191. rippleStyle['-webkit-transition-duration'] = Effect.duration + 'ms';
  4192. rippleStyle['-moz-transition-duration'] = Effect.duration + 'ms';
  4193. rippleStyle['-o-transition-duration'] = Effect.duration + 'ms';
  4194. rippleStyle['transition-duration'] = Effect.duration + 'ms';
  4195. rippleStyle['-webkit-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
  4196. rippleStyle['-moz-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
  4197. rippleStyle['-o-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
  4198. rippleStyle['transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
  4199. ripple.setAttribute('style', convertStyle(rippleStyle));
  4200. },
  4201. hide: function (e) {
  4202. TouchHandler.touchup(e);
  4203. var el = this;
  4204. var width = el.clientWidth * 1.4;
  4205. // Get first ripple
  4206. var ripple = null;
  4207. var ripples = el.getElementsByClassName('waves-ripple');
  4208. if (ripples.length > 0) {
  4209. ripple = ripples[ripples.length - 1];
  4210. } else {
  4211. return false;
  4212. }
  4213. var relativeX = ripple.getAttribute('data-x');
  4214. var relativeY = ripple.getAttribute('data-y');
  4215. var scale = ripple.getAttribute('data-scale');
  4216. // Get delay beetween mousedown and mouse leave
  4217. var diff = Date.now() - Number(ripple.getAttribute('data-hold'));
  4218. var delay = 350 - diff;
  4219. if (delay < 0) {
  4220. delay = 0;
  4221. }
  4222. // Fade out ripple after delay
  4223. setTimeout(function () {
  4224. var style = {
  4225. 'top': relativeY + 'px',
  4226. 'left': relativeX + 'px',
  4227. 'opacity': '0',
  4228. // Duration
  4229. '-webkit-transition-duration': Effect.duration + 'ms',
  4230. '-moz-transition-duration': Effect.duration + 'ms',
  4231. '-o-transition-duration': Effect.duration + 'ms',
  4232. 'transition-duration': Effect.duration + 'ms',
  4233. '-webkit-transform': scale,
  4234. '-moz-transform': scale,
  4235. '-ms-transform': scale,
  4236. '-o-transform': scale,
  4237. 'transform': scale
  4238. };
  4239. ripple.setAttribute('style', convertStyle(style));
  4240. setTimeout(function () {
  4241. try {
  4242. el.removeChild(ripple);
  4243. } catch (e) {
  4244. return false;
  4245. }
  4246. }, Effect.duration);
  4247. }, delay);
  4248. },
  4249. // Little hack to make <input> can perform waves effect
  4250. wrapInput: function (elements) {
  4251. for (var a = 0; a < elements.length; a++) {
  4252. var el = elements[a];
  4253. if (el.tagName.toLowerCase() === 'input') {
  4254. var parent = el.parentNode;
  4255. // If input already have parent just pass through
  4256. if (parent.tagName.toLowerCase() === 'i' && parent.className.indexOf('waves-effect') !== -1) {
  4257. continue;
  4258. }
  4259. // Put element class and style to the specified parent
  4260. var wrapper = document.createElement('i');
  4261. wrapper.className = el.className + ' waves-input-wrapper';
  4262. var elementStyle = el.getAttribute('style');
  4263. if (!elementStyle) {
  4264. elementStyle = '';
  4265. }
  4266. wrapper.setAttribute('style', elementStyle);
  4267. el.className = 'waves-button-input';
  4268. el.removeAttribute('style');
  4269. // Put element as child
  4270. parent.replaceChild(wrapper, el);
  4271. wrapper.appendChild(el);
  4272. }
  4273. }
  4274. }
  4275. };
  4276. /**
  4277. * Disable mousedown event for 500ms during and after touch
  4278. */
  4279. var TouchHandler = {
  4280. /* uses an integer rather than bool so there's no issues with
  4281. * needing to clear timeouts if another touch event occurred
  4282. * within the 500ms. Cannot mouseup between touchstart and
  4283. * touchend, nor in the 500ms after touchend. */
  4284. touches: 0,
  4285. allowEvent: function (e) {
  4286. var allow = true;
  4287. if (e.type === 'touchstart') {
  4288. TouchHandler.touches += 1; //push
  4289. } else if (e.type === 'touchend' || e.type === 'touchcancel') {
  4290. setTimeout(function () {
  4291. if (TouchHandler.touches > 0) {
  4292. TouchHandler.touches -= 1; //pop after 500ms
  4293. }
  4294. }, 500);
  4295. } else if (e.type === 'mousedown' && TouchHandler.touches > 0) {
  4296. allow = false;
  4297. }
  4298. return allow;
  4299. },
  4300. touchup: function (e) {
  4301. TouchHandler.allowEvent(e);
  4302. }
  4303. };
  4304. /**
  4305. * Delegated click handler for .waves-effect element.
  4306. * returns null when .waves-effect element not in "click tree"
  4307. */
  4308. function getWavesEffectElement(e) {
  4309. if (TouchHandler.allowEvent(e) === false) {
  4310. return null;
  4311. }
  4312. var element = null;
  4313. var target = e.target || e.srcElement;
  4314. while (target.parentNode !== null) {
  4315. if (!(target instanceof SVGElement) && target.className.indexOf('waves-effect') !== -1) {
  4316. element = target;
  4317. break;
  4318. }
  4319. target = target.parentNode;
  4320. }
  4321. return element;
  4322. }
  4323. /**
  4324. * Bubble the click and show effect if .waves-effect elem was found
  4325. */
  4326. function showEffect(e) {
  4327. var element = getWavesEffectElement(e);
  4328. if (element !== null) {
  4329. Effect.show(e, element);
  4330. if ('ontouchstart' in window) {
  4331. element.addEventListener('touchend', Effect.hide, false);
  4332. element.addEventListener('touchcancel', Effect.hide, false);
  4333. }
  4334. element.addEventListener('mouseup', Effect.hide, false);
  4335. element.addEventListener('mouseleave', Effect.hide, false);
  4336. element.addEventListener('dragend', Effect.hide, false);
  4337. }
  4338. }
  4339. Waves.displayEffect = function (options) {
  4340. options = options || {};
  4341. if ('duration' in options) {
  4342. Effect.duration = options.duration;
  4343. }
  4344. //Wrap input inside <i> tag
  4345. Effect.wrapInput($$('.waves-effect'));
  4346. if ('ontouchstart' in window) {
  4347. document.body.addEventListener('touchstart', showEffect, false);
  4348. }
  4349. document.body.addEventListener('mousedown', showEffect, false);
  4350. };
  4351. /**
  4352. * Attach Waves to an input element (or any element which doesn't
  4353. * bubble mouseup/mousedown events).
  4354. * Intended to be used with dynamically loaded forms/inputs, or
  4355. * where the user doesn't want a delegated click handler.
  4356. */
  4357. Waves.attach = function (element) {
  4358. //FUTURE: automatically add waves classes and allow users
  4359. // to specify them with an options param? Eg. light/classic/button
  4360. if (element.tagName.toLowerCase() === 'input') {
  4361. Effect.wrapInput([element]);
  4362. element = element.parentNode;
  4363. }
  4364. if ('ontouchstart' in window) {
  4365. element.addEventListener('touchstart', showEffect, false);
  4366. }
  4367. element.addEventListener('mousedown', showEffect, false);
  4368. };
  4369. window.Waves = Waves;
  4370. document.addEventListener('DOMContentLoaded', function () {
  4371. Waves.displayEffect();
  4372. }, false);
  4373. })(window);
  4374. ;(function ($, anim) {
  4375. 'use strict';
  4376. var _defaults = {
  4377. html: '',
  4378. displayLength: 4000,
  4379. inDuration: 300,
  4380. outDuration: 375,
  4381. classes: '',
  4382. completeCallback: null,
  4383. activationPercent: 0.8
  4384. };
  4385. var Toast = function () {
  4386. function Toast(options) {
  4387. _classCallCheck(this, Toast);
  4388. /**
  4389. * Options for the toast
  4390. * @member Toast#options
  4391. */
  4392. this.options = $.extend({}, Toast.defaults, options);
  4393. this.message = this.options.html;
  4394. /**
  4395. * Describes current pan state toast
  4396. * @type {Boolean}
  4397. */
  4398. this.panning = false;
  4399. /**
  4400. * Time remaining until toast is removed
  4401. */
  4402. this.timeRemaining = this.options.displayLength;
  4403. if (Toast._toasts.length === 0) {
  4404. Toast._createContainer();
  4405. }
  4406. // Create new toast
  4407. Toast._toasts.push(this);
  4408. var toastElement = this._createToast();
  4409. toastElement.M_Toast = this;
  4410. this.el = toastElement;
  4411. this.$el = $(toastElement);
  4412. this._animateIn();
  4413. this._setTimer();
  4414. }
  4415. _createClass(Toast, [{
  4416. key: "_createToast",
  4417. /**
  4418. * Create toast and append it to toast container
  4419. */
  4420. value: function _createToast() {
  4421. var toast = document.createElement('div');
  4422. toast.classList.add('toast');
  4423. // Add custom classes onto toast
  4424. if (!!this.options.classes.length) {
  4425. $(toast).addClass(this.options.classes);
  4426. }
  4427. // Set content
  4428. if (typeof HTMLElement === 'object' ? this.message instanceof HTMLElement : this.message && typeof this.message === 'object' && this.message !== null && this.message.nodeType === 1 && typeof this.message.nodeName === 'string') {
  4429. toast.appendChild(this.message);
  4430. // Check if it is jQuery object
  4431. } else if (!!this.message.jquery) {
  4432. $(toast).append(this.message[0]);
  4433. // Insert as html;
  4434. } else {
  4435. toast.innerHTML = this.message;
  4436. }
  4437. // Append toasft
  4438. Toast._container.appendChild(toast);
  4439. return toast;
  4440. }
  4441. /**
  4442. * Animate in toast
  4443. */
  4444. }, {
  4445. key: "_animateIn",
  4446. value: function _animateIn() {
  4447. // Animate toast in
  4448. anim({
  4449. targets: this.el,
  4450. top: 0,
  4451. opacity: 1,
  4452. duration: this.options.inDuration,
  4453. easing: 'easeOutCubic'
  4454. });
  4455. }
  4456. /**
  4457. * Create setInterval which automatically removes toast when timeRemaining >= 0
  4458. * has been reached
  4459. */
  4460. }, {
  4461. key: "_setTimer",
  4462. value: function _setTimer() {
  4463. var _this29 = this;
  4464. if (this.timeRemaining !== Infinity) {
  4465. this.counterInterval = setInterval(function () {
  4466. // If toast is not being dragged, decrease its time remaining
  4467. if (!_this29.panning) {
  4468. _this29.timeRemaining -= 20;
  4469. }
  4470. // Animate toast out
  4471. if (_this29.timeRemaining <= 0) {
  4472. _this29.dismiss();
  4473. }
  4474. }, 20);
  4475. }
  4476. }
  4477. /**
  4478. * Dismiss toast with animation
  4479. */
  4480. }, {
  4481. key: "dismiss",
  4482. value: function dismiss() {
  4483. var _this30 = this;
  4484. window.clearInterval(this.counterInterval);
  4485. var activationDistance = this.el.offsetWidth * this.options.activationPercent;
  4486. if (this.wasSwiped) {
  4487. this.el.style.transition = 'transform .05s, opacity .05s';
  4488. this.el.style.transform = "translateX(" + activationDistance + "px)";
  4489. this.el.style.opacity = 0;
  4490. }
  4491. anim({
  4492. targets: this.el,
  4493. opacity: 0,
  4494. marginTop: -40,
  4495. duration: this.options.outDuration,
  4496. easing: 'easeOutExpo',
  4497. complete: function () {
  4498. // Call the optional callback
  4499. if (typeof _this30.options.completeCallback === 'function') {
  4500. _this30.options.completeCallback();
  4501. }
  4502. // Remove toast from DOM
  4503. _this30.$el.remove();
  4504. Toast._toasts.splice(Toast._toasts.indexOf(_this30), 1);
  4505. if (Toast._toasts.length === 0) {
  4506. Toast._removeContainer();
  4507. }
  4508. }
  4509. });
  4510. }
  4511. }], [{
  4512. key: "getInstance",
  4513. /**
  4514. * Get Instance
  4515. */
  4516. value: function getInstance(el) {
  4517. var domElem = !!el.jquery ? el[0] : el;
  4518. return domElem.M_Toast;
  4519. }
  4520. /**
  4521. * Append toast container and add event handlers
  4522. */
  4523. }, {
  4524. key: "_createContainer",
  4525. value: function _createContainer() {
  4526. var container = document.createElement('div');
  4527. container.setAttribute('id', 'toast-container');
  4528. // Add event handler
  4529. container.addEventListener('touchstart', Toast._onDragStart);
  4530. container.addEventListener('touchmove', Toast._onDragMove);
  4531. container.addEventListener('touchend', Toast._onDragEnd);
  4532. container.addEventListener('mousedown', Toast._onDragStart);
  4533. document.addEventListener('mousemove', Toast._onDragMove);
  4534. document.addEventListener('mouseup', Toast._onDragEnd);
  4535. document.body.appendChild(container);
  4536. Toast._container = container;
  4537. }
  4538. /**
  4539. * Remove toast container and event handlers
  4540. */
  4541. }, {
  4542. key: "_removeContainer",
  4543. value: function _removeContainer() {
  4544. // Add event handler
  4545. document.removeEventListener('mousemove', Toast._onDragMove);
  4546. document.removeEventListener('mouseup', Toast._onDragEnd);
  4547. $(Toast._container).remove();
  4548. Toast._container = null;
  4549. }
  4550. /**
  4551. * Begin drag handler
  4552. * @param {Event} e
  4553. */
  4554. }, {
  4555. key: "_onDragStart",
  4556. value: function _onDragStart(e) {
  4557. if (e.target && $(e.target).closest('.toast').length) {
  4558. var $toast = $(e.target).closest('.toast');
  4559. var toast = $toast[0].M_Toast;
  4560. toast.panning = true;
  4561. Toast._draggedToast = toast;
  4562. toast.el.classList.add('panning');
  4563. toast.el.style.transition = '';
  4564. toast.startingXPos = Toast._xPos(e);
  4565. toast.time = Date.now();
  4566. toast.xPos = Toast._xPos(e);
  4567. }
  4568. }
  4569. /**
  4570. * Drag move handler
  4571. * @param {Event} e
  4572. */
  4573. }, {
  4574. key: "_onDragMove",
  4575. value: function _onDragMove(e) {
  4576. if (!!Toast._draggedToast) {
  4577. e.preventDefault();
  4578. var toast = Toast._draggedToast;
  4579. toast.deltaX = Math.abs(toast.xPos - Toast._xPos(e));
  4580. toast.xPos = Toast._xPos(e);
  4581. toast.velocityX = toast.deltaX / (Date.now() - toast.time);
  4582. toast.time = Date.now();
  4583. var totalDeltaX = toast.xPos - toast.startingXPos;
  4584. var activationDistance = toast.el.offsetWidth * toast.options.activationPercent;
  4585. toast.el.style.transform = "translateX(" + totalDeltaX + "px)";
  4586. toast.el.style.opacity = 1 - Math.abs(totalDeltaX / activationDistance);
  4587. }
  4588. }
  4589. /**
  4590. * End drag handler
  4591. */
  4592. }, {
  4593. key: "_onDragEnd",
  4594. value: function _onDragEnd() {
  4595. if (!!Toast._draggedToast) {
  4596. var toast = Toast._draggedToast;
  4597. toast.panning = false;
  4598. toast.el.classList.remove('panning');
  4599. var totalDeltaX = toast.xPos - toast.startingXPos;
  4600. var activationDistance = toast.el.offsetWidth * toast.options.activationPercent;
  4601. var shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance || toast.velocityX > 1;
  4602. // Remove toast
  4603. if (shouldBeDismissed) {
  4604. toast.wasSwiped = true;
  4605. toast.dismiss();
  4606. // Animate toast back to original position
  4607. } else {
  4608. toast.el.style.transition = 'transform .2s, opacity .2s';
  4609. toast.el.style.transform = '';
  4610. toast.el.style.opacity = '';
  4611. }
  4612. Toast._draggedToast = null;
  4613. }
  4614. }
  4615. /**
  4616. * Get x position of mouse or touch event
  4617. * @param {Event} e
  4618. */
  4619. }, {
  4620. key: "_xPos",
  4621. value: function _xPos(e) {
  4622. if (e.targetTouches && e.targetTouches.length >= 1) {
  4623. return e.targetTouches[0].clientX;
  4624. }
  4625. // mouse event
  4626. return e.clientX;
  4627. }
  4628. /**
  4629. * Remove all toasts
  4630. */
  4631. }, {
  4632. key: "dismissAll",
  4633. value: function dismissAll() {
  4634. for (var toastIndex in Toast._toasts) {
  4635. Toast._toasts[toastIndex].dismiss();
  4636. }
  4637. }
  4638. }, {
  4639. key: "defaults",
  4640. get: function () {
  4641. return _defaults;
  4642. }
  4643. }]);
  4644. return Toast;
  4645. }();
  4646. /**
  4647. * @static
  4648. * @memberof Toast
  4649. * @type {Array.<Toast>}
  4650. */
  4651. Toast._toasts = [];
  4652. /**
  4653. * @static
  4654. * @memberof Toast
  4655. */
  4656. Toast._container = null;
  4657. /**
  4658. * @static
  4659. * @memberof Toast
  4660. * @type {Toast}
  4661. */
  4662. Toast._draggedToast = null;
  4663. M.Toast = Toast;
  4664. M.toast = function (options) {
  4665. return new Toast(options);
  4666. };
  4667. })(cash, M.anime);
  4668. ;(function ($, anim) {
  4669. 'use strict';
  4670. var _defaults = {
  4671. edge: 'left',
  4672. draggable: true,
  4673. inDuration: 250,
  4674. outDuration: 200,
  4675. onOpenStart: null,
  4676. onOpenEnd: null,
  4677. onCloseStart: null,
  4678. onCloseEnd: null,
  4679. preventScrolling: true
  4680. };
  4681. /**
  4682. * @class
  4683. */
  4684. var Sidenav = function (_Component8) {
  4685. _inherits(Sidenav, _Component8);
  4686. /**
  4687. * Construct Sidenav instance and set up overlay
  4688. * @constructor
  4689. * @param {Element} el
  4690. * @param {Object} options
  4691. */
  4692. function Sidenav(el, options) {
  4693. _classCallCheck(this, Sidenav);
  4694. var _this31 = _possibleConstructorReturn(this, (Sidenav.__proto__ || Object.getPrototypeOf(Sidenav)).call(this, Sidenav, el, options));
  4695. _this31.el.M_Sidenav = _this31;
  4696. _this31.id = _this31.$el.attr('id');
  4697. /**
  4698. * Options for the Sidenav
  4699. * @member Sidenav#options
  4700. * @prop {String} [edge='left'] - Side of screen on which Sidenav appears
  4701. * @prop {Boolean} [draggable=true] - Allow swipe gestures to open/close Sidenav
  4702. * @prop {Number} [inDuration=250] - Length in ms of enter transition
  4703. * @prop {Number} [outDuration=200] - Length in ms of exit transition
  4704. * @prop {Function} onOpenStart - Function called when sidenav starts entering
  4705. * @prop {Function} onOpenEnd - Function called when sidenav finishes entering
  4706. * @prop {Function} onCloseStart - Function called when sidenav starts exiting
  4707. * @prop {Function} onCloseEnd - Function called when sidenav finishes exiting
  4708. */
  4709. _this31.options = $.extend({}, Sidenav.defaults, options);
  4710. /**
  4711. * Describes open/close state of Sidenav
  4712. * @type {Boolean}
  4713. */
  4714. _this31.isOpen = false;
  4715. /**
  4716. * Describes if Sidenav is fixed
  4717. * @type {Boolean}
  4718. */
  4719. _this31.isFixed = _this31.el.classList.contains('sidenav-fixed');
  4720. /**
  4721. * Describes if Sidenav is being draggeed
  4722. * @type {Boolean}
  4723. */
  4724. _this31.isDragged = false;
  4725. // Window size variables for window resize checks
  4726. _this31.lastWindowWidth = window.innerWidth;
  4727. _this31.lastWindowHeight = window.innerHeight;
  4728. _this31._createOverlay();
  4729. _this31._createDragTarget();
  4730. _this31._setupEventHandlers();
  4731. _this31._setupClasses();
  4732. _this31._setupFixed();
  4733. Sidenav._sidenavs.push(_this31);
  4734. return _this31;
  4735. }
  4736. _createClass(Sidenav, [{
  4737. key: "destroy",
  4738. /**
  4739. * Teardown component
  4740. */
  4741. value: function destroy() {
  4742. this._removeEventHandlers();
  4743. this._enableBodyScrolling();
  4744. this._overlay.parentNode.removeChild(this._overlay);
  4745. this.dragTarget.parentNode.removeChild(this.dragTarget);
  4746. this.el.M_Sidenav = undefined;
  4747. this.el.style.transform = '';
  4748. var index = Sidenav._sidenavs.indexOf(this);
  4749. if (index >= 0) {
  4750. Sidenav._sidenavs.splice(index, 1);
  4751. }
  4752. }
  4753. }, {
  4754. key: "_createOverlay",
  4755. value: function _createOverlay() {
  4756. var overlay = document.createElement('div');
  4757. this._closeBound = this.close.bind(this);
  4758. overlay.classList.add('sidenav-overlay');
  4759. overlay.addEventListener('click', this._closeBound);
  4760. document.body.appendChild(overlay);
  4761. this._overlay = overlay;
  4762. }
  4763. }, {
  4764. key: "_setupEventHandlers",
  4765. value: function _setupEventHandlers() {
  4766. if (Sidenav._sidenavs.length === 0) {
  4767. document.body.addEventListener('click', this._handleTriggerClick);
  4768. }
  4769. this._handleDragTargetDragBound = this._handleDragTargetDrag.bind(this);
  4770. this._handleDragTargetReleaseBound = this._handleDragTargetRelease.bind(this);
  4771. this._handleCloseDragBound = this._handleCloseDrag.bind(this);
  4772. this._handleCloseReleaseBound = this._handleCloseRelease.bind(this);
  4773. this._handleCloseTriggerClickBound = this._handleCloseTriggerClick.bind(this);
  4774. this.dragTarget.addEventListener('touchmove', this._handleDragTargetDragBound);
  4775. this.dragTarget.addEventListener('touchend', this._handleDragTargetReleaseBound);
  4776. this._overlay.addEventListener('touchmove', this._handleCloseDragBound);
  4777. this._overlay.addEventListener('touchend', this._handleCloseReleaseBound);
  4778. this.el.addEventListener('touchmove', this._handleCloseDragBound);
  4779. this.el.addEventListener('touchend', this._handleCloseReleaseBound);
  4780. this.el.addEventListener('click', this._handleCloseTriggerClickBound);
  4781. // Add resize for side nav fixed
  4782. if (this.isFixed) {
  4783. this._handleWindowResizeBound = this._handleWindowResize.bind(this);
  4784. window.addEventListener('resize', this._handleWindowResizeBound);
  4785. }
  4786. }
  4787. }, {
  4788. key: "_removeEventHandlers",
  4789. value: function _removeEventHandlers() {
  4790. if (Sidenav._sidenavs.length === 1) {
  4791. document.body.removeEventListener('click', this._handleTriggerClick);
  4792. }
  4793. this.dragTarget.removeEventListener('touchmove', this._handleDragTargetDragBound);
  4794. this.dragTarget.removeEventListener('touchend', this._handleDragTargetReleaseBound);
  4795. this._overlay.removeEventListener('touchmove', this._handleCloseDragBound);
  4796. this._overlay.removeEventListener('touchend', this._handleCloseReleaseBound);
  4797. this.el.removeEventListener('touchmove', this._handleCloseDragBound);
  4798. this.el.removeEventListener('touchend', this._handleCloseReleaseBound);
  4799. this.el.removeEventListener('click', this._handleCloseTriggerClickBound);
  4800. // Remove resize for side nav fixed
  4801. if (this.isFixed) {
  4802. window.removeEventListener('resize', this._handleWindowResizeBound);
  4803. }
  4804. }
  4805. /**
  4806. * Handle Trigger Click
  4807. * @param {Event} e
  4808. */
  4809. }, {
  4810. key: "_handleTriggerClick",
  4811. value: function _handleTriggerClick(e) {
  4812. var $trigger = $(e.target).closest('.sidenav-trigger');
  4813. if (e.target && $trigger.length) {
  4814. var sidenavId = M.getIdFromTrigger($trigger[0]);
  4815. var sidenavInstance = document.getElementById(sidenavId).M_Sidenav;
  4816. if (sidenavInstance) {
  4817. sidenavInstance.open($trigger);
  4818. }
  4819. e.preventDefault();
  4820. }
  4821. }
  4822. /**
  4823. * Set variables needed at the beggining of drag
  4824. * and stop any current transition.
  4825. * @param {Event} e
  4826. */
  4827. }, {
  4828. key: "_startDrag",
  4829. value: function _startDrag(e) {
  4830. var clientX = e.targetTouches[0].clientX;
  4831. this.isDragged = true;
  4832. this._startingXpos = clientX;
  4833. this._xPos = this._startingXpos;
  4834. this._time = Date.now();
  4835. this._width = this.el.getBoundingClientRect().width;
  4836. this._overlay.style.display = 'block';
  4837. this._initialScrollTop = this.isOpen ? this.el.scrollTop : M.getDocumentScrollTop();
  4838. this._verticallyScrolling = false;
  4839. anim.remove(this.el);
  4840. anim.remove(this._overlay);
  4841. }
  4842. /**
  4843. * Set variables needed at each drag move update tick
  4844. * @param {Event} e
  4845. */
  4846. }, {
  4847. key: "_dragMoveUpdate",
  4848. value: function _dragMoveUpdate(e) {
  4849. var clientX = e.targetTouches[0].clientX;
  4850. var currentScrollTop = this.isOpen ? this.el.scrollTop : M.getDocumentScrollTop();
  4851. this.deltaX = Math.abs(this._xPos - clientX);
  4852. this._xPos = clientX;
  4853. this.velocityX = this.deltaX / (Date.now() - this._time);
  4854. this._time = Date.now();
  4855. if (this._initialScrollTop !== currentScrollTop) {
  4856. this._verticallyScrolling = true;
  4857. }
  4858. }
  4859. /**
  4860. * Handles Dragging of Sidenav
  4861. * @param {Event} e
  4862. */
  4863. }, {
  4864. key: "_handleDragTargetDrag",
  4865. value: function _handleDragTargetDrag(e) {
  4866. // Check if draggable
  4867. if (!this.options.draggable || this._isCurrentlyFixed() || this._verticallyScrolling) {
  4868. return;
  4869. }
  4870. // If not being dragged, set initial drag start variables
  4871. if (!this.isDragged) {
  4872. this._startDrag(e);
  4873. }
  4874. // Run touchmove updates
  4875. this._dragMoveUpdate(e);
  4876. // Calculate raw deltaX
  4877. var totalDeltaX = this._xPos - this._startingXpos;
  4878. // dragDirection is the attempted user drag direction
  4879. var dragDirection = totalDeltaX > 0 ? 'right' : 'left';
  4880. // Don't allow totalDeltaX to exceed Sidenav width or be dragged in the opposite direction
  4881. totalDeltaX = Math.min(this._width, Math.abs(totalDeltaX));
  4882. if (this.options.edge === dragDirection) {
  4883. totalDeltaX = 0;
  4884. }
  4885. /**
  4886. * transformX is the drag displacement
  4887. * transformPrefix is the initial transform placement
  4888. * Invert values if Sidenav is right edge
  4889. */
  4890. var transformX = totalDeltaX;
  4891. var transformPrefix = 'translateX(-100%)';
  4892. if (this.options.edge === 'right') {
  4893. transformPrefix = 'translateX(100%)';
  4894. transformX = -transformX;
  4895. }
  4896. // Calculate open/close percentage of sidenav, with open = 1 and close = 0
  4897. this.percentOpen = Math.min(1, totalDeltaX / this._width);
  4898. // Set transform and opacity styles
  4899. this.el.style.transform = transformPrefix + " translateX(" + transformX + "px)";
  4900. this._overlay.style.opacity = this.percentOpen;
  4901. }
  4902. /**
  4903. * Handle Drag Target Release
  4904. */
  4905. }, {
  4906. key: "_handleDragTargetRelease",
  4907. value: function _handleDragTargetRelease() {
  4908. if (this.isDragged) {
  4909. if (this.percentOpen > 0.2) {
  4910. this.open();
  4911. } else {
  4912. this._animateOut();
  4913. }
  4914. this.isDragged = false;
  4915. this._verticallyScrolling = false;
  4916. }
  4917. }
  4918. /**
  4919. * Handle Close Drag
  4920. * @param {Event} e
  4921. */
  4922. }, {
  4923. key: "_handleCloseDrag",
  4924. value: function _handleCloseDrag(e) {
  4925. if (this.isOpen) {
  4926. // Check if draggable
  4927. if (!this.options.draggable || this._isCurrentlyFixed() || this._verticallyScrolling) {
  4928. return;
  4929. }
  4930. // If not being dragged, set initial drag start variables
  4931. if (!this.isDragged) {
  4932. this._startDrag(e);
  4933. }
  4934. // Run touchmove updates
  4935. this._dragMoveUpdate(e);
  4936. // Calculate raw deltaX
  4937. var totalDeltaX = this._xPos - this._startingXpos;
  4938. // dragDirection is the attempted user drag direction
  4939. var dragDirection = totalDeltaX > 0 ? 'right' : 'left';
  4940. // Don't allow totalDeltaX to exceed Sidenav width or be dragged in the opposite direction
  4941. totalDeltaX = Math.min(this._width, Math.abs(totalDeltaX));
  4942. if (this.options.edge !== dragDirection) {
  4943. totalDeltaX = 0;
  4944. }
  4945. var transformX = -totalDeltaX;
  4946. if (this.options.edge === 'right') {
  4947. transformX = -transformX;
  4948. }
  4949. // Calculate open/close percentage of sidenav, with open = 1 and close = 0
  4950. this.percentOpen = Math.min(1, 1 - totalDeltaX / this._width);
  4951. // Set transform and opacity styles
  4952. this.el.style.transform = "translateX(" + transformX + "px)";
  4953. this._overlay.style.opacity = this.percentOpen;
  4954. }
  4955. }
  4956. /**
  4957. * Handle Close Release
  4958. */
  4959. }, {
  4960. key: "_handleCloseRelease",
  4961. value: function _handleCloseRelease() {
  4962. if (this.isOpen && this.isDragged) {
  4963. if (this.percentOpen > 0.8) {
  4964. this._animateIn();
  4965. } else {
  4966. this.close();
  4967. }
  4968. this.isDragged = false;
  4969. this._verticallyScrolling = false;
  4970. }
  4971. }
  4972. /**
  4973. * Handles closing of Sidenav when element with class .sidenav-close
  4974. */
  4975. }, {
  4976. key: "_handleCloseTriggerClick",
  4977. value: function _handleCloseTriggerClick(e) {
  4978. var $closeTrigger = $(e.target).closest('.sidenav-close');
  4979. if ($closeTrigger.length && !this._isCurrentlyFixed()) {
  4980. this.close();
  4981. }
  4982. }
  4983. /**
  4984. * Handle Window Resize
  4985. */
  4986. }, {
  4987. key: "_handleWindowResize",
  4988. value: function _handleWindowResize() {
  4989. // Only handle horizontal resizes
  4990. if (this.lastWindowWidth !== window.innerWidth) {
  4991. if (window.innerWidth > 992) {
  4992. this.open();
  4993. } else {
  4994. this.close();
  4995. }
  4996. }
  4997. this.lastWindowWidth = window.innerWidth;
  4998. this.lastWindowHeight = window.innerHeight;
  4999. }
  5000. }, {
  5001. key: "_setupClasses",
  5002. value: function _setupClasses() {
  5003. if (this.options.edge === 'right') {
  5004. this.el.classList.add('right-aligned');
  5005. this.dragTarget.classList.add('right-aligned');
  5006. }
  5007. }
  5008. }, {
  5009. key: "_removeClasses",
  5010. value: function _removeClasses() {
  5011. this.el.classList.remove('right-aligned');
  5012. this.dragTarget.classList.remove('right-aligned');
  5013. }
  5014. }, {
  5015. key: "_setupFixed",
  5016. value: function _setupFixed() {
  5017. if (this._isCurrentlyFixed()) {
  5018. this.open();
  5019. }
  5020. }
  5021. }, {
  5022. key: "_isCurrentlyFixed",
  5023. value: function _isCurrentlyFixed() {
  5024. return this.isFixed && window.innerWidth > 992;
  5025. }
  5026. }, {
  5027. key: "_createDragTarget",
  5028. value: function _createDragTarget() {
  5029. var dragTarget = document.createElement('div');
  5030. dragTarget.classList.add('drag-target');
  5031. document.body.appendChild(dragTarget);
  5032. this.dragTarget = dragTarget;
  5033. }
  5034. }, {
  5035. key: "_preventBodyScrolling",
  5036. value: function _preventBodyScrolling() {
  5037. var body = document.body;
  5038. body.style.overflow = 'hidden';
  5039. }
  5040. }, {
  5041. key: "_enableBodyScrolling",
  5042. value: function _enableBodyScrolling() {
  5043. var body = document.body;
  5044. body.style.overflow = '';
  5045. }
  5046. }, {
  5047. key: "open",
  5048. value: function open() {
  5049. if (this.isOpen === true) {
  5050. return;
  5051. }
  5052. this.isOpen = true;
  5053. // Run onOpenStart callback
  5054. if (typeof this.options.onOpenStart === 'function') {
  5055. this.options.onOpenStart.call(this, this.el);
  5056. }
  5057. // Handle fixed Sidenav
  5058. if (this._isCurrentlyFixed()) {
  5059. anim.remove(this.el);
  5060. anim({
  5061. targets: this.el,
  5062. translateX: 0,
  5063. duration: 0,
  5064. easing: 'easeOutQuad'
  5065. });
  5066. this._enableBodyScrolling();
  5067. this._overlay.style.display = 'none';
  5068. // Handle non-fixed Sidenav
  5069. } else {
  5070. if (this.options.preventScrolling) {
  5071. this._preventBodyScrolling();
  5072. }
  5073. if (!this.isDragged || this.percentOpen != 1) {
  5074. this._animateIn();
  5075. }
  5076. }
  5077. }
  5078. }, {
  5079. key: "close",
  5080. value: function close() {
  5081. if (this.isOpen === false) {
  5082. return;
  5083. }
  5084. this.isOpen = false;
  5085. // Run onCloseStart callback
  5086. if (typeof this.options.onCloseStart === 'function') {
  5087. this.options.onCloseStart.call(this, this.el);
  5088. }
  5089. // Handle fixed Sidenav
  5090. if (this._isCurrentlyFixed()) {
  5091. var transformX = this.options.edge === 'left' ? '-105%' : '105%';
  5092. this.el.style.transform = "translateX(" + transformX + ")";
  5093. // Handle non-fixed Sidenav
  5094. } else {
  5095. this._enableBodyScrolling();
  5096. if (!this.isDragged || this.percentOpen != 0) {
  5097. this._animateOut();
  5098. } else {
  5099. this._overlay.style.display = 'none';
  5100. }
  5101. }
  5102. }
  5103. }, {
  5104. key: "_animateIn",
  5105. value: function _animateIn() {
  5106. this._animateSidenavIn();
  5107. this._animateOverlayIn();
  5108. }
  5109. }, {
  5110. key: "_animateSidenavIn",
  5111. value: function _animateSidenavIn() {
  5112. var _this32 = this;
  5113. var slideOutPercent = this.options.edge === 'left' ? -1 : 1;
  5114. if (this.isDragged) {
  5115. slideOutPercent = this.options.edge === 'left' ? slideOutPercent + this.percentOpen : slideOutPercent - this.percentOpen;
  5116. }
  5117. anim.remove(this.el);
  5118. anim({
  5119. targets: this.el,
  5120. translateX: [slideOutPercent * 100 + "%", 0],
  5121. duration: this.options.inDuration,
  5122. easing: 'easeOutQuad',
  5123. complete: function () {
  5124. // Run onOpenEnd callback
  5125. if (typeof _this32.options.onOpenEnd === 'function') {
  5126. _this32.options.onOpenEnd.call(_this32, _this32.el);
  5127. }
  5128. }
  5129. });
  5130. }
  5131. }, {
  5132. key: "_animateOverlayIn",
  5133. value: function _animateOverlayIn() {
  5134. var start = 0;
  5135. if (this.isDragged) {
  5136. start = this.percentOpen;
  5137. } else {
  5138. $(this._overlay).css({
  5139. display: 'block'
  5140. });
  5141. }
  5142. anim.remove(this._overlay);
  5143. anim({
  5144. targets: this._overlay,
  5145. opacity: [start, 1],
  5146. duration: this.options.inDuration,
  5147. easing: 'easeOutQuad'
  5148. });
  5149. }
  5150. }, {
  5151. key: "_animateOut",
  5152. value: function _animateOut() {
  5153. this._animateSidenavOut();
  5154. this._animateOverlayOut();
  5155. }
  5156. }, {
  5157. key: "_animateSidenavOut",
  5158. value: function _animateSidenavOut() {
  5159. var _this33 = this;
  5160. var endPercent = this.options.edge === 'left' ? -1 : 1;
  5161. var slideOutPercent = 0;
  5162. if (this.isDragged) {
  5163. slideOutPercent = this.options.edge === 'left' ? endPercent + this.percentOpen : endPercent - this.percentOpen;
  5164. }
  5165. anim.remove(this.el);
  5166. anim({
  5167. targets: this.el,
  5168. translateX: [slideOutPercent * 100 + "%", endPercent * 105 + "%"],
  5169. duration: this.options.outDuration,
  5170. easing: 'easeOutQuad',
  5171. complete: function () {
  5172. // Run onOpenEnd callback
  5173. if (typeof _this33.options.onCloseEnd === 'function') {
  5174. _this33.options.onCloseEnd.call(_this33, _this33.el);
  5175. }
  5176. }
  5177. });
  5178. }
  5179. }, {
  5180. key: "_animateOverlayOut",
  5181. value: function _animateOverlayOut() {
  5182. var _this34 = this;
  5183. anim.remove(this._overlay);
  5184. anim({
  5185. targets: this._overlay,
  5186. opacity: 0,
  5187. duration: this.options.outDuration,
  5188. easing: 'easeOutQuad',
  5189. complete: function () {
  5190. $(_this34._overlay).css('display', 'none');
  5191. }
  5192. });
  5193. }
  5194. }], [{
  5195. key: "init",
  5196. value: function init(els, options) {
  5197. return _get(Sidenav.__proto__ || Object.getPrototypeOf(Sidenav), "init", this).call(this, this, els, options);
  5198. }
  5199. /**
  5200. * Get Instance
  5201. */
  5202. }, {
  5203. key: "getInstance",
  5204. value: function getInstance(el) {
  5205. var domElem = !!el.jquery ? el[0] : el;
  5206. return domElem.M_Sidenav;
  5207. }
  5208. }, {
  5209. key: "defaults",
  5210. get: function () {
  5211. return _defaults;
  5212. }
  5213. }]);
  5214. return Sidenav;
  5215. }(Component);
  5216. /**
  5217. * @static
  5218. * @memberof Sidenav
  5219. * @type {Array.<Sidenav>}
  5220. */
  5221. Sidenav._sidenavs = [];
  5222. window.M.Sidenav = Sidenav;
  5223. if (M.jQueryLoaded) {
  5224. M.initializeJqueryWrapper(Sidenav, 'sidenav', 'M_Sidenav');
  5225. }
  5226. })(cash, M.anime);
  5227. ;(function ($, anim) {
  5228. 'use strict';
  5229. var _defaults = {
  5230. throttle: 100,
  5231. scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll
  5232. activeClass: 'active',
  5233. getActiveElement: function (id) {
  5234. return 'a[href="#' + id + '"]';
  5235. }
  5236. };
  5237. /**
  5238. * @class
  5239. *
  5240. */
  5241. var ScrollSpy = function (_Component9) {
  5242. _inherits(ScrollSpy, _Component9);
  5243. /**
  5244. * Construct ScrollSpy instance
  5245. * @constructor
  5246. * @param {Element} el
  5247. * @param {Object} options
  5248. */
  5249. function ScrollSpy(el, options) {
  5250. _classCallCheck(this, ScrollSpy);
  5251. var _this35 = _possibleConstructorReturn(this, (ScrollSpy.__proto__ || Object.getPrototypeOf(ScrollSpy)).call(this, ScrollSpy, el, options));
  5252. _this35.el.M_ScrollSpy = _this35;
  5253. /**
  5254. * Options for the modal
  5255. * @member Modal#options
  5256. * @prop {Number} [throttle=100] - Throttle of scroll handler
  5257. * @prop {Number} [scrollOffset=200] - Offset for centering element when scrolled to
  5258. * @prop {String} [activeClass='active'] - Class applied to active elements
  5259. * @prop {Function} [getActiveElement] - Used to find active element
  5260. */
  5261. _this35.options = $.extend({}, ScrollSpy.defaults, options);
  5262. // setup
  5263. ScrollSpy._elements.push(_this35);
  5264. ScrollSpy._count++;
  5265. ScrollSpy._increment++;
  5266. _this35.tickId = -1;
  5267. _this35.id = ScrollSpy._increment;
  5268. _this35._setupEventHandlers();
  5269. _this35._handleWindowScroll();
  5270. return _this35;
  5271. }
  5272. _createClass(ScrollSpy, [{
  5273. key: "destroy",
  5274. /**
  5275. * Teardown component
  5276. */
  5277. value: function destroy() {
  5278. ScrollSpy._elements.splice(ScrollSpy._elements.indexOf(this), 1);
  5279. ScrollSpy._elementsInView.splice(ScrollSpy._elementsInView.indexOf(this), 1);
  5280. ScrollSpy._visibleElements.splice(ScrollSpy._visibleElements.indexOf(this.$el), 1);
  5281. ScrollSpy._count--;
  5282. this._removeEventHandlers();
  5283. $(this.options.getActiveElement(this.$el.attr('id'))).removeClass(this.options.activeClass);
  5284. this.el.M_ScrollSpy = undefined;
  5285. }
  5286. /**
  5287. * Setup Event Handlers
  5288. */
  5289. }, {
  5290. key: "_setupEventHandlers",
  5291. value: function _setupEventHandlers() {
  5292. var throttledResize = M.throttle(this._handleWindowScroll, 200);
  5293. this._handleThrottledResizeBound = throttledResize.bind(this);
  5294. this._handleWindowScrollBound = this._handleWindowScroll.bind(this);
  5295. if (ScrollSpy._count === 1) {
  5296. window.addEventListener('scroll', this._handleWindowScrollBound);
  5297. window.addEventListener('resize', this._handleThrottledResizeBound);
  5298. document.body.addEventListener('click', this._handleTriggerClick);
  5299. }
  5300. }
  5301. /**
  5302. * Remove Event Handlers
  5303. */
  5304. }, {
  5305. key: "_removeEventHandlers",
  5306. value: function _removeEventHandlers() {
  5307. if (ScrollSpy._count === 0) {
  5308. window.removeEventListener('scroll', this._handleWindowScrollBound);
  5309. window.removeEventListener('resize', this._handleThrottledResizeBound);
  5310. document.body.removeEventListener('click', this._handleTriggerClick);
  5311. }
  5312. }
  5313. /**
  5314. * Handle Trigger Click
  5315. * @param {Event} e
  5316. */
  5317. }, {
  5318. key: "_handleTriggerClick",
  5319. value: function _handleTriggerClick(e) {
  5320. var $trigger = $(e.target);
  5321. for (var i = ScrollSpy._elements.length - 1; i >= 0; i--) {
  5322. var scrollspy = ScrollSpy._elements[i];
  5323. if ($trigger.is('a[href="#' + scrollspy.$el.attr('id') + '"]')) {
  5324. e.preventDefault();
  5325. var offset = scrollspy.$el.offset().top + 1;
  5326. anim({
  5327. targets: [document.documentElement, document.body],
  5328. scrollTop: offset - scrollspy.options.scrollOffset,
  5329. duration: 400,
  5330. easing: 'easeOutCubic'
  5331. });
  5332. break;
  5333. }
  5334. }
  5335. }
  5336. /**
  5337. * Handle Window Scroll
  5338. */
  5339. }, {
  5340. key: "_handleWindowScroll",
  5341. value: function _handleWindowScroll() {
  5342. // unique tick id
  5343. ScrollSpy._ticks++;
  5344. // viewport rectangle
  5345. var top = M.getDocumentScrollTop(),
  5346. left = M.getDocumentScrollLeft(),
  5347. right = left + window.innerWidth,
  5348. bottom = top + window.innerHeight;
  5349. // determine which elements are in view
  5350. var intersections = ScrollSpy._findElements(top, right, bottom, left);
  5351. for (var i = 0; i < intersections.length; i++) {
  5352. var scrollspy = intersections[i];
  5353. var lastTick = scrollspy.tickId;
  5354. if (lastTick < 0) {
  5355. // entered into view
  5356. scrollspy._enter();
  5357. }
  5358. // update tick id
  5359. scrollspy.tickId = ScrollSpy._ticks;
  5360. }
  5361. for (var _i = 0; _i < ScrollSpy._elementsInView.length; _i++) {
  5362. var _scrollspy = ScrollSpy._elementsInView[_i];
  5363. var _lastTick = _scrollspy.tickId;
  5364. if (_lastTick >= 0 && _lastTick !== ScrollSpy._ticks) {
  5365. // exited from view
  5366. _scrollspy._exit();
  5367. _scrollspy.tickId = -1;
  5368. }
  5369. }
  5370. // remember elements in view for next tick
  5371. ScrollSpy._elementsInView = intersections;
  5372. }
  5373. /**
  5374. * Find elements that are within the boundary
  5375. * @param {number} top
  5376. * @param {number} right
  5377. * @param {number} bottom
  5378. * @param {number} left
  5379. * @return {Array.<ScrollSpy>} A collection of elements
  5380. */
  5381. }, {
  5382. key: "_enter",
  5383. value: function _enter() {
  5384. ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(function (value) {
  5385. return value.height() != 0;
  5386. });
  5387. if (ScrollSpy._visibleElements[0]) {
  5388. $(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).removeClass(this.options.activeClass);
  5389. if (ScrollSpy._visibleElements[0][0].M_ScrollSpy && this.id < ScrollSpy._visibleElements[0][0].M_ScrollSpy.id) {
  5390. ScrollSpy._visibleElements.unshift(this.$el);
  5391. } else {
  5392. ScrollSpy._visibleElements.push(this.$el);
  5393. }
  5394. } else {
  5395. ScrollSpy._visibleElements.push(this.$el);
  5396. }
  5397. $(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).addClass(this.options.activeClass);
  5398. }
  5399. }, {
  5400. key: "_exit",
  5401. value: function _exit() {
  5402. var _this36 = this;
  5403. ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(function (value) {
  5404. return value.height() != 0;
  5405. });
  5406. if (ScrollSpy._visibleElements[0]) {
  5407. $(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).removeClass(this.options.activeClass);
  5408. ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(function (el) {
  5409. return el.attr('id') != _this36.$el.attr('id');
  5410. });
  5411. if (ScrollSpy._visibleElements[0]) {
  5412. // Check if empty
  5413. $(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).addClass(this.options.activeClass);
  5414. }
  5415. }
  5416. }
  5417. }], [{
  5418. key: "init",
  5419. value: function init(els, options) {
  5420. return _get(ScrollSpy.__proto__ || Object.getPrototypeOf(ScrollSpy), "init", this).call(this, this, els, options);
  5421. }
  5422. /**
  5423. * Get Instance
  5424. */
  5425. }, {
  5426. key: "getInstance",
  5427. value: function getInstance(el) {
  5428. var domElem = !!el.jquery ? el[0] : el;
  5429. return domElem.M_ScrollSpy;
  5430. }
  5431. }, {
  5432. key: "_findElements",
  5433. value: function _findElements(top, right, bottom, left) {
  5434. var hits = [];
  5435. for (var i = 0; i < ScrollSpy._elements.length; i++) {
  5436. var scrollspy = ScrollSpy._elements[i];
  5437. var currTop = top + scrollspy.options.scrollOffset || 200;
  5438. if (scrollspy.$el.height() > 0) {
  5439. var elTop = scrollspy.$el.offset().top,
  5440. elLeft = scrollspy.$el.offset().left,
  5441. elRight = elLeft + scrollspy.$el.width(),
  5442. elBottom = elTop + scrollspy.$el.height();
  5443. var isIntersect = !(elLeft > right || elRight < left || elTop > bottom || elBottom < currTop);
  5444. if (isIntersect) {
  5445. hits.push(scrollspy);
  5446. }
  5447. }
  5448. }
  5449. return hits;
  5450. }
  5451. }, {
  5452. key: "defaults",
  5453. get: function () {
  5454. return _defaults;
  5455. }
  5456. }]);
  5457. return ScrollSpy;
  5458. }(Component);
  5459. /**
  5460. * @static
  5461. * @memberof ScrollSpy
  5462. * @type {Array.<ScrollSpy>}
  5463. */
  5464. ScrollSpy._elements = [];
  5465. /**
  5466. * @static
  5467. * @memberof ScrollSpy
  5468. * @type {Array.<ScrollSpy>}
  5469. */
  5470. ScrollSpy._elementsInView = [];
  5471. /**
  5472. * @static
  5473. * @memberof ScrollSpy
  5474. * @type {Array.<cash>}
  5475. */
  5476. ScrollSpy._visibleElements = [];
  5477. /**
  5478. * @static
  5479. * @memberof ScrollSpy
  5480. */
  5481. ScrollSpy._count = 0;
  5482. /**
  5483. * @static
  5484. * @memberof ScrollSpy
  5485. */
  5486. ScrollSpy._increment = 0;
  5487. /**
  5488. * @static
  5489. * @memberof ScrollSpy
  5490. */
  5491. ScrollSpy._ticks = 0;
  5492. M.ScrollSpy = ScrollSpy;
  5493. if (M.jQueryLoaded) {
  5494. M.initializeJqueryWrapper(ScrollSpy, 'scrollSpy', 'M_ScrollSpy');
  5495. }
  5496. })(cash, M.anime);
  5497. ;(function ($) {
  5498. 'use strict';
  5499. var _defaults = {
  5500. data: {}, // Autocomplete data set
  5501. limit: Infinity, // Limit of results the autocomplete shows
  5502. onAutocomplete: null, // Callback for when autocompleted
  5503. minLength: 1, // Min characters before autocomplete starts
  5504. sortFunction: function (a, b, inputString) {
  5505. // Sort function for sorting autocomplete results
  5506. return a.indexOf(inputString) - b.indexOf(inputString);
  5507. }
  5508. };
  5509. /**
  5510. * @class
  5511. *
  5512. */
  5513. var Autocomplete = function (_Component10) {
  5514. _inherits(Autocomplete, _Component10);
  5515. /**
  5516. * Construct Autocomplete instance
  5517. * @constructor
  5518. * @param {Element} el
  5519. * @param {Object} options
  5520. */
  5521. function Autocomplete(el, options) {
  5522. _classCallCheck(this, Autocomplete);
  5523. var _this37 = _possibleConstructorReturn(this, (Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete)).call(this, Autocomplete, el, options));
  5524. _this37.el.M_Autocomplete = _this37;
  5525. /**
  5526. * Options for the autocomplete
  5527. * @member Autocomplete#options
  5528. * @prop {Number} duration
  5529. * @prop {Number} dist
  5530. * @prop {number} shift
  5531. * @prop {number} padding
  5532. * @prop {Boolean} fullWidth
  5533. * @prop {Boolean} indicators
  5534. * @prop {Boolean} noWrap
  5535. * @prop {Function} onCycleTo
  5536. */
  5537. _this37.options = $.extend({}, Autocomplete.defaults, options);
  5538. // Setup
  5539. _this37.isOpen = false;
  5540. _this37.count = 0;
  5541. _this37.activeIndex = -1;
  5542. _this37.oldVal;
  5543. _this37.$inputField = _this37.$el.closest('.input-field');
  5544. _this37.$active = $();
  5545. _this37._mousedown = false;
  5546. _this37._setupDropdown();
  5547. _this37._setupEventHandlers();
  5548. return _this37;
  5549. }
  5550. _createClass(Autocomplete, [{
  5551. key: "destroy",
  5552. /**
  5553. * Teardown component
  5554. */
  5555. value: function destroy() {
  5556. this._removeEventHandlers();
  5557. this._removeDropdown();
  5558. this.el.M_Autocomplete = undefined;
  5559. }
  5560. /**
  5561. * Setup Event Handlers
  5562. */
  5563. }, {
  5564. key: "_setupEventHandlers",
  5565. value: function _setupEventHandlers() {
  5566. this._handleInputBlurBound = this._handleInputBlur.bind(this);
  5567. this._handleInputKeyupAndFocusBound = this._handleInputKeyupAndFocus.bind(this);
  5568. this._handleInputKeydownBound = this._handleInputKeydown.bind(this);
  5569. this._handleInputClickBound = this._handleInputClick.bind(this);
  5570. this._handleContainerMousedownAndTouchstartBound = this._handleContainerMousedownAndTouchstart.bind(this);
  5571. this._handleContainerMouseupAndTouchendBound = this._handleContainerMouseupAndTouchend.bind(this);
  5572. this.el.addEventListener('blur', this._handleInputBlurBound);
  5573. this.el.addEventListener('keyup', this._handleInputKeyupAndFocusBound);
  5574. this.el.addEventListener('focus', this._handleInputKeyupAndFocusBound);
  5575. this.el.addEventListener('keydown', this._handleInputKeydownBound);
  5576. this.el.addEventListener('click', this._handleInputClickBound);
  5577. this.container.addEventListener('mousedown', this._handleContainerMousedownAndTouchstartBound);
  5578. this.container.addEventListener('mouseup', this._handleContainerMouseupAndTouchendBound);
  5579. if (typeof window.ontouchstart !== 'undefined') {
  5580. this.container.addEventListener('touchstart', this._handleContainerMousedownAndTouchstartBound);
  5581. this.container.addEventListener('touchend', this._handleContainerMouseupAndTouchendBound);
  5582. }
  5583. }
  5584. /**
  5585. * Remove Event Handlers
  5586. */
  5587. }, {
  5588. key: "_removeEventHandlers",
  5589. value: function _removeEventHandlers() {
  5590. this.el.removeEventListener('blur', this._handleInputBlurBound);
  5591. this.el.removeEventListener('keyup', this._handleInputKeyupAndFocusBound);
  5592. this.el.removeEventListener('focus', this._handleInputKeyupAndFocusBound);
  5593. this.el.removeEventListener('keydown', this._handleInputKeydownBound);
  5594. this.el.removeEventListener('click', this._handleInputClickBound);
  5595. this.container.removeEventListener('mousedown', this._handleContainerMousedownAndTouchstartBound);
  5596. this.container.removeEventListener('mouseup', this._handleContainerMouseupAndTouchendBound);
  5597. if (typeof window.ontouchstart !== 'undefined') {
  5598. this.container.removeEventListener('touchstart', this._handleContainerMousedownAndTouchstartBound);
  5599. this.container.removeEventListener('touchend', this._handleContainerMouseupAndTouchendBound);
  5600. }
  5601. }
  5602. /**
  5603. * Setup dropdown
  5604. */
  5605. }, {
  5606. key: "_setupDropdown",
  5607. value: function _setupDropdown() {
  5608. var _this38 = this;
  5609. this.container = document.createElement('ul');
  5610. this.container.id = "autocomplete-options-" + M.guid();
  5611. $(this.container).addClass('autocomplete-content dropdown-content');
  5612. this.$inputField.append(this.container);
  5613. this.el.setAttribute('data-target', this.container.id);
  5614. this.dropdown = M.Dropdown.init(this.el, {
  5615. autoFocus: false,
  5616. closeOnClick: false,
  5617. coverTrigger: false,
  5618. onItemClick: function (itemEl) {
  5619. _this38.selectOption($(itemEl));
  5620. }
  5621. });
  5622. // Sketchy removal of dropdown click handler
  5623. this.el.removeEventListener('click', this.dropdown._handleClickBound);
  5624. }
  5625. /**
  5626. * Remove dropdown
  5627. */
  5628. }, {
  5629. key: "_removeDropdown",
  5630. value: function _removeDropdown() {
  5631. this.container.parentNode.removeChild(this.container);
  5632. }
  5633. /**
  5634. * Handle Input Blur
  5635. */
  5636. }, {
  5637. key: "_handleInputBlur",
  5638. value: function _handleInputBlur() {
  5639. if (!this._mousedown) {
  5640. this.close();
  5641. this._resetAutocomplete();
  5642. }
  5643. }
  5644. /**
  5645. * Handle Input Keyup and Focus
  5646. * @param {Event} e
  5647. */
  5648. }, {
  5649. key: "_handleInputKeyupAndFocus",
  5650. value: function _handleInputKeyupAndFocus(e) {
  5651. if (e.type === 'keyup') {
  5652. Autocomplete._keydown = false;
  5653. }
  5654. this.count = 0;
  5655. var val = this.el.value.toLowerCase();
  5656. // Don't capture enter or arrow key usage.
  5657. if (e.keyCode === 13 || e.keyCode === 38 || e.keyCode === 40) {
  5658. return;
  5659. }
  5660. // Check if the input isn't empty
  5661. // Check if focus triggered by tab
  5662. if (this.oldVal !== val && (M.tabPressed || e.type !== 'focus')) {
  5663. this.open();
  5664. }
  5665. // Update oldVal
  5666. this.oldVal = val;
  5667. }
  5668. /**
  5669. * Handle Input Keydown
  5670. * @param {Event} e
  5671. */
  5672. }, {
  5673. key: "_handleInputKeydown",
  5674. value: function _handleInputKeydown(e) {
  5675. Autocomplete._keydown = true;
  5676. // Arrow keys and enter key usage
  5677. var keyCode = e.keyCode,
  5678. liElement = void 0,
  5679. numItems = $(this.container).children('li').length;
  5680. // select element on Enter
  5681. if (keyCode === M.keys.ENTER && this.activeIndex >= 0) {
  5682. liElement = $(this.container).children('li').eq(this.activeIndex);
  5683. if (liElement.length) {
  5684. this.selectOption(liElement);
  5685. e.preventDefault();
  5686. }
  5687. return;
  5688. }
  5689. // Capture up and down key
  5690. if (keyCode === M.keys.ARROW_UP || keyCode === M.keys.ARROW_DOWN) {
  5691. e.preventDefault();
  5692. if (keyCode === M.keys.ARROW_UP && this.activeIndex > 0) {
  5693. this.activeIndex--;
  5694. }
  5695. if (keyCode === M.keys.ARROW_DOWN && this.activeIndex < numItems - 1) {
  5696. this.activeIndex++;
  5697. }
  5698. this.$active.removeClass('active');
  5699. if (this.activeIndex >= 0) {
  5700. this.$active = $(this.container).children('li').eq(this.activeIndex);
  5701. this.$active.addClass('active');
  5702. }
  5703. }
  5704. }
  5705. /**
  5706. * Handle Input Click
  5707. * @param {Event} e
  5708. */
  5709. }, {
  5710. key: "_handleInputClick",
  5711. value: function _handleInputClick(e) {
  5712. this.open();
  5713. }
  5714. /**
  5715. * Handle Container Mousedown and Touchstart
  5716. * @param {Event} e
  5717. */
  5718. }, {
  5719. key: "_handleContainerMousedownAndTouchstart",
  5720. value: function _handleContainerMousedownAndTouchstart(e) {
  5721. this._mousedown = true;
  5722. }
  5723. /**
  5724. * Handle Container Mouseup and Touchend
  5725. * @param {Event} e
  5726. */
  5727. }, {
  5728. key: "_handleContainerMouseupAndTouchend",
  5729. value: function _handleContainerMouseupAndTouchend(e) {
  5730. this._mousedown = false;
  5731. }
  5732. /**
  5733. * Highlight partial match
  5734. */
  5735. }, {
  5736. key: "_highlight",
  5737. value: function _highlight(string, $el) {
  5738. var img = $el.find('img');
  5739. var matchStart = $el.text().toLowerCase().indexOf('' + string.toLowerCase() + ''),
  5740. matchEnd = matchStart + string.length - 1,
  5741. beforeMatch = $el.text().slice(0, matchStart),
  5742. matchText = $el.text().slice(matchStart, matchEnd + 1),
  5743. afterMatch = $el.text().slice(matchEnd + 1);
  5744. $el.html("<span>" + beforeMatch + "<span class='highlight'>" + matchText + "</span>" + afterMatch + "</span>");
  5745. if (img.length) {
  5746. $el.prepend(img);
  5747. }
  5748. }
  5749. /**
  5750. * Reset current element position
  5751. */
  5752. }, {
  5753. key: "_resetCurrentElement",
  5754. value: function _resetCurrentElement() {
  5755. this.activeIndex = -1;
  5756. this.$active.removeClass('active');
  5757. }
  5758. /**
  5759. * Reset autocomplete elements
  5760. */
  5761. }, {
  5762. key: "_resetAutocomplete",
  5763. value: function _resetAutocomplete() {
  5764. $(this.container).empty();
  5765. this._resetCurrentElement();
  5766. this.oldVal = null;
  5767. this.isOpen = false;
  5768. this._mousedown = false;
  5769. }
  5770. /**
  5771. * Select autocomplete option
  5772. * @param {Element} el Autocomplete option list item element
  5773. */
  5774. }, {
  5775. key: "selectOption",
  5776. value: function selectOption(el) {
  5777. var text = el.text().trim();
  5778. this.el.value = text;
  5779. this.$el.trigger('change');
  5780. this._resetAutocomplete();
  5781. this.close();
  5782. // Handle onAutocomplete callback.
  5783. if (typeof this.options.onAutocomplete === 'function') {
  5784. this.options.onAutocomplete.call(this, text);
  5785. }
  5786. }
  5787. /**
  5788. * Render dropdown content
  5789. * @param {Object} data data set
  5790. * @param {String} val current input value
  5791. */
  5792. }, {
  5793. key: "_renderDropdown",
  5794. value: function _renderDropdown(data, val) {
  5795. var _this39 = this;
  5796. this._resetAutocomplete();
  5797. var matchingData = [];
  5798. // Gather all matching data
  5799. for (var key in data) {
  5800. if (data.hasOwnProperty(key) && key.toLowerCase().indexOf(val) !== -1) {
  5801. // Break if past limit
  5802. if (this.count >= this.options.limit) {
  5803. break;
  5804. }
  5805. var entry = {
  5806. data: data[key],
  5807. key: key
  5808. };
  5809. matchingData.push(entry);
  5810. this.count++;
  5811. }
  5812. }
  5813. // Sort
  5814. if (this.options.sortFunction) {
  5815. var sortFunctionBound = function (a, b) {
  5816. return _this39.options.sortFunction(a.key.toLowerCase(), b.key.toLowerCase(), val.toLowerCase());
  5817. };
  5818. matchingData.sort(sortFunctionBound);
  5819. }
  5820. // Render
  5821. for (var i = 0; i < matchingData.length; i++) {
  5822. var _entry = matchingData[i];
  5823. var $autocompleteOption = $('<li></li>');
  5824. if (!!_entry.data) {
  5825. $autocompleteOption.append("<img src=\"" + _entry.data + "\" class=\"right circle\"><span>" + _entry.key + "</span>");
  5826. } else {
  5827. $autocompleteOption.append('<span>' + _entry.key + '</span>');
  5828. }
  5829. $(this.container).append($autocompleteOption);
  5830. this._highlight(val, $autocompleteOption);
  5831. }
  5832. }
  5833. /**
  5834. * Open Autocomplete Dropdown
  5835. */
  5836. }, {
  5837. key: "open",
  5838. value: function open() {
  5839. var val = this.el.value.toLowerCase();
  5840. this._resetAutocomplete();
  5841. if (val.length >= this.options.minLength) {
  5842. this.isOpen = true;
  5843. this._renderDropdown(this.options.data, val);
  5844. }
  5845. // Open dropdown
  5846. if (!this.dropdown.isOpen) {
  5847. this.dropdown.open();
  5848. } else {
  5849. // Recalculate dropdown when its already open
  5850. this.dropdown.recalculateDimensions();
  5851. }
  5852. }
  5853. /**
  5854. * Close Autocomplete Dropdown
  5855. */
  5856. }, {
  5857. key: "close",
  5858. value: function close() {
  5859. this.dropdown.close();
  5860. }
  5861. /**
  5862. * Update Data
  5863. * @param {Object} data
  5864. */
  5865. }, {
  5866. key: "updateData",
  5867. value: function updateData(data) {
  5868. var val = this.el.value.toLowerCase();
  5869. this.options.data = data;
  5870. if (this.isOpen) {
  5871. this._renderDropdown(data, val);
  5872. }
  5873. }
  5874. }], [{
  5875. key: "init",
  5876. value: function init(els, options) {
  5877. return _get(Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete), "init", this).call(this, this, els, options);
  5878. }
  5879. /**
  5880. * Get Instance
  5881. */
  5882. }, {
  5883. key: "getInstance",
  5884. value: function getInstance(el) {
  5885. var domElem = !!el.jquery ? el[0] : el;
  5886. return domElem.M_Autocomplete;
  5887. }
  5888. }, {
  5889. key: "defaults",
  5890. get: function () {
  5891. return _defaults;
  5892. }
  5893. }]);
  5894. return Autocomplete;
  5895. }(Component);
  5896. /**
  5897. * @static
  5898. * @memberof Autocomplete
  5899. */
  5900. Autocomplete._keydown = false;
  5901. M.Autocomplete = Autocomplete;
  5902. if (M.jQueryLoaded) {
  5903. M.initializeJqueryWrapper(Autocomplete, 'autocomplete', 'M_Autocomplete');
  5904. }
  5905. })(cash);
  5906. ;(function ($) {
  5907. // Function to update labels of text fields
  5908. M.updateTextFields = function () {
  5909. var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], input[type=date], input[type=time], textarea';
  5910. $(input_selector).each(function (element, index) {
  5911. var $this = $(this);
  5912. if (element.value.length > 0 || $(element).is(':focus') || element.autofocus || $this.attr('placeholder') !== null) {
  5913. $this.siblings('label').addClass('active');
  5914. } else if (element.validity) {
  5915. $this.siblings('label').toggleClass('active', element.validity.badInput === true);
  5916. } else {
  5917. $this.siblings('label').removeClass('active');
  5918. }
  5919. });
  5920. };
  5921. M.validate_field = function (object) {
  5922. var hasLength = object.attr('data-length') !== null;
  5923. var lenAttr = parseInt(object.attr('data-length'));
  5924. var len = object[0].value.length;
  5925. if (len === 0 && object[0].validity.badInput === false && !object.is(':required')) {
  5926. if (object.hasClass('validate')) {
  5927. object.removeClass('valid');
  5928. object.removeClass('invalid');
  5929. }
  5930. } else {
  5931. if (object.hasClass('validate')) {
  5932. // Check for character counter attributes
  5933. if (object.is(':valid') && hasLength && len <= lenAttr || object.is(':valid') && !hasLength) {
  5934. object.removeClass('invalid');
  5935. object.addClass('valid');
  5936. } else {
  5937. object.removeClass('valid');
  5938. object.addClass('invalid');
  5939. }
  5940. }
  5941. }
  5942. };
  5943. M.textareaAutoResize = function ($textarea) {
  5944. // Wrap if native element
  5945. if ($textarea instanceof Element) {
  5946. $textarea = $($textarea);
  5947. }
  5948. if (!$textarea.length) {
  5949. console.error('No textarea element found');
  5950. return;
  5951. }
  5952. // Textarea Auto Resize
  5953. var hiddenDiv = $('.hiddendiv').first();
  5954. if (!hiddenDiv.length) {
  5955. hiddenDiv = $('<div class="hiddendiv common"></div>');
  5956. $('body').append(hiddenDiv);
  5957. }
  5958. // Set font properties of hiddenDiv
  5959. var fontFamily = $textarea.css('font-family');
  5960. var fontSize = $textarea.css('font-size');
  5961. var lineHeight = $textarea.css('line-height');
  5962. // Firefox can't handle padding shorthand.
  5963. var paddingTop = $textarea.css('padding-top');
  5964. var paddingRight = $textarea.css('padding-right');
  5965. var paddingBottom = $textarea.css('padding-bottom');
  5966. var paddingLeft = $textarea.css('padding-left');
  5967. if (fontSize) {
  5968. hiddenDiv.css('font-size', fontSize);
  5969. }
  5970. if (fontFamily) {
  5971. hiddenDiv.css('font-family', fontFamily);
  5972. }
  5973. if (lineHeight) {
  5974. hiddenDiv.css('line-height', lineHeight);
  5975. }
  5976. if (paddingTop) {
  5977. hiddenDiv.css('padding-top', paddingTop);
  5978. }
  5979. if (paddingRight) {
  5980. hiddenDiv.css('padding-right', paddingRight);
  5981. }
  5982. if (paddingBottom) {
  5983. hiddenDiv.css('padding-bottom', paddingBottom);
  5984. }
  5985. if (paddingLeft) {
  5986. hiddenDiv.css('padding-left', paddingLeft);
  5987. }
  5988. // Set original-height, if none
  5989. if (!$textarea.data('original-height')) {
  5990. $textarea.data('original-height', $textarea.height());
  5991. }
  5992. if ($textarea.attr('wrap') === 'off') {
  5993. hiddenDiv.css('overflow-wrap', 'normal').css('white-space', 'pre');
  5994. }
  5995. hiddenDiv.text($textarea[0].value + '\n');
  5996. var content = hiddenDiv.html().replace(/\n/g, '<br>');
  5997. hiddenDiv.html(content);
  5998. // When textarea is hidden, width goes crazy.
  5999. // Approximate with half of window size
  6000. if ($textarea[0].offsetWidth > 0 && $textarea[0].offsetHeight > 0) {
  6001. hiddenDiv.css('width', $textarea.width() + 'px');
  6002. } else {
  6003. hiddenDiv.css('width', window.innerWidth / 2 + 'px');
  6004. }
  6005. /**
  6006. * Resize if the new height is greater than the
  6007. * original height of the textarea
  6008. */
  6009. if ($textarea.data('original-height') <= hiddenDiv.innerHeight()) {
  6010. $textarea.css('height', hiddenDiv.innerHeight() + 'px');
  6011. } else if ($textarea[0].value.length < $textarea.data('previous-length')) {
  6012. /**
  6013. * In case the new height is less than original height, it
  6014. * means the textarea has less text than before
  6015. * So we set the height to the original one
  6016. */
  6017. $textarea.css('height', $textarea.data('original-height') + 'px');
  6018. }
  6019. $textarea.data('previous-length', $textarea[0].value.length);
  6020. };
  6021. $(document).ready(function () {
  6022. // Text based inputs
  6023. var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], input[type=date], input[type=time], textarea';
  6024. // Add active if form auto complete
  6025. $(document).on('change', input_selector, function () {
  6026. if (this.value.length !== 0 || $(this).attr('placeholder') !== null) {
  6027. $(this).siblings('label').addClass('active');
  6028. }
  6029. M.validate_field($(this));
  6030. });
  6031. // Add active if input element has been pre-populated on document ready
  6032. $(document).ready(function () {
  6033. M.updateTextFields();
  6034. });
  6035. // HTML DOM FORM RESET handling
  6036. $(document).on('reset', function (e) {
  6037. var formReset = $(e.target);
  6038. if (formReset.is('form')) {
  6039. formReset.find(input_selector).removeClass('valid').removeClass('invalid');
  6040. formReset.find(input_selector).each(function (e) {
  6041. if (this.value.length) {
  6042. $(this).siblings('label').removeClass('active');
  6043. }
  6044. });
  6045. // Reset select (after native reset)
  6046. setTimeout(function () {
  6047. formReset.find('select').each(function () {
  6048. // check if initialized
  6049. if (this.M_FormSelect) {
  6050. $(this).trigger('change');
  6051. }
  6052. });
  6053. }, 0);
  6054. }
  6055. });
  6056. /**
  6057. * Add active when element has focus
  6058. * @param {Event} e
  6059. */
  6060. document.addEventListener('focus', function (e) {
  6061. if ($(e.target).is(input_selector)) {
  6062. $(e.target).siblings('label, .prefix').addClass('active');
  6063. }
  6064. }, true);
  6065. /**
  6066. * Remove active when element is blurred
  6067. * @param {Event} e
  6068. */
  6069. document.addEventListener('blur', function (e) {
  6070. var $inputElement = $(e.target);
  6071. if ($inputElement.is(input_selector)) {
  6072. var selector = '.prefix';
  6073. if ($inputElement[0].value.length === 0 && $inputElement[0].validity.badInput !== true && $inputElement.attr('placeholder') === null) {
  6074. selector += ', label';
  6075. }
  6076. $inputElement.siblings(selector).removeClass('active');
  6077. M.validate_field($inputElement);
  6078. }
  6079. }, true);
  6080. // Radio and Checkbox focus class
  6081. var radio_checkbox = 'input[type=radio], input[type=checkbox]';
  6082. $(document).on('keyup', radio_checkbox, function (e) {
  6083. // TAB, check if tabbing to radio or checkbox.
  6084. if (e.which === M.keys.TAB) {
  6085. $(this).addClass('tabbed');
  6086. var $this = $(this);
  6087. $this.one('blur', function (e) {
  6088. $(this).removeClass('tabbed');
  6089. });
  6090. return;
  6091. }
  6092. });
  6093. var text_area_selector = '.materialize-textarea';
  6094. $(text_area_selector).each(function () {
  6095. var $textarea = $(this);
  6096. /**
  6097. * Resize textarea on document load after storing
  6098. * the original height and the original length
  6099. */
  6100. $textarea.data('original-height', $textarea.height());
  6101. $textarea.data('previous-length', this.value.length);
  6102. M.textareaAutoResize($textarea);
  6103. });
  6104. $(document).on('keyup', text_area_selector, function () {
  6105. M.textareaAutoResize($(this));
  6106. });
  6107. $(document).on('keydown', text_area_selector, function () {
  6108. M.textareaAutoResize($(this));
  6109. });
  6110. // File Input Path
  6111. $(document).on('change', '.file-field input[type="file"]', function () {
  6112. var file_field = $(this).closest('.file-field');
  6113. var path_input = file_field.find('input.file-path');
  6114. var files = $(this)[0].files;
  6115. var file_names = [];
  6116. for (var i = 0; i < files.length; i++) {
  6117. file_names.push(files[i].name);
  6118. }
  6119. path_input[0].value = file_names.join(', ');
  6120. path_input.trigger('change');
  6121. });
  6122. }); // End of $(document).ready
  6123. })(cash);
  6124. ;(function ($, anim) {
  6125. 'use strict';
  6126. var _defaults = {
  6127. indicators: true,
  6128. height: 400,
  6129. duration: 500,
  6130. interval: 6000
  6131. };
  6132. /**
  6133. * @class
  6134. *
  6135. */
  6136. var Slider = function (_Component11) {
  6137. _inherits(Slider, _Component11);
  6138. /**
  6139. * Construct Slider instance and set up overlay
  6140. * @constructor
  6141. * @param {Element} el
  6142. * @param {Object} options
  6143. */
  6144. function Slider(el, options) {
  6145. _classCallCheck(this, Slider);
  6146. var _this40 = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, Slider, el, options));
  6147. _this40.el.M_Slider = _this40;
  6148. /**
  6149. * Options for the modal
  6150. * @member Slider#options
  6151. * @prop {Boolean} [indicators=true] - Show indicators
  6152. * @prop {Number} [height=400] - height of slider
  6153. * @prop {Number} [duration=500] - Length in ms of slide transition
  6154. * @prop {Number} [interval=6000] - Length in ms of slide interval
  6155. */
  6156. _this40.options = $.extend({}, Slider.defaults, options);
  6157. // setup
  6158. _this40.$slider = _this40.$el.find('.slides');
  6159. _this40.$slides = _this40.$slider.children('li');
  6160. _this40.activeIndex = _this40.$slides.filter(function (item) {
  6161. return $(item).hasClass('active');
  6162. }).first().index();
  6163. if (_this40.activeIndex != -1) {
  6164. _this40.$active = _this40.$slides.eq(_this40.activeIndex);
  6165. }
  6166. _this40._setSliderHeight();
  6167. // Set initial positions of captions
  6168. _this40.$slides.find('.caption').each(function (el) {
  6169. _this40._animateCaptionIn(el, 0);
  6170. });
  6171. // Move img src into background-image
  6172. _this40.$slides.find('img').each(function (el) {
  6173. var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
  6174. if ($(el).attr('src') !== placeholderBase64) {
  6175. $(el).css('background-image', 'url("' + $(el).attr('src') + '")');
  6176. $(el).attr('src', placeholderBase64);
  6177. }
  6178. });
  6179. _this40._setupIndicators();
  6180. // Show active slide
  6181. if (_this40.$active) {
  6182. _this40.$active.css('display', 'block');
  6183. } else {
  6184. _this40.$slides.first().addClass('active');
  6185. anim({
  6186. targets: _this40.$slides.first()[0],
  6187. opacity: 1,
  6188. duration: _this40.options.duration,
  6189. easing: 'easeOutQuad'
  6190. });
  6191. _this40.activeIndex = 0;
  6192. _this40.$active = _this40.$slides.eq(_this40.activeIndex);
  6193. // Update indicators
  6194. if (_this40.options.indicators) {
  6195. _this40.$indicators.eq(_this40.activeIndex).addClass('active');
  6196. }
  6197. }
  6198. // Adjust height to current slide
  6199. _this40.$active.find('img').each(function (el) {
  6200. anim({
  6201. targets: _this40.$active.find('.caption')[0],
  6202. opacity: 1,
  6203. translateX: 0,
  6204. translateY: 0,
  6205. duration: _this40.options.duration,
  6206. easing: 'easeOutQuad'
  6207. });
  6208. });
  6209. _this40._setupEventHandlers();
  6210. // auto scroll
  6211. _this40.start();
  6212. return _this40;
  6213. }
  6214. _createClass(Slider, [{
  6215. key: "destroy",
  6216. /**
  6217. * Teardown component
  6218. */
  6219. value: function destroy() {
  6220. this.pause();
  6221. this._removeIndicators();
  6222. this._removeEventHandlers();
  6223. this.el.M_Slider = undefined;
  6224. }
  6225. /**
  6226. * Setup Event Handlers
  6227. */
  6228. }, {
  6229. key: "_setupEventHandlers",
  6230. value: function _setupEventHandlers() {
  6231. var _this41 = this;
  6232. this._handleIntervalBound = this._handleInterval.bind(this);
  6233. this._handleIndicatorClickBound = this._handleIndicatorClick.bind(this);
  6234. if (this.options.indicators) {
  6235. this.$indicators.each(function (el) {
  6236. el.addEventListener('click', _this41._handleIndicatorClickBound);
  6237. });
  6238. }
  6239. }
  6240. /**
  6241. * Remove Event Handlers
  6242. */
  6243. }, {
  6244. key: "_removeEventHandlers",
  6245. value: function _removeEventHandlers() {
  6246. var _this42 = this;
  6247. if (this.options.indicators) {
  6248. this.$indicators.each(function (el) {
  6249. el.removeEventListener('click', _this42._handleIndicatorClickBound);
  6250. });
  6251. }
  6252. }
  6253. /**
  6254. * Handle indicator click
  6255. * @param {Event} e
  6256. */
  6257. }, {
  6258. key: "_handleIndicatorClick",
  6259. value: function _handleIndicatorClick(e) {
  6260. var currIndex = $(e.target).index();
  6261. this.set(currIndex);
  6262. }
  6263. /**
  6264. * Handle Interval
  6265. */
  6266. }, {
  6267. key: "_handleInterval",
  6268. value: function _handleInterval() {
  6269. var newActiveIndex = this.$slider.find('.active').index();
  6270. if (this.$slides.length === newActiveIndex + 1) newActiveIndex = 0;
  6271. // loop to start
  6272. else newActiveIndex += 1;
  6273. this.set(newActiveIndex);
  6274. }
  6275. /**
  6276. * Animate in caption
  6277. * @param {Element} caption
  6278. * @param {Number} duration
  6279. */
  6280. }, {
  6281. key: "_animateCaptionIn",
  6282. value: function _animateCaptionIn(caption, duration) {
  6283. var animOptions = {
  6284. targets: caption,
  6285. opacity: 0,
  6286. duration: duration,
  6287. easing: 'easeOutQuad'
  6288. };
  6289. if ($(caption).hasClass('center-align')) {
  6290. animOptions.translateY = -100;
  6291. } else if ($(caption).hasClass('right-align')) {
  6292. animOptions.translateX = 100;
  6293. } else if ($(caption).hasClass('left-align')) {
  6294. animOptions.translateX = -100;
  6295. }
  6296. anim(animOptions);
  6297. }
  6298. /**
  6299. * Set height of slider
  6300. */
  6301. }, {
  6302. key: "_setSliderHeight",
  6303. value: function _setSliderHeight() {
  6304. // If fullscreen, do nothing
  6305. if (!this.$el.hasClass('fullscreen')) {
  6306. if (this.options.indicators) {
  6307. // Add height if indicators are present
  6308. this.$el.css('height', this.options.height + 40 + 'px');
  6309. } else {
  6310. this.$el.css('height', this.options.height + 'px');
  6311. }
  6312. this.$slider.css('height', this.options.height + 'px');
  6313. }
  6314. }
  6315. /**
  6316. * Setup indicators
  6317. */
  6318. }, {
  6319. key: "_setupIndicators",
  6320. value: function _setupIndicators() {
  6321. var _this43 = this;
  6322. if (this.options.indicators) {
  6323. this.$indicators = $('<ul class="indicators"></ul>');
  6324. this.$slides.each(function (el, index) {
  6325. var $indicator = $('<li class="indicator-item"></li>');
  6326. _this43.$indicators.append($indicator[0]);
  6327. });
  6328. this.$el.append(this.$indicators[0]);
  6329. this.$indicators = this.$indicators.children('li.indicator-item');
  6330. }
  6331. }
  6332. /**
  6333. * Remove indicators
  6334. */
  6335. }, {
  6336. key: "_removeIndicators",
  6337. value: function _removeIndicators() {
  6338. this.$el.find('ul.indicators').remove();
  6339. }
  6340. /**
  6341. * Cycle to nth item
  6342. * @param {Number} index
  6343. */
  6344. }, {
  6345. key: "set",
  6346. value: function set(index) {
  6347. var _this44 = this;
  6348. // Wrap around indices.
  6349. if (index >= this.$slides.length) index = 0;else if (index < 0) index = this.$slides.length - 1;
  6350. // Only do if index changes
  6351. if (this.activeIndex != index) {
  6352. this.$active = this.$slides.eq(this.activeIndex);
  6353. var $caption = this.$active.find('.caption');
  6354. this.$active.removeClass('active');
  6355. anim({
  6356. targets: this.$active[0],
  6357. opacity: 0,
  6358. duration: this.options.duration,
  6359. easing: 'easeOutQuad',
  6360. complete: function () {
  6361. _this44.$slides.not('.active').each(function (el) {
  6362. anim({
  6363. targets: el,
  6364. opacity: 0,
  6365. translateX: 0,
  6366. translateY: 0,
  6367. duration: 0,
  6368. easing: 'easeOutQuad'
  6369. });
  6370. });
  6371. }
  6372. });
  6373. this._animateCaptionIn($caption[0], this.options.duration);
  6374. // Update indicators
  6375. if (this.options.indicators) {
  6376. this.$indicators.eq(this.activeIndex).removeClass('active');
  6377. this.$indicators.eq(index).addClass('active');
  6378. }
  6379. anim({
  6380. targets: this.$slides.eq(index)[0],
  6381. opacity: 1,
  6382. duration: this.options.duration,
  6383. easing: 'easeOutQuad'
  6384. });
  6385. anim({
  6386. targets: this.$slides.eq(index).find('.caption')[0],
  6387. opacity: 1,
  6388. translateX: 0,
  6389. translateY: 0,
  6390. duration: this.options.duration,
  6391. delay: this.options.duration,
  6392. easing: 'easeOutQuad'
  6393. });
  6394. this.$slides.eq(index).addClass('active');
  6395. this.activeIndex = index;
  6396. // Reset interval
  6397. this.start();
  6398. }
  6399. }
  6400. /**
  6401. * Pause slider interval
  6402. */
  6403. }, {
  6404. key: "pause",
  6405. value: function pause() {
  6406. clearInterval(this.interval);
  6407. }
  6408. /**
  6409. * Start slider interval
  6410. */
  6411. }, {
  6412. key: "start",
  6413. value: function start() {
  6414. clearInterval(this.interval);
  6415. this.interval = setInterval(this._handleIntervalBound, this.options.duration + this.options.interval);
  6416. }
  6417. /**
  6418. * Move to next slide
  6419. */
  6420. }, {
  6421. key: "next",
  6422. value: function next() {
  6423. var newIndex = this.activeIndex + 1;
  6424. // Wrap around indices.
  6425. if (newIndex >= this.$slides.length) newIndex = 0;else if (newIndex < 0) newIndex = this.$slides.length - 1;
  6426. this.set(newIndex);
  6427. }
  6428. /**
  6429. * Move to previous slide
  6430. */
  6431. }, {
  6432. key: "prev",
  6433. value: function prev() {
  6434. var newIndex = this.activeIndex - 1;
  6435. // Wrap around indices.
  6436. if (newIndex >= this.$slides.length) newIndex = 0;else if (newIndex < 0) newIndex = this.$slides.length - 1;
  6437. this.set(newIndex);
  6438. }
  6439. }], [{
  6440. key: "init",
  6441. value: function init(els, options) {
  6442. return _get(Slider.__proto__ || Object.getPrototypeOf(Slider), "init", this).call(this, this, els, options);
  6443. }
  6444. /**
  6445. * Get Instance
  6446. */
  6447. }, {
  6448. key: "getInstance",
  6449. value: function getInstance(el) {
  6450. var domElem = !!el.jquery ? el[0] : el;
  6451. return domElem.M_Slider;
  6452. }
  6453. }, {
  6454. key: "defaults",
  6455. get: function () {
  6456. return _defaults;
  6457. }
  6458. }]);
  6459. return Slider;
  6460. }(Component);
  6461. M.Slider = Slider;
  6462. if (M.jQueryLoaded) {
  6463. M.initializeJqueryWrapper(Slider, 'slider', 'M_Slider');
  6464. }
  6465. })(cash, M.anime);
  6466. ;(function ($, anim) {
  6467. $(document).on('click', '.card', function (e) {
  6468. if ($(this).children('.card-reveal').length) {
  6469. var $card = $(e.target).closest('.card');
  6470. if ($card.data('initialOverflow') === undefined) {
  6471. $card.data('initialOverflow', $card.css('overflow') === undefined ? '' : $card.css('overflow'));
  6472. }
  6473. var $cardReveal = $(this).find('.card-reveal');
  6474. if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) {
  6475. // Make Reveal animate down and display none
  6476. anim({
  6477. targets: $cardReveal[0],
  6478. translateY: 0,
  6479. duration: 225,
  6480. easing: 'easeInOutQuad',
  6481. complete: function (anim) {
  6482. var el = anim.animatables[0].target;
  6483. $(el).css({ display: 'none' });
  6484. $card.css('overflow', $card.data('initialOverflow'));
  6485. }
  6486. });
  6487. } else if ($(e.target).is($('.card .activator')) || $(e.target).is($('.card .activator i'))) {
  6488. $card.css('overflow', 'hidden');
  6489. $cardReveal.css({ display: 'block' });
  6490. anim({
  6491. targets: $cardReveal[0],
  6492. translateY: '-100%',
  6493. duration: 300,
  6494. easing: 'easeInOutQuad'
  6495. });
  6496. }
  6497. }
  6498. });
  6499. })(cash, M.anime);
  6500. ;(function ($) {
  6501. 'use strict';
  6502. var _defaults = {
  6503. data: [],
  6504. placeholder: '',
  6505. secondaryPlaceholder: '',
  6506. autocompleteOptions: {},
  6507. limit: Infinity,
  6508. onChipAdd: null,
  6509. onChipSelect: null,
  6510. onChipDelete: null
  6511. };
  6512. /**
  6513. * @typedef {Object} chip
  6514. * @property {String} tag chip tag string
  6515. * @property {String} [image] chip avatar image string
  6516. */
  6517. /**
  6518. * @class
  6519. *
  6520. */
  6521. var Chips = function (_Component12) {
  6522. _inherits(Chips, _Component12);
  6523. /**
  6524. * Construct Chips instance and set up overlay
  6525. * @constructor
  6526. * @param {Element} el
  6527. * @param {Object} options
  6528. */
  6529. function Chips(el, options) {
  6530. _classCallCheck(this, Chips);
  6531. var _this45 = _possibleConstructorReturn(this, (Chips.__proto__ || Object.getPrototypeOf(Chips)).call(this, Chips, el, options));
  6532. _this45.el.M_Chips = _this45;
  6533. /**
  6534. * Options for the modal
  6535. * @member Chips#options
  6536. * @prop {Array} data
  6537. * @prop {String} placeholder
  6538. * @prop {String} secondaryPlaceholder
  6539. * @prop {Object} autocompleteOptions
  6540. */
  6541. _this45.options = $.extend({}, Chips.defaults, options);
  6542. _this45.$el.addClass('chips input-field');
  6543. _this45.chipsData = [];
  6544. _this45.$chips = $();
  6545. _this45._setupInput();
  6546. _this45.hasAutocomplete = Object.keys(_this45.options.autocompleteOptions).length > 0;
  6547. // Set input id
  6548. if (!_this45.$input.attr('id')) {
  6549. _this45.$input.attr('id', M.guid());
  6550. }
  6551. // Render initial chips
  6552. if (_this45.options.data.length) {
  6553. _this45.chipsData = _this45.options.data;
  6554. _this45._renderChips(_this45.chipsData);
  6555. }
  6556. // Setup autocomplete if needed
  6557. if (_this45.hasAutocomplete) {
  6558. _this45._setupAutocomplete();
  6559. }
  6560. _this45._setPlaceholder();
  6561. _this45._setupLabel();
  6562. _this45._setupEventHandlers();
  6563. return _this45;
  6564. }
  6565. _createClass(Chips, [{
  6566. key: "getData",
  6567. /**
  6568. * Get Chips Data
  6569. */
  6570. value: function getData() {
  6571. return this.chipsData;
  6572. }
  6573. /**
  6574. * Teardown component
  6575. */
  6576. }, {
  6577. key: "destroy",
  6578. value: function destroy() {
  6579. this._removeEventHandlers();
  6580. this.$chips.remove();
  6581. this.el.M_Chips = undefined;
  6582. }
  6583. /**
  6584. * Setup Event Handlers
  6585. */
  6586. }, {
  6587. key: "_setupEventHandlers",
  6588. value: function _setupEventHandlers() {
  6589. this._handleChipClickBound = this._handleChipClick.bind(this);
  6590. this._handleInputKeydownBound = this._handleInputKeydown.bind(this);
  6591. this._handleInputFocusBound = this._handleInputFocus.bind(this);
  6592. this._handleInputBlurBound = this._handleInputBlur.bind(this);
  6593. this.el.addEventListener('click', this._handleChipClickBound);
  6594. document.addEventListener('keydown', Chips._handleChipsKeydown);
  6595. document.addEventListener('keyup', Chips._handleChipsKeyup);
  6596. this.el.addEventListener('blur', Chips._handleChipsBlur, true);
  6597. this.$input[0].addEventListener('focus', this._handleInputFocusBound);
  6598. this.$input[0].addEventListener('blur', this._handleInputBlurBound);
  6599. this.$input[0].addEventListener('keydown', this._handleInputKeydownBound);
  6600. }
  6601. /**
  6602. * Remove Event Handlers
  6603. */
  6604. }, {
  6605. key: "_removeEventHandlers",
  6606. value: function _removeEventHandlers() {
  6607. this.el.removeEventListener('click', this._handleChipClickBound);
  6608. document.removeEventListener('keydown', Chips._handleChipsKeydown);
  6609. document.removeEventListener('keyup', Chips._handleChipsKeyup);
  6610. this.el.removeEventListener('blur', Chips._handleChipsBlur, true);
  6611. this.$input[0].removeEventListener('focus', this._handleInputFocusBound);
  6612. this.$input[0].removeEventListener('blur', this._handleInputBlurBound);
  6613. this.$input[0].removeEventListener('keydown', this._handleInputKeydownBound);
  6614. }
  6615. /**
  6616. * Handle Chip Click
  6617. * @param {Event} e
  6618. */
  6619. }, {
  6620. key: "_handleChipClick",
  6621. value: function _handleChipClick(e) {
  6622. var $chip = $(e.target).closest('.chip');
  6623. var clickedClose = $(e.target).is('.close');
  6624. if ($chip.length) {
  6625. var index = $chip.index();
  6626. if (clickedClose) {
  6627. // delete chip
  6628. this.deleteChip(index);
  6629. this.$input[0].focus();
  6630. } else {
  6631. // select chip
  6632. this.selectChip(index);
  6633. }
  6634. // Default handle click to focus on input
  6635. } else {
  6636. this.$input[0].focus();
  6637. }
  6638. }
  6639. /**
  6640. * Handle Chips Keydown
  6641. * @param {Event} e
  6642. */
  6643. }, {
  6644. key: "_handleInputFocus",
  6645. /**
  6646. * Handle Input Focus
  6647. */
  6648. value: function _handleInputFocus() {
  6649. this.$el.addClass('focus');
  6650. }
  6651. /**
  6652. * Handle Input Blur
  6653. */
  6654. }, {
  6655. key: "_handleInputBlur",
  6656. value: function _handleInputBlur() {
  6657. this.$el.removeClass('focus');
  6658. }
  6659. /**
  6660. * Handle Input Keydown
  6661. * @param {Event} e
  6662. */
  6663. }, {
  6664. key: "_handleInputKeydown",
  6665. value: function _handleInputKeydown(e) {
  6666. Chips._keydown = true;
  6667. // enter
  6668. if (e.keyCode === 13) {
  6669. // Override enter if autocompleting.
  6670. if (this.hasAutocomplete && this.autocomplete && this.autocomplete.isOpen) {
  6671. return;
  6672. }
  6673. e.preventDefault();
  6674. this.addChip({
  6675. tag: this.$input[0].value
  6676. });
  6677. this.$input[0].value = '';
  6678. // delete or left
  6679. } else if ((e.keyCode === 8 || e.keyCode === 37) && this.$input[0].value === '' && this.chipsData.length) {
  6680. e.preventDefault();
  6681. this.selectChip(this.chipsData.length - 1);
  6682. }
  6683. }
  6684. /**
  6685. * Render Chip
  6686. * @param {chip} chip
  6687. * @return {Element}
  6688. */
  6689. }, {
  6690. key: "_renderChip",
  6691. value: function _renderChip(chip) {
  6692. if (!chip.tag) {
  6693. return;
  6694. }
  6695. var renderedChip = document.createElement('div');
  6696. var closeIcon = document.createElement('i');
  6697. renderedChip.classList.add('chip');
  6698. renderedChip.textContent = chip.tag;
  6699. renderedChip.setAttribute('tabindex', 0);
  6700. $(closeIcon).addClass('material-icons close');
  6701. closeIcon.textContent = 'close';
  6702. // attach image if needed
  6703. if (chip.image) {
  6704. var img = document.createElement('img');
  6705. img.setAttribute('src', chip.image);
  6706. renderedChip.insertBefore(img, renderedChip.firstChild);
  6707. }
  6708. renderedChip.appendChild(closeIcon);
  6709. return renderedChip;
  6710. }
  6711. /**
  6712. * Render Chips
  6713. */
  6714. }, {
  6715. key: "_renderChips",
  6716. value: function _renderChips() {
  6717. this.$chips.remove();
  6718. for (var i = 0; i < this.chipsData.length; i++) {
  6719. var chipEl = this._renderChip(this.chipsData[i]);
  6720. this.$el.append(chipEl);
  6721. this.$chips.add(chipEl);
  6722. }
  6723. // move input to end
  6724. this.$el.append(this.$input[0]);
  6725. }
  6726. /**
  6727. * Setup Autocomplete
  6728. */
  6729. }, {
  6730. key: "_setupAutocomplete",
  6731. value: function _setupAutocomplete() {
  6732. var _this46 = this;
  6733. this.options.autocompleteOptions.onAutocomplete = function (val) {
  6734. _this46.addChip({
  6735. tag: val
  6736. });
  6737. _this46.$input[0].value = '';
  6738. _this46.$input[0].focus();
  6739. };
  6740. this.autocomplete = M.Autocomplete.init(this.$input[0], this.options.autocompleteOptions);
  6741. }
  6742. /**
  6743. * Setup Input
  6744. */
  6745. }, {
  6746. key: "_setupInput",
  6747. value: function _setupInput() {
  6748. this.$input = this.$el.find('input');
  6749. if (!this.$input.length) {
  6750. this.$input = $('<input></input>');
  6751. this.$el.append(this.$input);
  6752. }
  6753. this.$input.addClass('input');
  6754. }
  6755. /**
  6756. * Setup Label
  6757. */
  6758. }, {
  6759. key: "_setupLabel",
  6760. value: function _setupLabel() {
  6761. this.$label = this.$el.find('label');
  6762. if (this.$label.length) {
  6763. this.$label.setAttribute('for', this.$input.attr('id'));
  6764. }
  6765. }
  6766. /**
  6767. * Set placeholder
  6768. */
  6769. }, {
  6770. key: "_setPlaceholder",
  6771. value: function _setPlaceholder() {
  6772. if (this.chipsData !== undefined && !this.chipsData.length && this.options.placeholder) {
  6773. $(this.$input).prop('placeholder', this.options.placeholder);
  6774. } else if ((this.chipsData === undefined || !!this.chipsData.length) && this.options.secondaryPlaceholder) {
  6775. $(this.$input).prop('placeholder', this.options.secondaryPlaceholder);
  6776. }
  6777. }
  6778. /**
  6779. * Check if chip is valid
  6780. * @param {chip} chip
  6781. */
  6782. }, {
  6783. key: "_isValid",
  6784. value: function _isValid(chip) {
  6785. if (chip.hasOwnProperty('tag') && chip.tag !== '') {
  6786. var exists = false;
  6787. for (var i = 0; i < this.chipsData.length; i++) {
  6788. if (this.chipsData[i].tag === chip.tag) {
  6789. exists = true;
  6790. break;
  6791. }
  6792. }
  6793. return !exists;
  6794. }
  6795. return false;
  6796. }
  6797. /**
  6798. * Add chip
  6799. * @param {chip} chip
  6800. */
  6801. }, {
  6802. key: "addChip",
  6803. value: function addChip(chip) {
  6804. if (!this._isValid(chip) || this.chipsData.length >= this.options.limit) {
  6805. return;
  6806. }
  6807. var renderedChip = this._renderChip(chip);
  6808. this.$chips.add(renderedChip);
  6809. this.chipsData.push(chip);
  6810. $(this.$input).before(renderedChip);
  6811. this._setPlaceholder();
  6812. // fire chipAdd callback
  6813. if (typeof this.options.onChipAdd === 'function') {
  6814. this.options.onChipAdd.call(this, this.$el, renderedChip);
  6815. }
  6816. }
  6817. /**
  6818. * Delete chip
  6819. * @param {Number} chip
  6820. */
  6821. }, {
  6822. key: "deleteChip",
  6823. value: function deleteChip(chipIndex) {
  6824. var $chip = this.$chips.eq(chipIndex);
  6825. this.$chips.eq(chipIndex).remove();
  6826. this.$chips = this.$chips.filter(function (el) {
  6827. return $(el).index() >= 0;
  6828. });
  6829. this.chipsData.splice(chipIndex, 1);
  6830. this._setPlaceholder();
  6831. // fire chipDelete callback
  6832. if (typeof this.options.onChipDelete === 'function') {
  6833. this.options.onChipDelete.call(this, this.$el, $chip[0]);
  6834. }
  6835. }
  6836. /**
  6837. * Select chip
  6838. * @param {Number} chip
  6839. */
  6840. }, {
  6841. key: "selectChip",
  6842. value: function selectChip(chipIndex) {
  6843. var $chip = this.$chips.eq(chipIndex);
  6844. this._selectedChip = $chip;
  6845. $chip[0].focus();
  6846. // fire chipSelect callback
  6847. if (typeof this.options.onChipSelect === 'function') {
  6848. this.options.onChipSelect.call(this, this.$el, $chip[0]);
  6849. }
  6850. }
  6851. }], [{
  6852. key: "init",
  6853. value: function init(els, options) {
  6854. return _get(Chips.__proto__ || Object.getPrototypeOf(Chips), "init", this).call(this, this, els, options);
  6855. }
  6856. /**
  6857. * Get Instance
  6858. */
  6859. }, {
  6860. key: "getInstance",
  6861. value: function getInstance(el) {
  6862. var domElem = !!el.jquery ? el[0] : el;
  6863. return domElem.M_Chips;
  6864. }
  6865. }, {
  6866. key: "_handleChipsKeydown",
  6867. value: function _handleChipsKeydown(e) {
  6868. Chips._keydown = true;
  6869. var $chips = $(e.target).closest('.chips');
  6870. var chipsKeydown = e.target && $chips.length;
  6871. // Don't handle keydown inputs on input and textarea
  6872. if ($(e.target).is('input, textarea') || !chipsKeydown) {
  6873. return;
  6874. }
  6875. var currChips = $chips[0].M_Chips;
  6876. // backspace and delete
  6877. if (e.keyCode === 8 || e.keyCode === 46) {
  6878. e.preventDefault();
  6879. var selectIndex = currChips.chipsData.length;
  6880. if (currChips._selectedChip) {
  6881. var index = currChips._selectedChip.index();
  6882. currChips.deleteChip(index);
  6883. currChips._selectedChip = null;
  6884. // Make sure selectIndex doesn't go negative
  6885. selectIndex = Math.max(index - 1, 0);
  6886. }
  6887. if (currChips.chipsData.length) {
  6888. currChips.selectChip(selectIndex);
  6889. }
  6890. // left arrow key
  6891. } else if (e.keyCode === 37) {
  6892. if (currChips._selectedChip) {
  6893. var _selectIndex = currChips._selectedChip.index() - 1;
  6894. if (_selectIndex < 0) {
  6895. return;
  6896. }
  6897. currChips.selectChip(_selectIndex);
  6898. }
  6899. // right arrow key
  6900. } else if (e.keyCode === 39) {
  6901. if (currChips._selectedChip) {
  6902. var _selectIndex2 = currChips._selectedChip.index() + 1;
  6903. if (_selectIndex2 >= currChips.chipsData.length) {
  6904. currChips.$input[0].focus();
  6905. } else {
  6906. currChips.selectChip(_selectIndex2);
  6907. }
  6908. }
  6909. }
  6910. }
  6911. /**
  6912. * Handle Chips Keyup
  6913. * @param {Event} e
  6914. */
  6915. }, {
  6916. key: "_handleChipsKeyup",
  6917. value: function _handleChipsKeyup(e) {
  6918. Chips._keydown = false;
  6919. }
  6920. /**
  6921. * Handle Chips Blur
  6922. * @param {Event} e
  6923. */
  6924. }, {
  6925. key: "_handleChipsBlur",
  6926. value: function _handleChipsBlur(e) {
  6927. if (!Chips._keydown) {
  6928. var $chips = $(e.target).closest('.chips');
  6929. var currChips = $chips[0].M_Chips;
  6930. currChips._selectedChip = null;
  6931. }
  6932. }
  6933. }, {
  6934. key: "defaults",
  6935. get: function () {
  6936. return _defaults;
  6937. }
  6938. }]);
  6939. return Chips;
  6940. }(Component);
  6941. /**
  6942. * @static
  6943. * @memberof Chips
  6944. */
  6945. Chips._keydown = false;
  6946. M.Chips = Chips;
  6947. if (M.jQueryLoaded) {
  6948. M.initializeJqueryWrapper(Chips, 'chips', 'M_Chips');
  6949. }
  6950. $(document).ready(function () {
  6951. // Handle removal of static chips.
  6952. $(document.body).on('click', '.chip .close', function () {
  6953. var $chips = $(this).closest('.chips');
  6954. if ($chips.length && $chips[0].M_Chips) {
  6955. return;
  6956. }
  6957. $(this).closest('.chip').remove();
  6958. });
  6959. });
  6960. })(cash);
  6961. ;(function ($) {
  6962. 'use strict';
  6963. var _defaults = {
  6964. top: 0,
  6965. bottom: Infinity,
  6966. offset: 0,
  6967. onPositionChange: null
  6968. };
  6969. /**
  6970. * @class
  6971. *
  6972. */
  6973. var Pushpin = function (_Component13) {
  6974. _inherits(Pushpin, _Component13);
  6975. /**
  6976. * Construct Pushpin instance
  6977. * @constructor
  6978. * @param {Element} el
  6979. * @param {Object} options
  6980. */
  6981. function Pushpin(el, options) {
  6982. _classCallCheck(this, Pushpin);
  6983. var _this47 = _possibleConstructorReturn(this, (Pushpin.__proto__ || Object.getPrototypeOf(Pushpin)).call(this, Pushpin, el, options));
  6984. _this47.el.M_Pushpin = _this47;
  6985. /**
  6986. * Options for the modal
  6987. * @member Pushpin#options
  6988. */
  6989. _this47.options = $.extend({}, Pushpin.defaults, options);
  6990. _this47.originalOffset = _this47.el.offsetTop;
  6991. Pushpin._pushpins.push(_this47);
  6992. _this47._setupEventHandlers();
  6993. _this47._updatePosition();
  6994. return _this47;
  6995. }
  6996. _createClass(Pushpin, [{
  6997. key: "destroy",
  6998. /**
  6999. * Teardown component
  7000. */
  7001. value: function destroy() {
  7002. this.el.style.top = null;
  7003. this._removePinClasses();
  7004. this._removeEventHandlers();
  7005. // Remove pushpin Inst
  7006. var index = Pushpin._pushpins.indexOf(this);
  7007. Pushpin._pushpins.splice(index, 1);
  7008. }
  7009. }, {
  7010. key: "_setupEventHandlers",
  7011. value: function _setupEventHandlers() {
  7012. document.addEventListener('scroll', Pushpin._updateElements);
  7013. }
  7014. }, {
  7015. key: "_removeEventHandlers",
  7016. value: function _removeEventHandlers() {
  7017. document.removeEventListener('scroll', Pushpin._updateElements);
  7018. }
  7019. }, {
  7020. key: "_updatePosition",
  7021. value: function _updatePosition() {
  7022. var scrolled = M.getDocumentScrollTop() + this.options.offset;
  7023. if (this.options.top <= scrolled && this.options.bottom >= scrolled && !this.el.classList.contains('pinned')) {
  7024. this._removePinClasses();
  7025. this.el.style.top = this.options.offset + "px";
  7026. this.el.classList.add('pinned');
  7027. // onPositionChange callback
  7028. if (typeof this.options.onPositionChange === 'function') {
  7029. this.options.onPositionChange.call(this, 'pinned');
  7030. }
  7031. }
  7032. // Add pin-top (when scrolled position is above top)
  7033. if (scrolled < this.options.top && !this.el.classList.contains('pin-top')) {
  7034. this._removePinClasses();
  7035. this.el.style.top = 0;
  7036. this.el.classList.add('pin-top');
  7037. // onPositionChange callback
  7038. if (typeof this.options.onPositionChange === 'function') {
  7039. this.options.onPositionChange.call(this, 'pin-top');
  7040. }
  7041. }
  7042. // Add pin-bottom (when scrolled position is below bottom)
  7043. if (scrolled > this.options.bottom && !this.el.classList.contains('pin-bottom')) {
  7044. this._removePinClasses();
  7045. this.el.classList.add('pin-bottom');
  7046. this.el.style.top = this.options.bottom - this.originalOffset + "px";
  7047. // onPositionChange callback
  7048. if (typeof this.options.onPositionChange === 'function') {
  7049. this.options.onPositionChange.call(this, 'pin-bottom');
  7050. }
  7051. }
  7052. }
  7053. }, {
  7054. key: "_removePinClasses",
  7055. value: function _removePinClasses() {
  7056. // IE 11 bug (can't remove multiple classes in one line)
  7057. this.el.classList.remove('pin-top');
  7058. this.el.classList.remove('pinned');
  7059. this.el.classList.remove('pin-bottom');
  7060. }
  7061. }], [{
  7062. key: "init",
  7063. value: function init(els, options) {
  7064. return _get(Pushpin.__proto__ || Object.getPrototypeOf(Pushpin), "init", this).call(this, this, els, options);
  7065. }
  7066. /**
  7067. * Get Instance
  7068. */
  7069. }, {
  7070. key: "getInstance",
  7071. value: function getInstance(el) {
  7072. var domElem = !!el.jquery ? el[0] : el;
  7073. return domElem.M_Pushpin;
  7074. }
  7075. }, {
  7076. key: "_updateElements",
  7077. value: function _updateElements() {
  7078. for (var elIndex in Pushpin._pushpins) {
  7079. var pInstance = Pushpin._pushpins[elIndex];
  7080. pInstance._updatePosition();
  7081. }
  7082. }
  7083. }, {
  7084. key: "defaults",
  7085. get: function () {
  7086. return _defaults;
  7087. }
  7088. }]);
  7089. return Pushpin;
  7090. }(Component);
  7091. /**
  7092. * @static
  7093. * @memberof Pushpin
  7094. */
  7095. Pushpin._pushpins = [];
  7096. M.Pushpin = Pushpin;
  7097. if (M.jQueryLoaded) {
  7098. M.initializeJqueryWrapper(Pushpin, 'pushpin', 'M_Pushpin');
  7099. }
  7100. })(cash);
  7101. ;(function ($, anim) {
  7102. 'use strict';
  7103. var _defaults = {
  7104. direction: 'top',
  7105. hoverEnabled: true,
  7106. toolbarEnabled: false
  7107. };
  7108. $.fn.reverse = [].reverse;
  7109. /**
  7110. * @class
  7111. *
  7112. */
  7113. var FloatingActionButton = function (_Component14) {
  7114. _inherits(FloatingActionButton, _Component14);
  7115. /**
  7116. * Construct FloatingActionButton instance
  7117. * @constructor
  7118. * @param {Element} el
  7119. * @param {Object} options
  7120. */
  7121. function FloatingActionButton(el, options) {
  7122. _classCallCheck(this, FloatingActionButton);
  7123. var _this48 = _possibleConstructorReturn(this, (FloatingActionButton.__proto__ || Object.getPrototypeOf(FloatingActionButton)).call(this, FloatingActionButton, el, options));
  7124. _this48.el.M_FloatingActionButton = _this48;
  7125. /**
  7126. * Options for the fab
  7127. * @member FloatingActionButton#options
  7128. * @prop {Boolean} [direction] - Direction fab menu opens
  7129. * @prop {Boolean} [hoverEnabled=true] - Enable hover vs click
  7130. * @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition
  7131. */
  7132. _this48.options = $.extend({}, FloatingActionButton.defaults, options);
  7133. _this48.isOpen = false;
  7134. _this48.$anchor = _this48.$el.children('a').first();
  7135. _this48.$menu = _this48.$el.children('ul').first();
  7136. _this48.$floatingBtns = _this48.$el.find('ul .btn-floating');
  7137. _this48.$floatingBtnsReverse = _this48.$el.find('ul .btn-floating').reverse();
  7138. _this48.offsetY = 0;
  7139. _this48.offsetX = 0;
  7140. _this48.$el.addClass("direction-" + _this48.options.direction);
  7141. if (_this48.options.direction === 'top') {
  7142. _this48.offsetY = 40;
  7143. } else if (_this48.options.direction === 'right') {
  7144. _this48.offsetX = -40;
  7145. } else if (_this48.options.direction === 'bottom') {
  7146. _this48.offsetY = -40;
  7147. } else {
  7148. _this48.offsetX = 40;
  7149. }
  7150. _this48._setupEventHandlers();
  7151. return _this48;
  7152. }
  7153. _createClass(FloatingActionButton, [{
  7154. key: "destroy",
  7155. /**
  7156. * Teardown component
  7157. */
  7158. value: function destroy() {
  7159. this._removeEventHandlers();
  7160. this.el.M_FloatingActionButton = undefined;
  7161. }
  7162. /**
  7163. * Setup Event Handlers
  7164. */
  7165. }, {
  7166. key: "_setupEventHandlers",
  7167. value: function _setupEventHandlers() {
  7168. this._handleFABClickBound = this._handleFABClick.bind(this);
  7169. this._handleOpenBound = this.open.bind(this);
  7170. this._handleCloseBound = this.close.bind(this);
  7171. if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
  7172. this.el.addEventListener('mouseenter', this._handleOpenBound);
  7173. this.el.addEventListener('mouseleave', this._handleCloseBound);
  7174. } else {
  7175. this.el.addEventListener('click', this._handleFABClickBound);
  7176. }
  7177. }
  7178. /**
  7179. * Remove Event Handlers
  7180. */
  7181. }, {
  7182. key: "_removeEventHandlers",
  7183. value: function _removeEventHandlers() {
  7184. if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
  7185. this.el.removeEventListener('mouseenter', this._handleOpenBound);
  7186. this.el.removeEventListener('mouseleave', this._handleCloseBound);
  7187. } else {
  7188. this.el.removeEventListener('click', this._handleFABClickBound);
  7189. }
  7190. }
  7191. /**
  7192. * Handle FAB Click
  7193. */
  7194. }, {
  7195. key: "_handleFABClick",
  7196. value: function _handleFABClick() {
  7197. if (this.isOpen) {
  7198. this.close();
  7199. } else {
  7200. this.open();
  7201. }
  7202. }
  7203. /**
  7204. * Handle Document Click
  7205. * @param {Event} e
  7206. */
  7207. }, {
  7208. key: "_handleDocumentClick",
  7209. value: function _handleDocumentClick(e) {
  7210. if (!$(e.target).closest(this.$menu).length) {
  7211. this.close();
  7212. }
  7213. }
  7214. /**
  7215. * Open FAB
  7216. */
  7217. }, {
  7218. key: "open",
  7219. value: function open() {
  7220. if (this.isOpen) {
  7221. return;
  7222. }
  7223. if (this.options.toolbarEnabled) {
  7224. this._animateInToolbar();
  7225. } else {
  7226. this._animateInFAB();
  7227. }
  7228. this.isOpen = true;
  7229. }
  7230. /**
  7231. * Close FAB
  7232. */
  7233. }, {
  7234. key: "close",
  7235. value: function close() {
  7236. if (!this.isOpen) {
  7237. return;
  7238. }
  7239. if (this.options.toolbarEnabled) {
  7240. window.removeEventListener('scroll', this._handleCloseBound, true);
  7241. document.body.removeEventListener('click', this._handleDocumentClickBound, true);
  7242. this._animateOutToolbar();
  7243. } else {
  7244. this._animateOutFAB();
  7245. }
  7246. this.isOpen = false;
  7247. }
  7248. /**
  7249. * Classic FAB Menu open
  7250. */
  7251. }, {
  7252. key: "_animateInFAB",
  7253. value: function _animateInFAB() {
  7254. var _this49 = this;
  7255. this.$el.addClass('active');
  7256. var time = 0;
  7257. this.$floatingBtnsReverse.each(function (el) {
  7258. anim({
  7259. targets: el,
  7260. opacity: 1,
  7261. scale: [0.4, 1],
  7262. translateY: [_this49.offsetY, 0],
  7263. translateX: [_this49.offsetX, 0],
  7264. duration: 275,
  7265. delay: time,
  7266. easing: 'easeInOutQuad'
  7267. });
  7268. time += 40;
  7269. });
  7270. }
  7271. /**
  7272. * Classic FAB Menu close
  7273. */
  7274. }, {
  7275. key: "_animateOutFAB",
  7276. value: function _animateOutFAB() {
  7277. var _this50 = this;
  7278. this.$floatingBtnsReverse.each(function (el) {
  7279. anim.remove(el);
  7280. anim({
  7281. targets: el,
  7282. opacity: 0,
  7283. scale: 0.4,
  7284. translateY: _this50.offsetY,
  7285. translateX: _this50.offsetX,
  7286. duration: 175,
  7287. easing: 'easeOutQuad',
  7288. complete: function () {
  7289. _this50.$el.removeClass('active');
  7290. }
  7291. });
  7292. });
  7293. }
  7294. /**
  7295. * Toolbar transition Menu open
  7296. */
  7297. }, {
  7298. key: "_animateInToolbar",
  7299. value: function _animateInToolbar() {
  7300. var _this51 = this;
  7301. var scaleFactor = void 0;
  7302. var windowWidth = window.innerWidth;
  7303. var windowHeight = window.innerHeight;
  7304. var btnRect = this.el.getBoundingClientRect();
  7305. var backdrop = $('<div class="fab-backdrop"></div>');
  7306. var fabColor = this.$anchor.css('background-color');
  7307. this.$anchor.append(backdrop);
  7308. this.offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
  7309. this.offsetY = windowHeight - btnRect.bottom;
  7310. scaleFactor = windowWidth / backdrop[0].clientWidth;
  7311. this.btnBottom = btnRect.bottom;
  7312. this.btnLeft = btnRect.left;
  7313. this.btnWidth = btnRect.width;
  7314. // Set initial state
  7315. this.$el.addClass('active');
  7316. this.$el.css({
  7317. 'text-align': 'center',
  7318. width: '100%',
  7319. bottom: 0,
  7320. left: 0,
  7321. transform: 'translateX(' + this.offsetX + 'px)',
  7322. transition: 'none'
  7323. });
  7324. this.$anchor.css({
  7325. transform: 'translateY(' + -this.offsetY + 'px)',
  7326. transition: 'none'
  7327. });
  7328. backdrop.css({
  7329. 'background-color': fabColor
  7330. });
  7331. setTimeout(function () {
  7332. _this51.$el.css({
  7333. transform: '',
  7334. transition: 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'
  7335. });
  7336. _this51.$anchor.css({
  7337. overflow: 'visible',
  7338. transform: '',
  7339. transition: 'transform .2s'
  7340. });
  7341. setTimeout(function () {
  7342. _this51.$el.css({
  7343. overflow: 'hidden',
  7344. 'background-color': fabColor
  7345. });
  7346. backdrop.css({
  7347. transform: 'scale(' + scaleFactor + ')',
  7348. transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
  7349. });
  7350. _this51.$menu.children('li').children('a').css({
  7351. opacity: 1
  7352. });
  7353. // Scroll to close.
  7354. _this51._handleDocumentClickBound = _this51._handleDocumentClick.bind(_this51);
  7355. window.addEventListener('scroll', _this51._handleCloseBound, true);
  7356. document.body.addEventListener('click', _this51._handleDocumentClickBound, true);
  7357. }, 100);
  7358. }, 0);
  7359. }
  7360. /**
  7361. * Toolbar transition Menu close
  7362. */
  7363. }, {
  7364. key: "_animateOutToolbar",
  7365. value: function _animateOutToolbar() {
  7366. var _this52 = this;
  7367. var windowWidth = window.innerWidth;
  7368. var windowHeight = window.innerHeight;
  7369. var backdrop = this.$el.find('.fab-backdrop');
  7370. var fabColor = this.$anchor.css('background-color');
  7371. this.offsetX = this.btnLeft - windowWidth / 2 + this.btnWidth / 2;
  7372. this.offsetY = windowHeight - this.btnBottom;
  7373. // Hide backdrop
  7374. this.$el.removeClass('active');
  7375. this.$el.css({
  7376. 'background-color': 'transparent',
  7377. transition: 'none'
  7378. });
  7379. this.$anchor.css({
  7380. transition: 'none'
  7381. });
  7382. backdrop.css({
  7383. transform: 'scale(0)',
  7384. 'background-color': fabColor
  7385. });
  7386. this.$menu.children('li').children('a').css({
  7387. opacity: ''
  7388. });
  7389. setTimeout(function () {
  7390. backdrop.remove();
  7391. // Set initial state.
  7392. _this52.$el.css({
  7393. 'text-align': '',
  7394. width: '',
  7395. bottom: '',
  7396. left: '',
  7397. overflow: '',
  7398. 'background-color': '',
  7399. transform: 'translate3d(' + -_this52.offsetX + 'px,0,0)'
  7400. });
  7401. _this52.$anchor.css({
  7402. overflow: '',
  7403. transform: 'translate3d(0,' + _this52.offsetY + 'px,0)'
  7404. });
  7405. setTimeout(function () {
  7406. _this52.$el.css({
  7407. transform: 'translate3d(0,0,0)',
  7408. transition: 'transform .2s'
  7409. });
  7410. _this52.$anchor.css({
  7411. transform: 'translate3d(0,0,0)',
  7412. transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
  7413. });
  7414. }, 20);
  7415. }, 200);
  7416. }
  7417. }], [{
  7418. key: "init",
  7419. value: function init(els, options) {
  7420. return _get(FloatingActionButton.__proto__ || Object.getPrototypeOf(FloatingActionButton), "init", this).call(this, this, els, options);
  7421. }
  7422. /**
  7423. * Get Instance
  7424. */
  7425. }, {
  7426. key: "getInstance",
  7427. value: function getInstance(el) {
  7428. var domElem = !!el.jquery ? el[0] : el;
  7429. return domElem.M_FloatingActionButton;
  7430. }
  7431. }, {
  7432. key: "defaults",
  7433. get: function () {
  7434. return _defaults;
  7435. }
  7436. }]);
  7437. return FloatingActionButton;
  7438. }(Component);
  7439. M.FloatingActionButton = FloatingActionButton;
  7440. if (M.jQueryLoaded) {
  7441. M.initializeJqueryWrapper(FloatingActionButton, 'floatingActionButton', 'M_FloatingActionButton');
  7442. }
  7443. })(cash, M.anime);
  7444. ;(function ($) {
  7445. 'use strict';
  7446. var _defaults = {
  7447. // Close when date is selected
  7448. autoClose: false,
  7449. // the default output format for the input field value
  7450. format: 'mmm dd, yyyy',
  7451. // Used to create date object from current input string
  7452. parse: null,
  7453. // The initial date to view when first opened
  7454. defaultDate: null,
  7455. // Make the `defaultDate` the initial selected value
  7456. setDefaultDate: false,
  7457. disableWeekends: false,
  7458. disableDayFn: null,
  7459. // First day of week (0: Sunday, 1: Monday etc)
  7460. firstDay: 0,
  7461. // The earliest date that can be selected
  7462. minDate: null,
  7463. // Thelatest date that can be selected
  7464. maxDate: null,
  7465. // Number of years either side, or array of upper/lower range
  7466. yearRange: 10,
  7467. // used internally (don't config outside)
  7468. minYear: 0,
  7469. maxYear: 9999,
  7470. minMonth: undefined,
  7471. maxMonth: undefined,
  7472. startRange: null,
  7473. endRange: null,
  7474. isRTL: false,
  7475. // Render the month after year in the calendar title
  7476. showMonthAfterYear: false,
  7477. // Render days of the calendar grid that fall in the next or previous month
  7478. showDaysInNextAndPreviousMonths: false,
  7479. // Specify a DOM element to render the calendar in
  7480. container: null,
  7481. // Show clear button
  7482. showClearBtn: false,
  7483. // internationalization
  7484. i18n: {
  7485. cancel: 'Cancel',
  7486. clear: 'Clear',
  7487. done: 'Ok',
  7488. previousMonth: '‹',
  7489. nextMonth: '›',
  7490. months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  7491. monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  7492. weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  7493. weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  7494. weekdaysAbbrev: ['S', 'M', 'T', 'W', 'T', 'F', 'S']
  7495. },
  7496. // events array
  7497. events: [],
  7498. // callback function
  7499. onSelect: null,
  7500. onOpen: null,
  7501. onClose: null,
  7502. onDraw: null
  7503. };
  7504. /**
  7505. * @class
  7506. *
  7507. */
  7508. var Datepicker = function (_Component15) {
  7509. _inherits(Datepicker, _Component15);
  7510. /**
  7511. * Construct Datepicker instance and set up overlay
  7512. * @constructor
  7513. * @param {Element} el
  7514. * @param {Object} options
  7515. */
  7516. function Datepicker(el, options) {
  7517. _classCallCheck(this, Datepicker);
  7518. var _this53 = _possibleConstructorReturn(this, (Datepicker.__proto__ || Object.getPrototypeOf(Datepicker)).call(this, Datepicker, el, options));
  7519. _this53.el.M_Datepicker = _this53;
  7520. _this53.options = $.extend({}, Datepicker.defaults, options);
  7521. // make sure i18n defaults are not lost when only few i18n option properties are passed
  7522. if (!!options && options.hasOwnProperty('i18n') && typeof options.i18n === 'object') {
  7523. _this53.options.i18n = $.extend({}, Datepicker.defaults.i18n, options.i18n);
  7524. }
  7525. // Remove time component from minDate and maxDate options
  7526. if (_this53.options.minDate) _this53.options.minDate.setHours(0, 0, 0, 0);
  7527. if (_this53.options.maxDate) _this53.options.maxDate.setHours(0, 0, 0, 0);
  7528. _this53.id = M.guid();
  7529. _this53._setupVariables();
  7530. _this53._insertHTMLIntoDOM();
  7531. _this53._setupModal();
  7532. _this53._setupEventHandlers();
  7533. if (!_this53.options.defaultDate) {
  7534. _this53.options.defaultDate = new Date(Date.parse(_this53.el.value));
  7535. }
  7536. var defDate = _this53.options.defaultDate;
  7537. if (Datepicker._isDate(defDate)) {
  7538. if (_this53.options.setDefaultDate) {
  7539. _this53.setDate(defDate, true);
  7540. _this53.setInputValue();
  7541. } else {
  7542. _this53.gotoDate(defDate);
  7543. }
  7544. } else {
  7545. _this53.gotoDate(new Date());
  7546. }
  7547. /**
  7548. * Describes open/close state of datepicker
  7549. * @type {Boolean}
  7550. */
  7551. _this53.isOpen = false;
  7552. return _this53;
  7553. }
  7554. _createClass(Datepicker, [{
  7555. key: "destroy",
  7556. /**
  7557. * Teardown component
  7558. */
  7559. value: function destroy() {
  7560. this._removeEventHandlers();
  7561. this.modal.destroy();
  7562. $(this.modalEl).remove();
  7563. this.destroySelects();
  7564. this.el.M_Datepicker = undefined;
  7565. }
  7566. }, {
  7567. key: "destroySelects",
  7568. value: function destroySelects() {
  7569. var oldYearSelect = this.calendarEl.querySelector('.orig-select-year');
  7570. if (oldYearSelect) {
  7571. M.FormSelect.getInstance(oldYearSelect).destroy();
  7572. }
  7573. var oldMonthSelect = this.calendarEl.querySelector('.orig-select-month');
  7574. if (oldMonthSelect) {
  7575. M.FormSelect.getInstance(oldMonthSelect).destroy();
  7576. }
  7577. }
  7578. }, {
  7579. key: "_insertHTMLIntoDOM",
  7580. value: function _insertHTMLIntoDOM() {
  7581. if (this.options.showClearBtn) {
  7582. $(this.clearBtn).css({ visibility: '' });
  7583. this.clearBtn.innerHTML = this.options.i18n.clear;
  7584. }
  7585. this.doneBtn.innerHTML = this.options.i18n.done;
  7586. this.cancelBtn.innerHTML = this.options.i18n.cancel;
  7587. if (this.options.container) {
  7588. this.$modalEl.appendTo(this.options.container);
  7589. } else {
  7590. this.$modalEl.insertBefore(this.el);
  7591. }
  7592. }
  7593. }, {
  7594. key: "_setupModal",
  7595. value: function _setupModal() {
  7596. var _this54 = this;
  7597. this.modalEl.id = 'modal-' + this.id;
  7598. this.modal = M.Modal.init(this.modalEl, {
  7599. onCloseEnd: function () {
  7600. _this54.isOpen = false;
  7601. }
  7602. });
  7603. }
  7604. }, {
  7605. key: "toString",
  7606. value: function toString(format) {
  7607. var _this55 = this;
  7608. format = format || this.options.format;
  7609. if (!Datepicker._isDate(this.date)) {
  7610. return '';
  7611. }
  7612. var formatArray = format.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g);
  7613. var formattedDate = formatArray.map(function (label) {
  7614. if (_this55.formats[label]) {
  7615. return _this55.formats[label]();
  7616. }
  7617. return label;
  7618. }).join('');
  7619. return formattedDate;
  7620. }
  7621. }, {
  7622. key: "setDate",
  7623. value: function setDate(date, preventOnSelect) {
  7624. if (!date) {
  7625. this.date = null;
  7626. this._renderDateDisplay();
  7627. return this.draw();
  7628. }
  7629. if (typeof date === 'string') {
  7630. date = new Date(Date.parse(date));
  7631. }
  7632. if (!Datepicker._isDate(date)) {
  7633. return;
  7634. }
  7635. var min = this.options.minDate,
  7636. max = this.options.maxDate;
  7637. if (Datepicker._isDate(min) && date < min) {
  7638. date = min;
  7639. } else if (Datepicker._isDate(max) && date > max) {
  7640. date = max;
  7641. }
  7642. this.date = new Date(date.getTime());
  7643. this._renderDateDisplay();
  7644. Datepicker._setToStartOfDay(this.date);
  7645. this.gotoDate(this.date);
  7646. if (!preventOnSelect && typeof this.options.onSelect === 'function') {
  7647. this.options.onSelect.call(this, this.date);
  7648. }
  7649. }
  7650. }, {
  7651. key: "setInputValue",
  7652. value: function setInputValue() {
  7653. this.el.value = this.toString();
  7654. this.$el.trigger('change', { firedBy: this });
  7655. }
  7656. }, {
  7657. key: "_renderDateDisplay",
  7658. value: function _renderDateDisplay() {
  7659. var displayDate = Datepicker._isDate(this.date) ? this.date : new Date();
  7660. var i18n = this.options.i18n;
  7661. var day = i18n.weekdaysShort[displayDate.getDay()];
  7662. var month = i18n.monthsShort[displayDate.getMonth()];
  7663. var date = displayDate.getDate();
  7664. this.yearTextEl.innerHTML = displayDate.getFullYear();
  7665. this.dateTextEl.innerHTML = day + ", " + month + " " + date;
  7666. }
  7667. /**
  7668. * change view to a specific date
  7669. */
  7670. }, {
  7671. key: "gotoDate",
  7672. value: function gotoDate(date) {
  7673. var newCalendar = true;
  7674. if (!Datepicker._isDate(date)) {
  7675. return;
  7676. }
  7677. if (this.calendars) {
  7678. var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
  7679. lastVisibleDate = new Date(this.calendars[this.calendars.length - 1].year, this.calendars[this.calendars.length - 1].month, 1),
  7680. visibleDate = date.getTime();
  7681. // get the end of the month
  7682. lastVisibleDate.setMonth(lastVisibleDate.getMonth() + 1);
  7683. lastVisibleDate.setDate(lastVisibleDate.getDate() - 1);
  7684. newCalendar = visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate;
  7685. }
  7686. if (newCalendar) {
  7687. this.calendars = [{
  7688. month: date.getMonth(),
  7689. year: date.getFullYear()
  7690. }];
  7691. }
  7692. this.adjustCalendars();
  7693. }
  7694. }, {
  7695. key: "adjustCalendars",
  7696. value: function adjustCalendars() {
  7697. this.calendars[0] = this.adjustCalendar(this.calendars[0]);
  7698. this.draw();
  7699. }
  7700. }, {
  7701. key: "adjustCalendar",
  7702. value: function adjustCalendar(calendar) {
  7703. if (calendar.month < 0) {
  7704. calendar.year -= Math.ceil(Math.abs(calendar.month) / 12);
  7705. calendar.month += 12;
  7706. }
  7707. if (calendar.month > 11) {
  7708. calendar.year += Math.floor(Math.abs(calendar.month) / 12);
  7709. calendar.month -= 12;
  7710. }
  7711. return calendar;
  7712. }
  7713. }, {
  7714. key: "nextMonth",
  7715. value: function nextMonth() {
  7716. this.calendars[0].month++;
  7717. this.adjustCalendars();
  7718. }
  7719. }, {
  7720. key: "prevMonth",
  7721. value: function prevMonth() {
  7722. this.calendars[0].month--;
  7723. this.adjustCalendars();
  7724. }
  7725. }, {
  7726. key: "render",
  7727. value: function render(year, month, randId) {
  7728. var opts = this.options,
  7729. now = new Date(),
  7730. days = Datepicker._getDaysInMonth(year, month),
  7731. before = new Date(year, month, 1).getDay(),
  7732. data = [],
  7733. row = [];
  7734. Datepicker._setToStartOfDay(now);
  7735. if (opts.firstDay > 0) {
  7736. before -= opts.firstDay;
  7737. if (before < 0) {
  7738. before += 7;
  7739. }
  7740. }
  7741. var previousMonth = month === 0 ? 11 : month - 1,
  7742. nextMonth = month === 11 ? 0 : month + 1,
  7743. yearOfPreviousMonth = month === 0 ? year - 1 : year,
  7744. yearOfNextMonth = month === 11 ? year + 1 : year,
  7745. daysInPreviousMonth = Datepicker._getDaysInMonth(yearOfPreviousMonth, previousMonth);
  7746. var cells = days + before,
  7747. after = cells;
  7748. while (after > 7) {
  7749. after -= 7;
  7750. }
  7751. cells += 7 - after;
  7752. var isWeekSelected = false;
  7753. for (var i = 0, r = 0; i < cells; i++) {
  7754. var day = new Date(year, month, 1 + (i - before)),
  7755. isSelected = Datepicker._isDate(this.date) ? Datepicker._compareDates(day, this.date) : false,
  7756. isToday = Datepicker._compareDates(day, now),
  7757. hasEvent = opts.events.indexOf(day.toDateString()) !== -1 ? true : false,
  7758. isEmpty = i < before || i >= days + before,
  7759. dayNumber = 1 + (i - before),
  7760. monthNumber = month,
  7761. yearNumber = year,
  7762. isStartRange = opts.startRange && Datepicker._compareDates(opts.startRange, day),
  7763. isEndRange = opts.endRange && Datepicker._compareDates(opts.endRange, day),
  7764. isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange,
  7765. isDisabled = opts.minDate && day < opts.minDate || opts.maxDate && day > opts.maxDate || opts.disableWeekends && Datepicker._isWeekend(day) || opts.disableDayFn && opts.disableDayFn(day);
  7766. if (isEmpty) {
  7767. if (i < before) {
  7768. dayNumber = daysInPreviousMonth + dayNumber;
  7769. monthNumber = previousMonth;
  7770. yearNumber = yearOfPreviousMonth;
  7771. } else {
  7772. dayNumber = dayNumber - days;
  7773. monthNumber = nextMonth;
  7774. yearNumber = yearOfNextMonth;
  7775. }
  7776. }
  7777. var dayConfig = {
  7778. day: dayNumber,
  7779. month: monthNumber,
  7780. year: yearNumber,
  7781. hasEvent: hasEvent,
  7782. isSelected: isSelected,
  7783. isToday: isToday,
  7784. isDisabled: isDisabled,
  7785. isEmpty: isEmpty,
  7786. isStartRange: isStartRange,
  7787. isEndRange: isEndRange,
  7788. isInRange: isInRange,
  7789. showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths
  7790. };
  7791. row.push(this.renderDay(dayConfig));
  7792. if (++r === 7) {
  7793. data.push(this.renderRow(row, opts.isRTL, isWeekSelected));
  7794. row = [];
  7795. r = 0;
  7796. isWeekSelected = false;
  7797. }
  7798. }
  7799. return this.renderTable(opts, data, randId);
  7800. }
  7801. }, {
  7802. key: "renderDay",
  7803. value: function renderDay(opts) {
  7804. var arr = [];
  7805. var ariaSelected = 'false';
  7806. if (opts.isEmpty) {
  7807. if (opts.showDaysInNextAndPreviousMonths) {
  7808. arr.push('is-outside-current-month');
  7809. arr.push('is-selection-disabled');
  7810. } else {
  7811. return '<td class="is-empty"></td>';
  7812. }
  7813. }
  7814. if (opts.isDisabled) {
  7815. arr.push('is-disabled');
  7816. }
  7817. if (opts.isToday) {
  7818. arr.push('is-today');
  7819. }
  7820. if (opts.isSelected) {
  7821. arr.push('is-selected');
  7822. ariaSelected = 'true';
  7823. }
  7824. if (opts.hasEvent) {
  7825. arr.push('has-event');
  7826. }
  7827. if (opts.isInRange) {
  7828. arr.push('is-inrange');
  7829. }
  7830. if (opts.isStartRange) {
  7831. arr.push('is-startrange');
  7832. }
  7833. if (opts.isEndRange) {
  7834. arr.push('is-endrange');
  7835. }
  7836. return "<td data-day=\"" + opts.day + "\" class=\"" + arr.join(' ') + "\" aria-selected=\"" + ariaSelected + "\">" + ("<button class=\"datepicker-day-button\" type=\"button\" data-year=\"" + opts.year + "\" data-month=\"" + opts.month + "\" data-day=\"" + opts.day + "\">" + opts.day + "</button>") + '</td>';
  7837. }
  7838. }, {
  7839. key: "renderRow",
  7840. value: function renderRow(days, isRTL, isRowSelected) {
  7841. return '<tr class="datepicker-row' + (isRowSelected ? ' is-selected' : '') + '">' + (isRTL ? days.reverse() : days).join('') + '</tr>';
  7842. }
  7843. }, {
  7844. key: "renderTable",
  7845. value: function renderTable(opts, data, randId) {
  7846. return '<div class="datepicker-table-wrapper"><table cellpadding="0" cellspacing="0" class="datepicker-table" role="grid" aria-labelledby="' + randId + '">' + this.renderHead(opts) + this.renderBody(data) + '</table></div>';
  7847. }
  7848. }, {
  7849. key: "renderHead",
  7850. value: function renderHead(opts) {
  7851. var i = void 0,
  7852. arr = [];
  7853. for (i = 0; i < 7; i++) {
  7854. arr.push("<th scope=\"col\"><abbr title=\"" + this.renderDayName(opts, i) + "\">" + this.renderDayName(opts, i, true) + "</abbr></th>");
  7855. }
  7856. return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>';
  7857. }
  7858. }, {
  7859. key: "renderBody",
  7860. value: function renderBody(rows) {
  7861. return '<tbody>' + rows.join('') + '</tbody>';
  7862. }
  7863. }, {
  7864. key: "renderTitle",
  7865. value: function renderTitle(instance, c, year, month, refYear, randId) {
  7866. var i = void 0,
  7867. j = void 0,
  7868. arr = void 0,
  7869. opts = this.options,
  7870. isMinYear = year === opts.minYear,
  7871. isMaxYear = year === opts.maxYear,
  7872. html = '<div id="' + randId + '" class="datepicker-controls" role="heading" aria-live="assertive">',
  7873. monthHtml = void 0,
  7874. yearHtml = void 0,
  7875. prev = true,
  7876. next = true;
  7877. for (arr = [], i = 0; i < 12; i++) {
  7878. arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' + (i === month ? ' selected="selected"' : '') + (isMinYear && i < opts.minMonth || isMaxYear && i > opts.maxMonth ? 'disabled="disabled"' : '') + '>' + opts.i18n.months[i] + '</option>');
  7879. }
  7880. monthHtml = '<select class="datepicker-select orig-select-month" tabindex="-1">' + arr.join('') + '</select>';
  7881. if ($.isArray(opts.yearRange)) {
  7882. i = opts.yearRange[0];
  7883. j = opts.yearRange[1] + 1;
  7884. } else {
  7885. i = year - opts.yearRange;
  7886. j = 1 + year + opts.yearRange;
  7887. }
  7888. for (arr = []; i < j && i <= opts.maxYear; i++) {
  7889. if (i >= opts.minYear) {
  7890. arr.push("<option value=\"" + i + "\" " + (i === year ? 'selected="selected"' : '') + ">" + i + "</option>");
  7891. }
  7892. }
  7893. yearHtml = "<select class=\"datepicker-select orig-select-year\" tabindex=\"-1\">" + arr.join('') + "</select>";
  7894. var leftArrow = '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"/><path d="M0-.5h24v24H0z" fill="none"/></svg>';
  7895. html += "<button class=\"month-prev" + (prev ? '' : ' is-disabled') + "\" type=\"button\">" + leftArrow + "</button>";
  7896. html += '<div class="selects-container">';
  7897. if (opts.showMonthAfterYear) {
  7898. html += yearHtml + monthHtml;
  7899. } else {
  7900. html += monthHtml + yearHtml;
  7901. }
  7902. html += '</div>';
  7903. if (isMinYear && (month === 0 || opts.minMonth >= month)) {
  7904. prev = false;
  7905. }
  7906. if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
  7907. next = false;
  7908. }
  7909. var rightArrow = '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/><path d="M0-.25h24v24H0z" fill="none"/></svg>';
  7910. html += "<button class=\"month-next" + (next ? '' : ' is-disabled') + "\" type=\"button\">" + rightArrow + "</button>";
  7911. return html += '</div>';
  7912. }
  7913. /**
  7914. * refresh the HTML
  7915. */
  7916. }, {
  7917. key: "draw",
  7918. value: function draw(force) {
  7919. if (!this.isOpen && !force) {
  7920. return;
  7921. }
  7922. var opts = this.options,
  7923. minYear = opts.minYear,
  7924. maxYear = opts.maxYear,
  7925. minMonth = opts.minMonth,
  7926. maxMonth = opts.maxMonth,
  7927. html = '',
  7928. randId = void 0;
  7929. if (this._y <= minYear) {
  7930. this._y = minYear;
  7931. if (!isNaN(minMonth) && this._m < minMonth) {
  7932. this._m = minMonth;
  7933. }
  7934. }
  7935. if (this._y >= maxYear) {
  7936. this._y = maxYear;
  7937. if (!isNaN(maxMonth) && this._m > maxMonth) {
  7938. this._m = maxMonth;
  7939. }
  7940. }
  7941. randId = 'datepicker-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2);
  7942. for (var c = 0; c < 1; c++) {
  7943. this._renderDateDisplay();
  7944. html += this.renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId);
  7945. }
  7946. this.destroySelects();
  7947. this.calendarEl.innerHTML = html;
  7948. // Init Materialize Select
  7949. var yearSelect = this.calendarEl.querySelector('.orig-select-year');
  7950. var monthSelect = this.calendarEl.querySelector('.orig-select-month');
  7951. M.FormSelect.init(yearSelect, {
  7952. classes: 'select-year',
  7953. dropdownOptions: { container: document.body, constrainWidth: false }
  7954. });
  7955. M.FormSelect.init(monthSelect, {
  7956. classes: 'select-month',
  7957. dropdownOptions: { container: document.body, constrainWidth: false }
  7958. });
  7959. // Add change handlers for select
  7960. yearSelect.addEventListener('change', this._handleYearChange.bind(this));
  7961. monthSelect.addEventListener('change', this._handleMonthChange.bind(this));
  7962. if (typeof this.options.onDraw === 'function') {
  7963. this.options.onDraw(this);
  7964. }
  7965. }
  7966. /**
  7967. * Setup Event Handlers
  7968. */
  7969. }, {
  7970. key: "_setupEventHandlers",
  7971. value: function _setupEventHandlers() {
  7972. this._handleInputKeydownBound = this._handleInputKeydown.bind(this);
  7973. this._handleInputClickBound = this._handleInputClick.bind(this);
  7974. this._handleInputChangeBound = this._handleInputChange.bind(this);
  7975. this._handleCalendarClickBound = this._handleCalendarClick.bind(this);
  7976. this._finishSelectionBound = this._finishSelection.bind(this);
  7977. this._handleMonthChange = this._handleMonthChange.bind(this);
  7978. this._closeBound = this.close.bind(this);
  7979. this.el.addEventListener('click', this._handleInputClickBound);
  7980. this.el.addEventListener('keydown', this._handleInputKeydownBound);
  7981. this.el.addEventListener('change', this._handleInputChangeBound);
  7982. this.calendarEl.addEventListener('click', this._handleCalendarClickBound);
  7983. this.doneBtn.addEventListener('click', this._finishSelectionBound);
  7984. this.cancelBtn.addEventListener('click', this._closeBound);
  7985. if (this.options.showClearBtn) {
  7986. this._handleClearClickBound = this._handleClearClick.bind(this);
  7987. this.clearBtn.addEventListener('click', this._handleClearClickBound);
  7988. }
  7989. }
  7990. }, {
  7991. key: "_setupVariables",
  7992. value: function _setupVariables() {
  7993. var _this56 = this;
  7994. this.$modalEl = $(Datepicker._template);
  7995. this.modalEl = this.$modalEl[0];
  7996. this.calendarEl = this.modalEl.querySelector('.datepicker-calendar');
  7997. this.yearTextEl = this.modalEl.querySelector('.year-text');
  7998. this.dateTextEl = this.modalEl.querySelector('.date-text');
  7999. if (this.options.showClearBtn) {
  8000. this.clearBtn = this.modalEl.querySelector('.datepicker-clear');
  8001. }
  8002. this.doneBtn = this.modalEl.querySelector('.datepicker-done');
  8003. this.cancelBtn = this.modalEl.querySelector('.datepicker-cancel');
  8004. this.formats = {
  8005. d: function () {
  8006. return _this56.date.getDate();
  8007. },
  8008. dd: function () {
  8009. var d = _this56.date.getDate();
  8010. return (d < 10 ? '0' : '') + d;
  8011. },
  8012. ddd: function () {
  8013. return _this56.options.i18n.weekdaysShort[_this56.date.getDay()];
  8014. },
  8015. dddd: function () {
  8016. return _this56.options.i18n.weekdays[_this56.date.getDay()];
  8017. },
  8018. m: function () {
  8019. return _this56.date.getMonth() + 1;
  8020. },
  8021. mm: function () {
  8022. var m = _this56.date.getMonth() + 1;
  8023. return (m < 10 ? '0' : '') + m;
  8024. },
  8025. mmm: function () {
  8026. return _this56.options.i18n.monthsShort[_this56.date.getMonth()];
  8027. },
  8028. mmmm: function () {
  8029. return _this56.options.i18n.months[_this56.date.getMonth()];
  8030. },
  8031. yy: function () {
  8032. return ('' + _this56.date.getFullYear()).slice(2);
  8033. },
  8034. yyyy: function () {
  8035. return _this56.date.getFullYear();
  8036. }
  8037. };
  8038. }
  8039. /**
  8040. * Remove Event Handlers
  8041. */
  8042. }, {
  8043. key: "_removeEventHandlers",
  8044. value: function _removeEventHandlers() {
  8045. this.el.removeEventListener('click', this._handleInputClickBound);
  8046. this.el.removeEventListener('keydown', this._handleInputKeydownBound);
  8047. this.el.removeEventListener('change', this._handleInputChangeBound);
  8048. this.calendarEl.removeEventListener('click', this._handleCalendarClickBound);
  8049. }
  8050. }, {
  8051. key: "_handleInputClick",
  8052. value: function _handleInputClick() {
  8053. this.open();
  8054. }
  8055. }, {
  8056. key: "_handleInputKeydown",
  8057. value: function _handleInputKeydown(e) {
  8058. if (e.which === M.keys.ENTER) {
  8059. e.preventDefault();
  8060. this.open();
  8061. }
  8062. }
  8063. }, {
  8064. key: "_handleCalendarClick",
  8065. value: function _handleCalendarClick(e) {
  8066. if (!this.isOpen) {
  8067. return;
  8068. }
  8069. var $target = $(e.target);
  8070. if (!$target.hasClass('is-disabled')) {
  8071. if ($target.hasClass('datepicker-day-button') && !$target.hasClass('is-empty') && !$target.parent().hasClass('is-disabled')) {
  8072. this.setDate(new Date(e.target.getAttribute('data-year'), e.target.getAttribute('data-month'), e.target.getAttribute('data-day')));
  8073. if (this.options.autoClose) {
  8074. this._finishSelection();
  8075. }
  8076. } else if ($target.closest('.month-prev').length) {
  8077. this.prevMonth();
  8078. } else if ($target.closest('.month-next').length) {
  8079. this.nextMonth();
  8080. }
  8081. }
  8082. }
  8083. }, {
  8084. key: "_handleClearClick",
  8085. value: function _handleClearClick() {
  8086. this.date = null;
  8087. this.setInputValue();
  8088. this.close();
  8089. }
  8090. }, {
  8091. key: "_handleMonthChange",
  8092. value: function _handleMonthChange(e) {
  8093. this.gotoMonth(e.target.value);
  8094. }
  8095. }, {
  8096. key: "_handleYearChange",
  8097. value: function _handleYearChange(e) {
  8098. this.gotoYear(e.target.value);
  8099. }
  8100. /**
  8101. * change view to a specific month (zero-index, e.g. 0: January)
  8102. */
  8103. }, {
  8104. key: "gotoMonth",
  8105. value: function gotoMonth(month) {
  8106. if (!isNaN(month)) {
  8107. this.calendars[0].month = parseInt(month, 10);
  8108. this.adjustCalendars();
  8109. }
  8110. }
  8111. /**
  8112. * change view to a specific full year (e.g. "2012")
  8113. */
  8114. }, {
  8115. key: "gotoYear",
  8116. value: function gotoYear(year) {
  8117. if (!isNaN(year)) {
  8118. this.calendars[0].year = parseInt(year, 10);
  8119. this.adjustCalendars();
  8120. }
  8121. }
  8122. }, {
  8123. key: "_handleInputChange",
  8124. value: function _handleInputChange(e) {
  8125. var date = void 0;
  8126. // Prevent change event from being fired when triggered by the plugin
  8127. if (e.firedBy === this) {
  8128. return;
  8129. }
  8130. if (this.options.parse) {
  8131. date = this.options.parse(this.el.value, this.options.format);
  8132. } else {
  8133. date = new Date(Date.parse(this.el.value));
  8134. }
  8135. if (Datepicker._isDate(date)) {
  8136. this.setDate(date);
  8137. }
  8138. }
  8139. }, {
  8140. key: "renderDayName",
  8141. value: function renderDayName(opts, day, abbr) {
  8142. day += opts.firstDay;
  8143. while (day >= 7) {
  8144. day -= 7;
  8145. }
  8146. return abbr ? opts.i18n.weekdaysAbbrev[day] : opts.i18n.weekdays[day];
  8147. }
  8148. /**
  8149. * Set input value to the selected date and close Datepicker
  8150. */
  8151. }, {
  8152. key: "_finishSelection",
  8153. value: function _finishSelection() {
  8154. this.setInputValue();
  8155. this.close();
  8156. }
  8157. /**
  8158. * Open Datepicker
  8159. */
  8160. }, {
  8161. key: "open",
  8162. value: function open() {
  8163. if (this.isOpen) {
  8164. return;
  8165. }
  8166. this.isOpen = true;
  8167. if (typeof this.options.onOpen === 'function') {
  8168. this.options.onOpen.call(this);
  8169. }
  8170. this.draw();
  8171. this.modal.open();
  8172. return this;
  8173. }
  8174. /**
  8175. * Close Datepicker
  8176. */
  8177. }, {
  8178. key: "close",
  8179. value: function close() {
  8180. if (!this.isOpen) {
  8181. return;
  8182. }
  8183. this.isOpen = false;
  8184. if (typeof this.options.onClose === 'function') {
  8185. this.options.onClose.call(this);
  8186. }
  8187. this.modal.close();
  8188. return this;
  8189. }
  8190. }], [{
  8191. key: "init",
  8192. value: function init(els, options) {
  8193. return _get(Datepicker.__proto__ || Object.getPrototypeOf(Datepicker), "init", this).call(this, this, els, options);
  8194. }
  8195. }, {
  8196. key: "_isDate",
  8197. value: function _isDate(obj) {
  8198. return (/Date/.test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime())
  8199. );
  8200. }
  8201. }, {
  8202. key: "_isWeekend",
  8203. value: function _isWeekend(date) {
  8204. var day = date.getDay();
  8205. return day === 0 || day === 6;
  8206. }
  8207. }, {
  8208. key: "_setToStartOfDay",
  8209. value: function _setToStartOfDay(date) {
  8210. if (Datepicker._isDate(date)) date.setHours(0, 0, 0, 0);
  8211. }
  8212. }, {
  8213. key: "_getDaysInMonth",
  8214. value: function _getDaysInMonth(year, month) {
  8215. return [31, Datepicker._isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
  8216. }
  8217. }, {
  8218. key: "_isLeapYear",
  8219. value: function _isLeapYear(year) {
  8220. // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
  8221. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  8222. }
  8223. }, {
  8224. key: "_compareDates",
  8225. value: function _compareDates(a, b) {
  8226. // weak date comparison (use setToStartOfDay(date) to ensure correct result)
  8227. return a.getTime() === b.getTime();
  8228. }
  8229. }, {
  8230. key: "_setToStartOfDay",
  8231. value: function _setToStartOfDay(date) {
  8232. if (Datepicker._isDate(date)) date.setHours(0, 0, 0, 0);
  8233. }
  8234. /**
  8235. * Get Instance
  8236. */
  8237. }, {
  8238. key: "getInstance",
  8239. value: function getInstance(el) {
  8240. var domElem = !!el.jquery ? el[0] : el;
  8241. return domElem.M_Datepicker;
  8242. }
  8243. }, {
  8244. key: "defaults",
  8245. get: function () {
  8246. return _defaults;
  8247. }
  8248. }]);
  8249. return Datepicker;
  8250. }(Component);
  8251. Datepicker._template = ['<div class= "modal datepicker-modal">', '<div class="modal-content datepicker-container">', '<div class="datepicker-date-display">', '<span class="year-text"></span>', '<span class="date-text"></span>', '</div>', '<div class="datepicker-calendar-container">', '<div class="datepicker-calendar"></div>', '<div class="datepicker-footer">', '<button class="btn-flat datepicker-clear waves-effect" style="visibility: hidden;" type="button"></button>', '<div class="confirmation-btns">', '<button class="btn-flat datepicker-cancel waves-effect" type="button"></button>', '<button class="btn-flat datepicker-done waves-effect" type="button"></button>', '</div>', '</div>', '</div>', '</div>', '</div>'].join('');
  8252. M.Datepicker = Datepicker;
  8253. if (M.jQueryLoaded) {
  8254. M.initializeJqueryWrapper(Datepicker, 'datepicker', 'M_Datepicker');
  8255. }
  8256. })(cash);
  8257. ;(function ($) {
  8258. 'use strict';
  8259. var _defaults = {
  8260. dialRadius: 135,
  8261. outerRadius: 105,
  8262. innerRadius: 70,
  8263. tickRadius: 20,
  8264. duration: 350,
  8265. container: null,
  8266. defaultTime: 'now', // default time, 'now' or '13:14' e.g.
  8267. fromNow: 0, // Millisecond offset from the defaultTime
  8268. showClearBtn: false,
  8269. // internationalization
  8270. i18n: {
  8271. cancel: 'Cancel',
  8272. clear: 'Clear',
  8273. done: 'Ok'
  8274. },
  8275. autoClose: false, // auto close when minute is selected
  8276. twelveHour: true, // change to 12 hour AM/PM clock from 24 hour
  8277. vibrate: true, // vibrate the device when dragging clock hand
  8278. // Callbacks
  8279. onOpenStart: null,
  8280. onOpenEnd: null,
  8281. onCloseStart: null,
  8282. onCloseEnd: null,
  8283. onSelect: null
  8284. };
  8285. /**
  8286. * @class
  8287. *
  8288. */
  8289. var Timepicker = function (_Component16) {
  8290. _inherits(Timepicker, _Component16);
  8291. function Timepicker(el, options) {
  8292. _classCallCheck(this, Timepicker);
  8293. var _this57 = _possibleConstructorReturn(this, (Timepicker.__proto__ || Object.getPrototypeOf(Timepicker)).call(this, Timepicker, el, options));
  8294. _this57.el.M_Timepicker = _this57;
  8295. _this57.options = $.extend({}, Timepicker.defaults, options);
  8296. _this57.id = M.guid();
  8297. _this57._insertHTMLIntoDOM();
  8298. _this57._setupModal();
  8299. _this57._setupVariables();
  8300. _this57._setupEventHandlers();
  8301. _this57._clockSetup();
  8302. _this57._pickerSetup();
  8303. return _this57;
  8304. }
  8305. _createClass(Timepicker, [{
  8306. key: "destroy",
  8307. /**
  8308. * Teardown component
  8309. */
  8310. value: function destroy() {
  8311. this._removeEventHandlers();
  8312. this.modal.destroy();
  8313. $(this.modalEl).remove();
  8314. this.el.M_Timepicker = undefined;
  8315. }
  8316. /**
  8317. * Setup Event Handlers
  8318. */
  8319. }, {
  8320. key: "_setupEventHandlers",
  8321. value: function _setupEventHandlers() {
  8322. this._handleInputKeydownBound = this._handleInputKeydown.bind(this);
  8323. this._handleInputClickBound = this._handleInputClick.bind(this);
  8324. this._handleClockClickStartBound = this._handleClockClickStart.bind(this);
  8325. this._handleDocumentClickMoveBound = this._handleDocumentClickMove.bind(this);
  8326. this._handleDocumentClickEndBound = this._handleDocumentClickEnd.bind(this);
  8327. this.el.addEventListener('click', this._handleInputClickBound);
  8328. this.el.addEventListener('keydown', this._handleInputKeydownBound);
  8329. this.plate.addEventListener('mousedown', this._handleClockClickStartBound);
  8330. this.plate.addEventListener('touchstart', this._handleClockClickStartBound);
  8331. $(this.spanHours).on('click', this.showView.bind(this, 'hours'));
  8332. $(this.spanMinutes).on('click', this.showView.bind(this, 'minutes'));
  8333. }
  8334. }, {
  8335. key: "_removeEventHandlers",
  8336. value: function _removeEventHandlers() {
  8337. this.el.removeEventListener('click', this._handleInputClickBound);
  8338. this.el.removeEventListener('keydown', this._handleInputKeydownBound);
  8339. }
  8340. }, {
  8341. key: "_handleInputClick",
  8342. value: function _handleInputClick() {
  8343. this.open();
  8344. }
  8345. }, {
  8346. key: "_handleInputKeydown",
  8347. value: function _handleInputKeydown(e) {
  8348. if (e.which === M.keys.ENTER) {
  8349. e.preventDefault();
  8350. this.open();
  8351. }
  8352. }
  8353. }, {
  8354. key: "_handleClockClickStart",
  8355. value: function _handleClockClickStart(e) {
  8356. e.preventDefault();
  8357. var clockPlateBR = this.plate.getBoundingClientRect();
  8358. var offset = { x: clockPlateBR.left, y: clockPlateBR.top };
  8359. this.x0 = offset.x + this.options.dialRadius;
  8360. this.y0 = offset.y + this.options.dialRadius;
  8361. this.moved = false;
  8362. var clickPos = Timepicker._Pos(e);
  8363. this.dx = clickPos.x - this.x0;
  8364. this.dy = clickPos.y - this.y0;
  8365. // Set clock hands
  8366. this.setHand(this.dx, this.dy, false);
  8367. // Mousemove on document
  8368. document.addEventListener('mousemove', this._handleDocumentClickMoveBound);
  8369. document.addEventListener('touchmove', this._handleDocumentClickMoveBound);
  8370. // Mouseup on document
  8371. document.addEventListener('mouseup', this._handleDocumentClickEndBound);
  8372. document.addEventListener('touchend', this._handleDocumentClickEndBound);
  8373. }
  8374. }, {
  8375. key: "_handleDocumentClickMove",
  8376. value: function _handleDocumentClickMove(e) {
  8377. e.preventDefault();
  8378. var clickPos = Timepicker._Pos(e);
  8379. var x = clickPos.x - this.x0;
  8380. var y = clickPos.y - this.y0;
  8381. this.moved = true;
  8382. this.setHand(x, y, false, true);
  8383. }
  8384. }, {
  8385. key: "_handleDocumentClickEnd",
  8386. value: function _handleDocumentClickEnd(e) {
  8387. var _this58 = this;
  8388. e.preventDefault();
  8389. document.removeEventListener('mouseup', this._handleDocumentClickEndBound);
  8390. document.removeEventListener('touchend', this._handleDocumentClickEndBound);
  8391. var clickPos = Timepicker._Pos(e);
  8392. var x = clickPos.x - this.x0;
  8393. var y = clickPos.y - this.y0;
  8394. if (this.moved && x === this.dx && y === this.dy) {
  8395. this.setHand(x, y);
  8396. }
  8397. if (this.currentView === 'hours') {
  8398. this.showView('minutes', this.options.duration / 2);
  8399. } else if (this.options.autoClose) {
  8400. $(this.minutesView).addClass('timepicker-dial-out');
  8401. setTimeout(function () {
  8402. _this58.done();
  8403. }, this.options.duration / 2);
  8404. }
  8405. if (typeof this.options.onSelect === 'function') {
  8406. this.options.onSelect.call(this, this.hours, this.minutes);
  8407. }
  8408. // Unbind mousemove event
  8409. document.removeEventListener('mousemove', this._handleDocumentClickMoveBound);
  8410. document.removeEventListener('touchmove', this._handleDocumentClickMoveBound);
  8411. }
  8412. }, {
  8413. key: "_insertHTMLIntoDOM",
  8414. value: function _insertHTMLIntoDOM() {
  8415. this.$modalEl = $(Timepicker._template);
  8416. this.modalEl = this.$modalEl[0];
  8417. this.modalEl.id = 'modal-' + this.id;
  8418. // Append popover to input by default
  8419. var containerEl = document.querySelector(this.options.container);
  8420. if (this.options.container && !!containerEl) {
  8421. this.$modalEl.appendTo(containerEl);
  8422. } else {
  8423. this.$modalEl.insertBefore(this.el);
  8424. }
  8425. }
  8426. }, {
  8427. key: "_setupModal",
  8428. value: function _setupModal() {
  8429. var _this59 = this;
  8430. this.modal = M.Modal.init(this.modalEl, {
  8431. onOpenStart: this.options.onOpenStart,
  8432. onOpenEnd: this.options.onOpenEnd,
  8433. onCloseStart: this.options.onCloseStart,
  8434. onCloseEnd: function () {
  8435. if (typeof _this59.options.onCloseEnd === 'function') {
  8436. _this59.options.onCloseEnd.call(_this59);
  8437. }
  8438. _this59.isOpen = false;
  8439. }
  8440. });
  8441. }
  8442. }, {
  8443. key: "_setupVariables",
  8444. value: function _setupVariables() {
  8445. this.currentView = 'hours';
  8446. this.vibrate = navigator.vibrate ? 'vibrate' : navigator.webkitVibrate ? 'webkitVibrate' : null;
  8447. this._canvas = this.modalEl.querySelector('.timepicker-canvas');
  8448. this.plate = this.modalEl.querySelector('.timepicker-plate');
  8449. this.hoursView = this.modalEl.querySelector('.timepicker-hours');
  8450. this.minutesView = this.modalEl.querySelector('.timepicker-minutes');
  8451. this.spanHours = this.modalEl.querySelector('.timepicker-span-hours');
  8452. this.spanMinutes = this.modalEl.querySelector('.timepicker-span-minutes');
  8453. this.spanAmPm = this.modalEl.querySelector('.timepicker-span-am-pm');
  8454. this.footer = this.modalEl.querySelector('.timepicker-footer');
  8455. this.amOrPm = 'PM';
  8456. }
  8457. }, {
  8458. key: "_pickerSetup",
  8459. value: function _pickerSetup() {
  8460. var $clearBtn = $("<button class=\"btn-flat timepicker-clear waves-effect\" style=\"visibility: hidden;\" type=\"button\" tabindex=\"" + (this.options.twelveHour ? '3' : '1') + "\">" + this.options.i18n.clear + "</button>").appendTo(this.footer).on('click', this.clear.bind(this));
  8461. if (this.options.showClearBtn) {
  8462. $clearBtn.css({ visibility: '' });
  8463. }
  8464. var confirmationBtnsContainer = $('<div class="confirmation-btns"></div>');
  8465. $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.cancel + '</button>').appendTo(confirmationBtnsContainer).on('click', this.close.bind(this));
  8466. $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.done + '</button>').appendTo(confirmationBtnsContainer).on('click', this.done.bind(this));
  8467. confirmationBtnsContainer.appendTo(this.footer);
  8468. }
  8469. }, {
  8470. key: "_clockSetup",
  8471. value: function _clockSetup() {
  8472. if (this.options.twelveHour) {
  8473. this.$amBtn = $('<div class="am-btn">AM</div>');
  8474. this.$pmBtn = $('<div class="pm-btn">PM</div>');
  8475. this.$amBtn.on('click', this._handleAmPmClick.bind(this)).appendTo(this.spanAmPm);
  8476. this.$pmBtn.on('click', this._handleAmPmClick.bind(this)).appendTo(this.spanAmPm);
  8477. }
  8478. this._buildHoursView();
  8479. this._buildMinutesView();
  8480. this._buildSVGClock();
  8481. }
  8482. }, {
  8483. key: "_buildSVGClock",
  8484. value: function _buildSVGClock() {
  8485. // Draw clock hands and others
  8486. var dialRadius = this.options.dialRadius;
  8487. var tickRadius = this.options.tickRadius;
  8488. var diameter = dialRadius * 2;
  8489. var svg = Timepicker._createSVGEl('svg');
  8490. svg.setAttribute('class', 'timepicker-svg');
  8491. svg.setAttribute('width', diameter);
  8492. svg.setAttribute('height', diameter);
  8493. var g = Timepicker._createSVGEl('g');
  8494. g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')');
  8495. var bearing = Timepicker._createSVGEl('circle');
  8496. bearing.setAttribute('class', 'timepicker-canvas-bearing');
  8497. bearing.setAttribute('cx', 0);
  8498. bearing.setAttribute('cy', 0);
  8499. bearing.setAttribute('r', 4);
  8500. var hand = Timepicker._createSVGEl('line');
  8501. hand.setAttribute('x1', 0);
  8502. hand.setAttribute('y1', 0);
  8503. var bg = Timepicker._createSVGEl('circle');
  8504. bg.setAttribute('class', 'timepicker-canvas-bg');
  8505. bg.setAttribute('r', tickRadius);
  8506. g.appendChild(hand);
  8507. g.appendChild(bg);
  8508. g.appendChild(bearing);
  8509. svg.appendChild(g);
  8510. this._canvas.appendChild(svg);
  8511. this.hand = hand;
  8512. this.bg = bg;
  8513. this.bearing = bearing;
  8514. this.g = g;
  8515. }
  8516. }, {
  8517. key: "_buildHoursView",
  8518. value: function _buildHoursView() {
  8519. var $tick = $('<div class="timepicker-tick"></div>');
  8520. // Hours view
  8521. if (this.options.twelveHour) {
  8522. for (var i = 1; i < 13; i += 1) {
  8523. var tick = $tick.clone();
  8524. var radian = i / 6 * Math.PI;
  8525. var radius = this.options.outerRadius;
  8526. tick.css({
  8527. left: this.options.dialRadius + Math.sin(radian) * radius - this.options.tickRadius + 'px',
  8528. top: this.options.dialRadius - Math.cos(radian) * radius - this.options.tickRadius + 'px'
  8529. });
  8530. tick.html(i === 0 ? '00' : i);
  8531. this.hoursView.appendChild(tick[0]);
  8532. // tick.on(mousedownEvent, mousedown);
  8533. }
  8534. } else {
  8535. for (var _i2 = 0; _i2 < 24; _i2 += 1) {
  8536. var _tick = $tick.clone();
  8537. var _radian = _i2 / 6 * Math.PI;
  8538. var inner = _i2 > 0 && _i2 < 13;
  8539. var _radius = inner ? this.options.innerRadius : this.options.outerRadius;
  8540. _tick.css({
  8541. left: this.options.dialRadius + Math.sin(_radian) * _radius - this.options.tickRadius + 'px',
  8542. top: this.options.dialRadius - Math.cos(_radian) * _radius - this.options.tickRadius + 'px'
  8543. });
  8544. _tick.html(_i2 === 0 ? '00' : _i2);
  8545. this.hoursView.appendChild(_tick[0]);
  8546. // tick.on(mousedownEvent, mousedown);
  8547. }
  8548. }
  8549. }
  8550. }, {
  8551. key: "_buildMinutesView",
  8552. value: function _buildMinutesView() {
  8553. var $tick = $('<div class="timepicker-tick"></div>');
  8554. // Minutes view
  8555. for (var i = 0; i < 60; i += 5) {
  8556. var tick = $tick.clone();
  8557. var radian = i / 30 * Math.PI;
  8558. tick.css({
  8559. left: this.options.dialRadius + Math.sin(radian) * this.options.outerRadius - this.options.tickRadius + 'px',
  8560. top: this.options.dialRadius - Math.cos(radian) * this.options.outerRadius - this.options.tickRadius + 'px'
  8561. });
  8562. tick.html(Timepicker._addLeadingZero(i));
  8563. this.minutesView.appendChild(tick[0]);
  8564. }
  8565. }
  8566. }, {
  8567. key: "_handleAmPmClick",
  8568. value: function _handleAmPmClick(e) {
  8569. var $btnClicked = $(e.target);
  8570. this.amOrPm = $btnClicked.hasClass('am-btn') ? 'AM' : 'PM';
  8571. this._updateAmPmView();
  8572. }
  8573. }, {
  8574. key: "_updateAmPmView",
  8575. value: function _updateAmPmView() {
  8576. if (this.options.twelveHour) {
  8577. this.$amBtn.toggleClass('text-primary', this.amOrPm === 'AM');
  8578. this.$pmBtn.toggleClass('text-primary', this.amOrPm === 'PM');
  8579. }
  8580. }
  8581. }, {
  8582. key: "_updateTimeFromInput",
  8583. value: function _updateTimeFromInput() {
  8584. // Get the time
  8585. var value = ((this.el.value || this.options.defaultTime || '') + '').split(':');
  8586. if (this.options.twelveHour && !(typeof value[1] === 'undefined')) {
  8587. if (value[1].toUpperCase().indexOf('AM') > 0) {
  8588. this.amOrPm = 'AM';
  8589. } else {
  8590. this.amOrPm = 'PM';
  8591. }
  8592. value[1] = value[1].replace('AM', '').replace('PM', '');
  8593. }
  8594. if (value[0] === 'now') {
  8595. var now = new Date(+new Date() + this.options.fromNow);
  8596. value = [now.getHours(), now.getMinutes()];
  8597. if (this.options.twelveHour) {
  8598. this.amOrPm = value[0] >= 12 && value[0] < 24 ? 'PM' : 'AM';
  8599. }
  8600. }
  8601. this.hours = +value[0] || 0;
  8602. this.minutes = +value[1] || 0;
  8603. this.spanHours.innerHTML = this.hours;
  8604. this.spanMinutes.innerHTML = Timepicker._addLeadingZero(this.minutes);
  8605. this._updateAmPmView();
  8606. }
  8607. }, {
  8608. key: "showView",
  8609. value: function showView(view, delay) {
  8610. if (view === 'minutes' && $(this.hoursView).css('visibility') === 'visible') {
  8611. // raiseCallback(this.options.beforeHourSelect);
  8612. }
  8613. var isHours = view === 'hours',
  8614. nextView = isHours ? this.hoursView : this.minutesView,
  8615. hideView = isHours ? this.minutesView : this.hoursView;
  8616. this.currentView = view;
  8617. $(this.spanHours).toggleClass('text-primary', isHours);
  8618. $(this.spanMinutes).toggleClass('text-primary', !isHours);
  8619. // Transition view
  8620. hideView.classList.add('timepicker-dial-out');
  8621. $(nextView).css('visibility', 'visible').removeClass('timepicker-dial-out');
  8622. // Reset clock hand
  8623. this.resetClock(delay);
  8624. // After transitions ended
  8625. clearTimeout(this.toggleViewTimer);
  8626. this.toggleViewTimer = setTimeout(function () {
  8627. $(hideView).css('visibility', 'hidden');
  8628. }, this.options.duration);
  8629. }
  8630. }, {
  8631. key: "resetClock",
  8632. value: function resetClock(delay) {
  8633. var view = this.currentView,
  8634. value = this[view],
  8635. isHours = view === 'hours',
  8636. unit = Math.PI / (isHours ? 6 : 30),
  8637. radian = value * unit,
  8638. radius = isHours && value > 0 && value < 13 ? this.options.innerRadius : this.options.outerRadius,
  8639. x = Math.sin(radian) * radius,
  8640. y = -Math.cos(radian) * radius,
  8641. self = this;
  8642. if (delay) {
  8643. $(this.canvas).addClass('timepicker-canvas-out');
  8644. setTimeout(function () {
  8645. $(self.canvas).removeClass('timepicker-canvas-out');
  8646. self.setHand(x, y);
  8647. }, delay);
  8648. } else {
  8649. this.setHand(x, y);
  8650. }
  8651. }
  8652. }, {
  8653. key: "setHand",
  8654. value: function setHand(x, y, roundBy5) {
  8655. var _this60 = this;
  8656. var radian = Math.atan2(x, -y),
  8657. isHours = this.currentView === 'hours',
  8658. unit = Math.PI / (isHours || roundBy5 ? 6 : 30),
  8659. z = Math.sqrt(x * x + y * y),
  8660. inner = isHours && z < (this.options.outerRadius + this.options.innerRadius) / 2,
  8661. radius = inner ? this.options.innerRadius : this.options.outerRadius;
  8662. if (this.options.twelveHour) {
  8663. radius = this.options.outerRadius;
  8664. }
  8665. // Radian should in range [0, 2PI]
  8666. if (radian < 0) {
  8667. radian = Math.PI * 2 + radian;
  8668. }
  8669. // Get the round value
  8670. var value = Math.round(radian / unit);
  8671. // Get the round radian
  8672. radian = value * unit;
  8673. // Correct the hours or minutes
  8674. if (this.options.twelveHour) {
  8675. if (isHours) {
  8676. if (value === 0) value = 12;
  8677. } else {
  8678. if (roundBy5) value *= 5;
  8679. if (value === 60) value = 0;
  8680. }
  8681. } else {
  8682. if (isHours) {
  8683. if (value === 12) {
  8684. value = 0;
  8685. }
  8686. value = inner ? value === 0 ? 12 : value : value === 0 ? 0 : value + 12;
  8687. } else {
  8688. if (roundBy5) {
  8689. value *= 5;
  8690. }
  8691. if (value === 60) {
  8692. value = 0;
  8693. }
  8694. }
  8695. }
  8696. // Once hours or minutes changed, vibrate the device
  8697. if (this[this.currentView] !== value) {
  8698. if (this.vibrate && this.options.vibrate) {
  8699. // Do not vibrate too frequently
  8700. if (!this.vibrateTimer) {
  8701. navigator[this.vibrate](10);
  8702. this.vibrateTimer = setTimeout(function () {
  8703. _this60.vibrateTimer = null;
  8704. }, 100);
  8705. }
  8706. }
  8707. }
  8708. this[this.currentView] = value;
  8709. if (isHours) {
  8710. this['spanHours'].innerHTML = value;
  8711. } else {
  8712. this['spanMinutes'].innerHTML = Timepicker._addLeadingZero(value);
  8713. }
  8714. // Set clock hand and others' position
  8715. var cx1 = Math.sin(radian) * (radius - this.options.tickRadius),
  8716. cy1 = -Math.cos(radian) * (radius - this.options.tickRadius),
  8717. cx2 = Math.sin(radian) * radius,
  8718. cy2 = -Math.cos(radian) * radius;
  8719. this.hand.setAttribute('x2', cx1);
  8720. this.hand.setAttribute('y2', cy1);
  8721. this.bg.setAttribute('cx', cx2);
  8722. this.bg.setAttribute('cy', cy2);
  8723. }
  8724. }, {
  8725. key: "open",
  8726. value: function open() {
  8727. if (this.isOpen) {
  8728. return;
  8729. }
  8730. this.isOpen = true;
  8731. this._updateTimeFromInput();
  8732. this.showView('hours');
  8733. this.modal.open();
  8734. }
  8735. }, {
  8736. key: "close",
  8737. value: function close() {
  8738. if (!this.isOpen) {
  8739. return;
  8740. }
  8741. this.isOpen = false;
  8742. this.modal.close();
  8743. }
  8744. /**
  8745. * Finish timepicker selection.
  8746. */
  8747. }, {
  8748. key: "done",
  8749. value: function done(e, clearValue) {
  8750. // Set input value
  8751. var last = this.el.value;
  8752. var value = clearValue ? '' : Timepicker._addLeadingZero(this.hours) + ':' + Timepicker._addLeadingZero(this.minutes);
  8753. this.time = value;
  8754. if (!clearValue && this.options.twelveHour) {
  8755. value = value + " " + this.amOrPm;
  8756. }
  8757. this.el.value = value;
  8758. // Trigger change event
  8759. if (value !== last) {
  8760. this.$el.trigger('change');
  8761. }
  8762. this.close();
  8763. this.el.focus();
  8764. }
  8765. }, {
  8766. key: "clear",
  8767. value: function clear() {
  8768. this.done(null, true);
  8769. }
  8770. }], [{
  8771. key: "init",
  8772. value: function init(els, options) {
  8773. return _get(Timepicker.__proto__ || Object.getPrototypeOf(Timepicker), "init", this).call(this, this, els, options);
  8774. }
  8775. }, {
  8776. key: "_addLeadingZero",
  8777. value: function _addLeadingZero(num) {
  8778. return (num < 10 ? '0' : '') + num;
  8779. }
  8780. }, {
  8781. key: "_createSVGEl",
  8782. value: function _createSVGEl(name) {
  8783. var svgNS = 'http://www.w3.org/2000/svg';
  8784. return document.createElementNS(svgNS, name);
  8785. }
  8786. /**
  8787. * @typedef {Object} Point
  8788. * @property {number} x The X Coordinate
  8789. * @property {number} y The Y Coordinate
  8790. */
  8791. /**
  8792. * Get x position of mouse or touch event
  8793. * @param {Event} e
  8794. * @return {Point} x and y location
  8795. */
  8796. }, {
  8797. key: "_Pos",
  8798. value: function _Pos(e) {
  8799. if (e.targetTouches && e.targetTouches.length >= 1) {
  8800. return { x: e.targetTouches[0].clientX, y: e.targetTouches[0].clientY };
  8801. }
  8802. // mouse event
  8803. return { x: e.clientX, y: e.clientY };
  8804. }
  8805. /**
  8806. * Get Instance
  8807. */
  8808. }, {
  8809. key: "getInstance",
  8810. value: function getInstance(el) {
  8811. var domElem = !!el.jquery ? el[0] : el;
  8812. return domElem.M_Timepicker;
  8813. }
  8814. }, {
  8815. key: "defaults",
  8816. get: function () {
  8817. return _defaults;
  8818. }
  8819. }]);
  8820. return Timepicker;
  8821. }(Component);
  8822. Timepicker._template = ['<div class= "modal timepicker-modal">', '<div class="modal-content timepicker-container">', '<div class="timepicker-digital-display">', '<div class="timepicker-text-container">', '<div class="timepicker-display-column">', '<span class="timepicker-span-hours text-primary"></span>', ':', '<span class="timepicker-span-minutes"></span>', '</div>', '<div class="timepicker-display-column timepicker-display-am-pm">', '<div class="timepicker-span-am-pm"></div>', '</div>', '</div>', '</div>', '<div class="timepicker-analog-display">', '<div class="timepicker-plate">', '<div class="timepicker-canvas"></div>', '<div class="timepicker-dial timepicker-hours"></div>', '<div class="timepicker-dial timepicker-minutes timepicker-dial-out"></div>', '</div>', '<div class="timepicker-footer"></div>', '</div>', '</div>', '</div>'].join('');
  8823. M.Timepicker = Timepicker;
  8824. if (M.jQueryLoaded) {
  8825. M.initializeJqueryWrapper(Timepicker, 'timepicker', 'M_Timepicker');
  8826. }
  8827. })(cash);
  8828. ;(function ($) {
  8829. 'use strict';
  8830. var _defaults = {};
  8831. /**
  8832. * @class
  8833. *
  8834. */
  8835. var CharacterCounter = function (_Component17) {
  8836. _inherits(CharacterCounter, _Component17);
  8837. /**
  8838. * Construct CharacterCounter instance
  8839. * @constructor
  8840. * @param {Element} el
  8841. * @param {Object} options
  8842. */
  8843. function CharacterCounter(el, options) {
  8844. _classCallCheck(this, CharacterCounter);
  8845. var _this61 = _possibleConstructorReturn(this, (CharacterCounter.__proto__ || Object.getPrototypeOf(CharacterCounter)).call(this, CharacterCounter, el, options));
  8846. _this61.el.M_CharacterCounter = _this61;
  8847. /**
  8848. * Options for the character counter
  8849. */
  8850. _this61.options = $.extend({}, CharacterCounter.defaults, options);
  8851. _this61.isInvalid = false;
  8852. _this61.isValidLength = false;
  8853. _this61._setupCounter();
  8854. _this61._setupEventHandlers();
  8855. return _this61;
  8856. }
  8857. _createClass(CharacterCounter, [{
  8858. key: "destroy",
  8859. /**
  8860. * Teardown component
  8861. */
  8862. value: function destroy() {
  8863. this._removeEventHandlers();
  8864. this.el.CharacterCounter = undefined;
  8865. this._removeCounter();
  8866. }
  8867. /**
  8868. * Setup Event Handlers
  8869. */
  8870. }, {
  8871. key: "_setupEventHandlers",
  8872. value: function _setupEventHandlers() {
  8873. this._handleUpdateCounterBound = this.updateCounter.bind(this);
  8874. this.el.addEventListener('focus', this._handleUpdateCounterBound, true);
  8875. this.el.addEventListener('input', this._handleUpdateCounterBound, true);
  8876. }
  8877. /**
  8878. * Remove Event Handlers
  8879. */
  8880. }, {
  8881. key: "_removeEventHandlers",
  8882. value: function _removeEventHandlers() {
  8883. this.el.removeEventListener('focus', this._handleUpdateCounterBound, true);
  8884. this.el.removeEventListener('input', this._handleUpdateCounterBound, true);
  8885. }
  8886. /**
  8887. * Setup counter element
  8888. */
  8889. }, {
  8890. key: "_setupCounter",
  8891. value: function _setupCounter() {
  8892. this.counterEl = document.createElement('span');
  8893. $(this.counterEl).addClass('character-counter').css({
  8894. float: 'right',
  8895. 'font-size': '12px',
  8896. height: 1
  8897. });
  8898. this.$el.parent().append(this.counterEl);
  8899. }
  8900. /**
  8901. * Remove counter element
  8902. */
  8903. }, {
  8904. key: "_removeCounter",
  8905. value: function _removeCounter() {
  8906. $(this.counterEl).remove();
  8907. }
  8908. /**
  8909. * Update counter
  8910. */
  8911. }, {
  8912. key: "updateCounter",
  8913. value: function updateCounter() {
  8914. var maxLength = +this.$el.attr('data-length'),
  8915. actualLength = this.el.value.length;
  8916. this.isValidLength = actualLength <= maxLength;
  8917. var counterString = actualLength;
  8918. if (maxLength) {
  8919. counterString += '/' + maxLength;
  8920. this._validateInput();
  8921. }
  8922. $(this.counterEl).html(counterString);
  8923. }
  8924. /**
  8925. * Add validation classes
  8926. */
  8927. }, {
  8928. key: "_validateInput",
  8929. value: function _validateInput() {
  8930. if (this.isValidLength && this.isInvalid) {
  8931. this.isInvalid = false;
  8932. this.$el.removeClass('invalid');
  8933. } else if (!this.isValidLength && !this.isInvalid) {
  8934. this.isInvalid = true;
  8935. this.$el.removeClass('valid');
  8936. this.$el.addClass('invalid');
  8937. }
  8938. }
  8939. }], [{
  8940. key: "init",
  8941. value: function init(els, options) {
  8942. return _get(CharacterCounter.__proto__ || Object.getPrototypeOf(CharacterCounter), "init", this).call(this, this, els, options);
  8943. }
  8944. /**
  8945. * Get Instance
  8946. */
  8947. }, {
  8948. key: "getInstance",
  8949. value: function getInstance(el) {
  8950. var domElem = !!el.jquery ? el[0] : el;
  8951. return domElem.M_CharacterCounter;
  8952. }
  8953. }, {
  8954. key: "defaults",
  8955. get: function () {
  8956. return _defaults;
  8957. }
  8958. }]);
  8959. return CharacterCounter;
  8960. }(Component);
  8961. M.CharacterCounter = CharacterCounter;
  8962. if (M.jQueryLoaded) {
  8963. M.initializeJqueryWrapper(CharacterCounter, 'characterCounter', 'M_CharacterCounter');
  8964. }
  8965. })(cash);
  8966. ;(function ($) {
  8967. 'use strict';
  8968. var _defaults = {
  8969. duration: 200, // ms
  8970. dist: -100, // zoom scale TODO: make this more intuitive as an option
  8971. shift: 0, // spacing for center image
  8972. padding: 0, // Padding between non center items
  8973. numVisible: 5, // Number of visible items in carousel
  8974. fullWidth: false, // Change to full width styles
  8975. indicators: false, // Toggle indicators
  8976. noWrap: false, // Don't wrap around and cycle through items.
  8977. onCycleTo: null // Callback for when a new slide is cycled to.
  8978. };
  8979. /**
  8980. * @class
  8981. *
  8982. */
  8983. var Carousel = function (_Component18) {
  8984. _inherits(Carousel, _Component18);
  8985. /**
  8986. * Construct Carousel instance
  8987. * @constructor
  8988. * @param {Element} el
  8989. * @param {Object} options
  8990. */
  8991. function Carousel(el, options) {
  8992. _classCallCheck(this, Carousel);
  8993. var _this62 = _possibleConstructorReturn(this, (Carousel.__proto__ || Object.getPrototypeOf(Carousel)).call(this, Carousel, el, options));
  8994. _this62.el.M_Carousel = _this62;
  8995. /**
  8996. * Options for the carousel
  8997. * @member Carousel#options
  8998. * @prop {Number} duration
  8999. * @prop {Number} dist
  9000. * @prop {Number} shift
  9001. * @prop {Number} padding
  9002. * @prop {Number} numVisible
  9003. * @prop {Boolean} fullWidth
  9004. * @prop {Boolean} indicators
  9005. * @prop {Boolean} noWrap
  9006. * @prop {Function} onCycleTo
  9007. */
  9008. _this62.options = $.extend({}, Carousel.defaults, options);
  9009. // Setup
  9010. _this62.hasMultipleSlides = _this62.$el.find('.carousel-item').length > 1;
  9011. _this62.showIndicators = _this62.options.indicators && _this62.hasMultipleSlides;
  9012. _this62.noWrap = _this62.options.noWrap || !_this62.hasMultipleSlides;
  9013. _this62.pressed = false;
  9014. _this62.dragged = false;
  9015. _this62.offset = _this62.target = 0;
  9016. _this62.images = [];
  9017. _this62.itemWidth = _this62.$el.find('.carousel-item').first().innerWidth();
  9018. _this62.itemHeight = _this62.$el.find('.carousel-item').first().innerHeight();
  9019. _this62.dim = _this62.itemWidth * 2 + _this62.options.padding || 1; // Make sure dim is non zero for divisions.
  9020. _this62._autoScrollBound = _this62._autoScroll.bind(_this62);
  9021. _this62._trackBound = _this62._track.bind(_this62);
  9022. // Full Width carousel setup
  9023. if (_this62.options.fullWidth) {
  9024. _this62.options.dist = 0;
  9025. _this62._setCarouselHeight();
  9026. // Offset fixed items when indicators.
  9027. if (_this62.showIndicators) {
  9028. _this62.$el.find('.carousel-fixed-item').addClass('with-indicators');
  9029. }
  9030. }
  9031. // Iterate through slides
  9032. _this62.$indicators = $('<ul class="indicators"></ul>');
  9033. _this62.$el.find('.carousel-item').each(function (el, i) {
  9034. _this62.images.push(el);
  9035. if (_this62.showIndicators) {
  9036. var $indicator = $('<li class="indicator-item"></li>');
  9037. // Add active to first by default.
  9038. if (i === 0) {
  9039. $indicator[0].classList.add('active');
  9040. }
  9041. _this62.$indicators.append($indicator);
  9042. }
  9043. });
  9044. if (_this62.showIndicators) {
  9045. _this62.$el.append(_this62.$indicators);
  9046. }
  9047. _this62.count = _this62.images.length;
  9048. // Cap numVisible at count
  9049. _this62.options.numVisible = Math.min(_this62.count, _this62.options.numVisible);
  9050. // Setup cross browser string
  9051. _this62.xform = 'transform';
  9052. ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) {
  9053. var e = prefix + 'Transform';
  9054. if (typeof document.body.style[e] !== 'undefined') {
  9055. _this62.xform = e;
  9056. return false;
  9057. }
  9058. return true;
  9059. });
  9060. _this62._setupEventHandlers();
  9061. _this62._scroll(_this62.offset);
  9062. return _this62;
  9063. }
  9064. _createClass(Carousel, [{
  9065. key: "destroy",
  9066. /**
  9067. * Teardown component
  9068. */
  9069. value: function destroy() {
  9070. this._removeEventHandlers();
  9071. this.el.M_Carousel = undefined;
  9072. }
  9073. /**
  9074. * Setup Event Handlers
  9075. */
  9076. }, {
  9077. key: "_setupEventHandlers",
  9078. value: function _setupEventHandlers() {
  9079. var _this63 = this;
  9080. this._handleCarouselTapBound = this._handleCarouselTap.bind(this);
  9081. this._handleCarouselDragBound = this._handleCarouselDrag.bind(this);
  9082. this._handleCarouselReleaseBound = this._handleCarouselRelease.bind(this);
  9083. this._handleCarouselClickBound = this._handleCarouselClick.bind(this);
  9084. if (typeof window.ontouchstart !== 'undefined') {
  9085. this.el.addEventListener('touchstart', this._handleCarouselTapBound);
  9086. this.el.addEventListener('touchmove', this._handleCarouselDragBound);
  9087. this.el.addEventListener('touchend', this._handleCarouselReleaseBound);
  9088. }
  9089. this.el.addEventListener('mousedown', this._handleCarouselTapBound);
  9090. this.el.addEventListener('mousemove', this._handleCarouselDragBound);
  9091. this.el.addEventListener('mouseup', this._handleCarouselReleaseBound);
  9092. this.el.addEventListener('mouseleave', this._handleCarouselReleaseBound);
  9093. this.el.addEventListener('click', this._handleCarouselClickBound);
  9094. if (this.showIndicators && this.$indicators) {
  9095. this._handleIndicatorClickBound = this._handleIndicatorClick.bind(this);
  9096. this.$indicators.find('.indicator-item').each(function (el, i) {
  9097. el.addEventListener('click', _this63._handleIndicatorClickBound);
  9098. });
  9099. }
  9100. // Resize
  9101. var throttledResize = M.throttle(this._handleResize, 200);
  9102. this._handleThrottledResizeBound = throttledResize.bind(this);
  9103. window.addEventListener('resize', this._handleThrottledResizeBound);
  9104. }
  9105. /**
  9106. * Remove Event Handlers
  9107. */
  9108. }, {
  9109. key: "_removeEventHandlers",
  9110. value: function _removeEventHandlers() {
  9111. var _this64 = this;
  9112. if (typeof window.ontouchstart !== 'undefined') {
  9113. this.el.removeEventListener('touchstart', this._handleCarouselTapBound);
  9114. this.el.removeEventListener('touchmove', this._handleCarouselDragBound);
  9115. this.el.removeEventListener('touchend', this._handleCarouselReleaseBound);
  9116. }
  9117. this.el.removeEventListener('mousedown', this._handleCarouselTapBound);
  9118. this.el.removeEventListener('mousemove', this._handleCarouselDragBound);
  9119. this.el.removeEventListener('mouseup', this._handleCarouselReleaseBound);
  9120. this.el.removeEventListener('mouseleave', this._handleCarouselReleaseBound);
  9121. this.el.removeEventListener('click', this._handleCarouselClickBound);
  9122. if (this.showIndicators && this.$indicators) {
  9123. this.$indicators.find('.indicator-item').each(function (el, i) {
  9124. el.removeEventListener('click', _this64._handleIndicatorClickBound);
  9125. });
  9126. }
  9127. window.removeEventListener('resize', this._handleThrottledResizeBound);
  9128. }
  9129. /**
  9130. * Handle Carousel Tap
  9131. * @param {Event} e
  9132. */
  9133. }, {
  9134. key: "_handleCarouselTap",
  9135. value: function _handleCarouselTap(e) {
  9136. // Fixes firefox draggable image bug
  9137. if (e.type === 'mousedown' && $(e.target).is('img')) {
  9138. e.preventDefault();
  9139. }
  9140. this.pressed = true;
  9141. this.dragged = false;
  9142. this.verticalDragged = false;
  9143. this.reference = this._xpos(e);
  9144. this.referenceY = this._ypos(e);
  9145. this.velocity = this.amplitude = 0;
  9146. this.frame = this.offset;
  9147. this.timestamp = Date.now();
  9148. clearInterval(this.ticker);
  9149. this.ticker = setInterval(this._trackBound, 100);
  9150. }
  9151. /**
  9152. * Handle Carousel Drag
  9153. * @param {Event} e
  9154. */
  9155. }, {
  9156. key: "_handleCarouselDrag",
  9157. value: function _handleCarouselDrag(e) {
  9158. var x = void 0,
  9159. y = void 0,
  9160. delta = void 0,
  9161. deltaY = void 0;
  9162. if (this.pressed) {
  9163. x = this._xpos(e);
  9164. y = this._ypos(e);
  9165. delta = this.reference - x;
  9166. deltaY = Math.abs(this.referenceY - y);
  9167. if (deltaY < 30 && !this.verticalDragged) {
  9168. // If vertical scrolling don't allow dragging.
  9169. if (delta > 2 || delta < -2) {
  9170. this.dragged = true;
  9171. this.reference = x;
  9172. this._scroll(this.offset + delta);
  9173. }
  9174. } else if (this.dragged) {
  9175. // If dragging don't allow vertical scroll.
  9176. e.preventDefault();
  9177. e.stopPropagation();
  9178. return false;
  9179. } else {
  9180. // Vertical scrolling.
  9181. this.verticalDragged = true;
  9182. }
  9183. }
  9184. if (this.dragged) {
  9185. // If dragging don't allow vertical scroll.
  9186. e.preventDefault();
  9187. e.stopPropagation();
  9188. return false;
  9189. }
  9190. }
  9191. /**
  9192. * Handle Carousel Release
  9193. * @param {Event} e
  9194. */
  9195. }, {
  9196. key: "_handleCarouselRelease",
  9197. value: function _handleCarouselRelease(e) {
  9198. if (this.pressed) {
  9199. this.pressed = false;
  9200. } else {
  9201. return;
  9202. }
  9203. clearInterval(this.ticker);
  9204. this.target = this.offset;
  9205. if (this.velocity > 10 || this.velocity < -10) {
  9206. this.amplitude = 0.9 * this.velocity;
  9207. this.target = this.offset + this.amplitude;
  9208. }
  9209. this.target = Math.round(this.target / this.dim) * this.dim;
  9210. // No wrap of items.
  9211. if (this.noWrap) {
  9212. if (this.target >= this.dim * (this.count - 1)) {
  9213. this.target = this.dim * (this.count - 1);
  9214. } else if (this.target < 0) {
  9215. this.target = 0;
  9216. }
  9217. }
  9218. this.amplitude = this.target - this.offset;
  9219. this.timestamp = Date.now();
  9220. requestAnimationFrame(this._autoScrollBound);
  9221. if (this.dragged) {
  9222. e.preventDefault();
  9223. e.stopPropagation();
  9224. }
  9225. return false;
  9226. }
  9227. /**
  9228. * Handle Carousel CLick
  9229. * @param {Event} e
  9230. */
  9231. }, {
  9232. key: "_handleCarouselClick",
  9233. value: function _handleCarouselClick(e) {
  9234. // Disable clicks if carousel was dragged.
  9235. if (this.dragged) {
  9236. e.preventDefault();
  9237. e.stopPropagation();
  9238. return false;
  9239. } else if (!this.options.fullWidth) {
  9240. var clickedIndex = $(e.target).closest('.carousel-item').index();
  9241. var diff = this._wrap(this.center) - clickedIndex;
  9242. // Disable clicks if carousel was shifted by click
  9243. if (diff !== 0) {
  9244. e.preventDefault();
  9245. e.stopPropagation();
  9246. }
  9247. this._cycleTo(clickedIndex);
  9248. }
  9249. }
  9250. /**
  9251. * Handle Indicator CLick
  9252. * @param {Event} e
  9253. */
  9254. }, {
  9255. key: "_handleIndicatorClick",
  9256. value: function _handleIndicatorClick(e) {
  9257. e.stopPropagation();
  9258. var indicator = $(e.target).closest('.indicator-item');
  9259. if (indicator.length) {
  9260. this._cycleTo(indicator.index());
  9261. }
  9262. }
  9263. /**
  9264. * Handle Throttle Resize
  9265. * @param {Event} e
  9266. */
  9267. }, {
  9268. key: "_handleResize",
  9269. value: function _handleResize(e) {
  9270. if (this.options.fullWidth) {
  9271. this.itemWidth = this.$el.find('.carousel-item').first().innerWidth();
  9272. this.imageHeight = this.$el.find('.carousel-item.active').height();
  9273. this.dim = this.itemWidth * 2 + this.options.padding;
  9274. this.offset = this.center * 2 * this.itemWidth;
  9275. this.target = this.offset;
  9276. this._setCarouselHeight(true);
  9277. } else {
  9278. this._scroll();
  9279. }
  9280. }
  9281. /**
  9282. * Set carousel height based on first slide
  9283. * @param {Booleam} imageOnly - true for image slides
  9284. */
  9285. }, {
  9286. key: "_setCarouselHeight",
  9287. value: function _setCarouselHeight(imageOnly) {
  9288. var _this65 = this;
  9289. var firstSlide = this.$el.find('.carousel-item.active').length ? this.$el.find('.carousel-item.active').first() : this.$el.find('.carousel-item').first();
  9290. var firstImage = firstSlide.find('img').first();
  9291. if (firstImage.length) {
  9292. if (firstImage[0].complete) {
  9293. // If image won't trigger the load event
  9294. var imageHeight = firstImage.height();
  9295. if (imageHeight > 0) {
  9296. this.$el.css('height', imageHeight + 'px');
  9297. } else {
  9298. // If image still has no height, use the natural dimensions to calculate
  9299. var naturalWidth = firstImage[0].naturalWidth;
  9300. var naturalHeight = firstImage[0].naturalHeight;
  9301. var adjustedHeight = this.$el.width() / naturalWidth * naturalHeight;
  9302. this.$el.css('height', adjustedHeight + 'px');
  9303. }
  9304. } else {
  9305. // Get height when image is loaded normally
  9306. firstImage.one('load', function (el, i) {
  9307. _this65.$el.css('height', el.offsetHeight + 'px');
  9308. });
  9309. }
  9310. } else if (!imageOnly) {
  9311. var slideHeight = firstSlide.height();
  9312. this.$el.css('height', slideHeight + 'px');
  9313. }
  9314. }
  9315. /**
  9316. * Get x position from event
  9317. * @param {Event} e
  9318. */
  9319. }, {
  9320. key: "_xpos",
  9321. value: function _xpos(e) {
  9322. // touch event
  9323. if (e.targetTouches && e.targetTouches.length >= 1) {
  9324. return e.targetTouches[0].clientX;
  9325. }
  9326. // mouse event
  9327. return e.clientX;
  9328. }
  9329. /**
  9330. * Get y position from event
  9331. * @param {Event} e
  9332. */
  9333. }, {
  9334. key: "_ypos",
  9335. value: function _ypos(e) {
  9336. // touch event
  9337. if (e.targetTouches && e.targetTouches.length >= 1) {
  9338. return e.targetTouches[0].clientY;
  9339. }
  9340. // mouse event
  9341. return e.clientY;
  9342. }
  9343. /**
  9344. * Wrap index
  9345. * @param {Number} x
  9346. */
  9347. }, {
  9348. key: "_wrap",
  9349. value: function _wrap(x) {
  9350. return x >= this.count ? x % this.count : x < 0 ? this._wrap(this.count + x % this.count) : x;
  9351. }
  9352. /**
  9353. * Tracks scrolling information
  9354. */
  9355. }, {
  9356. key: "_track",
  9357. value: function _track() {
  9358. var now = void 0,
  9359. elapsed = void 0,
  9360. delta = void 0,
  9361. v = void 0;
  9362. now = Date.now();
  9363. elapsed = now - this.timestamp;
  9364. this.timestamp = now;
  9365. delta = this.offset - this.frame;
  9366. this.frame = this.offset;
  9367. v = 1000 * delta / (1 + elapsed);
  9368. this.velocity = 0.8 * v + 0.2 * this.velocity;
  9369. }
  9370. /**
  9371. * Auto scrolls to nearest carousel item.
  9372. */
  9373. }, {
  9374. key: "_autoScroll",
  9375. value: function _autoScroll() {
  9376. var elapsed = void 0,
  9377. delta = void 0;
  9378. if (this.amplitude) {
  9379. elapsed = Date.now() - this.timestamp;
  9380. delta = this.amplitude * Math.exp(-elapsed / this.options.duration);
  9381. if (delta > 2 || delta < -2) {
  9382. this._scroll(this.target - delta);
  9383. requestAnimationFrame(this._autoScrollBound);
  9384. } else {
  9385. this._scroll(this.target);
  9386. }
  9387. }
  9388. }
  9389. /**
  9390. * Scroll to target
  9391. * @param {Number} x
  9392. */
  9393. }, {
  9394. key: "_scroll",
  9395. value: function _scroll(x) {
  9396. var _this66 = this;
  9397. // Track scrolling state
  9398. if (!this.$el.hasClass('scrolling')) {
  9399. this.el.classList.add('scrolling');
  9400. }
  9401. if (this.scrollingTimeout != null) {
  9402. window.clearTimeout(this.scrollingTimeout);
  9403. }
  9404. this.scrollingTimeout = window.setTimeout(function () {
  9405. _this66.$el.removeClass('scrolling');
  9406. }, this.options.duration);
  9407. // Start actual scroll
  9408. var i = void 0,
  9409. half = void 0,
  9410. delta = void 0,
  9411. dir = void 0,
  9412. tween = void 0,
  9413. el = void 0,
  9414. alignment = void 0,
  9415. zTranslation = void 0,
  9416. tweenedOpacity = void 0,
  9417. centerTweenedOpacity = void 0;
  9418. var lastCenter = this.center;
  9419. var numVisibleOffset = 1 / this.options.numVisible;
  9420. this.offset = typeof x === 'number' ? x : this.offset;
  9421. this.center = Math.floor((this.offset + this.dim / 2) / this.dim);
  9422. delta = this.offset - this.center * this.dim;
  9423. dir = delta < 0 ? 1 : -1;
  9424. tween = -dir * delta * 2 / this.dim;
  9425. half = this.count >> 1;
  9426. if (this.options.fullWidth) {
  9427. alignment = 'translateX(0)';
  9428. centerTweenedOpacity = 1;
  9429. } else {
  9430. alignment = 'translateX(' + (this.el.clientWidth - this.itemWidth) / 2 + 'px) ';
  9431. alignment += 'translateY(' + (this.el.clientHeight - this.itemHeight) / 2 + 'px)';
  9432. centerTweenedOpacity = 1 - numVisibleOffset * tween;
  9433. }
  9434. // Set indicator active
  9435. if (this.showIndicators) {
  9436. var diff = this.center % this.count;
  9437. var activeIndicator = this.$indicators.find('.indicator-item.active');
  9438. if (activeIndicator.index() !== diff) {
  9439. activeIndicator.removeClass('active');
  9440. this.$indicators.find('.indicator-item').eq(diff)[0].classList.add('active');
  9441. }
  9442. }
  9443. // center
  9444. // Don't show wrapped items.
  9445. if (!this.noWrap || this.center >= 0 && this.center < this.count) {
  9446. el = this.images[this._wrap(this.center)];
  9447. // Add active class to center item.
  9448. if (!$(el).hasClass('active')) {
  9449. this.$el.find('.carousel-item').removeClass('active');
  9450. el.classList.add('active');
  9451. }
  9452. var transformString = alignment + " translateX(" + -delta / 2 + "px) translateX(" + dir * this.options.shift * tween * i + "px) translateZ(" + this.options.dist * tween + "px)";
  9453. this._updateItemStyle(el, centerTweenedOpacity, 0, transformString);
  9454. }
  9455. for (i = 1; i <= half; ++i) {
  9456. // right side
  9457. if (this.options.fullWidth) {
  9458. zTranslation = this.options.dist;
  9459. tweenedOpacity = i === half && delta < 0 ? 1 - tween : 1;
  9460. } else {
  9461. zTranslation = this.options.dist * (i * 2 + tween * dir);
  9462. tweenedOpacity = 1 - numVisibleOffset * (i * 2 + tween * dir);
  9463. }
  9464. // Don't show wrapped items.
  9465. if (!this.noWrap || this.center + i < this.count) {
  9466. el = this.images[this._wrap(this.center + i)];
  9467. var _transformString = alignment + " translateX(" + (this.options.shift + (this.dim * i - delta) / 2) + "px) translateZ(" + zTranslation + "px)";
  9468. this._updateItemStyle(el, tweenedOpacity, -i, _transformString);
  9469. }
  9470. // left side
  9471. if (this.options.fullWidth) {
  9472. zTranslation = this.options.dist;
  9473. tweenedOpacity = i === half && delta > 0 ? 1 - tween : 1;
  9474. } else {
  9475. zTranslation = this.options.dist * (i * 2 - tween * dir);
  9476. tweenedOpacity = 1 - numVisibleOffset * (i * 2 - tween * dir);
  9477. }
  9478. // Don't show wrapped items.
  9479. if (!this.noWrap || this.center - i >= 0) {
  9480. el = this.images[this._wrap(this.center - i)];
  9481. var _transformString2 = alignment + " translateX(" + (-this.options.shift + (-this.dim * i - delta) / 2) + "px) translateZ(" + zTranslation + "px)";
  9482. this._updateItemStyle(el, tweenedOpacity, -i, _transformString2);
  9483. }
  9484. }
  9485. // center
  9486. // Don't show wrapped items.
  9487. if (!this.noWrap || this.center >= 0 && this.center < this.count) {
  9488. el = this.images[this._wrap(this.center)];
  9489. var _transformString3 = alignment + " translateX(" + -delta / 2 + "px) translateX(" + dir * this.options.shift * tween + "px) translateZ(" + this.options.dist * tween + "px)";
  9490. this._updateItemStyle(el, centerTweenedOpacity, 0, _transformString3);
  9491. }
  9492. // onCycleTo callback
  9493. var $currItem = this.$el.find('.carousel-item').eq(this._wrap(this.center));
  9494. if (lastCenter !== this.center && typeof this.options.onCycleTo === 'function') {
  9495. this.options.onCycleTo.call(this, $currItem[0], this.dragged);
  9496. }
  9497. // One time callback
  9498. if (typeof this.oneTimeCallback === 'function') {
  9499. this.oneTimeCallback.call(this, $currItem[0], this.dragged);
  9500. this.oneTimeCallback = null;
  9501. }
  9502. }
  9503. /**
  9504. * Cycle to target
  9505. * @param {Element} el
  9506. * @param {Number} opacity
  9507. * @param {Number} zIndex
  9508. * @param {String} transform
  9509. */
  9510. }, {
  9511. key: "_updateItemStyle",
  9512. value: function _updateItemStyle(el, opacity, zIndex, transform) {
  9513. el.style[this.xform] = transform;
  9514. el.style.zIndex = zIndex;
  9515. el.style.opacity = opacity;
  9516. el.style.visibility = 'visible';
  9517. }
  9518. /**
  9519. * Cycle to target
  9520. * @param {Number} n
  9521. * @param {Function} callback
  9522. */
  9523. }, {
  9524. key: "_cycleTo",
  9525. value: function _cycleTo(n, callback) {
  9526. var diff = this.center % this.count - n;
  9527. // Account for wraparound.
  9528. if (!this.noWrap) {
  9529. if (diff < 0) {
  9530. if (Math.abs(diff + this.count) < Math.abs(diff)) {
  9531. diff += this.count;
  9532. }
  9533. } else if (diff > 0) {
  9534. if (Math.abs(diff - this.count) < diff) {
  9535. diff -= this.count;
  9536. }
  9537. }
  9538. }
  9539. this.target = this.dim * Math.round(this.offset / this.dim);
  9540. // Next
  9541. if (diff < 0) {
  9542. this.target += this.dim * Math.abs(diff);
  9543. // Prev
  9544. } else if (diff > 0) {
  9545. this.target -= this.dim * diff;
  9546. }
  9547. // Set one time callback
  9548. if (typeof callback === 'function') {
  9549. this.oneTimeCallback = callback;
  9550. }
  9551. // Scroll
  9552. if (this.offset !== this.target) {
  9553. this.amplitude = this.target - this.offset;
  9554. this.timestamp = Date.now();
  9555. requestAnimationFrame(this._autoScrollBound);
  9556. }
  9557. }
  9558. /**
  9559. * Cycle to next item
  9560. * @param {Number} [n]
  9561. */
  9562. }, {
  9563. key: "next",
  9564. value: function next(n) {
  9565. if (n === undefined || isNaN(n)) {
  9566. n = 1;
  9567. }
  9568. var index = this.center + n;
  9569. if (index >= this.count || index < 0) {
  9570. if (this.noWrap) {
  9571. return;
  9572. }
  9573. index = this._wrap(index);
  9574. }
  9575. this._cycleTo(index);
  9576. }
  9577. /**
  9578. * Cycle to previous item
  9579. * @param {Number} [n]
  9580. */
  9581. }, {
  9582. key: "prev",
  9583. value: function prev(n) {
  9584. if (n === undefined || isNaN(n)) {
  9585. n = 1;
  9586. }
  9587. var index = this.center - n;
  9588. if (index >= this.count || index < 0) {
  9589. if (this.noWrap) {
  9590. return;
  9591. }
  9592. index = this._wrap(index);
  9593. }
  9594. this._cycleTo(index);
  9595. }
  9596. /**
  9597. * Cycle to nth item
  9598. * @param {Number} [n]
  9599. * @param {Function} callback
  9600. */
  9601. }, {
  9602. key: "set",
  9603. value: function set(n, callback) {
  9604. if (n === undefined || isNaN(n)) {
  9605. n = 0;
  9606. }
  9607. if (n > this.count || n < 0) {
  9608. if (this.noWrap) {
  9609. return;
  9610. }
  9611. n = this._wrap(n);
  9612. }
  9613. this._cycleTo(n, callback);
  9614. }
  9615. }], [{
  9616. key: "init",
  9617. value: function init(els, options) {
  9618. return _get(Carousel.__proto__ || Object.getPrototypeOf(Carousel), "init", this).call(this, this, els, options);
  9619. }
  9620. /**
  9621. * Get Instance
  9622. */
  9623. }, {
  9624. key: "getInstance",
  9625. value: function getInstance(el) {
  9626. var domElem = !!el.jquery ? el[0] : el;
  9627. return domElem.M_Carousel;
  9628. }
  9629. }, {
  9630. key: "defaults",
  9631. get: function () {
  9632. return _defaults;
  9633. }
  9634. }]);
  9635. return Carousel;
  9636. }(Component);
  9637. M.Carousel = Carousel;
  9638. if (M.jQueryLoaded) {
  9639. M.initializeJqueryWrapper(Carousel, 'carousel', 'M_Carousel');
  9640. }
  9641. })(cash);
  9642. ;(function ($) {
  9643. 'use strict';
  9644. var _defaults = {
  9645. onOpen: undefined,
  9646. onClose: undefined
  9647. };
  9648. /**
  9649. * @class
  9650. *
  9651. */
  9652. var TapTarget = function (_Component19) {
  9653. _inherits(TapTarget, _Component19);
  9654. /**
  9655. * Construct TapTarget instance
  9656. * @constructor
  9657. * @param {Element} el
  9658. * @param {Object} options
  9659. */
  9660. function TapTarget(el, options) {
  9661. _classCallCheck(this, TapTarget);
  9662. var _this67 = _possibleConstructorReturn(this, (TapTarget.__proto__ || Object.getPrototypeOf(TapTarget)).call(this, TapTarget, el, options));
  9663. _this67.el.M_TapTarget = _this67;
  9664. /**
  9665. * Options for the select
  9666. * @member TapTarget#options
  9667. * @prop {Function} onOpen - Callback function called when feature discovery is opened
  9668. * @prop {Function} onClose - Callback function called when feature discovery is closed
  9669. */
  9670. _this67.options = $.extend({}, TapTarget.defaults, options);
  9671. _this67.isOpen = false;
  9672. // setup
  9673. _this67.$origin = $('#' + _this67.$el.attr('data-target'));
  9674. _this67._setup();
  9675. _this67._calculatePositioning();
  9676. _this67._setupEventHandlers();
  9677. return _this67;
  9678. }
  9679. _createClass(TapTarget, [{
  9680. key: "destroy",
  9681. /**
  9682. * Teardown component
  9683. */
  9684. value: function destroy() {
  9685. this._removeEventHandlers();
  9686. this.el.TapTarget = undefined;
  9687. }
  9688. /**
  9689. * Setup Event Handlers
  9690. */
  9691. }, {
  9692. key: "_setupEventHandlers",
  9693. value: function _setupEventHandlers() {
  9694. this._handleDocumentClickBound = this._handleDocumentClick.bind(this);
  9695. this._handleTargetClickBound = this._handleTargetClick.bind(this);
  9696. this._handleOriginClickBound = this._handleOriginClick.bind(this);
  9697. this.el.addEventListener('click', this._handleTargetClickBound);
  9698. this.originEl.addEventListener('click', this._handleOriginClickBound);
  9699. // Resize
  9700. var throttledResize = M.throttle(this._handleResize, 200);
  9701. this._handleThrottledResizeBound = throttledResize.bind(this);
  9702. window.addEventListener('resize', this._handleThrottledResizeBound);
  9703. }
  9704. /**
  9705. * Remove Event Handlers
  9706. */
  9707. }, {
  9708. key: "_removeEventHandlers",
  9709. value: function _removeEventHandlers() {
  9710. this.el.removeEventListener('click', this._handleTargetClickBound);
  9711. this.originEl.removeEventListener('click', this._handleOriginClickBound);
  9712. window.removeEventListener('resize', this._handleThrottledResizeBound);
  9713. }
  9714. /**
  9715. * Handle Target Click
  9716. * @param {Event} e
  9717. */
  9718. }, {
  9719. key: "_handleTargetClick",
  9720. value: function _handleTargetClick(e) {
  9721. this.open();
  9722. }
  9723. /**
  9724. * Handle Origin Click
  9725. * @param {Event} e
  9726. */
  9727. }, {
  9728. key: "_handleOriginClick",
  9729. value: function _handleOriginClick(e) {
  9730. this.close();
  9731. }
  9732. /**
  9733. * Handle Resize
  9734. * @param {Event} e
  9735. */
  9736. }, {
  9737. key: "_handleResize",
  9738. value: function _handleResize(e) {
  9739. this._calculatePositioning();
  9740. }
  9741. /**
  9742. * Handle Resize
  9743. * @param {Event} e
  9744. */
  9745. }, {
  9746. key: "_handleDocumentClick",
  9747. value: function _handleDocumentClick(e) {
  9748. if (!$(e.target).closest('.tap-target-wrapper').length) {
  9749. this.close();
  9750. e.preventDefault();
  9751. e.stopPropagation();
  9752. }
  9753. }
  9754. /**
  9755. * Setup Tap Target
  9756. */
  9757. }, {
  9758. key: "_setup",
  9759. value: function _setup() {
  9760. // Creating tap target
  9761. this.wrapper = this.$el.parent()[0];
  9762. this.waveEl = $(this.wrapper).find('.tap-target-wave')[0];
  9763. this.originEl = $(this.wrapper).find('.tap-target-origin')[0];
  9764. this.contentEl = this.$el.find('.tap-target-content')[0];
  9765. // Creating wrapper
  9766. if (!$(this.wrapper).hasClass('.tap-target-wrapper')) {
  9767. this.wrapper = document.createElement('div');
  9768. this.wrapper.classList.add('tap-target-wrapper');
  9769. this.$el.before($(this.wrapper));
  9770. this.wrapper.append(this.el);
  9771. }
  9772. // Creating content
  9773. if (!this.contentEl) {
  9774. this.contentEl = document.createElement('div');
  9775. this.contentEl.classList.add('tap-target-content');
  9776. this.$el.append(this.contentEl);
  9777. }
  9778. // Creating foreground wave
  9779. if (!this.waveEl) {
  9780. this.waveEl = document.createElement('div');
  9781. this.waveEl.classList.add('tap-target-wave');
  9782. // Creating origin
  9783. if (!this.originEl) {
  9784. this.originEl = this.$origin.clone(true, true);
  9785. this.originEl.addClass('tap-target-origin');
  9786. this.originEl.removeAttr('id');
  9787. this.originEl.removeAttr('style');
  9788. this.originEl = this.originEl[0];
  9789. this.waveEl.append(this.originEl);
  9790. }
  9791. this.wrapper.append(this.waveEl);
  9792. }
  9793. }
  9794. /**
  9795. * Calculate positioning
  9796. */
  9797. }, {
  9798. key: "_calculatePositioning",
  9799. value: function _calculatePositioning() {
  9800. // Element or parent is fixed position?
  9801. var isFixed = this.$origin.css('position') === 'fixed';
  9802. if (!isFixed) {
  9803. var parents = this.$origin.parents();
  9804. for (var i = 0; i < parents.length; i++) {
  9805. isFixed = $(parents[i]).css('position') == 'fixed';
  9806. if (isFixed) {
  9807. break;
  9808. }
  9809. }
  9810. }
  9811. // Calculating origin
  9812. var originWidth = this.$origin.outerWidth();
  9813. var originHeight = this.$origin.outerHeight();
  9814. var originTop = isFixed ? this.$origin.offset().top - M.getDocumentScrollTop() : this.$origin.offset().top;
  9815. var originLeft = isFixed ? this.$origin.offset().left - M.getDocumentScrollLeft() : this.$origin.offset().left;
  9816. // Calculating screen
  9817. var windowWidth = window.innerWidth;
  9818. var windowHeight = window.innerHeight;
  9819. var centerX = windowWidth / 2;
  9820. var centerY = windowHeight / 2;
  9821. var isLeft = originLeft <= centerX;
  9822. var isRight = originLeft > centerX;
  9823. var isTop = originTop <= centerY;
  9824. var isBottom = originTop > centerY;
  9825. var isCenterX = originLeft >= windowWidth * 0.25 && originLeft <= windowWidth * 0.75;
  9826. // Calculating tap target
  9827. var tapTargetWidth = this.$el.outerWidth();
  9828. var tapTargetHeight = this.$el.outerHeight();
  9829. var tapTargetTop = originTop + originHeight / 2 - tapTargetHeight / 2;
  9830. var tapTargetLeft = originLeft + originWidth / 2 - tapTargetWidth / 2;
  9831. var tapTargetPosition = isFixed ? 'fixed' : 'absolute';
  9832. // Calculating content
  9833. var tapTargetTextWidth = isCenterX ? tapTargetWidth : tapTargetWidth / 2 + originWidth;
  9834. var tapTargetTextHeight = tapTargetHeight / 2;
  9835. var tapTargetTextTop = isTop ? tapTargetHeight / 2 : 0;
  9836. var tapTargetTextBottom = 0;
  9837. var tapTargetTextLeft = isLeft && !isCenterX ? tapTargetWidth / 2 - originWidth : 0;
  9838. var tapTargetTextRight = 0;
  9839. var tapTargetTextPadding = originWidth;
  9840. var tapTargetTextAlign = isBottom ? 'bottom' : 'top';
  9841. // Calculating wave
  9842. var tapTargetWaveWidth = originWidth > originHeight ? originWidth * 2 : originWidth * 2;
  9843. var tapTargetWaveHeight = tapTargetWaveWidth;
  9844. var tapTargetWaveTop = tapTargetHeight / 2 - tapTargetWaveHeight / 2;
  9845. var tapTargetWaveLeft = tapTargetWidth / 2 - tapTargetWaveWidth / 2;
  9846. // Setting tap target
  9847. var tapTargetWrapperCssObj = {};
  9848. tapTargetWrapperCssObj.top = isTop ? tapTargetTop + 'px' : '';
  9849. tapTargetWrapperCssObj.right = isRight ? windowWidth - tapTargetLeft - tapTargetWidth + 'px' : '';
  9850. tapTargetWrapperCssObj.bottom = isBottom ? windowHeight - tapTargetTop - tapTargetHeight + 'px' : '';
  9851. tapTargetWrapperCssObj.left = isLeft ? tapTargetLeft + 'px' : '';
  9852. tapTargetWrapperCssObj.position = tapTargetPosition;
  9853. $(this.wrapper).css(tapTargetWrapperCssObj);
  9854. // Setting content
  9855. $(this.contentEl).css({
  9856. width: tapTargetTextWidth + 'px',
  9857. height: tapTargetTextHeight + 'px',
  9858. top: tapTargetTextTop + 'px',
  9859. right: tapTargetTextRight + 'px',
  9860. bottom: tapTargetTextBottom + 'px',
  9861. left: tapTargetTextLeft + 'px',
  9862. padding: tapTargetTextPadding + 'px',
  9863. verticalAlign: tapTargetTextAlign
  9864. });
  9865. // Setting wave
  9866. $(this.waveEl).css({
  9867. top: tapTargetWaveTop + 'px',
  9868. left: tapTargetWaveLeft + 'px',
  9869. width: tapTargetWaveWidth + 'px',
  9870. height: tapTargetWaveHeight + 'px'
  9871. });
  9872. }
  9873. /**
  9874. * Open TapTarget
  9875. */
  9876. }, {
  9877. key: "open",
  9878. value: function open() {
  9879. if (this.isOpen) {
  9880. return;
  9881. }
  9882. // onOpen callback
  9883. if (typeof this.options.onOpen === 'function') {
  9884. this.options.onOpen.call(this, this.$origin[0]);
  9885. }
  9886. this.isOpen = true;
  9887. this.wrapper.classList.add('open');
  9888. document.body.addEventListener('click', this._handleDocumentClickBound, true);
  9889. document.body.addEventListener('touchend', this._handleDocumentClickBound);
  9890. }
  9891. /**
  9892. * Close Tap Target
  9893. */
  9894. }, {
  9895. key: "close",
  9896. value: function close() {
  9897. if (!this.isOpen) {
  9898. return;
  9899. }
  9900. // onClose callback
  9901. if (typeof this.options.onClose === 'function') {
  9902. this.options.onClose.call(this, this.$origin[0]);
  9903. }
  9904. this.isOpen = false;
  9905. this.wrapper.classList.remove('open');
  9906. document.body.removeEventListener('click', this._handleDocumentClickBound, true);
  9907. document.body.removeEventListener('touchend', this._handleDocumentClickBound);
  9908. }
  9909. }], [{
  9910. key: "init",
  9911. value: function init(els, options) {
  9912. return _get(TapTarget.__proto__ || Object.getPrototypeOf(TapTarget), "init", this).call(this, this, els, options);
  9913. }
  9914. /**
  9915. * Get Instance
  9916. */
  9917. }, {
  9918. key: "getInstance",
  9919. value: function getInstance(el) {
  9920. var domElem = !!el.jquery ? el[0] : el;
  9921. return domElem.M_TapTarget;
  9922. }
  9923. }, {
  9924. key: "defaults",
  9925. get: function () {
  9926. return _defaults;
  9927. }
  9928. }]);
  9929. return TapTarget;
  9930. }(Component);
  9931. M.TapTarget = TapTarget;
  9932. if (M.jQueryLoaded) {
  9933. M.initializeJqueryWrapper(TapTarget, 'tapTarget', 'M_TapTarget');
  9934. }
  9935. })(cash);
  9936. ;(function ($) {
  9937. 'use strict';
  9938. var _defaults = {
  9939. classes: '',
  9940. dropdownOptions: {}
  9941. };
  9942. /**
  9943. * @class
  9944. *
  9945. */
  9946. var FormSelect = function (_Component20) {
  9947. _inherits(FormSelect, _Component20);
  9948. /**
  9949. * Construct FormSelect instance
  9950. * @constructor
  9951. * @param {Element} el
  9952. * @param {Object} options
  9953. */
  9954. function FormSelect(el, options) {
  9955. _classCallCheck(this, FormSelect);
  9956. // Don't init if browser default version
  9957. var _this68 = _possibleConstructorReturn(this, (FormSelect.__proto__ || Object.getPrototypeOf(FormSelect)).call(this, FormSelect, el, options));
  9958. if (_this68.$el.hasClass('browser-default')) {
  9959. return _possibleConstructorReturn(_this68);
  9960. }
  9961. _this68.el.M_FormSelect = _this68;
  9962. /**
  9963. * Options for the select
  9964. * @member FormSelect#options
  9965. */
  9966. _this68.options = $.extend({}, FormSelect.defaults, options);
  9967. _this68.isMultiple = _this68.$el.prop('multiple');
  9968. // Setup
  9969. _this68.el.tabIndex = -1;
  9970. _this68._keysSelected = {};
  9971. _this68._valueDict = {}; // Maps key to original and generated option element.
  9972. _this68._setupDropdown();
  9973. _this68._setupEventHandlers();
  9974. return _this68;
  9975. }
  9976. _createClass(FormSelect, [{
  9977. key: "destroy",
  9978. /**
  9979. * Teardown component
  9980. */
  9981. value: function destroy() {
  9982. this._removeEventHandlers();
  9983. this._removeDropdown();
  9984. this.el.M_FormSelect = undefined;
  9985. }
  9986. /**
  9987. * Setup Event Handlers
  9988. */
  9989. }, {
  9990. key: "_setupEventHandlers",
  9991. value: function _setupEventHandlers() {
  9992. var _this69 = this;
  9993. this._handleSelectChangeBound = this._handleSelectChange.bind(this);
  9994. this._handleOptionClickBound = this._handleOptionClick.bind(this);
  9995. this._handleInputClickBound = this._handleInputClick.bind(this);
  9996. $(this.dropdownOptions).find('li:not(.optgroup)').each(function (el) {
  9997. el.addEventListener('click', _this69._handleOptionClickBound);
  9998. });
  9999. this.el.addEventListener('change', this._handleSelectChangeBound);
  10000. this.input.addEventListener('click', this._handleInputClickBound);
  10001. }
  10002. /**
  10003. * Remove Event Handlers
  10004. */
  10005. }, {
  10006. key: "_removeEventHandlers",
  10007. value: function _removeEventHandlers() {
  10008. var _this70 = this;
  10009. $(this.dropdownOptions).find('li:not(.optgroup)').each(function (el) {
  10010. el.removeEventListener('click', _this70._handleOptionClickBound);
  10011. });
  10012. this.el.removeEventListener('change', this._handleSelectChangeBound);
  10013. this.input.removeEventListener('click', this._handleInputClickBound);
  10014. }
  10015. /**
  10016. * Handle Select Change
  10017. * @param {Event} e
  10018. */
  10019. }, {
  10020. key: "_handleSelectChange",
  10021. value: function _handleSelectChange(e) {
  10022. this._setValueToInput();
  10023. }
  10024. /**
  10025. * Handle Option Click
  10026. * @param {Event} e
  10027. */
  10028. }, {
  10029. key: "_handleOptionClick",
  10030. value: function _handleOptionClick(e) {
  10031. e.preventDefault();
  10032. var option = $(e.target).closest('li')[0];
  10033. var key = option.id;
  10034. if (!$(option).hasClass('disabled') && !$(option).hasClass('optgroup') && key.length) {
  10035. var selected = true;
  10036. if (this.isMultiple) {
  10037. // Deselect placeholder option if still selected.
  10038. var placeholderOption = $(this.dropdownOptions).find('li.disabled.selected');
  10039. if (placeholderOption.length) {
  10040. placeholderOption.removeClass('selected');
  10041. placeholderOption.find('input[type="checkbox"]').prop('checked', false);
  10042. this._toggleEntryFromArray(placeholderOption[0].id);
  10043. }
  10044. selected = this._toggleEntryFromArray(key);
  10045. } else {
  10046. $(this.dropdownOptions).find('li').removeClass('selected');
  10047. $(option).toggleClass('selected', selected);
  10048. }
  10049. // Set selected on original select option
  10050. // Only trigger if selected state changed
  10051. var prevSelected = $(this._valueDict[key].el).prop('selected');
  10052. if (prevSelected !== selected) {
  10053. $(this._valueDict[key].el).prop('selected', selected);
  10054. this.$el.trigger('change');
  10055. }
  10056. }
  10057. e.stopPropagation();
  10058. }
  10059. /**
  10060. * Handle Input Click
  10061. */
  10062. }, {
  10063. key: "_handleInputClick",
  10064. value: function _handleInputClick() {
  10065. if (this.dropdown && this.dropdown.isOpen) {
  10066. this._setValueToInput();
  10067. this._setSelectedStates();
  10068. }
  10069. }
  10070. /**
  10071. * Setup dropdown
  10072. */
  10073. }, {
  10074. key: "_setupDropdown",
  10075. value: function _setupDropdown() {
  10076. var _this71 = this;
  10077. this.wrapper = document.createElement('div');
  10078. $(this.wrapper).addClass('select-wrapper ' + this.options.classes);
  10079. this.$el.before($(this.wrapper));
  10080. this.wrapper.appendChild(this.el);
  10081. if (this.el.disabled) {
  10082. this.wrapper.classList.add('disabled');
  10083. }
  10084. // Create dropdown
  10085. this.$selectOptions = this.$el.children('option, optgroup');
  10086. this.dropdownOptions = document.createElement('ul');
  10087. this.dropdownOptions.id = "select-options-" + M.guid();
  10088. $(this.dropdownOptions).addClass('dropdown-content select-dropdown ' + (this.isMultiple ? 'multiple-select-dropdown' : ''));
  10089. // Create dropdown structure.
  10090. if (this.$selectOptions.length) {
  10091. this.$selectOptions.each(function (el) {
  10092. if ($(el).is('option')) {
  10093. // Direct descendant option.
  10094. var optionEl = void 0;
  10095. if (_this71.isMultiple) {
  10096. optionEl = _this71._appendOptionWithIcon(_this71.$el, el, 'multiple');
  10097. } else {
  10098. optionEl = _this71._appendOptionWithIcon(_this71.$el, el);
  10099. }
  10100. _this71._addOptionToValueDict(el, optionEl);
  10101. } else if ($(el).is('optgroup')) {
  10102. // Optgroup.
  10103. var selectOptions = $(el).children('option');
  10104. $(_this71.dropdownOptions).append($('<li class="optgroup"><span>' + el.getAttribute('label') + '</span></li>')[0]);
  10105. selectOptions.each(function (el) {
  10106. var optionEl = _this71._appendOptionWithIcon(_this71.$el, el, 'optgroup-option');
  10107. _this71._addOptionToValueDict(el, optionEl);
  10108. });
  10109. }
  10110. });
  10111. }
  10112. this.$el.after(this.dropdownOptions);
  10113. // Add input dropdown
  10114. this.input = document.createElement('input');
  10115. $(this.input).addClass('select-dropdown dropdown-trigger');
  10116. this.input.setAttribute('type', 'text');
  10117. this.input.setAttribute('readonly', 'true');
  10118. this.input.setAttribute('data-target', this.dropdownOptions.id);
  10119. if (this.el.disabled) {
  10120. $(this.input).prop('disabled', 'true');
  10121. }
  10122. this.$el.before(this.input);
  10123. this._setValueToInput();
  10124. // Add caret
  10125. var dropdownIcon = $('<svg class="caret" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
  10126. this.$el.before(dropdownIcon[0]);
  10127. // Initialize dropdown
  10128. if (!this.el.disabled) {
  10129. var dropdownOptions = $.extend({}, this.options.dropdownOptions);
  10130. // Add callback for centering selected option when dropdown content is scrollable
  10131. dropdownOptions.onOpenEnd = function (el) {
  10132. var selectedOption = $(_this71.dropdownOptions).find('.selected').first();
  10133. if (_this71.dropdown.isScrollable && selectedOption.length) {
  10134. var scrollOffset = selectedOption[0].getBoundingClientRect().top - _this71.dropdownOptions.getBoundingClientRect().top; // scroll to selected option
  10135. scrollOffset -= _this71.dropdownOptions.clientHeight / 2; // center in dropdown
  10136. _this71.dropdownOptions.scrollTop = scrollOffset;
  10137. }
  10138. };
  10139. if (this.isMultiple) {
  10140. dropdownOptions.closeOnClick = false;
  10141. }
  10142. this.dropdown = M.Dropdown.init(this.input, dropdownOptions);
  10143. }
  10144. // Add initial selections
  10145. this._setSelectedStates();
  10146. }
  10147. /**
  10148. * Add option to value dict
  10149. * @param {Element} el original option element
  10150. * @param {Element} optionEl generated option element
  10151. */
  10152. }, {
  10153. key: "_addOptionToValueDict",
  10154. value: function _addOptionToValueDict(el, optionEl) {
  10155. var index = Object.keys(this._valueDict).length;
  10156. var key = this.dropdownOptions.id + index;
  10157. var obj = {};
  10158. optionEl.id = key;
  10159. obj.el = el;
  10160. obj.optionEl = optionEl;
  10161. this._valueDict[key] = obj;
  10162. }
  10163. /**
  10164. * Remove dropdown
  10165. */
  10166. }, {
  10167. key: "_removeDropdown",
  10168. value: function _removeDropdown() {
  10169. $(this.wrapper).find('.caret').remove();
  10170. $(this.input).remove();
  10171. $(this.dropdownOptions).remove();
  10172. $(this.wrapper).before(this.$el);
  10173. $(this.wrapper).remove();
  10174. }
  10175. /**
  10176. * Setup dropdown
  10177. * @param {Element} select select element
  10178. * @param {Element} option option element from select
  10179. * @param {String} type
  10180. * @return {Element} option element added
  10181. */
  10182. }, {
  10183. key: "_appendOptionWithIcon",
  10184. value: function _appendOptionWithIcon(select, option, type) {
  10185. // Add disabled attr if disabled
  10186. var disabledClass = option.disabled ? 'disabled ' : '';
  10187. var optgroupClass = type === 'optgroup-option' ? 'optgroup-option ' : '';
  10188. var multipleCheckbox = this.isMultiple ? "<label><input type=\"checkbox\"" + disabledClass + "\"/><span>" + option.innerHTML + "</span></label>" : option.innerHTML;
  10189. var liEl = $('<li></li>');
  10190. var spanEl = $('<span></span>');
  10191. spanEl.html(multipleCheckbox);
  10192. liEl.addClass(disabledClass + " " + optgroupClass);
  10193. liEl.append(spanEl);
  10194. // add icons
  10195. var iconUrl = option.getAttribute('data-icon');
  10196. if (!!iconUrl) {
  10197. var imgEl = $("<img alt=\"\" src=\"" + iconUrl + "\">");
  10198. liEl.prepend(imgEl);
  10199. }
  10200. // Check for multiple type.
  10201. $(this.dropdownOptions).append(liEl[0]);
  10202. return liEl[0];
  10203. }
  10204. /**
  10205. * Toggle entry from option
  10206. * @param {String} key Option key
  10207. * @return {Boolean} if entry was added or removed
  10208. */
  10209. }, {
  10210. key: "_toggleEntryFromArray",
  10211. value: function _toggleEntryFromArray(key) {
  10212. var notAdded = !this._keysSelected.hasOwnProperty(key);
  10213. var $optionLi = $(this._valueDict[key].optionEl);
  10214. if (notAdded) {
  10215. this._keysSelected[key] = true;
  10216. } else {
  10217. delete this._keysSelected[key];
  10218. }
  10219. $optionLi.toggleClass('selected', notAdded);
  10220. // Set checkbox checked value
  10221. $optionLi.find('input[type="checkbox"]').prop('checked', notAdded);
  10222. // use notAdded instead of true (to detect if the option is selected or not)
  10223. $optionLi.prop('selected', notAdded);
  10224. return notAdded;
  10225. }
  10226. /**
  10227. * Set text value to input
  10228. */
  10229. }, {
  10230. key: "_setValueToInput",
  10231. value: function _setValueToInput() {
  10232. var values = [];
  10233. var options = this.$el.find('option');
  10234. options.each(function (el) {
  10235. if ($(el).prop('selected')) {
  10236. var text = $(el).text();
  10237. values.push(text);
  10238. }
  10239. });
  10240. if (!values.length) {
  10241. var firstDisabled = this.$el.find('option:disabled').eq(0);
  10242. if (firstDisabled.length && firstDisabled[0].value === '') {
  10243. values.push(firstDisabled.text());
  10244. }
  10245. }
  10246. this.input.value = values.join(', ');
  10247. }
  10248. /**
  10249. * Set selected state of dropdown to match actual select element
  10250. */
  10251. }, {
  10252. key: "_setSelectedStates",
  10253. value: function _setSelectedStates() {
  10254. this._keysSelected = {};
  10255. for (var key in this._valueDict) {
  10256. var option = this._valueDict[key];
  10257. var optionIsSelected = $(option.el).prop('selected');
  10258. $(option.optionEl).find('input[type="checkbox"]').prop('checked', optionIsSelected);
  10259. if (optionIsSelected) {
  10260. this._activateOption($(this.dropdownOptions), $(option.optionEl));
  10261. this._keysSelected[key] = true;
  10262. } else {
  10263. $(option.optionEl).removeClass('selected');
  10264. }
  10265. }
  10266. }
  10267. /**
  10268. * Make option as selected and scroll to selected position
  10269. * @param {jQuery} collection Select options jQuery element
  10270. * @param {Element} newOption element of the new option
  10271. */
  10272. }, {
  10273. key: "_activateOption",
  10274. value: function _activateOption(collection, newOption) {
  10275. if (newOption) {
  10276. if (!this.isMultiple) {
  10277. collection.find('li.selected').removeClass('selected');
  10278. }
  10279. var option = $(newOption);
  10280. option.addClass('selected');
  10281. }
  10282. }
  10283. /**
  10284. * Get Selected Values
  10285. * @return {Array} Array of selected values
  10286. */
  10287. }, {
  10288. key: "getSelectedValues",
  10289. value: function getSelectedValues() {
  10290. var selectedValues = [];
  10291. for (var key in this._keysSelected) {
  10292. selectedValues.push(this._valueDict[key].el.value);
  10293. }
  10294. return selectedValues;
  10295. }
  10296. }], [{
  10297. key: "init",
  10298. value: function init(els, options) {
  10299. return _get(FormSelect.__proto__ || Object.getPrototypeOf(FormSelect), "init", this).call(this, this, els, options);
  10300. }
  10301. /**
  10302. * Get Instance
  10303. */
  10304. }, {
  10305. key: "getInstance",
  10306. value: function getInstance(el) {
  10307. var domElem = !!el.jquery ? el[0] : el;
  10308. return domElem.M_FormSelect;
  10309. }
  10310. }, {
  10311. key: "defaults",
  10312. get: function () {
  10313. return _defaults;
  10314. }
  10315. }]);
  10316. return FormSelect;
  10317. }(Component);
  10318. M.FormSelect = FormSelect;
  10319. if (M.jQueryLoaded) {
  10320. M.initializeJqueryWrapper(FormSelect, 'formSelect', 'M_FormSelect');
  10321. }
  10322. })(cash);
  10323. ;(function ($, anim) {
  10324. 'use strict';
  10325. var _defaults = {};
  10326. /**
  10327. * @class
  10328. *
  10329. */
  10330. var Range = function (_Component21) {
  10331. _inherits(Range, _Component21);
  10332. /**
  10333. * Construct Range instance
  10334. * @constructor
  10335. * @param {Element} el
  10336. * @param {Object} options
  10337. */
  10338. function Range(el, options) {
  10339. _classCallCheck(this, Range);
  10340. var _this72 = _possibleConstructorReturn(this, (Range.__proto__ || Object.getPrototypeOf(Range)).call(this, Range, el, options));
  10341. _this72.el.M_Range = _this72;
  10342. /**
  10343. * Options for the range
  10344. * @member Range#options
  10345. */
  10346. _this72.options = $.extend({}, Range.defaults, options);
  10347. _this72._mousedown = false;
  10348. // Setup
  10349. _this72._setupThumb();
  10350. _this72._setupEventHandlers();
  10351. return _this72;
  10352. }
  10353. _createClass(Range, [{
  10354. key: "destroy",
  10355. /**
  10356. * Teardown component
  10357. */
  10358. value: function destroy() {
  10359. this._removeEventHandlers();
  10360. this._removeThumb();
  10361. this.el.M_Range = undefined;
  10362. }
  10363. /**
  10364. * Setup Event Handlers
  10365. */
  10366. }, {
  10367. key: "_setupEventHandlers",
  10368. value: function _setupEventHandlers() {
  10369. this._handleRangeChangeBound = this._handleRangeChange.bind(this);
  10370. this._handleRangeMousedownTouchstartBound = this._handleRangeMousedownTouchstart.bind(this);
  10371. this._handleRangeInputMousemoveTouchmoveBound = this._handleRangeInputMousemoveTouchmove.bind(this);
  10372. this._handleRangeMouseupTouchendBound = this._handleRangeMouseupTouchend.bind(this);
  10373. this._handleRangeBlurMouseoutTouchleaveBound = this._handleRangeBlurMouseoutTouchleave.bind(this);
  10374. this.el.addEventListener('change', this._handleRangeChangeBound);
  10375. this.el.addEventListener('mousedown', this._handleRangeMousedownTouchstartBound);
  10376. this.el.addEventListener('touchstart', this._handleRangeMousedownTouchstartBound);
  10377. this.el.addEventListener('input', this._handleRangeInputMousemoveTouchmoveBound);
  10378. this.el.addEventListener('mousemove', this._handleRangeInputMousemoveTouchmoveBound);
  10379. this.el.addEventListener('touchmove', this._handleRangeInputMousemoveTouchmoveBound);
  10380. this.el.addEventListener('mouseup', this._handleRangeMouseupTouchendBound);
  10381. this.el.addEventListener('touchend', this._handleRangeMouseupTouchendBound);
  10382. this.el.addEventListener('blur', this._handleRangeBlurMouseoutTouchleaveBound);
  10383. this.el.addEventListener('mouseout', this._handleRangeBlurMouseoutTouchleaveBound);
  10384. this.el.addEventListener('touchleave', this._handleRangeBlurMouseoutTouchleaveBound);
  10385. }
  10386. /**
  10387. * Remove Event Handlers
  10388. */
  10389. }, {
  10390. key: "_removeEventHandlers",
  10391. value: function _removeEventHandlers() {
  10392. this.el.removeEventListener('change', this._handleRangeChangeBound);
  10393. this.el.removeEventListener('mousedown', this._handleRangeMousedownTouchstartBound);
  10394. this.el.removeEventListener('touchstart', this._handleRangeMousedownTouchstartBound);
  10395. this.el.removeEventListener('input', this._handleRangeInputMousemoveTouchmoveBound);
  10396. this.el.removeEventListener('mousemove', this._handleRangeInputMousemoveTouchmoveBound);
  10397. this.el.removeEventListener('touchmove', this._handleRangeInputMousemoveTouchmoveBound);
  10398. this.el.removeEventListener('mouseup', this._handleRangeMouseupTouchendBound);
  10399. this.el.removeEventListener('touchend', this._handleRangeMouseupTouchendBound);
  10400. this.el.removeEventListener('blur', this._handleRangeBlurMouseoutTouchleaveBound);
  10401. this.el.removeEventListener('mouseout', this._handleRangeBlurMouseoutTouchleaveBound);
  10402. this.el.removeEventListener('touchleave', this._handleRangeBlurMouseoutTouchleaveBound);
  10403. }
  10404. /**
  10405. * Handle Range Change
  10406. * @param {Event} e
  10407. */
  10408. }, {
  10409. key: "_handleRangeChange",
  10410. value: function _handleRangeChange() {
  10411. $(this.value).html(this.$el.val());
  10412. if (!$(this.thumb).hasClass('active')) {
  10413. this._showRangeBubble();
  10414. }
  10415. var offsetLeft = this._calcRangeOffset();
  10416. $(this.thumb).addClass('active').css('left', offsetLeft + 'px');
  10417. }
  10418. /**
  10419. * Handle Range Mousedown and Touchstart
  10420. * @param {Event} e
  10421. */
  10422. }, {
  10423. key: "_handleRangeMousedownTouchstart",
  10424. value: function _handleRangeMousedownTouchstart(e) {
  10425. // Set indicator value
  10426. $(this.value).html(this.$el.val());
  10427. this._mousedown = true;
  10428. this.$el.addClass('active');
  10429. if (!$(this.thumb).hasClass('active')) {
  10430. this._showRangeBubble();
  10431. }
  10432. if (e.type !== 'input') {
  10433. var offsetLeft = this._calcRangeOffset();
  10434. $(this.thumb).addClass('active').css('left', offsetLeft + 'px');
  10435. }
  10436. }
  10437. /**
  10438. * Handle Range Input, Mousemove and Touchmove
  10439. */
  10440. }, {
  10441. key: "_handleRangeInputMousemoveTouchmove",
  10442. value: function _handleRangeInputMousemoveTouchmove() {
  10443. if (this._mousedown) {
  10444. if (!$(this.thumb).hasClass('active')) {
  10445. this._showRangeBubble();
  10446. }
  10447. var offsetLeft = this._calcRangeOffset();
  10448. $(this.thumb).addClass('active').css('left', offsetLeft + 'px');
  10449. $(this.value).html(this.$el.val());
  10450. }
  10451. }
  10452. /**
  10453. * Handle Range Mouseup and Touchend
  10454. */
  10455. }, {
  10456. key: "_handleRangeMouseupTouchend",
  10457. value: function _handleRangeMouseupTouchend() {
  10458. this._mousedown = false;
  10459. this.$el.removeClass('active');
  10460. }
  10461. /**
  10462. * Handle Range Blur, Mouseout and Touchleave
  10463. */
  10464. }, {
  10465. key: "_handleRangeBlurMouseoutTouchleave",
  10466. value: function _handleRangeBlurMouseoutTouchleave() {
  10467. if (!this._mousedown) {
  10468. var paddingLeft = parseInt(this.$el.css('padding-left'));
  10469. var marginLeft = 7 + paddingLeft + 'px';
  10470. if ($(this.thumb).hasClass('active')) {
  10471. anim.remove(this.thumb);
  10472. anim({
  10473. targets: this.thumb,
  10474. height: 0,
  10475. width: 0,
  10476. top: 10,
  10477. easing: 'easeOutQuad',
  10478. marginLeft: marginLeft,
  10479. duration: 100
  10480. });
  10481. }
  10482. $(this.thumb).removeClass('active');
  10483. }
  10484. }
  10485. /**
  10486. * Setup dropdown
  10487. */
  10488. }, {
  10489. key: "_setupThumb",
  10490. value: function _setupThumb() {
  10491. this.thumb = document.createElement('span');
  10492. this.value = document.createElement('span');
  10493. $(this.thumb).addClass('thumb');
  10494. $(this.value).addClass('value');
  10495. $(this.thumb).append(this.value);
  10496. this.$el.after(this.thumb);
  10497. }
  10498. /**
  10499. * Remove dropdown
  10500. */
  10501. }, {
  10502. key: "_removeThumb",
  10503. value: function _removeThumb() {
  10504. $(this.thumb).remove();
  10505. }
  10506. /**
  10507. * morph thumb into bubble
  10508. */
  10509. }, {
  10510. key: "_showRangeBubble",
  10511. value: function _showRangeBubble() {
  10512. var paddingLeft = parseInt($(this.thumb).parent().css('padding-left'));
  10513. var marginLeft = -7 + paddingLeft + 'px'; // TODO: fix magic number?
  10514. anim.remove(this.thumb);
  10515. anim({
  10516. targets: this.thumb,
  10517. height: 30,
  10518. width: 30,
  10519. top: -30,
  10520. marginLeft: marginLeft,
  10521. duration: 300,
  10522. easing: 'easeOutQuint'
  10523. });
  10524. }
  10525. /**
  10526. * Calculate the offset of the thumb
  10527. * @return {Number} offset in pixels
  10528. */
  10529. }, {
  10530. key: "_calcRangeOffset",
  10531. value: function _calcRangeOffset() {
  10532. var width = this.$el.width() - 15;
  10533. var max = parseFloat(this.$el.attr('max')) || 100; // Range default max
  10534. var min = parseFloat(this.$el.attr('min')) || 0; // Range default min
  10535. var percent = (parseFloat(this.$el.val()) - min) / (max - min);
  10536. return percent * width;
  10537. }
  10538. }], [{
  10539. key: "init",
  10540. value: function init(els, options) {
  10541. return _get(Range.__proto__ || Object.getPrototypeOf(Range), "init", this).call(this, this, els, options);
  10542. }
  10543. /**
  10544. * Get Instance
  10545. */
  10546. }, {
  10547. key: "getInstance",
  10548. value: function getInstance(el) {
  10549. var domElem = !!el.jquery ? el[0] : el;
  10550. return domElem.M_Range;
  10551. }
  10552. }, {
  10553. key: "defaults",
  10554. get: function () {
  10555. return _defaults;
  10556. }
  10557. }]);
  10558. return Range;
  10559. }(Component);
  10560. M.Range = Range;
  10561. if (M.jQueryLoaded) {
  10562. M.initializeJqueryWrapper(Range, 'range', 'M_Range');
  10563. }
  10564. Range.init($('input[type=range]'));
  10565. })(cash, M.anime);