materialize.js 368 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179
  1. /*!
  2. * Materialize v0.100.2 (http://materializecss.com)
  3. * Copyright 2014-2017 Materialize
  4. * MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE)
  5. */
  6. 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; }; }();
  7. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8. // Check for jQuery.
  9. if (typeof jQuery === 'undefined') {
  10. // Check if require is a defined function.
  11. if (typeof require === 'function') {
  12. jQuery = $ = require('jquery');
  13. // Else use the dollar sign alias.
  14. } else {
  15. jQuery = $;
  16. }
  17. }
  18. ; /*
  19. * jQuery Easing v1.4.0 - http://gsgd.co.uk/sandbox/jquery/easing/
  20. * Open source under the BSD License.
  21. * Copyright © 2008 George McGinley Smith
  22. * All rights reserved.
  23. * https://raw.github.com/gdsmith/jquery-easing/master/LICENSE
  24. */
  25. (function (factory) {
  26. if (typeof define === "function" && define.amd) {
  27. define(['jquery'], function ($) {
  28. return factory($);
  29. });
  30. } else if (typeof module === "object" && typeof module.exports === "object") {
  31. exports = factory(require('jquery'));
  32. } else {
  33. factory(jQuery);
  34. }
  35. })(function ($) {
  36. // Preserve the original jQuery "swing" easing as "jswing"
  37. $.easing['jswing'] = $.easing['swing'];
  38. var pow = Math.pow,
  39. sqrt = Math.sqrt,
  40. sin = Math.sin,
  41. cos = Math.cos,
  42. PI = Math.PI,
  43. c1 = 1.70158,
  44. c2 = c1 * 1.525,
  45. c3 = c1 + 1,
  46. c4 = 2 * PI / 3,
  47. c5 = 2 * PI / 4.5;
  48. // x is the fraction of animation progress, in the range 0..1
  49. function bounceOut(x) {
  50. var n1 = 7.5625,
  51. d1 = 2.75;
  52. if (x < 1 / d1) {
  53. return n1 * x * x;
  54. } else if (x < 2 / d1) {
  55. return n1 * (x -= 1.5 / d1) * x + .75;
  56. } else if (x < 2.5 / d1) {
  57. return n1 * (x -= 2.25 / d1) * x + .9375;
  58. } else {
  59. return n1 * (x -= 2.625 / d1) * x + .984375;
  60. }
  61. }
  62. $.extend($.easing, {
  63. def: 'easeOutQuad',
  64. swing: function (x) {
  65. return $.easing[$.easing.def](x);
  66. },
  67. easeInQuad: function (x) {
  68. return x * x;
  69. },
  70. easeOutQuad: function (x) {
  71. return 1 - (1 - x) * (1 - x);
  72. },
  73. easeInOutQuad: function (x) {
  74. return x < 0.5 ? 2 * x * x : 1 - pow(-2 * x + 2, 2) / 2;
  75. },
  76. easeInCubic: function (x) {
  77. return x * x * x;
  78. },
  79. easeOutCubic: function (x) {
  80. return 1 - pow(1 - x, 3);
  81. },
  82. easeInOutCubic: function (x) {
  83. return x < 0.5 ? 4 * x * x * x : 1 - pow(-2 * x + 2, 3) / 2;
  84. },
  85. easeInQuart: function (x) {
  86. return x * x * x * x;
  87. },
  88. easeOutQuart: function (x) {
  89. return 1 - pow(1 - x, 4);
  90. },
  91. easeInOutQuart: function (x) {
  92. return x < 0.5 ? 8 * x * x * x * x : 1 - pow(-2 * x + 2, 4) / 2;
  93. },
  94. easeInQuint: function (x) {
  95. return x * x * x * x * x;
  96. },
  97. easeOutQuint: function (x) {
  98. return 1 - pow(1 - x, 5);
  99. },
  100. easeInOutQuint: function (x) {
  101. return x < 0.5 ? 16 * x * x * x * x * x : 1 - pow(-2 * x + 2, 5) / 2;
  102. },
  103. easeInSine: function (x) {
  104. return 1 - cos(x * PI / 2);
  105. },
  106. easeOutSine: function (x) {
  107. return sin(x * PI / 2);
  108. },
  109. easeInOutSine: function (x) {
  110. return -(cos(PI * x) - 1) / 2;
  111. },
  112. easeInExpo: function (x) {
  113. return x === 0 ? 0 : pow(2, 10 * x - 10);
  114. },
  115. easeOutExpo: function (x) {
  116. return x === 1 ? 1 : 1 - pow(2, -10 * x);
  117. },
  118. easeInOutExpo: function (x) {
  119. return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? pow(2, 20 * x - 10) / 2 : (2 - pow(2, -20 * x + 10)) / 2;
  120. },
  121. easeInCirc: function (x) {
  122. return 1 - sqrt(1 - pow(x, 2));
  123. },
  124. easeOutCirc: function (x) {
  125. return sqrt(1 - pow(x - 1, 2));
  126. },
  127. easeInOutCirc: function (x) {
  128. return x < 0.5 ? (1 - sqrt(1 - pow(2 * x, 2))) / 2 : (sqrt(1 - pow(-2 * x + 2, 2)) + 1) / 2;
  129. },
  130. easeInElastic: function (x) {
  131. return x === 0 ? 0 : x === 1 ? 1 : -pow(2, 10 * x - 10) * sin((x * 10 - 10.75) * c4);
  132. },
  133. easeOutElastic: function (x) {
  134. return x === 0 ? 0 : x === 1 ? 1 : pow(2, -10 * x) * sin((x * 10 - 0.75) * c4) + 1;
  135. },
  136. easeInOutElastic: function (x) {
  137. return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(pow(2, 20 * x - 10) * sin((20 * x - 11.125) * c5)) / 2 : pow(2, -20 * x + 10) * sin((20 * x - 11.125) * c5) / 2 + 1;
  138. },
  139. easeInBack: function (x) {
  140. return c3 * x * x * x - c1 * x * x;
  141. },
  142. easeOutBack: function (x) {
  143. return 1 + c3 * pow(x - 1, 3) + c1 * pow(x - 1, 2);
  144. },
  145. easeInOutBack: function (x) {
  146. return x < 0.5 ? pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2;
  147. },
  148. easeInBounce: function (x) {
  149. return 1 - bounceOut(1 - x);
  150. },
  151. easeOutBounce: bounceOut,
  152. easeInOutBounce: function (x) {
  153. return x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2;
  154. }
  155. });
  156. });; // Custom Easing
  157. jQuery.extend(jQuery.easing, {
  158. easeInOutMaterial: function (x, t, b, c, d) {
  159. if ((t /= d / 2) < 1) return c / 2 * t * t + b;
  160. return c / 4 * ((t -= 2) * t * t + 2) + b;
  161. }
  162. });; /*! VelocityJS.org (1.2.3). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */
  163. /*! VelocityJS.org jQuery Shim (1.0.1). (C) 2014 The jQuery Foundation. MIT @license: en.wikipedia.org/wiki/MIT_License. */
  164. /*! Note that this has been modified by Materialize to confirm that Velocity is not already being imported. */
  165. jQuery.Velocity ? console.log("Velocity is already loaded. You may be needlessly importing Velocity again; note that Materialize includes Velocity.") : (!function (e) {
  166. function t(e) {
  167. var t = e.length,
  168. a = r.type(e); return "function" === a || r.isWindow(e) ? !1 : 1 === e.nodeType && t ? !0 : "array" === a || 0 === t || "number" == typeof t && t > 0 && t - 1 in e;
  169. } if (!e.jQuery) {
  170. var r = function (e, t) {
  171. return new r.fn.init(e, t);
  172. }; r.isWindow = function (e) {
  173. return null != e && e == e.window;
  174. }, r.type = function (e) {
  175. return null == e ? e + "" : "object" == typeof e || "function" == typeof e ? n[i.call(e)] || "object" : typeof e;
  176. }, r.isArray = Array.isArray || function (e) {
  177. return "array" === r.type(e);
  178. }, r.isPlainObject = function (e) {
  179. var t; if (!e || "object" !== r.type(e) || e.nodeType || r.isWindow(e)) return !1; try {
  180. if (e.constructor && !o.call(e, "constructor") && !o.call(e.constructor.prototype, "isPrototypeOf")) return !1;
  181. } catch (a) {
  182. return !1;
  183. } for (t in e) { } return void 0 === t || o.call(e, t);
  184. }, r.each = function (e, r, a) {
  185. var n,
  186. o = 0,
  187. i = e.length,
  188. s = t(e); if (a) {
  189. if (s) for (; i > o && (n = r.apply(e[o], a), n !== !1); o++) { } else for (o in e) {
  190. if (n = r.apply(e[o], a), n === !1) break;
  191. }
  192. } else if (s) for (; i > o && (n = r.call(e[o], o, e[o]), n !== !1); o++) { } else for (o in e) {
  193. if (n = r.call(e[o], o, e[o]), n === !1) break;
  194. } return e;
  195. }, r.data = function (e, t, n) {
  196. if (void 0 === n) {
  197. var o = e[r.expando],
  198. i = o && a[o]; if (void 0 === t) return i; if (i && t in i) return i[t];
  199. } else if (void 0 !== t) {
  200. var o = e[r.expando] || (e[r.expando] = ++r.uuid); return a[o] = a[o] || {}, a[o][t] = n, n;
  201. }
  202. }, r.removeData = function (e, t) {
  203. var n = e[r.expando],
  204. o = n && a[n]; o && r.each(t, function (e, t) {
  205. delete o[t];
  206. });
  207. }, r.extend = function () {
  208. var e,
  209. t,
  210. a,
  211. n,
  212. o,
  213. i,
  214. s = arguments[0] || {},
  215. l = 1,
  216. u = arguments.length,
  217. c = !1; for ("boolean" == typeof s && (c = s, s = arguments[l] || {}, l++), "object" != typeof s && "function" !== r.type(s) && (s = {}), l === u && (s = this, l--); u > l; l++) {
  218. if (null != (o = arguments[l])) for (n in o) {
  219. e = s[n], a = o[n], s !== a && (c && a && (r.isPlainObject(a) || (t = r.isArray(a))) ? (t ? (t = !1, i = e && r.isArray(e) ? e : []) : i = e && r.isPlainObject(e) ? e : {}, s[n] = r.extend(c, i, a)) : void 0 !== a && (s[n] = a));
  220. }
  221. } return s;
  222. }, r.queue = function (e, a, n) {
  223. function o(e, r) {
  224. var a = r || []; return null != e && (t(Object(e)) ? !function (e, t) {
  225. for (var r = +t.length, a = 0, n = e.length; r > a;) {
  226. e[n++] = t[a++];
  227. } if (r !== r) for (; void 0 !== t[a];) {
  228. e[n++] = t[a++];
  229. } return e.length = n, e;
  230. }(a, "string" == typeof e ? [e] : e) : [].push.call(a, e)), a;
  231. } if (e) {
  232. a = (a || "fx") + "queue"; var i = r.data(e, a); return n ? (!i || r.isArray(n) ? i = r.data(e, a, o(n)) : i.push(n), i) : i || [];
  233. }
  234. }, r.dequeue = function (e, t) {
  235. r.each(e.nodeType ? [e] : e, function (e, a) {
  236. t = t || "fx"; var n = r.queue(a, t),
  237. o = n.shift(); "inprogress" === o && (o = n.shift()), o && ("fx" === t && n.unshift("inprogress"), o.call(a, function () {
  238. r.dequeue(a, t);
  239. }));
  240. });
  241. }, r.fn = r.prototype = {
  242. init: function (e) {
  243. if (e.nodeType) return this[0] = e, this; throw new Error("Not a DOM node.");
  244. }, offset: function () {
  245. var t = this[0].getBoundingClientRect ? this[0].getBoundingClientRect() : { top: 0, left: 0 }; return { top: t.top + (e.pageYOffset || document.scrollTop || 0) - (document.clientTop || 0), left: t.left + (e.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || 0) };
  246. }, position: function () {
  247. function e() {
  248. for (var e = this.offsetParent || document; e && "html" === !e.nodeType.toLowerCase && "static" === e.style.position;) {
  249. e = e.offsetParent;
  250. } return e || document;
  251. } var t = this[0],
  252. e = e.apply(t),
  253. a = this.offset(),
  254. n = /^(?:body|html)$/i.test(e.nodeName) ? { top: 0, left: 0 } : r(e).offset(); return a.top -= parseFloat(t.style.marginTop) || 0, a.left -= parseFloat(t.style.marginLeft) || 0, e.style && (n.top += parseFloat(e.style.borderTopWidth) || 0, n.left += parseFloat(e.style.borderLeftWidth) || 0), { top: a.top - n.top, left: a.left - n.left };
  255. }
  256. }; var a = {}; r.expando = "velocity" + new Date().getTime(), r.uuid = 0; for (var n = {}, o = n.hasOwnProperty, i = n.toString, s = "Boolean Number String Function Array Date RegExp Object Error".split(" "), l = 0; l < s.length; l++) {
  257. n["[object " + s[l] + "]"] = s[l].toLowerCase();
  258. } r.fn.init.prototype = r.fn, e.Velocity = { Utilities: r };
  259. }
  260. }(window), function (e) {
  261. "object" == typeof module && "object" == typeof module.exports ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : e();
  262. }(function () {
  263. return function (e, t, r, a) {
  264. function n(e) {
  265. for (var t = -1, r = e ? e.length : 0, a = []; ++t < r;) {
  266. var n = e[t]; n && a.push(n);
  267. } return a;
  268. } function o(e) {
  269. return m.isWrapped(e) ? e = [].slice.call(e) : m.isNode(e) && (e = [e]), e;
  270. } function i(e) {
  271. var t = f.data(e, "velocity"); return null === t ? a : t;
  272. } function s(e) {
  273. return function (t) {
  274. return Math.round(t * e) * (1 / e);
  275. };
  276. } function l(e, r, a, n) {
  277. function o(e, t) {
  278. return 1 - 3 * t + 3 * e;
  279. } function i(e, t) {
  280. return 3 * t - 6 * e;
  281. } function s(e) {
  282. return 3 * e;
  283. } function l(e, t, r) {
  284. return ((o(t, r) * e + i(t, r)) * e + s(t)) * e;
  285. } function u(e, t, r) {
  286. return 3 * o(t, r) * e * e + 2 * i(t, r) * e + s(t);
  287. } function c(t, r) {
  288. for (var n = 0; m > n; ++n) {
  289. var o = u(r, e, a); if (0 === o) return r; var i = l(r, e, a) - t; r -= i / o;
  290. } return r;
  291. } function p() {
  292. for (var t = 0; b > t; ++t) {
  293. w[t] = l(t * x, e, a);
  294. }
  295. } function f(t, r, n) {
  296. var o,
  297. i,
  298. s = 0; do {
  299. i = r + (n - r) / 2, o = l(i, e, a) - t, o > 0 ? n = i : r = i;
  300. } while (Math.abs(o) > h && ++s < v); return i;
  301. } function d(t) {
  302. for (var r = 0, n = 1, o = b - 1; n != o && w[n] <= t; ++n) {
  303. r += x;
  304. } --n; var i = (t - w[n]) / (w[n + 1] - w[n]),
  305. s = r + i * x,
  306. l = u(s, e, a); return l >= y ? c(t, s) : 0 == l ? s : f(t, r, r + x);
  307. } function g() {
  308. V = !0, (e != r || a != n) && p();
  309. } var m = 4,
  310. y = .001,
  311. h = 1e-7,
  312. v = 10,
  313. b = 11,
  314. x = 1 / (b - 1),
  315. S = "Float32Array" in t; if (4 !== arguments.length) return !1; for (var P = 0; 4 > P; ++P) {
  316. if ("number" != typeof arguments[P] || isNaN(arguments[P]) || !isFinite(arguments[P])) return !1;
  317. } e = Math.min(e, 1), a = Math.min(a, 1), e = Math.max(e, 0), a = Math.max(a, 0); var w = S ? new Float32Array(b) : new Array(b),
  318. V = !1,
  319. C = function (t) {
  320. return V || g(), e === r && a === n ? t : 0 === t ? 0 : 1 === t ? 1 : l(d(t), r, n);
  321. }; C.getControlPoints = function () {
  322. return [{ x: e, y: r }, { x: a, y: n }];
  323. }; var T = "generateBezier(" + [e, r, a, n] + ")"; return C.toString = function () {
  324. return T;
  325. }, C;
  326. } function u(e, t) {
  327. var r = e; return m.isString(e) ? b.Easings[e] || (r = !1) : r = m.isArray(e) && 1 === e.length ? s.apply(null, e) : m.isArray(e) && 2 === e.length ? x.apply(null, e.concat([t])) : m.isArray(e) && 4 === e.length ? l.apply(null, e) : !1, r === !1 && (r = b.Easings[b.defaults.easing] ? b.defaults.easing : v), r;
  328. } function c(e) {
  329. if (e) {
  330. var t = new Date().getTime(),
  331. r = b.State.calls.length; r > 1e4 && (b.State.calls = n(b.State.calls)); for (var o = 0; r > o; o++) {
  332. if (b.State.calls[o]) {
  333. var s = b.State.calls[o],
  334. l = s[0],
  335. u = s[2],
  336. d = s[3],
  337. g = !!d,
  338. y = null; d || (d = b.State.calls[o][3] = t - 16); for (var h = Math.min((t - d) / u.duration, 1), v = 0, x = l.length; x > v; v++) {
  339. var P = l[v],
  340. V = P.element; if (i(V)) {
  341. var C = !1; if (u.display !== a && null !== u.display && "none" !== u.display) {
  342. if ("flex" === u.display) {
  343. var T = ["-webkit-box", "-moz-box", "-ms-flexbox", "-webkit-flex"]; f.each(T, function (e, t) {
  344. S.setPropertyValue(V, "display", t);
  345. });
  346. } S.setPropertyValue(V, "display", u.display);
  347. } u.visibility !== a && "hidden" !== u.visibility && S.setPropertyValue(V, "visibility", u.visibility); for (var k in P) {
  348. if ("element" !== k) {
  349. var A,
  350. F = P[k],
  351. j = m.isString(F.easing) ? b.Easings[F.easing] : F.easing; if (1 === h) A = F.endValue; else {
  352. var E = F.endValue - F.startValue; if (A = F.startValue + E * j(h, u, E), !g && A === F.currentValue) continue;
  353. } if (F.currentValue = A, "tween" === k) y = A; else {
  354. if (S.Hooks.registered[k]) {
  355. var H = S.Hooks.getRoot(k),
  356. N = i(V).rootPropertyValueCache[H]; N && (F.rootPropertyValue = N);
  357. } var L = S.setPropertyValue(V, k, F.currentValue + (0 === parseFloat(A) ? "" : F.unitType), F.rootPropertyValue, F.scrollData); S.Hooks.registered[k] && (i(V).rootPropertyValueCache[H] = S.Normalizations.registered[H] ? S.Normalizations.registered[H]("extract", null, L[1]) : L[1]), "transform" === L[0] && (C = !0);
  358. }
  359. }
  360. } u.mobileHA && i(V).transformCache.translate3d === a && (i(V).transformCache.translate3d = "(0px, 0px, 0px)", C = !0), C && S.flushTransformCache(V);
  361. }
  362. } u.display !== a && "none" !== u.display && (b.State.calls[o][2].display = !1), u.visibility !== a && "hidden" !== u.visibility && (b.State.calls[o][2].visibility = !1), u.progress && u.progress.call(s[1], s[1], h, Math.max(0, d + u.duration - t), d, y), 1 === h && p(o);
  363. }
  364. }
  365. } b.State.isTicking && w(c);
  366. } function p(e, t) {
  367. if (!b.State.calls[e]) return !1; for (var r = b.State.calls[e][0], n = b.State.calls[e][1], o = b.State.calls[e][2], s = b.State.calls[e][4], l = !1, u = 0, c = r.length; c > u; u++) {
  368. var p = r[u].element; if (t || o.loop || ("none" === o.display && S.setPropertyValue(p, "display", o.display), "hidden" === o.visibility && S.setPropertyValue(p, "visibility", o.visibility)), o.loop !== !0 && (f.queue(p)[1] === a || !/\.velocityQueueEntryFlag/i.test(f.queue(p)[1])) && i(p)) {
  369. i(p).isAnimating = !1, i(p).rootPropertyValueCache = {}; var d = !1; f.each(S.Lists.transforms3D, function (e, t) {
  370. var r = /^scale/.test(t) ? 1 : 0,
  371. n = i(p).transformCache[t]; i(p).transformCache[t] !== a && new RegExp("^\\(" + r + "[^.]").test(n) && (d = !0, delete i(p).transformCache[t]);
  372. }), o.mobileHA && (d = !0, delete i(p).transformCache.translate3d), d && S.flushTransformCache(p), S.Values.removeClass(p, "velocity-animating");
  373. } if (!t && o.complete && !o.loop && u === c - 1) try {
  374. o.complete.call(n, n);
  375. } catch (g) {
  376. setTimeout(function () {
  377. throw g;
  378. }, 1);
  379. } s && o.loop !== !0 && s(n), i(p) && o.loop === !0 && !t && (f.each(i(p).tweensContainer, function (e, t) {
  380. /^rotate/.test(e) && 360 === parseFloat(t.endValue) && (t.endValue = 0, t.startValue = 360), /^backgroundPosition/.test(e) && 100 === parseFloat(t.endValue) && "%" === t.unitType && (t.endValue = 0, t.startValue = 100);
  381. }), b(p, "reverse", { loop: !0, delay: o.delay })), o.queue !== !1 && f.dequeue(p, o.queue);
  382. } b.State.calls[e] = !1; for (var m = 0, y = b.State.calls.length; y > m; m++) {
  383. if (b.State.calls[m] !== !1) {
  384. l = !0; break;
  385. }
  386. } l === !1 && (b.State.isTicking = !1, delete b.State.calls, b.State.calls = []);
  387. } var f,
  388. d = function () {
  389. if (r.documentMode) return r.documentMode; for (var e = 7; e > 4; e--) {
  390. var t = r.createElement("div"); if (t.innerHTML = "<!--[if IE " + e + "]><span></span><![endif]-->", t.getElementsByTagName("span").length) return t = null, e;
  391. } return a;
  392. }(),
  393. g = function () {
  394. var e = 0; return t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || function (t) {
  395. var r,
  396. a = new Date().getTime(); return r = Math.max(0, 16 - (a - e)), e = a + r, setTimeout(function () {
  397. t(a + r);
  398. }, r);
  399. };
  400. }(),
  401. m = {
  402. isString: function (e) {
  403. return "string" == typeof e;
  404. }, isArray: Array.isArray || function (e) {
  405. return "[object Array]" === Object.prototype.toString.call(e);
  406. }, isFunction: function (e) {
  407. return "[object Function]" === Object.prototype.toString.call(e);
  408. }, isNode: function (e) {
  409. return e && e.nodeType;
  410. }, isNodeList: function (e) {
  411. return "object" == typeof e && /^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e)) && e.length !== a && (0 === e.length || "object" == typeof e[0] && e[0].nodeType > 0);
  412. }, isWrapped: function (e) {
  413. return e && (e.jquery || t.Zepto && t.Zepto.zepto.isZ(e));
  414. }, isSVG: function (e) {
  415. return t.SVGElement && e instanceof t.SVGElement;
  416. }, isEmptyObject: function (e) {
  417. for (var t in e) {
  418. return !1;
  419. } return !0;
  420. }
  421. },
  422. y = !1; if (e.fn && e.fn.jquery ? (f = e, y = !0) : f = t.Velocity.Utilities, 8 >= d && !y) throw new Error("Velocity: IE8 and below require jQuery to be loaded before Velocity."); if (7 >= d) return void (jQuery.fn.velocity = jQuery.fn.animate); var h = 400,
  423. v = "swing",
  424. b = {
  425. State: { isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), isAndroid: /Android/i.test(navigator.userAgent), isGingerbread: /Android 2\.3\.[3-7]/i.test(navigator.userAgent), isChrome: t.chrome, isFirefox: /Firefox/i.test(navigator.userAgent), prefixElement: r.createElement("div"), prefixMatches: {}, scrollAnchor: null, scrollPropertyLeft: null, scrollPropertyTop: null, isTicking: !1, calls: [] }, CSS: {}, Utilities: f, Redirects: {}, Easings: {}, Promise: t.Promise, defaults: { queue: "", duration: h, easing: v, begin: a, complete: a, progress: a, display: a, visibility: a, loop: !1, delay: !1, mobileHA: !0, _cacheValues: !0 }, init: function (e) {
  426. f.data(e, "velocity", { isSVG: m.isSVG(e), isAnimating: !1, computedStyle: null, tweensContainer: null, rootPropertyValueCache: {}, transformCache: {} });
  427. }, hook: null, mock: !1, version: { major: 1, minor: 2, patch: 2 }, debug: !1
  428. }; t.pageYOffset !== a ? (b.State.scrollAnchor = t, b.State.scrollPropertyLeft = "pageXOffset", b.State.scrollPropertyTop = "pageYOffset") : (b.State.scrollAnchor = r.documentElement || r.body.parentNode || r.body, b.State.scrollPropertyLeft = "scrollLeft", b.State.scrollPropertyTop = "scrollTop"); var x = function () {
  429. function e(e) {
  430. return -e.tension * e.x - e.friction * e.v;
  431. } function t(t, r, a) {
  432. var n = { x: t.x + a.dx * r, v: t.v + a.dv * r, tension: t.tension, friction: t.friction }; return { dx: n.v, dv: e(n) };
  433. } function r(r, a) {
  434. var n = { dx: r.v, dv: e(r) },
  435. o = t(r, .5 * a, n),
  436. i = t(r, .5 * a, o),
  437. s = t(r, a, i),
  438. l = 1 / 6 * (n.dx + 2 * (o.dx + i.dx) + s.dx),
  439. u = 1 / 6 * (n.dv + 2 * (o.dv + i.dv) + s.dv); return r.x = r.x + l * a, r.v = r.v + u * a, r;
  440. } return function a(e, t, n) {
  441. var o,
  442. i,
  443. s,
  444. l = { x: -1, v: 0, tension: null, friction: null },
  445. u = [0],
  446. c = 0,
  447. p = 1e-4,
  448. f = .016; for (e = parseFloat(e) || 500, t = parseFloat(t) || 20, n = n || null, l.tension = e, l.friction = t, o = null !== n, o ? (c = a(e, t), i = c / n * f) : i = f; s = r(s || l, i), u.push(1 + s.x), c += 16, Math.abs(s.x) > p && Math.abs(s.v) > p;) { } return o ? function (e) {
  449. return u[e * (u.length - 1) | 0];
  450. } : c;
  451. };
  452. }(); b.Easings = {
  453. linear: function (e) {
  454. return e;
  455. }, swing: function (e) {
  456. return .5 - Math.cos(e * Math.PI) / 2;
  457. }, spring: function (e) {
  458. return 1 - Math.cos(4.5 * e * Math.PI) * Math.exp(6 * -e);
  459. }
  460. }, f.each([["ease", [.25, .1, .25, 1]], ["ease-in", [.42, 0, 1, 1]], ["ease-out", [0, 0, .58, 1]], ["ease-in-out", [.42, 0, .58, 1]], ["easeInSine", [.47, 0, .745, .715]], ["easeOutSine", [.39, .575, .565, 1]], ["easeInOutSine", [.445, .05, .55, .95]], ["easeInQuad", [.55, .085, .68, .53]], ["easeOutQuad", [.25, .46, .45, .94]], ["easeInOutQuad", [.455, .03, .515, .955]], ["easeInCubic", [.55, .055, .675, .19]], ["easeOutCubic", [.215, .61, .355, 1]], ["easeInOutCubic", [.645, .045, .355, 1]], ["easeInQuart", [.895, .03, .685, .22]], ["easeOutQuart", [.165, .84, .44, 1]], ["easeInOutQuart", [.77, 0, .175, 1]], ["easeInQuint", [.755, .05, .855, .06]], ["easeOutQuint", [.23, 1, .32, 1]], ["easeInOutQuint", [.86, 0, .07, 1]], ["easeInExpo", [.95, .05, .795, .035]], ["easeOutExpo", [.19, 1, .22, 1]], ["easeInOutExpo", [1, 0, 0, 1]], ["easeInCirc", [.6, .04, .98, .335]], ["easeOutCirc", [.075, .82, .165, 1]], ["easeInOutCirc", [.785, .135, .15, .86]]], function (e, t) {
  461. b.Easings[t[0]] = l.apply(null, t[1]);
  462. }); var S = b.CSS = {
  463. RegEx: { isHex: /^#([A-f\d]{3}){1,2}$/i, valueUnwrap: /^[A-z]+\((.*)\)$/i, wrappedValueAlreadyExtracted: /[0-9.]+ [0-9.]+ [0-9.]+( [0-9.]+)?/, valueSplit: /([A-z]+\(.+\))|(([A-z0-9#-.]+?)(?=\s|$))/gi }, Lists: { colors: ["fill", "stroke", "stopColor", "color", "backgroundColor", "borderColor", "borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor", "outlineColor"], transformsBase: ["translateX", "translateY", "scale", "scaleX", "scaleY", "skewX", "skewY", "rotateZ"], transforms3D: ["transformPerspective", "translateZ", "scaleZ", "rotateX", "rotateY"] }, Hooks: {
  464. templates: { textShadow: ["Color X Y Blur", "black 0px 0px 0px"], boxShadow: ["Color X Y Blur Spread", "black 0px 0px 0px 0px"], clip: ["Top Right Bottom Left", "0px 0px 0px 0px"], backgroundPosition: ["X Y", "0% 0%"], transformOrigin: ["X Y Z", "50% 50% 0px"], perspectiveOrigin: ["X Y", "50% 50%"] }, registered: {}, register: function () {
  465. for (var e = 0; e < S.Lists.colors.length; e++) {
  466. var t = "color" === S.Lists.colors[e] ? "0 0 0 1" : "255 255 255 1"; S.Hooks.templates[S.Lists.colors[e]] = ["Red Green Blue Alpha", t];
  467. } var r, a, n; if (d) for (r in S.Hooks.templates) {
  468. a = S.Hooks.templates[r], n = a[0].split(" "); var o = a[1].match(S.RegEx.valueSplit); "Color" === n[0] && (n.push(n.shift()), o.push(o.shift()), S.Hooks.templates[r] = [n.join(" "), o.join(" ")]);
  469. } for (r in S.Hooks.templates) {
  470. a = S.Hooks.templates[r], n = a[0].split(" "); for (var e in n) {
  471. var i = r + n[e],
  472. s = e; S.Hooks.registered[i] = [r, s];
  473. }
  474. }
  475. }, getRoot: function (e) {
  476. var t = S.Hooks.registered[e]; return t ? t[0] : e;
  477. }, cleanRootPropertyValue: function (e, t) {
  478. return S.RegEx.valueUnwrap.test(t) && (t = t.match(S.RegEx.valueUnwrap)[1]), S.Values.isCSSNullValue(t) && (t = S.Hooks.templates[e][1]), t;
  479. }, extractValue: function (e, t) {
  480. var r = S.Hooks.registered[e]; if (r) {
  481. var a = r[0],
  482. n = r[1]; return t = S.Hooks.cleanRootPropertyValue(a, t), t.toString().match(S.RegEx.valueSplit)[n];
  483. } return t;
  484. }, injectValue: function (e, t, r) {
  485. var a = S.Hooks.registered[e]; if (a) {
  486. var n,
  487. o,
  488. i = a[0],
  489. s = a[1]; return r = S.Hooks.cleanRootPropertyValue(i, r), n = r.toString().match(S.RegEx.valueSplit), n[s] = t, o = n.join(" ");
  490. } return r;
  491. }
  492. }, Normalizations: {
  493. registered: {
  494. clip: function (e, t, r) {
  495. switch (e) {
  496. case "name":
  497. return "clip"; case "extract":
  498. var a; return S.RegEx.wrappedValueAlreadyExtracted.test(r) ? a = r : (a = r.toString().match(S.RegEx.valueUnwrap), a = a ? a[1].replace(/,(\s+)?/g, " ") : r), a; case "inject":
  499. return "rect(" + r + ")";
  500. }
  501. }, blur: function (e, t, r) {
  502. switch (e) {
  503. case "name":
  504. return b.State.isFirefox ? "filter" : "-webkit-filter"; case "extract":
  505. var a = parseFloat(r); if (!a && 0 !== a) {
  506. var n = r.toString().match(/blur\(([0-9]+[A-z]+)\)/i); a = n ? n[1] : 0;
  507. } return a; case "inject":
  508. return parseFloat(r) ? "blur(" + r + ")" : "none";
  509. }
  510. }, opacity: function (e, t, r) {
  511. if (8 >= d) switch (e) {
  512. case "name":
  513. return "filter"; case "extract":
  514. var a = r.toString().match(/alpha\(opacity=(.*)\)/i); return r = a ? a[1] / 100 : 1; case "inject":
  515. return t.style.zoom = 1, parseFloat(r) >= 1 ? "" : "alpha(opacity=" + parseInt(100 * parseFloat(r), 10) + ")";
  516. } else switch (e) {
  517. case "name":
  518. return "opacity"; case "extract":
  519. return r; case "inject":
  520. return r;
  521. }
  522. }
  523. }, register: function () {
  524. 9 >= d || b.State.isGingerbread || (S.Lists.transformsBase = S.Lists.transformsBase.concat(S.Lists.transforms3D)); for (var e = 0; e < S.Lists.transformsBase.length; e++) {
  525. !function () {
  526. var t = S.Lists.transformsBase[e]; S.Normalizations.registered[t] = function (e, r, n) {
  527. switch (e) {
  528. case "name":
  529. return "transform"; case "extract":
  530. return i(r) === a || i(r).transformCache[t] === a ? /^scale/i.test(t) ? 1 : 0 : i(r).transformCache[t].replace(/[()]/g, ""); case "inject":
  531. var o = !1; switch (t.substr(0, t.length - 1)) {
  532. case "translate":
  533. o = !/(%|px|em|rem|vw|vh|\d)$/i.test(n); break; case "scal": case "scale":
  534. b.State.isAndroid && i(r).transformCache[t] === a && 1 > n && (n = 1), o = !/(\d)$/i.test(n); break; case "skew":
  535. o = !/(deg|\d)$/i.test(n); break; case "rotate":
  536. o = !/(deg|\d)$/i.test(n);
  537. }return o || (i(r).transformCache[t] = "(" + n + ")"), i(r).transformCache[t];
  538. }
  539. };
  540. }();
  541. } for (var e = 0; e < S.Lists.colors.length; e++) {
  542. !function () {
  543. var t = S.Lists.colors[e]; S.Normalizations.registered[t] = function (e, r, n) {
  544. switch (e) {
  545. case "name":
  546. return t; case "extract":
  547. var o; if (S.RegEx.wrappedValueAlreadyExtracted.test(n)) o = n; else {
  548. var i,
  549. s = { black: "rgb(0, 0, 0)", blue: "rgb(0, 0, 255)", gray: "rgb(128, 128, 128)", green: "rgb(0, 128, 0)", red: "rgb(255, 0, 0)", white: "rgb(255, 255, 255)" }; /^[A-z]+$/i.test(n) ? i = s[n] !== a ? s[n] : s.black : S.RegEx.isHex.test(n) ? i = "rgb(" + S.Values.hexToRgb(n).join(" ") + ")" : /^rgba?\(/i.test(n) || (i = s.black), o = (i || n).toString().match(S.RegEx.valueUnwrap)[1].replace(/,(\s+)?/g, " ");
  550. } return 8 >= d || 3 !== o.split(" ").length || (o += " 1"), o; case "inject":
  551. return 8 >= d ? 4 === n.split(" ").length && (n = n.split(/\s+/).slice(0, 3).join(" ")) : 3 === n.split(" ").length && (n += " 1"), (8 >= d ? "rgb" : "rgba") + "(" + n.replace(/\s+/g, ",").replace(/\.(\d)+(?=,)/g, "") + ")";
  552. }
  553. };
  554. }();
  555. }
  556. }
  557. }, Names: {
  558. camelCase: function (e) {
  559. return e.replace(/-(\w)/g, function (e, t) {
  560. return t.toUpperCase();
  561. });
  562. }, SVGAttribute: function (e) {
  563. var t = "width|height|x|y|cx|cy|r|rx|ry|x1|x2|y1|y2"; return (d || b.State.isAndroid && !b.State.isChrome) && (t += "|transform"), new RegExp("^(" + t + ")$", "i").test(e);
  564. }, prefixCheck: function (e) {
  565. if (b.State.prefixMatches[e]) return [b.State.prefixMatches[e], !0]; for (var t = ["", "Webkit", "Moz", "ms", "O"], r = 0, a = t.length; a > r; r++) {
  566. var n; if (n = 0 === r ? e : t[r] + e.replace(/^\w/, function (e) {
  567. return e.toUpperCase();
  568. }), m.isString(b.State.prefixElement.style[n])) return b.State.prefixMatches[e] = n, [n, !0];
  569. } return [e, !1];
  570. }
  571. }, Values: {
  572. hexToRgb: function (e) {
  573. var t,
  574. r = /^#?([a-f\d])([a-f\d])([a-f\d])$/i,
  575. a = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i; return e = e.replace(r, function (e, t, r, a) {
  576. return t + t + r + r + a + a;
  577. }), t = a.exec(e), t ? [parseInt(t[1], 16), parseInt(t[2], 16), parseInt(t[3], 16)] : [0, 0, 0];
  578. }, isCSSNullValue: function (e) {
  579. return 0 == e || /^(none|auto|transparent|(rgba\(0, ?0, ?0, ?0\)))$/i.test(e);
  580. }, getUnitType: function (e) {
  581. return (/^(rotate|skew)/i.test(e) ? "deg" : /(^(scale|scaleX|scaleY|scaleZ|alpha|flexGrow|flexHeight|zIndex|fontWeight)$)|((opacity|red|green|blue|alpha)$)/i.test(e) ? "" : "px"
  582. );
  583. }, getDisplayType: function (e) {
  584. var t = e && e.tagName.toString().toLowerCase(); return (/^(b|big|i|small|tt|abbr|acronym|cite|code|dfn|em|kbd|strong|samp|var|a|bdo|br|img|map|object|q|script|span|sub|sup|button|input|label|select|textarea)$/i.test(t) ? "inline" : /^(li)$/i.test(t) ? "list-item" : /^(tr)$/i.test(t) ? "table-row" : /^(table)$/i.test(t) ? "table" : /^(tbody)$/i.test(t) ? "table-row-group" : "block"
  585. );
  586. }, addClass: function (e, t) {
  587. e.classList ? e.classList.add(t) : e.className += (e.className.length ? " " : "") + t;
  588. }, removeClass: function (e, t) {
  589. e.classList ? e.classList.remove(t) : e.className = e.className.toString().replace(new RegExp("(^|\\s)" + t.split(" ").join("|") + "(\\s|$)", "gi"), " ");
  590. }
  591. }, getPropertyValue: function (e, r, n, o) {
  592. function s(e, r) {
  593. function n() {
  594. u && S.setPropertyValue(e, "display", "none");
  595. } var l = 0; if (8 >= d) l = f.css(e, r); else {
  596. var u = !1; if (/^(width|height)$/.test(r) && 0 === S.getPropertyValue(e, "display") && (u = !0, S.setPropertyValue(e, "display", S.Values.getDisplayType(e))), !o) {
  597. if ("height" === r && "border-box" !== S.getPropertyValue(e, "boxSizing").toString().toLowerCase()) {
  598. var c = e.offsetHeight - (parseFloat(S.getPropertyValue(e, "borderTopWidth")) || 0) - (parseFloat(S.getPropertyValue(e, "borderBottomWidth")) || 0) - (parseFloat(S.getPropertyValue(e, "paddingTop")) || 0) - (parseFloat(S.getPropertyValue(e, "paddingBottom")) || 0); return n(), c;
  599. } if ("width" === r && "border-box" !== S.getPropertyValue(e, "boxSizing").toString().toLowerCase()) {
  600. var p = e.offsetWidth - (parseFloat(S.getPropertyValue(e, "borderLeftWidth")) || 0) - (parseFloat(S.getPropertyValue(e, "borderRightWidth")) || 0) - (parseFloat(S.getPropertyValue(e, "paddingLeft")) || 0) - (parseFloat(S.getPropertyValue(e, "paddingRight")) || 0); return n(), p;
  601. }
  602. } var g; g = i(e) === a ? t.getComputedStyle(e, null) : i(e).computedStyle ? i(e).computedStyle : i(e).computedStyle = t.getComputedStyle(e, null), "borderColor" === r && (r = "borderTopColor"), l = 9 === d && "filter" === r ? g.getPropertyValue(r) : g[r], ("" === l || null === l) && (l = e.style[r]), n();
  603. } if ("auto" === l && /^(top|right|bottom|left)$/i.test(r)) {
  604. var m = s(e, "position"); ("fixed" === m || "absolute" === m && /top|left/i.test(r)) && (l = f(e).position()[r] + "px");
  605. } return l;
  606. } var l; if (S.Hooks.registered[r]) {
  607. var u = r,
  608. c = S.Hooks.getRoot(u); n === a && (n = S.getPropertyValue(e, S.Names.prefixCheck(c)[0])), S.Normalizations.registered[c] && (n = S.Normalizations.registered[c]("extract", e, n)), l = S.Hooks.extractValue(u, n);
  609. } else if (S.Normalizations.registered[r]) {
  610. var p, g; p = S.Normalizations.registered[r]("name", e), "transform" !== p && (g = s(e, S.Names.prefixCheck(p)[0]), S.Values.isCSSNullValue(g) && S.Hooks.templates[r] && (g = S.Hooks.templates[r][1])), l = S.Normalizations.registered[r]("extract", e, g);
  611. } if (!/^[\d-]/.test(l)) if (i(e) && i(e).isSVG && S.Names.SVGAttribute(r)) {
  612. if (/^(height|width)$/i.test(r)) try {
  613. l = e.getBBox()[r];
  614. } catch (m) {
  615. l = 0;
  616. } else l = e.getAttribute(r);
  617. } else l = s(e, S.Names.prefixCheck(r)[0]); return S.Values.isCSSNullValue(l) && (l = 0), b.debug >= 2 && console.log("Get " + r + ": " + l), l;
  618. }, setPropertyValue: function (e, r, a, n, o) {
  619. var s = r; if ("scroll" === r) o.container ? o.container["scroll" + o.direction] = a : "Left" === o.direction ? t.scrollTo(a, o.alternateValue) : t.scrollTo(o.alternateValue, a); else if (S.Normalizations.registered[r] && "transform" === S.Normalizations.registered[r]("name", e)) S.Normalizations.registered[r]("inject", e, a), s = "transform", a = i(e).transformCache[r]; else {
  620. if (S.Hooks.registered[r]) {
  621. var l = r,
  622. u = S.Hooks.getRoot(r); n = n || S.getPropertyValue(e, u), a = S.Hooks.injectValue(l, a, n), r = u;
  623. } if (S.Normalizations.registered[r] && (a = S.Normalizations.registered[r]("inject", e, a), r = S.Normalizations.registered[r]("name", e)), s = S.Names.prefixCheck(r)[0], 8 >= d) try {
  624. e.style[s] = a;
  625. } catch (c) {
  626. b.debug && console.log("Browser does not support [" + a + "] for [" + s + "]");
  627. } else i(e) && i(e).isSVG && S.Names.SVGAttribute(r) ? e.setAttribute(r, a) : e.style[s] = a; b.debug >= 2 && console.log("Set " + r + " (" + s + "): " + a);
  628. } return [s, a];
  629. }, flushTransformCache: function (e) {
  630. function t(t) {
  631. return parseFloat(S.getPropertyValue(e, t));
  632. } var r = ""; if ((d || b.State.isAndroid && !b.State.isChrome) && i(e).isSVG) {
  633. var a = { translate: [t("translateX"), t("translateY")], skewX: [t("skewX")], skewY: [t("skewY")], scale: 1 !== t("scale") ? [t("scale"), t("scale")] : [t("scaleX"), t("scaleY")], rotate: [t("rotateZ"), 0, 0] }; f.each(i(e).transformCache, function (e) {
  634. /^translate/i.test(e) ? e = "translate" : /^scale/i.test(e) ? e = "scale" : /^rotate/i.test(e) && (e = "rotate"), a[e] && (r += e + "(" + a[e].join(" ") + ") ", delete a[e]);
  635. });
  636. } else {
  637. var n, o; f.each(i(e).transformCache, function (t) {
  638. return n = i(e).transformCache[t], "transformPerspective" === t ? (o = n, !0) : (9 === d && "rotateZ" === t && (t = "rotate"), void (r += t + n + " "));
  639. }), o && (r = "perspective" + o + " " + r);
  640. } S.setPropertyValue(e, "transform", r);
  641. }
  642. }; S.Hooks.register(), S.Normalizations.register(), b.hook = function (e, t, r) {
  643. var n = a; return e = o(e), f.each(e, function (e, o) {
  644. if (i(o) === a && b.init(o), r === a) n === a && (n = b.CSS.getPropertyValue(o, t)); else {
  645. var s = b.CSS.setPropertyValue(o, t, r); "transform" === s[0] && b.CSS.flushTransformCache(o), n = s;
  646. }
  647. }), n;
  648. }; var P = function () {
  649. function e() {
  650. return s ? k.promise || null : l;
  651. } function n() {
  652. function e(e) {
  653. function p(e, t) {
  654. var r = a,
  655. n = a,
  656. i = a; return m.isArray(e) ? (r = e[0], !m.isArray(e[1]) && /^[\d-]/.test(e[1]) || m.isFunction(e[1]) || S.RegEx.isHex.test(e[1]) ? i = e[1] : (m.isString(e[1]) && !S.RegEx.isHex.test(e[1]) || m.isArray(e[1])) && (n = t ? e[1] : u(e[1], s.duration), e[2] !== a && (i = e[2]))) : r = e, t || (n = n || s.easing), m.isFunction(r) && (r = r.call(o, V, w)), m.isFunction(i) && (i = i.call(o, V, w)), [r || 0, n, i];
  657. } function d(e, t) {
  658. var r, a; return a = (t || "0").toString().toLowerCase().replace(/[%A-z]+$/, function (e) {
  659. return r = e, "";
  660. }), r || (r = S.Values.getUnitType(e)), [a, r];
  661. } function h() {
  662. var e = { myParent: o.parentNode || r.body, position: S.getPropertyValue(o, "position"), fontSize: S.getPropertyValue(o, "fontSize") },
  663. a = e.position === L.lastPosition && e.myParent === L.lastParent,
  664. n = e.fontSize === L.lastFontSize; L.lastParent = e.myParent, L.lastPosition = e.position, L.lastFontSize = e.fontSize; var s = 100,
  665. l = {}; if (n && a) l.emToPx = L.lastEmToPx, l.percentToPxWidth = L.lastPercentToPxWidth, l.percentToPxHeight = L.lastPercentToPxHeight; else {
  666. var u = i(o).isSVG ? r.createElementNS("http://www.w3.org/2000/svg", "rect") : r.createElement("div"); b.init(u), e.myParent.appendChild(u), f.each(["overflow", "overflowX", "overflowY"], function (e, t) {
  667. b.CSS.setPropertyValue(u, t, "hidden");
  668. }), b.CSS.setPropertyValue(u, "position", e.position), b.CSS.setPropertyValue(u, "fontSize", e.fontSize), b.CSS.setPropertyValue(u, "boxSizing", "content-box"), f.each(["minWidth", "maxWidth", "width", "minHeight", "maxHeight", "height"], function (e, t) {
  669. b.CSS.setPropertyValue(u, t, s + "%");
  670. }), b.CSS.setPropertyValue(u, "paddingLeft", s + "em"), l.percentToPxWidth = L.lastPercentToPxWidth = (parseFloat(S.getPropertyValue(u, "width", null, !0)) || 1) / s, l.percentToPxHeight = L.lastPercentToPxHeight = (parseFloat(S.getPropertyValue(u, "height", null, !0)) || 1) / s, l.emToPx = L.lastEmToPx = (parseFloat(S.getPropertyValue(u, "paddingLeft")) || 1) / s, e.myParent.removeChild(u);
  671. } return null === L.remToPx && (L.remToPx = parseFloat(S.getPropertyValue(r.body, "fontSize")) || 16), null === L.vwToPx && (L.vwToPx = parseFloat(t.innerWidth) / 100, L.vhToPx = parseFloat(t.innerHeight) / 100), l.remToPx = L.remToPx, l.vwToPx = L.vwToPx, l.vhToPx = L.vhToPx, b.debug >= 1 && console.log("Unit ratios: " + JSON.stringify(l), o), l;
  672. } if (s.begin && 0 === V) try {
  673. s.begin.call(g, g);
  674. } catch (x) {
  675. setTimeout(function () {
  676. throw x;
  677. }, 1);
  678. } if ("scroll" === A) {
  679. var P,
  680. C,
  681. T,
  682. F = /^x$/i.test(s.axis) ? "Left" : "Top",
  683. j = parseFloat(s.offset) || 0; s.container ? m.isWrapped(s.container) || m.isNode(s.container) ? (s.container = s.container[0] || s.container, P = s.container["scroll" + F], T = P + f(o).position()[F.toLowerCase()] + j) : s.container = null : (P = b.State.scrollAnchor[b.State["scrollProperty" + F]], C = b.State.scrollAnchor[b.State["scrollProperty" + ("Left" === F ? "Top" : "Left")]], T = f(o).offset()[F.toLowerCase()] + j), l = { scroll: { rootPropertyValue: !1, startValue: P, currentValue: P, endValue: T, unitType: "", easing: s.easing, scrollData: { container: s.container, direction: F, alternateValue: C } }, element: o }, b.debug && console.log("tweensContainer (scroll): ", l.scroll, o);
  684. } else if ("reverse" === A) {
  685. if (!i(o).tweensContainer) return void f.dequeue(o, s.queue); "none" === i(o).opts.display && (i(o).opts.display = "auto"), "hidden" === i(o).opts.visibility && (i(o).opts.visibility = "visible"), i(o).opts.loop = !1, i(o).opts.begin = null, i(o).opts.complete = null, v.easing || delete s.easing, v.duration || delete s.duration, s = f.extend({}, i(o).opts, s); var E = f.extend(!0, {}, i(o).tweensContainer); for (var H in E) {
  686. if ("element" !== H) {
  687. var N = E[H].startValue; E[H].startValue = E[H].currentValue = E[H].endValue, E[H].endValue = N, m.isEmptyObject(v) || (E[H].easing = s.easing), b.debug && console.log("reverse tweensContainer (" + H + "): " + JSON.stringify(E[H]), o);
  688. }
  689. } l = E;
  690. } else if ("start" === A) {
  691. var E; i(o).tweensContainer && i(o).isAnimating === !0 && (E = i(o).tweensContainer), f.each(y, function (e, t) {
  692. if (RegExp("^" + S.Lists.colors.join("$|^") + "$").test(e)) {
  693. var r = p(t, !0),
  694. n = r[0],
  695. o = r[1],
  696. i = r[2]; if (S.RegEx.isHex.test(n)) {
  697. for (var s = ["Red", "Green", "Blue"], l = S.Values.hexToRgb(n), u = i ? S.Values.hexToRgb(i) : a, c = 0; c < s.length; c++) {
  698. var f = [l[c]]; o && f.push(o), u !== a && f.push(u[c]), y[e + s[c]] = f;
  699. } delete y[e];
  700. }
  701. }
  702. }); for (var z in y) {
  703. var O = p(y[z]),
  704. q = O[0],
  705. $ = O[1],
  706. M = O[2]; z = S.Names.camelCase(z); var I = S.Hooks.getRoot(z),
  707. B = !1; if (i(o).isSVG || "tween" === I || S.Names.prefixCheck(I)[1] !== !1 || S.Normalizations.registered[I] !== a) {
  708. (s.display !== a && null !== s.display && "none" !== s.display || s.visibility !== a && "hidden" !== s.visibility) && /opacity|filter/.test(z) && !M && 0 !== q && (M = 0), s._cacheValues && E && E[z] ? (M === a && (M = E[z].endValue + E[z].unitType), B = i(o).rootPropertyValueCache[I]) : S.Hooks.registered[z] ? M === a ? (B = S.getPropertyValue(o, I), M = S.getPropertyValue(o, z, B)) : B = S.Hooks.templates[I][1] : M === a && (M = S.getPropertyValue(o, z)); var W,
  709. G,
  710. Y,
  711. D = !1; if (W = d(z, M), M = W[0], Y = W[1], W = d(z, q), q = W[0].replace(/^([+-\/*])=/, function (e, t) {
  712. return D = t, "";
  713. }), G = W[1], M = parseFloat(M) || 0, q = parseFloat(q) || 0, "%" === G && (/^(fontSize|lineHeight)$/.test(z) ? (q /= 100, G = "em") : /^scale/.test(z) ? (q /= 100, G = "") : /(Red|Green|Blue)$/i.test(z) && (q = q / 100 * 255, G = "")), /[\/*]/.test(D)) G = Y; else if (Y !== G && 0 !== M) if (0 === q) G = Y; else {
  714. n = n || h(); var Q = /margin|padding|left|right|width|text|word|letter/i.test(z) || /X$/.test(z) || "x" === z ? "x" : "y"; switch (Y) {
  715. case "%":
  716. M *= "x" === Q ? n.percentToPxWidth : n.percentToPxHeight; break; case "px":
  717. break; default:
  718. M *= n[Y + "ToPx"];
  719. }switch (G) {
  720. case "%":
  721. M *= 1 / ("x" === Q ? n.percentToPxWidth : n.percentToPxHeight); break; case "px":
  722. break; default:
  723. M *= 1 / n[G + "ToPx"];
  724. }
  725. } switch (D) {
  726. case "+":
  727. q = M + q; break; case "-":
  728. q = M - q; break; case "*":
  729. q = M * q; break; case "/":
  730. q = M / q;
  731. }l[z] = { rootPropertyValue: B, startValue: M, currentValue: M, endValue: q, unitType: G, easing: $ }, b.debug && console.log("tweensContainer (" + z + "): " + JSON.stringify(l[z]), o);
  732. } else b.debug && console.log("Skipping [" + I + "] due to a lack of browser support.");
  733. } l.element = o;
  734. } l.element && (S.Values.addClass(o, "velocity-animating"), R.push(l), "" === s.queue && (i(o).tweensContainer = l, i(o).opts = s), i(o).isAnimating = !0, V === w - 1 ? (b.State.calls.push([R, g, s, null, k.resolver]), b.State.isTicking === !1 && (b.State.isTicking = !0, c())) : V++);
  735. } var n,
  736. o = this,
  737. s = f.extend({}, b.defaults, v),
  738. l = {}; switch (i(o) === a && b.init(o), parseFloat(s.delay) && s.queue !== !1 && f.queue(o, s.queue, function (e) {
  739. b.velocityQueueEntryFlag = !0, i(o).delayTimer = { setTimeout: setTimeout(e, parseFloat(s.delay)), next: e };
  740. }), s.duration.toString().toLowerCase()) {
  741. case "fast":
  742. s.duration = 200; break; case "normal":
  743. s.duration = h; break; case "slow":
  744. s.duration = 600; break; default:
  745. s.duration = parseFloat(s.duration) || 1;
  746. }b.mock !== !1 && (b.mock === !0 ? s.duration = s.delay = 1 : (s.duration *= parseFloat(b.mock) || 1, s.delay *= parseFloat(b.mock) || 1)), s.easing = u(s.easing, s.duration), s.begin && !m.isFunction(s.begin) && (s.begin = null), s.progress && !m.isFunction(s.progress) && (s.progress = null), s.complete && !m.isFunction(s.complete) && (s.complete = null), s.display !== a && null !== s.display && (s.display = s.display.toString().toLowerCase(), "auto" === s.display && (s.display = b.CSS.Values.getDisplayType(o))), s.visibility !== a && null !== s.visibility && (s.visibility = s.visibility.toString().toLowerCase()), s.mobileHA = s.mobileHA && b.State.isMobile && !b.State.isGingerbread, s.queue === !1 ? s.delay ? setTimeout(e, s.delay) : e() : f.queue(o, s.queue, function (t, r) {
  747. return r === !0 ? (k.promise && k.resolver(g), !0) : (b.velocityQueueEntryFlag = !0, void e(t));
  748. }), "" !== s.queue && "fx" !== s.queue || "inprogress" === f.queue(o)[0] || f.dequeue(o);
  749. } var s,
  750. l,
  751. d,
  752. g,
  753. y,
  754. v,
  755. x = arguments[0] && (arguments[0].p || f.isPlainObject(arguments[0].properties) && !arguments[0].properties.names || m.isString(arguments[0].properties)); if (m.isWrapped(this) ? (s = !1, d = 0, g = this, l = this) : (s = !0, d = 1, g = x ? arguments[0].elements || arguments[0].e : arguments[0]), g = o(g)) {
  756. x ? (y = arguments[0].properties || arguments[0].p, v = arguments[0].options || arguments[0].o) : (y = arguments[d], v = arguments[d + 1]); var w = g.length,
  757. V = 0; if (!/^(stop|finish)$/i.test(y) && !f.isPlainObject(v)) {
  758. var C = d + 1; v = {}; for (var T = C; T < arguments.length; T++) {
  759. m.isArray(arguments[T]) || !/^(fast|normal|slow)$/i.test(arguments[T]) && !/^\d/.test(arguments[T]) ? m.isString(arguments[T]) || m.isArray(arguments[T]) ? v.easing = arguments[T] : m.isFunction(arguments[T]) && (v.complete = arguments[T]) : v.duration = arguments[T];
  760. }
  761. } var k = { promise: null, resolver: null, rejecter: null }; s && b.Promise && (k.promise = new b.Promise(function (e, t) {
  762. k.resolver = e, k.rejecter = t;
  763. })); var A; switch (y) {
  764. case "scroll":
  765. A = "scroll"; break; case "reverse":
  766. A = "reverse"; break; case "finish": case "stop":
  767. f.each(g, function (e, t) {
  768. i(t) && i(t).delayTimer && (clearTimeout(i(t).delayTimer.setTimeout), i(t).delayTimer.next && i(t).delayTimer.next(), delete i(t).delayTimer);
  769. }); var F = []; return f.each(b.State.calls, function (e, t) {
  770. t && f.each(t[1], function (r, n) {
  771. var o = v === a ? "" : v; return o === !0 || t[2].queue === o || v === a && t[2].queue === !1 ? void f.each(g, function (r, a) {
  772. a === n && ((v === !0 || m.isString(v)) && (f.each(f.queue(a, m.isString(v) ? v : ""), function (e, t) {
  773. m.isFunction(t) && t(null, !0);
  774. }), f.queue(a, m.isString(v) ? v : "", [])), "stop" === y ? (i(a) && i(a).tweensContainer && o !== !1 && f.each(i(a).tweensContainer, function (e, t) {
  775. t.endValue = t.currentValue;
  776. }), F.push(e)) : "finish" === y && (t[2].duration = 1));
  777. }) : !0;
  778. });
  779. }), "stop" === y && (f.each(F, function (e, t) {
  780. p(t, !0);
  781. }), k.promise && k.resolver(g)), e(); default:
  782. if (!f.isPlainObject(y) || m.isEmptyObject(y)) {
  783. if (m.isString(y) && b.Redirects[y]) {
  784. var j = f.extend({}, v),
  785. E = j.duration,
  786. H = j.delay || 0; return j.backwards === !0 && (g = f.extend(!0, [], g).reverse()), f.each(g, function (e, t) {
  787. parseFloat(j.stagger) ? j.delay = H + parseFloat(j.stagger) * e : m.isFunction(j.stagger) && (j.delay = H + j.stagger.call(t, e, w)), j.drag && (j.duration = parseFloat(E) || (/^(callout|transition)/.test(y) ? 1e3 : h), j.duration = Math.max(j.duration * (j.backwards ? 1 - e / w : (e + 1) / w), .75 * j.duration, 200)), b.Redirects[y].call(t, t, j || {}, e, w, g, k.promise ? k : a);
  788. }), e();
  789. } var N = "Velocity: First argument (" + y + ") was not a property map, a known action, or a registered redirect. Aborting."; return k.promise ? k.rejecter(new Error(N)) : console.log(N), e();
  790. } A = "start";
  791. }var L = { lastParent: null, lastPosition: null, lastFontSize: null, lastPercentToPxWidth: null, lastPercentToPxHeight: null, lastEmToPx: null, remToPx: null, vwToPx: null, vhToPx: null },
  792. R = []; f.each(g, function (e, t) {
  793. m.isNode(t) && n.call(t);
  794. }); var z,
  795. j = f.extend({}, b.defaults, v); if (j.loop = parseInt(j.loop), z = 2 * j.loop - 1, j.loop) for (var O = 0; z > O; O++) {
  796. var q = { delay: j.delay, progress: j.progress }; O === z - 1 && (q.display = j.display, q.visibility = j.visibility, q.complete = j.complete), P(g, "reverse", q);
  797. } return e();
  798. }
  799. }; b = f.extend(P, b), b.animate = P; var w = t.requestAnimationFrame || g; return b.State.isMobile || r.hidden === a || r.addEventListener("visibilitychange", function () {
  800. r.hidden ? (w = function (e) {
  801. return setTimeout(function () {
  802. e(!0);
  803. }, 16);
  804. }, c()) : w = t.requestAnimationFrame || g;
  805. }), e.Velocity = b, e !== t && (e.fn.velocity = P, e.fn.velocity.defaults = b.defaults), f.each(["Down", "Up"], function (e, t) {
  806. b.Redirects["slide" + t] = function (e, r, n, o, i, s) {
  807. var l = f.extend({}, r),
  808. u = l.begin,
  809. c = l.complete,
  810. p = { height: "", marginTop: "", marginBottom: "", paddingTop: "", paddingBottom: "" },
  811. d = {}; l.display === a && (l.display = "Down" === t ? "inline" === b.CSS.Values.getDisplayType(e) ? "inline-block" : "block" : "none"), l.begin = function () {
  812. u && u.call(i, i); for (var r in p) {
  813. d[r] = e.style[r]; var a = b.CSS.getPropertyValue(e, r); p[r] = "Down" === t ? [a, 0] : [0, a];
  814. } d.overflow = e.style.overflow, e.style.overflow = "hidden";
  815. }, l.complete = function () {
  816. for (var t in d) {
  817. e.style[t] = d[t];
  818. } c && c.call(i, i), s && s.resolver(i);
  819. }, b(e, p, l);
  820. };
  821. }), f.each(["In", "Out"], function (e, t) {
  822. b.Redirects["fade" + t] = function (e, r, n, o, i, s) {
  823. var l = f.extend({}, r),
  824. u = { opacity: "In" === t ? 1 : 0 },
  825. c = l.complete; l.complete = n !== o - 1 ? l.begin = null : function () {
  826. c && c.call(i, i), s && s.resolver(i);
  827. }, l.display === a && (l.display = "In" === t ? "auto" : "none"), b(this, u, l);
  828. };
  829. }), b;
  830. }(window.jQuery || window.Zepto || window, window, document);
  831. }));
  832. ; !function (a, b, c, d) {
  833. "use strict";
  834. function k(a, b, c) {
  835. return setTimeout(q(a, c), b);
  836. } function l(a, b, c) {
  837. return Array.isArray(a) ? (m(a, c[b], c), !0) : !1;
  838. } function m(a, b, c) {
  839. var e; if (a) if (a.forEach) a.forEach(b, c); else if (a.length !== d) for (e = 0; e < a.length;) {
  840. b.call(c, a[e], e, a), e++;
  841. } else for (e in a) {
  842. a.hasOwnProperty(e) && b.call(c, a[e], e, a);
  843. }
  844. } function n(a, b, c) {
  845. for (var e = Object.keys(b), f = 0; f < e.length;) {
  846. (!c || c && a[e[f]] === d) && (a[e[f]] = b[e[f]]), f++;
  847. } return a;
  848. } function o(a, b) {
  849. return n(a, b, !0);
  850. } function p(a, b, c) {
  851. var e,
  852. d = b.prototype; e = a.prototype = Object.create(d), e.constructor = a, e._super = d, c && n(e, c);
  853. } function q(a, b) {
  854. return function () {
  855. return a.apply(b, arguments);
  856. };
  857. } function r(a, b) {
  858. return typeof a == g ? a.apply(b ? b[0] || d : d, b) : a;
  859. } function s(a, b) {
  860. return a === d ? b : a;
  861. } function t(a, b, c) {
  862. m(x(b), function (b) {
  863. a.addEventListener(b, c, !1);
  864. });
  865. } function u(a, b, c) {
  866. m(x(b), function (b) {
  867. a.removeEventListener(b, c, !1);
  868. });
  869. } function v(a, b) {
  870. for (; a;) {
  871. if (a == b) return !0; a = a.parentNode;
  872. } return !1;
  873. } function w(a, b) {
  874. return a.indexOf(b) > -1;
  875. } function x(a) {
  876. return a.trim().split(/\s+/g);
  877. } function y(a, b, c) {
  878. if (a.indexOf && !c) return a.indexOf(b); for (var d = 0; d < a.length;) {
  879. if (c && a[d][c] == b || !c && a[d] === b) return d; d++;
  880. } return -1;
  881. } function z(a) {
  882. return Array.prototype.slice.call(a, 0);
  883. } function A(a, b, c) {
  884. for (var d = [], e = [], f = 0; f < a.length;) {
  885. var g = b ? a[f][b] : a[f]; y(e, g) < 0 && d.push(a[f]), e[f] = g, f++;
  886. } return c && (d = b ? d.sort(function (a, c) {
  887. return a[b] > c[b];
  888. }) : d.sort()), d;
  889. } function B(a, b) {
  890. for (var c, f, g = b[0].toUpperCase() + b.slice(1), h = 0; h < e.length;) {
  891. if (c = e[h], f = c ? c + g : b, f in a) return f; h++;
  892. } return d;
  893. } function D() {
  894. return C++;
  895. } function E(a) {
  896. var b = a.ownerDocument; return b.defaultView || b.parentWindow;
  897. } function ab(a, b) {
  898. var c = this; this.manager = a, this.callback = b, this.element = a.element, this.target = a.options.inputTarget, this.domHandler = function (b) {
  899. r(a.options.enable, [a]) && c.handler(b);
  900. }, this.init();
  901. } function bb(a) {
  902. var b,
  903. c = a.options.inputClass; return b = c ? c : H ? wb : I ? Eb : G ? Gb : rb, new b(a, cb);
  904. } function cb(a, b, c) {
  905. var d = c.pointers.length,
  906. e = c.changedPointers.length,
  907. f = b & O && 0 === d - e,
  908. g = b & (Q | R) && 0 === d - e; c.isFirst = !!f, c.isFinal = !!g, f && (a.session = {}), c.eventType = b, db(a, c), a.emit("hammer.input", c), a.recognize(c), a.session.prevInput = c;
  909. } function db(a, b) {
  910. var c = a.session,
  911. d = b.pointers,
  912. e = d.length; c.firstInput || (c.firstInput = gb(b)), e > 1 && !c.firstMultiple ? c.firstMultiple = gb(b) : 1 === e && (c.firstMultiple = !1); var f = c.firstInput,
  913. g = c.firstMultiple,
  914. h = g ? g.center : f.center,
  915. i = b.center = hb(d); b.timeStamp = j(), b.deltaTime = b.timeStamp - f.timeStamp, b.angle = lb(h, i), b.distance = kb(h, i), eb(c, b), b.offsetDirection = jb(b.deltaX, b.deltaY), b.scale = g ? nb(g.pointers, d) : 1, b.rotation = g ? mb(g.pointers, d) : 0, fb(c, b); var k = a.element; v(b.srcEvent.target, k) && (k = b.srcEvent.target), b.target = k;
  916. } function eb(a, b) {
  917. var c = b.center,
  918. d = a.offsetDelta || {},
  919. e = a.prevDelta || {},
  920. f = a.prevInput || {}; (b.eventType === O || f.eventType === Q) && (e = a.prevDelta = { x: f.deltaX || 0, y: f.deltaY || 0 }, d = a.offsetDelta = { x: c.x, y: c.y }), b.deltaX = e.x + (c.x - d.x), b.deltaY = e.y + (c.y - d.y);
  921. } function fb(a, b) {
  922. var f,
  923. g,
  924. h,
  925. j,
  926. c = a.lastInterval || b,
  927. e = b.timeStamp - c.timeStamp; if (b.eventType != R && (e > N || c.velocity === d)) {
  928. var k = c.deltaX - b.deltaX,
  929. l = c.deltaY - b.deltaY,
  930. m = ib(e, k, l); g = m.x, h = m.y, f = i(m.x) > i(m.y) ? m.x : m.y, j = jb(k, l), a.lastInterval = b;
  931. } else f = c.velocity, g = c.velocityX, h = c.velocityY, j = c.direction; b.velocity = f, b.velocityX = g, b.velocityY = h, b.direction = j;
  932. } function gb(a) {
  933. for (var b = [], c = 0; c < a.pointers.length;) {
  934. b[c] = { clientX: h(a.pointers[c].clientX), clientY: h(a.pointers[c].clientY) }, c++;
  935. } return { timeStamp: j(), pointers: b, center: hb(b), deltaX: a.deltaX, deltaY: a.deltaY };
  936. } function hb(a) {
  937. var b = a.length; if (1 === b) return { x: h(a[0].clientX), y: h(a[0].clientY) }; for (var c = 0, d = 0, e = 0; b > e;) {
  938. c += a[e].clientX, d += a[e].clientY, e++;
  939. } return { x: h(c / b), y: h(d / b) };
  940. } function ib(a, b, c) {
  941. return { x: b / a || 0, y: c / a || 0 };
  942. } function jb(a, b) {
  943. return a === b ? S : i(a) >= i(b) ? a > 0 ? T : U : b > 0 ? V : W;
  944. } function kb(a, b, c) {
  945. c || (c = $); var d = b[c[0]] - a[c[0]],
  946. e = b[c[1]] - a[c[1]]; return Math.sqrt(d * d + e * e);
  947. } function lb(a, b, c) {
  948. c || (c = $); var d = b[c[0]] - a[c[0]],
  949. e = b[c[1]] - a[c[1]]; return 180 * Math.atan2(e, d) / Math.PI;
  950. } function mb(a, b) {
  951. return lb(b[1], b[0], _) - lb(a[1], a[0], _);
  952. } function nb(a, b) {
  953. return kb(b[0], b[1], _) / kb(a[0], a[1], _);
  954. } function rb() {
  955. this.evEl = pb, this.evWin = qb, this.allow = !0, this.pressed = !1, ab.apply(this, arguments);
  956. } function wb() {
  957. this.evEl = ub, this.evWin = vb, ab.apply(this, arguments), this.store = this.manager.session.pointerEvents = [];
  958. } function Ab() {
  959. this.evTarget = yb, this.evWin = zb, this.started = !1, ab.apply(this, arguments);
  960. } function Bb(a, b) {
  961. var c = z(a.touches),
  962. d = z(a.changedTouches); return b & (Q | R) && (c = A(c.concat(d), "identifier", !0)), [c, d];
  963. } function Eb() {
  964. this.evTarget = Db, this.targetIds = {}, ab.apply(this, arguments);
  965. } function Fb(a, b) {
  966. var c = z(a.touches),
  967. d = this.targetIds; if (b & (O | P) && 1 === c.length) return d[c[0].identifier] = !0, [c, c]; var e,
  968. f,
  969. g = z(a.changedTouches),
  970. h = [],
  971. i = this.target; if (f = c.filter(function (a) {
  972. return v(a.target, i);
  973. }), b === O) for (e = 0; e < f.length;) {
  974. d[f[e].identifier] = !0, e++;
  975. } for (e = 0; e < g.length;) {
  976. d[g[e].identifier] && h.push(g[e]), b & (Q | R) && delete d[g[e].identifier], e++;
  977. } return h.length ? [A(f.concat(h), "identifier", !0), h] : void 0;
  978. } function Gb() {
  979. ab.apply(this, arguments); var a = q(this.handler, this); this.touch = new Eb(this.manager, a), this.mouse = new rb(this.manager, a);
  980. } function Pb(a, b) {
  981. this.manager = a, this.set(b);
  982. } function Qb(a) {
  983. if (w(a, Mb)) return Mb; var b = w(a, Nb),
  984. c = w(a, Ob); return b && c ? Nb + " " + Ob : b || c ? b ? Nb : Ob : w(a, Lb) ? Lb : Kb;
  985. } function Yb(a) {
  986. this.id = D(), this.manager = null, this.options = o(a || {}, this.defaults), this.options.enable = s(this.options.enable, !0), this.state = Rb, this.simultaneous = {}, this.requireFail = [];
  987. } function Zb(a) {
  988. return a & Wb ? "cancel" : a & Ub ? "end" : a & Tb ? "move" : a & Sb ? "start" : "";
  989. } function $b(a) {
  990. return a == W ? "down" : a == V ? "up" : a == T ? "left" : a == U ? "right" : "";
  991. } function _b(a, b) {
  992. var c = b.manager; return c ? c.get(a) : a;
  993. } function ac() {
  994. Yb.apply(this, arguments);
  995. } function bc() {
  996. ac.apply(this, arguments), this.pX = null, this.pY = null;
  997. } function cc() {
  998. ac.apply(this, arguments);
  999. } function dc() {
  1000. Yb.apply(this, arguments), this._timer = null, this._input = null;
  1001. } function ec() {
  1002. ac.apply(this, arguments);
  1003. } function fc() {
  1004. ac.apply(this, arguments);
  1005. } function gc() {
  1006. Yb.apply(this, arguments), this.pTime = !1, this.pCenter = !1, this._timer = null, this._input = null, this.count = 0;
  1007. } function hc(a, b) {
  1008. return b = b || {}, b.recognizers = s(b.recognizers, hc.defaults.preset), new kc(a, b);
  1009. } function kc(a, b) {
  1010. b = b || {}, this.options = o(b, hc.defaults), this.options.inputTarget = this.options.inputTarget || a, this.handlers = {}, this.session = {}, this.recognizers = [], this.element = a, this.input = bb(this), this.touchAction = new Pb(this, this.options.touchAction), lc(this, !0), m(b.recognizers, function (a) {
  1011. var b = this.add(new a[0](a[1])); a[2] && b.recognizeWith(a[2]), a[3] && b.requireFailure(a[3]);
  1012. }, this);
  1013. } function lc(a, b) {
  1014. var c = a.element; m(a.options.cssProps, function (a, d) {
  1015. c.style[B(c.style, d)] = b ? a : "";
  1016. });
  1017. } function mc(a, c) {
  1018. var d = b.createEvent("Event"); d.initEvent(a, !0, !0), d.gesture = c, c.target.dispatchEvent(d);
  1019. } var e = ["", "webkit", "moz", "MS", "ms", "o"],
  1020. f = b.createElement("div"),
  1021. g = "function",
  1022. h = Math.round,
  1023. i = Math.abs,
  1024. j = Date.now,
  1025. C = 1,
  1026. F = /mobile|tablet|ip(ad|hone|od)|android/i,
  1027. G = "ontouchstart" in a,
  1028. H = B(a, "PointerEvent") !== d,
  1029. I = G && F.test(navigator.userAgent),
  1030. J = "touch",
  1031. K = "pen",
  1032. L = "mouse",
  1033. M = "kinect",
  1034. N = 25,
  1035. O = 1,
  1036. P = 2,
  1037. Q = 4,
  1038. R = 8,
  1039. S = 1,
  1040. T = 2,
  1041. U = 4,
  1042. V = 8,
  1043. W = 16,
  1044. X = T | U,
  1045. Y = V | W,
  1046. Z = X | Y,
  1047. $ = ["x", "y"],
  1048. _ = ["clientX", "clientY"]; ab.prototype = {
  1049. handler: function () { }, init: function () {
  1050. this.evEl && t(this.element, this.evEl, this.domHandler), this.evTarget && t(this.target, this.evTarget, this.domHandler), this.evWin && t(E(this.element), this.evWin, this.domHandler);
  1051. }, destroy: function () {
  1052. this.evEl && u(this.element, this.evEl, this.domHandler), this.evTarget && u(this.target, this.evTarget, this.domHandler), this.evWin && u(E(this.element), this.evWin, this.domHandler);
  1053. }
  1054. }; var ob = { mousedown: O, mousemove: P, mouseup: Q },
  1055. pb = "mousedown",
  1056. qb = "mousemove mouseup"; p(rb, ab, {
  1057. handler: function (a) {
  1058. var b = ob[a.type]; b & O && 0 === a.button && (this.pressed = !0), b & P && 1 !== a.which && (b = Q), this.pressed && this.allow && (b & Q && (this.pressed = !1), this.callback(this.manager, b, { pointers: [a], changedPointers: [a], pointerType: L, srcEvent: a }));
  1059. }
  1060. }); var sb = { pointerdown: O, pointermove: P, pointerup: Q, pointercancel: R, pointerout: R },
  1061. tb = { 2: J, 3: K, 4: L, 5: M },
  1062. ub = "pointerdown",
  1063. vb = "pointermove pointerup pointercancel"; a.MSPointerEvent && (ub = "MSPointerDown", vb = "MSPointerMove MSPointerUp MSPointerCancel"), p(wb, ab, {
  1064. handler: function (a) {
  1065. var b = this.store,
  1066. c = !1,
  1067. d = a.type.toLowerCase().replace("ms", ""),
  1068. e = sb[d],
  1069. f = tb[a.pointerType] || a.pointerType,
  1070. g = f == J,
  1071. h = y(b, a.pointerId, "pointerId"); e & O && (0 === a.button || g) ? 0 > h && (b.push(a), h = b.length - 1) : e & (Q | R) && (c = !0), 0 > h || (b[h] = a, this.callback(this.manager, e, { pointers: b, changedPointers: [a], pointerType: f, srcEvent: a }), c && b.splice(h, 1));
  1072. }
  1073. }); var xb = { touchstart: O, touchmove: P, touchend: Q, touchcancel: R },
  1074. yb = "touchstart",
  1075. zb = "touchstart touchmove touchend touchcancel"; p(Ab, ab, {
  1076. handler: function (a) {
  1077. var b = xb[a.type]; if (b === O && (this.started = !0), this.started) {
  1078. var c = Bb.call(this, a, b); b & (Q | R) && 0 === c[0].length - c[1].length && (this.started = !1), this.callback(this.manager, b, { pointers: c[0], changedPointers: c[1], pointerType: J, srcEvent: a });
  1079. }
  1080. }
  1081. }); var Cb = { touchstart: O, touchmove: P, touchend: Q, touchcancel: R },
  1082. Db = "touchstart touchmove touchend touchcancel"; p(Eb, ab, {
  1083. handler: function (a) {
  1084. var b = Cb[a.type],
  1085. c = Fb.call(this, a, b); c && this.callback(this.manager, b, { pointers: c[0], changedPointers: c[1], pointerType: J, srcEvent: a });
  1086. }
  1087. }), p(Gb, ab, {
  1088. handler: function (a, b, c) {
  1089. var d = c.pointerType == J,
  1090. e = c.pointerType == L; if (d) this.mouse.allow = !1; else if (e && !this.mouse.allow) return; b & (Q | R) && (this.mouse.allow = !0), this.callback(a, b, c);
  1091. }, destroy: function () {
  1092. this.touch.destroy(), this.mouse.destroy();
  1093. }
  1094. }); var Hb = B(f.style, "touchAction"),
  1095. Ib = Hb !== d,
  1096. Jb = "compute",
  1097. Kb = "auto",
  1098. Lb = "manipulation",
  1099. Mb = "none",
  1100. Nb = "pan-x",
  1101. Ob = "pan-y"; Pb.prototype = {
  1102. set: function (a) {
  1103. a == Jb && (a = this.compute()), Ib && (this.manager.element.style[Hb] = a), this.actions = a.toLowerCase().trim();
  1104. }, update: function () {
  1105. this.set(this.manager.options.touchAction);
  1106. }, compute: function () {
  1107. var a = []; return m(this.manager.recognizers, function (b) {
  1108. r(b.options.enable, [b]) && (a = a.concat(b.getTouchAction()));
  1109. }), Qb(a.join(" "));
  1110. }, preventDefaults: function (a) {
  1111. if (!Ib) {
  1112. var b = a.srcEvent,
  1113. c = a.offsetDirection; if (this.manager.session.prevented) return b.preventDefault(), void 0; var d = this.actions,
  1114. e = w(d, Mb),
  1115. f = w(d, Ob),
  1116. g = w(d, Nb); return e || f && c & X || g && c & Y ? this.preventSrc(b) : void 0;
  1117. }
  1118. }, preventSrc: function (a) {
  1119. this.manager.session.prevented = !0, a.preventDefault();
  1120. }
  1121. }; var Rb = 1,
  1122. Sb = 2,
  1123. Tb = 4,
  1124. Ub = 8,
  1125. Vb = Ub,
  1126. Wb = 16,
  1127. Xb = 32; Yb.prototype = {
  1128. defaults: {}, set: function (a) {
  1129. return n(this.options, a), this.manager && this.manager.touchAction.update(), this;
  1130. }, recognizeWith: function (a) {
  1131. if (l(a, "recognizeWith", this)) return this; var b = this.simultaneous; return a = _b(a, this), b[a.id] || (b[a.id] = a, a.recognizeWith(this)), this;
  1132. }, dropRecognizeWith: function (a) {
  1133. return l(a, "dropRecognizeWith", this) ? this : (a = _b(a, this), delete this.simultaneous[a.id], this);
  1134. }, requireFailure: function (a) {
  1135. if (l(a, "requireFailure", this)) return this; var b = this.requireFail; return a = _b(a, this), -1 === y(b, a) && (b.push(a), a.requireFailure(this)), this;
  1136. }, dropRequireFailure: function (a) {
  1137. if (l(a, "dropRequireFailure", this)) return this; a = _b(a, this); var b = y(this.requireFail, a); return b > -1 && this.requireFail.splice(b, 1), this;
  1138. }, hasRequireFailures: function () {
  1139. return this.requireFail.length > 0;
  1140. }, canRecognizeWith: function (a) {
  1141. return !!this.simultaneous[a.id];
  1142. }, emit: function (a) {
  1143. function d(d) {
  1144. b.manager.emit(b.options.event + (d ? Zb(c) : ""), a);
  1145. } var b = this,
  1146. c = this.state; Ub > c && d(!0), d(), c >= Ub && d(!0);
  1147. }, tryEmit: function (a) {
  1148. return this.canEmit() ? this.emit(a) : (this.state = Xb, void 0);
  1149. }, canEmit: function () {
  1150. for (var a = 0; a < this.requireFail.length;) {
  1151. if (!(this.requireFail[a].state & (Xb | Rb))) return !1; a++;
  1152. } return !0;
  1153. }, recognize: function (a) {
  1154. var b = n({}, a); return r(this.options.enable, [this, b]) ? (this.state & (Vb | Wb | Xb) && (this.state = Rb), this.state = this.process(b), this.state & (Sb | Tb | Ub | Wb) && this.tryEmit(b), void 0) : (this.reset(), this.state = Xb, void 0);
  1155. }, process: function () { }, getTouchAction: function () { }, reset: function () { }
  1156. }, p(ac, Yb, {
  1157. defaults: { pointers: 1 }, attrTest: function (a) {
  1158. var b = this.options.pointers; return 0 === b || a.pointers.length === b;
  1159. }, process: function (a) {
  1160. var b = this.state,
  1161. c = a.eventType,
  1162. d = b & (Sb | Tb),
  1163. e = this.attrTest(a); return d && (c & R || !e) ? b | Wb : d || e ? c & Q ? b | Ub : b & Sb ? b | Tb : Sb : Xb;
  1164. }
  1165. }), p(bc, ac, {
  1166. defaults: { event: "pan", threshold: 10, pointers: 1, direction: Z }, getTouchAction: function () {
  1167. var a = this.options.direction,
  1168. b = []; return a & X && b.push(Ob), a & Y && b.push(Nb), b;
  1169. }, directionTest: function (a) {
  1170. var b = this.options,
  1171. c = !0,
  1172. d = a.distance,
  1173. e = a.direction,
  1174. f = a.deltaX,
  1175. g = a.deltaY; return e & b.direction || (b.direction & X ? (e = 0 === f ? S : 0 > f ? T : U, c = f != this.pX, d = Math.abs(a.deltaX)) : (e = 0 === g ? S : 0 > g ? V : W, c = g != this.pY, d = Math.abs(a.deltaY))), a.direction = e, c && d > b.threshold && e & b.direction;
  1176. }, attrTest: function (a) {
  1177. return ac.prototype.attrTest.call(this, a) && (this.state & Sb || !(this.state & Sb) && this.directionTest(a));
  1178. }, emit: function (a) {
  1179. this.pX = a.deltaX, this.pY = a.deltaY; var b = $b(a.direction); b && this.manager.emit(this.options.event + b, a), this._super.emit.call(this, a);
  1180. }
  1181. }), p(cc, ac, {
  1182. defaults: { event: "pinch", threshold: 0, pointers: 2 }, getTouchAction: function () {
  1183. return [Mb];
  1184. }, attrTest: function (a) {
  1185. return this._super.attrTest.call(this, a) && (Math.abs(a.scale - 1) > this.options.threshold || this.state & Sb);
  1186. }, emit: function (a) {
  1187. if (this._super.emit.call(this, a), 1 !== a.scale) {
  1188. var b = a.scale < 1 ? "in" : "out"; this.manager.emit(this.options.event + b, a);
  1189. }
  1190. }
  1191. }), p(dc, Yb, {
  1192. defaults: { event: "press", pointers: 1, time: 500, threshold: 5 }, getTouchAction: function () {
  1193. return [Kb];
  1194. }, process: function (a) {
  1195. var b = this.options,
  1196. c = a.pointers.length === b.pointers,
  1197. d = a.distance < b.threshold,
  1198. e = a.deltaTime > b.time; if (this._input = a, !d || !c || a.eventType & (Q | R) && !e) this.reset(); else if (a.eventType & O) this.reset(), this._timer = k(function () {
  1199. this.state = Vb, this.tryEmit();
  1200. }, b.time, this); else if (a.eventType & Q) return Vb; return Xb;
  1201. }, reset: function () {
  1202. clearTimeout(this._timer);
  1203. }, emit: function (a) {
  1204. this.state === Vb && (a && a.eventType & Q ? this.manager.emit(this.options.event + "up", a) : (this._input.timeStamp = j(), this.manager.emit(this.options.event, this._input)));
  1205. }
  1206. }), p(ec, ac, {
  1207. defaults: { event: "rotate", threshold: 0, pointers: 2 }, getTouchAction: function () {
  1208. return [Mb];
  1209. }, attrTest: function (a) {
  1210. return this._super.attrTest.call(this, a) && (Math.abs(a.rotation) > this.options.threshold || this.state & Sb);
  1211. }
  1212. }), p(fc, ac, {
  1213. defaults: { event: "swipe", threshold: 10, velocity: .65, direction: X | Y, pointers: 1 }, getTouchAction: function () {
  1214. return bc.prototype.getTouchAction.call(this);
  1215. }, attrTest: function (a) {
  1216. var c,
  1217. b = this.options.direction; return b & (X | Y) ? c = a.velocity : b & X ? c = a.velocityX : b & Y && (c = a.velocityY), this._super.attrTest.call(this, a) && b & a.direction && a.distance > this.options.threshold && i(c) > this.options.velocity && a.eventType & Q;
  1218. }, emit: function (a) {
  1219. var b = $b(a.direction); b && this.manager.emit(this.options.event + b, a), this.manager.emit(this.options.event, a);
  1220. }
  1221. }), p(gc, Yb, {
  1222. defaults: { event: "tap", pointers: 1, taps: 1, interval: 300, time: 250, threshold: 2, posThreshold: 10 }, getTouchAction: function () {
  1223. return [Lb];
  1224. }, process: function (a) {
  1225. var b = this.options,
  1226. c = a.pointers.length === b.pointers,
  1227. d = a.distance < b.threshold,
  1228. e = a.deltaTime < b.time; if (this.reset(), a.eventType & O && 0 === this.count) return this.failTimeout(); if (d && e && c) {
  1229. if (a.eventType != Q) return this.failTimeout(); var f = this.pTime ? a.timeStamp - this.pTime < b.interval : !0,
  1230. g = !this.pCenter || kb(this.pCenter, a.center) < b.posThreshold; this.pTime = a.timeStamp, this.pCenter = a.center, g && f ? this.count += 1 : this.count = 1, this._input = a; var h = this.count % b.taps; if (0 === h) return this.hasRequireFailures() ? (this._timer = k(function () {
  1231. this.state = Vb, this.tryEmit();
  1232. }, b.interval, this), Sb) : Vb;
  1233. } return Xb;
  1234. }, failTimeout: function () {
  1235. return this._timer = k(function () {
  1236. this.state = Xb;
  1237. }, this.options.interval, this), Xb;
  1238. }, reset: function () {
  1239. clearTimeout(this._timer);
  1240. }, emit: function () {
  1241. this.state == Vb && (this._input.tapCount = this.count, this.manager.emit(this.options.event, this._input));
  1242. }
  1243. }), hc.VERSION = "2.0.4", hc.defaults = { domEvents: !1, touchAction: Jb, enable: !0, inputTarget: null, inputClass: null, preset: [[ec, { enable: !1 }], [cc, { enable: !1 }, ["rotate"]], [fc, { direction: X }], [bc, { direction: X }, ["swipe"]], [gc], [gc, { event: "doubletap", taps: 2 }, ["tap"]], [dc]], cssProps: { userSelect: "default", touchSelect: "none", touchCallout: "none", contentZooming: "none", userDrag: "none", tapHighlightColor: "rgba(0,0,0,0)" } }; var ic = 1,
  1244. jc = 2; kc.prototype = {
  1245. set: function (a) {
  1246. return n(this.options, a), a.touchAction && this.touchAction.update(), a.inputTarget && (this.input.destroy(), this.input.target = a.inputTarget, this.input.init()), this;
  1247. }, stop: function (a) {
  1248. this.session.stopped = a ? jc : ic;
  1249. }, recognize: function (a) {
  1250. var b = this.session; if (!b.stopped) {
  1251. this.touchAction.preventDefaults(a); var c,
  1252. d = this.recognizers,
  1253. e = b.curRecognizer; (!e || e && e.state & Vb) && (e = b.curRecognizer = null); for (var f = 0; f < d.length;) {
  1254. c = d[f], b.stopped === jc || e && c != e && !c.canRecognizeWith(e) ? c.reset() : c.recognize(a), !e && c.state & (Sb | Tb | Ub) && (e = b.curRecognizer = c), f++;
  1255. }
  1256. }
  1257. }, get: function (a) {
  1258. if (a instanceof Yb) return a; for (var b = this.recognizers, c = 0; c < b.length; c++) {
  1259. if (b[c].options.event == a) return b[c];
  1260. } return null;
  1261. }, add: function (a) {
  1262. if (l(a, "add", this)) return this; var b = this.get(a.options.event); return b && this.remove(b), this.recognizers.push(a), a.manager = this, this.touchAction.update(), a;
  1263. }, remove: function (a) {
  1264. if (l(a, "remove", this)) return this; var b = this.recognizers; return a = this.get(a), b.splice(y(b, a), 1), this.touchAction.update(), this;
  1265. }, on: function (a, b) {
  1266. var c = this.handlers; return m(x(a), function (a) {
  1267. c[a] = c[a] || [], c[a].push(b);
  1268. }), this;
  1269. }, off: function (a, b) {
  1270. var c = this.handlers; return m(x(a), function (a) {
  1271. b ? c[a].splice(y(c[a], b), 1) : delete c[a];
  1272. }), this;
  1273. }, emit: function (a, b) {
  1274. this.options.domEvents && mc(a, b); var c = this.handlers[a] && this.handlers[a].slice(); if (c && c.length) {
  1275. b.type = a, b.preventDefault = function () {
  1276. b.srcEvent.preventDefault();
  1277. }; for (var d = 0; d < c.length;) {
  1278. c[d](b), d++;
  1279. }
  1280. }
  1281. }, destroy: function () {
  1282. this.element && lc(this, !1), this.handlers = {}, this.session = {}, this.input.destroy(), this.element = null;
  1283. }
  1284. }, n(hc, { INPUT_START: O, INPUT_MOVE: P, INPUT_END: Q, INPUT_CANCEL: R, STATE_POSSIBLE: Rb, STATE_BEGAN: Sb, STATE_CHANGED: Tb, STATE_ENDED: Ub, STATE_RECOGNIZED: Vb, STATE_CANCELLED: Wb, STATE_FAILED: Xb, DIRECTION_NONE: S, DIRECTION_LEFT: T, DIRECTION_RIGHT: U, DIRECTION_UP: V, DIRECTION_DOWN: W, DIRECTION_HORIZONTAL: X, DIRECTION_VERTICAL: Y, DIRECTION_ALL: Z, Manager: kc, Input: ab, TouchAction: Pb, TouchInput: Eb, MouseInput: rb, PointerEventInput: wb, TouchMouseInput: Gb, SingleTouchInput: Ab, Recognizer: Yb, AttrRecognizer: ac, Tap: gc, Pan: bc, Swipe: fc, Pinch: cc, Rotate: ec, Press: dc, on: t, off: u, each: m, merge: o, extend: n, inherit: p, bindFn: q, prefixed: B }), typeof define == g && define.amd ? define(function () {
  1285. return hc;
  1286. }) : "undefined" != typeof module && module.exports ? module.exports = hc : a[c] = hc;
  1287. }(window, document, "Hammer");; (function (factory) {
  1288. if (typeof define === 'function' && define.amd) {
  1289. define(['jquery', 'hammerjs'], factory);
  1290. } else if (typeof exports === 'object') {
  1291. factory(require('jquery'), require('hammerjs'));
  1292. } else {
  1293. factory(jQuery, Hammer);
  1294. }
  1295. })(function ($, Hammer) {
  1296. function hammerify(el, options) {
  1297. var $el = $(el);
  1298. if (!$el.data("hammer")) {
  1299. $el.data("hammer", new Hammer($el[0], options));
  1300. }
  1301. }
  1302. $.fn.hammer = function (options) {
  1303. return this.each(function () {
  1304. hammerify(this, options);
  1305. });
  1306. };
  1307. // extend the emit method to also trigger jQuery events
  1308. Hammer.Manager.prototype.emit = function (originalEmit) {
  1309. return function (type, data) {
  1310. originalEmit.call(this, type, data);
  1311. $(this.element).trigger({
  1312. type: type,
  1313. gesture: data
  1314. });
  1315. };
  1316. }(Hammer.Manager.prototype.emit);
  1317. });
  1318. ; // Required for Meteor package, the use of window prevents export by Meteor
  1319. (function (window) {
  1320. if (window.Package) {
  1321. Materialize = {};
  1322. } else {
  1323. window.Materialize = {};
  1324. }
  1325. })(window);
  1326. if (typeof exports !== 'undefined' && !exports.nodeType) {
  1327. if (typeof module !== 'undefined' && !module.nodeType && module.exports) {
  1328. exports = module.exports = Materialize;
  1329. }
  1330. exports.default = Materialize;
  1331. }
  1332. /*
  1333. * raf.js
  1334. * https://github.com/ngryman/raf.js
  1335. *
  1336. * original requestAnimationFrame polyfill by Erik Möller
  1337. * inspired from paul_irish gist and post
  1338. *
  1339. * Copyright (c) 2013 ngryman
  1340. * Licensed under the MIT license.
  1341. */
  1342. (function (window) {
  1343. var lastTime = 0,
  1344. vendors = ['webkit', 'moz'],
  1345. requestAnimationFrame = window.requestAnimationFrame,
  1346. cancelAnimationFrame = window.cancelAnimationFrame,
  1347. i = vendors.length;
  1348. // try to un-prefix existing raf
  1349. while (--i >= 0 && !requestAnimationFrame) {
  1350. requestAnimationFrame = window[vendors[i] + 'RequestAnimationFrame'];
  1351. cancelAnimationFrame = window[vendors[i] + 'CancelRequestAnimationFrame'];
  1352. }
  1353. // polyfill with setTimeout fallback
  1354. // heavily inspired from @darius gist mod: https://gist.github.com/paulirish/1579671#comment-837945
  1355. if (!requestAnimationFrame || !cancelAnimationFrame) {
  1356. requestAnimationFrame = function (callback) {
  1357. var now = +Date.now(),
  1358. nextTime = Math.max(lastTime + 16, now);
  1359. return setTimeout(function () {
  1360. callback(lastTime = nextTime);
  1361. }, nextTime - now);
  1362. };
  1363. cancelAnimationFrame = clearTimeout;
  1364. }
  1365. // export to window
  1366. window.requestAnimationFrame = requestAnimationFrame;
  1367. window.cancelAnimationFrame = cancelAnimationFrame;
  1368. })(window);
  1369. /**
  1370. * Generate approximated selector string for a jQuery object
  1371. * @param {jQuery} obj jQuery object to be parsed
  1372. * @returns {string}
  1373. */
  1374. Materialize.objectSelectorString = function (obj) {
  1375. var tagStr = obj.prop('tagName') || '';
  1376. var idStr = obj.attr('id') || '';
  1377. var classStr = obj.attr('class') || '';
  1378. return (tagStr + idStr + classStr).replace(/\s/g, '');
  1379. };
  1380. // Unique Random ID
  1381. Materialize.guid = function () {
  1382. function s4() {
  1383. return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  1384. }
  1385. return function () {
  1386. return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
  1387. };
  1388. }();
  1389. /**
  1390. * Escapes hash from special characters
  1391. * @param {string} hash String returned from this.hash
  1392. * @returns {string}
  1393. */
  1394. Materialize.escapeHash = function (hash) {
  1395. return hash.replace(/(:|\.|\[|\]|,|=)/g, "\\$1");
  1396. };
  1397. Materialize.elementOrParentIsFixed = function (element) {
  1398. var $element = $(element);
  1399. var $checkElements = $element.add($element.parents());
  1400. var isFixed = false;
  1401. $checkElements.each(function () {
  1402. if ($(this).css("position") === "fixed") {
  1403. isFixed = true;
  1404. return false;
  1405. }
  1406. });
  1407. return isFixed;
  1408. };
  1409. /**
  1410. * Get time in ms
  1411. * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
  1412. * @type {function}
  1413. * @return {number}
  1414. */
  1415. var getTime = Date.now || function () {
  1416. return new Date().getTime();
  1417. };
  1418. /**
  1419. * Returns a function, that, when invoked, will only be triggered at most once
  1420. * during a given window of time. Normally, the throttled function will run
  1421. * as much as it can, without ever going more than once per `wait` duration;
  1422. * but if you'd like to disable the execution on the leading edge, pass
  1423. * `{leading: false}`. To disable execution on the trailing edge, ditto.
  1424. * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
  1425. * @param {function} func
  1426. * @param {number} wait
  1427. * @param {Object=} options
  1428. * @returns {Function}
  1429. */
  1430. Materialize.throttle = function (func, wait, options) {
  1431. var context, args, result;
  1432. var timeout = null;
  1433. var previous = 0;
  1434. options || (options = {});
  1435. var later = function () {
  1436. previous = options.leading === false ? 0 : getTime();
  1437. timeout = null;
  1438. result = func.apply(context, args);
  1439. context = args = null;
  1440. };
  1441. return function () {
  1442. var now = getTime();
  1443. if (!previous && options.leading === false) previous = now;
  1444. var remaining = wait - (now - previous);
  1445. context = this;
  1446. args = arguments;
  1447. if (remaining <= 0) {
  1448. clearTimeout(timeout);
  1449. timeout = null;
  1450. previous = now;
  1451. result = func.apply(context, args);
  1452. context = args = null;
  1453. } else if (!timeout && options.trailing !== false) {
  1454. timeout = setTimeout(later, remaining);
  1455. }
  1456. return result;
  1457. };
  1458. };
  1459. // Velocity has conflicts when loaded with jQuery, this will check for it
  1460. // First, check if in noConflict mode
  1461. var Vel;
  1462. if (jQuery) {
  1463. Vel = jQuery.Velocity;
  1464. } else if ($) {
  1465. Vel = $.Velocity;
  1466. } else {
  1467. Vel = Velocity;
  1468. }
  1469. if (Vel) {
  1470. Materialize.Vel = Vel;
  1471. } else {
  1472. Materialize.Vel = Velocity;
  1473. }
  1474. ; (function ($) {
  1475. $.fn.collapsible = function (options, methodParam) {
  1476. var defaults = {
  1477. accordion: undefined,
  1478. onOpen: undefined,
  1479. onClose: undefined
  1480. };
  1481. var methodName = options;
  1482. options = $.extend(defaults, options);
  1483. return this.each(function () {
  1484. var $this = $(this);
  1485. var $panel_headers = $(this).find('> li > .collapsible-header');
  1486. var collapsible_type = $this.data("collapsible");
  1487. /****************
  1488. Helper Functions
  1489. ****************/
  1490. // Accordion Open
  1491. function accordionOpen(object) {
  1492. $panel_headers = $this.find('> li > .collapsible-header');
  1493. if (object.hasClass('active')) {
  1494. object.parent().addClass('active');
  1495. } else {
  1496. object.parent().removeClass('active');
  1497. }
  1498. if (object.parent().hasClass('active')) {
  1499. object.siblings('.collapsible-body').stop(true, false).slideDown({
  1500. duration: 350, easing: "easeOutQuart", queue: false, complete: function () {
  1501. $(this).css('height', '');
  1502. }
  1503. });
  1504. } else {
  1505. object.siblings('.collapsible-body').stop(true, false).slideUp({
  1506. duration: 350, easing: "easeOutQuart", queue: false, complete: function () {
  1507. $(this).css('height', '');
  1508. }
  1509. });
  1510. }
  1511. $panel_headers.not(object).removeClass('active').parent().removeClass('active');
  1512. // Close previously open accordion elements.
  1513. $panel_headers.not(object).parent().children('.collapsible-body').stop(true, false).each(function () {
  1514. if ($(this).is(':visible')) {
  1515. $(this).slideUp({
  1516. duration: 350,
  1517. easing: "easeOutQuart",
  1518. queue: false,
  1519. complete: function () {
  1520. $(this).css('height', '');
  1521. execCallbacks($(this).siblings('.collapsible-header'));
  1522. }
  1523. });
  1524. }
  1525. });
  1526. }
  1527. // Expandable Open
  1528. function expandableOpen(object) {
  1529. if (object.hasClass('active')) {
  1530. object.parent().addClass('active');
  1531. } else {
  1532. object.parent().removeClass('active');
  1533. }
  1534. if (object.parent().hasClass('active')) {
  1535. object.siblings('.collapsible-body').stop(true, false).slideDown({
  1536. duration: 350, easing: "easeOutQuart", queue: false, complete: function () {
  1537. $(this).css('height', '');
  1538. }
  1539. });
  1540. } else {
  1541. object.siblings('.collapsible-body').stop(true, false).slideUp({
  1542. duration: 350, easing: "easeOutQuart", queue: false, complete: function () {
  1543. $(this).css('height', '');
  1544. }
  1545. });
  1546. }
  1547. }
  1548. // Open collapsible. object: .collapsible-header
  1549. function collapsibleOpen(object, noToggle) {
  1550. if (!noToggle) {
  1551. object.toggleClass('active');
  1552. }
  1553. if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) {
  1554. // Handle Accordion
  1555. accordionOpen(object);
  1556. } else {
  1557. // Handle Expandables
  1558. expandableOpen(object);
  1559. }
  1560. execCallbacks(object);
  1561. }
  1562. // Handle callbacks
  1563. function execCallbacks(object) {
  1564. if (object.hasClass('active')) {
  1565. if (typeof options.onOpen === "function") {
  1566. options.onOpen.call(this, object.parent());
  1567. }
  1568. } else {
  1569. if (typeof options.onClose === "function") {
  1570. options.onClose.call(this, object.parent());
  1571. }
  1572. }
  1573. }
  1574. /**
  1575. * Check if object is children of panel header
  1576. * @param {Object} object Jquery object
  1577. * @return {Boolean} true if it is children
  1578. */
  1579. function isChildrenOfPanelHeader(object) {
  1580. var panelHeader = getPanelHeader(object);
  1581. return panelHeader.length > 0;
  1582. }
  1583. /**
  1584. * Get panel header from a children element
  1585. * @param {Object} object Jquery object
  1586. * @return {Object} panel header object
  1587. */
  1588. function getPanelHeader(object) {
  1589. return object.closest('li > .collapsible-header');
  1590. }
  1591. // Turn off any existing event handlers
  1592. function removeEventHandlers() {
  1593. $this.off('click.collapse', '> li > .collapsible-header');
  1594. }
  1595. /***** End Helper Functions *****/
  1596. // Methods
  1597. if (methodName === 'destroy') {
  1598. removeEventHandlers();
  1599. return;
  1600. } else if (methodParam >= 0 && methodParam < $panel_headers.length) {
  1601. var $curr_header = $panel_headers.eq(methodParam);
  1602. if ($curr_header.length && (methodName === 'open' || methodName === 'close' && $curr_header.hasClass('active'))) {
  1603. collapsibleOpen($curr_header);
  1604. }
  1605. return;
  1606. }
  1607. removeEventHandlers();
  1608. // Add click handler to only direct collapsible header children
  1609. $this.on('click.collapse', '> li > .collapsible-header', function (e) {
  1610. var element = $(e.target);
  1611. if (isChildrenOfPanelHeader(element)) {
  1612. element = getPanelHeader(element);
  1613. }
  1614. collapsibleOpen(element);
  1615. });
  1616. // Open first active
  1617. if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) {
  1618. // Handle Accordion
  1619. collapsibleOpen($panel_headers.filter('.active').first(), true);
  1620. } else {
  1621. // Handle Expandables
  1622. $panel_headers.filter('.active').each(function () {
  1623. collapsibleOpen($(this), true);
  1624. });
  1625. }
  1626. });
  1627. };
  1628. $(document).ready(function () {
  1629. $('.collapsible').collapsible();
  1630. });
  1631. })(jQuery);; (function ($) {
  1632. // Add posibility to scroll to selected option
  1633. // usefull for select for example
  1634. $.fn.scrollTo = function (elem) {
  1635. $(this).scrollTop($(this).scrollTop() - $(this).offset().top + $(elem).offset().top);
  1636. return this;
  1637. };
  1638. $.fn.dropdown = function (options) {
  1639. var defaults = {
  1640. inDuration: 300,
  1641. outDuration: 225,
  1642. constrainWidth: true, // Constrains width of dropdown to the activator
  1643. hover: false,
  1644. gutter: 0, // Spacing from edge
  1645. belowOrigin: false,
  1646. alignment: 'left',
  1647. stopPropagation: false
  1648. };
  1649. // Open dropdown.
  1650. if (options === "open") {
  1651. this.each(function () {
  1652. $(this).trigger('open');
  1653. });
  1654. return false;
  1655. }
  1656. // Close dropdown.
  1657. if (options === "close") {
  1658. this.each(function () {
  1659. $(this).trigger('close');
  1660. });
  1661. return false;
  1662. }
  1663. this.each(function () {
  1664. var origin = $(this);
  1665. var curr_options = $.extend({}, defaults, options);
  1666. var isFocused = false;
  1667. // Dropdown menu
  1668. var activates = $("#" + origin.attr('data-activates'));
  1669. function updateOptions() {
  1670. if (origin.data('induration') !== undefined) curr_options.inDuration = origin.data('induration');
  1671. if (origin.data('outduration') !== undefined) curr_options.outDuration = origin.data('outduration');
  1672. if (origin.data('constrainwidth') !== undefined) curr_options.constrainWidth = origin.data('constrainwidth');
  1673. if (origin.data('hover') !== undefined) curr_options.hover = origin.data('hover');
  1674. if (origin.data('gutter') !== undefined) curr_options.gutter = origin.data('gutter');
  1675. if (origin.data('beloworigin') !== undefined) curr_options.belowOrigin = origin.data('beloworigin');
  1676. if (origin.data('alignment') !== undefined) curr_options.alignment = origin.data('alignment');
  1677. if (origin.data('stoppropagation') !== undefined) curr_options.stopPropagation = origin.data('stoppropagation');
  1678. }
  1679. updateOptions();
  1680. // Attach dropdown to its activator
  1681. origin.after(activates);
  1682. /*
  1683. Helper function to position and resize dropdown.
  1684. Used in hover and click handler.
  1685. */
  1686. function placeDropdown(eventType) {
  1687. // Check for simultaneous focus and click events.
  1688. if (eventType === 'focus') {
  1689. isFocused = true;
  1690. }
  1691. // Check html data attributes
  1692. updateOptions();
  1693. // Set Dropdown state
  1694. activates.addClass('active');
  1695. origin.addClass('active');
  1696. var originWidth = origin[0].getBoundingClientRect().width;
  1697. // Constrain width
  1698. if (curr_options.constrainWidth === true) {
  1699. activates.css('width', originWidth);
  1700. } else {
  1701. activates.css('white-space', 'nowrap');
  1702. }
  1703. // Offscreen detection
  1704. var windowHeight = window.innerHeight;
  1705. var originHeight = origin.innerHeight();
  1706. var offsetLeft = origin.offset().left;
  1707. var offsetTop = origin.offset().top - $(window).scrollTop();
  1708. var currAlignment = curr_options.alignment;
  1709. var gutterSpacing = 0;
  1710. var leftPosition = 0;
  1711. // Below Origin
  1712. var verticalOffset = 0;
  1713. if (curr_options.belowOrigin === true) {
  1714. verticalOffset = originHeight;
  1715. }
  1716. // Check for scrolling positioned container.
  1717. var scrollYOffset = 0;
  1718. var scrollXOffset = 0;
  1719. var wrapper = origin.parent();
  1720. if (!wrapper.is('body')) {
  1721. if (wrapper[0].scrollHeight > wrapper[0].clientHeight) {
  1722. scrollYOffset = wrapper[0].scrollTop;
  1723. }
  1724. if (wrapper[0].scrollWidth > wrapper[0].clientWidth) {
  1725. scrollXOffset = wrapper[0].scrollLeft;
  1726. }
  1727. }
  1728. if (offsetLeft + activates.innerWidth() > $(window).width()) {
  1729. // Dropdown goes past screen on right, force right alignment
  1730. currAlignment = 'right';
  1731. } else if (offsetLeft - activates.innerWidth() + origin.innerWidth() < 0) {
  1732. // Dropdown goes past screen on left, force left alignment
  1733. currAlignment = 'left';
  1734. }
  1735. // Vertical bottom offscreen detection
  1736. if (offsetTop + activates.innerHeight() > windowHeight) {
  1737. // If going upwards still goes offscreen, just crop height of dropdown.
  1738. if (offsetTop + originHeight - activates.innerHeight() < 0) {
  1739. var adjustedHeight = windowHeight - offsetTop - verticalOffset;
  1740. activates.css('max-height', adjustedHeight);
  1741. } else {
  1742. // Flow upwards.
  1743. if (!verticalOffset) {
  1744. verticalOffset += originHeight;
  1745. }
  1746. verticalOffset -= activates.innerHeight();
  1747. }
  1748. }
  1749. // Handle edge alignment
  1750. if (currAlignment === 'left') {
  1751. gutterSpacing = curr_options.gutter;
  1752. leftPosition = origin.position().left + gutterSpacing;
  1753. } else if (currAlignment === 'right') {
  1754. // Material icons fix
  1755. activates.stop(true, true).css({
  1756. opacity: 0,
  1757. left: 0
  1758. });
  1759. var offsetRight = origin.position().left + originWidth - activates.width();
  1760. gutterSpacing = -curr_options.gutter;
  1761. leftPosition = offsetRight + gutterSpacing;
  1762. }
  1763. // Position dropdown
  1764. activates.css({
  1765. position: 'absolute',
  1766. top: origin.position().top + verticalOffset + scrollYOffset == 0 ? 64 : origin.position().top + verticalOffset + scrollYOffset,
  1767. left: leftPosition + scrollXOffset
  1768. });
  1769. // Show dropdown
  1770. activates.slideDown({
  1771. queue: false,
  1772. duration: curr_options.inDuration,
  1773. easing: 'easeOutCubic',
  1774. complete: function () {
  1775. $(this).css('height', '');
  1776. }
  1777. }).animate({ opacity: 1 }, { queue: false, duration: curr_options.inDuration, easing: 'easeOutSine' });
  1778. // Add click close handler to document
  1779. setTimeout(function () {
  1780. $(document).on('click.' + activates.attr('id'), function (e) {
  1781. hideDropdown();
  1782. $(document).off('click.' + activates.attr('id'));
  1783. });
  1784. }, 0);
  1785. }
  1786. function hideDropdown() {
  1787. // Check for simultaneous focus and click events.
  1788. isFocused = false;
  1789. activates.fadeOut(curr_options.outDuration);
  1790. activates.removeClass('active');
  1791. origin.removeClass('active');
  1792. $(document).off('click.' + activates.attr('id'));
  1793. setTimeout(function () {
  1794. activates.css('max-height', '');
  1795. }, curr_options.outDuration);
  1796. }
  1797. // Hover
  1798. if (curr_options.hover) {
  1799. var open = false;
  1800. origin.off('click.' + origin.attr('id'));
  1801. // Hover handler to show dropdown
  1802. origin.on('mouseenter', function (e) {
  1803. // Mouse over
  1804. if (open === false) {
  1805. placeDropdown();
  1806. open = true;
  1807. }
  1808. });
  1809. origin.on('mouseleave', function (e) {
  1810. // If hover on origin then to something other than dropdown content, then close
  1811. var toEl = e.toElement || e.relatedTarget; // added browser compatibility for target element
  1812. if (!$(toEl).closest('.dropdown-content').is(activates)) {
  1813. activates.stop(true, true);
  1814. hideDropdown();
  1815. open = false;
  1816. }
  1817. });
  1818. activates.on('mouseleave', function (e) {
  1819. // Mouse out
  1820. var toEl = e.toElement || e.relatedTarget;
  1821. if (!$(toEl).closest('.dropdown-button').is(origin)) {
  1822. activates.stop(true, true);
  1823. hideDropdown();
  1824. open = false;
  1825. }
  1826. });
  1827. // Click
  1828. } else {
  1829. // Click handler to show dropdown
  1830. origin.off('click.' + origin.attr('id'));
  1831. origin.on('click.' + origin.attr('id'), function (e) {
  1832. if (!isFocused) {
  1833. if (origin[0] == e.currentTarget && !origin.hasClass('active') && $(e.target).closest('.dropdown-content').length === 0) {
  1834. e.preventDefault(); // Prevents button click from moving window
  1835. if (curr_options.stopPropagation) {
  1836. e.stopPropagation();
  1837. }
  1838. placeDropdown('click');
  1839. }
  1840. // If origin is clicked and menu is open, close menu
  1841. else if (origin.hasClass('active')) {
  1842. hideDropdown();
  1843. $(document).off('click.' + activates.attr('id'));
  1844. }
  1845. }
  1846. });
  1847. } // End else
  1848. // Listen to open and close event - useful for select component
  1849. origin.on('open', function (e, eventType) {
  1850. placeDropdown(eventType);
  1851. });
  1852. origin.on('close', hideDropdown);
  1853. });
  1854. }; // End dropdown plugin
  1855. $(document).ready(function () {
  1856. $('.dropdown-button').dropdown();
  1857. });
  1858. })(jQuery);
  1859. ; (function ($, Vel) {
  1860. 'use strict';
  1861. var _defaults = {
  1862. opacity: 0.5,
  1863. inDuration: 250,
  1864. outDuration: 250,
  1865. ready: undefined,
  1866. complete: undefined,
  1867. dismissible: true,
  1868. startingTop: '4%',
  1869. endingTop: '10%'
  1870. };
  1871. /**
  1872. * @class
  1873. *
  1874. */
  1875. var Modal = function () {
  1876. /**
  1877. * Construct Modal instance and set up overlay
  1878. * @constructor
  1879. * @param {jQuery} $el
  1880. * @param {Object} options
  1881. */
  1882. function Modal($el, options) {
  1883. _classCallCheck(this, Modal);
  1884. // If exists, destroy and reinitialize
  1885. if (!!$el[0].M_Modal) {
  1886. $el[0].M_Modal.destroy();
  1887. }
  1888. /**
  1889. * The jQuery element
  1890. * @type {jQuery}
  1891. */
  1892. this.$el = $el;
  1893. /**
  1894. * Options for the modal
  1895. * @member Modal#options
  1896. * @prop {Number} [opacity=0.5] - Opacity of the modal overlay
  1897. * @prop {Number} [inDuration=250] - Length in ms of enter transition
  1898. * @prop {Number} [outDuration=250] - Length in ms of exit transition
  1899. * @prop {Function} ready - Callback function called when modal is finished entering
  1900. * @prop {Function} complete - Callback function called when modal is finished exiting
  1901. * @prop {Boolean} [dismissible=true] - Allow modal to be dismissed by keyboard or overlay click
  1902. * @prop {String} [startingTop='4%'] - startingTop
  1903. * @prop {String} [endingTop='10%'] - endingTop
  1904. */
  1905. this.options = $.extend({}, Modal.defaults, options);
  1906. /**
  1907. * Describes open/close state of modal
  1908. * @type {Boolean}
  1909. */
  1910. this.isOpen = false;
  1911. this.$el[0].M_Modal = this;
  1912. this.id = $el.attr('id');
  1913. this.openingTrigger = undefined;
  1914. this.$overlay = $('<div class="modal-overlay"></div>');
  1915. Modal._increment++;
  1916. Modal._count++;
  1917. this.$overlay[0].style.zIndex = 1000 + Modal._increment * 2;
  1918. this.$el[0].style.zIndex = 1000 + Modal._increment * 2 + 1;
  1919. this.setupEventHandlers();
  1920. }
  1921. _createClass(Modal, [{
  1922. key: 'getInstance',
  1923. /**
  1924. * Get Instance
  1925. */
  1926. value: function getInstance() {
  1927. return this;
  1928. }
  1929. /**
  1930. * Teardown component
  1931. */
  1932. }, {
  1933. key: 'destroy',
  1934. value: function destroy() {
  1935. this.removeEventHandlers();
  1936. this.$el[0].removeAttribute('style');
  1937. if (!!this.$overlay[0].parentNode) {
  1938. this.$overlay[0].parentNode.removeChild(this.$overlay[0]);
  1939. }
  1940. this.$el[0].M_Modal = undefined;
  1941. Modal._count--;
  1942. }
  1943. /**
  1944. * Setup Event Handlers
  1945. */
  1946. }, {
  1947. key: 'setupEventHandlers',
  1948. value: function setupEventHandlers() {
  1949. this.handleOverlayClickBound = this.handleOverlayClick.bind(this);
  1950. this.handleModalCloseClickBound = this.handleModalCloseClick.bind(this);
  1951. if (Modal._count === 1) {
  1952. document.body.addEventListener('click', this.handleTriggerClick);
  1953. }
  1954. this.$overlay[0].addEventListener('click', this.handleOverlayClickBound);
  1955. this.$el[0].addEventListener('click', this.handleModalCloseClickBound);
  1956. }
  1957. /**
  1958. * Remove Event Handlers
  1959. */
  1960. }, {
  1961. key: 'removeEventHandlers',
  1962. value: function removeEventHandlers() {
  1963. if (Modal._count === 0) {
  1964. document.body.removeEventListener('click', this.handleTriggerClick);
  1965. }
  1966. this.$overlay[0].removeEventListener('click', this.handleOverlayClickBound);
  1967. this.$el[0].removeEventListener('click', this.handleModalCloseClickBound);
  1968. }
  1969. /**
  1970. * Handle Trigger Click
  1971. * @param {Event} e
  1972. */
  1973. }, {
  1974. key: 'handleTriggerClick',
  1975. value: function handleTriggerClick(e) {
  1976. var $trigger = $(e.target).closest('.modal-trigger');
  1977. if (e.target && $trigger.length) {
  1978. var modalId = $trigger[0].getAttribute('href');
  1979. if (modalId) {
  1980. modalId = modalId.slice(1);
  1981. } else {
  1982. modalId = $trigger[0].getAttribute('data-target');
  1983. }
  1984. var modalInstance = document.getElementById(modalId).M_Modal;
  1985. if (modalInstance) {
  1986. modalInstance.open($trigger);
  1987. }
  1988. e.preventDefault();
  1989. }
  1990. }
  1991. /**
  1992. * Handle Overlay Click
  1993. */
  1994. }, {
  1995. key: 'handleOverlayClick',
  1996. value: function handleOverlayClick() {
  1997. if (this.options.dismissible) {
  1998. this.close();
  1999. }
  2000. }
  2001. /**
  2002. * Handle Modal Close Click
  2003. * @param {Event} e
  2004. */
  2005. }, {
  2006. key: 'handleModalCloseClick',
  2007. value: function handleModalCloseClick(e) {
  2008. var $closeTrigger = $(e.target).closest('.modal-close');
  2009. if (e.target && $closeTrigger.length) {
  2010. this.close();
  2011. }
  2012. }
  2013. /**
  2014. * Handle Keydown
  2015. * @param {Event} e
  2016. */
  2017. }, {
  2018. key: 'handleKeydown',
  2019. value: function handleKeydown(e) {
  2020. // ESC key
  2021. if (e.keyCode === 27 && this.options.dismissible) {
  2022. this.close();
  2023. }
  2024. }
  2025. /**
  2026. * Animate in modal
  2027. */
  2028. }, {
  2029. key: 'animateIn',
  2030. value: function animateIn() {
  2031. var _this = this;
  2032. // Set initial styles
  2033. $.extend(this.$el[0].style, {
  2034. display: 'block',
  2035. opacity: 0
  2036. });
  2037. $.extend(this.$overlay[0].style, {
  2038. display: 'block',
  2039. opacity: 0
  2040. });
  2041. // Animate overlay
  2042. Vel(this.$overlay[0], { opacity: this.options.opacity }, { duration: this.options.inDuration, queue: false, ease: 'easeOutCubic' });
  2043. // Define modal animation options
  2044. var enterVelocityOptions = {
  2045. duration: this.options.inDuration,
  2046. queue: false,
  2047. ease: 'easeOutCubic',
  2048. // Handle modal ready callback
  2049. complete: function () {
  2050. if (typeof _this.options.ready === 'function') {
  2051. _this.options.ready.call(_this, _this.$el, _this.openingTrigger);
  2052. }
  2053. }
  2054. };
  2055. // Bottom sheet animation
  2056. if (this.$el[0].classList.contains('bottom-sheet')) {
  2057. Vel(this.$el[0], { bottom: 0, opacity: 1 }, enterVelocityOptions);
  2058. // Normal modal animation
  2059. } else {
  2060. Vel.hook(this.$el[0], 'scaleX', 0.7);
  2061. this.$el[0].style.top = this.options.startingTop;
  2062. Vel(this.$el[0], { top: this.options.endingTop, opacity: 1, scaleX: 1 }, enterVelocityOptions);
  2063. }
  2064. }
  2065. /**
  2066. * Animate out modal
  2067. */
  2068. }, {
  2069. key: 'animateOut',
  2070. value: function animateOut() {
  2071. var _this2 = this;
  2072. // Animate overlay
  2073. Vel(this.$overlay[0], { opacity: 0 }, { duration: this.options.outDuration, queue: false, ease: 'easeOutQuart' });
  2074. // Define modal animation options
  2075. var exitVelocityOptions = {
  2076. duration: this.options.outDuration,
  2077. queue: false,
  2078. ease: 'easeOutCubic',
  2079. // Handle modal ready callback
  2080. complete: function () {
  2081. _this2.$el[0].style.display = 'none';
  2082. // Call complete callback
  2083. if (typeof _this2.options.complete === 'function') {
  2084. _this2.options.complete.call(_this2, _this2.$el);
  2085. }
  2086. _this2.$overlay[0].parentNode.removeChild(_this2.$overlay[0]);
  2087. }
  2088. };
  2089. // Bottom sheet animation
  2090. if (this.$el[0].classList.contains('bottom-sheet')) {
  2091. Vel(this.$el[0], { bottom: '-100%', opacity: 0 }, exitVelocityOptions);
  2092. // Normal modal animation
  2093. } else {
  2094. Vel(this.$el[0], { top: this.options.startingTop, opacity: 0, scaleX: 0.7 }, exitVelocityOptions);
  2095. }
  2096. }
  2097. /**
  2098. * Open Modal
  2099. * @param {jQuery} [$trigger]
  2100. */
  2101. }, {
  2102. key: 'open',
  2103. value: function open($trigger) {
  2104. if (this.isOpen) {
  2105. return;
  2106. }
  2107. this.isOpen = true;
  2108. var body = document.body;
  2109. body.style.overflow = 'hidden';
  2110. this.$el[0].classList.add('open');
  2111. body.appendChild(this.$overlay[0]);
  2112. // Set opening trigger, undefined indicates modal was opened by javascript
  2113. this.openingTrigger = !!$trigger ? $trigger : undefined;
  2114. if (this.options.dismissible) {
  2115. this.handleKeydownBound = this.handleKeydown.bind(this);
  2116. document.addEventListener('keydown', this.handleKeydownBound);
  2117. }
  2118. this.animateIn();
  2119. return this;
  2120. }
  2121. /**
  2122. * Close Modal
  2123. */
  2124. }, {
  2125. key: 'close',
  2126. value: function close() {
  2127. if (!this.isOpen) {
  2128. return;
  2129. }
  2130. this.isOpen = false;
  2131. this.$el[0].classList.remove('open');
  2132. document.body.style.overflow = '';
  2133. if (this.options.dismissible) {
  2134. document.removeEventListener('keydown', this.handleKeydownBound);
  2135. }
  2136. this.animateOut();
  2137. return this;
  2138. }
  2139. }], [{
  2140. key: 'init',
  2141. value: function init($els, options) {
  2142. var arr = [];
  2143. $els.each(function () {
  2144. arr.push(new Modal($(this), options));
  2145. });
  2146. return arr;
  2147. }
  2148. }, {
  2149. key: 'defaults',
  2150. get: function () {
  2151. return _defaults;
  2152. }
  2153. }]);
  2154. return Modal;
  2155. }();
  2156. /**
  2157. * @static
  2158. * @memberof Modal
  2159. */
  2160. Modal._increment = 0;
  2161. /**
  2162. * @static
  2163. * @memberof Modal
  2164. */
  2165. Modal._count = 0;
  2166. Materialize.Modal = Modal;
  2167. $.fn.modal = function (methodOrOptions) {
  2168. // Call plugin method if valid method name is passed in
  2169. if (Modal.prototype[methodOrOptions]) {
  2170. // Getter methods
  2171. if (methodOrOptions.slice(0, 3) === 'get') {
  2172. return this.first()[0].M_Modal[methodOrOptions]();
  2173. // Void methods
  2174. } else {
  2175. return this.each(function () {
  2176. this.M_Modal[methodOrOptions]();
  2177. });
  2178. }
  2179. // Initialize plugin if options or no argument is passed in
  2180. } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
  2181. Modal.init(this, arguments[0]);
  2182. return this;
  2183. // Return error if an unrecognized method name is passed in
  2184. } else {
  2185. $.error('Method ' + methodOrOptions + ' does not exist on jQuery.modal');
  2186. }
  2187. };
  2188. })(jQuery, Materialize.Vel);
  2189. ; (function ($) {
  2190. $.fn.materialbox = function () {
  2191. return this.each(function () {
  2192. if ($(this).hasClass('initialized')) {
  2193. return;
  2194. }
  2195. $(this).addClass('initialized');
  2196. var overlayActive = false;
  2197. var doneAnimating = true;
  2198. var inDuration = 275;
  2199. var outDuration = 200;
  2200. var origin = $(this);
  2201. var placeholder = $('<div></div>').addClass('material-placeholder');
  2202. var originalWidth = 0;
  2203. var originalHeight = 0;
  2204. var ancestorsChanged;
  2205. var ancestor;
  2206. var originInlineStyles = origin.attr('style');
  2207. origin.wrap(placeholder);
  2208. // Start click handler
  2209. origin.on('click', function () {
  2210. var placeholder = origin.parent('.material-placeholder');
  2211. var windowWidth = window.innerWidth;
  2212. var windowHeight = window.innerHeight;
  2213. var originalWidth = origin.width();
  2214. var originalHeight = origin.height();
  2215. // If already modal, return to original
  2216. if (doneAnimating === false) {
  2217. returnToOriginal();
  2218. return false;
  2219. } else if (overlayActive && doneAnimating === true) {
  2220. returnToOriginal();
  2221. return false;
  2222. }
  2223. // Set states
  2224. doneAnimating = false;
  2225. origin.addClass('active');
  2226. overlayActive = true;
  2227. // Set positioning for placeholder
  2228. placeholder.css({
  2229. width: placeholder[0].getBoundingClientRect().width,
  2230. height: placeholder[0].getBoundingClientRect().height,
  2231. position: 'relative',
  2232. top: 0,
  2233. left: 0
  2234. });
  2235. // Find ancestor with overflow: hidden; and remove it
  2236. ancestorsChanged = undefined;
  2237. ancestor = placeholder[0].parentNode;
  2238. var count = 0;
  2239. while (ancestor !== null && !$(ancestor).is(document)) {
  2240. var curr = $(ancestor);
  2241. if (curr.css('overflow') !== 'visible') {
  2242. curr.css('overflow', 'visible');
  2243. if (ancestorsChanged === undefined) {
  2244. ancestorsChanged = curr;
  2245. } else {
  2246. ancestorsChanged = ancestorsChanged.add(curr);
  2247. }
  2248. }
  2249. ancestor = ancestor.parentNode;
  2250. }
  2251. // Set css on origin
  2252. origin.css({
  2253. position: 'absolute',
  2254. 'z-index': 1000,
  2255. 'will-change': 'left, top, width, height'
  2256. }).data('width', originalWidth).data('height', originalHeight);
  2257. // Add overlay
  2258. var overlay = $('<div id="materialbox-overlay"></div>').css({
  2259. opacity: 0
  2260. }).click(function () {
  2261. if (doneAnimating === true) returnToOriginal();
  2262. });
  2263. // Put before in origin image to preserve z-index layering.
  2264. origin.before(overlay);
  2265. // Set dimensions if needed
  2266. var overlayOffset = overlay[0].getBoundingClientRect();
  2267. overlay.css({
  2268. width: windowWidth,
  2269. height: windowHeight,
  2270. left: -1 * overlayOffset.left,
  2271. top: -1 * overlayOffset.top
  2272. });
  2273. // Animate Overlay
  2274. overlay.velocity({ opacity: 1 }, { duration: inDuration, queue: false, easing: 'easeOutQuad' });
  2275. // Add and animate caption if it exists
  2276. if (origin.data('caption') !== "") {
  2277. var $photo_caption = $('<div class="materialbox-caption"></div>');
  2278. $photo_caption.text(origin.data('caption'));
  2279. $('body').append($photo_caption);
  2280. $photo_caption.css({ "display": "inline" });
  2281. $photo_caption.velocity({ opacity: 1 }, { duration: inDuration, queue: false, easing: 'easeOutQuad' });
  2282. }
  2283. // Resize Image
  2284. var ratio = 0;
  2285. var widthPercent = originalWidth / windowWidth;
  2286. var heightPercent = originalHeight / windowHeight;
  2287. var newWidth = 0;
  2288. var newHeight = 0;
  2289. if (widthPercent > heightPercent) {
  2290. ratio = originalHeight / originalWidth;
  2291. newWidth = windowWidth * 0.9;
  2292. newHeight = windowWidth * 0.9 * ratio;
  2293. } else {
  2294. ratio = originalWidth / originalHeight;
  2295. newWidth = windowHeight * 0.9 * ratio;
  2296. newHeight = windowHeight * 0.9;
  2297. }
  2298. // Animate image + set z-index
  2299. if (origin.hasClass('responsive-img')) {
  2300. origin.velocity({ 'max-width': newWidth, 'width': originalWidth }, {
  2301. duration: 0, queue: false,
  2302. complete: function () {
  2303. origin.css({ left: 0, top: 0 }).velocity({
  2304. height: newHeight,
  2305. width: newWidth,
  2306. left: $(document).scrollLeft() + windowWidth / 2 - origin.parent('.material-placeholder').offset().left - newWidth / 2,
  2307. top: $(document).scrollTop() + windowHeight / 2 - origin.parent('.material-placeholder').offset().top - newHeight / 2
  2308. }, {
  2309. duration: inDuration,
  2310. queue: false,
  2311. easing: 'easeOutQuad',
  2312. complete: function () {
  2313. doneAnimating = true;
  2314. }
  2315. });
  2316. } // End Complete
  2317. }); // End Velocity
  2318. } else {
  2319. origin.css('left', 0).css('top', 0).velocity({
  2320. height: newHeight,
  2321. width: newWidth,
  2322. left: $(document).scrollLeft() + windowWidth / 2 - origin.parent('.material-placeholder').offset().left - newWidth / 2,
  2323. top: $(document).scrollTop() + windowHeight / 2 - origin.parent('.material-placeholder').offset().top - newHeight / 2
  2324. }, {
  2325. duration: inDuration,
  2326. queue: false,
  2327. easing: 'easeOutQuad',
  2328. complete: function () {
  2329. doneAnimating = true;
  2330. }
  2331. }); // End Velocity
  2332. }
  2333. // Handle Exit triggers
  2334. $(window).on('scroll.materialbox', function () {
  2335. if (overlayActive) {
  2336. returnToOriginal();
  2337. }
  2338. });
  2339. $(window).on('resize.materialbox', function () {
  2340. if (overlayActive) {
  2341. returnToOriginal();
  2342. }
  2343. });
  2344. $(document).on('keyup.materialbox', function (e) {
  2345. // ESC key
  2346. if (e.keyCode === 27 && doneAnimating === true && overlayActive) {
  2347. returnToOriginal();
  2348. }
  2349. });
  2350. }); // End click handler
  2351. // This function returns the modaled image to the original spot
  2352. function returnToOriginal() {
  2353. doneAnimating = false;
  2354. var placeholder = origin.parent('.material-placeholder');
  2355. var windowWidth = window.innerWidth;
  2356. var windowHeight = window.innerHeight;
  2357. var originalWidth = origin.data('width');
  2358. var originalHeight = origin.data('height');
  2359. origin.velocity("stop", true);
  2360. $('#materialbox-overlay').velocity("stop", true);
  2361. $('.materialbox-caption').velocity("stop", true);
  2362. // disable exit handlers
  2363. $(window).off('scroll.materialbox');
  2364. $(document).off('keyup.materialbox');
  2365. $(window).off('resize.materialbox');
  2366. $('#materialbox-overlay').velocity({ opacity: 0 }, {
  2367. duration: outDuration, // Delay prevents animation overlapping
  2368. queue: false, easing: 'easeOutQuad',
  2369. complete: function () {
  2370. // Remove Overlay
  2371. overlayActive = false;
  2372. $(this).remove();
  2373. }
  2374. });
  2375. // Resize Image
  2376. origin.velocity({
  2377. width: originalWidth,
  2378. height: originalHeight,
  2379. left: 0,
  2380. top: 0
  2381. }, {
  2382. duration: outDuration,
  2383. queue: false, easing: 'easeOutQuad',
  2384. complete: function () {
  2385. placeholder.css({
  2386. height: '',
  2387. width: '',
  2388. position: '',
  2389. top: '',
  2390. left: ''
  2391. });
  2392. origin.removeAttr('style');
  2393. origin.attr('style', originInlineStyles);
  2394. // Remove class
  2395. origin.removeClass('active');
  2396. doneAnimating = true;
  2397. // Remove overflow overrides on ancestors
  2398. if (ancestorsChanged) {
  2399. ancestorsChanged.css('overflow', '');
  2400. }
  2401. }
  2402. });
  2403. // Remove Caption + reset css settings on image
  2404. $('.materialbox-caption').velocity({ opacity: 0 }, {
  2405. duration: outDuration, // Delay prevents animation overlapping
  2406. queue: false, easing: 'easeOutQuad',
  2407. complete: function () {
  2408. $(this).remove();
  2409. }
  2410. });
  2411. }
  2412. });
  2413. };
  2414. $(document).ready(function () {
  2415. $('.materialboxed').materialbox();
  2416. });
  2417. })(jQuery);
  2418. ; (function ($) {
  2419. $.fn.parallax = function () {
  2420. var window_width = $(window).width();
  2421. // Parallax Scripts
  2422. return this.each(function (i) {
  2423. var $this = $(this);
  2424. $this.addClass('parallax');
  2425. function updateParallax(initial) {
  2426. var container_height;
  2427. if (window_width < 601) {
  2428. container_height = $this.height() > 0 ? $this.height() : $this.children("img").height();
  2429. } else {
  2430. container_height = $this.height() > 0 ? $this.height() : 500;
  2431. }
  2432. var $img = $this.children("img").first();
  2433. var img_height = $img.height();
  2434. var parallax_dist = img_height - container_height;
  2435. var bottom = $this.offset().top + container_height;
  2436. var top = $this.offset().top;
  2437. var scrollTop = $(window).scrollTop();
  2438. var windowHeight = window.innerHeight;
  2439. var windowBottom = scrollTop + windowHeight;
  2440. var percentScrolled = (windowBottom - top) / (container_height + windowHeight);
  2441. var parallax = Math.round(parallax_dist * percentScrolled);
  2442. if (initial) {
  2443. $img.css('display', 'block');
  2444. }
  2445. if (bottom > scrollTop && top < scrollTop + windowHeight) {
  2446. $img.css('transform', "translate3D(-50%," + parallax + "px, 0)");
  2447. }
  2448. }
  2449. // Wait for image load
  2450. $this.children("img").one("load", function () {
  2451. updateParallax(true);
  2452. }).each(function () {
  2453. if (this.complete) $(this).trigger("load");
  2454. });
  2455. $(window).scroll(function () {
  2456. window_width = $(window).width();
  2457. updateParallax(false);
  2458. });
  2459. $(window).resize(function () {
  2460. window_width = $(window).width();
  2461. updateParallax(false);
  2462. });
  2463. });
  2464. };
  2465. })(jQuery);
  2466. ; (function ($) {
  2467. var methods = {
  2468. init: function (options) {
  2469. var defaults = {
  2470. onShow: null,
  2471. swipeable: false,
  2472. responsiveThreshold: Infinity // breakpoint for swipeable
  2473. };
  2474. options = $.extend(defaults, options);
  2475. var namespace = Materialize.objectSelectorString($(this));
  2476. return this.each(function (i) {
  2477. var uniqueNamespace = namespace + i;
  2478. // For each set of tabs, we want to keep track of
  2479. // which tab is active and its associated content
  2480. var $this = $(this),
  2481. window_width = $(window).width();
  2482. var $active,
  2483. $content,
  2484. $links = $this.find('li.tab a'),
  2485. $tabs_width = $this.width(),
  2486. $tabs_content = $(),
  2487. $tabs_wrapper,
  2488. $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length,
  2489. $indicator,
  2490. index = 0,
  2491. prev_index = 0,
  2492. clicked = false,
  2493. clickedTimeout,
  2494. transition = 300;
  2495. // Finds right attribute for indicator based on active tab.
  2496. // el: jQuery Object
  2497. var calcRightPos = function (el) {
  2498. return Math.ceil($tabs_width - el.position().left - el[0].getBoundingClientRect().width - $this.scrollLeft());
  2499. };
  2500. // Finds left attribute for indicator based on active tab.
  2501. // el: jQuery Object
  2502. var calcLeftPos = function (el) {
  2503. return Math.floor(el.position().left + $this.scrollLeft());
  2504. };
  2505. // Animates Indicator to active tab.
  2506. // prev_index: Number
  2507. var animateIndicator = function (prev_index) {
  2508. if (index - prev_index >= 0) {
  2509. $indicator.velocity({ "right": calcRightPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad' });
  2510. $indicator.velocity({ "left": calcLeftPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad', delay: 90 });
  2511. } else {
  2512. $indicator.velocity({ "left": calcLeftPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad' });
  2513. $indicator.velocity({ "right": calcRightPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad', delay: 90 });
  2514. }
  2515. };
  2516. // Change swipeable according to responsive threshold
  2517. if (options.swipeable) {
  2518. if (window_width > options.responsiveThreshold) {
  2519. options.swipeable = false;
  2520. }
  2521. }
  2522. // If the location.hash matches one of the links, use that as the active tab.
  2523. $active = $($links.filter('[href="' + location.hash + '"]'));
  2524. // If no match is found, use the first link or any with class 'active' as the initial active tab.
  2525. if ($active.length === 0) {
  2526. $active = $(this).find('li.tab a.active').first();
  2527. }
  2528. if ($active.length === 0) {
  2529. $active = $(this).find('li.tab a').first();
  2530. }
  2531. $active.addClass('active');
  2532. index = $links.index($active);
  2533. if (index < 0) {
  2534. index = 0;
  2535. }
  2536. if ($active[0] !== undefined) {
  2537. $content = $($active[0].hash);
  2538. $content.addClass('active');
  2539. }
  2540. // append indicator then set indicator width to tab width
  2541. if (!$this.find('.indicator').length) {
  2542. $this.append('<li class="indicator"></li>');
  2543. }
  2544. $indicator = $this.find('.indicator');
  2545. // we make sure that the indicator is at the end of the tabs
  2546. $this.append($indicator);
  2547. if ($this.is(":visible")) {
  2548. // $indicator.css({"right": $tabs_width - ((index + 1) * $tab_width)});
  2549. // $indicator.css({"left": index * $tab_width});
  2550. setTimeout(function () {
  2551. $indicator.css({ "right": calcRightPos($active) });
  2552. $indicator.css({ "left": calcLeftPos($active) });
  2553. }, 0);
  2554. }
  2555. $(window).off('resize.tabs-' + uniqueNamespace).on('resize.tabs-' + uniqueNamespace, function () {
  2556. $tabs_width = $this.width();
  2557. $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
  2558. if (index < 0) {
  2559. index = 0;
  2560. }
  2561. if ($tab_width !== 0 && $tabs_width !== 0) {
  2562. $indicator.css({ "right": calcRightPos($active) });
  2563. $indicator.css({ "left": calcLeftPos($active) });
  2564. }
  2565. });
  2566. // Initialize Tabs Content.
  2567. if (options.swipeable) {
  2568. // TODO: Duplicate calls with swipeable? handle multiple div wrapping.
  2569. $links.each(function () {
  2570. var $curr_content = $(Materialize.escapeHash(this.hash));
  2571. $curr_content.addClass('carousel-item');
  2572. $tabs_content = $tabs_content.add($curr_content);
  2573. });
  2574. $tabs_wrapper = $tabs_content.wrapAll('<div class="tabs-content carousel"></div>');
  2575. $tabs_content.css('display', '');
  2576. $('.tabs-content.carousel').carousel({
  2577. fullWidth: true,
  2578. noWrap: true,
  2579. onCycleTo: function (item) {
  2580. if (!clicked) {
  2581. var prev_index = index;
  2582. index = $tabs_wrapper.index(item);
  2583. $active.removeClass('active');
  2584. $active = $links.eq(index);
  2585. $active.addClass('active');
  2586. animateIndicator(prev_index);
  2587. if (typeof options.onShow === "function") {
  2588. options.onShow.call($this[0], $content);
  2589. }
  2590. }
  2591. }
  2592. });
  2593. } else {
  2594. // Hide the remaining content
  2595. $links.not($active).each(function () {
  2596. $(Materialize.escapeHash(this.hash)).hide();
  2597. });
  2598. }
  2599. // Bind the click event handler
  2600. $this.off('click.tabs').on('click.tabs', 'a', function (e) {
  2601. if ($(this).parent().hasClass('disabled')) {
  2602. e.preventDefault();
  2603. return;
  2604. }
  2605. // Act as regular link if target attribute is specified.
  2606. if (!!$(this).attr("target")) {
  2607. return;
  2608. }
  2609. clicked = true;
  2610. $tabs_width = $this.width();
  2611. $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
  2612. // Make the old tab inactive.
  2613. $active.removeClass('active');
  2614. var $oldContent = $content;
  2615. // Update the variables with the new link and content
  2616. $active = $(this);
  2617. $content = $(Materialize.escapeHash(this.hash));
  2618. $links = $this.find('li.tab a');
  2619. var activeRect = $active.position();
  2620. // Make the tab active.
  2621. $active.addClass('active');
  2622. prev_index = index;
  2623. index = $links.index($(this));
  2624. if (index < 0) {
  2625. index = 0;
  2626. }
  2627. // Change url to current tab
  2628. // window.location.hash = $active.attr('href');
  2629. // Swap content
  2630. if (options.swipeable) {
  2631. if ($tabs_content.length) {
  2632. $tabs_content.carousel('set', index, function () {
  2633. if (typeof options.onShow === "function") {
  2634. options.onShow.call($this[0], $content);
  2635. }
  2636. });
  2637. }
  2638. } else {
  2639. if ($content !== undefined) {
  2640. $content.show();
  2641. $content.addClass('active');
  2642. if (typeof options.onShow === "function") {
  2643. options.onShow.call(this, $content);
  2644. }
  2645. }
  2646. if ($oldContent !== undefined && !$oldContent.is($content)) {
  2647. $oldContent.hide();
  2648. $oldContent.removeClass('active');
  2649. }
  2650. }
  2651. // Reset clicked state
  2652. clickedTimeout = setTimeout(function () {
  2653. clicked = false;
  2654. }, transition);
  2655. // Update indicator
  2656. animateIndicator(prev_index);
  2657. // Prevent the anchor's default click action
  2658. e.preventDefault();
  2659. });
  2660. });
  2661. },
  2662. select_tab: function (id) {
  2663. this.find('a[href="#' + id + '"]').trigger('click');
  2664. }
  2665. };
  2666. $.fn.tabs = function (methodOrOptions) {
  2667. if (methods[methodOrOptions]) {
  2668. return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
  2669. } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
  2670. // Default to "init"
  2671. return methods.init.apply(this, arguments);
  2672. } else {
  2673. $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tabs');
  2674. }
  2675. };
  2676. $(document).ready(function () {
  2677. $('ul.tabs').tabs();
  2678. });
  2679. })(jQuery);
  2680. ; (function ($) {
  2681. $.fn.tooltip = function (options) {
  2682. var timeout = null,
  2683. margin = 5;
  2684. // Defaults
  2685. var defaults = {
  2686. delay: 350,
  2687. tooltip: '',
  2688. position: 'bottom',
  2689. html: false
  2690. };
  2691. // Remove tooltip from the activator
  2692. if (options === "remove") {
  2693. this.each(function () {
  2694. $('#' + $(this).attr('data-tooltip-id')).remove();
  2695. $(this).removeAttr('data-tooltip-id');
  2696. $(this).off('mouseenter.tooltip mouseleave.tooltip');
  2697. });
  2698. return false;
  2699. }
  2700. options = $.extend(defaults, options);
  2701. return this.each(function () {
  2702. var tooltipId = Materialize.guid();
  2703. var origin = $(this);
  2704. // Destroy old tooltip
  2705. if (origin.attr('data-tooltip-id')) {
  2706. $('#' + origin.attr('data-tooltip-id')).remove();
  2707. }
  2708. origin.attr('data-tooltip-id', tooltipId);
  2709. // Get attributes.
  2710. var allowHtml, tooltipDelay, tooltipPosition, tooltipText, tooltipEl, backdrop;
  2711. var setAttributes = function () {
  2712. allowHtml = origin.attr('data-html') ? origin.attr('data-html') === 'true' : options.html;
  2713. tooltipDelay = origin.attr('data-delay');
  2714. tooltipDelay = tooltipDelay === undefined || tooltipDelay === '' ? options.delay : tooltipDelay;
  2715. tooltipPosition = origin.attr('data-position');
  2716. tooltipPosition = tooltipPosition === undefined || tooltipPosition === '' ? options.position : tooltipPosition;
  2717. tooltipText = origin.attr('data-tooltip');
  2718. tooltipText = tooltipText === undefined || tooltipText === '' ? options.tooltip : tooltipText;
  2719. };
  2720. setAttributes();
  2721. var renderTooltipEl = function () {
  2722. var tooltip = $('<div class="material-tooltip"></div>');
  2723. // Create Text span
  2724. if (allowHtml) {
  2725. tooltipText = $('<span></span>').html(tooltipText);
  2726. } else {
  2727. tooltipText = $('<span></span>').text(tooltipText);
  2728. }
  2729. // Create tooltip
  2730. tooltip.append(tooltipText).appendTo($('body')).attr('id', tooltipId);
  2731. // Create backdrop
  2732. backdrop = $('<div class="backdrop"></div>');
  2733. backdrop.appendTo(tooltip);
  2734. return tooltip;
  2735. };
  2736. tooltipEl = renderTooltipEl();
  2737. // Destroy previously binded events
  2738. origin.off('mouseenter.tooltip mouseleave.tooltip');
  2739. // Mouse In
  2740. var started = false,
  2741. timeoutRef;
  2742. origin.on({
  2743. 'mouseenter.tooltip': function (e) {
  2744. var showTooltip = function () {
  2745. setAttributes();
  2746. started = true;
  2747. tooltipEl.velocity('stop');
  2748. backdrop.velocity('stop');
  2749. tooltipEl.css({ visibility: 'visible', left: '0px', top: '0px' });
  2750. // Tooltip positioning
  2751. var originWidth = origin.outerWidth();
  2752. var originHeight = origin.outerHeight();
  2753. var tooltipHeight = tooltipEl.outerHeight();
  2754. var tooltipWidth = tooltipEl.outerWidth();
  2755. var tooltipVerticalMovement = '0px';
  2756. var tooltipHorizontalMovement = '0px';
  2757. var backdropOffsetWidth = backdrop[0].offsetWidth;
  2758. var backdropOffsetHeight = backdrop[0].offsetHeight;
  2759. var scaleXFactor = 8;
  2760. var scaleYFactor = 8;
  2761. var scaleFactor = 0;
  2762. var targetTop, targetLeft, newCoordinates;
  2763. if (tooltipPosition === "top") {
  2764. // Top Position
  2765. targetTop = origin.offset().top - tooltipHeight - margin;
  2766. targetLeft = origin.offset().left + originWidth / 2 - tooltipWidth / 2;
  2767. newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
  2768. tooltipVerticalMovement = '-10px';
  2769. backdrop.css({
  2770. bottom: 0,
  2771. left: 0,
  2772. borderRadius: '14px 14px 0 0',
  2773. transformOrigin: '50% 100%',
  2774. marginTop: tooltipHeight,
  2775. marginLeft: tooltipWidth / 2 - backdropOffsetWidth / 2
  2776. });
  2777. }
  2778. // Left Position
  2779. else if (tooltipPosition === "left") {
  2780. targetTop = origin.offset().top + originHeight / 2 - tooltipHeight / 2;
  2781. targetLeft = origin.offset().left - tooltipWidth - margin;
  2782. newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
  2783. tooltipHorizontalMovement = '-10px';
  2784. backdrop.css({
  2785. top: '-7px',
  2786. right: 0,
  2787. width: '14px',
  2788. height: '14px',
  2789. borderRadius: '14px 0 0 14px',
  2790. transformOrigin: '95% 50%',
  2791. marginTop: tooltipHeight / 2,
  2792. marginLeft: tooltipWidth
  2793. });
  2794. }
  2795. // Right Position
  2796. else if (tooltipPosition === "right") {
  2797. targetTop = origin.offset().top + originHeight / 2 - tooltipHeight / 2;
  2798. targetLeft = origin.offset().left + originWidth + margin;
  2799. newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
  2800. tooltipHorizontalMovement = '+10px';
  2801. backdrop.css({
  2802. top: '-7px',
  2803. left: 0,
  2804. width: '14px',
  2805. height: '14px',
  2806. borderRadius: '0 14px 14px 0',
  2807. transformOrigin: '5% 50%',
  2808. marginTop: tooltipHeight / 2,
  2809. marginLeft: '0px'
  2810. });
  2811. } else {
  2812. // Bottom Position
  2813. targetTop = origin.offset().top + origin.outerHeight() + margin;
  2814. targetLeft = origin.offset().left + originWidth / 2 - tooltipWidth / 2;
  2815. newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
  2816. tooltipVerticalMovement = '+10px';
  2817. backdrop.css({
  2818. top: 0,
  2819. left: 0,
  2820. marginLeft: tooltipWidth / 2 - backdropOffsetWidth / 2
  2821. });
  2822. }
  2823. // Set tooptip css placement
  2824. tooltipEl.css({
  2825. top: newCoordinates.y,
  2826. left: newCoordinates.x
  2827. });
  2828. // Calculate Scale to fill
  2829. scaleXFactor = Math.SQRT2 * tooltipWidth / parseInt(backdropOffsetWidth);
  2830. scaleYFactor = Math.SQRT2 * tooltipHeight / parseInt(backdropOffsetHeight);
  2831. scaleFactor = Math.max(scaleXFactor, scaleYFactor);
  2832. tooltipEl.velocity({ translateY: tooltipVerticalMovement, translateX: tooltipHorizontalMovement }, { duration: 350, queue: false }).velocity({ opacity: 1 }, { duration: 300, delay: 50, queue: false });
  2833. backdrop.css({ visibility: 'visible' }).velocity({ opacity: 1 }, { duration: 55, delay: 0, queue: false }).velocity({ scaleX: scaleFactor, scaleY: scaleFactor }, { duration: 300, delay: 0, queue: false, easing: 'easeInOutQuad' });
  2834. };
  2835. timeoutRef = setTimeout(showTooltip, tooltipDelay); // End Interval
  2836. // Mouse Out
  2837. },
  2838. 'mouseleave.tooltip': function () {
  2839. // Reset State
  2840. started = false;
  2841. clearTimeout(timeoutRef);
  2842. // Animate back
  2843. setTimeout(function () {
  2844. if (started !== true) {
  2845. tooltipEl.velocity({
  2846. opacity: 0, translateY: 0, translateX: 0
  2847. }, { duration: 225, queue: false });
  2848. backdrop.velocity({ opacity: 0, scaleX: 1, scaleY: 1 }, {
  2849. duration: 225,
  2850. queue: false,
  2851. complete: function () {
  2852. backdrop.css({ visibility: 'hidden' });
  2853. tooltipEl.css({ visibility: 'hidden' });
  2854. started = false;
  2855. }
  2856. });
  2857. }
  2858. }, 225);
  2859. }
  2860. });
  2861. });
  2862. };
  2863. var repositionWithinScreen = function (x, y, width, height) {
  2864. var newX = x;
  2865. var newY = y;
  2866. if (newX < 0) {
  2867. newX = 4;
  2868. } else if (newX + width > window.innerWidth) {
  2869. newX -= newX + width - window.innerWidth;
  2870. }
  2871. if (newY < 0) {
  2872. newY = 4;
  2873. } else if (newY + height > window.innerHeight + $(window).scrollTop) {
  2874. newY -= newY + height - window.innerHeight;
  2875. }
  2876. return { x: newX, y: newY };
  2877. };
  2878. $(document).ready(function () {
  2879. $('.tooltipped').tooltip();
  2880. });
  2881. })(jQuery);
  2882. ; /*!
  2883. * Waves v0.6.4
  2884. * http://fian.my.id/Waves
  2885. *
  2886. * Copyright 2014 Alfiana E. Sibuea and other contributors
  2887. * Released under the MIT license
  2888. * https://github.com/fians/Waves/blob/master/LICENSE
  2889. */
  2890. ; (function (window) {
  2891. 'use strict';
  2892. var Waves = Waves || {};
  2893. var $$ = document.querySelectorAll.bind(document);
  2894. // Find exact position of element
  2895. function isWindow(obj) {
  2896. return obj !== null && obj === obj.window;
  2897. }
  2898. function getWindow(elem) {
  2899. return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
  2900. }
  2901. function offset(elem) {
  2902. var docElem,
  2903. win,
  2904. box = { top: 0, left: 0 },
  2905. doc = elem && elem.ownerDocument;
  2906. docElem = doc.documentElement;
  2907. if (typeof elem.getBoundingClientRect !== typeof undefined) {
  2908. box = elem.getBoundingClientRect();
  2909. }
  2910. win = getWindow(doc);
  2911. return {
  2912. top: box.top + win.pageYOffset - docElem.clientTop,
  2913. left: box.left + win.pageXOffset - docElem.clientLeft
  2914. };
  2915. }
  2916. function convertStyle(obj) {
  2917. var style = '';
  2918. for (var a in obj) {
  2919. if (obj.hasOwnProperty(a)) {
  2920. style += a + ':' + obj[a] + ';';
  2921. }
  2922. }
  2923. return style;
  2924. }
  2925. var Effect = {
  2926. // Effect delay
  2927. duration: 750,
  2928. show: function (e, element) {
  2929. if ($('.waves-ripple')[0]) {
  2930. $('.waves-ripple')[0].remove();
  2931. }
  2932. // Disable right click
  2933. if (e.button === 2) {
  2934. return false;
  2935. }
  2936. var el = element || this;
  2937. // Create ripple
  2938. var ripple = document.createElement('div');
  2939. ripple.className = 'waves-ripple';
  2940. el.appendChild(ripple);
  2941. // Get click coordinate and element witdh
  2942. var pos = offset(el);
  2943. var relativeY = e.pageY - pos.top;
  2944. var relativeX = e.pageX - pos.left;
  2945. var scale = 'scale(' + el.clientWidth / 100 * 10 + ')';
  2946. // Support for touch devices
  2947. if ('touches' in e) {
  2948. relativeY = e.touches[0].pageY - pos.top;
  2949. relativeX = e.touches[0].pageX - pos.left;
  2950. }
  2951. // Attach data to element
  2952. ripple.setAttribute('data-hold', Date.now());
  2953. ripple.setAttribute('data-scale', scale);
  2954. ripple.setAttribute('data-x', relativeX);
  2955. ripple.setAttribute('data-y', relativeY);
  2956. // Set ripple position
  2957. var rippleStyle = {
  2958. 'top': relativeY + 'px',
  2959. 'left': relativeX + 'px'
  2960. };
  2961. ripple.className = ripple.className + ' waves-notransition';
  2962. ripple.setAttribute('style', convertStyle(rippleStyle));
  2963. ripple.className = ripple.className.replace('waves-notransition', '');
  2964. // Scale the ripple
  2965. rippleStyle['-webkit-transform'] = scale;
  2966. rippleStyle['-moz-transform'] = scale;
  2967. rippleStyle['-ms-transform'] = scale;
  2968. rippleStyle['-o-transform'] = scale;
  2969. rippleStyle.transform = scale;
  2970. rippleStyle.opacity = '1';
  2971. rippleStyle['-webkit-transition-duration'] = Effect.duration + 'ms';
  2972. rippleStyle['-moz-transition-duration'] = Effect.duration + 'ms';
  2973. rippleStyle['-o-transition-duration'] = Effect.duration + 'ms';
  2974. rippleStyle['transition-duration'] = Effect.duration + 'ms';
  2975. rippleStyle['-webkit-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
  2976. rippleStyle['-moz-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
  2977. rippleStyle['-o-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
  2978. rippleStyle['transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)';
  2979. ripple.setAttribute('style', convertStyle(rippleStyle));
  2980. },
  2981. hide: function (e) {
  2982. TouchHandler.touchup(e);
  2983. var el = this;
  2984. var width = el.clientWidth * 1.4;
  2985. // Get first ripple
  2986. var ripple = null;
  2987. var ripples = el.getElementsByClassName('waves-ripple');
  2988. if (ripples.length > 0) {
  2989. ripple = ripples[ripples.length - 1];
  2990. ripples[1] ? ripples[1].remove() : '';
  2991. } else {
  2992. return false;
  2993. }
  2994. var relativeX = ripple.getAttribute('data-x');
  2995. var relativeY = ripple.getAttribute('data-y');
  2996. var scale = ripple.getAttribute('data-scale');
  2997. // Get delay beetween mousedown and mouse leave
  2998. var diff = Date.now() - Number(ripple.getAttribute('data-hold'));
  2999. var delay = 350 - diff;
  3000. if (delay < 0) {
  3001. delay = 0;
  3002. }
  3003. // Fade out ripple after delay
  3004. setTimeout(function () {
  3005. var style = {
  3006. 'top': relativeY + 'px',
  3007. 'left': relativeX + 'px',
  3008. 'opacity': '0',
  3009. // Duration
  3010. '-webkit-transition-duration': Effect.duration + 'ms',
  3011. '-moz-transition-duration': Effect.duration + 'ms',
  3012. '-o-transition-duration': Effect.duration + 'ms',
  3013. 'transition-duration': Effect.duration + 'ms',
  3014. '-webkit-transform': scale,
  3015. '-moz-transform': scale,
  3016. '-ms-transform': scale,
  3017. '-o-transform': scale,
  3018. 'transform': scale
  3019. };
  3020. ripple.setAttribute('style', convertStyle(style));
  3021. setTimeout(function () {
  3022. try {
  3023. el.removeChild(ripple);
  3024. } catch (e) {
  3025. return false;
  3026. }
  3027. }, Effect.duration);
  3028. }, delay);
  3029. },
  3030. // Little hack to make <input> can perform waves effect
  3031. wrapInput: function (elements) {
  3032. for (var a = 0; a < elements.length; a++) {
  3033. var el = elements[a];
  3034. if (el.tagName.toLowerCase() === 'input') {
  3035. var parent = el.parentNode;
  3036. // If input already have parent just pass through
  3037. if (parent.tagName.toLowerCase() === 'i' && parent.className.indexOf('waves-effect') !== -1) {
  3038. continue;
  3039. }
  3040. // Put element class and style to the specified parent
  3041. var wrapper = document.createElement('i');
  3042. wrapper.className = el.className + ' waves-input-wrapper';
  3043. var elementStyle = el.getAttribute('style');
  3044. if (!elementStyle) {
  3045. elementStyle = '';
  3046. }
  3047. wrapper.setAttribute('style', elementStyle);
  3048. el.className = 'waves-button-input';
  3049. el.removeAttribute('style');
  3050. // Put element as child
  3051. parent.replaceChild(wrapper, el);
  3052. wrapper.appendChild(el);
  3053. }
  3054. }
  3055. }
  3056. };
  3057. /**
  3058. * Disable mousedown event for 500ms during and after touch
  3059. */
  3060. var TouchHandler = {
  3061. /* uses an integer rather than bool so there's no issues with
  3062. * needing to clear timeouts if another touch event occurred
  3063. * within the 500ms. Cannot mouseup between touchstart and
  3064. * touchend, nor in the 500ms after touchend. */
  3065. touches: 0,
  3066. allowEvent: function (e) {
  3067. var allow = true;
  3068. if (e.type === 'touchstart') {
  3069. TouchHandler.touches += 1; //push
  3070. } else if (e.type === 'touchend' || e.type === 'touchcancel') {
  3071. setTimeout(function () {
  3072. if (TouchHandler.touches > 0) {
  3073. TouchHandler.touches -= 1; //pop after 500ms
  3074. }
  3075. }, 500);
  3076. } else if (e.type === 'mousedown' && TouchHandler.touches > 0) {
  3077. allow = false;
  3078. }
  3079. return allow;
  3080. },
  3081. touchup: function (e) {
  3082. TouchHandler.allowEvent(e);
  3083. }
  3084. };
  3085. /**
  3086. * Delegated click handler for .waves-effect element.
  3087. * returns null when .waves-effect element not in "click tree"
  3088. */
  3089. function getWavesEffectElement(e) {
  3090. if (TouchHandler.allowEvent(e) === false) {
  3091. return null;
  3092. }
  3093. var element = null;
  3094. var target = e.target || e.srcElement;
  3095. while (target.parentNode !== null) {
  3096. if (!(target instanceof SVGElement) && target.className.indexOf('waves-effect') !== -1) {
  3097. element = target;
  3098. break;
  3099. }
  3100. target = target.parentNode;
  3101. }
  3102. return element;
  3103. }
  3104. /**
  3105. * Bubble the click and show effect if .waves-effect elem was found
  3106. */
  3107. function showEffect(e) {
  3108. var element = getWavesEffectElement(e);
  3109. if (element !== null) {
  3110. Effect.show(e, element);
  3111. if ('ontouchstart' in window) {
  3112. element.addEventListener('touchend', Effect.hide, false);
  3113. element.addEventListener('touchcancel', Effect.hide, false);
  3114. }
  3115. element.addEventListener('mouseup', Effect.hide, false);
  3116. element.addEventListener('mouseleave', Effect.hide, false);
  3117. element.addEventListener('dragend', Effect.hide, false);
  3118. }
  3119. }
  3120. Waves.displayEffect = function (options) {
  3121. options = options || {};
  3122. if ('duration' in options) {
  3123. Effect.duration = options.duration;
  3124. }
  3125. //Wrap input inside <i> tag
  3126. Effect.wrapInput($$('.waves-effect'));
  3127. if ('ontouchstart' in window) {
  3128. document.body.addEventListener('touchstart', showEffect, false);
  3129. }
  3130. document.body.addEventListener('mousedown', showEffect, false);
  3131. };
  3132. /**
  3133. * Attach Waves to an input element (or any element which doesn't
  3134. * bubble mouseup/mousedown events).
  3135. * Intended to be used with dynamically loaded forms/inputs, or
  3136. * where the user doesn't want a delegated click handler.
  3137. */
  3138. Waves.attach = function (element) {
  3139. //FUTURE: automatically add waves classes and allow users
  3140. // to specify them with an options param? Eg. light/classic/button
  3141. if (element.tagName.toLowerCase() === 'input') {
  3142. Effect.wrapInput([element]);
  3143. element = element.parentNode;
  3144. }
  3145. if ('ontouchstart' in window) {
  3146. element.addEventListener('touchstart', showEffect, false);
  3147. }
  3148. element.addEventListener('mousedown', showEffect, false);
  3149. };
  3150. window.Waves = Waves;
  3151. document.addEventListener('DOMContentLoaded', function () {
  3152. Waves.displayEffect();
  3153. }, false);
  3154. })(window);
  3155. ; (function ($, Vel) {
  3156. 'use strict';
  3157. var _defaults = {
  3158. displayLength: Infinity,
  3159. inDuration: 300,
  3160. outDuration: 375,
  3161. className: undefined,
  3162. completeCallback: undefined,
  3163. activationPercent: 0.8
  3164. };
  3165. var Toast = function () {
  3166. function Toast(message, displayLength, className, completeCallback) {
  3167. _classCallCheck(this, Toast);
  3168. if (!message) {
  3169. return;
  3170. }
  3171. /**
  3172. * Options for the toast
  3173. * @member Toast#options
  3174. */
  3175. this.options = {
  3176. displayLength: displayLength,
  3177. className: className,
  3178. completeCallback: completeCallback
  3179. };
  3180. this.options = $.extend({}, Toast.defaults, this.options);
  3181. this.message = message;
  3182. /**
  3183. * Describes current pan state toast
  3184. * @type {Boolean}
  3185. */
  3186. this.panning = false;
  3187. /**
  3188. * Time remaining until toast is removed
  3189. */
  3190. this.timeRemaining = this.options.displayLength;
  3191. if (Toast._toasts.length === 0) {
  3192. Toast._createContainer();
  3193. }
  3194. // Create new toast
  3195. Toast._toasts.push(this);
  3196. var toastElement = this.createToast();
  3197. toastElement.M_Toast = this;
  3198. this.el = toastElement;
  3199. this._animateIn();
  3200. this.setTimer();
  3201. }
  3202. _createClass(Toast, [{
  3203. key: 'createToast',
  3204. /**
  3205. * Create toast and append it to toast container
  3206. */
  3207. value: function createToast() {
  3208. var toast = document.createElement('div');
  3209. toast.classList.add('toast');
  3210. // Add custom classes onto toast
  3211. if (this.options.className) {
  3212. var classes = this.options.className.split(' ');
  3213. var i = void 0,
  3214. count = void 0;
  3215. for (i = 0, count = classes.length; i < count; i++) {
  3216. toast.classList.add(classes[i]);
  3217. }
  3218. }
  3219. // Set content
  3220. 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') {
  3221. toast.appendChild(this.message);
  3222. // Check if it is jQuery object
  3223. } else if (this.message instanceof jQuery) {
  3224. $(toast).append(this.message);
  3225. // Insert as text;
  3226. } else {
  3227. toast.innerHTML = this.message;
  3228. }
  3229. // Append toasft
  3230. Toast._container.appendChild(toast);
  3231. return toast;
  3232. }
  3233. /**
  3234. * Animate in toast
  3235. */
  3236. }, {
  3237. key: '_animateIn',
  3238. value: function _animateIn() {
  3239. // Animate toast in
  3240. Vel(this.el, { top: 0, opacity: 1 }, {
  3241. duration: 300,
  3242. easing: 'easeOutCubic',
  3243. queue: false
  3244. });
  3245. }
  3246. /**
  3247. * Create setInterval which automatically removes toast when timeRemaining >= 0
  3248. * has been reached
  3249. */
  3250. }, {
  3251. key: 'setTimer',
  3252. value: function setTimer() {
  3253. var _this3 = this;
  3254. if (this.timeRemaining !== Infinity) {
  3255. this.counterInterval = setInterval(function () {
  3256. // If toast is not being dragged, decrease its time remaining
  3257. if (!_this3.panning) {
  3258. _this3.timeRemaining -= 20;
  3259. }
  3260. // Animate toast out
  3261. if (_this3.timeRemaining <= 0) {
  3262. _this3.remove();
  3263. }
  3264. }, 20);
  3265. }
  3266. }
  3267. /**
  3268. * Dismiss toast with animation
  3269. */
  3270. }, {
  3271. key: 'remove',
  3272. value: function remove() {
  3273. var _this4 = this;
  3274. window.clearInterval(this.counterInterval);
  3275. var activationDistance = this.el.offsetWidth * this.options.activationPercent;
  3276. if (this.wasSwiped) {
  3277. this.el.style.transition = 'transform .05s, opacity .05s';
  3278. this.el.style.transform = 'translateX(' + activationDistance + 'px)';
  3279. this.el.style.opacity = 0;
  3280. }
  3281. Vel(this.el, { opacity: 0, marginTop: '-40px' }, {
  3282. duration: this.options.outDuration,
  3283. easing: 'easeOutExpo',
  3284. queue: false,
  3285. complete: function () {
  3286. // Call the optional callback
  3287. if (typeof _this4.options.completeCallback === 'function') {
  3288. _this4.options.completeCallback();
  3289. }
  3290. // Remove toast from DOM
  3291. _this4.el.parentNode.removeChild(_this4.el);
  3292. Toast._toasts.splice(Toast._toasts.indexOf(_this4), 1);
  3293. if (Toast._toasts.length === 0) {
  3294. Toast._removeContainer();
  3295. }
  3296. }
  3297. });
  3298. }
  3299. }], [{
  3300. key: '_createContainer',
  3301. /**
  3302. * Append toast container and add event handlers
  3303. */
  3304. value: function _createContainer() {
  3305. var container = document.createElement('div');
  3306. container.setAttribute('id', 'toast-container');
  3307. // Add event handler
  3308. container.addEventListener('touchstart', Toast._onDragStart);
  3309. container.addEventListener('touchmove', Toast._onDragMove);
  3310. container.addEventListener('touchend', Toast._onDragEnd);
  3311. container.addEventListener('mousedown', Toast._onDragStart);
  3312. document.addEventListener('mousemove', Toast._onDragMove);
  3313. document.addEventListener('mouseup', Toast._onDragEnd);
  3314. document.body.appendChild(container);
  3315. Toast._container = container;
  3316. }
  3317. /**
  3318. * Remove toast container and event handlers
  3319. */
  3320. }, {
  3321. key: '_removeContainer',
  3322. value: function _removeContainer() {
  3323. // Add event handler
  3324. document.removeEventListener('mousemove', Toast._onDragMove);
  3325. document.removeEventListener('mouseup', Toast._onDragEnd);
  3326. Toast._container.parentNode.removeChild(Toast._container);
  3327. Toast._container = null;
  3328. }
  3329. /**
  3330. * Begin drag handler
  3331. * @param {Event} e
  3332. */
  3333. }, {
  3334. key: '_onDragStart',
  3335. value: function _onDragStart(e) {
  3336. if (e.target && $(e.target).closest('.toast').length) {
  3337. var $toast = $(e.target).closest('.toast');
  3338. var toast = $toast[0].M_Toast;
  3339. toast.panning = true;
  3340. Toast._draggedToast = toast;
  3341. toast.el.classList.add('panning');
  3342. toast.el.style.transition = '';
  3343. toast.startingXPos = Toast._xPos(e);
  3344. toast.time = Date.now();
  3345. toast.xPos = Toast._xPos(e);
  3346. }
  3347. }
  3348. /**
  3349. * Drag move handler
  3350. * @param {Event} e
  3351. */
  3352. }, {
  3353. key: '_onDragMove',
  3354. value: function _onDragMove(e) {
  3355. if (!!Toast._draggedToast) {
  3356. e.preventDefault();
  3357. var toast = Toast._draggedToast;
  3358. toast.deltaX = Math.abs(toast.xPos - Toast._xPos(e));
  3359. toast.xPos = Toast._xPos(e);
  3360. toast.velocityX = toast.deltaX / (Date.now() - toast.time);
  3361. toast.time = Date.now();
  3362. var totalDeltaX = toast.xPos - toast.startingXPos;
  3363. var activationDistance = toast.el.offsetWidth * toast.options.activationPercent;
  3364. toast.el.style.transform = 'translateX(' + totalDeltaX + 'px)';
  3365. toast.el.style.opacity = 1 - Math.abs(totalDeltaX / activationDistance);
  3366. }
  3367. }
  3368. /**
  3369. * End drag handler
  3370. * @param {Event} e
  3371. */
  3372. }, {
  3373. key: '_onDragEnd',
  3374. value: function _onDragEnd(e) {
  3375. if (!!Toast._draggedToast) {
  3376. var toast = Toast._draggedToast;
  3377. toast.panning = false;
  3378. toast.el.classList.remove('panning');
  3379. var totalDeltaX = toast.xPos - toast.startingXPos;
  3380. var activationDistance = toast.el.offsetWidth * toast.options.activationPercent;
  3381. var shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance || toast.velocityX > 1;
  3382. // Remove toast
  3383. if (shouldBeDismissed) {
  3384. toast.wasSwiped = true;
  3385. toast.remove();
  3386. // Animate toast back to original position
  3387. } else {
  3388. toast.el.style.transition = 'transform .2s, opacity .2s';
  3389. toast.el.style.transform = '';
  3390. toast.el.style.opacity = '';
  3391. }
  3392. Toast._draggedToast = null;
  3393. }
  3394. }
  3395. /**
  3396. * Get x position of mouse or touch event
  3397. * @param {Event} e
  3398. */
  3399. }, {
  3400. key: '_xPos',
  3401. value: function _xPos(e) {
  3402. if (e.targetTouches && e.targetTouches.length >= 1) {
  3403. return e.targetTouches[0].clientX;
  3404. }
  3405. // mouse event
  3406. return e.clientX;
  3407. }
  3408. /**
  3409. * Remove all toasts
  3410. */
  3411. }, {
  3412. key: 'removeAll',
  3413. value: function removeAll() {
  3414. for (var toastIndex in Toast._toasts) {
  3415. Toast._toasts[toastIndex].remove();
  3416. }
  3417. }
  3418. }, {
  3419. key: 'defaults',
  3420. get: function () {
  3421. return _defaults;
  3422. }
  3423. }]);
  3424. return Toast;
  3425. }();
  3426. /**
  3427. * @static
  3428. * @memberof Toast
  3429. * @type {Array.<Toast>}
  3430. */
  3431. Toast._toasts = [];
  3432. /**
  3433. * @static
  3434. * @memberof Toast
  3435. */
  3436. Toast._container = null;
  3437. /**
  3438. * @static
  3439. * @memberof Toast
  3440. * @type {Toast}
  3441. */
  3442. Toast._draggedToast = null;
  3443. Materialize.Toast = Toast;
  3444. Materialize.toast = function (message, displayLength, className, completeCallback) {
  3445. return new Toast(message, displayLength, className, completeCallback);
  3446. };
  3447. })(jQuery, Materialize.Vel);
  3448. ; (function ($) {
  3449. var methods = {
  3450. init: function (options) {
  3451. var defaults = {
  3452. menuWidth: 300,
  3453. edge: 'left',
  3454. closeOnClick: false,
  3455. draggable: true,
  3456. onOpen: null,
  3457. onClose: null
  3458. };
  3459. options = $.extend(defaults, options);
  3460. $(this).each(function () {
  3461. var $this = $(this);
  3462. var menuId = $this.attr('data-activates');
  3463. var menu = $("#" + menuId);
  3464. // Set to width
  3465. if (options.menuWidth != 300) {
  3466. menu.css('width', options.menuWidth);
  3467. }
  3468. // Add Touch Area
  3469. var $dragTarget = $('.drag-target[data-sidenav="' + menuId + '"]');
  3470. if (options.draggable) {
  3471. // Regenerate dragTarget
  3472. if ($dragTarget.length) {
  3473. $dragTarget.remove();
  3474. }
  3475. $dragTarget = $('<div class="drag-target"></div>').attr('data-sidenav', menuId);
  3476. $('body').append($dragTarget);
  3477. } else {
  3478. $dragTarget = $();
  3479. }
  3480. if (options.edge == 'left') {
  3481. menu.css('transform', 'translateX(-100%)');
  3482. $dragTarget.css({ 'left': 0 }); // Add Touch Area
  3483. } else {
  3484. menu.addClass('right-aligned') // Change text-alignment to right
  3485. .css('transform', 'translateX(100%)');
  3486. $dragTarget.css({ 'right': 0 }); // Add Touch Area
  3487. }
  3488. // If fixed sidenav, bring menu out
  3489. if (menu.hasClass('fixed')) {
  3490. if (window.innerWidth > 992) {
  3491. menu.css('transform', 'translateX(0)');
  3492. }
  3493. }
  3494. // Window resize to reset on large screens fixed
  3495. if (menu.hasClass('fixed')) {
  3496. $(window).resize(function () {
  3497. if (window.innerWidth > 992) {
  3498. // Close menu if window is resized bigger than 992 and user has fixed sidenav
  3499. if ($('#sidenav-overlay').length !== 0 && menuOut) {
  3500. removeMenu(true);
  3501. } else {
  3502. // menu.removeAttr('style');
  3503. menu.css('transform', 'translateX(0%)');
  3504. // menu.css('width', options.menuWidth);
  3505. }
  3506. } else if (menuOut === false) {
  3507. if (options.edge === 'left') {
  3508. menu.css('transform', 'translateX(-100%)');
  3509. } else {
  3510. menu.css('transform', 'translateX(100%)');
  3511. }
  3512. }
  3513. });
  3514. }
  3515. // if closeOnClick, then add close event for all a tags in side sideNav
  3516. if (options.closeOnClick === true) {
  3517. menu.on("click.itemclick", "a:not(.collapsible-header)", function () {
  3518. if (!(window.innerWidth > 992 && menu.hasClass('fixed'))) {
  3519. removeMenu();
  3520. }
  3521. });
  3522. }
  3523. var removeMenu = function (restoreNav) {
  3524. panning = false;
  3525. menuOut = false;
  3526. // Reenable scrolling
  3527. $('body').css({
  3528. overflow: '',
  3529. width: ''
  3530. });
  3531. $('#sidenav-overlay').velocity({ opacity: 0 }, {
  3532. duration: 200,
  3533. queue: false, easing: 'easeOutQuad',
  3534. complete: function () {
  3535. $(this).remove();
  3536. }
  3537. });
  3538. if (options.edge === 'left') {
  3539. // Reset phantom div
  3540. $dragTarget.css({ width: '', right: '', left: '0' });
  3541. menu.velocity({ 'translateX': '-100%' }, {
  3542. duration: 200,
  3543. queue: false,
  3544. easing: 'easeOutCubic',
  3545. complete: function () {
  3546. if (restoreNav === true) {
  3547. // Restore Fixed sidenav
  3548. menu.removeAttr('style');
  3549. menu.css('width', options.menuWidth);
  3550. }
  3551. }
  3552. });
  3553. } else {
  3554. // Reset phantom div
  3555. $dragTarget.css({ width: '', right: '0', left: '' });
  3556. menu.velocity({ 'translateX': '100%' }, {
  3557. duration: 200,
  3558. queue: false,
  3559. easing: 'easeOutCubic',
  3560. complete: function () {
  3561. if (restoreNav === true) {
  3562. // Restore Fixed sidenav
  3563. menu.removeAttr('style');
  3564. menu.css('width', options.menuWidth);
  3565. }
  3566. }
  3567. });
  3568. }
  3569. // Callback
  3570. if (typeof options.onClose === 'function') {
  3571. options.onClose.call(this, menu);
  3572. }
  3573. };
  3574. // Touch Event
  3575. var panning = false;
  3576. var menuOut = false;
  3577. if (options.draggable) {
  3578. $dragTarget.on('click', function () {
  3579. if (menuOut) {
  3580. removeMenu();
  3581. }
  3582. });
  3583. $dragTarget.hammer({
  3584. prevent_default: false
  3585. }).on('pan', function (e) {
  3586. if (e.gesture.pointerType == "touch") {
  3587. var direction = e.gesture.direction;
  3588. var x = e.gesture.center.x;
  3589. var y = e.gesture.center.y;
  3590. var velocityX = e.gesture.velocityX;
  3591. // Vertical scroll bugfix
  3592. if (x === 0 && y === 0) {
  3593. return;
  3594. }
  3595. // Disable Scrolling
  3596. var $body = $('body');
  3597. var $overlay = $('#sidenav-overlay');
  3598. var oldWidth = $body.innerWidth();
  3599. $body.css('overflow', 'hidden');
  3600. $body.width(oldWidth);
  3601. // If overlay does not exist, create one and if it is clicked, close menu
  3602. if ($overlay.length === 0) {
  3603. $overlay = $('<div id="sidenav-overlay"></div>');
  3604. $overlay.css('opacity', 0).click(function () {
  3605. removeMenu();
  3606. });
  3607. // Run 'onOpen' when sidenav is opened via touch/swipe if applicable
  3608. if (typeof options.onOpen === 'function') {
  3609. options.onOpen.call(this, menu);
  3610. }
  3611. $('body').append($overlay);
  3612. }
  3613. // Keep within boundaries
  3614. if (options.edge === 'left') {
  3615. if (x > options.menuWidth) {
  3616. x = options.menuWidth;
  3617. } else if (x < 0) {
  3618. x = 0;
  3619. }
  3620. }
  3621. if (options.edge === 'left') {
  3622. // Left Direction
  3623. if (x < options.menuWidth / 2) {
  3624. menuOut = false;
  3625. }
  3626. // Right Direction
  3627. else if (x >= options.menuWidth / 2) {
  3628. menuOut = true;
  3629. }
  3630. menu.css('transform', 'translateX(' + (x - options.menuWidth) + 'px)');
  3631. } else {
  3632. // Left Direction
  3633. if (x < window.innerWidth - options.menuWidth / 2) {
  3634. menuOut = true;
  3635. }
  3636. // Right Direction
  3637. else if (x >= window.innerWidth - options.menuWidth / 2) {
  3638. menuOut = false;
  3639. }
  3640. var rightPos = x - options.menuWidth / 2;
  3641. if (rightPos < 0) {
  3642. rightPos = 0;
  3643. }
  3644. menu.css('transform', 'translateX(' + rightPos + 'px)');
  3645. }
  3646. // Percentage overlay
  3647. var overlayPerc;
  3648. if (options.edge === 'left') {
  3649. overlayPerc = x / options.menuWidth;
  3650. $overlay.velocity({ opacity: overlayPerc }, { duration: 10, queue: false, easing: 'easeOutQuad' });
  3651. } else {
  3652. overlayPerc = Math.abs((x - window.innerWidth) / options.menuWidth);
  3653. $overlay.velocity({ opacity: overlayPerc }, { duration: 10, queue: false, easing: 'easeOutQuad' });
  3654. }
  3655. }
  3656. }).on('panend', function (e) {
  3657. if (e.gesture.pointerType == "touch") {
  3658. var $overlay = $('#sidenav-overlay');
  3659. var velocityX = e.gesture.velocityX;
  3660. var x = e.gesture.center.x;
  3661. var leftPos = x - options.menuWidth;
  3662. var rightPos = x - options.menuWidth / 2;
  3663. if (leftPos > 0) {
  3664. leftPos = 0;
  3665. }
  3666. if (rightPos < 0) {
  3667. rightPos = 0;
  3668. }
  3669. panning = false;
  3670. if (options.edge === 'left') {
  3671. // If velocityX <= 0.3 then the user is flinging the menu closed so ignore menuOut
  3672. if (menuOut && velocityX <= 0.3 || velocityX < -0.5) {
  3673. // Return menu to open
  3674. if (leftPos !== 0) {
  3675. menu.velocity({ 'translateX': [0, leftPos] }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  3676. }
  3677. $overlay.velocity({ opacity: 1 }, { duration: 50, queue: false, easing: 'easeOutQuad' });
  3678. $dragTarget.css({ width: '50%', right: 0, left: '' });
  3679. menuOut = true;
  3680. } else if (!menuOut || velocityX > 0.3) {
  3681. // Enable Scrolling
  3682. $('body').css({
  3683. overflow: '',
  3684. width: ''
  3685. });
  3686. // Slide menu closed
  3687. menu.velocity({ 'translateX': [-1 * options.menuWidth - 10, leftPos] }, { duration: 200, queue: false, easing: 'easeOutQuad' });
  3688. $overlay.velocity({ opacity: 0 }, {
  3689. duration: 200, queue: false, easing: 'easeOutQuad',
  3690. complete: function () {
  3691. // Run 'onClose' when sidenav is closed via touch/swipe if applicable
  3692. if (typeof options.onClose === 'function') {
  3693. options.onClose.call(this, menu);
  3694. }
  3695. $(this).remove();
  3696. }
  3697. });
  3698. $dragTarget.css({ width: '10px', right: '', left: 0 });
  3699. }
  3700. } else {
  3701. if (menuOut && velocityX >= -0.3 || velocityX > 0.5) {
  3702. // Return menu to open
  3703. if (rightPos !== 0) {
  3704. menu.velocity({ 'translateX': [0, rightPos] }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  3705. }
  3706. $overlay.velocity({ opacity: 1 }, { duration: 50, queue: false, easing: 'easeOutQuad' });
  3707. $dragTarget.css({ width: '50%', right: '', left: 0 });
  3708. menuOut = true;
  3709. } else if (!menuOut || velocityX < -0.3) {
  3710. // Enable Scrolling
  3711. $('body').css({
  3712. overflow: '',
  3713. width: ''
  3714. });
  3715. // Slide menu closed
  3716. menu.velocity({ 'translateX': [options.menuWidth + 10, rightPos] }, { duration: 200, queue: false, easing: 'easeOutQuad' });
  3717. $overlay.velocity({ opacity: 0 }, {
  3718. duration: 200, queue: false, easing: 'easeOutQuad',
  3719. complete: function () {
  3720. // Run 'onClose' when sidenav is closed via touch/swipe if applicable
  3721. if (typeof options.onClose === 'function') {
  3722. options.onClose.call(this, menu);
  3723. }
  3724. $(this).remove();
  3725. }
  3726. });
  3727. $dragTarget.css({ width: '10px', right: 0, left: '' });
  3728. }
  3729. }
  3730. }
  3731. });
  3732. }
  3733. $this.off('click.sidenav').on('click.sidenav', function () {
  3734. if (menuOut === true) {
  3735. menuOut = false;
  3736. panning = false;
  3737. removeMenu();
  3738. } else {
  3739. // Disable Scrolling
  3740. var $body = $('body');
  3741. var $overlay = $('<div id="sidenav-overlay"></div>');
  3742. var oldWidth = $body.innerWidth();
  3743. $body.css('overflow', 'hidden');
  3744. $body.width(oldWidth);
  3745. // Push current drag target on top of DOM tree
  3746. $('body').append($dragTarget);
  3747. if (options.edge === 'left') {
  3748. $dragTarget.css({ width: '50%', right: 0, left: '' });
  3749. menu.velocity({ 'translateX': [0, -1 * options.menuWidth] }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  3750. } else {
  3751. $dragTarget.css({ width: '50%', right: '', left: 0 });
  3752. menu.velocity({ 'translateX': [0, options.menuWidth] }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  3753. }
  3754. // Overlay close on click
  3755. $overlay.css('opacity', 0).click(function () {
  3756. menuOut = false;
  3757. panning = false;
  3758. removeMenu();
  3759. $overlay.velocity({ opacity: 0 }, {
  3760. duration: 300, queue: false, easing: 'easeOutQuad',
  3761. complete: function () {
  3762. $(this).remove();
  3763. }
  3764. });
  3765. });
  3766. // Append body
  3767. $('body').append($overlay);
  3768. $overlay.velocity({ opacity: 1 }, {
  3769. duration: 300, queue: false, easing: 'easeOutQuad',
  3770. complete: function () {
  3771. menuOut = true;
  3772. panning = false;
  3773. }
  3774. });
  3775. // Callback
  3776. if (typeof options.onOpen === 'function') {
  3777. options.onOpen.call(this, menu);
  3778. }
  3779. }
  3780. return false;
  3781. });
  3782. });
  3783. },
  3784. destroy: function () {
  3785. var $overlay = $('#sidenav-overlay');
  3786. var $dragTarget = $('.drag-target[data-sidenav="' + $(this).attr('data-activates') + '"]');
  3787. $overlay.trigger('click');
  3788. $dragTarget.remove();
  3789. $(this).off('click');
  3790. $overlay.remove();
  3791. },
  3792. show: function () {
  3793. this.trigger('click');
  3794. },
  3795. hide: function () {
  3796. $('#sidenav-overlay').trigger('click');
  3797. }
  3798. };
  3799. $.fn.sideNav = function (methodOrOptions) {
  3800. if (methods[methodOrOptions]) {
  3801. return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
  3802. } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
  3803. // Default to "init"
  3804. return methods.init.apply(this, arguments);
  3805. } else {
  3806. $.error('Method ' + methodOrOptions + ' does not exist on jQuery.sideNav');
  3807. }
  3808. }; // Plugin end
  3809. })(jQuery);
  3810. ; /**
  3811. * Extend jquery with a scrollspy plugin.
  3812. * This watches the window scroll and fires events when elements are scrolled into viewport.
  3813. *
  3814. * throttle() and getTime() taken from Underscore.js
  3815. * https://github.com/jashkenas/underscore
  3816. *
  3817. * @author Copyright 2013 John Smart
  3818. * @license https://raw.github.com/thesmart/jquery-scrollspy/master/LICENSE
  3819. * @see https://github.com/thesmart
  3820. * @version 0.1.2
  3821. */
  3822. (function ($) {
  3823. var jWindow = $(window);
  3824. var elements = [];
  3825. var elementsInView = [];
  3826. var isSpying = false;
  3827. var ticks = 0;
  3828. var unique_id = 1;
  3829. var offset = {
  3830. top: 0,
  3831. right: 0,
  3832. bottom: 0,
  3833. left: 0
  3834. /**
  3835. * Find elements that are within the boundary
  3836. * @param {number} top
  3837. * @param {number} right
  3838. * @param {number} bottom
  3839. * @param {number} left
  3840. * @return {jQuery} A collection of elements
  3841. */
  3842. }; function findElements(top, right, bottom, left) {
  3843. var hits = $();
  3844. $.each(elements, function (i, element) {
  3845. if (element.height() > 0) {
  3846. var elTop = element.offset().top,
  3847. elLeft = element.offset().left,
  3848. elRight = elLeft + element.width(),
  3849. elBottom = elTop + element.height();
  3850. var isIntersect = !(elLeft > right || elRight < left || elTop > bottom || elBottom < top);
  3851. if (isIntersect) {
  3852. hits.push(element);
  3853. }
  3854. }
  3855. });
  3856. return hits;
  3857. }
  3858. /**
  3859. * Called when the user scrolls the window
  3860. */
  3861. function onScroll(scrollOffset) {
  3862. // unique tick id
  3863. ++ticks;
  3864. // viewport rectangle
  3865. var top = jWindow.scrollTop(),
  3866. left = jWindow.scrollLeft(),
  3867. right = left + jWindow.width(),
  3868. bottom = top + jWindow.height();
  3869. // determine which elements are in view
  3870. var intersections = findElements(top + offset.top + scrollOffset || 200, right + offset.right, bottom + offset.bottom, left + offset.left);
  3871. $.each(intersections, function (i, element) {
  3872. var lastTick = element.data('scrollSpy:ticks');
  3873. if (typeof lastTick != 'number') {
  3874. // entered into view
  3875. element.triggerHandler('scrollSpy:enter');
  3876. }
  3877. // update tick id
  3878. element.data('scrollSpy:ticks', ticks);
  3879. });
  3880. // determine which elements are no longer in view
  3881. $.each(elementsInView, function (i, element) {
  3882. var lastTick = element.data('scrollSpy:ticks');
  3883. if (typeof lastTick == 'number' && lastTick !== ticks) {
  3884. // exited from view
  3885. element.triggerHandler('scrollSpy:exit');
  3886. element.data('scrollSpy:ticks', null);
  3887. }
  3888. });
  3889. // remember elements in view for next tick
  3890. elementsInView = intersections;
  3891. }
  3892. /**
  3893. * Called when window is resized
  3894. */
  3895. function onWinSize() {
  3896. jWindow.trigger('scrollSpy:winSize');
  3897. }
  3898. /**
  3899. * Enables ScrollSpy using a selector
  3900. * @param {jQuery|string} selector The elements collection, or a selector
  3901. * @param {Object=} options Optional.
  3902. throttle : number -> scrollspy throttling. Default: 100 ms
  3903. offsetTop : number -> offset from top. Default: 0
  3904. offsetRight : number -> offset from right. Default: 0
  3905. offsetBottom : number -> offset from bottom. Default: 0
  3906. offsetLeft : number -> offset from left. Default: 0
  3907. activeClass : string -> Class name to be added to the active link. Default: active
  3908. * @returns {jQuery}
  3909. */
  3910. $.scrollSpy = function (selector, options) {
  3911. var defaults = {
  3912. throttle: 100,
  3913. scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll
  3914. activeClass: 'active',
  3915. getActiveElement: function (id) {
  3916. return 'a[href="#' + id + '"]';
  3917. }
  3918. };
  3919. options = $.extend(defaults, options);
  3920. var visible = [];
  3921. selector = $(selector);
  3922. selector.each(function (i, element) {
  3923. elements.push($(element));
  3924. $(element).data("scrollSpy:id", i);
  3925. // Smooth scroll to section
  3926. $('a[href="#' + $(element).attr('id') + '"]').click(function (e) {
  3927. e.preventDefault();
  3928. var offset = $(Materialize.escapeHash(this.hash)).offset().top + 1;
  3929. $('html, body').animate({ scrollTop: offset - options.scrollOffset }, { duration: 400, queue: false, easing: 'easeOutCubic' });
  3930. });
  3931. });
  3932. offset.top = options.offsetTop || 0;
  3933. offset.right = options.offsetRight || 0;
  3934. offset.bottom = options.offsetBottom || 0;
  3935. offset.left = options.offsetLeft || 0;
  3936. var throttledScroll = Materialize.throttle(function () {
  3937. onScroll(options.scrollOffset);
  3938. }, options.throttle || 100);
  3939. var readyScroll = function () {
  3940. $(document).ready(throttledScroll);
  3941. };
  3942. if (!isSpying) {
  3943. jWindow.on('scroll', readyScroll);
  3944. jWindow.on('resize', readyScroll);
  3945. isSpying = true;
  3946. }
  3947. // perform a scan once, after current execution context, and after dom is ready
  3948. setTimeout(readyScroll, 0);
  3949. selector.on('scrollSpy:enter', function () {
  3950. visible = $.grep(visible, function (value) {
  3951. return value.height() != 0;
  3952. });
  3953. var $this = $(this);
  3954. if (visible[0]) {
  3955. $(options.getActiveElement(visible[0].attr('id'))).removeClass(options.activeClass);
  3956. if ($this.data('scrollSpy:id') < visible[0].data('scrollSpy:id')) {
  3957. visible.unshift($(this));
  3958. } else {
  3959. visible.push($(this));
  3960. }
  3961. } else {
  3962. visible.push($(this));
  3963. }
  3964. $(options.getActiveElement(visible[0].attr('id'))).addClass(options.activeClass);
  3965. });
  3966. selector.on('scrollSpy:exit', function () {
  3967. visible = $.grep(visible, function (value) {
  3968. return value.height() != 0;
  3969. });
  3970. if (visible[0]) {
  3971. $(options.getActiveElement(visible[0].attr('id'))).removeClass(options.activeClass);
  3972. var $this = $(this);
  3973. visible = $.grep(visible, function (value) {
  3974. return value.attr('id') != $this.attr('id');
  3975. });
  3976. if (visible[0]) {
  3977. // Check if empty
  3978. $(options.getActiveElement(visible[0].attr('id'))).addClass(options.activeClass);
  3979. }
  3980. }
  3981. });
  3982. return selector;
  3983. };
  3984. /**
  3985. * Listen for window resize events
  3986. * @param {Object=} options Optional. Set { throttle: number } to change throttling. Default: 100 ms
  3987. * @returns {jQuery} $(window)
  3988. */
  3989. $.winSizeSpy = function (options) {
  3990. $.winSizeSpy = function () {
  3991. return jWindow;
  3992. }; // lock from multiple calls
  3993. options = options || {
  3994. throttle: 100
  3995. };
  3996. return jWindow.on('resize', Materialize.throttle(onWinSize, options.throttle || 100));
  3997. };
  3998. /**
  3999. * Enables ScrollSpy on a collection of elements
  4000. * e.g. $('.scrollSpy').scrollSpy()
  4001. * @param {Object=} options Optional.
  4002. throttle : number -> scrollspy throttling. Default: 100 ms
  4003. offsetTop : number -> offset from top. Default: 0
  4004. offsetRight : number -> offset from right. Default: 0
  4005. offsetBottom : number -> offset from bottom. Default: 0
  4006. offsetLeft : number -> offset from left. Default: 0
  4007. * @returns {jQuery}
  4008. */
  4009. $.fn.scrollSpy = function (options) {
  4010. return $.scrollSpy($(this), options);
  4011. };
  4012. })(jQuery);
  4013. ; (function ($) {
  4014. $(document).ready(function () {
  4015. // Function to update labels of text fields
  4016. Materialize.updateTextFields = function () {
  4017. var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea';
  4018. $(input_selector).each(function (index, element) {
  4019. var $this = $(this);
  4020. if ($(element).val().length > 0 || $(element).is(':focus') || element.autofocus || $this.attr('placeholder') !== undefined) {
  4021. $this.siblings('label').addClass('active');
  4022. } else if ($(element)[0].validity) {
  4023. $this.siblings('label').toggleClass('active', $(element)[0].validity.badInput === true);
  4024. } else {
  4025. $this.siblings('label').removeClass('active');
  4026. }
  4027. });
  4028. };
  4029. // Text based inputs
  4030. var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea';
  4031. // Add active if form auto complete
  4032. $(document).on('change', input_selector, function () {
  4033. if ($(this).val().length !== 0 || $(this).attr('placeholder') !== undefined) {
  4034. $(this).siblings('label').addClass('active');
  4035. }
  4036. validate_field($(this));
  4037. });
  4038. // Add active if input element has been pre-populated on document ready
  4039. $(document).ready(function () {
  4040. Materialize.updateTextFields();
  4041. });
  4042. // HTML DOM FORM RESET handling
  4043. $(document).on('reset', function (e) {
  4044. var formReset = $(e.target);
  4045. if (formReset.is('form')) {
  4046. formReset.find(input_selector).removeClass('valid').removeClass('invalid');
  4047. formReset.find(input_selector).each(function () {
  4048. if ($(this).attr('value') === '') {
  4049. $(this).siblings('label').removeClass('active');
  4050. }
  4051. });
  4052. // Reset select
  4053. formReset.find('select.initialized').each(function () {
  4054. var reset_text = formReset.find('option[selected]').text();
  4055. formReset.siblings('input.select-dropdown').val(reset_text);
  4056. });
  4057. }
  4058. });
  4059. // Add active when element has focus
  4060. $(document).on('focus', input_selector, function () {
  4061. $(this).siblings('label, .prefix').addClass('active');
  4062. });
  4063. $(document).on('blur', input_selector, function () {
  4064. var $inputElement = $(this);
  4065. var selector = ".prefix";
  4066. if ($inputElement.val().length === 0 && $inputElement[0].validity.badInput !== true && $inputElement.attr('placeholder') === undefined) {
  4067. selector += ", label";
  4068. }
  4069. $inputElement.siblings(selector).removeClass('active');
  4070. validate_field($inputElement);
  4071. });
  4072. window.validate_field = function (object) {
  4073. var hasLength = object.attr('data-length') !== undefined;
  4074. var lenAttr = parseInt(object.attr('data-length'));
  4075. var len = object.val().length;
  4076. if (object.val().length === 0 && object[0].validity.badInput === false && !object.is(':required')) {
  4077. if (object.hasClass('validate')) {
  4078. object.removeClass('valid');
  4079. object.removeClass('invalid');
  4080. }
  4081. } else {
  4082. if (object.hasClass('validate')) {
  4083. // Check for character counter attributes
  4084. if (object.is(':valid') && hasLength && len <= lenAttr || object.is(':valid') && !hasLength) {
  4085. object.removeClass('invalid');
  4086. object.addClass('valid');
  4087. } else {
  4088. object.removeClass('valid');
  4089. object.addClass('invalid');
  4090. }
  4091. }
  4092. }
  4093. };
  4094. // Radio and Checkbox focus class
  4095. var radio_checkbox = 'input[type=radio], input[type=checkbox]';
  4096. $(document).on('keyup.radio', radio_checkbox, function (e) {
  4097. // TAB, check if tabbing to radio or checkbox.
  4098. if (e.which === 9) {
  4099. $(this).addClass('tabbed');
  4100. var $this = $(this);
  4101. $this.one('blur', function (e) {
  4102. $(this).removeClass('tabbed');
  4103. });
  4104. return;
  4105. }
  4106. });
  4107. // Textarea Auto Resize
  4108. var hiddenDiv = $('.hiddendiv').first();
  4109. if (!hiddenDiv.length) {
  4110. hiddenDiv = $('<div class="hiddendiv common"></div>');
  4111. $('body').append(hiddenDiv);
  4112. }
  4113. var text_area_selector = '.materialize-textarea';
  4114. function textareaAutoResize($textarea) {
  4115. // Set font properties of hiddenDiv
  4116. var fontFamily = $textarea.css('font-family');
  4117. var fontSize = $textarea.css('font-size');
  4118. var lineHeight = $textarea.css('line-height');
  4119. var padding = $textarea.css('padding');
  4120. if (fontSize) {
  4121. hiddenDiv.css('font-size', fontSize);
  4122. }
  4123. if (fontFamily) {
  4124. hiddenDiv.css('font-family', fontFamily);
  4125. }
  4126. if (lineHeight) {
  4127. hiddenDiv.css('line-height', lineHeight);
  4128. }
  4129. if (padding) {
  4130. hiddenDiv.css('padding', padding);
  4131. }
  4132. // Set original-height, if none
  4133. if (!$textarea.data('original-height')) {
  4134. $textarea.data('original-height', $textarea.height());
  4135. }
  4136. if ($textarea.attr('wrap') === 'off') {
  4137. hiddenDiv.css('overflow-wrap', 'normal').css('white-space', 'pre');
  4138. }
  4139. hiddenDiv.text($textarea.val() + '\n');
  4140. var content = hiddenDiv.html().replace(/\n/g, '<br>');
  4141. hiddenDiv.html(content);
  4142. // When textarea is hidden, width goes crazy.
  4143. // Approximate with half of window size
  4144. if ($textarea.is(':visible')) {
  4145. hiddenDiv.css('width', $textarea.width());
  4146. } else {
  4147. hiddenDiv.css('width', $(window).width() / 2);
  4148. }
  4149. /**
  4150. * Resize if the new height is greater than the
  4151. * original height of the textarea
  4152. */
  4153. if ($textarea.data('original-height') <= hiddenDiv.height()) {
  4154. $textarea.css('height', hiddenDiv.height());
  4155. } else if ($textarea.val().length < $textarea.data('previous-length')) {
  4156. /**
  4157. * In case the new height is less than original height, it
  4158. * means the textarea has less text than before
  4159. * So we set the height to the original one
  4160. */
  4161. $textarea.css('height', $textarea.data('original-height'));
  4162. }
  4163. $textarea.data('previous-length', $textarea.val().length);
  4164. }
  4165. $(text_area_selector).each(function () {
  4166. var $textarea = $(this);
  4167. /**
  4168. * Instead of resizing textarea on document load,
  4169. * store the original height and the original length
  4170. */
  4171. $textarea.data('original-height', $textarea.height());
  4172. $textarea.data('previous-length', $textarea.val().length);
  4173. });
  4174. $('body').on('keyup keydown autoresize', text_area_selector, function () {
  4175. textareaAutoResize($(this));
  4176. });
  4177. // File Input Path
  4178. $(document).on('change', '.file-field input[type="file"]', function () {
  4179. var file_field = $(this).closest('.file-field');
  4180. var path_input = file_field.find('input.file-path');
  4181. var files = $(this)[0].files;
  4182. var file_names = [];
  4183. for (var i = 0; i < files.length; i++) {
  4184. file_names.push(files[i].name);
  4185. }
  4186. path_input.val(file_names.join(", "));
  4187. path_input.trigger('change');
  4188. });
  4189. /****************
  4190. * Range Input *
  4191. ****************/
  4192. var range_type = 'input[type=range]';
  4193. var range_mousedown = false;
  4194. var left;
  4195. $(range_type).each(function () {
  4196. var thumb = $('<span class="thumb"><span class="value"></span></span>');
  4197. $(this).after(thumb);
  4198. });
  4199. var showRangeBubble = function (thumb) {
  4200. var paddingLeft = parseInt(thumb.parent().css('padding-left'));
  4201. var marginLeft = -7 + paddingLeft + 'px';
  4202. thumb.velocity({ height: "30px", width: "30px", top: "-30px", marginLeft: marginLeft }, { duration: 300, easing: 'easeOutExpo' });
  4203. };
  4204. var calcRangeOffset = function (range) {
  4205. var width = range.width() - 15;
  4206. var max = parseFloat(range.attr('max'));
  4207. var min = parseFloat(range.attr('min'));
  4208. var percent = (parseFloat(range.val()) - min) / (max - min);
  4209. return percent * width;
  4210. };
  4211. var range_wrapper = '.range-field';
  4212. $(document).on('change', range_type, function (e) {
  4213. var thumb = $(this).siblings('.thumb');
  4214. thumb.find('.value').html($(this).val());
  4215. if (!thumb.hasClass('active')) {
  4216. showRangeBubble(thumb);
  4217. }
  4218. var offsetLeft = calcRangeOffset($(this));
  4219. thumb.addClass('active').css('left', offsetLeft);
  4220. });
  4221. $(document).on('mousedown touchstart', range_type, function (e) {
  4222. var thumb = $(this).siblings('.thumb');
  4223. // If thumb indicator does not exist yet, create it
  4224. if (thumb.length <= 0) {
  4225. thumb = $('<span class="thumb"><span class="value"></span></span>');
  4226. $(this).after(thumb);
  4227. }
  4228. // Set indicator value
  4229. thumb.find('.value').html($(this).val());
  4230. range_mousedown = true;
  4231. $(this).addClass('active');
  4232. if (!thumb.hasClass('active')) {
  4233. showRangeBubble(thumb);
  4234. }
  4235. if (e.type !== 'input') {
  4236. var offsetLeft = calcRangeOffset($(this));
  4237. thumb.addClass('active').css('left', offsetLeft);
  4238. }
  4239. });
  4240. $(document).on('mouseup touchend', range_wrapper, function () {
  4241. range_mousedown = false;
  4242. $(this).removeClass('active');
  4243. });
  4244. $(document).on('input mousemove touchmove', range_wrapper, function (e) {
  4245. var thumb = $(this).children('.thumb');
  4246. var left;
  4247. var input = $(this).find(range_type);
  4248. if (range_mousedown) {
  4249. if (!thumb.hasClass('active')) {
  4250. showRangeBubble(thumb);
  4251. }
  4252. var offsetLeft = calcRangeOffset(input);
  4253. thumb.addClass('active').css('left', offsetLeft);
  4254. thumb.find('.value').html(thumb.siblings(range_type).val());
  4255. }
  4256. });
  4257. $(document).on('mouseout touchleave', range_wrapper, function () {
  4258. if (!range_mousedown) {
  4259. var thumb = $(this).children('.thumb');
  4260. var paddingLeft = parseInt($(this).css('padding-left'));
  4261. var marginLeft = 7 + paddingLeft + 'px';
  4262. if (thumb.hasClass('active')) {
  4263. thumb.velocity({ height: '0', width: '0', top: '10px', marginLeft: marginLeft }, { duration: 100 });
  4264. }
  4265. thumb.removeClass('active');
  4266. }
  4267. });
  4268. /**************************
  4269. * Auto complete plugin *
  4270. *************************/
  4271. $.fn.autocomplete = function (options) {
  4272. // Defaults
  4273. var defaults = {
  4274. data: {},
  4275. limit: Infinity,
  4276. onAutocomplete: null,
  4277. minLength: 1
  4278. };
  4279. options = $.extend(defaults, options);
  4280. return this.each(function () {
  4281. var $input = $(this);
  4282. var data = options.data,
  4283. count = 0,
  4284. activeIndex = -1,
  4285. oldVal,
  4286. $inputDiv = $input.closest('.input-field'); // Div to append on
  4287. // Check if data isn't empty
  4288. if (!$.isEmptyObject(data)) {
  4289. var $autocomplete = $('<ul class="autocomplete-content dropdown-content"></ul>');
  4290. var $oldAutocomplete;
  4291. // Append autocomplete element.
  4292. // Prevent double structure init.
  4293. if ($inputDiv.length) {
  4294. $oldAutocomplete = $inputDiv.children('.autocomplete-content.dropdown-content').first();
  4295. if (!$oldAutocomplete.length) {
  4296. $inputDiv.append($autocomplete); // Set ul in body
  4297. }
  4298. } else {
  4299. $oldAutocomplete = $input.next('.autocomplete-content.dropdown-content');
  4300. if (!$oldAutocomplete.length) {
  4301. $input.after($autocomplete);
  4302. }
  4303. }
  4304. if ($oldAutocomplete.length) {
  4305. $autocomplete = $oldAutocomplete;
  4306. }
  4307. // Highlight partial match.
  4308. var highlight = function (string, $el) {
  4309. var img = $el.find('img');
  4310. var matchStart = $el.text().toLowerCase().indexOf("" + string.toLowerCase() + ""),
  4311. matchEnd = matchStart + string.length - 1,
  4312. beforeMatch = $el.text().slice(0, matchStart),
  4313. matchText = $el.text().slice(matchStart, matchEnd + 1),
  4314. afterMatch = $el.text().slice(matchEnd + 1);
  4315. $el.html("<span>" + beforeMatch + "<span class='highlight'>" + matchText + "</span>" + afterMatch + "</span>");
  4316. if (img.length) {
  4317. $el.prepend(img);
  4318. }
  4319. };
  4320. // Reset current element position
  4321. var resetCurrentElement = function () {
  4322. activeIndex = -1;
  4323. $autocomplete.find('.active').removeClass('active');
  4324. };
  4325. // Remove autocomplete elements
  4326. var removeAutocomplete = function () {
  4327. $autocomplete.empty();
  4328. resetCurrentElement();
  4329. oldVal = undefined;
  4330. };
  4331. $input.off('blur.autocomplete').on('blur.autocomplete', function () {
  4332. removeAutocomplete();
  4333. });
  4334. // Perform search
  4335. $input.off('keyup.autocomplete focus.autocomplete').on('keyup.autocomplete focus.autocomplete', function (e) {
  4336. // Reset count.
  4337. count = 0;
  4338. var val = $input.val().toLowerCase();
  4339. // Don't capture enter or arrow key usage.
  4340. if (e.which === 13 || e.which === 38 || e.which === 40) {
  4341. return;
  4342. }
  4343. // Check if the input isn't empty
  4344. if (oldVal !== val) {
  4345. removeAutocomplete();
  4346. if (val.length >= options.minLength) {
  4347. for (var key in data) {
  4348. if (data.hasOwnProperty(key) && key.toLowerCase().indexOf(val) !== -1) {
  4349. // Break if past limit
  4350. if (count >= options.limit) {
  4351. break;
  4352. }
  4353. var autocompleteOption = $('<li></li>');
  4354. if (!!data[key]) {
  4355. autocompleteOption.append('<img src="' + data[key] + '" class="right circle"><span>' + key + '</span>');
  4356. } else {
  4357. autocompleteOption.append('<span>' + key + '</span>');
  4358. }
  4359. $autocomplete.append(autocompleteOption);
  4360. highlight(val, autocompleteOption);
  4361. count++;
  4362. }
  4363. }
  4364. }
  4365. }
  4366. // Update oldVal
  4367. oldVal = val;
  4368. });
  4369. $input.off('keydown.autocomplete').on('keydown.autocomplete', function (e) {
  4370. // Arrow keys and enter key usage
  4371. var keyCode = e.which,
  4372. liElement,
  4373. numItems = $autocomplete.children('li').length,
  4374. $active = $autocomplete.children('.active').first();
  4375. // select element on Enter
  4376. if (keyCode === 13 && activeIndex >= 0) {
  4377. liElement = $autocomplete.children('li').eq(activeIndex);
  4378. if (liElement.length) {
  4379. liElement.trigger('mousedown.autocomplete');
  4380. e.preventDefault();
  4381. }
  4382. return;
  4383. }
  4384. // Capture up and down key
  4385. if (keyCode === 38 || keyCode === 40) {
  4386. e.preventDefault();
  4387. if (keyCode === 38 && activeIndex > 0) {
  4388. activeIndex--;
  4389. }
  4390. if (keyCode === 40 && activeIndex < numItems - 1) {
  4391. activeIndex++;
  4392. }
  4393. $active.removeClass('active');
  4394. if (activeIndex >= 0) {
  4395. $autocomplete.children('li').eq(activeIndex).addClass('active');
  4396. }
  4397. }
  4398. });
  4399. // Set input value
  4400. $autocomplete.off('mousedown.autocomplete touchstart.autocomplete').on('mousedown.autocomplete touchstart.autocomplete', 'li', function () {
  4401. var text = $(this).text().trim();
  4402. $input.val(text);
  4403. $input.trigger('change');
  4404. removeAutocomplete();
  4405. // Handle onAutocomplete callback.
  4406. if (typeof options.onAutocomplete === "function") {
  4407. options.onAutocomplete.call(this, text);
  4408. }
  4409. });
  4410. // Empty data
  4411. } else {
  4412. $input.off('keyup.autocomplete focus.autocomplete');
  4413. }
  4414. });
  4415. };
  4416. }); // End of $(document).ready
  4417. /*******************
  4418. * Select Plugin *
  4419. ******************/
  4420. $.fn.material_select = function (callback) {
  4421. $(this).each(function () {
  4422. var $select = $(this);
  4423. if ($select.hasClass('browser-default')) {
  4424. return; // Continue to next (return false breaks out of entire loop)
  4425. }
  4426. var multiple = $select.attr('multiple') ? true : false,
  4427. lastID = $select.attr('data-select-id'); // Tear down structure if Select needs to be rebuilt
  4428. if (lastID) {
  4429. $select.parent().find('span.caret').remove();
  4430. $select.parent().find('input').remove();
  4431. $select.unwrap();
  4432. $('ul#select-options-' + lastID).remove();
  4433. }
  4434. // If destroying the select, remove the selelct-id and reset it to it's uninitialized state.
  4435. if (callback === 'destroy') {
  4436. $select.removeAttr('data-select-id').removeClass('initialized');
  4437. $(window).off('click.select');
  4438. return;
  4439. }
  4440. var uniqueID = Materialize.guid();
  4441. $select.attr('data-select-id', uniqueID);
  4442. var wrapper = $('<div class="select-wrapper"></div>');
  4443. wrapper.addClass($select.attr('class'));
  4444. if ($select.is(':disabled')) wrapper.addClass('disabled');
  4445. var options = $('<ul id="select-options-' + uniqueID + '" class="dropdown-content select-dropdown ' + (multiple ? 'multiple-select-dropdown' : '') + '"></ul>'),
  4446. selectChildren = $select.children('option, optgroup'),
  4447. valuesSelected = [],
  4448. optionsHover = false;
  4449. var label = $select.find('option:selected').html() || $select.find('option:first').html() || "";
  4450. var a = "disabled"
  4451. var a1 = $("#send_file")[0];
  4452. var a2 = $("#qiehuanbtn")[0];
  4453. var a3 = $("#send_string")[0];
  4454. var a4 = $("#uploadpy")[0];
  4455. if (label == CCB.str_group.no_port_option || !!!isgetmcnty) {
  4456. if (a1.className.indexOf("disabled") != -1) {
  4457. } else {
  4458. a1.className += a;
  4459. a2.className += a;
  4460. a3.className += a;
  4461. a4.className += a;
  4462. // $("#refresh-disabled").css("display","block");
  4463. $("#refresh").css("display","block");
  4464. $("#refresh-press").css("display","none");
  4465. $("#progress").css("display","none");
  4466. $("#uploader_connect_status").css("display","block");
  4467. $("#runSuccess").css("display","none");
  4468. $("#runFail").css("display","none");
  4469. $(".determinate").css("width","0%");
  4470. $("#statusMsg").replaceWith(`<span id="statusMsg" style="display: none;"></span>`);
  4471. $('#device_connect_status').replaceWith(`<span id="device_connect_status" style="color: #222222;font-family: '微软雅黑';font-size: 16px;font-weight: bold;"><span id="device_connect_status_txt">${Ardublockly.LOCALISED_TEXT.device_no_connect}&nbsp&nbsp&nbsp&nbsp</span></span>`);
  4472. }
  4473. } else {
  4474. a1.className = a1.className.replace(a, "");
  4475. a2.className = a2.className.replace(a, "");
  4476. a3.className = a3.className.replace(a, "");
  4477. a4.className = a4.className.replace(a, "");
  4478. // $("#refresh-disabled").css("display","none");
  4479. $("#refresh").css("display","block");
  4480. $("#refresh-press").css("display","none");
  4481. $("#progress").css("display","block");
  4482. $("#uploader_connect_status").css("display","none");
  4483. $("#statusMsg").css("display","block");
  4484. $('#device_connect_status').replaceWith(`<span id="device_connect_status" style="color: #222222;font-family: '微软雅黑';font-size: 16px;font-weight: bold;"><span id="device_connect_status_txt">${Ardublockly.LOCALISED_TEXT.device_connect}&nbsp&nbsp&nbsp&nbsp</span></span>`);
  4485. }
  4486. // Function that renders and appends the option taking into
  4487. // account type and possible image icon.
  4488. var appendOptionWithIcon = function (select, option, type) {
  4489. // Add disabled attr if disabled
  4490. var disabledClass = option.is(':disabled') ? 'disabled ' : '';
  4491. var optgroupClass = type === 'optgroup-option' ? 'optgroup-option ' : '';
  4492. var multipleCheckbox = multiple ? '<input type="checkbox"' + disabledClass + '/><label></label>' : '';
  4493. // add icons
  4494. var icon_url = option.data('icon');
  4495. var classes = option.attr('class');
  4496. if (!!icon_url) {
  4497. var classString = '';
  4498. if (!!classes) classString = ' class="' + classes + '"';
  4499. // Check for multiple type.
  4500. options.append($('<li class="' + disabledClass + optgroupClass + '"><img alt="" src="' + icon_url + '"' + classString + '><span>' + multipleCheckbox + option.html() + '</span></li>'));
  4501. return true;
  4502. }
  4503. // Check for multiple type.
  4504. options.append($('<li class="' + disabledClass + optgroupClass + '"><span>' + multipleCheckbox + option.html() + '</span></li>'));
  4505. };
  4506. /* Create dropdown structure. */
  4507. if (selectChildren.length) {
  4508. selectChildren.each(function () {
  4509. if ($(this).is('option')) {
  4510. // Direct descendant option.
  4511. if (multiple) {
  4512. appendOptionWithIcon($select, $(this), 'multiple');
  4513. } else {
  4514. appendOptionWithIcon($select, $(this));
  4515. }
  4516. } else if ($(this).is('optgroup')) {
  4517. // Optgroup.
  4518. var selectOptions = $(this).children('option');
  4519. options.append($('<li class="optgroup"><span>' + $(this).attr('label') + '</span></li>'));
  4520. selectOptions.each(function () {
  4521. appendOptionWithIcon($select, $(this), 'optgroup-option');
  4522. });
  4523. }
  4524. });
  4525. }
  4526. options.find('li:not(.optgroup)').each(function (i) {
  4527. $(this).click(function (e) {
  4528. // Check if option element is disabled
  4529. if (!$(this).hasClass('disabled') && !$(this).hasClass('optgroup')) {
  4530. var selected = true;
  4531. if (multiple) {
  4532. $('input[type="checkbox"]', this).prop('checked', function (i, v) {
  4533. return !v;
  4534. });
  4535. selected = toggleEntryFromArray(valuesSelected, i, $select);
  4536. $newSelect.trigger('focus');
  4537. } else {
  4538. options.find('li').removeClass('active');
  4539. $(this).toggleClass('active');
  4540. $newSelect.val($(this).text());
  4541. }
  4542. activateOption(options, $(this));
  4543. $select.find('option').eq(i).prop('selected', selected);
  4544. // Trigger onchange() event
  4545. $select.trigger('change');
  4546. if (typeof callback !== 'undefined') callback();
  4547. }
  4548. e.stopPropagation();
  4549. });
  4550. });
  4551. // Wrap Elements
  4552. $select.wrap(wrapper);
  4553. // Add Select Display Element
  4554. var dropdownIcon = $('<span class="caret">&#9660;</span>');
  4555. // escape double quotes
  4556. var sanitizedLabelHtml = label.replace(/"/g, '&quot;');
  4557. var $newSelect = $('<input type="text" class="select-dropdown" readonly="true" ' + ($select.is(':disabled') ? 'disabled' : '') + ' data-activates="select-options-' + uniqueID + '" value="' + sanitizedLabelHtml + '"/>');
  4558. $select.before($newSelect);
  4559. $newSelect.before(dropdownIcon);
  4560. $newSelect.after(options);
  4561. // Check if section element is disabled
  4562. if (!$select.is(':disabled')) {
  4563. $newSelect.dropdown({ 'hover': false });
  4564. }
  4565. // Copy tabindex
  4566. if ($select.attr('tabindex')) {
  4567. $($newSelect[0]).attr('tabindex', $select.attr('tabindex'));
  4568. }
  4569. $select.addClass('initialized');
  4570. $newSelect.on({
  4571. 'focus': function () {
  4572. if ($('ul.select-dropdown').not(options[0]).is(':visible')) {
  4573. $('input.select-dropdown').trigger('close');
  4574. $(window).off('click.select');
  4575. }
  4576. if (!options.is(':visible')) {
  4577. $(this).trigger('open', ['focus']);
  4578. var label = $(this).val();
  4579. if (multiple && label.indexOf(',') >= 0) {
  4580. label = label.split(',')[0];
  4581. }
  4582. var selectedOption = options.find('li').filter(function () {
  4583. return $(this).text().toLowerCase() === label.toLowerCase();
  4584. })[0];
  4585. activateOption(options, selectedOption, true);
  4586. $(window).off('click.select').on('click.select', function () {
  4587. multiple && (optionsHover || $newSelect.trigger('close'));
  4588. $(window).off('click.select');
  4589. });
  4590. }
  4591. },
  4592. 'click': function (e) {
  4593. e.stopPropagation();
  4594. }
  4595. });
  4596. $newSelect.on('blur', function () {
  4597. if (!multiple) {
  4598. $(this).trigger('close');
  4599. $(window).off('click.select');
  4600. }
  4601. options.find('li.selected').removeClass('selected');
  4602. });
  4603. options.hover(function () {
  4604. optionsHover = true;
  4605. }, function () {
  4606. optionsHover = false;
  4607. });
  4608. // Add initial multiple selections.
  4609. if (multiple) {
  4610. $select.find("option:selected:not(:disabled)").each(function () {
  4611. var index = this.index;
  4612. toggleEntryFromArray(valuesSelected, index, $select);
  4613. options.find("li:not(.optgroup)").eq(index).find(":checkbox").prop("checked", true);
  4614. });
  4615. }
  4616. /**
  4617. * Make option as selected and scroll to selected position
  4618. * @param {jQuery} collection Select options jQuery element
  4619. * @param {Element} newOption element of the new option
  4620. * @param {Boolean} firstActivation If on first activation of select
  4621. */
  4622. var activateOption = function (collection, newOption, firstActivation) {
  4623. if (newOption) {
  4624. collection.find('li.selected').removeClass('selected');
  4625. var option = $(newOption);
  4626. option.addClass('selected');
  4627. if (!multiple || !!firstActivation) {
  4628. options.scrollTo(option);
  4629. }
  4630. }
  4631. };
  4632. // Allow user to search by typing
  4633. // this array is cleared after 1 second
  4634. var filterQuery = [],
  4635. onKeyDown = function (e) {
  4636. // TAB - switch to another input
  4637. if (e.which == 9) {
  4638. $newSelect.trigger('close');
  4639. return;
  4640. }
  4641. // ARROW DOWN WHEN SELECT IS CLOSED - open select options
  4642. if (e.which == 40 && !options.is(':visible')) {
  4643. $newSelect.trigger('open');
  4644. return;
  4645. }
  4646. // ENTER WHEN SELECT IS CLOSED - submit form
  4647. if (e.which == 13 && !options.is(':visible')) {
  4648. return;
  4649. }
  4650. e.preventDefault();
  4651. // CASE WHEN USER TYPE LETTERS
  4652. var letter = String.fromCharCode(e.which).toLowerCase(),
  4653. nonLetters = [9, 13, 27, 38, 40];
  4654. if (letter && nonLetters.indexOf(e.which) === -1) {
  4655. filterQuery.push(letter);
  4656. var string = filterQuery.join(''),
  4657. newOption = options.find('li').filter(function () {
  4658. return $(this).text().toLowerCase().indexOf(string) === 0;
  4659. })[0];
  4660. if (newOption) {
  4661. activateOption(options, newOption);
  4662. }
  4663. }
  4664. // ENTER - select option and close when select options are opened
  4665. if (e.which == 13) {
  4666. var activeOption = options.find('li.selected:not(.disabled)')[0];
  4667. if (activeOption) {
  4668. $(activeOption).trigger('click');
  4669. if (!multiple) {
  4670. $newSelect.trigger('close');
  4671. }
  4672. }
  4673. }
  4674. // ARROW DOWN - move to next not disabled option
  4675. if (e.which == 40) {
  4676. if (options.find('li.selected').length) {
  4677. newOption = options.find('li.selected').next('li:not(.disabled)')[0];
  4678. } else {
  4679. newOption = options.find('li:not(.disabled)')[0];
  4680. }
  4681. activateOption(options, newOption);
  4682. }
  4683. // ESC - close options
  4684. if (e.which == 27) {
  4685. $newSelect.trigger('close');
  4686. }
  4687. // ARROW UP - move to previous not disabled option
  4688. if (e.which == 38) {
  4689. newOption = options.find('li.selected').prev('li:not(.disabled)')[0];
  4690. if (newOption) activateOption(options, newOption);
  4691. }
  4692. // Automaticaly clean filter query so user can search again by starting letters
  4693. setTimeout(function () {
  4694. filterQuery = [];
  4695. }, 1000);
  4696. };
  4697. $newSelect.on('keydown', onKeyDown);
  4698. });
  4699. function toggleEntryFromArray(entriesArray, entryIndex, select) {
  4700. var index = entriesArray.indexOf(entryIndex),
  4701. notAdded = index === -1;
  4702. if (notAdded) {
  4703. entriesArray.push(entryIndex);
  4704. } else {
  4705. entriesArray.splice(index, 1);
  4706. }
  4707. select.siblings('ul.dropdown-content').find('li:not(.optgroup)').eq(entryIndex).toggleClass('active');
  4708. // use notAdded instead of true (to detect if the option is selected or not)
  4709. select.find('option').eq(entryIndex).prop('selected', notAdded);
  4710. setValueToInput(entriesArray, select);
  4711. return notAdded;
  4712. }
  4713. function setValueToInput(entriesArray, select) {
  4714. var value = '';
  4715. for (var i = 0, count = entriesArray.length; i < count; i++) {
  4716. var text = select.find('option').eq(entriesArray[i]).text();
  4717. i === 0 ? value += text : value += ', ' + text;
  4718. }
  4719. if (value === '') {
  4720. value = select.find('option:disabled').eq(0).text();
  4721. }
  4722. select.siblings('input.select-dropdown').val(value);
  4723. }
  4724. };
  4725. })(jQuery);
  4726. ; (function ($) {
  4727. var methods = {
  4728. init: function (options) {
  4729. var defaults = {
  4730. indicators: true,
  4731. height: 400,
  4732. transition: 500,
  4733. interval: 6000
  4734. };
  4735. options = $.extend(defaults, options);
  4736. return this.each(function () {
  4737. // For each slider, we want to keep track of
  4738. // which slide is active and its associated content
  4739. var $this = $(this);
  4740. var $slider = $this.find('ul.slides').first();
  4741. var $slides = $slider.find('> li');
  4742. var $active_index = $slider.find('.active').index();
  4743. var $active, $indicators, $interval;
  4744. if ($active_index != -1) {
  4745. $active = $slides.eq($active_index);
  4746. }
  4747. // Transitions the caption depending on alignment
  4748. function captionTransition(caption, duration) {
  4749. if (caption.hasClass("center-align")) {
  4750. caption.velocity({ opacity: 0, translateY: -100 }, { duration: duration, queue: false });
  4751. } else if (caption.hasClass("right-align")) {
  4752. caption.velocity({ opacity: 0, translateX: 100 }, { duration: duration, queue: false });
  4753. } else if (caption.hasClass("left-align")) {
  4754. caption.velocity({ opacity: 0, translateX: -100 }, { duration: duration, queue: false });
  4755. }
  4756. }
  4757. // This function will transition the slide to any index of the next slide
  4758. function moveToSlide(index) {
  4759. // Wrap around indices.
  4760. if (index >= $slides.length) index = 0; else if (index < 0) index = $slides.length - 1;
  4761. $active_index = $slider.find('.active').index();
  4762. // Only do if index changes
  4763. if ($active_index != index) {
  4764. $active = $slides.eq($active_index);
  4765. $caption = $active.find('.caption');
  4766. $active.removeClass('active');
  4767. $active.velocity({ opacity: 0 }, {
  4768. duration: options.transition, queue: false, easing: 'easeOutQuad',
  4769. complete: function () {
  4770. $slides.not('.active').velocity({ opacity: 0, translateX: 0, translateY: 0 }, { duration: 0, queue: false });
  4771. }
  4772. });
  4773. captionTransition($caption, options.transition);
  4774. // Update indicators
  4775. if (options.indicators) {
  4776. $indicators.eq($active_index).removeClass('active');
  4777. }
  4778. $slides.eq(index).velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' });
  4779. $slides.eq(index).find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, delay: options.transition, queue: false, easing: 'easeOutQuad' });
  4780. $slides.eq(index).addClass('active');
  4781. // Update indicators
  4782. if (options.indicators) {
  4783. $indicators.eq(index).addClass('active');
  4784. }
  4785. }
  4786. }
  4787. // Set height of slider
  4788. // If fullscreen, do nothing
  4789. if (!$this.hasClass('fullscreen')) {
  4790. if (options.indicators) {
  4791. // Add height if indicators are present
  4792. $this.height(options.height + 40);
  4793. } else {
  4794. $this.height(options.height);
  4795. }
  4796. $slider.height(options.height);
  4797. }
  4798. // Set initial positions of captions
  4799. $slides.find('.caption').each(function () {
  4800. captionTransition($(this), 0);
  4801. });
  4802. // Move img src into background-image
  4803. $slides.find('img').each(function () {
  4804. var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
  4805. if ($(this).attr('src') !== placeholderBase64) {
  4806. $(this).css('background-image', 'url("' + $(this).attr('src') + '")');
  4807. $(this).attr('src', placeholderBase64);
  4808. }
  4809. });
  4810. // dynamically add indicators
  4811. if (options.indicators) {
  4812. $indicators = $('<ul class="indicators"></ul>');
  4813. $slides.each(function (index) {
  4814. var $indicator = $('<li class="indicator-item"></li>');
  4815. // Handle clicks on indicators
  4816. $indicator.click(function () {
  4817. var $parent = $slider.parent();
  4818. var curr_index = $parent.find($(this)).index();
  4819. moveToSlide(curr_index);
  4820. // reset interval
  4821. clearInterval($interval);
  4822. $interval = setInterval(function () {
  4823. $active_index = $slider.find('.active').index();
  4824. if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
  4825. else $active_index += 1;
  4826. moveToSlide($active_index);
  4827. }, options.transition + options.interval);
  4828. });
  4829. $indicators.append($indicator);
  4830. });
  4831. $this.append($indicators);
  4832. $indicators = $this.find('ul.indicators').find('li.indicator-item');
  4833. }
  4834. if ($active) {
  4835. $active.show();
  4836. } else {
  4837. $slides.first().addClass('active').velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' });
  4838. $active_index = 0;
  4839. $active = $slides.eq($active_index);
  4840. // Update indicators
  4841. if (options.indicators) {
  4842. $indicators.eq($active_index).addClass('active');
  4843. }
  4844. }
  4845. // Adjust height to current slide
  4846. $active.find('img').each(function () {
  4847. $active.find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' });
  4848. });
  4849. // auto scroll
  4850. $interval = setInterval(function () {
  4851. $active_index = $slider.find('.active').index();
  4852. moveToSlide($active_index + 1);
  4853. }, options.transition + options.interval);
  4854. // HammerJS, Swipe navigation
  4855. // Touch Event
  4856. var panning = false;
  4857. var swipeLeft = false;
  4858. var swipeRight = false;
  4859. $this.hammer({
  4860. prevent_default: false
  4861. }).on('pan', function (e) {
  4862. if (e.gesture.pointerType === "touch") {
  4863. // reset interval
  4864. clearInterval($interval);
  4865. var direction = e.gesture.direction;
  4866. var x = e.gesture.deltaX;
  4867. var velocityX = e.gesture.velocityX;
  4868. var velocityY = e.gesture.velocityY;
  4869. $curr_slide = $slider.find('.active');
  4870. if (Math.abs(velocityX) > Math.abs(velocityY)) {
  4871. $curr_slide.velocity({
  4872. translateX: x
  4873. }, { duration: 50, queue: false, easing: 'easeOutQuad' });
  4874. }
  4875. // Swipe Left
  4876. if (direction === 4 && (x > $this.innerWidth() / 2 || velocityX < -0.65)) {
  4877. swipeRight = true;
  4878. }
  4879. // Swipe Right
  4880. else if (direction === 2 && (x < -1 * $this.innerWidth() / 2 || velocityX > 0.65)) {
  4881. swipeLeft = true;
  4882. }
  4883. // Make Slide Behind active slide visible
  4884. var next_slide;
  4885. if (swipeLeft) {
  4886. next_slide = $curr_slide.next();
  4887. if (next_slide.length === 0) {
  4888. next_slide = $slides.first();
  4889. }
  4890. next_slide.velocity({
  4891. opacity: 1
  4892. }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  4893. }
  4894. if (swipeRight) {
  4895. next_slide = $curr_slide.prev();
  4896. if (next_slide.length === 0) {
  4897. next_slide = $slides.last();
  4898. }
  4899. next_slide.velocity({
  4900. opacity: 1
  4901. }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  4902. }
  4903. }
  4904. }).on('panend', function (e) {
  4905. if (e.gesture.pointerType === "touch") {
  4906. $curr_slide = $slider.find('.active');
  4907. panning = false;
  4908. curr_index = $slider.find('.active').index();
  4909. if (!swipeRight && !swipeLeft || $slides.length <= 1) {
  4910. // Return to original spot
  4911. $curr_slide.velocity({
  4912. translateX: 0
  4913. }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  4914. } else if (swipeLeft) {
  4915. moveToSlide(curr_index + 1);
  4916. $curr_slide.velocity({ translateX: -1 * $this.innerWidth() }, {
  4917. duration: 300, queue: false, easing: 'easeOutQuad',
  4918. complete: function () {
  4919. $curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false });
  4920. }
  4921. });
  4922. } else if (swipeRight) {
  4923. moveToSlide(curr_index - 1);
  4924. $curr_slide.velocity({ translateX: $this.innerWidth() }, {
  4925. duration: 300, queue: false, easing: 'easeOutQuad',
  4926. complete: function () {
  4927. $curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false });
  4928. }
  4929. });
  4930. }
  4931. swipeLeft = false;
  4932. swipeRight = false;
  4933. // Restart interval
  4934. clearInterval($interval);
  4935. $interval = setInterval(function () {
  4936. $active_index = $slider.find('.active').index();
  4937. if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
  4938. else $active_index += 1;
  4939. moveToSlide($active_index);
  4940. }, options.transition + options.interval);
  4941. }
  4942. });
  4943. $this.on('sliderPause', function () {
  4944. clearInterval($interval);
  4945. });
  4946. $this.on('sliderStart', function () {
  4947. clearInterval($interval);
  4948. $interval = setInterval(function () {
  4949. $active_index = $slider.find('.active').index();
  4950. if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
  4951. else $active_index += 1;
  4952. moveToSlide($active_index);
  4953. }, options.transition + options.interval);
  4954. });
  4955. $this.on('sliderNext', function () {
  4956. $active_index = $slider.find('.active').index();
  4957. moveToSlide($active_index + 1);
  4958. });
  4959. $this.on('sliderPrev', function () {
  4960. $active_index = $slider.find('.active').index();
  4961. moveToSlide($active_index - 1);
  4962. });
  4963. });
  4964. },
  4965. pause: function () {
  4966. $(this).trigger('sliderPause');
  4967. },
  4968. start: function () {
  4969. $(this).trigger('sliderStart');
  4970. },
  4971. next: function () {
  4972. $(this).trigger('sliderNext');
  4973. },
  4974. prev: function () {
  4975. $(this).trigger('sliderPrev');
  4976. }
  4977. };
  4978. $.fn.slider = function (methodOrOptions) {
  4979. if (methods[methodOrOptions]) {
  4980. return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
  4981. } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
  4982. // Default to "init"
  4983. return methods.init.apply(this, arguments);
  4984. } else {
  4985. $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tooltip');
  4986. }
  4987. }; // Plugin end
  4988. })(jQuery);
  4989. ; (function ($) {
  4990. $(document).ready(function () {
  4991. $(document).on('click.card', '.card', function (e) {
  4992. if ($(this).find('> .card-reveal').length) {
  4993. var $card = $(e.target).closest('.card');
  4994. if ($card.data('initialOverflow') === undefined) {
  4995. $card.data('initialOverflow', $card.css('overflow') === undefined ? '' : $card.css('overflow'));
  4996. }
  4997. if ($(e.target).is($('.card-reveal .card-title>i'))) {
  4998. // Make Reveal animate down and display none
  4999. $(this).find('.card-reveal').velocity({ translateY: 0 }, {
  5000. duration: 225,
  5001. queue: false,
  5002. easing: 'easeInOutQuad',
  5003. complete: function () {
  5004. $(this).css({ display: 'none' });
  5005. $card.css('overflow', $card.data('initialOverflow'));
  5006. }
  5007. });
  5008. } else if ($(e.target).is($('.card .activator')) || $(e.target).is($('.card .activator i'))) {
  5009. $card.css('overflow', 'hidden');
  5010. $(this).find('.card-reveal').css({ display: 'block' }).velocity("stop", false).velocity({ translateY: '-100%' }, { duration: 300, queue: false, easing: 'easeInOutQuad' });
  5011. }
  5012. }
  5013. });
  5014. });
  5015. })(jQuery);
  5016. ; (function ($) {
  5017. var materialChipsDefaults = {
  5018. data: [],
  5019. placeholder: '',
  5020. secondaryPlaceholder: '',
  5021. autocompleteOptions: {}
  5022. };
  5023. $(document).ready(function () {
  5024. // Handle removal of static chips.
  5025. $(document).on('click', '.chip .close', function (e) {
  5026. var $chips = $(this).closest('.chips');
  5027. if ($chips.attr('data-initialized')) {
  5028. return;
  5029. }
  5030. $(this).closest('.chip').remove();
  5031. });
  5032. });
  5033. $.fn.material_chip = function (options) {
  5034. var self = this;
  5035. this.$el = $(this);
  5036. this.$document = $(document);
  5037. this.SELS = {
  5038. CHIPS: '.chips',
  5039. CHIP: '.chip',
  5040. INPUT: 'input',
  5041. DELETE: '.material-icons',
  5042. SELECTED_CHIP: '.selected'
  5043. };
  5044. if ('data' === options) {
  5045. return this.$el.data('chips');
  5046. }
  5047. var curr_options = $.extend({}, materialChipsDefaults, options);
  5048. self.hasAutocomplete = !$.isEmptyObject(curr_options.autocompleteOptions.data);
  5049. // Initialize
  5050. this.init = function () {
  5051. var i = 0;
  5052. var chips;
  5053. self.$el.each(function () {
  5054. var $chips = $(this);
  5055. var chipId = Materialize.guid();
  5056. self.chipId = chipId;
  5057. if (!curr_options.data || !(curr_options.data instanceof Array)) {
  5058. curr_options.data = [];
  5059. }
  5060. $chips.data('chips', curr_options.data);
  5061. $chips.attr('data-index', i);
  5062. $chips.attr('data-initialized', true);
  5063. if (!$chips.hasClass(self.SELS.CHIPS)) {
  5064. $chips.addClass('chips');
  5065. }
  5066. self.chips($chips, chipId);
  5067. i++;
  5068. });
  5069. };
  5070. this.handleEvents = function () {
  5071. var SELS = self.SELS;
  5072. self.$document.off('click.chips-focus', SELS.CHIPS).on('click.chips-focus', SELS.CHIPS, function (e) {
  5073. $(e.target).find(SELS.INPUT).focus();
  5074. });
  5075. self.$document.off('click.chips-select', SELS.CHIP).on('click.chips-select', SELS.CHIP, function (e) {
  5076. var $chip = $(e.target);
  5077. if ($chip.length) {
  5078. var wasSelected = $chip.hasClass('selected');
  5079. var $chips = $chip.closest(SELS.CHIPS);
  5080. $(SELS.CHIP).removeClass('selected');
  5081. if (!wasSelected) {
  5082. self.selectChip($chip.index(), $chips);
  5083. }
  5084. }
  5085. });
  5086. self.$document.off('keydown.chips').on('keydown.chips', function (e) {
  5087. if ($(e.target).is('input, textarea')) {
  5088. return;
  5089. }
  5090. // delete
  5091. var $chip = self.$document.find(SELS.CHIP + SELS.SELECTED_CHIP);
  5092. var $chips = $chip.closest(SELS.CHIPS);
  5093. var length = $chip.siblings(SELS.CHIP).length;
  5094. var index;
  5095. if (!$chip.length) {
  5096. return;
  5097. }
  5098. if (e.which === 8 || e.which === 46) {
  5099. e.preventDefault();
  5100. index = $chip.index();
  5101. self.deleteChip(index, $chips);
  5102. var selectIndex = null;
  5103. if (index + 1 < length) {
  5104. selectIndex = index;
  5105. } else if (index === length || index + 1 === length) {
  5106. selectIndex = length - 1;
  5107. }
  5108. if (selectIndex < 0) selectIndex = null;
  5109. if (null !== selectIndex) {
  5110. self.selectChip(selectIndex, $chips);
  5111. }
  5112. if (!length) $chips.find('input').focus();
  5113. // left
  5114. } else if (e.which === 37) {
  5115. index = $chip.index() - 1;
  5116. if (index < 0) {
  5117. return;
  5118. }
  5119. $(SELS.CHIP).removeClass('selected');
  5120. self.selectChip(index, $chips);
  5121. // right
  5122. } else if (e.which === 39) {
  5123. index = $chip.index() + 1;
  5124. $(SELS.CHIP).removeClass('selected');
  5125. if (index > length) {
  5126. $chips.find('input').focus();
  5127. return;
  5128. }
  5129. self.selectChip(index, $chips);
  5130. }
  5131. });
  5132. self.$document.off('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) {
  5133. var $currChips = $(e.target).closest(SELS.CHIPS);
  5134. $currChips.addClass('focus');
  5135. $currChips.siblings('label, .prefix').addClass('active');
  5136. $(SELS.CHIP).removeClass('selected');
  5137. });
  5138. self.$document.off('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) {
  5139. var $currChips = $(e.target).closest(SELS.CHIPS);
  5140. $currChips.removeClass('focus');
  5141. // Remove active if empty
  5142. if ($currChips.data('chips') === undefined || !$currChips.data('chips').length) {
  5143. $currChips.siblings('label').removeClass('active');
  5144. }
  5145. $currChips.siblings('.prefix').removeClass('active');
  5146. });
  5147. self.$document.off('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT).on('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT, function (e) {
  5148. var $target = $(e.target);
  5149. var $chips = $target.closest(SELS.CHIPS);
  5150. var chipsLength = $chips.children(SELS.CHIP).length;
  5151. // enter
  5152. if (13 === e.which) {
  5153. // Override enter if autocompleting.
  5154. if (self.hasAutocomplete && $chips.find('.autocomplete-content.dropdown-content').length && $chips.find('.autocomplete-content.dropdown-content').children().length) {
  5155. return;
  5156. }
  5157. e.preventDefault();
  5158. self.addChip({ tag: $target.val() }, $chips);
  5159. $target.val('');
  5160. return;
  5161. }
  5162. // delete or left
  5163. if ((8 === e.keyCode || 37 === e.keyCode) && '' === $target.val() && chipsLength) {
  5164. e.preventDefault();
  5165. self.selectChip(chipsLength - 1, $chips);
  5166. $target.blur();
  5167. return;
  5168. }
  5169. });
  5170. // Click on delete icon in chip.
  5171. self.$document.off('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE).on('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE, function (e) {
  5172. var $target = $(e.target);
  5173. var $chips = $target.closest(SELS.CHIPS);
  5174. var $chip = $target.closest(SELS.CHIP);
  5175. e.stopPropagation();
  5176. self.deleteChip($chip.index(), $chips);
  5177. $chips.find('input').focus();
  5178. });
  5179. };
  5180. this.chips = function ($chips, chipId) {
  5181. $chips.empty();
  5182. $chips.data('chips').forEach(function (elem) {
  5183. $chips.append(self.renderChip(elem));
  5184. });
  5185. $chips.append($('<input id="' + chipId + '" class="input" placeholder="">'));
  5186. self.setPlaceholder($chips);
  5187. // Set for attribute for label
  5188. var label = $chips.next('label');
  5189. if (label.length) {
  5190. label.attr('for', chipId);
  5191. if ($chips.data('chips') !== undefined && $chips.data('chips').length) {
  5192. label.addClass('active');
  5193. }
  5194. }
  5195. // Setup autocomplete if needed.
  5196. var input = $('#' + chipId);
  5197. if (self.hasAutocomplete) {
  5198. curr_options.autocompleteOptions.onAutocomplete = function (val) {
  5199. self.addChip({ tag: val }, $chips);
  5200. input.val('');
  5201. input.focus();
  5202. };
  5203. input.autocomplete(curr_options.autocompleteOptions);
  5204. }
  5205. };
  5206. /**
  5207. * Render chip jQuery element.
  5208. * @param {Object} elem
  5209. * @return {jQuery}
  5210. */
  5211. this.renderChip = function (elem) {
  5212. if (!elem.tag) return;
  5213. var $renderedChip = $('<div class="chip"></div>');
  5214. $renderedChip.text(elem.tag);
  5215. if (elem.image) {
  5216. $renderedChip.prepend($('<img />').attr('src', elem.image));
  5217. }
  5218. $renderedChip.append($('<i class="material-icons close">close</i>'));
  5219. return $renderedChip;
  5220. };
  5221. this.setPlaceholder = function ($chips) {
  5222. if ($chips.data('chips') !== undefined && !$chips.data('chips').length && curr_options.placeholder) {
  5223. $chips.find('input').prop('placeholder', curr_options.placeholder);
  5224. } else if (($chips.data('chips') === undefined || !!$chips.data('chips').length) && curr_options.secondaryPlaceholder) {
  5225. $chips.find('input').prop('placeholder', curr_options.secondaryPlaceholder);
  5226. }
  5227. };
  5228. this.isValid = function ($chips, elem) {
  5229. var chips = $chips.data('chips');
  5230. var exists = false;
  5231. for (var i = 0; i < chips.length; i++) {
  5232. if (chips[i].tag === elem.tag) {
  5233. exists = true;
  5234. return;
  5235. }
  5236. }
  5237. return '' !== elem.tag && !exists;
  5238. };
  5239. this.addChip = function (elem, $chips) {
  5240. if (!self.isValid($chips, elem)) {
  5241. return;
  5242. }
  5243. var $renderedChip = self.renderChip(elem);
  5244. var newData = [];
  5245. var oldData = $chips.data('chips');
  5246. for (var i = 0; i < oldData.length; i++) {
  5247. newData.push(oldData[i]);
  5248. }
  5249. newData.push(elem);
  5250. $chips.data('chips', newData);
  5251. $renderedChip.insertBefore($chips.find('input'));
  5252. $chips.trigger('chip.add', elem);
  5253. self.setPlaceholder($chips);
  5254. };
  5255. this.deleteChip = function (chipIndex, $chips) {
  5256. var chip = $chips.data('chips')[chipIndex];
  5257. $chips.find('.chip').eq(chipIndex).remove();
  5258. var newData = [];
  5259. var oldData = $chips.data('chips');
  5260. for (var i = 0; i < oldData.length; i++) {
  5261. if (i !== chipIndex) {
  5262. newData.push(oldData[i]);
  5263. }
  5264. }
  5265. $chips.data('chips', newData);
  5266. $chips.trigger('chip.delete', chip);
  5267. self.setPlaceholder($chips);
  5268. };
  5269. this.selectChip = function (chipIndex, $chips) {
  5270. var $chip = $chips.find('.chip').eq(chipIndex);
  5271. if ($chip && false === $chip.hasClass('selected')) {
  5272. $chip.addClass('selected');
  5273. $chips.trigger('chip.select', $chips.data('chips')[chipIndex]);
  5274. }
  5275. };
  5276. this.getChipsElement = function (index, $chips) {
  5277. return $chips.eq(index);
  5278. };
  5279. // init
  5280. this.init();
  5281. this.handleEvents();
  5282. };
  5283. })(jQuery);
  5284. ; (function ($) {
  5285. $.fn.pushpin = function (options) {
  5286. // Defaults
  5287. var defaults = {
  5288. top: 0,
  5289. bottom: Infinity,
  5290. offset: 0
  5291. };
  5292. // Remove pushpin event and classes
  5293. if (options === "remove") {
  5294. this.each(function () {
  5295. if (id = $(this).data('pushpin-id')) {
  5296. $(window).off('scroll.' + id);
  5297. $(this).removeData('pushpin-id').removeClass('pin-top pinned pin-bottom').removeAttr('style');
  5298. }
  5299. });
  5300. return false;
  5301. }
  5302. options = $.extend(defaults, options);
  5303. $index = 0;
  5304. return this.each(function () {
  5305. var $uniqueId = Materialize.guid(),
  5306. $this = $(this),
  5307. $original_offset = $(this).offset().top;
  5308. function removePinClasses(object) {
  5309. object.removeClass('pin-top');
  5310. object.removeClass('pinned');
  5311. object.removeClass('pin-bottom');
  5312. }
  5313. function updateElements(objects, scrolled) {
  5314. objects.each(function () {
  5315. // Add position fixed (because its between top and bottom)
  5316. if (options.top <= scrolled && options.bottom >= scrolled && !$(this).hasClass('pinned')) {
  5317. removePinClasses($(this));
  5318. $(this).css('top', options.offset);
  5319. $(this).addClass('pinned');
  5320. }
  5321. // Add pin-top (when scrolled position is above top)
  5322. if (scrolled < options.top && !$(this).hasClass('pin-top')) {
  5323. removePinClasses($(this));
  5324. $(this).css('top', 0);
  5325. $(this).addClass('pin-top');
  5326. }
  5327. // Add pin-bottom (when scrolled position is below bottom)
  5328. if (scrolled > options.bottom && !$(this).hasClass('pin-bottom')) {
  5329. removePinClasses($(this));
  5330. $(this).addClass('pin-bottom');
  5331. $(this).css('top', options.bottom - $original_offset);
  5332. }
  5333. });
  5334. }
  5335. $(this).data('pushpin-id', $uniqueId);
  5336. updateElements($this, $(window).scrollTop());
  5337. $(window).on('scroll.' + $uniqueId, function () {
  5338. var $scrolled = $(window).scrollTop() + options.offset;
  5339. updateElements($this, $scrolled);
  5340. });
  5341. });
  5342. };
  5343. })(jQuery);; (function ($) {
  5344. $(document).ready(function () {
  5345. // jQuery reverse
  5346. $.fn.reverse = [].reverse;
  5347. // Hover behaviour: make sure this doesn't work on .click-to-toggle FABs!
  5348. $(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) {
  5349. var $this = $(this);
  5350. openFABMenu($this);
  5351. });
  5352. $(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) {
  5353. var $this = $(this);
  5354. closeFABMenu($this);
  5355. });
  5356. // Toggle-on-click behaviour.
  5357. $(document).on('click.fabClickToggle', '.fixed-action-btn.click-to-toggle > a', function (e) {
  5358. var $this = $(this);
  5359. var $menu = $this.parent();
  5360. if ($menu.hasClass('active')) {
  5361. closeFABMenu($menu);
  5362. } else {
  5363. openFABMenu($menu);
  5364. }
  5365. });
  5366. // Toolbar transition behaviour.
  5367. $(document).on('click.fabToolbar', '.fixed-action-btn.toolbar > a', function (e) {
  5368. var $this = $(this);
  5369. var $menu = $this.parent();
  5370. FABtoToolbar($menu);
  5371. });
  5372. });
  5373. $.fn.extend({
  5374. openFAB: function () {
  5375. openFABMenu($(this));
  5376. },
  5377. closeFAB: function () {
  5378. closeFABMenu($(this));
  5379. },
  5380. openToolbar: function () {
  5381. FABtoToolbar($(this));
  5382. },
  5383. closeToolbar: function () {
  5384. toolbarToFAB($(this));
  5385. }
  5386. });
  5387. var openFABMenu = function (btn) {
  5388. var $this = btn;
  5389. if ($this.hasClass('active') === false) {
  5390. // Get direction option
  5391. var horizontal = $this.hasClass('horizontal');
  5392. var offsetY, offsetX;
  5393. if (horizontal === true) {
  5394. offsetX = 40;
  5395. } else {
  5396. offsetY = 40;
  5397. }
  5398. if ($this.find("div").length > 0) {
  5399. $this.find("div")[0].style.display = "block";
  5400. }
  5401. else {
  5402. $this.addClass('active');
  5403. $this.find('ul .btn-floating').velocity({ scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 0 });
  5404. var time = 0;
  5405. $this.find('ul .btn-floating').reverse().each(function () {
  5406. $(this).velocity({ opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0' }, { duration: 80, delay: time });
  5407. time += 40;
  5408. });
  5409. }
  5410. }
  5411. };
  5412. var closeFABMenu = function (btn) {
  5413. var $this = btn;
  5414. // Get direction option
  5415. var horizontal = $this.hasClass('horizontal');
  5416. var offsetY, offsetX;
  5417. if (horizontal === true) {
  5418. offsetX = 40;
  5419. } else {
  5420. offsetY = 40;
  5421. }
  5422. $this.removeClass('active');
  5423. var time = 0;
  5424. $this.find('ul .btn-floating').velocity("stop", true);
  5425. $this.find('ul .btn-floating').velocity({ opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 80 });
  5426. };
  5427. /**
  5428. * Transform FAB into toolbar
  5429. * @param {Object} object jQuery object
  5430. */
  5431. var FABtoToolbar = function (btn) {
  5432. if (btn.attr('data-open') === "true") {
  5433. return;
  5434. }
  5435. var offsetX, offsetY, scaleFactor;
  5436. var windowWidth = window.innerWidth;
  5437. var windowHeight = window.innerHeight;
  5438. var btnRect = btn[0].getBoundingClientRect();
  5439. var anchor = btn.find('> a').first();
  5440. var menu = btn.find('> ul').first();
  5441. var backdrop = $('<div class="fab-backdrop"></div>');
  5442. var fabColor = anchor.css('background-color');
  5443. anchor.append(backdrop);
  5444. offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
  5445. offsetY = windowHeight - btnRect.bottom;
  5446. scaleFactor = windowWidth / backdrop.width();
  5447. btn.attr('data-origin-bottom', btnRect.bottom);
  5448. btn.attr('data-origin-left', btnRect.left);
  5449. btn.attr('data-origin-width', btnRect.width);
  5450. // Set initial state
  5451. btn.addClass('active');
  5452. btn.attr('data-open', true);
  5453. btn.css({
  5454. 'text-align': 'center',
  5455. width: '100%',
  5456. bottom: 0,
  5457. left: 0,
  5458. transform: 'translateX(' + offsetX + 'px)',
  5459. transition: 'none'
  5460. });
  5461. anchor.css({
  5462. transform: 'translateY(' + -offsetY + 'px)',
  5463. transition: 'none'
  5464. });
  5465. backdrop.css({
  5466. 'background-color': fabColor
  5467. });
  5468. setTimeout(function () {
  5469. btn.css({
  5470. transform: '',
  5471. transition: 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'
  5472. });
  5473. anchor.css({
  5474. overflow: 'visible',
  5475. transform: '',
  5476. transition: 'transform .2s'
  5477. });
  5478. setTimeout(function () {
  5479. btn.css({
  5480. overflow: 'hidden',
  5481. 'background-color': fabColor
  5482. });
  5483. backdrop.css({
  5484. transform: 'scale(' + scaleFactor + ')',
  5485. transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
  5486. });
  5487. menu.find('> li > a').css({
  5488. opacity: 1
  5489. });
  5490. // Scroll to close.
  5491. $(window).on('scroll.fabToolbarClose', function () {
  5492. toolbarToFAB(btn);
  5493. $(window).off('scroll.fabToolbarClose');
  5494. $(document).off('click.fabToolbarClose');
  5495. });
  5496. $(document).on('click.fabToolbarClose', function (e) {
  5497. if (!$(e.target).closest(menu).length) {
  5498. toolbarToFAB(btn);
  5499. $(window).off('scroll.fabToolbarClose');
  5500. $(document).off('click.fabToolbarClose');
  5501. }
  5502. });
  5503. }, 100);
  5504. }, 0);
  5505. };
  5506. /**
  5507. * Transform toolbar back into FAB
  5508. * @param {Object} object jQuery object
  5509. */
  5510. var toolbarToFAB = function (btn) {
  5511. if (btn.attr('data-open') !== "true") {
  5512. return;
  5513. }
  5514. var offsetX, offsetY, scaleFactor;
  5515. var windowWidth = window.innerWidth;
  5516. var windowHeight = window.innerHeight;
  5517. var btnWidth = btn.attr('data-origin-width');
  5518. var btnBottom = btn.attr('data-origin-bottom');
  5519. var btnLeft = btn.attr('data-origin-left');
  5520. var anchor = btn.find('> .btn-floating').first();
  5521. var menu = btn.find('> ul').first();
  5522. var backdrop = btn.find('.fab-backdrop');
  5523. var fabColor = anchor.css('background-color');
  5524. offsetX = btnLeft - windowWidth / 2 + btnWidth / 2;
  5525. offsetY = windowHeight - btnBottom;
  5526. scaleFactor = windowWidth / backdrop.width();
  5527. // Hide backdrop
  5528. btn.removeClass('active');
  5529. btn.attr('data-open', false);
  5530. btn.css({
  5531. 'background-color': 'transparent',
  5532. transition: 'none'
  5533. });
  5534. anchor.css({
  5535. transition: 'none'
  5536. });
  5537. backdrop.css({
  5538. transform: 'scale(0)',
  5539. 'background-color': fabColor
  5540. });
  5541. menu.find('> li > a').css({
  5542. opacity: ''
  5543. });
  5544. setTimeout(function () {
  5545. backdrop.remove();
  5546. // Set initial state.
  5547. btn.css({
  5548. 'text-align': '',
  5549. width: '',
  5550. bottom: '',
  5551. left: '',
  5552. overflow: '',
  5553. 'background-color': '',
  5554. transform: 'translate3d(' + -offsetX + 'px,0,0)'
  5555. });
  5556. anchor.css({
  5557. overflow: '',
  5558. transform: 'translate3d(0,' + offsetY + 'px,0)'
  5559. });
  5560. setTimeout(function () {
  5561. btn.css({
  5562. transform: 'translate3d(0,0,0)',
  5563. transition: 'transform .2s'
  5564. });
  5565. anchor.css({
  5566. transform: 'translate3d(0,0,0)',
  5567. transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
  5568. });
  5569. }, 20);
  5570. }, 200);
  5571. };
  5572. })(jQuery);
  5573. ; (function ($) {
  5574. // Image transition function
  5575. Materialize.fadeInImage = function (selectorOrEl) {
  5576. var element;
  5577. if (typeof selectorOrEl === 'string') {
  5578. element = $(selectorOrEl);
  5579. } else if (typeof selectorOrEl === 'object') {
  5580. element = selectorOrEl;
  5581. } else {
  5582. return;
  5583. }
  5584. element.css({ opacity: 0 });
  5585. $(element).velocity({ opacity: 1 }, {
  5586. duration: 650,
  5587. queue: false,
  5588. easing: 'easeOutSine'
  5589. });
  5590. $(element).velocity({ opacity: 1 }, {
  5591. duration: 1300,
  5592. queue: false,
  5593. easing: 'swing',
  5594. step: function (now, fx) {
  5595. fx.start = 100;
  5596. var grayscale_setting = now / 100;
  5597. var brightness_setting = 150 - (100 - now) / 1.75;
  5598. if (brightness_setting < 100) {
  5599. brightness_setting = 100;
  5600. }
  5601. if (now >= 0) {
  5602. $(this).css({
  5603. "-webkit-filter": "grayscale(" + grayscale_setting + ")" + "brightness(" + brightness_setting + "%)",
  5604. "filter": "grayscale(" + grayscale_setting + ")" + "brightness(" + brightness_setting + "%)"
  5605. });
  5606. }
  5607. }
  5608. });
  5609. };
  5610. // Horizontal staggered list
  5611. Materialize.showStaggeredList = function (selectorOrEl) {
  5612. var element;
  5613. if (typeof selectorOrEl === 'string') {
  5614. element = $(selectorOrEl);
  5615. } else if (typeof selectorOrEl === 'object') {
  5616. element = selectorOrEl;
  5617. } else {
  5618. return;
  5619. }
  5620. var time = 0;
  5621. element.find('li').velocity({ translateX: "-100px" }, { duration: 0 });
  5622. element.find('li').each(function () {
  5623. $(this).velocity({ opacity: "1", translateX: "0" }, { duration: 800, delay: time, easing: [60, 10] });
  5624. time += 120;
  5625. });
  5626. };
  5627. $(document).ready(function () {
  5628. // Hardcoded .staggered-list scrollFire
  5629. // var staggeredListOptions = [];
  5630. // $('ul.staggered-list').each(function (i) {
  5631. // var label = 'scrollFire-' + i;
  5632. // $(this).addClass(label);
  5633. // staggeredListOptions.push(
  5634. // {selector: 'ul.staggered-list.' + label,
  5635. // offset: 200,
  5636. // callback: 'showStaggeredList("ul.staggered-list.' + label + '")'});
  5637. // });
  5638. // scrollFire(staggeredListOptions);
  5639. // HammerJS, Swipe navigation
  5640. // Touch Event
  5641. var swipeLeft = false;
  5642. var swipeRight = false;
  5643. // Dismissible Collections
  5644. $('.dismissable').each(function () {
  5645. $(this).hammer({
  5646. prevent_default: false
  5647. }).on('pan', function (e) {
  5648. if (e.gesture.pointerType === "touch") {
  5649. var $this = $(this);
  5650. var direction = e.gesture.direction;
  5651. var x = e.gesture.deltaX;
  5652. var velocityX = e.gesture.velocityX;
  5653. $this.velocity({
  5654. translateX: x
  5655. }, { duration: 50, queue: false, easing: 'easeOutQuad' });
  5656. // Swipe Left
  5657. if (direction === 4 && (x > $this.innerWidth() / 2 || velocityX < -0.75)) {
  5658. swipeLeft = true;
  5659. }
  5660. // Swipe Right
  5661. if (direction === 2 && (x < -1 * $this.innerWidth() / 2 || velocityX > 0.75)) {
  5662. swipeRight = true;
  5663. }
  5664. }
  5665. }).on('panend', function (e) {
  5666. // Reset if collection is moved back into original position
  5667. if (Math.abs(e.gesture.deltaX) < $(this).innerWidth() / 2) {
  5668. swipeRight = false;
  5669. swipeLeft = false;
  5670. }
  5671. if (e.gesture.pointerType === "touch") {
  5672. var $this = $(this);
  5673. if (swipeLeft || swipeRight) {
  5674. var fullWidth;
  5675. if (swipeLeft) {
  5676. fullWidth = $this.innerWidth();
  5677. } else {
  5678. fullWidth = -1 * $this.innerWidth();
  5679. }
  5680. $this.velocity({
  5681. translateX: fullWidth
  5682. }, {
  5683. duration: 100, queue: false, easing: 'easeOutQuad', complete: function () {
  5684. $this.css('border', 'none');
  5685. $this.velocity({
  5686. height: 0, padding: 0
  5687. }, {
  5688. duration: 200, queue: false, easing: 'easeOutQuad', complete: function () {
  5689. $this.remove();
  5690. }
  5691. });
  5692. }
  5693. });
  5694. } else {
  5695. $this.velocity({
  5696. translateX: 0
  5697. }, { duration: 100, queue: false, easing: 'easeOutQuad' });
  5698. }
  5699. swipeLeft = false;
  5700. swipeRight = false;
  5701. }
  5702. });
  5703. });
  5704. // time = 0
  5705. // // Vertical Staggered list
  5706. // $('ul.staggered-list.vertical li').velocity(
  5707. // { translateY: "100px"},
  5708. // { duration: 0 });
  5709. // $('ul.staggered-list.vertical li').each(function() {
  5710. // $(this).velocity(
  5711. // { opacity: "1", translateY: "0"},
  5712. // { duration: 800, delay: time, easing: [60, 25] });
  5713. // time += 120;
  5714. // });
  5715. // // Fade in and Scale
  5716. // $('.fade-in.scale').velocity(
  5717. // { scaleX: .4, scaleY: .4, translateX: -600},
  5718. // { duration: 0});
  5719. // $('.fade-in').each(function() {
  5720. // $(this).velocity(
  5721. // { opacity: "1", scaleX: 1, scaleY: 1, translateX: 0},
  5722. // { duration: 800, easing: [60, 10] });
  5723. // });
  5724. });
  5725. })(jQuery);
  5726. ; (function ($) {
  5727. var scrollFireEventsHandled = false;
  5728. // Input: Array of JSON objects {selector, offset, callback}
  5729. Materialize.scrollFire = function (options) {
  5730. var onScroll = function () {
  5731. var windowScroll = window.pageYOffset + window.innerHeight;
  5732. for (var i = 0; i < options.length; i++) {
  5733. // Get options from each line
  5734. var value = options[i];
  5735. var selector = value.selector,
  5736. offset = value.offset,
  5737. callback = value.callback;
  5738. var currentElement = document.querySelector(selector);
  5739. if (currentElement !== null) {
  5740. var elementOffset = currentElement.getBoundingClientRect().top + window.pageYOffset;
  5741. if (windowScroll > elementOffset + offset) {
  5742. if (value.done !== true) {
  5743. if (typeof callback === 'function') {
  5744. callback.call(this, currentElement);
  5745. } else if (typeof callback === 'string') {
  5746. var callbackFunc = new Function(callback);
  5747. callbackFunc(currentElement);
  5748. }
  5749. value.done = true;
  5750. }
  5751. }
  5752. }
  5753. }
  5754. };
  5755. var throttledScroll = Materialize.throttle(function () {
  5756. onScroll();
  5757. }, options.throttle || 100);
  5758. if (!scrollFireEventsHandled) {
  5759. window.addEventListener("scroll", throttledScroll);
  5760. window.addEventListener("resize", throttledScroll);
  5761. scrollFireEventsHandled = true;
  5762. }
  5763. // perform a scan once, after current execution context, and after dom is ready
  5764. setTimeout(throttledScroll, 0);
  5765. };
  5766. })(jQuery);
  5767. ; /*!
  5768. * pickadate.js v3.5.0, 2014/04/13
  5769. * By Amsul, http://amsul.ca
  5770. * Hosted on http://amsul.github.io/pickadate.js
  5771. * Licensed under MIT
  5772. */
  5773. (function (factory) {
  5774. Materialize.Picker = factory(jQuery);
  5775. })(function ($) {
  5776. var $window = $(window);
  5777. var $document = $(document);
  5778. var $html = $(document.documentElement);
  5779. /**
  5780. * The picker constructor that creates a blank picker.
  5781. */
  5782. function PickerConstructor(ELEMENT, NAME, COMPONENT, OPTIONS) {
  5783. // If there’s no element, return the picker constructor.
  5784. if (!ELEMENT) return PickerConstructor;
  5785. var IS_DEFAULT_THEME = false,
  5786. // The state of the picker.
  5787. STATE = {
  5788. id: ELEMENT.id || 'P' + Math.abs(~~(Math.random() * new Date()))
  5789. },
  5790. // Merge the defaults and options passed.
  5791. SETTINGS = COMPONENT ? $.extend(true, {}, COMPONENT.defaults, OPTIONS) : OPTIONS || {},
  5792. // Merge the default classes with the settings classes.
  5793. CLASSES = $.extend({}, PickerConstructor.klasses(), SETTINGS.klass),
  5794. // The element node wrapper into a jQuery object.
  5795. $ELEMENT = $(ELEMENT),
  5796. // Pseudo picker constructor.
  5797. PickerInstance = function () {
  5798. return this.start();
  5799. },
  5800. // The picker prototype.
  5801. P = PickerInstance.prototype = {
  5802. constructor: PickerInstance,
  5803. $node: $ELEMENT,
  5804. /**
  5805. * Initialize everything
  5806. */
  5807. start: function () {
  5808. // If it’s already started, do nothing.
  5809. if (STATE && STATE.start) return P;
  5810. // Update the picker states.
  5811. STATE.methods = {};
  5812. STATE.start = true;
  5813. STATE.open = false;
  5814. STATE.type = ELEMENT.type;
  5815. // Confirm focus state, convert into text input to remove UA stylings,
  5816. // and set as readonly to prevent keyboard popup.
  5817. ELEMENT.autofocus = ELEMENT == getActiveElement();
  5818. ELEMENT.readOnly = !SETTINGS.editable;
  5819. ELEMENT.id = ELEMENT.id || STATE.id;
  5820. if (ELEMENT.type != 'text') {
  5821. ELEMENT.type = 'text';
  5822. }
  5823. // Create a new picker component with the settings.
  5824. P.component = new COMPONENT(P, SETTINGS);
  5825. // Create the picker root with a holder and then prepare it.
  5826. P.$root = $(PickerConstructor._.node('div', createWrappedComponent(), CLASSES.picker, 'id="' + ELEMENT.id + '_root" tabindex="0"'));
  5827. prepareElementRoot();
  5828. // If there’s a format for the hidden input element, create the element.
  5829. if (SETTINGS.formatSubmit) {
  5830. prepareElementHidden();
  5831. }
  5832. // Prepare the input element.
  5833. prepareElement();
  5834. // Insert the root as specified in the settings.
  5835. if (SETTINGS.container) $(SETTINGS.container).append(P.$root); else $ELEMENT.before(P.$root);
  5836. // Bind the default component and settings events.
  5837. P.on({
  5838. start: P.component.onStart,
  5839. render: P.component.onRender,
  5840. stop: P.component.onStop,
  5841. open: P.component.onOpen,
  5842. close: P.component.onClose,
  5843. set: P.component.onSet
  5844. }).on({
  5845. start: SETTINGS.onStart,
  5846. render: SETTINGS.onRender,
  5847. stop: SETTINGS.onStop,
  5848. open: SETTINGS.onOpen,
  5849. close: SETTINGS.onClose,
  5850. set: SETTINGS.onSet
  5851. });
  5852. // Once we’re all set, check the theme in use.
  5853. IS_DEFAULT_THEME = isUsingDefaultTheme(P.$root.children()[0]);
  5854. // If the element has autofocus, open the picker.
  5855. if (ELEMENT.autofocus) {
  5856. P.open();
  5857. }
  5858. // Trigger queued the “start” and “render” events.
  5859. return P.trigger('start').trigger('render');
  5860. }, //start
  5861. /**
  5862. * Render a new picker
  5863. */
  5864. render: function (entireComponent) {
  5865. // Insert a new component holder in the root or box.
  5866. if (entireComponent) P.$root.html(createWrappedComponent()); else P.$root.find('.' + CLASSES.box).html(P.component.nodes(STATE.open));
  5867. // Trigger the queued “render” events.
  5868. return P.trigger('render');
  5869. }, //render
  5870. /**
  5871. * Destroy everything
  5872. */
  5873. stop: function () {
  5874. // If it’s already stopped, do nothing.
  5875. if (!STATE.start) return P;
  5876. // Then close the picker.
  5877. P.close();
  5878. // Remove the hidden field.
  5879. if (P._hidden) {
  5880. P._hidden.parentNode.removeChild(P._hidden);
  5881. }
  5882. // Remove the root.
  5883. P.$root.remove();
  5884. // Remove the input class, remove the stored data, and unbind
  5885. // the events (after a tick for IE - see `P.close`).
  5886. $ELEMENT.removeClass(CLASSES.input).removeData(NAME);
  5887. setTimeout(function () {
  5888. $ELEMENT.off('.' + STATE.id);
  5889. }, 0);
  5890. // Restore the element state
  5891. ELEMENT.type = STATE.type;
  5892. ELEMENT.readOnly = false;
  5893. // Trigger the queued “stop” events.
  5894. P.trigger('stop');
  5895. // Reset the picker states.
  5896. STATE.methods = {};
  5897. STATE.start = false;
  5898. return P;
  5899. }, //stop
  5900. /**
  5901. * Open up the picker
  5902. */
  5903. open: function (dontGiveFocus) {
  5904. // If it’s already open, do nothing.
  5905. if (STATE.open) return P;
  5906. // Add the “active” class.
  5907. $ELEMENT.addClass(CLASSES.active);
  5908. aria(ELEMENT, 'expanded', true);
  5909. // * A Firefox bug, when `html` has `overflow:hidden`, results in
  5910. // killing transitions :(. So add the “opened” state on the next tick.
  5911. // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
  5912. setTimeout(function () {
  5913. // Add the “opened” class to the picker root.
  5914. P.$root.addClass(CLASSES.opened);
  5915. aria(P.$root[0], 'hidden', false);
  5916. }, 0);
  5917. // If we have to give focus, bind the element and doc events.
  5918. if (dontGiveFocus !== false) {
  5919. // Set it as open.
  5920. STATE.open = true;
  5921. // Prevent the page from scrolling.
  5922. if (IS_DEFAULT_THEME) {
  5923. $html.css('overflow', 'hidden').css('padding-right', '+=' + getScrollbarWidth());
  5924. }
  5925. // Pass focus to the root element’s jQuery object.
  5926. // * Workaround for iOS8 to bring the picker’s root into view.
  5927. P.$root.eq(0).focus();
  5928. // Bind the document events.
  5929. $document.on('click.' + STATE.id + ' focusin.' + STATE.id, function (event) {
  5930. var target = event.target;
  5931. // If the target of the event is not the element, close the picker picker.
  5932. // * Don’t worry about clicks or focusins on the root because those don’t bubble up.
  5933. // Also, for Firefox, a click on an `option` element bubbles up directly
  5934. // to the doc. So make sure the target wasn't the doc.
  5935. // * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling,
  5936. // which causes the picker to unexpectedly close when right-clicking it. So make
  5937. // sure the event wasn’t a right-click.
  5938. if (target != ELEMENT && target != document && event.which != 3) {
  5939. // If the target was the holder that covers the screen,
  5940. // keep the element focused to maintain tabindex.
  5941. P.close(target === P.$root.children()[0]);
  5942. }
  5943. }).on('keydown.' + STATE.id, function (event) {
  5944. var
  5945. // Get the keycode.
  5946. keycode = event.keyCode,
  5947. // Translate that to a selection change.
  5948. keycodeToMove = P.component.key[keycode],
  5949. // Grab the target.
  5950. target = event.target;
  5951. // On escape, close the picker and give focus.
  5952. if (keycode == 27) {
  5953. P.close(true);
  5954. }
  5955. // Check if there is a key movement or “enter” keypress on the element.
  5956. else if (target == P.$root[0] && (keycodeToMove || keycode == 13)) {
  5957. // Prevent the default action to stop page movement.
  5958. event.preventDefault();
  5959. // Trigger the key movement action.
  5960. if (keycodeToMove) {
  5961. PickerConstructor._.trigger(P.component.key.go, P, [PickerConstructor._.trigger(keycodeToMove)]);
  5962. }
  5963. // On “enter”, if the highlighted item isn’t disabled, set the value and close.
  5964. else if (!P.$root.find('.' + CLASSES.highlighted).hasClass(CLASSES.disabled)) {
  5965. P.set('select', P.component.item.highlight);
  5966. if (SETTINGS.closeOnSelect) {
  5967. P.close(true);
  5968. }
  5969. }
  5970. }
  5971. // If the target is within the root and “enter” is pressed,
  5972. // prevent the default action and trigger a click on the target instead.
  5973. else if ($.contains(P.$root[0], target) && keycode == 13) {
  5974. event.preventDefault();
  5975. target.click();
  5976. }
  5977. });
  5978. }
  5979. // Trigger the queued “open” events.
  5980. return P.trigger('open');
  5981. }, //open
  5982. /**
  5983. * Close the picker
  5984. */
  5985. close: function (giveFocus) {
  5986. // If we need to give focus, do it before changing states.
  5987. if (giveFocus) {
  5988. // ....ah yes! It would’ve been incomplete without a crazy workaround for IE :|
  5989. // The focus is triggered *after* the close has completed - causing it
  5990. // to open again. So unbind and rebind the event at the next tick.
  5991. P.$root.off('focus.toOpen').eq(0).focus();
  5992. setTimeout(function () {
  5993. P.$root.on('focus.toOpen', handleFocusToOpenEvent);
  5994. }, 0);
  5995. }
  5996. // Remove the “active” class.
  5997. $ELEMENT.removeClass(CLASSES.active);
  5998. aria(ELEMENT, 'expanded', false);
  5999. // * A Firefox bug, when `html` has `overflow:hidden`, results in
  6000. // killing transitions :(. So remove the “opened” state on the next tick.
  6001. // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
  6002. setTimeout(function () {
  6003. // Remove the “opened” and “focused” class from the picker root.
  6004. P.$root.removeClass(CLASSES.opened + ' ' + CLASSES.focused);
  6005. aria(P.$root[0], 'hidden', true);
  6006. }, 0);
  6007. // If it’s already closed, do nothing more.
  6008. if (!STATE.open) return P;
  6009. // Set it as closed.
  6010. STATE.open = false;
  6011. // Allow the page to scroll.
  6012. if (IS_DEFAULT_THEME) {
  6013. $html.css('overflow', '').css('padding-right', '-=' + getScrollbarWidth());
  6014. }
  6015. // Unbind the document events.
  6016. $document.off('.' + STATE.id);
  6017. // Trigger the queued “close” events.
  6018. return P.trigger('close');
  6019. }, //close
  6020. /**
  6021. * Clear the values
  6022. */
  6023. clear: function (options) {
  6024. return P.set('clear', null, options);
  6025. }, //clear
  6026. /**
  6027. * Set something
  6028. */
  6029. set: function (thing, value, options) {
  6030. var thingItem,
  6031. thingValue,
  6032. thingIsObject = $.isPlainObject(thing),
  6033. thingObject = thingIsObject ? thing : {};
  6034. // Make sure we have usable options.
  6035. options = thingIsObject && $.isPlainObject(value) ? value : options || {};
  6036. if (thing) {
  6037. // If the thing isn’t an object, make it one.
  6038. if (!thingIsObject) {
  6039. thingObject[thing] = value;
  6040. }
  6041. // Go through the things of items to set.
  6042. for (thingItem in thingObject) {
  6043. // Grab the value of the thing.
  6044. thingValue = thingObject[thingItem];
  6045. // First, if the item exists and there’s a value, set it.
  6046. if (thingItem in P.component.item) {
  6047. if (thingValue === undefined) thingValue = null;
  6048. P.component.set(thingItem, thingValue, options);
  6049. }
  6050. // Then, check to update the element value and broadcast a change.
  6051. if (thingItem == 'select' || thingItem == 'clear') {
  6052. $ELEMENT.val(thingItem == 'clear' ? '' : P.get(thingItem, SETTINGS.format)).trigger('change');
  6053. }
  6054. }
  6055. // Render a new picker.
  6056. P.render();
  6057. }
  6058. // When the method isn’t muted, trigger queued “set” events and pass the `thingObject`.
  6059. return options.muted ? P : P.trigger('set', thingObject);
  6060. }, //set
  6061. /**
  6062. * Get something
  6063. */
  6064. get: function (thing, format) {
  6065. // Make sure there’s something to get.
  6066. thing = thing || 'value';
  6067. // If a picker state exists, return that.
  6068. if (STATE[thing] != null) {
  6069. return STATE[thing];
  6070. }
  6071. // Return the submission value, if that.
  6072. if (thing == 'valueSubmit') {
  6073. if (P._hidden) {
  6074. return P._hidden.value;
  6075. }
  6076. thing = 'value';
  6077. }
  6078. // Return the value, if that.
  6079. if (thing == 'value') {
  6080. return ELEMENT.value;
  6081. }
  6082. // Check if a component item exists, return that.
  6083. if (thing in P.component.item) {
  6084. if (typeof format == 'string') {
  6085. var thingValue = P.component.get(thing);
  6086. return thingValue ? PickerConstructor._.trigger(P.component.formats.toString, P.component, [format, thingValue]) : '';
  6087. }
  6088. return P.component.get(thing);
  6089. }
  6090. }, //get
  6091. /**
  6092. * Bind events on the things.
  6093. */
  6094. on: function (thing, method, internal) {
  6095. var thingName,
  6096. thingMethod,
  6097. thingIsObject = $.isPlainObject(thing),
  6098. thingObject = thingIsObject ? thing : {};
  6099. if (thing) {
  6100. // If the thing isn’t an object, make it one.
  6101. if (!thingIsObject) {
  6102. thingObject[thing] = method;
  6103. }
  6104. // Go through the things to bind to.
  6105. for (thingName in thingObject) {
  6106. // Grab the method of the thing.
  6107. thingMethod = thingObject[thingName];
  6108. // If it was an internal binding, prefix it.
  6109. if (internal) {
  6110. thingName = '_' + thingName;
  6111. }
  6112. // Make sure the thing methods collection exists.
  6113. STATE.methods[thingName] = STATE.methods[thingName] || [];
  6114. // Add the method to the relative method collection.
  6115. STATE.methods[thingName].push(thingMethod);
  6116. }
  6117. }
  6118. return P;
  6119. }, //on
  6120. /**
  6121. * Unbind events on the things.
  6122. */
  6123. off: function () {
  6124. var i,
  6125. thingName,
  6126. names = arguments;
  6127. for (i = 0, namesCount = names.length; i < namesCount; i += 1) {
  6128. thingName = names[i];
  6129. if (thingName in STATE.methods) {
  6130. delete STATE.methods[thingName];
  6131. }
  6132. }
  6133. return P;
  6134. },
  6135. /**
  6136. * Fire off method events.
  6137. */
  6138. trigger: function (name, data) {
  6139. var _trigger = function (name) {
  6140. var methodList = STATE.methods[name];
  6141. if (methodList) {
  6142. methodList.map(function (method) {
  6143. PickerConstructor._.trigger(method, P, [data]);
  6144. });
  6145. }
  6146. };
  6147. _trigger('_' + name);
  6148. _trigger(name);
  6149. return P;
  6150. } //trigger
  6151. //PickerInstance.prototype
  6152. /**
  6153. * Wrap the picker holder components together.
  6154. */
  6155. }; function createWrappedComponent() {
  6156. // Create a picker wrapper holder
  6157. return PickerConstructor._.node('div',
  6158. // Create a picker wrapper node
  6159. PickerConstructor._.node('div',
  6160. // Create a picker frame
  6161. PickerConstructor._.node('div',
  6162. // Create a picker box node
  6163. PickerConstructor._.node('div',
  6164. // Create the components nodes.
  6165. P.component.nodes(STATE.open),
  6166. // The picker box class
  6167. CLASSES.box),
  6168. // Picker wrap class
  6169. CLASSES.wrap),
  6170. // Picker frame class
  6171. CLASSES.frame),
  6172. // Picker holder class
  6173. CLASSES.holder); //endreturn
  6174. } //createWrappedComponent
  6175. /**
  6176. * Prepare the input element with all bindings.
  6177. */
  6178. function prepareElement() {
  6179. $ELEMENT.
  6180. // Store the picker data by component name.
  6181. data(NAME, P).
  6182. // Add the “input” class name.
  6183. addClass(CLASSES.input).
  6184. // Remove the tabindex.
  6185. attr('tabindex', -1).
  6186. // If there’s a `data-value`, update the value of the element.
  6187. val($ELEMENT.data('value') ? P.get('select', SETTINGS.format) : ELEMENT.value);
  6188. // Only bind keydown events if the element isn’t editable.
  6189. if (!SETTINGS.editable) {
  6190. $ELEMENT.
  6191. // On focus/click, focus onto the root to open it up.
  6192. on('focus.' + STATE.id + ' click.' + STATE.id, function (event) {
  6193. event.preventDefault();
  6194. P.$root.eq(0).focus();
  6195. }).
  6196. // Handle keyboard event based on the picker being opened or not.
  6197. on('keydown.' + STATE.id, handleKeydownEvent);
  6198. }
  6199. // Update the aria attributes.
  6200. aria(ELEMENT, {
  6201. haspopup: true,
  6202. expanded: false,
  6203. readonly: false,
  6204. owns: ELEMENT.id + '_root'
  6205. });
  6206. }
  6207. /**
  6208. * Prepare the root picker element with all bindings.
  6209. */
  6210. function prepareElementRoot() {
  6211. P.$root.on({
  6212. // For iOS8.
  6213. keydown: handleKeydownEvent,
  6214. // When something within the root is focused, stop from bubbling
  6215. // to the doc and remove the “focused” state from the root.
  6216. focusin: function (event) {
  6217. P.$root.removeClass(CLASSES.focused);
  6218. event.stopPropagation();
  6219. },
  6220. // When something within the root holder is clicked, stop it
  6221. // from bubbling to the doc.
  6222. 'mousedown click': function (event) {
  6223. var target = event.target;
  6224. // Make sure the target isn’t the root holder so it can bubble up.
  6225. if (target != P.$root.children()[0]) {
  6226. event.stopPropagation();
  6227. // * For mousedown events, cancel the default action in order to
  6228. // prevent cases where focus is shifted onto external elements
  6229. // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120).
  6230. // Also, for Firefox, don’t prevent action on the `option` element.
  6231. if (event.type == 'mousedown' && !$(target).is('input, select, textarea, button, option')) {
  6232. event.preventDefault();
  6233. // Re-focus onto the root so that users can click away
  6234. // from elements focused within the picker.
  6235. P.$root.eq(0).focus();
  6236. }
  6237. }
  6238. }
  6239. }).
  6240. // Add/remove the “target” class on focus and blur.
  6241. on({
  6242. focus: function () {
  6243. $ELEMENT.addClass(CLASSES.target);
  6244. },
  6245. blur: function () {
  6246. $ELEMENT.removeClass(CLASSES.target);
  6247. }
  6248. }).
  6249. // Open the picker and adjust the root “focused” state
  6250. on('focus.toOpen', handleFocusToOpenEvent).
  6251. // If there’s a click on an actionable element, carry out the actions.
  6252. on('click', '[data-pick], [data-nav], [data-clear], [data-close]', function () {
  6253. var $target = $(this),
  6254. targetData = $target.data(),
  6255. targetDisabled = $target.hasClass(CLASSES.navDisabled) || $target.hasClass(CLASSES.disabled),
  6256. // * For IE, non-focusable elements can be active elements as well
  6257. // (http://stackoverflow.com/a/2684561).
  6258. activeElement = getActiveElement();
  6259. activeElement = activeElement && (activeElement.type || activeElement.href) && activeElement;
  6260. // If it’s disabled or nothing inside is actively focused, re-focus the element.
  6261. if (targetDisabled || activeElement && !$.contains(P.$root[0], activeElement)) {
  6262. P.$root.eq(0).focus();
  6263. }
  6264. // If something is superficially changed, update the `highlight` based on the `nav`.
  6265. if (!targetDisabled && targetData.nav) {
  6266. P.set('highlight', P.component.item.highlight, { nav: targetData.nav });
  6267. }
  6268. // If something is picked, set `select` then close with focus.
  6269. else if (!targetDisabled && 'pick' in targetData) {
  6270. P.set('select', targetData.pick);
  6271. if (SETTINGS.closeOnSelect) {
  6272. P.close(true);
  6273. }
  6274. }
  6275. // If a “clear” button is pressed, empty the values and close with focus.
  6276. else if (targetData.clear) {
  6277. P.clear();
  6278. if (SETTINGS.closeOnSelect) {
  6279. P.close(true);
  6280. }
  6281. } else if (targetData.close) {
  6282. P.close(true);
  6283. }
  6284. }); //P.$root
  6285. aria(P.$root[0], 'hidden', true);
  6286. }
  6287. /**
  6288. * Prepare the hidden input element along with all bindings.
  6289. */
  6290. function prepareElementHidden() {
  6291. var name;
  6292. if (SETTINGS.hiddenName === true) {
  6293. name = ELEMENT.name;
  6294. ELEMENT.name = '';
  6295. } else {
  6296. name = [typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '', typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit'];
  6297. name = name[0] + ELEMENT.name + name[1];
  6298. }
  6299. P._hidden = $('<input ' + 'type=hidden ' +
  6300. // Create the name using the original input’s with a prefix and suffix.
  6301. 'name="' + name + '"' + (
  6302. // If the element has a value, set the hidden value as well.
  6303. $ELEMENT.data('value') || ELEMENT.value ? ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' : '') + '>')[0];
  6304. $ELEMENT.
  6305. // If the value changes, update the hidden input with the correct format.
  6306. on('change.' + STATE.id, function () {
  6307. P._hidden.value = ELEMENT.value ? P.get('select', SETTINGS.formatSubmit) : '';
  6308. });
  6309. // Insert the hidden input as specified in the settings.
  6310. if (SETTINGS.container) $(SETTINGS.container).append(P._hidden); else $ELEMENT.before(P._hidden);
  6311. }
  6312. // For iOS8.
  6313. function handleKeydownEvent(event) {
  6314. var keycode = event.keyCode,
  6315. // Check if one of the delete keys was pressed.
  6316. isKeycodeDelete = /^(8|46)$/.test(keycode);
  6317. // For some reason IE clears the input value on “escape”.
  6318. if (keycode == 27) {
  6319. P.close();
  6320. return false;
  6321. }
  6322. // Check if `space` or `delete` was pressed or the picker is closed with a key movement.
  6323. if (keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode]) {
  6324. // Prevent it from moving the page and bubbling to doc.
  6325. event.preventDefault();
  6326. event.stopPropagation();
  6327. // If `delete` was pressed, clear the values and close the picker.
  6328. // Otherwise open the picker.
  6329. if (isKeycodeDelete) {
  6330. P.clear().close();
  6331. } else {
  6332. P.open();
  6333. }
  6334. }
  6335. }
  6336. // Separated for IE
  6337. function handleFocusToOpenEvent(event) {
  6338. // Stop the event from propagating to the doc.
  6339. event.stopPropagation();
  6340. // If it’s a focus event, add the “focused” class to the root.
  6341. if (event.type == 'focus') {
  6342. P.$root.addClass(CLASSES.focused);
  6343. }
  6344. // And then finally open the picker.
  6345. P.open();
  6346. }
  6347. // Return a new picker instance.
  6348. return new PickerInstance();
  6349. } //PickerConstructor
  6350. /**
  6351. * The default classes and prefix to use for the HTML classes.
  6352. */
  6353. PickerConstructor.klasses = function (prefix) {
  6354. prefix = prefix || 'picker';
  6355. return {
  6356. picker: prefix,
  6357. opened: prefix + '--opened',
  6358. focused: prefix + '--focused',
  6359. input: prefix + '__input',
  6360. active: prefix + '__input--active',
  6361. target: prefix + '__input--target',
  6362. holder: prefix + '__holder',
  6363. frame: prefix + '__frame',
  6364. wrap: prefix + '__wrap',
  6365. box: prefix + '__box'
  6366. };
  6367. }; //PickerConstructor.klasses
  6368. /**
  6369. * Check if the default theme is being used.
  6370. */
  6371. function isUsingDefaultTheme(element) {
  6372. var theme,
  6373. prop = 'position';
  6374. // For IE.
  6375. if (element.currentStyle) {
  6376. theme = element.currentStyle[prop];
  6377. }
  6378. // For normal browsers.
  6379. else if (window.getComputedStyle) {
  6380. theme = getComputedStyle(element)[prop];
  6381. }
  6382. return theme == 'fixed';
  6383. }
  6384. /**
  6385. * Get the width of the browser’s scrollbar.
  6386. * Taken from: https://github.com/VodkaBears/Remodal/blob/master/src/jquery.remodal.js
  6387. */
  6388. function getScrollbarWidth() {
  6389. if ($html.height() <= $window.height()) {
  6390. return 0;
  6391. }
  6392. var $outer = $('<div style="visibility:hidden;width:100px" />').appendTo('body');
  6393. // Get the width without scrollbars.
  6394. var widthWithoutScroll = $outer[0].offsetWidth;
  6395. // Force adding scrollbars.
  6396. $outer.css('overflow', 'scroll');
  6397. // Add the inner div.
  6398. var $inner = $('<div style="width:100%" />').appendTo($outer);
  6399. // Get the width with scrollbars.
  6400. var widthWithScroll = $inner[0].offsetWidth;
  6401. // Remove the divs.
  6402. $outer.remove();
  6403. // Return the difference between the widths.
  6404. return widthWithoutScroll - widthWithScroll;
  6405. }
  6406. /**
  6407. * PickerConstructor helper methods.
  6408. */
  6409. PickerConstructor._ = {
  6410. /**
  6411. * Create a group of nodes. Expects:
  6412. * `
  6413. {
  6414. min: {Integer},
  6415. max: {Integer},
  6416. i: {Integer},
  6417. node: {String},
  6418. item: {Function}
  6419. }
  6420. * `
  6421. */
  6422. group: function (groupObject) {
  6423. var
  6424. // Scope for the looped object
  6425. loopObjectScope,
  6426. // Create the nodes list
  6427. nodesList = '',
  6428. // The counter starts from the `min`
  6429. counter = PickerConstructor._.trigger(groupObject.min, groupObject);
  6430. // Loop from the `min` to `max`, incrementing by `i`
  6431. for (; counter <= PickerConstructor._.trigger(groupObject.max, groupObject, [counter]); counter += groupObject.i) {
  6432. // Trigger the `item` function within scope of the object
  6433. loopObjectScope = PickerConstructor._.trigger(groupObject.item, groupObject, [counter]);
  6434. // Splice the subgroup and create nodes out of the sub nodes
  6435. nodesList += PickerConstructor._.node(groupObject.node, loopObjectScope[0], // the node
  6436. loopObjectScope[1], // the classes
  6437. loopObjectScope[2] // the attributes
  6438. );
  6439. }
  6440. // Return the list of nodes
  6441. return nodesList;
  6442. }, //group
  6443. /**
  6444. * Create a dom node string
  6445. */
  6446. node: function (wrapper, item, klass, attribute) {
  6447. // If the item is false-y, just return an empty string
  6448. if (!item) return '';
  6449. // If the item is an array, do a join
  6450. item = $.isArray(item) ? item.join('') : item;
  6451. // Check for the class
  6452. klass = klass ? ' class="' + klass + '"' : '';
  6453. // Check for any attributes
  6454. attribute = attribute ? ' ' + attribute : '';
  6455. // Return the wrapped item
  6456. return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>';
  6457. }, //node
  6458. /**
  6459. * Lead numbers below 10 with a zero.
  6460. */
  6461. lead: function (number) {
  6462. return (number < 10 ? '0' : '') + number;
  6463. },
  6464. /**
  6465. * Trigger a function otherwise return the value.
  6466. */
  6467. trigger: function (callback, scope, args) {
  6468. return typeof callback == 'function' ? callback.apply(scope, args || []) : callback;
  6469. },
  6470. /**
  6471. * If the second character is a digit, length is 2 otherwise 1.
  6472. */
  6473. digits: function (string) {
  6474. return (/\d/.test(string[1]) ? 2 : 1
  6475. );
  6476. },
  6477. /**
  6478. * Tell if something is a date object.
  6479. */
  6480. isDate: function (value) {
  6481. return {}.toString.call(value).indexOf('Date') > -1 && this.isInteger(value.getDate());
  6482. },
  6483. /**
  6484. * Tell if something is an integer.
  6485. */
  6486. isInteger: function (value) {
  6487. return {}.toString.call(value).indexOf('Number') > -1 && value % 1 === 0;
  6488. },
  6489. /**
  6490. * Create ARIA attribute strings.
  6491. */
  6492. ariaAttr: ariaAttr //PickerConstructor._
  6493. /**
  6494. * Extend the picker with a component and defaults.
  6495. */
  6496. }; PickerConstructor.extend = function (name, Component) {
  6497. // Extend jQuery.
  6498. $.fn[name] = function (options, action) {
  6499. // Grab the component data.
  6500. var componentData = this.data(name);
  6501. // If the picker is requested, return the data object.
  6502. if (options == 'picker') {
  6503. return componentData;
  6504. }
  6505. // If the component data exists and `options` is a string, carry out the action.
  6506. if (componentData && typeof options == 'string') {
  6507. return PickerConstructor._.trigger(componentData[options], componentData, [action]);
  6508. }
  6509. // Otherwise go through each matched element and if the component
  6510. // doesn’t exist, create a new picker using `this` element
  6511. // and merging the defaults and options with a deep copy.
  6512. return this.each(function () {
  6513. var $this = $(this);
  6514. if (!$this.data(name)) {
  6515. new PickerConstructor(this, name, Component, options);
  6516. }
  6517. });
  6518. };
  6519. // Set the defaults.
  6520. $.fn[name].defaults = Component.defaults;
  6521. }; //PickerConstructor.extend
  6522. function aria(element, attribute, value) {
  6523. if ($.isPlainObject(attribute)) {
  6524. for (var key in attribute) {
  6525. ariaSet(element, key, attribute[key]);
  6526. }
  6527. } else {
  6528. ariaSet(element, attribute, value);
  6529. }
  6530. }
  6531. function ariaSet(element, attribute, value) {
  6532. element.setAttribute((attribute == 'role' ? '' : 'aria-') + attribute, value);
  6533. }
  6534. function ariaAttr(attribute, data) {
  6535. if (!$.isPlainObject(attribute)) {
  6536. attribute = { attribute: data };
  6537. }
  6538. data = '';
  6539. for (var key in attribute) {
  6540. var attr = (key == 'role' ? '' : 'aria-') + key,
  6541. attrVal = attribute[key];
  6542. data += attrVal == null ? '' : attr + '="' + attribute[key] + '"';
  6543. }
  6544. return data;
  6545. }
  6546. // IE8 bug throws an error for activeElements within iframes.
  6547. function getActiveElement() {
  6548. try {
  6549. return document.activeElement;
  6550. } catch (err) { }
  6551. }
  6552. // Expose the picker constructor.
  6553. return PickerConstructor;
  6554. });
  6555. ; /*!
  6556. * Date picker for pickadate.js v3.5.0
  6557. * http://amsul.github.io/pickadate.js/date.htm
  6558. */
  6559. (function (factory) {
  6560. factory(Materialize.Picker, jQuery);
  6561. })(function (Picker, $) {
  6562. /**
  6563. * Globals and constants
  6564. */
  6565. var DAYS_IN_WEEK = 7,
  6566. WEEKS_IN_CALENDAR = 6,
  6567. _ = Picker._;
  6568. /**
  6569. * The date picker constructor
  6570. */
  6571. function DatePicker(picker, settings) {
  6572. var calendar = this,
  6573. element = picker.$node[0],
  6574. elementValue = element.value,
  6575. elementDataValue = picker.$node.data('value'),
  6576. valueString = elementDataValue || elementValue,
  6577. formatString = elementDataValue ? settings.formatSubmit : settings.format,
  6578. isRTL = function () {
  6579. return element.currentStyle ?
  6580. // For IE.
  6581. element.currentStyle.direction == 'rtl' :
  6582. // For normal browsers.
  6583. getComputedStyle(picker.$root[0]).direction == 'rtl';
  6584. };
  6585. calendar.settings = settings;
  6586. calendar.$node = picker.$node;
  6587. // The queue of methods that will be used to build item objects.
  6588. calendar.queue = {
  6589. min: 'measure create',
  6590. max: 'measure create',
  6591. now: 'now create',
  6592. select: 'parse create validate',
  6593. highlight: 'parse navigate create validate',
  6594. view: 'parse create validate viewset',
  6595. disable: 'deactivate',
  6596. enable: 'activate'
  6597. // The component's item object.
  6598. }; calendar.item = {};
  6599. calendar.item.clear = null;
  6600. calendar.item.disable = (settings.disable || []).slice(0);
  6601. calendar.item.enable = -function (collectionDisabled) {
  6602. return collectionDisabled[0] === true ? collectionDisabled.shift() : -1;
  6603. }(calendar.item.disable);
  6604. calendar.set('min', settings.min).set('max', settings.max).set('now');
  6605. // When there’s a value, set the `select`, which in turn
  6606. // also sets the `highlight` and `view`.
  6607. if (valueString) {
  6608. calendar.set('select', valueString, { format: formatString });
  6609. }
  6610. // If there’s no value, default to highlighting “today”.
  6611. else {
  6612. calendar.set('select', null).set('highlight', calendar.item.now);
  6613. }
  6614. // The keycode to movement mapping.
  6615. calendar.key = {
  6616. 40: 7, // Down
  6617. 38: -7, // Up
  6618. 39: function () {
  6619. return isRTL() ? -1 : 1;
  6620. }, // Right
  6621. 37: function () {
  6622. return isRTL() ? 1 : -1;
  6623. }, // Left
  6624. go: function (timeChange) {
  6625. var highlightedObject = calendar.item.highlight,
  6626. targetDate = new Date(highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange);
  6627. calendar.set('highlight', targetDate, { interval: timeChange });
  6628. this.render();
  6629. }
  6630. // Bind some picker events.
  6631. }; picker.on('render', function () {
  6632. picker.$root.find('.' + settings.klass.selectMonth).on('change', function () {
  6633. var value = this.value;
  6634. if (value) {
  6635. picker.set('highlight', [picker.get('view').year, value, picker.get('highlight').date]);
  6636. picker.$root.find('.' + settings.klass.selectMonth).trigger('focus');
  6637. }
  6638. });
  6639. picker.$root.find('.' + settings.klass.selectYear).on('change', function () {
  6640. var value = this.value;
  6641. if (value) {
  6642. picker.set('highlight', [value, picker.get('view').month, picker.get('highlight').date]);
  6643. picker.$root.find('.' + settings.klass.selectYear).trigger('focus');
  6644. }
  6645. });
  6646. }, 1).on('open', function () {
  6647. var includeToday = '';
  6648. if (calendar.disabled(calendar.get('now'))) {
  6649. includeToday = ':not(.' + settings.klass.buttonToday + ')';
  6650. }
  6651. picker.$root.find('button' + includeToday + ', select').attr('disabled', false);
  6652. }, 1).on('close', function () {
  6653. picker.$root.find('button, select').attr('disabled', true);
  6654. }, 1);
  6655. } //DatePicker
  6656. /**
  6657. * Set a datepicker item object.
  6658. */
  6659. DatePicker.prototype.set = function (type, value, options) {
  6660. var calendar = this,
  6661. calendarItem = calendar.item;
  6662. // If the value is `null` just set it immediately.
  6663. if (value === null) {
  6664. if (type == 'clear') type = 'select';
  6665. calendarItem[type] = value;
  6666. return calendar;
  6667. }
  6668. // Otherwise go through the queue of methods, and invoke the functions.
  6669. // Update this as the time unit, and set the final value as this item.
  6670. // * In the case of `enable`, keep the queue but set `disable` instead.
  6671. // And in the case of `flip`, keep the queue but set `enable` instead.
  6672. calendarItem[type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type] = calendar.queue[type].split(' ').map(function (method) {
  6673. value = calendar[method](type, value, options);
  6674. return value;
  6675. }).pop();
  6676. // Check if we need to cascade through more updates.
  6677. if (type == 'select') {
  6678. calendar.set('highlight', calendarItem.select, options);
  6679. } else if (type == 'highlight') {
  6680. calendar.set('view', calendarItem.highlight, options);
  6681. } else if (type.match(/^(flip|min|max|disable|enable)$/)) {
  6682. if (calendarItem.select && calendar.disabled(calendarItem.select)) {
  6683. calendar.set('select', calendarItem.select, options);
  6684. }
  6685. if (calendarItem.highlight && calendar.disabled(calendarItem.highlight)) {
  6686. calendar.set('highlight', calendarItem.highlight, options);
  6687. }
  6688. }
  6689. return calendar;
  6690. }; //DatePicker.prototype.set
  6691. /**
  6692. * Get a datepicker item object.
  6693. */
  6694. DatePicker.prototype.get = function (type) {
  6695. return this.item[type];
  6696. }; //DatePicker.prototype.get
  6697. /**
  6698. * Create a picker date object.
  6699. */
  6700. DatePicker.prototype.create = function (type, value, options) {
  6701. var isInfiniteValue,
  6702. calendar = this;
  6703. // If there’s no value, use the type as the value.
  6704. value = value === undefined ? type : value;
  6705. // If it’s infinity, update the value.
  6706. if (value == -Infinity || value == Infinity) {
  6707. isInfiniteValue = value;
  6708. }
  6709. // If it’s an object, use the native date object.
  6710. else if ($.isPlainObject(value) && _.isInteger(value.pick)) {
  6711. value = value.obj;
  6712. }
  6713. // If it’s an array, convert it into a date and make sure
  6714. // that it’s a valid date – otherwise default to today.
  6715. else if ($.isArray(value)) {
  6716. value = new Date(value[0], value[1], value[2]);
  6717. value = _.isDate(value) ? value : calendar.create().obj;
  6718. }
  6719. // If it’s a number or date object, make a normalized date.
  6720. else if (_.isInteger(value) || _.isDate(value)) {
  6721. value = calendar.normalize(new Date(value), options);
  6722. }
  6723. // If it’s a literal true or any other case, set it to now.
  6724. else /*if ( value === true )*/ {
  6725. value = calendar.now(type, value, options);
  6726. }
  6727. // Return the compiled object.
  6728. return {
  6729. year: isInfiniteValue || value.getFullYear(),
  6730. month: isInfiniteValue || value.getMonth(),
  6731. date: isInfiniteValue || value.getDate(),
  6732. day: isInfiniteValue || value.getDay(),
  6733. obj: isInfiniteValue || value,
  6734. pick: isInfiniteValue || value.getTime()
  6735. };
  6736. }; //DatePicker.prototype.create
  6737. /**
  6738. * Create a range limit object using an array, date object,
  6739. * literal “true”, or integer relative to another time.
  6740. */
  6741. DatePicker.prototype.createRange = function (from, to) {
  6742. var calendar = this,
  6743. createDate = function (date) {
  6744. if (date === true || $.isArray(date) || _.isDate(date)) {
  6745. return calendar.create(date);
  6746. }
  6747. return date;
  6748. };
  6749. // Create objects if possible.
  6750. if (!_.isInteger(from)) {
  6751. from = createDate(from);
  6752. }
  6753. if (!_.isInteger(to)) {
  6754. to = createDate(to);
  6755. }
  6756. // Create relative dates.
  6757. if (_.isInteger(from) && $.isPlainObject(to)) {
  6758. from = [to.year, to.month, to.date + from];
  6759. } else if (_.isInteger(to) && $.isPlainObject(from)) {
  6760. to = [from.year, from.month, from.date + to];
  6761. }
  6762. return {
  6763. from: createDate(from),
  6764. to: createDate(to)
  6765. };
  6766. }; //DatePicker.prototype.createRange
  6767. /**
  6768. * Check if a date unit falls within a date range object.
  6769. */
  6770. DatePicker.prototype.withinRange = function (range, dateUnit) {
  6771. range = this.createRange(range.from, range.to);
  6772. return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick;
  6773. };
  6774. /**
  6775. * Check if two date range objects overlap.
  6776. */
  6777. DatePicker.prototype.overlapRanges = function (one, two) {
  6778. var calendar = this;
  6779. // Convert the ranges into comparable dates.
  6780. one = calendar.createRange(one.from, one.to);
  6781. two = calendar.createRange(two.from, two.to);
  6782. return calendar.withinRange(one, two.from) || calendar.withinRange(one, two.to) || calendar.withinRange(two, one.from) || calendar.withinRange(two, one.to);
  6783. };
  6784. /**
  6785. * Get the date today.
  6786. */
  6787. DatePicker.prototype.now = function (type, value, options) {
  6788. value = new Date();
  6789. if (options && options.rel) {
  6790. value.setDate(value.getDate() + options.rel);
  6791. }
  6792. return this.normalize(value, options);
  6793. };
  6794. /**
  6795. * Navigate to next/prev month.
  6796. */
  6797. DatePicker.prototype.navigate = function (type, value, options) {
  6798. var targetDateObject,
  6799. targetYear,
  6800. targetMonth,
  6801. targetDate,
  6802. isTargetArray = $.isArray(value),
  6803. isTargetObject = $.isPlainObject(value),
  6804. viewsetObject = this.item.view; /*,
  6805. safety = 100*/
  6806. if (isTargetArray || isTargetObject) {
  6807. if (isTargetObject) {
  6808. targetYear = value.year;
  6809. targetMonth = value.month;
  6810. targetDate = value.date;
  6811. } else {
  6812. targetYear = +value[0];
  6813. targetMonth = +value[1];
  6814. targetDate = +value[2];
  6815. }
  6816. // If we’re navigating months but the view is in a different
  6817. // month, navigate to the view’s year and month.
  6818. if (options && options.nav && viewsetObject && viewsetObject.month !== targetMonth) {
  6819. targetYear = viewsetObject.year;
  6820. targetMonth = viewsetObject.month;
  6821. }
  6822. // Figure out the expected target year and month.
  6823. targetDateObject = new Date(targetYear, targetMonth + (options && options.nav ? options.nav : 0), 1);
  6824. targetYear = targetDateObject.getFullYear();
  6825. targetMonth = targetDateObject.getMonth();
  6826. // If the month we’re going to doesn’t have enough days,
  6827. // keep decreasing the date until we reach the month’s last date.
  6828. while ( /*safety &&*/new Date(targetYear, targetMonth, targetDate).getMonth() !== targetMonth) {
  6829. targetDate -= 1;
  6830. /*safety -= 1
  6831. if ( !safety ) {
  6832. throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.'
  6833. }*/
  6834. }
  6835. value = [targetYear, targetMonth, targetDate];
  6836. }
  6837. return value;
  6838. }; //DatePicker.prototype.navigate
  6839. /**
  6840. * Normalize a date by setting the hours to midnight.
  6841. */
  6842. DatePicker.prototype.normalize = function (value /*, options*/) {
  6843. value.setHours(0, 0, 0, 0);
  6844. return value;
  6845. };
  6846. /**
  6847. * Measure the range of dates.
  6848. */
  6849. DatePicker.prototype.measure = function (type, value /*, options*/) {
  6850. var calendar = this;
  6851. // If it’s anything false-y, remove the limits.
  6852. if (!value) {
  6853. value = type == 'min' ? -Infinity : Infinity;
  6854. }
  6855. // If it’s a string, parse it.
  6856. else if (typeof value == 'string') {
  6857. value = calendar.parse(type, value);
  6858. }
  6859. // If it's an integer, get a date relative to today.
  6860. else if (_.isInteger(value)) {
  6861. value = calendar.now(type, value, { rel: value });
  6862. }
  6863. return value;
  6864. }; ///DatePicker.prototype.measure
  6865. /**
  6866. * Create a viewset object based on navigation.
  6867. */
  6868. DatePicker.prototype.viewset = function (type, dateObject /*, options*/) {
  6869. return this.create([dateObject.year, dateObject.month, 1]);
  6870. };
  6871. /**
  6872. * Validate a date as enabled and shift if needed.
  6873. */
  6874. DatePicker.prototype.validate = function (type, dateObject, options) {
  6875. var calendar = this,
  6876. // Keep a reference to the original date.
  6877. originalDateObject = dateObject,
  6878. // Make sure we have an interval.
  6879. interval = options && options.interval ? options.interval : 1,
  6880. // Check if the calendar enabled dates are inverted.
  6881. isFlippedBase = calendar.item.enable === -1,
  6882. // Check if we have any enabled dates after/before now.
  6883. hasEnabledBeforeTarget,
  6884. hasEnabledAfterTarget,
  6885. // The min & max limits.
  6886. minLimitObject = calendar.item.min,
  6887. maxLimitObject = calendar.item.max,
  6888. // Check if we’ve reached the limit during shifting.
  6889. reachedMin,
  6890. reachedMax,
  6891. // Check if the calendar is inverted and at least one weekday is enabled.
  6892. hasEnabledWeekdays = isFlippedBase && calendar.item.disable.filter(function (value) {
  6893. // If there’s a date, check where it is relative to the target.
  6894. if ($.isArray(value)) {
  6895. var dateTime = calendar.create(value).pick;
  6896. if (dateTime < dateObject.pick) hasEnabledBeforeTarget = true; else if (dateTime > dateObject.pick) hasEnabledAfterTarget = true;
  6897. }
  6898. // Return only integers for enabled weekdays.
  6899. return _.isInteger(value);
  6900. }).length; /*,
  6901. safety = 100*/
  6902. // Cases to validate for:
  6903. // [1] Not inverted and date disabled.
  6904. // [2] Inverted and some dates enabled.
  6905. // [3] Not inverted and out of range.
  6906. //
  6907. // Cases to **not** validate for:
  6908. // • Navigating months.
  6909. // • Not inverted and date enabled.
  6910. // • Inverted and all dates disabled.
  6911. // • ..and anything else.
  6912. if (!options || !options.nav) if (
  6913. /* 1 */!isFlippedBase && calendar.disabled(dateObject) ||
  6914. /* 2 */isFlippedBase && calendar.disabled(dateObject) && (hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget) ||
  6915. /* 3 */ !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick)) {
  6916. // When inverted, flip the direction if there aren’t any enabled weekdays
  6917. // and there are no enabled dates in the direction of the interval.
  6918. if (isFlippedBase && !hasEnabledWeekdays && (!hasEnabledAfterTarget && interval > 0 || !hasEnabledBeforeTarget && interval < 0)) {
  6919. interval *= -1;
  6920. }
  6921. // Keep looping until we reach an enabled date.
  6922. while ( /*safety &&*/calendar.disabled(dateObject)) {
  6923. /*safety -= 1
  6924. if ( !safety ) {
  6925. throw 'Fell into an infinite loop while validating ' + dateObject.obj + '.'
  6926. }*/
  6927. // If we’ve looped into the next/prev month with a large interval, return to the original date and flatten the interval.
  6928. if (Math.abs(interval) > 1 && (dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month)) {
  6929. dateObject = originalDateObject;
  6930. interval = interval > 0 ? 1 : -1;
  6931. }
  6932. // If we’ve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit.
  6933. if (dateObject.pick <= minLimitObject.pick) {
  6934. reachedMin = true;
  6935. interval = 1;
  6936. dateObject = calendar.create([minLimitObject.year, minLimitObject.month, minLimitObject.date + (dateObject.pick === minLimitObject.pick ? 0 : -1)]);
  6937. } else if (dateObject.pick >= maxLimitObject.pick) {
  6938. reachedMax = true;
  6939. interval = -1;
  6940. dateObject = calendar.create([maxLimitObject.year, maxLimitObject.month, maxLimitObject.date + (dateObject.pick === maxLimitObject.pick ? 0 : 1)]);
  6941. }
  6942. // If we’ve reached both limits, just break out of the loop.
  6943. if (reachedMin && reachedMax) {
  6944. break;
  6945. }
  6946. // Finally, create the shifted date using the interval and keep looping.
  6947. dateObject = calendar.create([dateObject.year, dateObject.month, dateObject.date + interval]);
  6948. }
  6949. } //endif
  6950. // Return the date object settled on.
  6951. return dateObject;
  6952. }; //DatePicker.prototype.validate
  6953. /**
  6954. * Check if a date is disabled.
  6955. */
  6956. DatePicker.prototype.disabled = function (dateToVerify) {
  6957. var calendar = this,
  6958. // Filter through the disabled dates to check if this is one.
  6959. isDisabledMatch = calendar.item.disable.filter(function (dateToDisable) {
  6960. // If the date is a number, match the weekday with 0index and `firstDay` check.
  6961. if (_.isInteger(dateToDisable)) {
  6962. return dateToVerify.day === (calendar.settings.firstDay ? dateToDisable : dateToDisable - 1) % 7;
  6963. }
  6964. // If it’s an array or a native JS date, create and match the exact date.
  6965. if ($.isArray(dateToDisable) || _.isDate(dateToDisable)) {
  6966. return dateToVerify.pick === calendar.create(dateToDisable).pick;
  6967. }
  6968. // If it’s an object, match a date within the “from” and “to” range.
  6969. if ($.isPlainObject(dateToDisable)) {
  6970. return calendar.withinRange(dateToDisable, dateToVerify);
  6971. }
  6972. });
  6973. // If this date matches a disabled date, confirm it’s not inverted.
  6974. isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function (dateToDisable) {
  6975. return $.isArray(dateToDisable) && dateToDisable[3] == 'inverted' || $.isPlainObject(dateToDisable) && dateToDisable.inverted;
  6976. }).length;
  6977. // Check the calendar “enabled” flag and respectively flip the
  6978. // disabled state. Then also check if it’s beyond the min/max limits.
  6979. return calendar.item.enable === -1 ? !isDisabledMatch : isDisabledMatch || dateToVerify.pick < calendar.item.min.pick || dateToVerify.pick > calendar.item.max.pick;
  6980. }; //DatePicker.prototype.disabled
  6981. /**
  6982. * Parse a string into a usable type.
  6983. */
  6984. DatePicker.prototype.parse = function (type, value, options) {
  6985. var calendar = this,
  6986. parsingObject = {};
  6987. // If it’s already parsed, we’re good.
  6988. if (!value || typeof value != 'string') {
  6989. return value;
  6990. }
  6991. // We need a `.format` to parse the value with.
  6992. if (!(options && options.format)) {
  6993. options = options || {};
  6994. options.format = calendar.settings.format;
  6995. }
  6996. // Convert the format into an array and then map through it.
  6997. calendar.formats.toArray(options.format).map(function (label) {
  6998. var
  6999. // Grab the formatting label.
  7000. formattingLabel = calendar.formats[label],
  7001. // The format length is from the formatting label function or the
  7002. // label length without the escaping exclamation (!) mark.
  7003. formatLength = formattingLabel ? _.trigger(formattingLabel, calendar, [value, parsingObject]) : label.replace(/^!/, '').length;
  7004. // If there's a format label, split the value up to the format length.
  7005. // Then add it to the parsing object with appropriate label.
  7006. if (formattingLabel) {
  7007. parsingObject[label] = value.substr(0, formatLength);
  7008. }
  7009. // Update the value as the substring from format length to end.
  7010. value = value.substr(formatLength);
  7011. });
  7012. // Compensate for month 0index.
  7013. return [parsingObject.yyyy || parsingObject.yy, +(parsingObject.mm || parsingObject.m) - 1, parsingObject.dd || parsingObject.d];
  7014. }; //DatePicker.prototype.parse
  7015. /**
  7016. * Various formats to display the object in.
  7017. */
  7018. DatePicker.prototype.formats = function () {
  7019. // Return the length of the first word in a collection.
  7020. function getWordLengthFromCollection(string, collection, dateObject) {
  7021. // Grab the first word from the string.
  7022. var word = string.match(/\w+/)[0];
  7023. // If there's no month index, add it to the date object
  7024. if (!dateObject.mm && !dateObject.m) {
  7025. dateObject.m = collection.indexOf(word) + 1;
  7026. }
  7027. // Return the length of the word.
  7028. return word.length;
  7029. }
  7030. // Get the length of the first word in a string.
  7031. function getFirstWordLength(string) {
  7032. return string.match(/\w+/)[0].length;
  7033. }
  7034. return {
  7035. d: function (string, dateObject) {
  7036. // If there's string, then get the digits length.
  7037. // Otherwise return the selected date.
  7038. return string ? _.digits(string) : dateObject.date;
  7039. },
  7040. dd: function (string, dateObject) {
  7041. // If there's a string, then the length is always 2.
  7042. // Otherwise return the selected date with a leading zero.
  7043. return string ? 2 : _.lead(dateObject.date);
  7044. },
  7045. ddd: function (string, dateObject) {
  7046. // If there's a string, then get the length of the first word.
  7047. // Otherwise return the short selected weekday.
  7048. return string ? getFirstWordLength(string) : this.settings.weekdaysShort[dateObject.day];
  7049. },
  7050. dddd: function (string, dateObject) {
  7051. // If there's a string, then get the length of the first word.
  7052. // Otherwise return the full selected weekday.
  7053. return string ? getFirstWordLength(string) : this.settings.weekdaysFull[dateObject.day];
  7054. },
  7055. m: function (string, dateObject) {
  7056. // If there's a string, then get the length of the digits
  7057. // Otherwise return the selected month with 0index compensation.
  7058. return string ? _.digits(string) : dateObject.month + 1;
  7059. },
  7060. mm: function (string, dateObject) {
  7061. // If there's a string, then the length is always 2.
  7062. // Otherwise return the selected month with 0index and leading zero.
  7063. return string ? 2 : _.lead(dateObject.month + 1);
  7064. },
  7065. mmm: function (string, dateObject) {
  7066. var collection = this.settings.monthsShort;
  7067. // If there's a string, get length of the relevant month from the short
  7068. // months collection. Otherwise return the selected month from that collection.
  7069. return string ? getWordLengthFromCollection(string, collection, dateObject) : collection[dateObject.month];
  7070. },
  7071. mmmm: function (string, dateObject) {
  7072. var collection = this.settings.monthsFull;
  7073. // If there's a string, get length of the relevant month from the full
  7074. // months collection. Otherwise return the selected month from that collection.
  7075. return string ? getWordLengthFromCollection(string, collection, dateObject) : collection[dateObject.month];
  7076. },
  7077. yy: function (string, dateObject) {
  7078. // If there's a string, then the length is always 2.
  7079. // Otherwise return the selected year by slicing out the first 2 digits.
  7080. return string ? 2 : ('' + dateObject.year).slice(2);
  7081. },
  7082. yyyy: function (string, dateObject) {
  7083. // If there's a string, then the length is always 4.
  7084. // Otherwise return the selected year.
  7085. return string ? 4 : dateObject.year;
  7086. },
  7087. // Create an array by splitting the formatting string passed.
  7088. toArray: function (formatString) {
  7089. return formatString.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g);
  7090. },
  7091. // Format an object into a string using the formatting options.
  7092. toString: function (formatString, itemObject) {
  7093. var calendar = this;
  7094. return calendar.formats.toArray(formatString).map(function (label) {
  7095. return _.trigger(calendar.formats[label], calendar, [0, itemObject]) || label.replace(/^!/, '');
  7096. }).join('');
  7097. }
  7098. };
  7099. }(); //DatePicker.prototype.formats
  7100. /**
  7101. * Check if two date units are the exact.
  7102. */
  7103. DatePicker.prototype.isDateExact = function (one, two) {
  7104. var calendar = this;
  7105. // When we’re working with weekdays, do a direct comparison.
  7106. if (_.isInteger(one) && _.isInteger(two) || typeof one == 'boolean' && typeof two == 'boolean') {
  7107. return one === two;
  7108. }
  7109. // When we’re working with date representations, compare the “pick” value.
  7110. if ((_.isDate(one) || $.isArray(one)) && (_.isDate(two) || $.isArray(two))) {
  7111. return calendar.create(one).pick === calendar.create(two).pick;
  7112. }
  7113. // When we’re working with range objects, compare the “from” and “to”.
  7114. if ($.isPlainObject(one) && $.isPlainObject(two)) {
  7115. return calendar.isDateExact(one.from, two.from) && calendar.isDateExact(one.to, two.to);
  7116. }
  7117. return false;
  7118. };
  7119. /**
  7120. * Check if two date units overlap.
  7121. */
  7122. DatePicker.prototype.isDateOverlap = function (one, two) {
  7123. var calendar = this,
  7124. firstDay = calendar.settings.firstDay ? 1 : 0;
  7125. // When we’re working with a weekday index, compare the days.
  7126. if (_.isInteger(one) && (_.isDate(two) || $.isArray(two))) {
  7127. one = one % 7 + firstDay;
  7128. return one === calendar.create(two).day + 1;
  7129. }
  7130. if (_.isInteger(two) && (_.isDate(one) || $.isArray(one))) {
  7131. two = two % 7 + firstDay;
  7132. return two === calendar.create(one).day + 1;
  7133. }
  7134. // When we’re working with range objects, check if the ranges overlap.
  7135. if ($.isPlainObject(one) && $.isPlainObject(two)) {
  7136. return calendar.overlapRanges(one, two);
  7137. }
  7138. return false;
  7139. };
  7140. /**
  7141. * Flip the “enabled” state.
  7142. */
  7143. DatePicker.prototype.flipEnable = function (val) {
  7144. var itemObject = this.item;
  7145. itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1);
  7146. };
  7147. /**
  7148. * Mark a collection of dates as “disabled”.
  7149. */
  7150. DatePicker.prototype.deactivate = function (type, datesToDisable) {
  7151. var calendar = this,
  7152. disabledItems = calendar.item.disable.slice(0);
  7153. // If we’re flipping, that’s all we need to do.
  7154. if (datesToDisable == 'flip') {
  7155. calendar.flipEnable();
  7156. } else if (datesToDisable === false) {
  7157. calendar.flipEnable(1);
  7158. disabledItems = [];
  7159. } else if (datesToDisable === true) {
  7160. calendar.flipEnable(-1);
  7161. disabledItems = [];
  7162. }
  7163. // Otherwise go through the dates to disable.
  7164. else {
  7165. datesToDisable.map(function (unitToDisable) {
  7166. var matchFound;
  7167. // When we have disabled items, check for matches.
  7168. // If something is matched, immediately break out.
  7169. for (var index = 0; index < disabledItems.length; index += 1) {
  7170. if (calendar.isDateExact(unitToDisable, disabledItems[index])) {
  7171. matchFound = true;
  7172. break;
  7173. }
  7174. }
  7175. // If nothing was found, add the validated unit to the collection.
  7176. if (!matchFound) {
  7177. if (_.isInteger(unitToDisable) || _.isDate(unitToDisable) || $.isArray(unitToDisable) || $.isPlainObject(unitToDisable) && unitToDisable.from && unitToDisable.to) {
  7178. disabledItems.push(unitToDisable);
  7179. }
  7180. }
  7181. });
  7182. }
  7183. // Return the updated collection.
  7184. return disabledItems;
  7185. }; //DatePicker.prototype.deactivate
  7186. /**
  7187. * Mark a collection of dates as “enabled”.
  7188. */
  7189. DatePicker.prototype.activate = function (type, datesToEnable) {
  7190. var calendar = this,
  7191. disabledItems = calendar.item.disable,
  7192. disabledItemsCount = disabledItems.length;
  7193. // If we’re flipping, that’s all we need to do.
  7194. if (datesToEnable == 'flip') {
  7195. calendar.flipEnable();
  7196. } else if (datesToEnable === true) {
  7197. calendar.flipEnable(1);
  7198. disabledItems = [];
  7199. } else if (datesToEnable === false) {
  7200. calendar.flipEnable(-1);
  7201. disabledItems = [];
  7202. }
  7203. // Otherwise go through the disabled dates.
  7204. else {
  7205. datesToEnable.map(function (unitToEnable) {
  7206. var matchFound, disabledUnit, index, isExactRange;
  7207. // Go through the disabled items and try to find a match.
  7208. for (index = 0; index < disabledItemsCount; index += 1) {
  7209. disabledUnit = disabledItems[index];
  7210. // When an exact match is found, remove it from the collection.
  7211. if (calendar.isDateExact(disabledUnit, unitToEnable)) {
  7212. matchFound = disabledItems[index] = null;
  7213. isExactRange = true;
  7214. break;
  7215. }
  7216. // When an overlapped match is found, add the “inverted” state to it.
  7217. else if (calendar.isDateOverlap(disabledUnit, unitToEnable)) {
  7218. if ($.isPlainObject(unitToEnable)) {
  7219. unitToEnable.inverted = true;
  7220. matchFound = unitToEnable;
  7221. } else if ($.isArray(unitToEnable)) {
  7222. matchFound = unitToEnable;
  7223. if (!matchFound[3]) matchFound.push('inverted');
  7224. } else if (_.isDate(unitToEnable)) {
  7225. matchFound = [unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted'];
  7226. }
  7227. break;
  7228. }
  7229. }
  7230. // If a match was found, remove a previous duplicate entry.
  7231. if (matchFound) for (index = 0; index < disabledItemsCount; index += 1) {
  7232. if (calendar.isDateExact(disabledItems[index], unitToEnable)) {
  7233. disabledItems[index] = null;
  7234. break;
  7235. }
  7236. }
  7237. // In the event that we’re dealing with an exact range of dates,
  7238. // make sure there are no “inverted” dates because of it.
  7239. if (isExactRange) for (index = 0; index < disabledItemsCount; index += 1) {
  7240. if (calendar.isDateOverlap(disabledItems[index], unitToEnable)) {
  7241. disabledItems[index] = null;
  7242. break;
  7243. }
  7244. }
  7245. // If something is still matched, add it into the collection.
  7246. if (matchFound) {
  7247. disabledItems.push(matchFound);
  7248. }
  7249. });
  7250. }
  7251. // Return the updated collection.
  7252. return disabledItems.filter(function (val) {
  7253. return val != null;
  7254. });
  7255. }; //DatePicker.prototype.activate
  7256. /**
  7257. * Create a string for the nodes in the picker.
  7258. */
  7259. DatePicker.prototype.nodes = function (isOpen) {
  7260. var calendar = this,
  7261. settings = calendar.settings,
  7262. calendarItem = calendar.item,
  7263. nowObject = calendarItem.now,
  7264. selectedObject = calendarItem.select,
  7265. highlightedObject = calendarItem.highlight,
  7266. viewsetObject = calendarItem.view,
  7267. disabledCollection = calendarItem.disable,
  7268. minLimitObject = calendarItem.min,
  7269. maxLimitObject = calendarItem.max,
  7270. // Create the calendar table head using a copy of weekday labels collection.
  7271. // * We do a copy so we don't mutate the original array.
  7272. tableHead = function (collection, fullCollection) {
  7273. // If the first day should be Monday, move Sunday to the end.
  7274. if (settings.firstDay) {
  7275. collection.push(collection.shift());
  7276. fullCollection.push(fullCollection.shift());
  7277. }
  7278. // Create and return the table head group.
  7279. return _.node('thead', _.node('tr', _.group({
  7280. min: 0,
  7281. max: DAYS_IN_WEEK - 1,
  7282. i: 1,
  7283. node: 'th',
  7284. item: function (counter) {
  7285. return [collection[counter], settings.klass.weekdays, 'scope=col title="' + fullCollection[counter] + '"'];
  7286. }
  7287. }))); //endreturn
  7288. // Materialize modified
  7289. }((settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysLetter).slice(0), settings.weekdaysFull.slice(0)),
  7290. //tableHead
  7291. // Create the nav for next/prev month.
  7292. createMonthNav = function (next) {
  7293. // Otherwise, return the created month tag.
  7294. return _.node('div', ' ', settings.klass['nav' + (next ? 'Next' : 'Prev')] + (
  7295. // If the focused month is outside the range, disabled the button.
  7296. next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month || !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ? ' ' + settings.klass.navDisabled : ''), 'data-nav=' + (next || -1) + ' ' + _.ariaAttr({
  7297. role: 'button',
  7298. controls: calendar.$node[0].id + '_table'
  7299. }) + ' ' + 'title="' + (next ? settings.labelMonthNext : settings.labelMonthPrev) + '"'); //endreturn
  7300. },
  7301. //createMonthNav
  7302. // Create the month label.
  7303. //Materialize modified
  7304. createMonthLabel = function (override) {
  7305. var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull;
  7306. // Materialize modified
  7307. if (override == "short_months") {
  7308. monthsCollection = settings.monthsShort;
  7309. }
  7310. // If there are months to select, add a dropdown menu.
  7311. if (settings.selectMonths && override == undefined) {
  7312. return _.node('select', _.group({
  7313. min: 0,
  7314. max: 11,
  7315. i: 1,
  7316. node: 'option',
  7317. item: function (loopedMonth) {
  7318. return [
  7319. // The looped month and no classes.
  7320. monthsCollection[loopedMonth], 0,
  7321. // Set the value and selected index.
  7322. 'value=' + loopedMonth + (viewsetObject.month == loopedMonth ? ' selected' : '') + (viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month || viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month ? ' disabled' : '')];
  7323. }
  7324. }), settings.klass.selectMonth + ' browser-default', (isOpen ? '' : 'disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + 'title="' + settings.labelMonthSelect + '"');
  7325. }
  7326. // Materialize modified
  7327. if (override == "short_months") if (selectedObject != null) return monthsCollection[selectedObject.month]; else return monthsCollection[viewsetObject.month];
  7328. // If there's a need for a month selector
  7329. return _.node('div', monthsCollection[viewsetObject.month], settings.klass.month);
  7330. },
  7331. //createMonthLabel
  7332. // Create the year label.
  7333. // Materialize modified
  7334. createYearLabel = function (override) {
  7335. var focusedYear = viewsetObject.year,
  7336. // If years selector is set to a literal "true", set it to 5. Otherwise
  7337. // divide in half to get half before and half after focused year.
  7338. numberYears = settings.selectYears === true ? 5 : ~~(settings.selectYears / 2);
  7339. // If there are years to select, add a dropdown menu.
  7340. if (numberYears) {
  7341. var minYear = minLimitObject.year,
  7342. maxYear = maxLimitObject.year,
  7343. lowestYear = focusedYear - numberYears,
  7344. highestYear = focusedYear + numberYears;
  7345. // If the min year is greater than the lowest year, increase the highest year
  7346. // by the difference and set the lowest year to the min year.
  7347. if (minYear > lowestYear) {
  7348. highestYear += minYear - lowestYear;
  7349. lowestYear = minYear;
  7350. }
  7351. // If the max year is less than the highest year, decrease the lowest year
  7352. // by the lower of the two: available and needed years. Then set the
  7353. // highest year to the max year.
  7354. if (maxYear < highestYear) {
  7355. var availableYears = lowestYear - minYear,
  7356. neededYears = highestYear - maxYear;
  7357. lowestYear -= availableYears > neededYears ? neededYears : availableYears;
  7358. highestYear = maxYear;
  7359. }
  7360. if (settings.selectYears && override == undefined) {
  7361. return _.node('select', _.group({
  7362. min: lowestYear,
  7363. max: highestYear,
  7364. i: 1,
  7365. node: 'option',
  7366. item: function (loopedYear) {
  7367. return [
  7368. // The looped year and no classes.
  7369. loopedYear, 0,
  7370. // Set the value and selected index.
  7371. 'value=' + loopedYear + (focusedYear == loopedYear ? ' selected' : '')];
  7372. }
  7373. }), settings.klass.selectYear + ' browser-default', (isOpen ? '' : 'disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + 'title="' + settings.labelYearSelect + '"');
  7374. }
  7375. }
  7376. // Materialize modified
  7377. if (override === 'raw' && selectedObject != null) {
  7378. return _.node('div', selectedObject.year);
  7379. }
  7380. // Otherwise just return the year focused
  7381. return _.node('div', focusedYear, settings.klass.year);
  7382. }; //createYearLabel
  7383. // Materialize modified
  7384. createDayLabel = function () {
  7385. if (selectedObject != null) return selectedObject.date; else return nowObject.date;
  7386. };
  7387. createWeekdayLabel = function () {
  7388. var display_day;
  7389. if (selectedObject != null) display_day = selectedObject.day; else display_day = nowObject.day;
  7390. var weekday = settings.weekdaysShort[display_day];
  7391. return weekday;
  7392. };
  7393. // Create and return the entire calendar.
  7394. return _.node(
  7395. // Date presentation View
  7396. 'div', _.node(
  7397. // Div for Year
  7398. 'div', createYearLabel("raw"), settings.klass.year_display) + _.node('span', createWeekdayLabel() + ', ', "picker__weekday-display") + _.node(
  7399. // Div for short Month
  7400. 'span', createMonthLabel("short_months") + ' ', settings.klass.month_display) + _.node(
  7401. // Div for Day
  7402. 'span', createDayLabel(), settings.klass.day_display), settings.klass.date_display) +
  7403. // Calendar container
  7404. _.node('div', _.node('div', _.node('div', (settings.selectYears ? createMonthLabel() + createYearLabel() : createMonthLabel() + createYearLabel()) + createMonthNav() + createMonthNav(1), settings.klass.header) + _.node('table', tableHead + _.node('tbody', _.group({
  7405. min: 0,
  7406. max: WEEKS_IN_CALENDAR - 1,
  7407. i: 1,
  7408. node: 'tr',
  7409. item: function (rowCounter) {
  7410. // If Monday is the first day and the month starts on Sunday, shift the date back a week.
  7411. var shiftDateBy = settings.firstDay && calendar.create([viewsetObject.year, viewsetObject.month, 1]).day === 0 ? -7 : 0;
  7412. return [_.group({
  7413. min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
  7414. max: function () {
  7415. return this.min + DAYS_IN_WEEK - 1;
  7416. },
  7417. i: 1,
  7418. node: 'td',
  7419. item: function (targetDate) {
  7420. // Convert the time date from a relative date to a target date.
  7421. targetDate = calendar.create([viewsetObject.year, viewsetObject.month, targetDate + (settings.firstDay ? 1 : 0)]);
  7422. var isSelected = selectedObject && selectedObject.pick == targetDate.pick,
  7423. isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick,
  7424. isDisabled = disabledCollection && calendar.disabled(targetDate) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick,
  7425. formattedDate = _.trigger(calendar.formats.toString, calendar, [settings.format, targetDate]);
  7426. return [_.node('div', targetDate.date, function (klasses) {
  7427. // Add the `infocus` or `outfocus` classes based on month in view.
  7428. klasses.push(viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus);
  7429. // Add the `today` class if needed.
  7430. if (nowObject.pick == targetDate.pick) {
  7431. klasses.push(settings.klass.now);
  7432. }
  7433. // Add the `selected` class if something's selected and the time matches.
  7434. if (isSelected) {
  7435. klasses.push(settings.klass.selected);
  7436. }
  7437. // Add the `highlighted` class if something's highlighted and the time matches.
  7438. if (isHighlighted) {
  7439. klasses.push(settings.klass.highlighted);
  7440. }
  7441. // Add the `disabled` class if something's disabled and the object matches.
  7442. if (isDisabled) {
  7443. klasses.push(settings.klass.disabled);
  7444. }
  7445. return klasses.join(' ');
  7446. }([settings.klass.day]), 'data-pick=' + targetDate.pick + ' ' + _.ariaAttr({
  7447. role: 'gridcell',
  7448. label: formattedDate,
  7449. selected: isSelected && calendar.$node.val() === formattedDate ? true : null,
  7450. activedescendant: isHighlighted ? true : null,
  7451. disabled: isDisabled ? true : null
  7452. }) + ' ' + (isDisabled ? '' : 'tabindex="0"')), '', _.ariaAttr({ role: 'presentation' })]; //endreturn
  7453. }
  7454. })]; //endreturn
  7455. }
  7456. })), settings.klass.table, 'id="' + calendar.$node[0].id + '_table' + '" ' + _.ariaAttr({
  7457. role: 'grid',
  7458. controls: calendar.$node[0].id,
  7459. readonly: true
  7460. })), settings.klass.calendar_container) // end calendar
  7461. +
  7462. // * For Firefox forms to submit, make sure to set the buttons’ `type` attributes as “button”.
  7463. _.node('div', _.node('button', settings.today, "btn-flat picker__today waves-effect", 'type=button data-pick=' + nowObject.pick + (isOpen && !calendar.disabled(nowObject) ? '' : ' disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id })) + _.node('button', settings.clear, "btn-flat picker__clear waves-effect", 'type=button data-clear=1' + (isOpen ? '' : ' disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id })) + _.node('button', settings.close, "btn-flat picker__close waves-effect", 'type=button data-close=true ' + (isOpen ? '' : ' disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id })), settings.klass.footer), 'picker__container__wrapper'); //endreturn
  7464. }; //DatePicker.prototype.nodes
  7465. /**
  7466. * The date picker defaults.
  7467. */
  7468. DatePicker.defaults = function (prefix) {
  7469. return {
  7470. // The title label to use for the month nav buttons
  7471. labelMonthNext: 'Next month',
  7472. labelMonthPrev: 'Previous month',
  7473. // The title label to use for the dropdown selectors
  7474. labelMonthSelect: 'Select a month',
  7475. labelYearSelect: 'Select a year',
  7476. // Months and weekdays
  7477. monthsFull: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  7478. monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  7479. weekdaysFull: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  7480. weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  7481. // Materialize modified
  7482. weekdaysLetter: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
  7483. // Today and clear
  7484. today: 'Today',
  7485. clear: 'Clear',
  7486. close: 'Ok',
  7487. // Picker close behavior (Prevent a change in behaviour for backwards compatibility)
  7488. closeOnSelect: false,
  7489. // The format to show on the `input` element
  7490. format: 'd mmmm, yyyy',
  7491. // Classes
  7492. klass: {
  7493. table: prefix + 'table',
  7494. header: prefix + 'header',
  7495. // Materialize Added klasses
  7496. date_display: prefix + 'date-display',
  7497. day_display: prefix + 'day-display',
  7498. month_display: prefix + 'month-display',
  7499. year_display: prefix + 'year-display',
  7500. calendar_container: prefix + 'calendar-container',
  7501. // end
  7502. navPrev: prefix + 'nav--prev',
  7503. navNext: prefix + 'nav--next',
  7504. navDisabled: prefix + 'nav--disabled',
  7505. month: prefix + 'month',
  7506. year: prefix + 'year',
  7507. selectMonth: prefix + 'select--month',
  7508. selectYear: prefix + 'select--year',
  7509. weekdays: prefix + 'weekday',
  7510. day: prefix + 'day',
  7511. disabled: prefix + 'day--disabled',
  7512. selected: prefix + 'day--selected',
  7513. highlighted: prefix + 'day--highlighted',
  7514. now: prefix + 'day--today',
  7515. infocus: prefix + 'day--infocus',
  7516. outfocus: prefix + 'day--outfocus',
  7517. footer: prefix + 'footer',
  7518. buttonClear: prefix + 'button--clear',
  7519. buttonToday: prefix + 'button--today',
  7520. buttonClose: prefix + 'button--close'
  7521. }
  7522. };
  7523. }(Picker.klasses().picker + '__');
  7524. /**
  7525. * Extend the picker to add the date picker.
  7526. */
  7527. Picker.extend('pickadate', DatePicker);
  7528. });
  7529. ; /*!
  7530. * ClockPicker v0.0.7 (http://weareoutman.github.io/clockpicker/)
  7531. * Copyright 2014 Wang Shenwei.
  7532. * Licensed under MIT (https://github.com/weareoutman/clockpicker/blob/gh-pages/LICENSE)
  7533. *
  7534. * Further modified
  7535. * Copyright 2015 Ching Yaw Hao.
  7536. */
  7537. (function ($) {
  7538. var $win = $(window),
  7539. $doc = $(document);
  7540. // Can I use inline svg ?
  7541. var svgNS = 'http://www.w3.org/2000/svg',
  7542. svgSupported = 'SVGAngle' in window && function () {
  7543. var supported,
  7544. el = document.createElement('div');
  7545. el.innerHTML = '<svg/>';
  7546. supported = (el.firstChild && el.firstChild.namespaceURI) == svgNS;
  7547. el.innerHTML = '';
  7548. return supported;
  7549. }();
  7550. // Can I use transition ?
  7551. var transitionSupported = function () {
  7552. var style = document.createElement('div').style;
  7553. return 'transition' in style || 'WebkitTransition' in style || 'MozTransition' in style || 'msTransition' in style || 'OTransition' in style;
  7554. }();
  7555. // Listen touch events in touch screen device, instead of mouse events in desktop.
  7556. var touchSupported = 'ontouchstart' in window,
  7557. mousedownEvent = 'mousedown' + (touchSupported ? ' touchstart' : ''),
  7558. mousemoveEvent = 'mousemove.clockpicker' + (touchSupported ? ' touchmove.clockpicker' : ''),
  7559. mouseupEvent = 'mouseup.clockpicker' + (touchSupported ? ' touchend.clockpicker' : '');
  7560. // Vibrate the device if supported
  7561. var vibrate = navigator.vibrate ? 'vibrate' : navigator.webkitVibrate ? 'webkitVibrate' : null;
  7562. function createSvgElement(name) {
  7563. return document.createElementNS(svgNS, name);
  7564. }
  7565. function leadingZero(num) {
  7566. return (num < 10 ? '0' : '') + num;
  7567. }
  7568. // Get a unique id
  7569. var idCounter = 0;
  7570. function uniqueId(prefix) {
  7571. var id = ++idCounter + '';
  7572. return prefix ? prefix + id : id;
  7573. }
  7574. // Clock size
  7575. var dialRadius = 135,
  7576. outerRadius = 105,
  7577. // innerRadius = 80 on 12 hour clock
  7578. innerRadius = 70,
  7579. tickRadius = 20,
  7580. diameter = dialRadius * 2,
  7581. duration = transitionSupported ? 350 : 1;
  7582. // Popover template
  7583. var tpl = ['<div class="clockpicker picker">', '<div class="picker__holder">', '<div class="picker__frame">', '<div class="picker__wrap">', '<div class="picker__box">', '<div class="picker__date-display">', '<div class="clockpicker-display">', '<div class="clockpicker-display-column">', '<span class="clockpicker-span-hours text-primary"></span>', ':', '<span class="clockpicker-span-minutes"></span>', '</div>', '<div class="clockpicker-display-column clockpicker-display-am-pm">', '<div class="clockpicker-span-am-pm"></div>', '</div>', '</div>', '</div>', '<div class="picker__container__wrapper">', '<div class="picker__calendar-container">', '<div class="clockpicker-plate">', '<div class="clockpicker-canvas"></div>', '<div class="clockpicker-dial clockpicker-hours"></div>', '<div class="clockpicker-dial clockpicker-minutes clockpicker-dial-out"></div>', '</div>', '<div class="clockpicker-am-pm-block">', '</div>', '</div>', '<div class="picker__footer">', '</div>', '</div>', '</div>', '</div>', '</div>', '</div>', '</div>'].join('');
  7584. // ClockPicker
  7585. function ClockPicker(element, options) {
  7586. var popover = $(tpl),
  7587. plate = popover.find('.clockpicker-plate'),
  7588. holder = popover.find('.picker__holder'),
  7589. hoursView = popover.find('.clockpicker-hours'),
  7590. minutesView = popover.find('.clockpicker-minutes'),
  7591. amPmBlock = popover.find('.clockpicker-am-pm-block'),
  7592. isInput = element.prop('tagName') === 'INPUT',
  7593. input = isInput ? element : element.find('input'),
  7594. label = $("label[for=" + input.attr("id") + "]"),
  7595. self = this;
  7596. this.id = uniqueId('cp');
  7597. this.element = element;
  7598. this.holder = holder;
  7599. this.options = options;
  7600. this.isAppended = false;
  7601. this.isShown = false;
  7602. this.currentView = 'hours';
  7603. this.isInput = isInput;
  7604. this.input = input;
  7605. this.label = label;
  7606. this.popover = popover;
  7607. this.plate = plate;
  7608. this.hoursView = hoursView;
  7609. this.minutesView = minutesView;
  7610. this.amPmBlock = amPmBlock;
  7611. this.spanHours = popover.find('.clockpicker-span-hours');
  7612. this.spanMinutes = popover.find('.clockpicker-span-minutes');
  7613. this.spanAmPm = popover.find('.clockpicker-span-am-pm');
  7614. this.footer = popover.find('.picker__footer');
  7615. this.amOrPm = "PM";
  7616. // Setup for for 12 hour clock if option is selected
  7617. if (options.twelvehour) {
  7618. if (!options.ampmclickable) {
  7619. this.spanAmPm.empty();
  7620. $('<div id="click-am">AM</div>').appendTo(this.spanAmPm);
  7621. $('<div id="click-pm">PM</div>').appendTo(this.spanAmPm);
  7622. } else {
  7623. this.spanAmPm.empty();
  7624. $('<div id="click-am">AM</div>').on("click", function () {
  7625. self.spanAmPm.children('#click-am').addClass("text-primary");
  7626. self.spanAmPm.children('#click-pm').removeClass("text-primary");
  7627. self.amOrPm = "AM";
  7628. }).appendTo(this.spanAmPm);
  7629. $('<div id="click-pm">PM</div>').on("click", function () {
  7630. self.spanAmPm.children('#click-pm').addClass("text-primary");
  7631. self.spanAmPm.children('#click-am').removeClass("text-primary");
  7632. self.amOrPm = 'PM';
  7633. }).appendTo(this.spanAmPm);
  7634. }
  7635. }
  7636. // Add buttons to footer
  7637. $('<button type="button" class="btn-flat picker__clear" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.cleartext + '</button>').click($.proxy(this.clear, this)).appendTo(this.footer);
  7638. $('<button type="button" class="btn-flat picker__close" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.canceltext + '</button>').click($.proxy(this.hide, this)).appendTo(this.footer);
  7639. $('<button type="button" class="btn-flat picker__close" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.donetext + '</button>').click($.proxy(this.done, this)).appendTo(this.footer);
  7640. this.spanHours.click($.proxy(this.toggleView, this, 'hours'));
  7641. this.spanMinutes.click($.proxy(this.toggleView, this, 'minutes'));
  7642. // Show or toggle
  7643. input.on('focus.clockpicker click.clockpicker', $.proxy(this.show, this));
  7644. // Build ticks
  7645. var tickTpl = $('<div class="clockpicker-tick"></div>'),
  7646. i,
  7647. tick,
  7648. radian,
  7649. radius;
  7650. // Hours view
  7651. if (options.twelvehour) {
  7652. for (i = 1; i < 13; i += 1) {
  7653. tick = tickTpl.clone();
  7654. radian = i / 6 * Math.PI;
  7655. radius = outerRadius;
  7656. tick.css({
  7657. left: dialRadius + Math.sin(radian) * radius - tickRadius,
  7658. top: dialRadius - Math.cos(radian) * radius - tickRadius
  7659. });
  7660. tick.html(i === 0 ? '00' : i);
  7661. hoursView.append(tick);
  7662. tick.on(mousedownEvent, mousedown);
  7663. }
  7664. } else {
  7665. for (i = 0; i < 24; i += 1) {
  7666. tick = tickTpl.clone();
  7667. radian = i / 6 * Math.PI;
  7668. var inner = i > 0 && i < 13;
  7669. radius = inner ? innerRadius : outerRadius;
  7670. tick.css({
  7671. left: dialRadius + Math.sin(radian) * radius - tickRadius,
  7672. top: dialRadius - Math.cos(radian) * radius - tickRadius
  7673. });
  7674. tick.html(i === 0 ? '00' : i);
  7675. hoursView.append(tick);
  7676. tick.on(mousedownEvent, mousedown);
  7677. }
  7678. }
  7679. // Minutes view
  7680. for (i = 0; i < 60; i += 5) {
  7681. tick = tickTpl.clone();
  7682. radian = i / 30 * Math.PI;
  7683. tick.css({
  7684. left: dialRadius + Math.sin(radian) * outerRadius - tickRadius,
  7685. top: dialRadius - Math.cos(radian) * outerRadius - tickRadius
  7686. });
  7687. tick.html(leadingZero(i));
  7688. minutesView.append(tick);
  7689. tick.on(mousedownEvent, mousedown);
  7690. }
  7691. // Clicking on minutes view space
  7692. plate.on(mousedownEvent, function (e) {
  7693. if ($(e.target).closest('.clockpicker-tick').length === 0) {
  7694. mousedown(e, true);
  7695. }
  7696. });
  7697. // Mousedown or touchstart
  7698. function mousedown(e, space) {
  7699. var offset = plate.offset(),
  7700. isTouch = /^touch/.test(e.type),
  7701. x0 = offset.left + dialRadius,
  7702. y0 = offset.top + dialRadius,
  7703. dx = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
  7704. dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0,
  7705. z = Math.sqrt(dx * dx + dy * dy),
  7706. moved = false;
  7707. // When clicking on minutes view space, check the mouse position
  7708. if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius)) {
  7709. return;
  7710. }
  7711. e.preventDefault();
  7712. // Set cursor style of body after 200ms
  7713. var movingTimer = setTimeout(function () {
  7714. self.popover.addClass('clockpicker-moving');
  7715. }, 200);
  7716. // Clock
  7717. self.setHand(dx, dy, !space, true);
  7718. // Mousemove on document
  7719. $doc.off(mousemoveEvent).on(mousemoveEvent, function (e) {
  7720. e.preventDefault();
  7721. var isTouch = /^touch/.test(e.type),
  7722. x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
  7723. y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;
  7724. if (!moved && x === dx && y === dy) {
  7725. // Clicking in chrome on windows will trigger a mousemove event
  7726. return;
  7727. }
  7728. moved = true;
  7729. self.setHand(x, y, false, true);
  7730. });
  7731. // Mouseup on document
  7732. $doc.off(mouseupEvent).on(mouseupEvent, function (e) {
  7733. $doc.off(mouseupEvent);
  7734. e.preventDefault();
  7735. var isTouch = /^touch/.test(e.type),
  7736. x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0,
  7737. y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;
  7738. if ((space || moved) && x === dx && y === dy) {
  7739. self.setHand(x, y);
  7740. }
  7741. if (self.currentView === 'hours') {
  7742. self.toggleView('minutes', duration / 2);
  7743. } else if (options.autoclose) {
  7744. self.minutesView.addClass('clockpicker-dial-out');
  7745. setTimeout(function () {
  7746. self.done();
  7747. }, duration / 2);
  7748. }
  7749. plate.prepend(canvas);
  7750. // Reset cursor style of body
  7751. clearTimeout(movingTimer);
  7752. self.popover.removeClass('clockpicker-moving');
  7753. // Unbind mousemove event
  7754. $doc.off(mousemoveEvent);
  7755. });
  7756. }
  7757. if (svgSupported) {
  7758. // Draw clock hands and others
  7759. var canvas = popover.find('.clockpicker-canvas'),
  7760. svg = createSvgElement('svg');
  7761. svg.setAttribute('class', 'clockpicker-svg');
  7762. svg.setAttribute('width', diameter);
  7763. svg.setAttribute('height', diameter);
  7764. var g = createSvgElement('g');
  7765. g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')');
  7766. var bearing = createSvgElement('circle');
  7767. bearing.setAttribute('class', 'clockpicker-canvas-bearing');
  7768. bearing.setAttribute('cx', 0);
  7769. bearing.setAttribute('cy', 0);
  7770. bearing.setAttribute('r', 4);
  7771. var hand = createSvgElement('line');
  7772. hand.setAttribute('x1', 0);
  7773. hand.setAttribute('y1', 0);
  7774. var bg = createSvgElement('circle');
  7775. bg.setAttribute('class', 'clockpicker-canvas-bg');
  7776. bg.setAttribute('r', tickRadius);
  7777. g.appendChild(hand);
  7778. g.appendChild(bg);
  7779. g.appendChild(bearing);
  7780. svg.appendChild(g);
  7781. canvas.append(svg);
  7782. this.hand = hand;
  7783. this.bg = bg;
  7784. this.bearing = bearing;
  7785. this.g = g;
  7786. this.canvas = canvas;
  7787. }
  7788. raiseCallback(this.options.init);
  7789. }
  7790. function raiseCallback(callbackFunction) {
  7791. if (callbackFunction && typeof callbackFunction === "function") callbackFunction();
  7792. }
  7793. // Default options
  7794. ClockPicker.DEFAULTS = {
  7795. 'default': '', // default time, 'now' or '13:14' e.g.
  7796. fromnow: 0, // set default time to * milliseconds from now (using with default = 'now')
  7797. donetext: 'Ok', // done button text
  7798. cleartext: 'Clear',
  7799. canceltext: 'Cancel',
  7800. autoclose: false, // auto close when minute is selected
  7801. ampmclickable: true, // set am/pm button on itself
  7802. darktheme: false, // set to dark theme
  7803. twelvehour: true, // change to 12 hour AM/PM clock from 24 hour
  7804. vibrate: true // vibrate the device when dragging clock hand
  7805. };
  7806. // Show or hide popover
  7807. ClockPicker.prototype.toggle = function () {
  7808. this[this.isShown ? 'hide' : 'show']();
  7809. };
  7810. // Set popover position
  7811. ClockPicker.prototype.locate = function () {
  7812. var element = this.element,
  7813. popover = this.popover,
  7814. offset = element.offset(),
  7815. width = element.outerWidth(),
  7816. height = element.outerHeight(),
  7817. align = this.options.align,
  7818. self = this;
  7819. popover.show();
  7820. };
  7821. // Show popover
  7822. ClockPicker.prototype.show = function (e) {
  7823. // Not show again
  7824. if (this.isShown) {
  7825. return;
  7826. }
  7827. raiseCallback(this.options.beforeShow);
  7828. $(':input').each(function () {
  7829. $(this).attr('tabindex', -1);
  7830. });
  7831. var self = this;
  7832. // Initialize
  7833. this.input.blur();
  7834. this.popover.addClass('picker--opened');
  7835. this.input.addClass('picker__input picker__input--active');
  7836. $(document.body).css('overflow', 'hidden');
  7837. // Get the time
  7838. var value = ((this.input.prop('value') || this.options['default'] || '') + '').split(':');
  7839. if (this.options.twelvehour && !(typeof value[1] === 'undefined')) {
  7840. if (value[1].indexOf("AM") > 0) {
  7841. this.amOrPm = 'AM';
  7842. } else {
  7843. this.amOrPm = 'PM';
  7844. }
  7845. value[1] = value[1].replace("AM", "").replace("PM", "");
  7846. }
  7847. if (value[0] === 'now') {
  7848. var now = new Date(+new Date() + this.options.fromnow);
  7849. value = [now.getHours(), now.getMinutes()];
  7850. if (this.options.twelvehour) {
  7851. this.amOrPm = value[0] >= 12 && value[0] < 24 ? 'PM' : 'AM';
  7852. }
  7853. }
  7854. this.hours = +value[0] || 0;
  7855. this.minutes = +value[1] || 0;
  7856. this.spanHours.html(this.hours);
  7857. this.spanMinutes.html(leadingZero(this.minutes));
  7858. if (!this.isAppended) {
  7859. // Append popover to input by default
  7860. var containerEl = document.querySelector(this.options.container);
  7861. if (this.options.container && containerEl) {
  7862. containerEl.appendChild(this.popover[0]);
  7863. } else {
  7864. this.popover.insertAfter(this.input);
  7865. }
  7866. if (this.options.twelvehour) {
  7867. if (this.amOrPm === 'PM') {
  7868. this.spanAmPm.children('#click-pm').addClass("text-primary");
  7869. this.spanAmPm.children('#click-am').removeClass("text-primary");
  7870. } else {
  7871. this.spanAmPm.children('#click-am').addClass("text-primary");
  7872. this.spanAmPm.children('#click-pm').removeClass("text-primary");
  7873. }
  7874. }
  7875. // Reset position when resize
  7876. $win.on('resize.clockpicker' + this.id, function () {
  7877. if (self.isShown) {
  7878. self.locate();
  7879. }
  7880. });
  7881. this.isAppended = true;
  7882. }
  7883. // Toggle to hours view
  7884. this.toggleView('hours');
  7885. // Set position
  7886. this.locate();
  7887. this.isShown = true;
  7888. // Hide when clicking or tabbing on any element except the clock and input
  7889. $doc.on('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id, function (e) {
  7890. var target = $(e.target);
  7891. if (target.closest(self.popover.find('.picker__wrap')).length === 0 && target.closest(self.input).length === 0) {
  7892. self.hide();
  7893. }
  7894. });
  7895. // Hide when ESC is pressed
  7896. $doc.on('keyup.clockpicker.' + this.id, function (e) {
  7897. if (e.keyCode === 27) {
  7898. self.hide();
  7899. }
  7900. });
  7901. raiseCallback(this.options.afterShow);
  7902. };
  7903. // Hide popover
  7904. ClockPicker.prototype.hide = function () {
  7905. raiseCallback(this.options.beforeHide);
  7906. this.input.removeClass('picker__input picker__input--active');
  7907. this.popover.removeClass('picker--opened');
  7908. $(document.body).css('overflow', 'visible');
  7909. this.isShown = false;
  7910. $(':input').each(function (index) {
  7911. $(this).attr('tabindex', index + 1);
  7912. });
  7913. // Unbinding events on document
  7914. $doc.off('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id);
  7915. $doc.off('keyup.clockpicker.' + this.id);
  7916. this.popover.hide();
  7917. raiseCallback(this.options.afterHide);
  7918. };
  7919. // Toggle to hours or minutes view
  7920. ClockPicker.prototype.toggleView = function (view, delay) {
  7921. var raiseAfterHourSelect = false;
  7922. if (view === 'minutes' && $(this.hoursView).css("visibility") === "visible") {
  7923. raiseCallback(this.options.beforeHourSelect);
  7924. raiseAfterHourSelect = true;
  7925. }
  7926. var isHours = view === 'hours',
  7927. nextView = isHours ? this.hoursView : this.minutesView,
  7928. hideView = isHours ? this.minutesView : this.hoursView;
  7929. this.currentView = view;
  7930. this.spanHours.toggleClass('text-primary', isHours);
  7931. this.spanMinutes.toggleClass('text-primary', !isHours);
  7932. // Let's make transitions
  7933. hideView.addClass('clockpicker-dial-out');
  7934. nextView.css('visibility', 'visible').removeClass('clockpicker-dial-out');
  7935. // Reset clock hand
  7936. this.resetClock(delay);
  7937. // After transitions ended
  7938. clearTimeout(this.toggleViewTimer);
  7939. this.toggleViewTimer = setTimeout(function () {
  7940. hideView.css('visibility', 'hidden');
  7941. }, duration);
  7942. if (raiseAfterHourSelect) {
  7943. raiseCallback(this.options.afterHourSelect);
  7944. }
  7945. };
  7946. // Reset clock hand
  7947. ClockPicker.prototype.resetClock = function (delay) {
  7948. var view = this.currentView,
  7949. value = this[view],
  7950. isHours = view === 'hours',
  7951. unit = Math.PI / (isHours ? 6 : 30),
  7952. radian = value * unit,
  7953. radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius,
  7954. x = Math.sin(radian) * radius,
  7955. y = -Math.cos(radian) * radius,
  7956. self = this;
  7957. if (svgSupported && delay) {
  7958. self.canvas.addClass('clockpicker-canvas-out');
  7959. setTimeout(function () {
  7960. self.canvas.removeClass('clockpicker-canvas-out');
  7961. self.setHand(x, y);
  7962. }, delay);
  7963. } else this.setHand(x, y);
  7964. };
  7965. // Set clock hand to (x, y)
  7966. ClockPicker.prototype.setHand = function (x, y, roundBy5, dragging) {
  7967. var radian = Math.atan2(x, -y),
  7968. isHours = this.currentView === 'hours',
  7969. unit = Math.PI / (isHours || roundBy5 ? 6 : 30),
  7970. z = Math.sqrt(x * x + y * y),
  7971. options = this.options,
  7972. inner = isHours && z < (outerRadius + innerRadius) / 2,
  7973. radius = inner ? innerRadius : outerRadius,
  7974. value;
  7975. if (options.twelvehour) {
  7976. radius = outerRadius;
  7977. }
  7978. // Radian should in range [0, 2PI]
  7979. if (radian < 0) {
  7980. radian = Math.PI * 2 + radian;
  7981. }
  7982. // Get the round value
  7983. value = Math.round(radian / unit);
  7984. // Get the round radian
  7985. radian = value * unit;
  7986. // Correct the hours or minutes
  7987. if (options.twelvehour) {
  7988. if (isHours) {
  7989. if (value === 0) value = 12;
  7990. } else {
  7991. if (roundBy5) value *= 5;
  7992. if (value === 60) value = 0;
  7993. }
  7994. } else {
  7995. if (isHours) {
  7996. if (value === 12) value = 0;
  7997. value = inner ? value === 0 ? 12 : value : value === 0 ? 0 : value + 12;
  7998. } else {
  7999. if (roundBy5) value *= 5;
  8000. if (value === 60) value = 0;
  8001. }
  8002. }
  8003. // Once hours or minutes changed, vibrate the device
  8004. if (this[this.currentView] !== value) {
  8005. if (vibrate && this.options.vibrate) {
  8006. // Do not vibrate too frequently
  8007. if (!this.vibrateTimer) {
  8008. navigator[vibrate](10);
  8009. this.vibrateTimer = setTimeout($.proxy(function () {
  8010. this.vibrateTimer = null;
  8011. }, this), 100);
  8012. }
  8013. }
  8014. }
  8015. this[this.currentView] = value;
  8016. if (isHours) {
  8017. this['spanHours'].html(value);
  8018. } else {
  8019. this['spanMinutes'].html(leadingZero(value));
  8020. }
  8021. // If svg is not supported, just add an active class to the tick
  8022. if (!svgSupported) {
  8023. this[isHours ? 'hoursView' : 'minutesView'].find('.clockpicker-tick').each(function () {
  8024. var tick = $(this);
  8025. tick.toggleClass('active', value === +tick.html());
  8026. });
  8027. return;
  8028. }
  8029. // Set clock hand and others' position
  8030. var cx1 = Math.sin(radian) * (radius - tickRadius),
  8031. cy1 = -Math.cos(radian) * (radius - tickRadius),
  8032. cx2 = Math.sin(radian) * radius,
  8033. cy2 = -Math.cos(radian) * radius;
  8034. this.hand.setAttribute('x2', cx1);
  8035. this.hand.setAttribute('y2', cy1);
  8036. this.bg.setAttribute('cx', cx2);
  8037. this.bg.setAttribute('cy', cy2);
  8038. };
  8039. // Hours and minutes are selected
  8040. ClockPicker.prototype.done = function () {
  8041. raiseCallback(this.options.beforeDone);
  8042. this.hide();
  8043. this.label.addClass('active');
  8044. var last = this.input.prop('value'),
  8045. value = leadingZero(this.hours) + ':' + leadingZero(this.minutes);
  8046. if (this.options.twelvehour) {
  8047. value = value + this.amOrPm;
  8048. }
  8049. this.input.prop('value', value);
  8050. if (value !== last) {
  8051. this.input.triggerHandler('change');
  8052. if (!this.isInput) {
  8053. this.element.trigger('change');
  8054. }
  8055. }
  8056. if (this.options.autoclose) this.input.trigger('blur');
  8057. raiseCallback(this.options.afterDone);
  8058. };
  8059. // Clear input field
  8060. ClockPicker.prototype.clear = function () {
  8061. this.hide();
  8062. this.label.removeClass('active');
  8063. var last = this.input.prop('value'),
  8064. value = '';
  8065. this.input.prop('value', value);
  8066. if (value !== last) {
  8067. this.input.triggerHandler('change');
  8068. if (!this.isInput) {
  8069. this.element.trigger('change');
  8070. }
  8071. }
  8072. if (this.options.autoclose) {
  8073. this.input.trigger('blur');
  8074. }
  8075. };
  8076. // Remove clockpicker from input
  8077. ClockPicker.prototype.remove = function () {
  8078. this.element.removeData('clockpicker');
  8079. this.input.off('focus.clockpicker click.clockpicker');
  8080. if (this.isShown) {
  8081. this.hide();
  8082. }
  8083. if (this.isAppended) {
  8084. $win.off('resize.clockpicker' + this.id);
  8085. this.popover.remove();
  8086. }
  8087. };
  8088. // Extends $.fn.clockpicker
  8089. $.fn.pickatime = function (option) {
  8090. var args = Array.prototype.slice.call(arguments, 1);
  8091. return this.each(function () {
  8092. var $this = $(this),
  8093. data = $this.data('clockpicker');
  8094. if (!data) {
  8095. var options = $.extend({}, ClockPicker.DEFAULTS, $this.data(), typeof option == 'object' && option);
  8096. $this.data('clockpicker', new ClockPicker($this, options));
  8097. } else {
  8098. // Manual operatsions. show, hide, remove, e.g.
  8099. if (typeof data[option] === 'function') {
  8100. data[option].apply(data, args);
  8101. }
  8102. }
  8103. });
  8104. };
  8105. })(jQuery);
  8106. ; (function ($) {
  8107. $.fn.characterCounter = function () {
  8108. return this.each(function () {
  8109. var $input = $(this);
  8110. var $counterElement = $input.parent().find('span[class="character-counter"]');
  8111. // character counter has already been added appended to the parent container
  8112. if ($counterElement.length) {
  8113. return;
  8114. }
  8115. var itHasLengthAttribute = $input.attr('data-length') !== undefined;
  8116. if (itHasLengthAttribute) {
  8117. $input.on('input', updateCounter);
  8118. $input.on('focus', updateCounter);
  8119. $input.on('blur', removeCounterElement);
  8120. addCounterElement($input);
  8121. }
  8122. });
  8123. };
  8124. function updateCounter() {
  8125. var maxLength = +$(this).attr('data-length'),
  8126. actualLength = +$(this).val().length,
  8127. isValidLength = actualLength <= maxLength;
  8128. $(this).parent().find('span[class="character-counter"]').html(actualLength + '/' + maxLength);
  8129. addInputStyle(isValidLength, $(this));
  8130. }
  8131. function addCounterElement($input) {
  8132. var $counterElement = $input.parent().find('span[class="character-counter"]');
  8133. if ($counterElement.length) {
  8134. return;
  8135. }
  8136. $counterElement = $('<span/>').addClass('character-counter').css('float', 'right').css('font-size', '12px').css('height', 1);
  8137. $input.parent().append($counterElement);
  8138. }
  8139. function removeCounterElement() {
  8140. $(this).parent().find('span[class="character-counter"]').html('');
  8141. }
  8142. function addInputStyle(isValidLength, $input) {
  8143. var inputHasInvalidClass = $input.hasClass('invalid');
  8144. if (isValidLength && inputHasInvalidClass) {
  8145. $input.removeClass('invalid');
  8146. } else if (!isValidLength && !inputHasInvalidClass) {
  8147. $input.removeClass('valid');
  8148. $input.addClass('invalid');
  8149. }
  8150. }
  8151. $(document).ready(function () {
  8152. $('input, textarea').characterCounter();
  8153. });
  8154. })(jQuery);
  8155. ; (function ($) {
  8156. var methods = {
  8157. init: function (options) {
  8158. var defaults = {
  8159. duration: 200, // ms
  8160. dist: -100, // zoom scale TODO: make this more intuitive as an option
  8161. shift: 0, // spacing for center image
  8162. padding: 0, // Padding between non center items
  8163. fullWidth: false, // Change to full width styles
  8164. indicators: false, // Toggle indicators
  8165. noWrap: false, // Don't wrap around and cycle through items.
  8166. onCycleTo: null // Callback for when a new slide is cycled to.
  8167. };
  8168. options = $.extend(defaults, options);
  8169. var namespace = Materialize.objectSelectorString($(this));
  8170. return this.each(function (i) {
  8171. var images, item_width, item_height, offset, center, pressed, dim, count, reference, referenceY, amplitude, target, velocity, scrolling, xform, frame, timestamp, ticker, dragged, vertical_dragged;
  8172. var $indicators = $('<ul class="indicators"></ul>');
  8173. var scrollingTimeout = null;
  8174. var oneTimeCallback = null;
  8175. // Initialize
  8176. var view = $(this);
  8177. var hasMultipleSlides = view.find('.carousel-item').length > 1;
  8178. var showIndicators = (view.attr('data-indicators') || options.indicators) && hasMultipleSlides;
  8179. var noWrap = view.attr('data-no-wrap') || options.noWrap || !hasMultipleSlides;
  8180. var uniqueNamespace = view.attr('data-namespace') || namespace + i;
  8181. view.attr('data-namespace', uniqueNamespace);
  8182. // Options
  8183. var setCarouselHeight = function (imageOnly) {
  8184. var firstSlide = view.find('.carousel-item.active').length ? view.find('.carousel-item.active').first() : view.find('.carousel-item').first();
  8185. var firstImage = firstSlide.find('img').first();
  8186. if (firstImage.length) {
  8187. if (firstImage[0].complete) {
  8188. // If image won't trigger the load event
  8189. var imageHeight = firstImage.height();
  8190. if (imageHeight > 0) {
  8191. view.css('height', firstImage.height());
  8192. } else {
  8193. // If image still has no height, use the natural dimensions to calculate
  8194. var naturalWidth = firstImage[0].naturalWidth;
  8195. var naturalHeight = firstImage[0].naturalHeight;
  8196. var adjustedHeight = view.width() / naturalWidth * naturalHeight;
  8197. view.css('height', adjustedHeight);
  8198. }
  8199. } else {
  8200. // Get height when image is loaded normally
  8201. firstImage.on('load', function () {
  8202. view.css('height', $(this).height());
  8203. });
  8204. }
  8205. } else if (!imageOnly) {
  8206. var slideHeight = firstSlide.height();
  8207. view.css('height', slideHeight);
  8208. }
  8209. };
  8210. if (options.fullWidth) {
  8211. options.dist = 0;
  8212. setCarouselHeight();
  8213. // Offset fixed items when indicators.
  8214. if (showIndicators) {
  8215. view.find('.carousel-fixed-item').addClass('with-indicators');
  8216. }
  8217. }
  8218. // Don't double initialize.
  8219. if (view.hasClass('initialized')) {
  8220. // Recalculate variables
  8221. $(window).trigger('resize');
  8222. // Redraw carousel.
  8223. view.trigger('carouselNext', [0.000001]);
  8224. return true;
  8225. }
  8226. view.addClass('initialized');
  8227. pressed = false;
  8228. offset = target = 0;
  8229. images = [];
  8230. item_width = view.find('.carousel-item').first().innerWidth();
  8231. item_height = view.find('.carousel-item').first().innerHeight();
  8232. dim = item_width * 2 + options.padding;
  8233. view.find('.carousel-item').each(function (i) {
  8234. images.push($(this)[0]);
  8235. if (showIndicators) {
  8236. var $indicator = $('<li class="indicator-item"></li>');
  8237. // Add active to first by default.
  8238. if (i === 0) {
  8239. $indicator.addClass('active');
  8240. }
  8241. // Handle clicks on indicators.
  8242. $indicator.click(function (e) {
  8243. e.stopPropagation();
  8244. var index = $(this).index();
  8245. cycleTo(index);
  8246. });
  8247. $indicators.append($indicator);
  8248. }
  8249. });
  8250. if (showIndicators) {
  8251. view.append($indicators);
  8252. }
  8253. count = images.length;
  8254. function setupEvents() {
  8255. if (typeof window.ontouchstart !== 'undefined') {
  8256. view.on('touchstart.carousel', tap);
  8257. view.on('touchmove.carousel', drag);
  8258. view.on('touchend.carousel', release);
  8259. }
  8260. view.on('mousedown.carousel', tap);
  8261. view.on('mousemove.carousel', drag);
  8262. view.on('mouseup.carousel', release);
  8263. view.on('mouseleave.carousel', release);
  8264. view.on('click.carousel', click);
  8265. }
  8266. function xpos(e) {
  8267. // touch event
  8268. if (e.targetTouches && e.targetTouches.length >= 1) {
  8269. return e.targetTouches[0].clientX;
  8270. }
  8271. // mouse event
  8272. return e.clientX;
  8273. }
  8274. function ypos(e) {
  8275. // touch event
  8276. if (e.targetTouches && e.targetTouches.length >= 1) {
  8277. return e.targetTouches[0].clientY;
  8278. }
  8279. // mouse event
  8280. return e.clientY;
  8281. }
  8282. function wrap(x) {
  8283. return x >= count ? x % count : x < 0 ? wrap(count + x % count) : x;
  8284. }
  8285. function scroll(x) {
  8286. // Track scrolling state
  8287. scrolling = true;
  8288. if (!view.hasClass('scrolling')) {
  8289. view.addClass('scrolling');
  8290. }
  8291. if (scrollingTimeout != null) {
  8292. window.clearTimeout(scrollingTimeout);
  8293. }
  8294. scrollingTimeout = window.setTimeout(function () {
  8295. scrolling = false;
  8296. view.removeClass('scrolling');
  8297. }, options.duration);
  8298. // Start actual scroll
  8299. var i, half, delta, dir, tween, el, alignment, xTranslation;
  8300. var lastCenter = center;
  8301. offset = typeof x === 'number' ? x : offset;
  8302. center = Math.floor((offset + dim / 2) / dim);
  8303. delta = offset - center * dim;
  8304. dir = delta < 0 ? 1 : -1;
  8305. tween = -dir * delta * 2 / dim;
  8306. half = count >> 1;
  8307. if (!options.fullWidth) {
  8308. alignment = 'translateX(' + (view[0].clientWidth - item_width) / 2 + 'px) ';
  8309. alignment += 'translateY(' + (view[0].clientHeight - item_height) / 2 + 'px)';
  8310. } else {
  8311. alignment = 'translateX(0)';
  8312. }
  8313. // Set indicator active
  8314. if (showIndicators) {
  8315. var diff = center % count;
  8316. var activeIndicator = $indicators.find('.indicator-item.active');
  8317. if (activeIndicator.index() !== diff) {
  8318. activeIndicator.removeClass('active');
  8319. $indicators.find('.indicator-item').eq(diff).addClass('active');
  8320. }
  8321. }
  8322. // center
  8323. // Don't show wrapped items.
  8324. if (!noWrap || center >= 0 && center < count) {
  8325. el = images[wrap(center)];
  8326. // Add active class to center item.
  8327. if (!$(el).hasClass('active')) {
  8328. view.find('.carousel-item').removeClass('active');
  8329. $(el).addClass('active');
  8330. }
  8331. el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween * i + 'px)' + ' translateZ(' + options.dist * tween + 'px)';
  8332. el.style.zIndex = 0;
  8333. if (options.fullWidth) {
  8334. tweenedOpacity = 1;
  8335. } else {
  8336. tweenedOpacity = 1 - 0.2 * tween;
  8337. }
  8338. el.style.opacity = tweenedOpacity;
  8339. el.style.display = 'block';
  8340. }
  8341. for (i = 1; i <= half; ++i) {
  8342. // right side
  8343. if (options.fullWidth) {
  8344. zTranslation = options.dist;
  8345. tweenedOpacity = i === half && delta < 0 ? 1 - tween : 1;
  8346. } else {
  8347. zTranslation = options.dist * (i * 2 + tween * dir);
  8348. tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir);
  8349. }
  8350. // Don't show wrapped items.
  8351. if (!noWrap || center + i < count) {
  8352. el = images[wrap(center + i)];
  8353. el.style[xform] = alignment + ' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)';
  8354. el.style.zIndex = -i;
  8355. el.style.opacity = tweenedOpacity;
  8356. el.style.display = 'block';
  8357. }
  8358. // left side
  8359. if (options.fullWidth) {
  8360. zTranslation = options.dist;
  8361. tweenedOpacity = i === half && delta > 0 ? 1 - tween : 1;
  8362. } else {
  8363. zTranslation = options.dist * (i * 2 - tween * dir);
  8364. tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir);
  8365. }
  8366. // Don't show wrapped items.
  8367. if (!noWrap || center - i >= 0) {
  8368. el = images[wrap(center - i)];
  8369. el.style[xform] = alignment + ' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)';
  8370. el.style.zIndex = -i;
  8371. el.style.opacity = tweenedOpacity;
  8372. el.style.display = 'block';
  8373. }
  8374. }
  8375. // center
  8376. // Don't show wrapped items.
  8377. if (!noWrap || center >= 0 && center < count) {
  8378. el = images[wrap(center)];
  8379. el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween + 'px)' + ' translateZ(' + options.dist * tween + 'px)';
  8380. el.style.zIndex = 0;
  8381. if (options.fullWidth) {
  8382. tweenedOpacity = 1;
  8383. } else {
  8384. tweenedOpacity = 1 - 0.2 * tween;
  8385. }
  8386. el.style.opacity = tweenedOpacity;
  8387. el.style.display = 'block';
  8388. }
  8389. // onCycleTo callback
  8390. if (lastCenter !== center && typeof options.onCycleTo === "function") {
  8391. var $curr_item = view.find('.carousel-item').eq(wrap(center));
  8392. options.onCycleTo.call(this, $curr_item, dragged);
  8393. }
  8394. // One time callback
  8395. if (typeof oneTimeCallback === "function") {
  8396. oneTimeCallback.call(this, $curr_item, dragged);
  8397. oneTimeCallback = null;
  8398. }
  8399. }
  8400. function track() {
  8401. var now, elapsed, delta, v;
  8402. now = Date.now();
  8403. elapsed = now - timestamp;
  8404. timestamp = now;
  8405. delta = offset - frame;
  8406. frame = offset;
  8407. v = 1000 * delta / (1 + elapsed);
  8408. velocity = 0.8 * v + 0.2 * velocity;
  8409. }
  8410. function autoScroll() {
  8411. var elapsed, delta;
  8412. if (amplitude) {
  8413. elapsed = Date.now() - timestamp;
  8414. delta = amplitude * Math.exp(-elapsed / options.duration);
  8415. if (delta > 2 || delta < -2) {
  8416. scroll(target - delta);
  8417. requestAnimationFrame(autoScroll);
  8418. } else {
  8419. scroll(target);
  8420. }
  8421. }
  8422. }
  8423. function click(e) {
  8424. // Disable clicks if carousel was dragged.
  8425. if (dragged) {
  8426. e.preventDefault();
  8427. e.stopPropagation();
  8428. return false;
  8429. } else if (!options.fullWidth) {
  8430. var clickedIndex = $(e.target).closest('.carousel-item').index();
  8431. var diff = wrap(center) - clickedIndex;
  8432. // Disable clicks if carousel was shifted by click
  8433. if (diff !== 0) {
  8434. e.preventDefault();
  8435. e.stopPropagation();
  8436. }
  8437. cycleTo(clickedIndex);
  8438. }
  8439. }
  8440. function cycleTo(n) {
  8441. var diff = center % count - n;
  8442. // Account for wraparound.
  8443. if (!noWrap) {
  8444. if (diff < 0) {
  8445. if (Math.abs(diff + count) < Math.abs(diff)) {
  8446. diff += count;
  8447. }
  8448. } else if (diff > 0) {
  8449. if (Math.abs(diff - count) < diff) {
  8450. diff -= count;
  8451. }
  8452. }
  8453. }
  8454. // Call prev or next accordingly.
  8455. if (diff < 0) {
  8456. view.trigger('carouselNext', [Math.abs(diff)]);
  8457. } else if (diff > 0) {
  8458. view.trigger('carouselPrev', [diff]);
  8459. }
  8460. }
  8461. function tap(e) {
  8462. // Fixes firefox draggable image bug
  8463. if (e.type === 'mousedown' && $(e.target).is('img')) {
  8464. e.preventDefault();
  8465. }
  8466. pressed = true;
  8467. dragged = false;
  8468. vertical_dragged = false;
  8469. reference = xpos(e);
  8470. referenceY = ypos(e);
  8471. velocity = amplitude = 0;
  8472. frame = offset;
  8473. timestamp = Date.now();
  8474. clearInterval(ticker);
  8475. ticker = setInterval(track, 100);
  8476. }
  8477. function drag(e) {
  8478. var x, delta, deltaY;
  8479. if (pressed) {
  8480. x = xpos(e);
  8481. y = ypos(e);
  8482. delta = reference - x;
  8483. deltaY = Math.abs(referenceY - y);
  8484. if (deltaY < 30 && !vertical_dragged) {
  8485. // If vertical scrolling don't allow dragging.
  8486. if (delta > 2 || delta < -2) {
  8487. dragged = true;
  8488. reference = x;
  8489. scroll(offset + delta);
  8490. }
  8491. } else if (dragged) {
  8492. // If dragging don't allow vertical scroll.
  8493. e.preventDefault();
  8494. e.stopPropagation();
  8495. return false;
  8496. } else {
  8497. // Vertical scrolling.
  8498. vertical_dragged = true;
  8499. }
  8500. }
  8501. if (dragged) {
  8502. // If dragging don't allow vertical scroll.
  8503. e.preventDefault();
  8504. e.stopPropagation();
  8505. return false;
  8506. }
  8507. }
  8508. function release(e) {
  8509. if (pressed) {
  8510. pressed = false;
  8511. } else {
  8512. return;
  8513. }
  8514. clearInterval(ticker);
  8515. target = offset;
  8516. if (velocity > 10 || velocity < -10) {
  8517. amplitude = 0.9 * velocity;
  8518. target = offset + amplitude;
  8519. }
  8520. target = Math.round(target / dim) * dim;
  8521. // No wrap of items.
  8522. if (noWrap) {
  8523. if (target >= dim * (count - 1)) {
  8524. target = dim * (count - 1);
  8525. } else if (target < 0) {
  8526. target = 0;
  8527. }
  8528. }
  8529. amplitude = target - offset;
  8530. timestamp = Date.now();
  8531. requestAnimationFrame(autoScroll);
  8532. if (dragged) {
  8533. e.preventDefault();
  8534. e.stopPropagation();
  8535. }
  8536. return false;
  8537. }
  8538. xform = 'transform';
  8539. ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) {
  8540. var e = prefix + 'Transform';
  8541. if (typeof document.body.style[e] !== 'undefined') {
  8542. xform = e;
  8543. return false;
  8544. }
  8545. return true;
  8546. });
  8547. var throttledResize = Materialize.throttle(function () {
  8548. if (options.fullWidth) {
  8549. item_width = view.find('.carousel-item').first().innerWidth();
  8550. var imageHeight = view.find('.carousel-item.active').height();
  8551. dim = item_width * 2 + options.padding;
  8552. offset = center * 2 * item_width;
  8553. target = offset;
  8554. setCarouselHeight(true);
  8555. } else {
  8556. scroll();
  8557. }
  8558. }, 200);
  8559. $(window).off('resize.carousel-' + uniqueNamespace).on('resize.carousel-' + uniqueNamespace, throttledResize);
  8560. setupEvents();
  8561. scroll(offset);
  8562. $(this).on('carouselNext', function (e, n, callback) {
  8563. if (n === undefined) {
  8564. n = 1;
  8565. }
  8566. if (typeof callback === "function") {
  8567. oneTimeCallback = callback;
  8568. }
  8569. target = dim * Math.round(offset / dim) + dim * n;
  8570. if (offset !== target) {
  8571. amplitude = target - offset;
  8572. timestamp = Date.now();
  8573. requestAnimationFrame(autoScroll);
  8574. }
  8575. });
  8576. $(this).on('carouselPrev', function (e, n, callback) {
  8577. if (n === undefined) {
  8578. n = 1;
  8579. }
  8580. if (typeof callback === "function") {
  8581. oneTimeCallback = callback;
  8582. }
  8583. target = dim * Math.round(offset / dim) - dim * n;
  8584. if (offset !== target) {
  8585. amplitude = target - offset;
  8586. timestamp = Date.now();
  8587. requestAnimationFrame(autoScroll);
  8588. }
  8589. });
  8590. $(this).on('carouselSet', function (e, n, callback) {
  8591. if (n === undefined) {
  8592. n = 0;
  8593. }
  8594. if (typeof callback === "function") {
  8595. oneTimeCallback = callback;
  8596. }
  8597. cycleTo(n);
  8598. });
  8599. });
  8600. },
  8601. next: function (n, callback) {
  8602. $(this).trigger('carouselNext', [n, callback]);
  8603. },
  8604. prev: function (n, callback) {
  8605. $(this).trigger('carouselPrev', [n, callback]);
  8606. },
  8607. set: function (n, callback) {
  8608. $(this).trigger('carouselSet', [n, callback]);
  8609. },
  8610. destroy: function () {
  8611. var uniqueNamespace = $(this).attr('data-namespace');
  8612. $(this).removeAttr('data-namespace');
  8613. $(this).removeClass('initialized');
  8614. $(this).find('.indicators').remove();
  8615. // Remove event handlers
  8616. $(this).off('carouselNext carouselPrev carouselSet');
  8617. $(window).off('resize.carousel-' + uniqueNamespace);
  8618. if (typeof window.ontouchstart !== 'undefined') {
  8619. $(this).off('touchstart.carousel touchmove.carousel touchend.carousel');
  8620. }
  8621. $(this).off('mousedown.carousel mousemove.carousel mouseup.carousel mouseleave.carousel click.carousel');
  8622. }
  8623. };
  8624. $.fn.carousel = function (methodOrOptions) {
  8625. if (methods[methodOrOptions]) {
  8626. return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
  8627. } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
  8628. // Default to "init"
  8629. return methods.init.apply(this, arguments);
  8630. } else {
  8631. $.error('Method ' + methodOrOptions + ' does not exist on jQuery.carousel');
  8632. }
  8633. }; // Plugin end
  8634. })(jQuery);
  8635. ; (function ($) {
  8636. var methods = {
  8637. init: function (options) {
  8638. return this.each(function () {
  8639. var origin = $('#' + $(this).attr('data-activates'));
  8640. var screen = $('body');
  8641. // Creating tap target
  8642. var tapTargetEl = $(this);
  8643. var tapTargetWrapper = tapTargetEl.parent('.tap-target-wrapper');
  8644. var tapTargetWave = tapTargetWrapper.find('.tap-target-wave');
  8645. var tapTargetOriginEl = tapTargetWrapper.find('.tap-target-origin');
  8646. var tapTargetContentEl = tapTargetEl.find('.tap-target-content');
  8647. // Creating wrapper
  8648. if (!tapTargetWrapper.length) {
  8649. tapTargetWrapper = tapTargetEl.wrap($('<div class="tap-target-wrapper"></div>')).parent();
  8650. }
  8651. // Creating content
  8652. if (!tapTargetContentEl.length) {
  8653. tapTargetContentEl = $('<div class="tap-target-content"></div>');
  8654. tapTargetEl.append(tapTargetContentEl);
  8655. }
  8656. // Creating foreground wave
  8657. if (!tapTargetWave.length) {
  8658. tapTargetWave = $('<div class="tap-target-wave"></div>');
  8659. // Creating origin
  8660. if (!tapTargetOriginEl.length) {
  8661. tapTargetOriginEl = origin.clone(true, true);
  8662. tapTargetOriginEl.addClass('tap-target-origin');
  8663. tapTargetOriginEl.removeAttr('id');
  8664. tapTargetOriginEl.removeAttr('style');
  8665. tapTargetWave.append(tapTargetOriginEl);
  8666. }
  8667. tapTargetWrapper.append(tapTargetWave);
  8668. }
  8669. // Open
  8670. var openTapTarget = function () {
  8671. if (tapTargetWrapper.is('.open')) {
  8672. return;
  8673. }
  8674. // Adding open class
  8675. tapTargetWrapper.addClass('open');
  8676. setTimeout(function () {
  8677. tapTargetOriginEl.off('click.tapTarget').on('click.tapTarget', function (e) {
  8678. closeTapTarget();
  8679. tapTargetOriginEl.off('click.tapTarget');
  8680. });
  8681. $(document).off('click.tapTarget').on('click.tapTarget', function (e) {
  8682. closeTapTarget();
  8683. $(document).off('click.tapTarget');
  8684. });
  8685. var throttledCalc = Materialize.throttle(function () {
  8686. calculateTapTarget();
  8687. }, 200);
  8688. $(window).off('resize.tapTarget').on('resize.tapTarget', throttledCalc);
  8689. }, 0);
  8690. };
  8691. // Close
  8692. var closeTapTarget = function () {
  8693. if (!tapTargetWrapper.is('.open')) {
  8694. return;
  8695. }
  8696. tapTargetWrapper.removeClass('open');
  8697. tapTargetOriginEl.off('click.tapTarget');
  8698. $(document).off('click.tapTarget');
  8699. $(window).off('resize.tapTarget');
  8700. };
  8701. // Pre calculate
  8702. var calculateTapTarget = function () {
  8703. // Element or parent is fixed position?
  8704. var isFixed = origin.css('position') === 'fixed';
  8705. if (!isFixed) {
  8706. var parents = origin.parents();
  8707. for (var i = 0; i < parents.length; i++) {
  8708. isFixed = $(parents[i]).css('position') == 'fixed';
  8709. if (isFixed) {
  8710. break;
  8711. }
  8712. }
  8713. }
  8714. // Calculating origin
  8715. var originWidth = origin.outerWidth();
  8716. var originHeight = origin.outerHeight();
  8717. var originTop = isFixed ? origin.offset().top - $(document).scrollTop() : origin.offset().top;
  8718. var originLeft = isFixed ? origin.offset().left - $(document).scrollLeft() : origin.offset().left;
  8719. // Calculating screen
  8720. var windowWidth = $(window).width();
  8721. var windowHeight = $(window).height();
  8722. var centerX = windowWidth / 2;
  8723. var centerY = windowHeight / 2;
  8724. var isLeft = originLeft <= centerX;
  8725. var isRight = originLeft > centerX;
  8726. var isTop = originTop <= centerY;
  8727. var isBottom = originTop > centerY;
  8728. var isCenterX = originLeft >= windowWidth * 0.25 && originLeft <= windowWidth * 0.75;
  8729. var isCenterY = originTop >= windowHeight * 0.25 && originTop <= windowHeight * 0.75;
  8730. // Calculating tap target
  8731. var tapTargetWidth = tapTargetEl.outerWidth();
  8732. var tapTargetHeight = tapTargetEl.outerHeight();
  8733. var tapTargetTop = originTop + originHeight / 2 - tapTargetHeight / 2;
  8734. var tapTargetLeft = originLeft + originWidth / 2 - tapTargetWidth / 2;
  8735. var tapTargetPosition = isFixed ? 'fixed' : 'absolute';
  8736. // Calculating content
  8737. var tapTargetTextWidth = isCenterX ? tapTargetWidth : tapTargetWidth / 2 + originWidth;
  8738. var tapTargetTextHeight = tapTargetHeight / 2;
  8739. var tapTargetTextTop = isTop ? tapTargetHeight / 2 : 0;
  8740. var tapTargetTextBottom = 0;
  8741. var tapTargetTextLeft = isLeft && !isCenterX ? tapTargetWidth / 2 - originWidth : 0;
  8742. var tapTargetTextRight = 0;
  8743. var tapTargetTextPadding = originWidth;
  8744. var tapTargetTextAlign = isBottom ? 'bottom' : 'top';
  8745. // Calculating wave
  8746. var tapTargetWaveWidth = originWidth > originHeight ? originWidth * 2 : originWidth * 2;
  8747. var tapTargetWaveHeight = tapTargetWaveWidth;
  8748. var tapTargetWaveTop = tapTargetHeight / 2 - tapTargetWaveHeight / 2;
  8749. var tapTargetWaveLeft = tapTargetWidth / 2 - tapTargetWaveWidth / 2;
  8750. // Setting tap target
  8751. var tapTargetWrapperCssObj = {};
  8752. tapTargetWrapperCssObj.top = isTop ? tapTargetTop : '';
  8753. tapTargetWrapperCssObj.right = isRight ? windowWidth - tapTargetLeft - tapTargetWidth : '';
  8754. tapTargetWrapperCssObj.bottom = isBottom ? windowHeight - tapTargetTop - tapTargetHeight : '';
  8755. tapTargetWrapperCssObj.left = isLeft ? tapTargetLeft : '';
  8756. tapTargetWrapperCssObj.position = tapTargetPosition;
  8757. tapTargetWrapper.css(tapTargetWrapperCssObj);
  8758. // Setting content
  8759. tapTargetContentEl.css({
  8760. width: tapTargetTextWidth,
  8761. height: tapTargetTextHeight,
  8762. top: tapTargetTextTop,
  8763. right: tapTargetTextRight,
  8764. bottom: tapTargetTextBottom,
  8765. left: tapTargetTextLeft,
  8766. padding: tapTargetTextPadding,
  8767. verticalAlign: tapTargetTextAlign
  8768. });
  8769. // Setting wave
  8770. tapTargetWave.css({
  8771. top: tapTargetWaveTop,
  8772. left: tapTargetWaveLeft,
  8773. width: tapTargetWaveWidth,
  8774. height: tapTargetWaveHeight
  8775. });
  8776. };
  8777. if (options == 'open') {
  8778. calculateTapTarget();
  8779. openTapTarget();
  8780. }
  8781. if (options == 'close') closeTapTarget();
  8782. });
  8783. },
  8784. open: function () { },
  8785. close: function () { }
  8786. };
  8787. $.fn.tapTarget = function (methodOrOptions) {
  8788. if (methods[methodOrOptions] || typeof methodOrOptions === 'object') return methods.init.apply(this, arguments);
  8789. $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tap-target');
  8790. };
  8791. })(jQuery);