materialize.js 367 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168
  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","none");
  4464. $("#refresh-press").css("display","none");
  4465. }
  4466. } else {
  4467. a1.className = a1.className.replace(a, "");
  4468. a2.className = a2.className.replace(a, "");
  4469. a3.className = a3.className.replace(a, "");
  4470. a4.className = a4.className.replace(a, "");
  4471. $("#refresh-disabled").css("display","none");
  4472. $("#refresh").css("display","block");
  4473. $("#refresh-press").css("display","none");
  4474. }
  4475. // Function that renders and appends the option taking into
  4476. // account type and possible image icon.
  4477. var appendOptionWithIcon = function (select, option, type) {
  4478. // Add disabled attr if disabled
  4479. var disabledClass = option.is(':disabled') ? 'disabled ' : '';
  4480. var optgroupClass = type === 'optgroup-option' ? 'optgroup-option ' : '';
  4481. var multipleCheckbox = multiple ? '<input type="checkbox"' + disabledClass + '/><label></label>' : '';
  4482. // add icons
  4483. var icon_url = option.data('icon');
  4484. var classes = option.attr('class');
  4485. if (!!icon_url) {
  4486. var classString = '';
  4487. if (!!classes) classString = ' class="' + classes + '"';
  4488. // Check for multiple type.
  4489. options.append($('<li class="' + disabledClass + optgroupClass + '"><img alt="" src="' + icon_url + '"' + classString + '><span>' + multipleCheckbox + option.html() + '</span></li>'));
  4490. return true;
  4491. }
  4492. // Check for multiple type.
  4493. options.append($('<li class="' + disabledClass + optgroupClass + '"><span>' + multipleCheckbox + option.html() + '</span></li>'));
  4494. };
  4495. /* Create dropdown structure. */
  4496. if (selectChildren.length) {
  4497. selectChildren.each(function () {
  4498. if ($(this).is('option')) {
  4499. // Direct descendant option.
  4500. if (multiple) {
  4501. appendOptionWithIcon($select, $(this), 'multiple');
  4502. } else {
  4503. appendOptionWithIcon($select, $(this));
  4504. }
  4505. } else if ($(this).is('optgroup')) {
  4506. // Optgroup.
  4507. var selectOptions = $(this).children('option');
  4508. options.append($('<li class="optgroup"><span>' + $(this).attr('label') + '</span></li>'));
  4509. selectOptions.each(function () {
  4510. appendOptionWithIcon($select, $(this), 'optgroup-option');
  4511. });
  4512. }
  4513. });
  4514. }
  4515. options.find('li:not(.optgroup)').each(function (i) {
  4516. $(this).click(function (e) {
  4517. // Check if option element is disabled
  4518. if (!$(this).hasClass('disabled') && !$(this).hasClass('optgroup')) {
  4519. var selected = true;
  4520. if (multiple) {
  4521. $('input[type="checkbox"]', this).prop('checked', function (i, v) {
  4522. return !v;
  4523. });
  4524. selected = toggleEntryFromArray(valuesSelected, i, $select);
  4525. $newSelect.trigger('focus');
  4526. } else {
  4527. options.find('li').removeClass('active');
  4528. $(this).toggleClass('active');
  4529. $newSelect.val($(this).text());
  4530. }
  4531. activateOption(options, $(this));
  4532. $select.find('option').eq(i).prop('selected', selected);
  4533. // Trigger onchange() event
  4534. $select.trigger('change');
  4535. if (typeof callback !== 'undefined') callback();
  4536. }
  4537. e.stopPropagation();
  4538. });
  4539. });
  4540. // Wrap Elements
  4541. $select.wrap(wrapper);
  4542. // Add Select Display Element
  4543. var dropdownIcon = $('<span class="caret">&#9660;</span>');
  4544. // escape double quotes
  4545. var sanitizedLabelHtml = label.replace(/"/g, '&quot;');
  4546. var $newSelect = $('<input type="text" class="select-dropdown" readonly="true" ' + ($select.is(':disabled') ? 'disabled' : '') + ' data-activates="select-options-' + uniqueID + '" value="' + sanitizedLabelHtml + '"/>');
  4547. $select.before($newSelect);
  4548. $newSelect.before(dropdownIcon);
  4549. $newSelect.after(options);
  4550. // Check if section element is disabled
  4551. if (!$select.is(':disabled')) {
  4552. $newSelect.dropdown({ 'hover': false });
  4553. }
  4554. // Copy tabindex
  4555. if ($select.attr('tabindex')) {
  4556. $($newSelect[0]).attr('tabindex', $select.attr('tabindex'));
  4557. }
  4558. $select.addClass('initialized');
  4559. $newSelect.on({
  4560. 'focus': function () {
  4561. if ($('ul.select-dropdown').not(options[0]).is(':visible')) {
  4562. $('input.select-dropdown').trigger('close');
  4563. $(window).off('click.select');
  4564. }
  4565. if (!options.is(':visible')) {
  4566. $(this).trigger('open', ['focus']);
  4567. var label = $(this).val();
  4568. if (multiple && label.indexOf(',') >= 0) {
  4569. label = label.split(',')[0];
  4570. }
  4571. var selectedOption = options.find('li').filter(function () {
  4572. return $(this).text().toLowerCase() === label.toLowerCase();
  4573. })[0];
  4574. activateOption(options, selectedOption, true);
  4575. $(window).off('click.select').on('click.select', function () {
  4576. multiple && (optionsHover || $newSelect.trigger('close'));
  4577. $(window).off('click.select');
  4578. });
  4579. }
  4580. },
  4581. 'click': function (e) {
  4582. e.stopPropagation();
  4583. }
  4584. });
  4585. $newSelect.on('blur', function () {
  4586. if (!multiple) {
  4587. $(this).trigger('close');
  4588. $(window).off('click.select');
  4589. }
  4590. options.find('li.selected').removeClass('selected');
  4591. });
  4592. options.hover(function () {
  4593. optionsHover = true;
  4594. }, function () {
  4595. optionsHover = false;
  4596. });
  4597. // Add initial multiple selections.
  4598. if (multiple) {
  4599. $select.find("option:selected:not(:disabled)").each(function () {
  4600. var index = this.index;
  4601. toggleEntryFromArray(valuesSelected, index, $select);
  4602. options.find("li:not(.optgroup)").eq(index).find(":checkbox").prop("checked", true);
  4603. });
  4604. }
  4605. /**
  4606. * Make option as selected and scroll to selected position
  4607. * @param {jQuery} collection Select options jQuery element
  4608. * @param {Element} newOption element of the new option
  4609. * @param {Boolean} firstActivation If on first activation of select
  4610. */
  4611. var activateOption = function (collection, newOption, firstActivation) {
  4612. if (newOption) {
  4613. collection.find('li.selected').removeClass('selected');
  4614. var option = $(newOption);
  4615. option.addClass('selected');
  4616. if (!multiple || !!firstActivation) {
  4617. options.scrollTo(option);
  4618. }
  4619. }
  4620. };
  4621. // Allow user to search by typing
  4622. // this array is cleared after 1 second
  4623. var filterQuery = [],
  4624. onKeyDown = function (e) {
  4625. // TAB - switch to another input
  4626. if (e.which == 9) {
  4627. $newSelect.trigger('close');
  4628. return;
  4629. }
  4630. // ARROW DOWN WHEN SELECT IS CLOSED - open select options
  4631. if (e.which == 40 && !options.is(':visible')) {
  4632. $newSelect.trigger('open');
  4633. return;
  4634. }
  4635. // ENTER WHEN SELECT IS CLOSED - submit form
  4636. if (e.which == 13 && !options.is(':visible')) {
  4637. return;
  4638. }
  4639. e.preventDefault();
  4640. // CASE WHEN USER TYPE LETTERS
  4641. var letter = String.fromCharCode(e.which).toLowerCase(),
  4642. nonLetters = [9, 13, 27, 38, 40];
  4643. if (letter && nonLetters.indexOf(e.which) === -1) {
  4644. filterQuery.push(letter);
  4645. var string = filterQuery.join(''),
  4646. newOption = options.find('li').filter(function () {
  4647. return $(this).text().toLowerCase().indexOf(string) === 0;
  4648. })[0];
  4649. if (newOption) {
  4650. activateOption(options, newOption);
  4651. }
  4652. }
  4653. // ENTER - select option and close when select options are opened
  4654. if (e.which == 13) {
  4655. var activeOption = options.find('li.selected:not(.disabled)')[0];
  4656. if (activeOption) {
  4657. $(activeOption).trigger('click');
  4658. if (!multiple) {
  4659. $newSelect.trigger('close');
  4660. }
  4661. }
  4662. }
  4663. // ARROW DOWN - move to next not disabled option
  4664. if (e.which == 40) {
  4665. if (options.find('li.selected').length) {
  4666. newOption = options.find('li.selected').next('li:not(.disabled)')[0];
  4667. } else {
  4668. newOption = options.find('li:not(.disabled)')[0];
  4669. }
  4670. activateOption(options, newOption);
  4671. }
  4672. // ESC - close options
  4673. if (e.which == 27) {
  4674. $newSelect.trigger('close');
  4675. }
  4676. // ARROW UP - move to previous not disabled option
  4677. if (e.which == 38) {
  4678. newOption = options.find('li.selected').prev('li:not(.disabled)')[0];
  4679. if (newOption) activateOption(options, newOption);
  4680. }
  4681. // Automaticaly clean filter query so user can search again by starting letters
  4682. setTimeout(function () {
  4683. filterQuery = [];
  4684. }, 1000);
  4685. };
  4686. $newSelect.on('keydown', onKeyDown);
  4687. });
  4688. function toggleEntryFromArray(entriesArray, entryIndex, select) {
  4689. var index = entriesArray.indexOf(entryIndex),
  4690. notAdded = index === -1;
  4691. if (notAdded) {
  4692. entriesArray.push(entryIndex);
  4693. } else {
  4694. entriesArray.splice(index, 1);
  4695. }
  4696. select.siblings('ul.dropdown-content').find('li:not(.optgroup)').eq(entryIndex).toggleClass('active');
  4697. // use notAdded instead of true (to detect if the option is selected or not)
  4698. select.find('option').eq(entryIndex).prop('selected', notAdded);
  4699. setValueToInput(entriesArray, select);
  4700. return notAdded;
  4701. }
  4702. function setValueToInput(entriesArray, select) {
  4703. var value = '';
  4704. for (var i = 0, count = entriesArray.length; i < count; i++) {
  4705. var text = select.find('option').eq(entriesArray[i]).text();
  4706. i === 0 ? value += text : value += ', ' + text;
  4707. }
  4708. if (value === '') {
  4709. value = select.find('option:disabled').eq(0).text();
  4710. }
  4711. select.siblings('input.select-dropdown').val(value);
  4712. }
  4713. };
  4714. })(jQuery);
  4715. ; (function ($) {
  4716. var methods = {
  4717. init: function (options) {
  4718. var defaults = {
  4719. indicators: true,
  4720. height: 400,
  4721. transition: 500,
  4722. interval: 6000
  4723. };
  4724. options = $.extend(defaults, options);
  4725. return this.each(function () {
  4726. // For each slider, we want to keep track of
  4727. // which slide is active and its associated content
  4728. var $this = $(this);
  4729. var $slider = $this.find('ul.slides').first();
  4730. var $slides = $slider.find('> li');
  4731. var $active_index = $slider.find('.active').index();
  4732. var $active, $indicators, $interval;
  4733. if ($active_index != -1) {
  4734. $active = $slides.eq($active_index);
  4735. }
  4736. // Transitions the caption depending on alignment
  4737. function captionTransition(caption, duration) {
  4738. if (caption.hasClass("center-align")) {
  4739. caption.velocity({ opacity: 0, translateY: -100 }, { duration: duration, queue: false });
  4740. } else if (caption.hasClass("right-align")) {
  4741. caption.velocity({ opacity: 0, translateX: 100 }, { duration: duration, queue: false });
  4742. } else if (caption.hasClass("left-align")) {
  4743. caption.velocity({ opacity: 0, translateX: -100 }, { duration: duration, queue: false });
  4744. }
  4745. }
  4746. // This function will transition the slide to any index of the next slide
  4747. function moveToSlide(index) {
  4748. // Wrap around indices.
  4749. if (index >= $slides.length) index = 0; else if (index < 0) index = $slides.length - 1;
  4750. $active_index = $slider.find('.active').index();
  4751. // Only do if index changes
  4752. if ($active_index != index) {
  4753. $active = $slides.eq($active_index);
  4754. $caption = $active.find('.caption');
  4755. $active.removeClass('active');
  4756. $active.velocity({ opacity: 0 }, {
  4757. duration: options.transition, queue: false, easing: 'easeOutQuad',
  4758. complete: function () {
  4759. $slides.not('.active').velocity({ opacity: 0, translateX: 0, translateY: 0 }, { duration: 0, queue: false });
  4760. }
  4761. });
  4762. captionTransition($caption, options.transition);
  4763. // Update indicators
  4764. if (options.indicators) {
  4765. $indicators.eq($active_index).removeClass('active');
  4766. }
  4767. $slides.eq(index).velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' });
  4768. $slides.eq(index).find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, delay: options.transition, queue: false, easing: 'easeOutQuad' });
  4769. $slides.eq(index).addClass('active');
  4770. // Update indicators
  4771. if (options.indicators) {
  4772. $indicators.eq(index).addClass('active');
  4773. }
  4774. }
  4775. }
  4776. // Set height of slider
  4777. // If fullscreen, do nothing
  4778. if (!$this.hasClass('fullscreen')) {
  4779. if (options.indicators) {
  4780. // Add height if indicators are present
  4781. $this.height(options.height + 40);
  4782. } else {
  4783. $this.height(options.height);
  4784. }
  4785. $slider.height(options.height);
  4786. }
  4787. // Set initial positions of captions
  4788. $slides.find('.caption').each(function () {
  4789. captionTransition($(this), 0);
  4790. });
  4791. // Move img src into background-image
  4792. $slides.find('img').each(function () {
  4793. var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
  4794. if ($(this).attr('src') !== placeholderBase64) {
  4795. $(this).css('background-image', 'url("' + $(this).attr('src') + '")');
  4796. $(this).attr('src', placeholderBase64);
  4797. }
  4798. });
  4799. // dynamically add indicators
  4800. if (options.indicators) {
  4801. $indicators = $('<ul class="indicators"></ul>');
  4802. $slides.each(function (index) {
  4803. var $indicator = $('<li class="indicator-item"></li>');
  4804. // Handle clicks on indicators
  4805. $indicator.click(function () {
  4806. var $parent = $slider.parent();
  4807. var curr_index = $parent.find($(this)).index();
  4808. moveToSlide(curr_index);
  4809. // reset interval
  4810. clearInterval($interval);
  4811. $interval = setInterval(function () {
  4812. $active_index = $slider.find('.active').index();
  4813. if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
  4814. else $active_index += 1;
  4815. moveToSlide($active_index);
  4816. }, options.transition + options.interval);
  4817. });
  4818. $indicators.append($indicator);
  4819. });
  4820. $this.append($indicators);
  4821. $indicators = $this.find('ul.indicators').find('li.indicator-item');
  4822. }
  4823. if ($active) {
  4824. $active.show();
  4825. } else {
  4826. $slides.first().addClass('active').velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' });
  4827. $active_index = 0;
  4828. $active = $slides.eq($active_index);
  4829. // Update indicators
  4830. if (options.indicators) {
  4831. $indicators.eq($active_index).addClass('active');
  4832. }
  4833. }
  4834. // Adjust height to current slide
  4835. $active.find('img').each(function () {
  4836. $active.find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' });
  4837. });
  4838. // auto scroll
  4839. $interval = setInterval(function () {
  4840. $active_index = $slider.find('.active').index();
  4841. moveToSlide($active_index + 1);
  4842. }, options.transition + options.interval);
  4843. // HammerJS, Swipe navigation
  4844. // Touch Event
  4845. var panning = false;
  4846. var swipeLeft = false;
  4847. var swipeRight = false;
  4848. $this.hammer({
  4849. prevent_default: false
  4850. }).on('pan', function (e) {
  4851. if (e.gesture.pointerType === "touch") {
  4852. // reset interval
  4853. clearInterval($interval);
  4854. var direction = e.gesture.direction;
  4855. var x = e.gesture.deltaX;
  4856. var velocityX = e.gesture.velocityX;
  4857. var velocityY = e.gesture.velocityY;
  4858. $curr_slide = $slider.find('.active');
  4859. if (Math.abs(velocityX) > Math.abs(velocityY)) {
  4860. $curr_slide.velocity({
  4861. translateX: x
  4862. }, { duration: 50, queue: false, easing: 'easeOutQuad' });
  4863. }
  4864. // Swipe Left
  4865. if (direction === 4 && (x > $this.innerWidth() / 2 || velocityX < -0.65)) {
  4866. swipeRight = true;
  4867. }
  4868. // Swipe Right
  4869. else if (direction === 2 && (x < -1 * $this.innerWidth() / 2 || velocityX > 0.65)) {
  4870. swipeLeft = true;
  4871. }
  4872. // Make Slide Behind active slide visible
  4873. var next_slide;
  4874. if (swipeLeft) {
  4875. next_slide = $curr_slide.next();
  4876. if (next_slide.length === 0) {
  4877. next_slide = $slides.first();
  4878. }
  4879. next_slide.velocity({
  4880. opacity: 1
  4881. }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  4882. }
  4883. if (swipeRight) {
  4884. next_slide = $curr_slide.prev();
  4885. if (next_slide.length === 0) {
  4886. next_slide = $slides.last();
  4887. }
  4888. next_slide.velocity({
  4889. opacity: 1
  4890. }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  4891. }
  4892. }
  4893. }).on('panend', function (e) {
  4894. if (e.gesture.pointerType === "touch") {
  4895. $curr_slide = $slider.find('.active');
  4896. panning = false;
  4897. curr_index = $slider.find('.active').index();
  4898. if (!swipeRight && !swipeLeft || $slides.length <= 1) {
  4899. // Return to original spot
  4900. $curr_slide.velocity({
  4901. translateX: 0
  4902. }, { duration: 300, queue: false, easing: 'easeOutQuad' });
  4903. } else if (swipeLeft) {
  4904. moveToSlide(curr_index + 1);
  4905. $curr_slide.velocity({ translateX: -1 * $this.innerWidth() }, {
  4906. duration: 300, queue: false, easing: 'easeOutQuad',
  4907. complete: function () {
  4908. $curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false });
  4909. }
  4910. });
  4911. } else if (swipeRight) {
  4912. moveToSlide(curr_index - 1);
  4913. $curr_slide.velocity({ translateX: $this.innerWidth() }, {
  4914. duration: 300, queue: false, easing: 'easeOutQuad',
  4915. complete: function () {
  4916. $curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false });
  4917. }
  4918. });
  4919. }
  4920. swipeLeft = false;
  4921. swipeRight = false;
  4922. // Restart interval
  4923. clearInterval($interval);
  4924. $interval = setInterval(function () {
  4925. $active_index = $slider.find('.active').index();
  4926. if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
  4927. else $active_index += 1;
  4928. moveToSlide($active_index);
  4929. }, options.transition + options.interval);
  4930. }
  4931. });
  4932. $this.on('sliderPause', function () {
  4933. clearInterval($interval);
  4934. });
  4935. $this.on('sliderStart', function () {
  4936. clearInterval($interval);
  4937. $interval = setInterval(function () {
  4938. $active_index = $slider.find('.active').index();
  4939. if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
  4940. else $active_index += 1;
  4941. moveToSlide($active_index);
  4942. }, options.transition + options.interval);
  4943. });
  4944. $this.on('sliderNext', function () {
  4945. $active_index = $slider.find('.active').index();
  4946. moveToSlide($active_index + 1);
  4947. });
  4948. $this.on('sliderPrev', function () {
  4949. $active_index = $slider.find('.active').index();
  4950. moveToSlide($active_index - 1);
  4951. });
  4952. });
  4953. },
  4954. pause: function () {
  4955. $(this).trigger('sliderPause');
  4956. },
  4957. start: function () {
  4958. $(this).trigger('sliderStart');
  4959. },
  4960. next: function () {
  4961. $(this).trigger('sliderNext');
  4962. },
  4963. prev: function () {
  4964. $(this).trigger('sliderPrev');
  4965. }
  4966. };
  4967. $.fn.slider = function (methodOrOptions) {
  4968. if (methods[methodOrOptions]) {
  4969. return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
  4970. } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
  4971. // Default to "init"
  4972. return methods.init.apply(this, arguments);
  4973. } else {
  4974. $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tooltip');
  4975. }
  4976. }; // Plugin end
  4977. })(jQuery);
  4978. ; (function ($) {
  4979. $(document).ready(function () {
  4980. $(document).on('click.card', '.card', function (e) {
  4981. if ($(this).find('> .card-reveal').length) {
  4982. var $card = $(e.target).closest('.card');
  4983. if ($card.data('initialOverflow') === undefined) {
  4984. $card.data('initialOverflow', $card.css('overflow') === undefined ? '' : $card.css('overflow'));
  4985. }
  4986. if ($(e.target).is($('.card-reveal .card-title>i'))) {
  4987. // Make Reveal animate down and display none
  4988. $(this).find('.card-reveal').velocity({ translateY: 0 }, {
  4989. duration: 225,
  4990. queue: false,
  4991. easing: 'easeInOutQuad',
  4992. complete: function () {
  4993. $(this).css({ display: 'none' });
  4994. $card.css('overflow', $card.data('initialOverflow'));
  4995. }
  4996. });
  4997. } else if ($(e.target).is($('.card .activator')) || $(e.target).is($('.card .activator i'))) {
  4998. $card.css('overflow', 'hidden');
  4999. $(this).find('.card-reveal').css({ display: 'block' }).velocity("stop", false).velocity({ translateY: '-100%' }, { duration: 300, queue: false, easing: 'easeInOutQuad' });
  5000. }
  5001. }
  5002. });
  5003. });
  5004. })(jQuery);
  5005. ; (function ($) {
  5006. var materialChipsDefaults = {
  5007. data: [],
  5008. placeholder: '',
  5009. secondaryPlaceholder: '',
  5010. autocompleteOptions: {}
  5011. };
  5012. $(document).ready(function () {
  5013. // Handle removal of static chips.
  5014. $(document).on('click', '.chip .close', function (e) {
  5015. var $chips = $(this).closest('.chips');
  5016. if ($chips.attr('data-initialized')) {
  5017. return;
  5018. }
  5019. $(this).closest('.chip').remove();
  5020. });
  5021. });
  5022. $.fn.material_chip = function (options) {
  5023. var self = this;
  5024. this.$el = $(this);
  5025. this.$document = $(document);
  5026. this.SELS = {
  5027. CHIPS: '.chips',
  5028. CHIP: '.chip',
  5029. INPUT: 'input',
  5030. DELETE: '.material-icons',
  5031. SELECTED_CHIP: '.selected'
  5032. };
  5033. if ('data' === options) {
  5034. return this.$el.data('chips');
  5035. }
  5036. var curr_options = $.extend({}, materialChipsDefaults, options);
  5037. self.hasAutocomplete = !$.isEmptyObject(curr_options.autocompleteOptions.data);
  5038. // Initialize
  5039. this.init = function () {
  5040. var i = 0;
  5041. var chips;
  5042. self.$el.each(function () {
  5043. var $chips = $(this);
  5044. var chipId = Materialize.guid();
  5045. self.chipId = chipId;
  5046. if (!curr_options.data || !(curr_options.data instanceof Array)) {
  5047. curr_options.data = [];
  5048. }
  5049. $chips.data('chips', curr_options.data);
  5050. $chips.attr('data-index', i);
  5051. $chips.attr('data-initialized', true);
  5052. if (!$chips.hasClass(self.SELS.CHIPS)) {
  5053. $chips.addClass('chips');
  5054. }
  5055. self.chips($chips, chipId);
  5056. i++;
  5057. });
  5058. };
  5059. this.handleEvents = function () {
  5060. var SELS = self.SELS;
  5061. self.$document.off('click.chips-focus', SELS.CHIPS).on('click.chips-focus', SELS.CHIPS, function (e) {
  5062. $(e.target).find(SELS.INPUT).focus();
  5063. });
  5064. self.$document.off('click.chips-select', SELS.CHIP).on('click.chips-select', SELS.CHIP, function (e) {
  5065. var $chip = $(e.target);
  5066. if ($chip.length) {
  5067. var wasSelected = $chip.hasClass('selected');
  5068. var $chips = $chip.closest(SELS.CHIPS);
  5069. $(SELS.CHIP).removeClass('selected');
  5070. if (!wasSelected) {
  5071. self.selectChip($chip.index(), $chips);
  5072. }
  5073. }
  5074. });
  5075. self.$document.off('keydown.chips').on('keydown.chips', function (e) {
  5076. if ($(e.target).is('input, textarea')) {
  5077. return;
  5078. }
  5079. // delete
  5080. var $chip = self.$document.find(SELS.CHIP + SELS.SELECTED_CHIP);
  5081. var $chips = $chip.closest(SELS.CHIPS);
  5082. var length = $chip.siblings(SELS.CHIP).length;
  5083. var index;
  5084. if (!$chip.length) {
  5085. return;
  5086. }
  5087. if (e.which === 8 || e.which === 46) {
  5088. e.preventDefault();
  5089. index = $chip.index();
  5090. self.deleteChip(index, $chips);
  5091. var selectIndex = null;
  5092. if (index + 1 < length) {
  5093. selectIndex = index;
  5094. } else if (index === length || index + 1 === length) {
  5095. selectIndex = length - 1;
  5096. }
  5097. if (selectIndex < 0) selectIndex = null;
  5098. if (null !== selectIndex) {
  5099. self.selectChip(selectIndex, $chips);
  5100. }
  5101. if (!length) $chips.find('input').focus();
  5102. // left
  5103. } else if (e.which === 37) {
  5104. index = $chip.index() - 1;
  5105. if (index < 0) {
  5106. return;
  5107. }
  5108. $(SELS.CHIP).removeClass('selected');
  5109. self.selectChip(index, $chips);
  5110. // right
  5111. } else if (e.which === 39) {
  5112. index = $chip.index() + 1;
  5113. $(SELS.CHIP).removeClass('selected');
  5114. if (index > length) {
  5115. $chips.find('input').focus();
  5116. return;
  5117. }
  5118. self.selectChip(index, $chips);
  5119. }
  5120. });
  5121. self.$document.off('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) {
  5122. var $currChips = $(e.target).closest(SELS.CHIPS);
  5123. $currChips.addClass('focus');
  5124. $currChips.siblings('label, .prefix').addClass('active');
  5125. $(SELS.CHIP).removeClass('selected');
  5126. });
  5127. self.$document.off('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) {
  5128. var $currChips = $(e.target).closest(SELS.CHIPS);
  5129. $currChips.removeClass('focus');
  5130. // Remove active if empty
  5131. if ($currChips.data('chips') === undefined || !$currChips.data('chips').length) {
  5132. $currChips.siblings('label').removeClass('active');
  5133. }
  5134. $currChips.siblings('.prefix').removeClass('active');
  5135. });
  5136. self.$document.off('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT).on('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT, function (e) {
  5137. var $target = $(e.target);
  5138. var $chips = $target.closest(SELS.CHIPS);
  5139. var chipsLength = $chips.children(SELS.CHIP).length;
  5140. // enter
  5141. if (13 === e.which) {
  5142. // Override enter if autocompleting.
  5143. if (self.hasAutocomplete && $chips.find('.autocomplete-content.dropdown-content').length && $chips.find('.autocomplete-content.dropdown-content').children().length) {
  5144. return;
  5145. }
  5146. e.preventDefault();
  5147. self.addChip({ tag: $target.val() }, $chips);
  5148. $target.val('');
  5149. return;
  5150. }
  5151. // delete or left
  5152. if ((8 === e.keyCode || 37 === e.keyCode) && '' === $target.val() && chipsLength) {
  5153. e.preventDefault();
  5154. self.selectChip(chipsLength - 1, $chips);
  5155. $target.blur();
  5156. return;
  5157. }
  5158. });
  5159. // Click on delete icon in chip.
  5160. self.$document.off('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE).on('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE, function (e) {
  5161. var $target = $(e.target);
  5162. var $chips = $target.closest(SELS.CHIPS);
  5163. var $chip = $target.closest(SELS.CHIP);
  5164. e.stopPropagation();
  5165. self.deleteChip($chip.index(), $chips);
  5166. $chips.find('input').focus();
  5167. });
  5168. };
  5169. this.chips = function ($chips, chipId) {
  5170. $chips.empty();
  5171. $chips.data('chips').forEach(function (elem) {
  5172. $chips.append(self.renderChip(elem));
  5173. });
  5174. $chips.append($('<input id="' + chipId + '" class="input" placeholder="">'));
  5175. self.setPlaceholder($chips);
  5176. // Set for attribute for label
  5177. var label = $chips.next('label');
  5178. if (label.length) {
  5179. label.attr('for', chipId);
  5180. if ($chips.data('chips') !== undefined && $chips.data('chips').length) {
  5181. label.addClass('active');
  5182. }
  5183. }
  5184. // Setup autocomplete if needed.
  5185. var input = $('#' + chipId);
  5186. if (self.hasAutocomplete) {
  5187. curr_options.autocompleteOptions.onAutocomplete = function (val) {
  5188. self.addChip({ tag: val }, $chips);
  5189. input.val('');
  5190. input.focus();
  5191. };
  5192. input.autocomplete(curr_options.autocompleteOptions);
  5193. }
  5194. };
  5195. /**
  5196. * Render chip jQuery element.
  5197. * @param {Object} elem
  5198. * @return {jQuery}
  5199. */
  5200. this.renderChip = function (elem) {
  5201. if (!elem.tag) return;
  5202. var $renderedChip = $('<div class="chip"></div>');
  5203. $renderedChip.text(elem.tag);
  5204. if (elem.image) {
  5205. $renderedChip.prepend($('<img />').attr('src', elem.image));
  5206. }
  5207. $renderedChip.append($('<i class="material-icons close">close</i>'));
  5208. return $renderedChip;
  5209. };
  5210. this.setPlaceholder = function ($chips) {
  5211. if ($chips.data('chips') !== undefined && !$chips.data('chips').length && curr_options.placeholder) {
  5212. $chips.find('input').prop('placeholder', curr_options.placeholder);
  5213. } else if (($chips.data('chips') === undefined || !!$chips.data('chips').length) && curr_options.secondaryPlaceholder) {
  5214. $chips.find('input').prop('placeholder', curr_options.secondaryPlaceholder);
  5215. }
  5216. };
  5217. this.isValid = function ($chips, elem) {
  5218. var chips = $chips.data('chips');
  5219. var exists = false;
  5220. for (var i = 0; i < chips.length; i++) {
  5221. if (chips[i].tag === elem.tag) {
  5222. exists = true;
  5223. return;
  5224. }
  5225. }
  5226. return '' !== elem.tag && !exists;
  5227. };
  5228. this.addChip = function (elem, $chips) {
  5229. if (!self.isValid($chips, elem)) {
  5230. return;
  5231. }
  5232. var $renderedChip = self.renderChip(elem);
  5233. var newData = [];
  5234. var oldData = $chips.data('chips');
  5235. for (var i = 0; i < oldData.length; i++) {
  5236. newData.push(oldData[i]);
  5237. }
  5238. newData.push(elem);
  5239. $chips.data('chips', newData);
  5240. $renderedChip.insertBefore($chips.find('input'));
  5241. $chips.trigger('chip.add', elem);
  5242. self.setPlaceholder($chips);
  5243. };
  5244. this.deleteChip = function (chipIndex, $chips) {
  5245. var chip = $chips.data('chips')[chipIndex];
  5246. $chips.find('.chip').eq(chipIndex).remove();
  5247. var newData = [];
  5248. var oldData = $chips.data('chips');
  5249. for (var i = 0; i < oldData.length; i++) {
  5250. if (i !== chipIndex) {
  5251. newData.push(oldData[i]);
  5252. }
  5253. }
  5254. $chips.data('chips', newData);
  5255. $chips.trigger('chip.delete', chip);
  5256. self.setPlaceholder($chips);
  5257. };
  5258. this.selectChip = function (chipIndex, $chips) {
  5259. var $chip = $chips.find('.chip').eq(chipIndex);
  5260. if ($chip && false === $chip.hasClass('selected')) {
  5261. $chip.addClass('selected');
  5262. $chips.trigger('chip.select', $chips.data('chips')[chipIndex]);
  5263. }
  5264. };
  5265. this.getChipsElement = function (index, $chips) {
  5266. return $chips.eq(index);
  5267. };
  5268. // init
  5269. this.init();
  5270. this.handleEvents();
  5271. };
  5272. })(jQuery);
  5273. ; (function ($) {
  5274. $.fn.pushpin = function (options) {
  5275. // Defaults
  5276. var defaults = {
  5277. top: 0,
  5278. bottom: Infinity,
  5279. offset: 0
  5280. };
  5281. // Remove pushpin event and classes
  5282. if (options === "remove") {
  5283. this.each(function () {
  5284. if (id = $(this).data('pushpin-id')) {
  5285. $(window).off('scroll.' + id);
  5286. $(this).removeData('pushpin-id').removeClass('pin-top pinned pin-bottom').removeAttr('style');
  5287. }
  5288. });
  5289. return false;
  5290. }
  5291. options = $.extend(defaults, options);
  5292. $index = 0;
  5293. return this.each(function () {
  5294. var $uniqueId = Materialize.guid(),
  5295. $this = $(this),
  5296. $original_offset = $(this).offset().top;
  5297. function removePinClasses(object) {
  5298. object.removeClass('pin-top');
  5299. object.removeClass('pinned');
  5300. object.removeClass('pin-bottom');
  5301. }
  5302. function updateElements(objects, scrolled) {
  5303. objects.each(function () {
  5304. // Add position fixed (because its between top and bottom)
  5305. if (options.top <= scrolled && options.bottom >= scrolled && !$(this).hasClass('pinned')) {
  5306. removePinClasses($(this));
  5307. $(this).css('top', options.offset);
  5308. $(this).addClass('pinned');
  5309. }
  5310. // Add pin-top (when scrolled position is above top)
  5311. if (scrolled < options.top && !$(this).hasClass('pin-top')) {
  5312. removePinClasses($(this));
  5313. $(this).css('top', 0);
  5314. $(this).addClass('pin-top');
  5315. }
  5316. // Add pin-bottom (when scrolled position is below bottom)
  5317. if (scrolled > options.bottom && !$(this).hasClass('pin-bottom')) {
  5318. removePinClasses($(this));
  5319. $(this).addClass('pin-bottom');
  5320. $(this).css('top', options.bottom - $original_offset);
  5321. }
  5322. });
  5323. }
  5324. $(this).data('pushpin-id', $uniqueId);
  5325. updateElements($this, $(window).scrollTop());
  5326. $(window).on('scroll.' + $uniqueId, function () {
  5327. var $scrolled = $(window).scrollTop() + options.offset;
  5328. updateElements($this, $scrolled);
  5329. });
  5330. });
  5331. };
  5332. })(jQuery);; (function ($) {
  5333. $(document).ready(function () {
  5334. // jQuery reverse
  5335. $.fn.reverse = [].reverse;
  5336. // Hover behaviour: make sure this doesn't work on .click-to-toggle FABs!
  5337. $(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) {
  5338. var $this = $(this);
  5339. openFABMenu($this);
  5340. });
  5341. $(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) {
  5342. var $this = $(this);
  5343. closeFABMenu($this);
  5344. });
  5345. // Toggle-on-click behaviour.
  5346. $(document).on('click.fabClickToggle', '.fixed-action-btn.click-to-toggle > a', function (e) {
  5347. var $this = $(this);
  5348. var $menu = $this.parent();
  5349. if ($menu.hasClass('active')) {
  5350. closeFABMenu($menu);
  5351. } else {
  5352. openFABMenu($menu);
  5353. }
  5354. });
  5355. // Toolbar transition behaviour.
  5356. $(document).on('click.fabToolbar', '.fixed-action-btn.toolbar > a', function (e) {
  5357. var $this = $(this);
  5358. var $menu = $this.parent();
  5359. FABtoToolbar($menu);
  5360. });
  5361. });
  5362. $.fn.extend({
  5363. openFAB: function () {
  5364. openFABMenu($(this));
  5365. },
  5366. closeFAB: function () {
  5367. closeFABMenu($(this));
  5368. },
  5369. openToolbar: function () {
  5370. FABtoToolbar($(this));
  5371. },
  5372. closeToolbar: function () {
  5373. toolbarToFAB($(this));
  5374. }
  5375. });
  5376. var openFABMenu = function (btn) {
  5377. var $this = btn;
  5378. if ($this.hasClass('active') === false) {
  5379. // Get direction option
  5380. var horizontal = $this.hasClass('horizontal');
  5381. var offsetY, offsetX;
  5382. if (horizontal === true) {
  5383. offsetX = 40;
  5384. } else {
  5385. offsetY = 40;
  5386. }
  5387. if ($this.find("div").length > 0) {
  5388. $this.find("div")[0].style.display = "block";
  5389. }
  5390. else {
  5391. $this.addClass('active');
  5392. $this.find('ul .btn-floating').velocity({ scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 0 });
  5393. var time = 0;
  5394. $this.find('ul .btn-floating').reverse().each(function () {
  5395. $(this).velocity({ opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0' }, { duration: 80, delay: time });
  5396. time += 40;
  5397. });
  5398. }
  5399. }
  5400. };
  5401. var closeFABMenu = function (btn) {
  5402. var $this = btn;
  5403. // Get direction option
  5404. var horizontal = $this.hasClass('horizontal');
  5405. var offsetY, offsetX;
  5406. if (horizontal === true) {
  5407. offsetX = 40;
  5408. } else {
  5409. offsetY = 40;
  5410. }
  5411. $this.removeClass('active');
  5412. var time = 0;
  5413. $this.find('ul .btn-floating').velocity("stop", true);
  5414. $this.find('ul .btn-floating').velocity({ opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 80 });
  5415. };
  5416. /**
  5417. * Transform FAB into toolbar
  5418. * @param {Object} object jQuery object
  5419. */
  5420. var FABtoToolbar = function (btn) {
  5421. if (btn.attr('data-open') === "true") {
  5422. return;
  5423. }
  5424. var offsetX, offsetY, scaleFactor;
  5425. var windowWidth = window.innerWidth;
  5426. var windowHeight = window.innerHeight;
  5427. var btnRect = btn[0].getBoundingClientRect();
  5428. var anchor = btn.find('> a').first();
  5429. var menu = btn.find('> ul').first();
  5430. var backdrop = $('<div class="fab-backdrop"></div>');
  5431. var fabColor = anchor.css('background-color');
  5432. anchor.append(backdrop);
  5433. offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
  5434. offsetY = windowHeight - btnRect.bottom;
  5435. scaleFactor = windowWidth / backdrop.width();
  5436. btn.attr('data-origin-bottom', btnRect.bottom);
  5437. btn.attr('data-origin-left', btnRect.left);
  5438. btn.attr('data-origin-width', btnRect.width);
  5439. // Set initial state
  5440. btn.addClass('active');
  5441. btn.attr('data-open', true);
  5442. btn.css({
  5443. 'text-align': 'center',
  5444. width: '100%',
  5445. bottom: 0,
  5446. left: 0,
  5447. transform: 'translateX(' + offsetX + 'px)',
  5448. transition: 'none'
  5449. });
  5450. anchor.css({
  5451. transform: 'translateY(' + -offsetY + 'px)',
  5452. transition: 'none'
  5453. });
  5454. backdrop.css({
  5455. 'background-color': fabColor
  5456. });
  5457. setTimeout(function () {
  5458. btn.css({
  5459. transform: '',
  5460. transition: 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'
  5461. });
  5462. anchor.css({
  5463. overflow: 'visible',
  5464. transform: '',
  5465. transition: 'transform .2s'
  5466. });
  5467. setTimeout(function () {
  5468. btn.css({
  5469. overflow: 'hidden',
  5470. 'background-color': fabColor
  5471. });
  5472. backdrop.css({
  5473. transform: 'scale(' + scaleFactor + ')',
  5474. transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
  5475. });
  5476. menu.find('> li > a').css({
  5477. opacity: 1
  5478. });
  5479. // Scroll to close.
  5480. $(window).on('scroll.fabToolbarClose', function () {
  5481. toolbarToFAB(btn);
  5482. $(window).off('scroll.fabToolbarClose');
  5483. $(document).off('click.fabToolbarClose');
  5484. });
  5485. $(document).on('click.fabToolbarClose', function (e) {
  5486. if (!$(e.target).closest(menu).length) {
  5487. toolbarToFAB(btn);
  5488. $(window).off('scroll.fabToolbarClose');
  5489. $(document).off('click.fabToolbarClose');
  5490. }
  5491. });
  5492. }, 100);
  5493. }, 0);
  5494. };
  5495. /**
  5496. * Transform toolbar back into FAB
  5497. * @param {Object} object jQuery object
  5498. */
  5499. var toolbarToFAB = function (btn) {
  5500. if (btn.attr('data-open') !== "true") {
  5501. return;
  5502. }
  5503. var offsetX, offsetY, scaleFactor;
  5504. var windowWidth = window.innerWidth;
  5505. var windowHeight = window.innerHeight;
  5506. var btnWidth = btn.attr('data-origin-width');
  5507. var btnBottom = btn.attr('data-origin-bottom');
  5508. var btnLeft = btn.attr('data-origin-left');
  5509. var anchor = btn.find('> .btn-floating').first();
  5510. var menu = btn.find('> ul').first();
  5511. var backdrop = btn.find('.fab-backdrop');
  5512. var fabColor = anchor.css('background-color');
  5513. offsetX = btnLeft - windowWidth / 2 + btnWidth / 2;
  5514. offsetY = windowHeight - btnBottom;
  5515. scaleFactor = windowWidth / backdrop.width();
  5516. // Hide backdrop
  5517. btn.removeClass('active');
  5518. btn.attr('data-open', false);
  5519. btn.css({
  5520. 'background-color': 'transparent',
  5521. transition: 'none'
  5522. });
  5523. anchor.css({
  5524. transition: 'none'
  5525. });
  5526. backdrop.css({
  5527. transform: 'scale(0)',
  5528. 'background-color': fabColor
  5529. });
  5530. menu.find('> li > a').css({
  5531. opacity: ''
  5532. });
  5533. setTimeout(function () {
  5534. backdrop.remove();
  5535. // Set initial state.
  5536. btn.css({
  5537. 'text-align': '',
  5538. width: '',
  5539. bottom: '',
  5540. left: '',
  5541. overflow: '',
  5542. 'background-color': '',
  5543. transform: 'translate3d(' + -offsetX + 'px,0,0)'
  5544. });
  5545. anchor.css({
  5546. overflow: '',
  5547. transform: 'translate3d(0,' + offsetY + 'px,0)'
  5548. });
  5549. setTimeout(function () {
  5550. btn.css({
  5551. transform: 'translate3d(0,0,0)',
  5552. transition: 'transform .2s'
  5553. });
  5554. anchor.css({
  5555. transform: 'translate3d(0,0,0)',
  5556. transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
  5557. });
  5558. }, 20);
  5559. }, 200);
  5560. };
  5561. })(jQuery);
  5562. ; (function ($) {
  5563. // Image transition function
  5564. Materialize.fadeInImage = function (selectorOrEl) {
  5565. var element;
  5566. if (typeof selectorOrEl === 'string') {
  5567. element = $(selectorOrEl);
  5568. } else if (typeof selectorOrEl === 'object') {
  5569. element = selectorOrEl;
  5570. } else {
  5571. return;
  5572. }
  5573. element.css({ opacity: 0 });
  5574. $(element).velocity({ opacity: 1 }, {
  5575. duration: 650,
  5576. queue: false,
  5577. easing: 'easeOutSine'
  5578. });
  5579. $(element).velocity({ opacity: 1 }, {
  5580. duration: 1300,
  5581. queue: false,
  5582. easing: 'swing',
  5583. step: function (now, fx) {
  5584. fx.start = 100;
  5585. var grayscale_setting = now / 100;
  5586. var brightness_setting = 150 - (100 - now) / 1.75;
  5587. if (brightness_setting < 100) {
  5588. brightness_setting = 100;
  5589. }
  5590. if (now >= 0) {
  5591. $(this).css({
  5592. "-webkit-filter": "grayscale(" + grayscale_setting + ")" + "brightness(" + brightness_setting + "%)",
  5593. "filter": "grayscale(" + grayscale_setting + ")" + "brightness(" + brightness_setting + "%)"
  5594. });
  5595. }
  5596. }
  5597. });
  5598. };
  5599. // Horizontal staggered list
  5600. Materialize.showStaggeredList = function (selectorOrEl) {
  5601. var element;
  5602. if (typeof selectorOrEl === 'string') {
  5603. element = $(selectorOrEl);
  5604. } else if (typeof selectorOrEl === 'object') {
  5605. element = selectorOrEl;
  5606. } else {
  5607. return;
  5608. }
  5609. var time = 0;
  5610. element.find('li').velocity({ translateX: "-100px" }, { duration: 0 });
  5611. element.find('li').each(function () {
  5612. $(this).velocity({ opacity: "1", translateX: "0" }, { duration: 800, delay: time, easing: [60, 10] });
  5613. time += 120;
  5614. });
  5615. };
  5616. $(document).ready(function () {
  5617. // Hardcoded .staggered-list scrollFire
  5618. // var staggeredListOptions = [];
  5619. // $('ul.staggered-list').each(function (i) {
  5620. // var label = 'scrollFire-' + i;
  5621. // $(this).addClass(label);
  5622. // staggeredListOptions.push(
  5623. // {selector: 'ul.staggered-list.' + label,
  5624. // offset: 200,
  5625. // callback: 'showStaggeredList("ul.staggered-list.' + label + '")'});
  5626. // });
  5627. // scrollFire(staggeredListOptions);
  5628. // HammerJS, Swipe navigation
  5629. // Touch Event
  5630. var swipeLeft = false;
  5631. var swipeRight = false;
  5632. // Dismissible Collections
  5633. $('.dismissable').each(function () {
  5634. $(this).hammer({
  5635. prevent_default: false
  5636. }).on('pan', function (e) {
  5637. if (e.gesture.pointerType === "touch") {
  5638. var $this = $(this);
  5639. var direction = e.gesture.direction;
  5640. var x = e.gesture.deltaX;
  5641. var velocityX = e.gesture.velocityX;
  5642. $this.velocity({
  5643. translateX: x
  5644. }, { duration: 50, queue: false, easing: 'easeOutQuad' });
  5645. // Swipe Left
  5646. if (direction === 4 && (x > $this.innerWidth() / 2 || velocityX < -0.75)) {
  5647. swipeLeft = true;
  5648. }
  5649. // Swipe Right
  5650. if (direction === 2 && (x < -1 * $this.innerWidth() / 2 || velocityX > 0.75)) {
  5651. swipeRight = true;
  5652. }
  5653. }
  5654. }).on('panend', function (e) {
  5655. // Reset if collection is moved back into original position
  5656. if (Math.abs(e.gesture.deltaX) < $(this).innerWidth() / 2) {
  5657. swipeRight = false;
  5658. swipeLeft = false;
  5659. }
  5660. if (e.gesture.pointerType === "touch") {
  5661. var $this = $(this);
  5662. if (swipeLeft || swipeRight) {
  5663. var fullWidth;
  5664. if (swipeLeft) {
  5665. fullWidth = $this.innerWidth();
  5666. } else {
  5667. fullWidth = -1 * $this.innerWidth();
  5668. }
  5669. $this.velocity({
  5670. translateX: fullWidth
  5671. }, {
  5672. duration: 100, queue: false, easing: 'easeOutQuad', complete: function () {
  5673. $this.css('border', 'none');
  5674. $this.velocity({
  5675. height: 0, padding: 0
  5676. }, {
  5677. duration: 200, queue: false, easing: 'easeOutQuad', complete: function () {
  5678. $this.remove();
  5679. }
  5680. });
  5681. }
  5682. });
  5683. } else {
  5684. $this.velocity({
  5685. translateX: 0
  5686. }, { duration: 100, queue: false, easing: 'easeOutQuad' });
  5687. }
  5688. swipeLeft = false;
  5689. swipeRight = false;
  5690. }
  5691. });
  5692. });
  5693. // time = 0
  5694. // // Vertical Staggered list
  5695. // $('ul.staggered-list.vertical li').velocity(
  5696. // { translateY: "100px"},
  5697. // { duration: 0 });
  5698. // $('ul.staggered-list.vertical li').each(function() {
  5699. // $(this).velocity(
  5700. // { opacity: "1", translateY: "0"},
  5701. // { duration: 800, delay: time, easing: [60, 25] });
  5702. // time += 120;
  5703. // });
  5704. // // Fade in and Scale
  5705. // $('.fade-in.scale').velocity(
  5706. // { scaleX: .4, scaleY: .4, translateX: -600},
  5707. // { duration: 0});
  5708. // $('.fade-in').each(function() {
  5709. // $(this).velocity(
  5710. // { opacity: "1", scaleX: 1, scaleY: 1, translateX: 0},
  5711. // { duration: 800, easing: [60, 10] });
  5712. // });
  5713. });
  5714. })(jQuery);
  5715. ; (function ($) {
  5716. var scrollFireEventsHandled = false;
  5717. // Input: Array of JSON objects {selector, offset, callback}
  5718. Materialize.scrollFire = function (options) {
  5719. var onScroll = function () {
  5720. var windowScroll = window.pageYOffset + window.innerHeight;
  5721. for (var i = 0; i < options.length; i++) {
  5722. // Get options from each line
  5723. var value = options[i];
  5724. var selector = value.selector,
  5725. offset = value.offset,
  5726. callback = value.callback;
  5727. var currentElement = document.querySelector(selector);
  5728. if (currentElement !== null) {
  5729. var elementOffset = currentElement.getBoundingClientRect().top + window.pageYOffset;
  5730. if (windowScroll > elementOffset + offset) {
  5731. if (value.done !== true) {
  5732. if (typeof callback === 'function') {
  5733. callback.call(this, currentElement);
  5734. } else if (typeof callback === 'string') {
  5735. var callbackFunc = new Function(callback);
  5736. callbackFunc(currentElement);
  5737. }
  5738. value.done = true;
  5739. }
  5740. }
  5741. }
  5742. }
  5743. };
  5744. var throttledScroll = Materialize.throttle(function () {
  5745. onScroll();
  5746. }, options.throttle || 100);
  5747. if (!scrollFireEventsHandled) {
  5748. window.addEventListener("scroll", throttledScroll);
  5749. window.addEventListener("resize", throttledScroll);
  5750. scrollFireEventsHandled = true;
  5751. }
  5752. // perform a scan once, after current execution context, and after dom is ready
  5753. setTimeout(throttledScroll, 0);
  5754. };
  5755. })(jQuery);
  5756. ; /*!
  5757. * pickadate.js v3.5.0, 2014/04/13
  5758. * By Amsul, http://amsul.ca
  5759. * Hosted on http://amsul.github.io/pickadate.js
  5760. * Licensed under MIT
  5761. */
  5762. (function (factory) {
  5763. Materialize.Picker = factory(jQuery);
  5764. })(function ($) {
  5765. var $window = $(window);
  5766. var $document = $(document);
  5767. var $html = $(document.documentElement);
  5768. /**
  5769. * The picker constructor that creates a blank picker.
  5770. */
  5771. function PickerConstructor(ELEMENT, NAME, COMPONENT, OPTIONS) {
  5772. // If there’s no element, return the picker constructor.
  5773. if (!ELEMENT) return PickerConstructor;
  5774. var IS_DEFAULT_THEME = false,
  5775. // The state of the picker.
  5776. STATE = {
  5777. id: ELEMENT.id || 'P' + Math.abs(~~(Math.random() * new Date()))
  5778. },
  5779. // Merge the defaults and options passed.
  5780. SETTINGS = COMPONENT ? $.extend(true, {}, COMPONENT.defaults, OPTIONS) : OPTIONS || {},
  5781. // Merge the default classes with the settings classes.
  5782. CLASSES = $.extend({}, PickerConstructor.klasses(), SETTINGS.klass),
  5783. // The element node wrapper into a jQuery object.
  5784. $ELEMENT = $(ELEMENT),
  5785. // Pseudo picker constructor.
  5786. PickerInstance = function () {
  5787. return this.start();
  5788. },
  5789. // The picker prototype.
  5790. P = PickerInstance.prototype = {
  5791. constructor: PickerInstance,
  5792. $node: $ELEMENT,
  5793. /**
  5794. * Initialize everything
  5795. */
  5796. start: function () {
  5797. // If it’s already started, do nothing.
  5798. if (STATE && STATE.start) return P;
  5799. // Update the picker states.
  5800. STATE.methods = {};
  5801. STATE.start = true;
  5802. STATE.open = false;
  5803. STATE.type = ELEMENT.type;
  5804. // Confirm focus state, convert into text input to remove UA stylings,
  5805. // and set as readonly to prevent keyboard popup.
  5806. ELEMENT.autofocus = ELEMENT == getActiveElement();
  5807. ELEMENT.readOnly = !SETTINGS.editable;
  5808. ELEMENT.id = ELEMENT.id || STATE.id;
  5809. if (ELEMENT.type != 'text') {
  5810. ELEMENT.type = 'text';
  5811. }
  5812. // Create a new picker component with the settings.
  5813. P.component = new COMPONENT(P, SETTINGS);
  5814. // Create the picker root with a holder and then prepare it.
  5815. P.$root = $(PickerConstructor._.node('div', createWrappedComponent(), CLASSES.picker, 'id="' + ELEMENT.id + '_root" tabindex="0"'));
  5816. prepareElementRoot();
  5817. // If there’s a format for the hidden input element, create the element.
  5818. if (SETTINGS.formatSubmit) {
  5819. prepareElementHidden();
  5820. }
  5821. // Prepare the input element.
  5822. prepareElement();
  5823. // Insert the root as specified in the settings.
  5824. if (SETTINGS.container) $(SETTINGS.container).append(P.$root); else $ELEMENT.before(P.$root);
  5825. // Bind the default component and settings events.
  5826. P.on({
  5827. start: P.component.onStart,
  5828. render: P.component.onRender,
  5829. stop: P.component.onStop,
  5830. open: P.component.onOpen,
  5831. close: P.component.onClose,
  5832. set: P.component.onSet
  5833. }).on({
  5834. start: SETTINGS.onStart,
  5835. render: SETTINGS.onRender,
  5836. stop: SETTINGS.onStop,
  5837. open: SETTINGS.onOpen,
  5838. close: SETTINGS.onClose,
  5839. set: SETTINGS.onSet
  5840. });
  5841. // Once we’re all set, check the theme in use.
  5842. IS_DEFAULT_THEME = isUsingDefaultTheme(P.$root.children()[0]);
  5843. // If the element has autofocus, open the picker.
  5844. if (ELEMENT.autofocus) {
  5845. P.open();
  5846. }
  5847. // Trigger queued the “start” and “render” events.
  5848. return P.trigger('start').trigger('render');
  5849. }, //start
  5850. /**
  5851. * Render a new picker
  5852. */
  5853. render: function (entireComponent) {
  5854. // Insert a new component holder in the root or box.
  5855. if (entireComponent) P.$root.html(createWrappedComponent()); else P.$root.find('.' + CLASSES.box).html(P.component.nodes(STATE.open));
  5856. // Trigger the queued “render” events.
  5857. return P.trigger('render');
  5858. }, //render
  5859. /**
  5860. * Destroy everything
  5861. */
  5862. stop: function () {
  5863. // If it’s already stopped, do nothing.
  5864. if (!STATE.start) return P;
  5865. // Then close the picker.
  5866. P.close();
  5867. // Remove the hidden field.
  5868. if (P._hidden) {
  5869. P._hidden.parentNode.removeChild(P._hidden);
  5870. }
  5871. // Remove the root.
  5872. P.$root.remove();
  5873. // Remove the input class, remove the stored data, and unbind
  5874. // the events (after a tick for IE - see `P.close`).
  5875. $ELEMENT.removeClass(CLASSES.input).removeData(NAME);
  5876. setTimeout(function () {
  5877. $ELEMENT.off('.' + STATE.id);
  5878. }, 0);
  5879. // Restore the element state
  5880. ELEMENT.type = STATE.type;
  5881. ELEMENT.readOnly = false;
  5882. // Trigger the queued “stop” events.
  5883. P.trigger('stop');
  5884. // Reset the picker states.
  5885. STATE.methods = {};
  5886. STATE.start = false;
  5887. return P;
  5888. }, //stop
  5889. /**
  5890. * Open up the picker
  5891. */
  5892. open: function (dontGiveFocus) {
  5893. // If it’s already open, do nothing.
  5894. if (STATE.open) return P;
  5895. // Add the “active” class.
  5896. $ELEMENT.addClass(CLASSES.active);
  5897. aria(ELEMENT, 'expanded', true);
  5898. // * A Firefox bug, when `html` has `overflow:hidden`, results in
  5899. // killing transitions :(. So add the “opened” state on the next tick.
  5900. // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
  5901. setTimeout(function () {
  5902. // Add the “opened” class to the picker root.
  5903. P.$root.addClass(CLASSES.opened);
  5904. aria(P.$root[0], 'hidden', false);
  5905. }, 0);
  5906. // If we have to give focus, bind the element and doc events.
  5907. if (dontGiveFocus !== false) {
  5908. // Set it as open.
  5909. STATE.open = true;
  5910. // Prevent the page from scrolling.
  5911. if (IS_DEFAULT_THEME) {
  5912. $html.css('overflow', 'hidden').css('padding-right', '+=' + getScrollbarWidth());
  5913. }
  5914. // Pass focus to the root element’s jQuery object.
  5915. // * Workaround for iOS8 to bring the picker’s root into view.
  5916. P.$root.eq(0).focus();
  5917. // Bind the document events.
  5918. $document.on('click.' + STATE.id + ' focusin.' + STATE.id, function (event) {
  5919. var target = event.target;
  5920. // If the target of the event is not the element, close the picker picker.
  5921. // * Don’t worry about clicks or focusins on the root because those don’t bubble up.
  5922. // Also, for Firefox, a click on an `option` element bubbles up directly
  5923. // to the doc. So make sure the target wasn't the doc.
  5924. // * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling,
  5925. // which causes the picker to unexpectedly close when right-clicking it. So make
  5926. // sure the event wasn’t a right-click.
  5927. if (target != ELEMENT && target != document && event.which != 3) {
  5928. // If the target was the holder that covers the screen,
  5929. // keep the element focused to maintain tabindex.
  5930. P.close(target === P.$root.children()[0]);
  5931. }
  5932. }).on('keydown.' + STATE.id, function (event) {
  5933. var
  5934. // Get the keycode.
  5935. keycode = event.keyCode,
  5936. // Translate that to a selection change.
  5937. keycodeToMove = P.component.key[keycode],
  5938. // Grab the target.
  5939. target = event.target;
  5940. // On escape, close the picker and give focus.
  5941. if (keycode == 27) {
  5942. P.close(true);
  5943. }
  5944. // Check if there is a key movement or “enter” keypress on the element.
  5945. else if (target == P.$root[0] && (keycodeToMove || keycode == 13)) {
  5946. // Prevent the default action to stop page movement.
  5947. event.preventDefault();
  5948. // Trigger the key movement action.
  5949. if (keycodeToMove) {
  5950. PickerConstructor._.trigger(P.component.key.go, P, [PickerConstructor._.trigger(keycodeToMove)]);
  5951. }
  5952. // On “enter”, if the highlighted item isn’t disabled, set the value and close.
  5953. else if (!P.$root.find('.' + CLASSES.highlighted).hasClass(CLASSES.disabled)) {
  5954. P.set('select', P.component.item.highlight);
  5955. if (SETTINGS.closeOnSelect) {
  5956. P.close(true);
  5957. }
  5958. }
  5959. }
  5960. // If the target is within the root and “enter” is pressed,
  5961. // prevent the default action and trigger a click on the target instead.
  5962. else if ($.contains(P.$root[0], target) && keycode == 13) {
  5963. event.preventDefault();
  5964. target.click();
  5965. }
  5966. });
  5967. }
  5968. // Trigger the queued “open” events.
  5969. return P.trigger('open');
  5970. }, //open
  5971. /**
  5972. * Close the picker
  5973. */
  5974. close: function (giveFocus) {
  5975. // If we need to give focus, do it before changing states.
  5976. if (giveFocus) {
  5977. // ....ah yes! It would’ve been incomplete without a crazy workaround for IE :|
  5978. // The focus is triggered *after* the close has completed - causing it
  5979. // to open again. So unbind and rebind the event at the next tick.
  5980. P.$root.off('focus.toOpen').eq(0).focus();
  5981. setTimeout(function () {
  5982. P.$root.on('focus.toOpen', handleFocusToOpenEvent);
  5983. }, 0);
  5984. }
  5985. // Remove the “active” class.
  5986. $ELEMENT.removeClass(CLASSES.active);
  5987. aria(ELEMENT, 'expanded', false);
  5988. // * A Firefox bug, when `html` has `overflow:hidden`, results in
  5989. // killing transitions :(. So remove the “opened” state on the next tick.
  5990. // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
  5991. setTimeout(function () {
  5992. // Remove the “opened” and “focused” class from the picker root.
  5993. P.$root.removeClass(CLASSES.opened + ' ' + CLASSES.focused);
  5994. aria(P.$root[0], 'hidden', true);
  5995. }, 0);
  5996. // If it’s already closed, do nothing more.
  5997. if (!STATE.open) return P;
  5998. // Set it as closed.
  5999. STATE.open = false;
  6000. // Allow the page to scroll.
  6001. if (IS_DEFAULT_THEME) {
  6002. $html.css('overflow', '').css('padding-right', '-=' + getScrollbarWidth());
  6003. }
  6004. // Unbind the document events.
  6005. $document.off('.' + STATE.id);
  6006. // Trigger the queued “close” events.
  6007. return P.trigger('close');
  6008. }, //close
  6009. /**
  6010. * Clear the values
  6011. */
  6012. clear: function (options) {
  6013. return P.set('clear', null, options);
  6014. }, //clear
  6015. /**
  6016. * Set something
  6017. */
  6018. set: function (thing, value, options) {
  6019. var thingItem,
  6020. thingValue,
  6021. thingIsObject = $.isPlainObject(thing),
  6022. thingObject = thingIsObject ? thing : {};
  6023. // Make sure we have usable options.
  6024. options = thingIsObject && $.isPlainObject(value) ? value : options || {};
  6025. if (thing) {
  6026. // If the thing isn’t an object, make it one.
  6027. if (!thingIsObject) {
  6028. thingObject[thing] = value;
  6029. }
  6030. // Go through the things of items to set.
  6031. for (thingItem in thingObject) {
  6032. // Grab the value of the thing.
  6033. thingValue = thingObject[thingItem];
  6034. // First, if the item exists and there’s a value, set it.
  6035. if (thingItem in P.component.item) {
  6036. if (thingValue === undefined) thingValue = null;
  6037. P.component.set(thingItem, thingValue, options);
  6038. }
  6039. // Then, check to update the element value and broadcast a change.
  6040. if (thingItem == 'select' || thingItem == 'clear') {
  6041. $ELEMENT.val(thingItem == 'clear' ? '' : P.get(thingItem, SETTINGS.format)).trigger('change');
  6042. }
  6043. }
  6044. // Render a new picker.
  6045. P.render();
  6046. }
  6047. // When the method isn’t muted, trigger queued “set” events and pass the `thingObject`.
  6048. return options.muted ? P : P.trigger('set', thingObject);
  6049. }, //set
  6050. /**
  6051. * Get something
  6052. */
  6053. get: function (thing, format) {
  6054. // Make sure there’s something to get.
  6055. thing = thing || 'value';
  6056. // If a picker state exists, return that.
  6057. if (STATE[thing] != null) {
  6058. return STATE[thing];
  6059. }
  6060. // Return the submission value, if that.
  6061. if (thing == 'valueSubmit') {
  6062. if (P._hidden) {
  6063. return P._hidden.value;
  6064. }
  6065. thing = 'value';
  6066. }
  6067. // Return the value, if that.
  6068. if (thing == 'value') {
  6069. return ELEMENT.value;
  6070. }
  6071. // Check if a component item exists, return that.
  6072. if (thing in P.component.item) {
  6073. if (typeof format == 'string') {
  6074. var thingValue = P.component.get(thing);
  6075. return thingValue ? PickerConstructor._.trigger(P.component.formats.toString, P.component, [format, thingValue]) : '';
  6076. }
  6077. return P.component.get(thing);
  6078. }
  6079. }, //get
  6080. /**
  6081. * Bind events on the things.
  6082. */
  6083. on: function (thing, method, internal) {
  6084. var thingName,
  6085. thingMethod,
  6086. thingIsObject = $.isPlainObject(thing),
  6087. thingObject = thingIsObject ? thing : {};
  6088. if (thing) {
  6089. // If the thing isn’t an object, make it one.
  6090. if (!thingIsObject) {
  6091. thingObject[thing] = method;
  6092. }
  6093. // Go through the things to bind to.
  6094. for (thingName in thingObject) {
  6095. // Grab the method of the thing.
  6096. thingMethod = thingObject[thingName];
  6097. // If it was an internal binding, prefix it.
  6098. if (internal) {
  6099. thingName = '_' + thingName;
  6100. }
  6101. // Make sure the thing methods collection exists.
  6102. STATE.methods[thingName] = STATE.methods[thingName] || [];
  6103. // Add the method to the relative method collection.
  6104. STATE.methods[thingName].push(thingMethod);
  6105. }
  6106. }
  6107. return P;
  6108. }, //on
  6109. /**
  6110. * Unbind events on the things.
  6111. */
  6112. off: function () {
  6113. var i,
  6114. thingName,
  6115. names = arguments;
  6116. for (i = 0, namesCount = names.length; i < namesCount; i += 1) {
  6117. thingName = names[i];
  6118. if (thingName in STATE.methods) {
  6119. delete STATE.methods[thingName];
  6120. }
  6121. }
  6122. return P;
  6123. },
  6124. /**
  6125. * Fire off method events.
  6126. */
  6127. trigger: function (name, data) {
  6128. var _trigger = function (name) {
  6129. var methodList = STATE.methods[name];
  6130. if (methodList) {
  6131. methodList.map(function (method) {
  6132. PickerConstructor._.trigger(method, P, [data]);
  6133. });
  6134. }
  6135. };
  6136. _trigger('_' + name);
  6137. _trigger(name);
  6138. return P;
  6139. } //trigger
  6140. //PickerInstance.prototype
  6141. /**
  6142. * Wrap the picker holder components together.
  6143. */
  6144. }; function createWrappedComponent() {
  6145. // Create a picker wrapper holder
  6146. return PickerConstructor._.node('div',
  6147. // Create a picker wrapper node
  6148. PickerConstructor._.node('div',
  6149. // Create a picker frame
  6150. PickerConstructor._.node('div',
  6151. // Create a picker box node
  6152. PickerConstructor._.node('div',
  6153. // Create the components nodes.
  6154. P.component.nodes(STATE.open),
  6155. // The picker box class
  6156. CLASSES.box),
  6157. // Picker wrap class
  6158. CLASSES.wrap),
  6159. // Picker frame class
  6160. CLASSES.frame),
  6161. // Picker holder class
  6162. CLASSES.holder); //endreturn
  6163. } //createWrappedComponent
  6164. /**
  6165. * Prepare the input element with all bindings.
  6166. */
  6167. function prepareElement() {
  6168. $ELEMENT.
  6169. // Store the picker data by component name.
  6170. data(NAME, P).
  6171. // Add the “input” class name.
  6172. addClass(CLASSES.input).
  6173. // Remove the tabindex.
  6174. attr('tabindex', -1).
  6175. // If there’s a `data-value`, update the value of the element.
  6176. val($ELEMENT.data('value') ? P.get('select', SETTINGS.format) : ELEMENT.value);
  6177. // Only bind keydown events if the element isn’t editable.
  6178. if (!SETTINGS.editable) {
  6179. $ELEMENT.
  6180. // On focus/click, focus onto the root to open it up.
  6181. on('focus.' + STATE.id + ' click.' + STATE.id, function (event) {
  6182. event.preventDefault();
  6183. P.$root.eq(0).focus();
  6184. }).
  6185. // Handle keyboard event based on the picker being opened or not.
  6186. on('keydown.' + STATE.id, handleKeydownEvent);
  6187. }
  6188. // Update the aria attributes.
  6189. aria(ELEMENT, {
  6190. haspopup: true,
  6191. expanded: false,
  6192. readonly: false,
  6193. owns: ELEMENT.id + '_root'
  6194. });
  6195. }
  6196. /**
  6197. * Prepare the root picker element with all bindings.
  6198. */
  6199. function prepareElementRoot() {
  6200. P.$root.on({
  6201. // For iOS8.
  6202. keydown: handleKeydownEvent,
  6203. // When something within the root is focused, stop from bubbling
  6204. // to the doc and remove the “focused” state from the root.
  6205. focusin: function (event) {
  6206. P.$root.removeClass(CLASSES.focused);
  6207. event.stopPropagation();
  6208. },
  6209. // When something within the root holder is clicked, stop it
  6210. // from bubbling to the doc.
  6211. 'mousedown click': function (event) {
  6212. var target = event.target;
  6213. // Make sure the target isn’t the root holder so it can bubble up.
  6214. if (target != P.$root.children()[0]) {
  6215. event.stopPropagation();
  6216. // * For mousedown events, cancel the default action in order to
  6217. // prevent cases where focus is shifted onto external elements
  6218. // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120).
  6219. // Also, for Firefox, don’t prevent action on the `option` element.
  6220. if (event.type == 'mousedown' && !$(target).is('input, select, textarea, button, option')) {
  6221. event.preventDefault();
  6222. // Re-focus onto the root so that users can click away
  6223. // from elements focused within the picker.
  6224. P.$root.eq(0).focus();
  6225. }
  6226. }
  6227. }
  6228. }).
  6229. // Add/remove the “target” class on focus and blur.
  6230. on({
  6231. focus: function () {
  6232. $ELEMENT.addClass(CLASSES.target);
  6233. },
  6234. blur: function () {
  6235. $ELEMENT.removeClass(CLASSES.target);
  6236. }
  6237. }).
  6238. // Open the picker and adjust the root “focused” state
  6239. on('focus.toOpen', handleFocusToOpenEvent).
  6240. // If there’s a click on an actionable element, carry out the actions.
  6241. on('click', '[data-pick], [data-nav], [data-clear], [data-close]', function () {
  6242. var $target = $(this),
  6243. targetData = $target.data(),
  6244. targetDisabled = $target.hasClass(CLASSES.navDisabled) || $target.hasClass(CLASSES.disabled),
  6245. // * For IE, non-focusable elements can be active elements as well
  6246. // (http://stackoverflow.com/a/2684561).
  6247. activeElement = getActiveElement();
  6248. activeElement = activeElement && (activeElement.type || activeElement.href) && activeElement;
  6249. // If it’s disabled or nothing inside is actively focused, re-focus the element.
  6250. if (targetDisabled || activeElement && !$.contains(P.$root[0], activeElement)) {
  6251. P.$root.eq(0).focus();
  6252. }
  6253. // If something is superficially changed, update the `highlight` based on the `nav`.
  6254. if (!targetDisabled && targetData.nav) {
  6255. P.set('highlight', P.component.item.highlight, { nav: targetData.nav });
  6256. }
  6257. // If something is picked, set `select` then close with focus.
  6258. else if (!targetDisabled && 'pick' in targetData) {
  6259. P.set('select', targetData.pick);
  6260. if (SETTINGS.closeOnSelect) {
  6261. P.close(true);
  6262. }
  6263. }
  6264. // If a “clear” button is pressed, empty the values and close with focus.
  6265. else if (targetData.clear) {
  6266. P.clear();
  6267. if (SETTINGS.closeOnSelect) {
  6268. P.close(true);
  6269. }
  6270. } else if (targetData.close) {
  6271. P.close(true);
  6272. }
  6273. }); //P.$root
  6274. aria(P.$root[0], 'hidden', true);
  6275. }
  6276. /**
  6277. * Prepare the hidden input element along with all bindings.
  6278. */
  6279. function prepareElementHidden() {
  6280. var name;
  6281. if (SETTINGS.hiddenName === true) {
  6282. name = ELEMENT.name;
  6283. ELEMENT.name = '';
  6284. } else {
  6285. name = [typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '', typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit'];
  6286. name = name[0] + ELEMENT.name + name[1];
  6287. }
  6288. P._hidden = $('<input ' + 'type=hidden ' +
  6289. // Create the name using the original input’s with a prefix and suffix.
  6290. 'name="' + name + '"' + (
  6291. // If the element has a value, set the hidden value as well.
  6292. $ELEMENT.data('value') || ELEMENT.value ? ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' : '') + '>')[0];
  6293. $ELEMENT.
  6294. // If the value changes, update the hidden input with the correct format.
  6295. on('change.' + STATE.id, function () {
  6296. P._hidden.value = ELEMENT.value ? P.get('select', SETTINGS.formatSubmit) : '';
  6297. });
  6298. // Insert the hidden input as specified in the settings.
  6299. if (SETTINGS.container) $(SETTINGS.container).append(P._hidden); else $ELEMENT.before(P._hidden);
  6300. }
  6301. // For iOS8.
  6302. function handleKeydownEvent(event) {
  6303. var keycode = event.keyCode,
  6304. // Check if one of the delete keys was pressed.
  6305. isKeycodeDelete = /^(8|46)$/.test(keycode);
  6306. // For some reason IE clears the input value on “escape”.
  6307. if (keycode == 27) {
  6308. P.close();
  6309. return false;
  6310. }
  6311. // Check if `space` or `delete` was pressed or the picker is closed with a key movement.
  6312. if (keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode]) {
  6313. // Prevent it from moving the page and bubbling to doc.
  6314. event.preventDefault();
  6315. event.stopPropagation();
  6316. // If `delete` was pressed, clear the values and close the picker.
  6317. // Otherwise open the picker.
  6318. if (isKeycodeDelete) {
  6319. P.clear().close();
  6320. } else {
  6321. P.open();
  6322. }
  6323. }
  6324. }
  6325. // Separated for IE
  6326. function handleFocusToOpenEvent(event) {
  6327. // Stop the event from propagating to the doc.
  6328. event.stopPropagation();
  6329. // If it’s a focus event, add the “focused” class to the root.
  6330. if (event.type == 'focus') {
  6331. P.$root.addClass(CLASSES.focused);
  6332. }
  6333. // And then finally open the picker.
  6334. P.open();
  6335. }
  6336. // Return a new picker instance.
  6337. return new PickerInstance();
  6338. } //PickerConstructor
  6339. /**
  6340. * The default classes and prefix to use for the HTML classes.
  6341. */
  6342. PickerConstructor.klasses = function (prefix) {
  6343. prefix = prefix || 'picker';
  6344. return {
  6345. picker: prefix,
  6346. opened: prefix + '--opened',
  6347. focused: prefix + '--focused',
  6348. input: prefix + '__input',
  6349. active: prefix + '__input--active',
  6350. target: prefix + '__input--target',
  6351. holder: prefix + '__holder',
  6352. frame: prefix + '__frame',
  6353. wrap: prefix + '__wrap',
  6354. box: prefix + '__box'
  6355. };
  6356. }; //PickerConstructor.klasses
  6357. /**
  6358. * Check if the default theme is being used.
  6359. */
  6360. function isUsingDefaultTheme(element) {
  6361. var theme,
  6362. prop = 'position';
  6363. // For IE.
  6364. if (element.currentStyle) {
  6365. theme = element.currentStyle[prop];
  6366. }
  6367. // For normal browsers.
  6368. else if (window.getComputedStyle) {
  6369. theme = getComputedStyle(element)[prop];
  6370. }
  6371. return theme == 'fixed';
  6372. }
  6373. /**
  6374. * Get the width of the browser’s scrollbar.
  6375. * Taken from: https://github.com/VodkaBears/Remodal/blob/master/src/jquery.remodal.js
  6376. */
  6377. function getScrollbarWidth() {
  6378. if ($html.height() <= $window.height()) {
  6379. return 0;
  6380. }
  6381. var $outer = $('<div style="visibility:hidden;width:100px" />').appendTo('body');
  6382. // Get the width without scrollbars.
  6383. var widthWithoutScroll = $outer[0].offsetWidth;
  6384. // Force adding scrollbars.
  6385. $outer.css('overflow', 'scroll');
  6386. // Add the inner div.
  6387. var $inner = $('<div style="width:100%" />').appendTo($outer);
  6388. // Get the width with scrollbars.
  6389. var widthWithScroll = $inner[0].offsetWidth;
  6390. // Remove the divs.
  6391. $outer.remove();
  6392. // Return the difference between the widths.
  6393. return widthWithoutScroll - widthWithScroll;
  6394. }
  6395. /**
  6396. * PickerConstructor helper methods.
  6397. */
  6398. PickerConstructor._ = {
  6399. /**
  6400. * Create a group of nodes. Expects:
  6401. * `
  6402. {
  6403. min: {Integer},
  6404. max: {Integer},
  6405. i: {Integer},
  6406. node: {String},
  6407. item: {Function}
  6408. }
  6409. * `
  6410. */
  6411. group: function (groupObject) {
  6412. var
  6413. // Scope for the looped object
  6414. loopObjectScope,
  6415. // Create the nodes list
  6416. nodesList = '',
  6417. // The counter starts from the `min`
  6418. counter = PickerConstructor._.trigger(groupObject.min, groupObject);
  6419. // Loop from the `min` to `max`, incrementing by `i`
  6420. for (; counter <= PickerConstructor._.trigger(groupObject.max, groupObject, [counter]); counter += groupObject.i) {
  6421. // Trigger the `item` function within scope of the object
  6422. loopObjectScope = PickerConstructor._.trigger(groupObject.item, groupObject, [counter]);
  6423. // Splice the subgroup and create nodes out of the sub nodes
  6424. nodesList += PickerConstructor._.node(groupObject.node, loopObjectScope[0], // the node
  6425. loopObjectScope[1], // the classes
  6426. loopObjectScope[2] // the attributes
  6427. );
  6428. }
  6429. // Return the list of nodes
  6430. return nodesList;
  6431. }, //group
  6432. /**
  6433. * Create a dom node string
  6434. */
  6435. node: function (wrapper, item, klass, attribute) {
  6436. // If the item is false-y, just return an empty string
  6437. if (!item) return '';
  6438. // If the item is an array, do a join
  6439. item = $.isArray(item) ? item.join('') : item;
  6440. // Check for the class
  6441. klass = klass ? ' class="' + klass + '"' : '';
  6442. // Check for any attributes
  6443. attribute = attribute ? ' ' + attribute : '';
  6444. // Return the wrapped item
  6445. return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>';
  6446. }, //node
  6447. /**
  6448. * Lead numbers below 10 with a zero.
  6449. */
  6450. lead: function (number) {
  6451. return (number < 10 ? '0' : '') + number;
  6452. },
  6453. /**
  6454. * Trigger a function otherwise return the value.
  6455. */
  6456. trigger: function (callback, scope, args) {
  6457. return typeof callback == 'function' ? callback.apply(scope, args || []) : callback;
  6458. },
  6459. /**
  6460. * If the second character is a digit, length is 2 otherwise 1.
  6461. */
  6462. digits: function (string) {
  6463. return (/\d/.test(string[1]) ? 2 : 1
  6464. );
  6465. },
  6466. /**
  6467. * Tell if something is a date object.
  6468. */
  6469. isDate: function (value) {
  6470. return {}.toString.call(value).indexOf('Date') > -1 && this.isInteger(value.getDate());
  6471. },
  6472. /**
  6473. * Tell if something is an integer.
  6474. */
  6475. isInteger: function (value) {
  6476. return {}.toString.call(value).indexOf('Number') > -1 && value % 1 === 0;
  6477. },
  6478. /**
  6479. * Create ARIA attribute strings.
  6480. */
  6481. ariaAttr: ariaAttr //PickerConstructor._
  6482. /**
  6483. * Extend the picker with a component and defaults.
  6484. */
  6485. }; PickerConstructor.extend = function (name, Component) {
  6486. // Extend jQuery.
  6487. $.fn[name] = function (options, action) {
  6488. // Grab the component data.
  6489. var componentData = this.data(name);
  6490. // If the picker is requested, return the data object.
  6491. if (options == 'picker') {
  6492. return componentData;
  6493. }
  6494. // If the component data exists and `options` is a string, carry out the action.
  6495. if (componentData && typeof options == 'string') {
  6496. return PickerConstructor._.trigger(componentData[options], componentData, [action]);
  6497. }
  6498. // Otherwise go through each matched element and if the component
  6499. // doesn’t exist, create a new picker using `this` element
  6500. // and merging the defaults and options with a deep copy.
  6501. return this.each(function () {
  6502. var $this = $(this);
  6503. if (!$this.data(name)) {
  6504. new PickerConstructor(this, name, Component, options);
  6505. }
  6506. });
  6507. };
  6508. // Set the defaults.
  6509. $.fn[name].defaults = Component.defaults;
  6510. }; //PickerConstructor.extend
  6511. function aria(element, attribute, value) {
  6512. if ($.isPlainObject(attribute)) {
  6513. for (var key in attribute) {
  6514. ariaSet(element, key, attribute[key]);
  6515. }
  6516. } else {
  6517. ariaSet(element, attribute, value);
  6518. }
  6519. }
  6520. function ariaSet(element, attribute, value) {
  6521. element.setAttribute((attribute == 'role' ? '' : 'aria-') + attribute, value);
  6522. }
  6523. function ariaAttr(attribute, data) {
  6524. if (!$.isPlainObject(attribute)) {
  6525. attribute = { attribute: data };
  6526. }
  6527. data = '';
  6528. for (var key in attribute) {
  6529. var attr = (key == 'role' ? '' : 'aria-') + key,
  6530. attrVal = attribute[key];
  6531. data += attrVal == null ? '' : attr + '="' + attribute[key] + '"';
  6532. }
  6533. return data;
  6534. }
  6535. // IE8 bug throws an error for activeElements within iframes.
  6536. function getActiveElement() {
  6537. try {
  6538. return document.activeElement;
  6539. } catch (err) { }
  6540. }
  6541. // Expose the picker constructor.
  6542. return PickerConstructor;
  6543. });
  6544. ; /*!
  6545. * Date picker for pickadate.js v3.5.0
  6546. * http://amsul.github.io/pickadate.js/date.htm
  6547. */
  6548. (function (factory) {
  6549. factory(Materialize.Picker, jQuery);
  6550. })(function (Picker, $) {
  6551. /**
  6552. * Globals and constants
  6553. */
  6554. var DAYS_IN_WEEK = 7,
  6555. WEEKS_IN_CALENDAR = 6,
  6556. _ = Picker._;
  6557. /**
  6558. * The date picker constructor
  6559. */
  6560. function DatePicker(picker, settings) {
  6561. var calendar = this,
  6562. element = picker.$node[0],
  6563. elementValue = element.value,
  6564. elementDataValue = picker.$node.data('value'),
  6565. valueString = elementDataValue || elementValue,
  6566. formatString = elementDataValue ? settings.formatSubmit : settings.format,
  6567. isRTL = function () {
  6568. return element.currentStyle ?
  6569. // For IE.
  6570. element.currentStyle.direction == 'rtl' :
  6571. // For normal browsers.
  6572. getComputedStyle(picker.$root[0]).direction == 'rtl';
  6573. };
  6574. calendar.settings = settings;
  6575. calendar.$node = picker.$node;
  6576. // The queue of methods that will be used to build item objects.
  6577. calendar.queue = {
  6578. min: 'measure create',
  6579. max: 'measure create',
  6580. now: 'now create',
  6581. select: 'parse create validate',
  6582. highlight: 'parse navigate create validate',
  6583. view: 'parse create validate viewset',
  6584. disable: 'deactivate',
  6585. enable: 'activate'
  6586. // The component's item object.
  6587. }; calendar.item = {};
  6588. calendar.item.clear = null;
  6589. calendar.item.disable = (settings.disable || []).slice(0);
  6590. calendar.item.enable = -function (collectionDisabled) {
  6591. return collectionDisabled[0] === true ? collectionDisabled.shift() : -1;
  6592. }(calendar.item.disable);
  6593. calendar.set('min', settings.min).set('max', settings.max).set('now');
  6594. // When there’s a value, set the `select`, which in turn
  6595. // also sets the `highlight` and `view`.
  6596. if (valueString) {
  6597. calendar.set('select', valueString, { format: formatString });
  6598. }
  6599. // If there’s no value, default to highlighting “today”.
  6600. else {
  6601. calendar.set('select', null).set('highlight', calendar.item.now);
  6602. }
  6603. // The keycode to movement mapping.
  6604. calendar.key = {
  6605. 40: 7, // Down
  6606. 38: -7, // Up
  6607. 39: function () {
  6608. return isRTL() ? -1 : 1;
  6609. }, // Right
  6610. 37: function () {
  6611. return isRTL() ? 1 : -1;
  6612. }, // Left
  6613. go: function (timeChange) {
  6614. var highlightedObject = calendar.item.highlight,
  6615. targetDate = new Date(highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange);
  6616. calendar.set('highlight', targetDate, { interval: timeChange });
  6617. this.render();
  6618. }
  6619. // Bind some picker events.
  6620. }; picker.on('render', function () {
  6621. picker.$root.find('.' + settings.klass.selectMonth).on('change', function () {
  6622. var value = this.value;
  6623. if (value) {
  6624. picker.set('highlight', [picker.get('view').year, value, picker.get('highlight').date]);
  6625. picker.$root.find('.' + settings.klass.selectMonth).trigger('focus');
  6626. }
  6627. });
  6628. picker.$root.find('.' + settings.klass.selectYear).on('change', function () {
  6629. var value = this.value;
  6630. if (value) {
  6631. picker.set('highlight', [value, picker.get('view').month, picker.get('highlight').date]);
  6632. picker.$root.find('.' + settings.klass.selectYear).trigger('focus');
  6633. }
  6634. });
  6635. }, 1).on('open', function () {
  6636. var includeToday = '';
  6637. if (calendar.disabled(calendar.get('now'))) {
  6638. includeToday = ':not(.' + settings.klass.buttonToday + ')';
  6639. }
  6640. picker.$root.find('button' + includeToday + ', select').attr('disabled', false);
  6641. }, 1).on('close', function () {
  6642. picker.$root.find('button, select').attr('disabled', true);
  6643. }, 1);
  6644. } //DatePicker
  6645. /**
  6646. * Set a datepicker item object.
  6647. */
  6648. DatePicker.prototype.set = function (type, value, options) {
  6649. var calendar = this,
  6650. calendarItem = calendar.item;
  6651. // If the value is `null` just set it immediately.
  6652. if (value === null) {
  6653. if (type == 'clear') type = 'select';
  6654. calendarItem[type] = value;
  6655. return calendar;
  6656. }
  6657. // Otherwise go through the queue of methods, and invoke the functions.
  6658. // Update this as the time unit, and set the final value as this item.
  6659. // * In the case of `enable`, keep the queue but set `disable` instead.
  6660. // And in the case of `flip`, keep the queue but set `enable` instead.
  6661. calendarItem[type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type] = calendar.queue[type].split(' ').map(function (method) {
  6662. value = calendar[method](type, value, options);
  6663. return value;
  6664. }).pop();
  6665. // Check if we need to cascade through more updates.
  6666. if (type == 'select') {
  6667. calendar.set('highlight', calendarItem.select, options);
  6668. } else if (type == 'highlight') {
  6669. calendar.set('view', calendarItem.highlight, options);
  6670. } else if (type.match(/^(flip|min|max|disable|enable)$/)) {
  6671. if (calendarItem.select && calendar.disabled(calendarItem.select)) {
  6672. calendar.set('select', calendarItem.select, options);
  6673. }
  6674. if (calendarItem.highlight && calendar.disabled(calendarItem.highlight)) {
  6675. calendar.set('highlight', calendarItem.highlight, options);
  6676. }
  6677. }
  6678. return calendar;
  6679. }; //DatePicker.prototype.set
  6680. /**
  6681. * Get a datepicker item object.
  6682. */
  6683. DatePicker.prototype.get = function (type) {
  6684. return this.item[type];
  6685. }; //DatePicker.prototype.get
  6686. /**
  6687. * Create a picker date object.
  6688. */
  6689. DatePicker.prototype.create = function (type, value, options) {
  6690. var isInfiniteValue,
  6691. calendar = this;
  6692. // If there’s no value, use the type as the value.
  6693. value = value === undefined ? type : value;
  6694. // If it’s infinity, update the value.
  6695. if (value == -Infinity || value == Infinity) {
  6696. isInfiniteValue = value;
  6697. }
  6698. // If it’s an object, use the native date object.
  6699. else if ($.isPlainObject(value) && _.isInteger(value.pick)) {
  6700. value = value.obj;
  6701. }
  6702. // If it’s an array, convert it into a date and make sure
  6703. // that it’s a valid date – otherwise default to today.
  6704. else if ($.isArray(value)) {
  6705. value = new Date(value[0], value[1], value[2]);
  6706. value = _.isDate(value) ? value : calendar.create().obj;
  6707. }
  6708. // If it’s a number or date object, make a normalized date.
  6709. else if (_.isInteger(value) || _.isDate(value)) {
  6710. value = calendar.normalize(new Date(value), options);
  6711. }
  6712. // If it’s a literal true or any other case, set it to now.
  6713. else /*if ( value === true )*/ {
  6714. value = calendar.now(type, value, options);
  6715. }
  6716. // Return the compiled object.
  6717. return {
  6718. year: isInfiniteValue || value.getFullYear(),
  6719. month: isInfiniteValue || value.getMonth(),
  6720. date: isInfiniteValue || value.getDate(),
  6721. day: isInfiniteValue || value.getDay(),
  6722. obj: isInfiniteValue || value,
  6723. pick: isInfiniteValue || value.getTime()
  6724. };
  6725. }; //DatePicker.prototype.create
  6726. /**
  6727. * Create a range limit object using an array, date object,
  6728. * literal “true”, or integer relative to another time.
  6729. */
  6730. DatePicker.prototype.createRange = function (from, to) {
  6731. var calendar = this,
  6732. createDate = function (date) {
  6733. if (date === true || $.isArray(date) || _.isDate(date)) {
  6734. return calendar.create(date);
  6735. }
  6736. return date;
  6737. };
  6738. // Create objects if possible.
  6739. if (!_.isInteger(from)) {
  6740. from = createDate(from);
  6741. }
  6742. if (!_.isInteger(to)) {
  6743. to = createDate(to);
  6744. }
  6745. // Create relative dates.
  6746. if (_.isInteger(from) && $.isPlainObject(to)) {
  6747. from = [to.year, to.month, to.date + from];
  6748. } else if (_.isInteger(to) && $.isPlainObject(from)) {
  6749. to = [from.year, from.month, from.date + to];
  6750. }
  6751. return {
  6752. from: createDate(from),
  6753. to: createDate(to)
  6754. };
  6755. }; //DatePicker.prototype.createRange
  6756. /**
  6757. * Check if a date unit falls within a date range object.
  6758. */
  6759. DatePicker.prototype.withinRange = function (range, dateUnit) {
  6760. range = this.createRange(range.from, range.to);
  6761. return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick;
  6762. };
  6763. /**
  6764. * Check if two date range objects overlap.
  6765. */
  6766. DatePicker.prototype.overlapRanges = function (one, two) {
  6767. var calendar = this;
  6768. // Convert the ranges into comparable dates.
  6769. one = calendar.createRange(one.from, one.to);
  6770. two = calendar.createRange(two.from, two.to);
  6771. return calendar.withinRange(one, two.from) || calendar.withinRange(one, two.to) || calendar.withinRange(two, one.from) || calendar.withinRange(two, one.to);
  6772. };
  6773. /**
  6774. * Get the date today.
  6775. */
  6776. DatePicker.prototype.now = function (type, value, options) {
  6777. value = new Date();
  6778. if (options && options.rel) {
  6779. value.setDate(value.getDate() + options.rel);
  6780. }
  6781. return this.normalize(value, options);
  6782. };
  6783. /**
  6784. * Navigate to next/prev month.
  6785. */
  6786. DatePicker.prototype.navigate = function (type, value, options) {
  6787. var targetDateObject,
  6788. targetYear,
  6789. targetMonth,
  6790. targetDate,
  6791. isTargetArray = $.isArray(value),
  6792. isTargetObject = $.isPlainObject(value),
  6793. viewsetObject = this.item.view; /*,
  6794. safety = 100*/
  6795. if (isTargetArray || isTargetObject) {
  6796. if (isTargetObject) {
  6797. targetYear = value.year;
  6798. targetMonth = value.month;
  6799. targetDate = value.date;
  6800. } else {
  6801. targetYear = +value[0];
  6802. targetMonth = +value[1];
  6803. targetDate = +value[2];
  6804. }
  6805. // If we’re navigating months but the view is in a different
  6806. // month, navigate to the view’s year and month.
  6807. if (options && options.nav && viewsetObject && viewsetObject.month !== targetMonth) {
  6808. targetYear = viewsetObject.year;
  6809. targetMonth = viewsetObject.month;
  6810. }
  6811. // Figure out the expected target year and month.
  6812. targetDateObject = new Date(targetYear, targetMonth + (options && options.nav ? options.nav : 0), 1);
  6813. targetYear = targetDateObject.getFullYear();
  6814. targetMonth = targetDateObject.getMonth();
  6815. // If the month we’re going to doesn’t have enough days,
  6816. // keep decreasing the date until we reach the month’s last date.
  6817. while ( /*safety &&*/new Date(targetYear, targetMonth, targetDate).getMonth() !== targetMonth) {
  6818. targetDate -= 1;
  6819. /*safety -= 1
  6820. if ( !safety ) {
  6821. throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.'
  6822. }*/
  6823. }
  6824. value = [targetYear, targetMonth, targetDate];
  6825. }
  6826. return value;
  6827. }; //DatePicker.prototype.navigate
  6828. /**
  6829. * Normalize a date by setting the hours to midnight.
  6830. */
  6831. DatePicker.prototype.normalize = function (value /*, options*/) {
  6832. value.setHours(0, 0, 0, 0);
  6833. return value;
  6834. };
  6835. /**
  6836. * Measure the range of dates.
  6837. */
  6838. DatePicker.prototype.measure = function (type, value /*, options*/) {
  6839. var calendar = this;
  6840. // If it’s anything false-y, remove the limits.
  6841. if (!value) {
  6842. value = type == 'min' ? -Infinity : Infinity;
  6843. }
  6844. // If it’s a string, parse it.
  6845. else if (typeof value == 'string') {
  6846. value = calendar.parse(type, value);
  6847. }
  6848. // If it's an integer, get a date relative to today.
  6849. else if (_.isInteger(value)) {
  6850. value = calendar.now(type, value, { rel: value });
  6851. }
  6852. return value;
  6853. }; ///DatePicker.prototype.measure
  6854. /**
  6855. * Create a viewset object based on navigation.
  6856. */
  6857. DatePicker.prototype.viewset = function (type, dateObject /*, options*/) {
  6858. return this.create([dateObject.year, dateObject.month, 1]);
  6859. };
  6860. /**
  6861. * Validate a date as enabled and shift if needed.
  6862. */
  6863. DatePicker.prototype.validate = function (type, dateObject, options) {
  6864. var calendar = this,
  6865. // Keep a reference to the original date.
  6866. originalDateObject = dateObject,
  6867. // Make sure we have an interval.
  6868. interval = options && options.interval ? options.interval : 1,
  6869. // Check if the calendar enabled dates are inverted.
  6870. isFlippedBase = calendar.item.enable === -1,
  6871. // Check if we have any enabled dates after/before now.
  6872. hasEnabledBeforeTarget,
  6873. hasEnabledAfterTarget,
  6874. // The min & max limits.
  6875. minLimitObject = calendar.item.min,
  6876. maxLimitObject = calendar.item.max,
  6877. // Check if we’ve reached the limit during shifting.
  6878. reachedMin,
  6879. reachedMax,
  6880. // Check if the calendar is inverted and at least one weekday is enabled.
  6881. hasEnabledWeekdays = isFlippedBase && calendar.item.disable.filter(function (value) {
  6882. // If there’s a date, check where it is relative to the target.
  6883. if ($.isArray(value)) {
  6884. var dateTime = calendar.create(value).pick;
  6885. if (dateTime < dateObject.pick) hasEnabledBeforeTarget = true; else if (dateTime > dateObject.pick) hasEnabledAfterTarget = true;
  6886. }
  6887. // Return only integers for enabled weekdays.
  6888. return _.isInteger(value);
  6889. }).length; /*,
  6890. safety = 100*/
  6891. // Cases to validate for:
  6892. // [1] Not inverted and date disabled.
  6893. // [2] Inverted and some dates enabled.
  6894. // [3] Not inverted and out of range.
  6895. //
  6896. // Cases to **not** validate for:
  6897. // • Navigating months.
  6898. // • Not inverted and date enabled.
  6899. // • Inverted and all dates disabled.
  6900. // • ..and anything else.
  6901. if (!options || !options.nav) if (
  6902. /* 1 */!isFlippedBase && calendar.disabled(dateObject) ||
  6903. /* 2 */isFlippedBase && calendar.disabled(dateObject) && (hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget) ||
  6904. /* 3 */ !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick)) {
  6905. // When inverted, flip the direction if there aren’t any enabled weekdays
  6906. // and there are no enabled dates in the direction of the interval.
  6907. if (isFlippedBase && !hasEnabledWeekdays && (!hasEnabledAfterTarget && interval > 0 || !hasEnabledBeforeTarget && interval < 0)) {
  6908. interval *= -1;
  6909. }
  6910. // Keep looping until we reach an enabled date.
  6911. while ( /*safety &&*/calendar.disabled(dateObject)) {
  6912. /*safety -= 1
  6913. if ( !safety ) {
  6914. throw 'Fell into an infinite loop while validating ' + dateObject.obj + '.'
  6915. }*/
  6916. // If we’ve looped into the next/prev month with a large interval, return to the original date and flatten the interval.
  6917. if (Math.abs(interval) > 1 && (dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month)) {
  6918. dateObject = originalDateObject;
  6919. interval = interval > 0 ? 1 : -1;
  6920. }
  6921. // If we’ve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit.
  6922. if (dateObject.pick <= minLimitObject.pick) {
  6923. reachedMin = true;
  6924. interval = 1;
  6925. dateObject = calendar.create([minLimitObject.year, minLimitObject.month, minLimitObject.date + (dateObject.pick === minLimitObject.pick ? 0 : -1)]);
  6926. } else if (dateObject.pick >= maxLimitObject.pick) {
  6927. reachedMax = true;
  6928. interval = -1;
  6929. dateObject = calendar.create([maxLimitObject.year, maxLimitObject.month, maxLimitObject.date + (dateObject.pick === maxLimitObject.pick ? 0 : 1)]);
  6930. }
  6931. // If we’ve reached both limits, just break out of the loop.
  6932. if (reachedMin && reachedMax) {
  6933. break;
  6934. }
  6935. // Finally, create the shifted date using the interval and keep looping.
  6936. dateObject = calendar.create([dateObject.year, dateObject.month, dateObject.date + interval]);
  6937. }
  6938. } //endif
  6939. // Return the date object settled on.
  6940. return dateObject;
  6941. }; //DatePicker.prototype.validate
  6942. /**
  6943. * Check if a date is disabled.
  6944. */
  6945. DatePicker.prototype.disabled = function (dateToVerify) {
  6946. var calendar = this,
  6947. // Filter through the disabled dates to check if this is one.
  6948. isDisabledMatch = calendar.item.disable.filter(function (dateToDisable) {
  6949. // If the date is a number, match the weekday with 0index and `firstDay` check.
  6950. if (_.isInteger(dateToDisable)) {
  6951. return dateToVerify.day === (calendar.settings.firstDay ? dateToDisable : dateToDisable - 1) % 7;
  6952. }
  6953. // If it’s an array or a native JS date, create and match the exact date.
  6954. if ($.isArray(dateToDisable) || _.isDate(dateToDisable)) {
  6955. return dateToVerify.pick === calendar.create(dateToDisable).pick;
  6956. }
  6957. // If it’s an object, match a date within the “from” and “to” range.
  6958. if ($.isPlainObject(dateToDisable)) {
  6959. return calendar.withinRange(dateToDisable, dateToVerify);
  6960. }
  6961. });
  6962. // If this date matches a disabled date, confirm it’s not inverted.
  6963. isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function (dateToDisable) {
  6964. return $.isArray(dateToDisable) && dateToDisable[3] == 'inverted' || $.isPlainObject(dateToDisable) && dateToDisable.inverted;
  6965. }).length;
  6966. // Check the calendar “enabled” flag and respectively flip the
  6967. // disabled state. Then also check if it’s beyond the min/max limits.
  6968. return calendar.item.enable === -1 ? !isDisabledMatch : isDisabledMatch || dateToVerify.pick < calendar.item.min.pick || dateToVerify.pick > calendar.item.max.pick;
  6969. }; //DatePicker.prototype.disabled
  6970. /**
  6971. * Parse a string into a usable type.
  6972. */
  6973. DatePicker.prototype.parse = function (type, value, options) {
  6974. var calendar = this,
  6975. parsingObject = {};
  6976. // If it’s already parsed, we’re good.
  6977. if (!value || typeof value != 'string') {
  6978. return value;
  6979. }
  6980. // We need a `.format` to parse the value with.
  6981. if (!(options && options.format)) {
  6982. options = options || {};
  6983. options.format = calendar.settings.format;
  6984. }
  6985. // Convert the format into an array and then map through it.
  6986. calendar.formats.toArray(options.format).map(function (label) {
  6987. var
  6988. // Grab the formatting label.
  6989. formattingLabel = calendar.formats[label],
  6990. // The format length is from the formatting label function or the
  6991. // label length without the escaping exclamation (!) mark.
  6992. formatLength = formattingLabel ? _.trigger(formattingLabel, calendar, [value, parsingObject]) : label.replace(/^!/, '').length;
  6993. // If there's a format label, split the value up to the format length.
  6994. // Then add it to the parsing object with appropriate label.
  6995. if (formattingLabel) {
  6996. parsingObject[label] = value.substr(0, formatLength);
  6997. }
  6998. // Update the value as the substring from format length to end.
  6999. value = value.substr(formatLength);
  7000. });
  7001. // Compensate for month 0index.
  7002. return [parsingObject.yyyy || parsingObject.yy, +(parsingObject.mm || parsingObject.m) - 1, parsingObject.dd || parsingObject.d];
  7003. }; //DatePicker.prototype.parse
  7004. /**
  7005. * Various formats to display the object in.
  7006. */
  7007. DatePicker.prototype.formats = function () {
  7008. // Return the length of the first word in a collection.
  7009. function getWordLengthFromCollection(string, collection, dateObject) {
  7010. // Grab the first word from the string.
  7011. var word = string.match(/\w+/)[0];
  7012. // If there's no month index, add it to the date object
  7013. if (!dateObject.mm && !dateObject.m) {
  7014. dateObject.m = collection.indexOf(word) + 1;
  7015. }
  7016. // Return the length of the word.
  7017. return word.length;
  7018. }
  7019. // Get the length of the first word in a string.
  7020. function getFirstWordLength(string) {
  7021. return string.match(/\w+/)[0].length;
  7022. }
  7023. return {
  7024. d: function (string, dateObject) {
  7025. // If there's string, then get the digits length.
  7026. // Otherwise return the selected date.
  7027. return string ? _.digits(string) : dateObject.date;
  7028. },
  7029. dd: function (string, dateObject) {
  7030. // If there's a string, then the length is always 2.
  7031. // Otherwise return the selected date with a leading zero.
  7032. return string ? 2 : _.lead(dateObject.date);
  7033. },
  7034. ddd: function (string, dateObject) {
  7035. // If there's a string, then get the length of the first word.
  7036. // Otherwise return the short selected weekday.
  7037. return string ? getFirstWordLength(string) : this.settings.weekdaysShort[dateObject.day];
  7038. },
  7039. dddd: function (string, dateObject) {
  7040. // If there's a string, then get the length of the first word.
  7041. // Otherwise return the full selected weekday.
  7042. return string ? getFirstWordLength(string) : this.settings.weekdaysFull[dateObject.day];
  7043. },
  7044. m: function (string, dateObject) {
  7045. // If there's a string, then get the length of the digits
  7046. // Otherwise return the selected month with 0index compensation.
  7047. return string ? _.digits(string) : dateObject.month + 1;
  7048. },
  7049. mm: function (string, dateObject) {
  7050. // If there's a string, then the length is always 2.
  7051. // Otherwise return the selected month with 0index and leading zero.
  7052. return string ? 2 : _.lead(dateObject.month + 1);
  7053. },
  7054. mmm: function (string, dateObject) {
  7055. var collection = this.settings.monthsShort;
  7056. // If there's a string, get length of the relevant month from the short
  7057. // months collection. Otherwise return the selected month from that collection.
  7058. return string ? getWordLengthFromCollection(string, collection, dateObject) : collection[dateObject.month];
  7059. },
  7060. mmmm: function (string, dateObject) {
  7061. var collection = this.settings.monthsFull;
  7062. // If there's a string, get length of the relevant month from the full
  7063. // months collection. Otherwise return the selected month from that collection.
  7064. return string ? getWordLengthFromCollection(string, collection, dateObject) : collection[dateObject.month];
  7065. },
  7066. yy: function (string, dateObject) {
  7067. // If there's a string, then the length is always 2.
  7068. // Otherwise return the selected year by slicing out the first 2 digits.
  7069. return string ? 2 : ('' + dateObject.year).slice(2);
  7070. },
  7071. yyyy: function (string, dateObject) {
  7072. // If there's a string, then the length is always 4.
  7073. // Otherwise return the selected year.
  7074. return string ? 4 : dateObject.year;
  7075. },
  7076. // Create an array by splitting the formatting string passed.
  7077. toArray: function (formatString) {
  7078. return formatString.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g);
  7079. },
  7080. // Format an object into a string using the formatting options.
  7081. toString: function (formatString, itemObject) {
  7082. var calendar = this;
  7083. return calendar.formats.toArray(formatString).map(function (label) {
  7084. return _.trigger(calendar.formats[label], calendar, [0, itemObject]) || label.replace(/^!/, '');
  7085. }).join('');
  7086. }
  7087. };
  7088. }(); //DatePicker.prototype.formats
  7089. /**
  7090. * Check if two date units are the exact.
  7091. */
  7092. DatePicker.prototype.isDateExact = function (one, two) {
  7093. var calendar = this;
  7094. // When we’re working with weekdays, do a direct comparison.
  7095. if (_.isInteger(one) && _.isInteger(two) || typeof one == 'boolean' && typeof two == 'boolean') {
  7096. return one === two;
  7097. }
  7098. // When we’re working with date representations, compare the “pick” value.
  7099. if ((_.isDate(one) || $.isArray(one)) && (_.isDate(two) || $.isArray(two))) {
  7100. return calendar.create(one).pick === calendar.create(two).pick;
  7101. }
  7102. // When we’re working with range objects, compare the “from” and “to”.
  7103. if ($.isPlainObject(one) && $.isPlainObject(two)) {
  7104. return calendar.isDateExact(one.from, two.from) && calendar.isDateExact(one.to, two.to);
  7105. }
  7106. return false;
  7107. };
  7108. /**
  7109. * Check if two date units overlap.
  7110. */
  7111. DatePicker.prototype.isDateOverlap = function (one, two) {
  7112. var calendar = this,
  7113. firstDay = calendar.settings.firstDay ? 1 : 0;
  7114. // When we’re working with a weekday index, compare the days.
  7115. if (_.isInteger(one) && (_.isDate(two) || $.isArray(two))) {
  7116. one = one % 7 + firstDay;
  7117. return one === calendar.create(two).day + 1;
  7118. }
  7119. if (_.isInteger(two) && (_.isDate(one) || $.isArray(one))) {
  7120. two = two % 7 + firstDay;
  7121. return two === calendar.create(one).day + 1;
  7122. }
  7123. // When we’re working with range objects, check if the ranges overlap.
  7124. if ($.isPlainObject(one) && $.isPlainObject(two)) {
  7125. return calendar.overlapRanges(one, two);
  7126. }
  7127. return false;
  7128. };
  7129. /**
  7130. * Flip the “enabled” state.
  7131. */
  7132. DatePicker.prototype.flipEnable = function (val) {
  7133. var itemObject = this.item;
  7134. itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1);
  7135. };
  7136. /**
  7137. * Mark a collection of dates as “disabled”.
  7138. */
  7139. DatePicker.prototype.deactivate = function (type, datesToDisable) {
  7140. var calendar = this,
  7141. disabledItems = calendar.item.disable.slice(0);
  7142. // If we’re flipping, that’s all we need to do.
  7143. if (datesToDisable == 'flip') {
  7144. calendar.flipEnable();
  7145. } else if (datesToDisable === false) {
  7146. calendar.flipEnable(1);
  7147. disabledItems = [];
  7148. } else if (datesToDisable === true) {
  7149. calendar.flipEnable(-1);
  7150. disabledItems = [];
  7151. }
  7152. // Otherwise go through the dates to disable.
  7153. else {
  7154. datesToDisable.map(function (unitToDisable) {
  7155. var matchFound;
  7156. // When we have disabled items, check for matches.
  7157. // If something is matched, immediately break out.
  7158. for (var index = 0; index < disabledItems.length; index += 1) {
  7159. if (calendar.isDateExact(unitToDisable, disabledItems[index])) {
  7160. matchFound = true;
  7161. break;
  7162. }
  7163. }
  7164. // If nothing was found, add the validated unit to the collection.
  7165. if (!matchFound) {
  7166. if (_.isInteger(unitToDisable) || _.isDate(unitToDisable) || $.isArray(unitToDisable) || $.isPlainObject(unitToDisable) && unitToDisable.from && unitToDisable.to) {
  7167. disabledItems.push(unitToDisable);
  7168. }
  7169. }
  7170. });
  7171. }
  7172. // Return the updated collection.
  7173. return disabledItems;
  7174. }; //DatePicker.prototype.deactivate
  7175. /**
  7176. * Mark a collection of dates as “enabled”.
  7177. */
  7178. DatePicker.prototype.activate = function (type, datesToEnable) {
  7179. var calendar = this,
  7180. disabledItems = calendar.item.disable,
  7181. disabledItemsCount = disabledItems.length;
  7182. // If we’re flipping, that’s all we need to do.
  7183. if (datesToEnable == 'flip') {
  7184. calendar.flipEnable();
  7185. } else if (datesToEnable === true) {
  7186. calendar.flipEnable(1);
  7187. disabledItems = [];
  7188. } else if (datesToEnable === false) {
  7189. calendar.flipEnable(-1);
  7190. disabledItems = [];
  7191. }
  7192. // Otherwise go through the disabled dates.
  7193. else {
  7194. datesToEnable.map(function (unitToEnable) {
  7195. var matchFound, disabledUnit, index, isExactRange;
  7196. // Go through the disabled items and try to find a match.
  7197. for (index = 0; index < disabledItemsCount; index += 1) {
  7198. disabledUnit = disabledItems[index];
  7199. // When an exact match is found, remove it from the collection.
  7200. if (calendar.isDateExact(disabledUnit, unitToEnable)) {
  7201. matchFound = disabledItems[index] = null;
  7202. isExactRange = true;
  7203. break;
  7204. }
  7205. // When an overlapped match is found, add the “inverted” state to it.
  7206. else if (calendar.isDateOverlap(disabledUnit, unitToEnable)) {
  7207. if ($.isPlainObject(unitToEnable)) {
  7208. unitToEnable.inverted = true;
  7209. matchFound = unitToEnable;
  7210. } else if ($.isArray(unitToEnable)) {
  7211. matchFound = unitToEnable;
  7212. if (!matchFound[3]) matchFound.push('inverted');
  7213. } else if (_.isDate(unitToEnable)) {
  7214. matchFound = [unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted'];
  7215. }
  7216. break;
  7217. }
  7218. }
  7219. // If a match was found, remove a previous duplicate entry.
  7220. if (matchFound) for (index = 0; index < disabledItemsCount; index += 1) {
  7221. if (calendar.isDateExact(disabledItems[index], unitToEnable)) {
  7222. disabledItems[index] = null;
  7223. break;
  7224. }
  7225. }
  7226. // In the event that we’re dealing with an exact range of dates,
  7227. // make sure there are no “inverted” dates because of it.
  7228. if (isExactRange) for (index = 0; index < disabledItemsCount; index += 1) {
  7229. if (calendar.isDateOverlap(disabledItems[index], unitToEnable)) {
  7230. disabledItems[index] = null;
  7231. break;
  7232. }
  7233. }
  7234. // If something is still matched, add it into the collection.
  7235. if (matchFound) {
  7236. disabledItems.push(matchFound);
  7237. }
  7238. });
  7239. }
  7240. // Return the updated collection.
  7241. return disabledItems.filter(function (val) {
  7242. return val != null;
  7243. });
  7244. }; //DatePicker.prototype.activate
  7245. /**
  7246. * Create a string for the nodes in the picker.
  7247. */
  7248. DatePicker.prototype.nodes = function (isOpen) {
  7249. var calendar = this,
  7250. settings = calendar.settings,
  7251. calendarItem = calendar.item,
  7252. nowObject = calendarItem.now,
  7253. selectedObject = calendarItem.select,
  7254. highlightedObject = calendarItem.highlight,
  7255. viewsetObject = calendarItem.view,
  7256. disabledCollection = calendarItem.disable,
  7257. minLimitObject = calendarItem.min,
  7258. maxLimitObject = calendarItem.max,
  7259. // Create the calendar table head using a copy of weekday labels collection.
  7260. // * We do a copy so we don't mutate the original array.
  7261. tableHead = function (collection, fullCollection) {
  7262. // If the first day should be Monday, move Sunday to the end.
  7263. if (settings.firstDay) {
  7264. collection.push(collection.shift());
  7265. fullCollection.push(fullCollection.shift());
  7266. }
  7267. // Create and return the table head group.
  7268. return _.node('thead', _.node('tr', _.group({
  7269. min: 0,
  7270. max: DAYS_IN_WEEK - 1,
  7271. i: 1,
  7272. node: 'th',
  7273. item: function (counter) {
  7274. return [collection[counter], settings.klass.weekdays, 'scope=col title="' + fullCollection[counter] + '"'];
  7275. }
  7276. }))); //endreturn
  7277. // Materialize modified
  7278. }((settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysLetter).slice(0), settings.weekdaysFull.slice(0)),
  7279. //tableHead
  7280. // Create the nav for next/prev month.
  7281. createMonthNav = function (next) {
  7282. // Otherwise, return the created month tag.
  7283. return _.node('div', ' ', settings.klass['nav' + (next ? 'Next' : 'Prev')] + (
  7284. // If the focused month is outside the range, disabled the button.
  7285. 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({
  7286. role: 'button',
  7287. controls: calendar.$node[0].id + '_table'
  7288. }) + ' ' + 'title="' + (next ? settings.labelMonthNext : settings.labelMonthPrev) + '"'); //endreturn
  7289. },
  7290. //createMonthNav
  7291. // Create the month label.
  7292. //Materialize modified
  7293. createMonthLabel = function (override) {
  7294. var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull;
  7295. // Materialize modified
  7296. if (override == "short_months") {
  7297. monthsCollection = settings.monthsShort;
  7298. }
  7299. // If there are months to select, add a dropdown menu.
  7300. if (settings.selectMonths && override == undefined) {
  7301. return _.node('select', _.group({
  7302. min: 0,
  7303. max: 11,
  7304. i: 1,
  7305. node: 'option',
  7306. item: function (loopedMonth) {
  7307. return [
  7308. // The looped month and no classes.
  7309. monthsCollection[loopedMonth], 0,
  7310. // Set the value and selected index.
  7311. 'value=' + loopedMonth + (viewsetObject.month == loopedMonth ? ' selected' : '') + (viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month || viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month ? ' disabled' : '')];
  7312. }
  7313. }), settings.klass.selectMonth + ' browser-default', (isOpen ? '' : 'disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + 'title="' + settings.labelMonthSelect + '"');
  7314. }
  7315. // Materialize modified
  7316. if (override == "short_months") if (selectedObject != null) return monthsCollection[selectedObject.month]; else return monthsCollection[viewsetObject.month];
  7317. // If there's a need for a month selector
  7318. return _.node('div', monthsCollection[viewsetObject.month], settings.klass.month);
  7319. },
  7320. //createMonthLabel
  7321. // Create the year label.
  7322. // Materialize modified
  7323. createYearLabel = function (override) {
  7324. var focusedYear = viewsetObject.year,
  7325. // If years selector is set to a literal "true", set it to 5. Otherwise
  7326. // divide in half to get half before and half after focused year.
  7327. numberYears = settings.selectYears === true ? 5 : ~~(settings.selectYears / 2);
  7328. // If there are years to select, add a dropdown menu.
  7329. if (numberYears) {
  7330. var minYear = minLimitObject.year,
  7331. maxYear = maxLimitObject.year,
  7332. lowestYear = focusedYear - numberYears,
  7333. highestYear = focusedYear + numberYears;
  7334. // If the min year is greater than the lowest year, increase the highest year
  7335. // by the difference and set the lowest year to the min year.
  7336. if (minYear > lowestYear) {
  7337. highestYear += minYear - lowestYear;
  7338. lowestYear = minYear;
  7339. }
  7340. // If the max year is less than the highest year, decrease the lowest year
  7341. // by the lower of the two: available and needed years. Then set the
  7342. // highest year to the max year.
  7343. if (maxYear < highestYear) {
  7344. var availableYears = lowestYear - minYear,
  7345. neededYears = highestYear - maxYear;
  7346. lowestYear -= availableYears > neededYears ? neededYears : availableYears;
  7347. highestYear = maxYear;
  7348. }
  7349. if (settings.selectYears && override == undefined) {
  7350. return _.node('select', _.group({
  7351. min: lowestYear,
  7352. max: highestYear,
  7353. i: 1,
  7354. node: 'option',
  7355. item: function (loopedYear) {
  7356. return [
  7357. // The looped year and no classes.
  7358. loopedYear, 0,
  7359. // Set the value and selected index.
  7360. 'value=' + loopedYear + (focusedYear == loopedYear ? ' selected' : '')];
  7361. }
  7362. }), settings.klass.selectYear + ' browser-default', (isOpen ? '' : 'disabled') + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + 'title="' + settings.labelYearSelect + '"');
  7363. }
  7364. }
  7365. // Materialize modified
  7366. if (override === 'raw' && selectedObject != null) {
  7367. return _.node('div', selectedObject.year);
  7368. }
  7369. // Otherwise just return the year focused
  7370. return _.node('div', focusedYear, settings.klass.year);
  7371. }; //createYearLabel
  7372. // Materialize modified
  7373. createDayLabel = function () {
  7374. if (selectedObject != null) return selectedObject.date; else return nowObject.date;
  7375. };
  7376. createWeekdayLabel = function () {
  7377. var display_day;
  7378. if (selectedObject != null) display_day = selectedObject.day; else display_day = nowObject.day;
  7379. var weekday = settings.weekdaysShort[display_day];
  7380. return weekday;
  7381. };
  7382. // Create and return the entire calendar.
  7383. return _.node(
  7384. // Date presentation View
  7385. 'div', _.node(
  7386. // Div for Year
  7387. 'div', createYearLabel("raw"), settings.klass.year_display) + _.node('span', createWeekdayLabel() + ', ', "picker__weekday-display") + _.node(
  7388. // Div for short Month
  7389. 'span', createMonthLabel("short_months") + ' ', settings.klass.month_display) + _.node(
  7390. // Div for Day
  7391. 'span', createDayLabel(), settings.klass.day_display), settings.klass.date_display) +
  7392. // Calendar container
  7393. _.node('div', _.node('div', _.node('div', (settings.selectYears ? createMonthLabel() + createYearLabel() : createMonthLabel() + createYearLabel()) + createMonthNav() + createMonthNav(1), settings.klass.header) + _.node('table', tableHead + _.node('tbody', _.group({
  7394. min: 0,
  7395. max: WEEKS_IN_CALENDAR - 1,
  7396. i: 1,
  7397. node: 'tr',
  7398. item: function (rowCounter) {
  7399. // If Monday is the first day and the month starts on Sunday, shift the date back a week.
  7400. var shiftDateBy = settings.firstDay && calendar.create([viewsetObject.year, viewsetObject.month, 1]).day === 0 ? -7 : 0;
  7401. return [_.group({
  7402. min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
  7403. max: function () {
  7404. return this.min + DAYS_IN_WEEK - 1;
  7405. },
  7406. i: 1,
  7407. node: 'td',
  7408. item: function (targetDate) {
  7409. // Convert the time date from a relative date to a target date.
  7410. targetDate = calendar.create([viewsetObject.year, viewsetObject.month, targetDate + (settings.firstDay ? 1 : 0)]);
  7411. var isSelected = selectedObject && selectedObject.pick == targetDate.pick,
  7412. isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick,
  7413. isDisabled = disabledCollection && calendar.disabled(targetDate) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick,
  7414. formattedDate = _.trigger(calendar.formats.toString, calendar, [settings.format, targetDate]);
  7415. return [_.node('div', targetDate.date, function (klasses) {
  7416. // Add the `infocus` or `outfocus` classes based on month in view.
  7417. klasses.push(viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus);
  7418. // Add the `today` class if needed.
  7419. if (nowObject.pick == targetDate.pick) {
  7420. klasses.push(settings.klass.now);
  7421. }
  7422. // Add the `selected` class if something's selected and the time matches.
  7423. if (isSelected) {
  7424. klasses.push(settings.klass.selected);
  7425. }
  7426. // Add the `highlighted` class if something's highlighted and the time matches.
  7427. if (isHighlighted) {
  7428. klasses.push(settings.klass.highlighted);
  7429. }
  7430. // Add the `disabled` class if something's disabled and the object matches.
  7431. if (isDisabled) {
  7432. klasses.push(settings.klass.disabled);
  7433. }
  7434. return klasses.join(' ');
  7435. }([settings.klass.day]), 'data-pick=' + targetDate.pick + ' ' + _.ariaAttr({
  7436. role: 'gridcell',
  7437. label: formattedDate,
  7438. selected: isSelected && calendar.$node.val() === formattedDate ? true : null,
  7439. activedescendant: isHighlighted ? true : null,
  7440. disabled: isDisabled ? true : null
  7441. }) + ' ' + (isDisabled ? '' : 'tabindex="0"')), '', _.ariaAttr({ role: 'presentation' })]; //endreturn
  7442. }
  7443. })]; //endreturn
  7444. }
  7445. })), settings.klass.table, 'id="' + calendar.$node[0].id + '_table' + '" ' + _.ariaAttr({
  7446. role: 'grid',
  7447. controls: calendar.$node[0].id,
  7448. readonly: true
  7449. })), settings.klass.calendar_container) // end calendar
  7450. +
  7451. // * For Firefox forms to submit, make sure to set the buttons’ `type` attributes as “button”.
  7452. _.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
  7453. }; //DatePicker.prototype.nodes
  7454. /**
  7455. * The date picker defaults.
  7456. */
  7457. DatePicker.defaults = function (prefix) {
  7458. return {
  7459. // The title label to use for the month nav buttons
  7460. labelMonthNext: 'Next month',
  7461. labelMonthPrev: 'Previous month',
  7462. // The title label to use for the dropdown selectors
  7463. labelMonthSelect: 'Select a month',
  7464. labelYearSelect: 'Select a year',
  7465. // Months and weekdays
  7466. monthsFull: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  7467. monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  7468. weekdaysFull: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  7469. weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  7470. // Materialize modified
  7471. weekdaysLetter: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
  7472. // Today and clear
  7473. today: 'Today',
  7474. clear: 'Clear',
  7475. close: 'Ok',
  7476. // Picker close behavior (Prevent a change in behaviour for backwards compatibility)
  7477. closeOnSelect: false,
  7478. // The format to show on the `input` element
  7479. format: 'd mmmm, yyyy',
  7480. // Classes
  7481. klass: {
  7482. table: prefix + 'table',
  7483. header: prefix + 'header',
  7484. // Materialize Added klasses
  7485. date_display: prefix + 'date-display',
  7486. day_display: prefix + 'day-display',
  7487. month_display: prefix + 'month-display',
  7488. year_display: prefix + 'year-display',
  7489. calendar_container: prefix + 'calendar-container',
  7490. // end
  7491. navPrev: prefix + 'nav--prev',
  7492. navNext: prefix + 'nav--next',
  7493. navDisabled: prefix + 'nav--disabled',
  7494. month: prefix + 'month',
  7495. year: prefix + 'year',
  7496. selectMonth: prefix + 'select--month',
  7497. selectYear: prefix + 'select--year',
  7498. weekdays: prefix + 'weekday',
  7499. day: prefix + 'day',
  7500. disabled: prefix + 'day--disabled',
  7501. selected: prefix + 'day--selected',
  7502. highlighted: prefix + 'day--highlighted',
  7503. now: prefix + 'day--today',
  7504. infocus: prefix + 'day--infocus',
  7505. outfocus: prefix + 'day--outfocus',
  7506. footer: prefix + 'footer',
  7507. buttonClear: prefix + 'button--clear',
  7508. buttonToday: prefix + 'button--today',
  7509. buttonClose: prefix + 'button--close'
  7510. }
  7511. };
  7512. }(Picker.klasses().picker + '__');
  7513. /**
  7514. * Extend the picker to add the date picker.
  7515. */
  7516. Picker.extend('pickadate', DatePicker);
  7517. });
  7518. ; /*!
  7519. * ClockPicker v0.0.7 (http://weareoutman.github.io/clockpicker/)
  7520. * Copyright 2014 Wang Shenwei.
  7521. * Licensed under MIT (https://github.com/weareoutman/clockpicker/blob/gh-pages/LICENSE)
  7522. *
  7523. * Further modified
  7524. * Copyright 2015 Ching Yaw Hao.
  7525. */
  7526. (function ($) {
  7527. var $win = $(window),
  7528. $doc = $(document);
  7529. // Can I use inline svg ?
  7530. var svgNS = 'http://www.w3.org/2000/svg',
  7531. svgSupported = 'SVGAngle' in window && function () {
  7532. var supported,
  7533. el = document.createElement('div');
  7534. el.innerHTML = '<svg/>';
  7535. supported = (el.firstChild && el.firstChild.namespaceURI) == svgNS;
  7536. el.innerHTML = '';
  7537. return supported;
  7538. }();
  7539. // Can I use transition ?
  7540. var transitionSupported = function () {
  7541. var style = document.createElement('div').style;
  7542. return 'transition' in style || 'WebkitTransition' in style || 'MozTransition' in style || 'msTransition' in style || 'OTransition' in style;
  7543. }();
  7544. // Listen touch events in touch screen device, instead of mouse events in desktop.
  7545. var touchSupported = 'ontouchstart' in window,
  7546. mousedownEvent = 'mousedown' + (touchSupported ? ' touchstart' : ''),
  7547. mousemoveEvent = 'mousemove.clockpicker' + (touchSupported ? ' touchmove.clockpicker' : ''),
  7548. mouseupEvent = 'mouseup.clockpicker' + (touchSupported ? ' touchend.clockpicker' : '');
  7549. // Vibrate the device if supported
  7550. var vibrate = navigator.vibrate ? 'vibrate' : navigator.webkitVibrate ? 'webkitVibrate' : null;
  7551. function createSvgElement(name) {
  7552. return document.createElementNS(svgNS, name);
  7553. }
  7554. function leadingZero(num) {
  7555. return (num < 10 ? '0' : '') + num;
  7556. }
  7557. // Get a unique id
  7558. var idCounter = 0;
  7559. function uniqueId(prefix) {
  7560. var id = ++idCounter + '';
  7561. return prefix ? prefix + id : id;
  7562. }
  7563. // Clock size
  7564. var dialRadius = 135,
  7565. outerRadius = 105,
  7566. // innerRadius = 80 on 12 hour clock
  7567. innerRadius = 70,
  7568. tickRadius = 20,
  7569. diameter = dialRadius * 2,
  7570. duration = transitionSupported ? 350 : 1;
  7571. // Popover template
  7572. 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('');
  7573. // ClockPicker
  7574. function ClockPicker(element, options) {
  7575. var popover = $(tpl),
  7576. plate = popover.find('.clockpicker-plate'),
  7577. holder = popover.find('.picker__holder'),
  7578. hoursView = popover.find('.clockpicker-hours'),
  7579. minutesView = popover.find('.clockpicker-minutes'),
  7580. amPmBlock = popover.find('.clockpicker-am-pm-block'),
  7581. isInput = element.prop('tagName') === 'INPUT',
  7582. input = isInput ? element : element.find('input'),
  7583. label = $("label[for=" + input.attr("id") + "]"),
  7584. self = this;
  7585. this.id = uniqueId('cp');
  7586. this.element = element;
  7587. this.holder = holder;
  7588. this.options = options;
  7589. this.isAppended = false;
  7590. this.isShown = false;
  7591. this.currentView = 'hours';
  7592. this.isInput = isInput;
  7593. this.input = input;
  7594. this.label = label;
  7595. this.popover = popover;
  7596. this.plate = plate;
  7597. this.hoursView = hoursView;
  7598. this.minutesView = minutesView;
  7599. this.amPmBlock = amPmBlock;
  7600. this.spanHours = popover.find('.clockpicker-span-hours');
  7601. this.spanMinutes = popover.find('.clockpicker-span-minutes');
  7602. this.spanAmPm = popover.find('.clockpicker-span-am-pm');
  7603. this.footer = popover.find('.picker__footer');
  7604. this.amOrPm = "PM";
  7605. // Setup for for 12 hour clock if option is selected
  7606. if (options.twelvehour) {
  7607. if (!options.ampmclickable) {
  7608. this.spanAmPm.empty();
  7609. $('<div id="click-am">AM</div>').appendTo(this.spanAmPm);
  7610. $('<div id="click-pm">PM</div>').appendTo(this.spanAmPm);
  7611. } else {
  7612. this.spanAmPm.empty();
  7613. $('<div id="click-am">AM</div>').on("click", function () {
  7614. self.spanAmPm.children('#click-am').addClass("text-primary");
  7615. self.spanAmPm.children('#click-pm').removeClass("text-primary");
  7616. self.amOrPm = "AM";
  7617. }).appendTo(this.spanAmPm);
  7618. $('<div id="click-pm">PM</div>').on("click", function () {
  7619. self.spanAmPm.children('#click-pm').addClass("text-primary");
  7620. self.spanAmPm.children('#click-am').removeClass("text-primary");
  7621. self.amOrPm = 'PM';
  7622. }).appendTo(this.spanAmPm);
  7623. }
  7624. }
  7625. // Add buttons to footer
  7626. $('<button type="button" class="btn-flat picker__clear" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.cleartext + '</button>').click($.proxy(this.clear, this)).appendTo(this.footer);
  7627. $('<button type="button" class="btn-flat picker__close" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.canceltext + '</button>').click($.proxy(this.hide, this)).appendTo(this.footer);
  7628. $('<button type="button" class="btn-flat picker__close" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.donetext + '</button>').click($.proxy(this.done, this)).appendTo(this.footer);
  7629. this.spanHours.click($.proxy(this.toggleView, this, 'hours'));
  7630. this.spanMinutes.click($.proxy(this.toggleView, this, 'minutes'));
  7631. // Show or toggle
  7632. input.on('focus.clockpicker click.clockpicker', $.proxy(this.show, this));
  7633. // Build ticks
  7634. var tickTpl = $('<div class="clockpicker-tick"></div>'),
  7635. i,
  7636. tick,
  7637. radian,
  7638. radius;
  7639. // Hours view
  7640. if (options.twelvehour) {
  7641. for (i = 1; i < 13; i += 1) {
  7642. tick = tickTpl.clone();
  7643. radian = i / 6 * Math.PI;
  7644. radius = outerRadius;
  7645. tick.css({
  7646. left: dialRadius + Math.sin(radian) * radius - tickRadius,
  7647. top: dialRadius - Math.cos(radian) * radius - tickRadius
  7648. });
  7649. tick.html(i === 0 ? '00' : i);
  7650. hoursView.append(tick);
  7651. tick.on(mousedownEvent, mousedown);
  7652. }
  7653. } else {
  7654. for (i = 0; i < 24; i += 1) {
  7655. tick = tickTpl.clone();
  7656. radian = i / 6 * Math.PI;
  7657. var inner = i > 0 && i < 13;
  7658. radius = inner ? innerRadius : outerRadius;
  7659. tick.css({
  7660. left: dialRadius + Math.sin(radian) * radius - tickRadius,
  7661. top: dialRadius - Math.cos(radian) * radius - tickRadius
  7662. });
  7663. tick.html(i === 0 ? '00' : i);
  7664. hoursView.append(tick);
  7665. tick.on(mousedownEvent, mousedown);
  7666. }
  7667. }
  7668. // Minutes view
  7669. for (i = 0; i < 60; i += 5) {
  7670. tick = tickTpl.clone();
  7671. radian = i / 30 * Math.PI;
  7672. tick.css({
  7673. left: dialRadius + Math.sin(radian) * outerRadius - tickRadius,
  7674. top: dialRadius - Math.cos(radian) * outerRadius - tickRadius
  7675. });
  7676. tick.html(leadingZero(i));
  7677. minutesView.append(tick);
  7678. tick.on(mousedownEvent, mousedown);
  7679. }
  7680. // Clicking on minutes view space
  7681. plate.on(mousedownEvent, function (e) {
  7682. if ($(e.target).closest('.clockpicker-tick').length === 0) {
  7683. mousedown(e, true);
  7684. }
  7685. });
  7686. // Mousedown or touchstart
  7687. function mousedown(e, space) {
  7688. var offset = plate.offset(),
  7689. isTouch = /^touch/.test(e.type),
  7690. x0 = offset.left + dialRadius,
  7691. y0 = offset.top + dialRadius,
  7692. dx = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
  7693. dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0,
  7694. z = Math.sqrt(dx * dx + dy * dy),
  7695. moved = false;
  7696. // When clicking on minutes view space, check the mouse position
  7697. if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius)) {
  7698. return;
  7699. }
  7700. e.preventDefault();
  7701. // Set cursor style of body after 200ms
  7702. var movingTimer = setTimeout(function () {
  7703. self.popover.addClass('clockpicker-moving');
  7704. }, 200);
  7705. // Clock
  7706. self.setHand(dx, dy, !space, true);
  7707. // Mousemove on document
  7708. $doc.off(mousemoveEvent).on(mousemoveEvent, function (e) {
  7709. e.preventDefault();
  7710. var isTouch = /^touch/.test(e.type),
  7711. x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
  7712. y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;
  7713. if (!moved && x === dx && y === dy) {
  7714. // Clicking in chrome on windows will trigger a mousemove event
  7715. return;
  7716. }
  7717. moved = true;
  7718. self.setHand(x, y, false, true);
  7719. });
  7720. // Mouseup on document
  7721. $doc.off(mouseupEvent).on(mouseupEvent, function (e) {
  7722. $doc.off(mouseupEvent);
  7723. e.preventDefault();
  7724. var isTouch = /^touch/.test(e.type),
  7725. x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0,
  7726. y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;
  7727. if ((space || moved) && x === dx && y === dy) {
  7728. self.setHand(x, y);
  7729. }
  7730. if (self.currentView === 'hours') {
  7731. self.toggleView('minutes', duration / 2);
  7732. } else if (options.autoclose) {
  7733. self.minutesView.addClass('clockpicker-dial-out');
  7734. setTimeout(function () {
  7735. self.done();
  7736. }, duration / 2);
  7737. }
  7738. plate.prepend(canvas);
  7739. // Reset cursor style of body
  7740. clearTimeout(movingTimer);
  7741. self.popover.removeClass('clockpicker-moving');
  7742. // Unbind mousemove event
  7743. $doc.off(mousemoveEvent);
  7744. });
  7745. }
  7746. if (svgSupported) {
  7747. // Draw clock hands and others
  7748. var canvas = popover.find('.clockpicker-canvas'),
  7749. svg = createSvgElement('svg');
  7750. svg.setAttribute('class', 'clockpicker-svg');
  7751. svg.setAttribute('width', diameter);
  7752. svg.setAttribute('height', diameter);
  7753. var g = createSvgElement('g');
  7754. g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')');
  7755. var bearing = createSvgElement('circle');
  7756. bearing.setAttribute('class', 'clockpicker-canvas-bearing');
  7757. bearing.setAttribute('cx', 0);
  7758. bearing.setAttribute('cy', 0);
  7759. bearing.setAttribute('r', 4);
  7760. var hand = createSvgElement('line');
  7761. hand.setAttribute('x1', 0);
  7762. hand.setAttribute('y1', 0);
  7763. var bg = createSvgElement('circle');
  7764. bg.setAttribute('class', 'clockpicker-canvas-bg');
  7765. bg.setAttribute('r', tickRadius);
  7766. g.appendChild(hand);
  7767. g.appendChild(bg);
  7768. g.appendChild(bearing);
  7769. svg.appendChild(g);
  7770. canvas.append(svg);
  7771. this.hand = hand;
  7772. this.bg = bg;
  7773. this.bearing = bearing;
  7774. this.g = g;
  7775. this.canvas = canvas;
  7776. }
  7777. raiseCallback(this.options.init);
  7778. }
  7779. function raiseCallback(callbackFunction) {
  7780. if (callbackFunction && typeof callbackFunction === "function") callbackFunction();
  7781. }
  7782. // Default options
  7783. ClockPicker.DEFAULTS = {
  7784. 'default': '', // default time, 'now' or '13:14' e.g.
  7785. fromnow: 0, // set default time to * milliseconds from now (using with default = 'now')
  7786. donetext: 'Ok', // done button text
  7787. cleartext: 'Clear',
  7788. canceltext: 'Cancel',
  7789. autoclose: false, // auto close when minute is selected
  7790. ampmclickable: true, // set am/pm button on itself
  7791. darktheme: false, // set to dark theme
  7792. twelvehour: true, // change to 12 hour AM/PM clock from 24 hour
  7793. vibrate: true // vibrate the device when dragging clock hand
  7794. };
  7795. // Show or hide popover
  7796. ClockPicker.prototype.toggle = function () {
  7797. this[this.isShown ? 'hide' : 'show']();
  7798. };
  7799. // Set popover position
  7800. ClockPicker.prototype.locate = function () {
  7801. var element = this.element,
  7802. popover = this.popover,
  7803. offset = element.offset(),
  7804. width = element.outerWidth(),
  7805. height = element.outerHeight(),
  7806. align = this.options.align,
  7807. self = this;
  7808. popover.show();
  7809. };
  7810. // Show popover
  7811. ClockPicker.prototype.show = function (e) {
  7812. // Not show again
  7813. if (this.isShown) {
  7814. return;
  7815. }
  7816. raiseCallback(this.options.beforeShow);
  7817. $(':input').each(function () {
  7818. $(this).attr('tabindex', -1);
  7819. });
  7820. var self = this;
  7821. // Initialize
  7822. this.input.blur();
  7823. this.popover.addClass('picker--opened');
  7824. this.input.addClass('picker__input picker__input--active');
  7825. $(document.body).css('overflow', 'hidden');
  7826. // Get the time
  7827. var value = ((this.input.prop('value') || this.options['default'] || '') + '').split(':');
  7828. if (this.options.twelvehour && !(typeof value[1] === 'undefined')) {
  7829. if (value[1].indexOf("AM") > 0) {
  7830. this.amOrPm = 'AM';
  7831. } else {
  7832. this.amOrPm = 'PM';
  7833. }
  7834. value[1] = value[1].replace("AM", "").replace("PM", "");
  7835. }
  7836. if (value[0] === 'now') {
  7837. var now = new Date(+new Date() + this.options.fromnow);
  7838. value = [now.getHours(), now.getMinutes()];
  7839. if (this.options.twelvehour) {
  7840. this.amOrPm = value[0] >= 12 && value[0] < 24 ? 'PM' : 'AM';
  7841. }
  7842. }
  7843. this.hours = +value[0] || 0;
  7844. this.minutes = +value[1] || 0;
  7845. this.spanHours.html(this.hours);
  7846. this.spanMinutes.html(leadingZero(this.minutes));
  7847. if (!this.isAppended) {
  7848. // Append popover to input by default
  7849. var containerEl = document.querySelector(this.options.container);
  7850. if (this.options.container && containerEl) {
  7851. containerEl.appendChild(this.popover[0]);
  7852. } else {
  7853. this.popover.insertAfter(this.input);
  7854. }
  7855. if (this.options.twelvehour) {
  7856. if (this.amOrPm === 'PM') {
  7857. this.spanAmPm.children('#click-pm').addClass("text-primary");
  7858. this.spanAmPm.children('#click-am').removeClass("text-primary");
  7859. } else {
  7860. this.spanAmPm.children('#click-am').addClass("text-primary");
  7861. this.spanAmPm.children('#click-pm').removeClass("text-primary");
  7862. }
  7863. }
  7864. // Reset position when resize
  7865. $win.on('resize.clockpicker' + this.id, function () {
  7866. if (self.isShown) {
  7867. self.locate();
  7868. }
  7869. });
  7870. this.isAppended = true;
  7871. }
  7872. // Toggle to hours view
  7873. this.toggleView('hours');
  7874. // Set position
  7875. this.locate();
  7876. this.isShown = true;
  7877. // Hide when clicking or tabbing on any element except the clock and input
  7878. $doc.on('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id, function (e) {
  7879. var target = $(e.target);
  7880. if (target.closest(self.popover.find('.picker__wrap')).length === 0 && target.closest(self.input).length === 0) {
  7881. self.hide();
  7882. }
  7883. });
  7884. // Hide when ESC is pressed
  7885. $doc.on('keyup.clockpicker.' + this.id, function (e) {
  7886. if (e.keyCode === 27) {
  7887. self.hide();
  7888. }
  7889. });
  7890. raiseCallback(this.options.afterShow);
  7891. };
  7892. // Hide popover
  7893. ClockPicker.prototype.hide = function () {
  7894. raiseCallback(this.options.beforeHide);
  7895. this.input.removeClass('picker__input picker__input--active');
  7896. this.popover.removeClass('picker--opened');
  7897. $(document.body).css('overflow', 'visible');
  7898. this.isShown = false;
  7899. $(':input').each(function (index) {
  7900. $(this).attr('tabindex', index + 1);
  7901. });
  7902. // Unbinding events on document
  7903. $doc.off('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id);
  7904. $doc.off('keyup.clockpicker.' + this.id);
  7905. this.popover.hide();
  7906. raiseCallback(this.options.afterHide);
  7907. };
  7908. // Toggle to hours or minutes view
  7909. ClockPicker.prototype.toggleView = function (view, delay) {
  7910. var raiseAfterHourSelect = false;
  7911. if (view === 'minutes' && $(this.hoursView).css("visibility") === "visible") {
  7912. raiseCallback(this.options.beforeHourSelect);
  7913. raiseAfterHourSelect = true;
  7914. }
  7915. var isHours = view === 'hours',
  7916. nextView = isHours ? this.hoursView : this.minutesView,
  7917. hideView = isHours ? this.minutesView : this.hoursView;
  7918. this.currentView = view;
  7919. this.spanHours.toggleClass('text-primary', isHours);
  7920. this.spanMinutes.toggleClass('text-primary', !isHours);
  7921. // Let's make transitions
  7922. hideView.addClass('clockpicker-dial-out');
  7923. nextView.css('visibility', 'visible').removeClass('clockpicker-dial-out');
  7924. // Reset clock hand
  7925. this.resetClock(delay);
  7926. // After transitions ended
  7927. clearTimeout(this.toggleViewTimer);
  7928. this.toggleViewTimer = setTimeout(function () {
  7929. hideView.css('visibility', 'hidden');
  7930. }, duration);
  7931. if (raiseAfterHourSelect) {
  7932. raiseCallback(this.options.afterHourSelect);
  7933. }
  7934. };
  7935. // Reset clock hand
  7936. ClockPicker.prototype.resetClock = function (delay) {
  7937. var view = this.currentView,
  7938. value = this[view],
  7939. isHours = view === 'hours',
  7940. unit = Math.PI / (isHours ? 6 : 30),
  7941. radian = value * unit,
  7942. radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius,
  7943. x = Math.sin(radian) * radius,
  7944. y = -Math.cos(radian) * radius,
  7945. self = this;
  7946. if (svgSupported && delay) {
  7947. self.canvas.addClass('clockpicker-canvas-out');
  7948. setTimeout(function () {
  7949. self.canvas.removeClass('clockpicker-canvas-out');
  7950. self.setHand(x, y);
  7951. }, delay);
  7952. } else this.setHand(x, y);
  7953. };
  7954. // Set clock hand to (x, y)
  7955. ClockPicker.prototype.setHand = function (x, y, roundBy5, dragging) {
  7956. var radian = Math.atan2(x, -y),
  7957. isHours = this.currentView === 'hours',
  7958. unit = Math.PI / (isHours || roundBy5 ? 6 : 30),
  7959. z = Math.sqrt(x * x + y * y),
  7960. options = this.options,
  7961. inner = isHours && z < (outerRadius + innerRadius) / 2,
  7962. radius = inner ? innerRadius : outerRadius,
  7963. value;
  7964. if (options.twelvehour) {
  7965. radius = outerRadius;
  7966. }
  7967. // Radian should in range [0, 2PI]
  7968. if (radian < 0) {
  7969. radian = Math.PI * 2 + radian;
  7970. }
  7971. // Get the round value
  7972. value = Math.round(radian / unit);
  7973. // Get the round radian
  7974. radian = value * unit;
  7975. // Correct the hours or minutes
  7976. if (options.twelvehour) {
  7977. if (isHours) {
  7978. if (value === 0) value = 12;
  7979. } else {
  7980. if (roundBy5) value *= 5;
  7981. if (value === 60) value = 0;
  7982. }
  7983. } else {
  7984. if (isHours) {
  7985. if (value === 12) value = 0;
  7986. value = inner ? value === 0 ? 12 : value : value === 0 ? 0 : value + 12;
  7987. } else {
  7988. if (roundBy5) value *= 5;
  7989. if (value === 60) value = 0;
  7990. }
  7991. }
  7992. // Once hours or minutes changed, vibrate the device
  7993. if (this[this.currentView] !== value) {
  7994. if (vibrate && this.options.vibrate) {
  7995. // Do not vibrate too frequently
  7996. if (!this.vibrateTimer) {
  7997. navigator[vibrate](10);
  7998. this.vibrateTimer = setTimeout($.proxy(function () {
  7999. this.vibrateTimer = null;
  8000. }, this), 100);
  8001. }
  8002. }
  8003. }
  8004. this[this.currentView] = value;
  8005. if (isHours) {
  8006. this['spanHours'].html(value);
  8007. } else {
  8008. this['spanMinutes'].html(leadingZero(value));
  8009. }
  8010. // If svg is not supported, just add an active class to the tick
  8011. if (!svgSupported) {
  8012. this[isHours ? 'hoursView' : 'minutesView'].find('.clockpicker-tick').each(function () {
  8013. var tick = $(this);
  8014. tick.toggleClass('active', value === +tick.html());
  8015. });
  8016. return;
  8017. }
  8018. // Set clock hand and others' position
  8019. var cx1 = Math.sin(radian) * (radius - tickRadius),
  8020. cy1 = -Math.cos(radian) * (radius - tickRadius),
  8021. cx2 = Math.sin(radian) * radius,
  8022. cy2 = -Math.cos(radian) * radius;
  8023. this.hand.setAttribute('x2', cx1);
  8024. this.hand.setAttribute('y2', cy1);
  8025. this.bg.setAttribute('cx', cx2);
  8026. this.bg.setAttribute('cy', cy2);
  8027. };
  8028. // Hours and minutes are selected
  8029. ClockPicker.prototype.done = function () {
  8030. raiseCallback(this.options.beforeDone);
  8031. this.hide();
  8032. this.label.addClass('active');
  8033. var last = this.input.prop('value'),
  8034. value = leadingZero(this.hours) + ':' + leadingZero(this.minutes);
  8035. if (this.options.twelvehour) {
  8036. value = value + this.amOrPm;
  8037. }
  8038. this.input.prop('value', value);
  8039. if (value !== last) {
  8040. this.input.triggerHandler('change');
  8041. if (!this.isInput) {
  8042. this.element.trigger('change');
  8043. }
  8044. }
  8045. if (this.options.autoclose) this.input.trigger('blur');
  8046. raiseCallback(this.options.afterDone);
  8047. };
  8048. // Clear input field
  8049. ClockPicker.prototype.clear = function () {
  8050. this.hide();
  8051. this.label.removeClass('active');
  8052. var last = this.input.prop('value'),
  8053. value = '';
  8054. this.input.prop('value', value);
  8055. if (value !== last) {
  8056. this.input.triggerHandler('change');
  8057. if (!this.isInput) {
  8058. this.element.trigger('change');
  8059. }
  8060. }
  8061. if (this.options.autoclose) {
  8062. this.input.trigger('blur');
  8063. }
  8064. };
  8065. // Remove clockpicker from input
  8066. ClockPicker.prototype.remove = function () {
  8067. this.element.removeData('clockpicker');
  8068. this.input.off('focus.clockpicker click.clockpicker');
  8069. if (this.isShown) {
  8070. this.hide();
  8071. }
  8072. if (this.isAppended) {
  8073. $win.off('resize.clockpicker' + this.id);
  8074. this.popover.remove();
  8075. }
  8076. };
  8077. // Extends $.fn.clockpicker
  8078. $.fn.pickatime = function (option) {
  8079. var args = Array.prototype.slice.call(arguments, 1);
  8080. return this.each(function () {
  8081. var $this = $(this),
  8082. data = $this.data('clockpicker');
  8083. if (!data) {
  8084. var options = $.extend({}, ClockPicker.DEFAULTS, $this.data(), typeof option == 'object' && option);
  8085. $this.data('clockpicker', new ClockPicker($this, options));
  8086. } else {
  8087. // Manual operatsions. show, hide, remove, e.g.
  8088. if (typeof data[option] === 'function') {
  8089. data[option].apply(data, args);
  8090. }
  8091. }
  8092. });
  8093. };
  8094. })(jQuery);
  8095. ; (function ($) {
  8096. $.fn.characterCounter = function () {
  8097. return this.each(function () {
  8098. var $input = $(this);
  8099. var $counterElement = $input.parent().find('span[class="character-counter"]');
  8100. // character counter has already been added appended to the parent container
  8101. if ($counterElement.length) {
  8102. return;
  8103. }
  8104. var itHasLengthAttribute = $input.attr('data-length') !== undefined;
  8105. if (itHasLengthAttribute) {
  8106. $input.on('input', updateCounter);
  8107. $input.on('focus', updateCounter);
  8108. $input.on('blur', removeCounterElement);
  8109. addCounterElement($input);
  8110. }
  8111. });
  8112. };
  8113. function updateCounter() {
  8114. var maxLength = +$(this).attr('data-length'),
  8115. actualLength = +$(this).val().length,
  8116. isValidLength = actualLength <= maxLength;
  8117. $(this).parent().find('span[class="character-counter"]').html(actualLength + '/' + maxLength);
  8118. addInputStyle(isValidLength, $(this));
  8119. }
  8120. function addCounterElement($input) {
  8121. var $counterElement = $input.parent().find('span[class="character-counter"]');
  8122. if ($counterElement.length) {
  8123. return;
  8124. }
  8125. $counterElement = $('<span/>').addClass('character-counter').css('float', 'right').css('font-size', '12px').css('height', 1);
  8126. $input.parent().append($counterElement);
  8127. }
  8128. function removeCounterElement() {
  8129. $(this).parent().find('span[class="character-counter"]').html('');
  8130. }
  8131. function addInputStyle(isValidLength, $input) {
  8132. var inputHasInvalidClass = $input.hasClass('invalid');
  8133. if (isValidLength && inputHasInvalidClass) {
  8134. $input.removeClass('invalid');
  8135. } else if (!isValidLength && !inputHasInvalidClass) {
  8136. $input.removeClass('valid');
  8137. $input.addClass('invalid');
  8138. }
  8139. }
  8140. $(document).ready(function () {
  8141. $('input, textarea').characterCounter();
  8142. });
  8143. })(jQuery);
  8144. ; (function ($) {
  8145. var methods = {
  8146. init: function (options) {
  8147. var defaults = {
  8148. duration: 200, // ms
  8149. dist: -100, // zoom scale TODO: make this more intuitive as an option
  8150. shift: 0, // spacing for center image
  8151. padding: 0, // Padding between non center items
  8152. fullWidth: false, // Change to full width styles
  8153. indicators: false, // Toggle indicators
  8154. noWrap: false, // Don't wrap around and cycle through items.
  8155. onCycleTo: null // Callback for when a new slide is cycled to.
  8156. };
  8157. options = $.extend(defaults, options);
  8158. var namespace = Materialize.objectSelectorString($(this));
  8159. return this.each(function (i) {
  8160. var images, item_width, item_height, offset, center, pressed, dim, count, reference, referenceY, amplitude, target, velocity, scrolling, xform, frame, timestamp, ticker, dragged, vertical_dragged;
  8161. var $indicators = $('<ul class="indicators"></ul>');
  8162. var scrollingTimeout = null;
  8163. var oneTimeCallback = null;
  8164. // Initialize
  8165. var view = $(this);
  8166. var hasMultipleSlides = view.find('.carousel-item').length > 1;
  8167. var showIndicators = (view.attr('data-indicators') || options.indicators) && hasMultipleSlides;
  8168. var noWrap = view.attr('data-no-wrap') || options.noWrap || !hasMultipleSlides;
  8169. var uniqueNamespace = view.attr('data-namespace') || namespace + i;
  8170. view.attr('data-namespace', uniqueNamespace);
  8171. // Options
  8172. var setCarouselHeight = function (imageOnly) {
  8173. var firstSlide = view.find('.carousel-item.active').length ? view.find('.carousel-item.active').first() : view.find('.carousel-item').first();
  8174. var firstImage = firstSlide.find('img').first();
  8175. if (firstImage.length) {
  8176. if (firstImage[0].complete) {
  8177. // If image won't trigger the load event
  8178. var imageHeight = firstImage.height();
  8179. if (imageHeight > 0) {
  8180. view.css('height', firstImage.height());
  8181. } else {
  8182. // If image still has no height, use the natural dimensions to calculate
  8183. var naturalWidth = firstImage[0].naturalWidth;
  8184. var naturalHeight = firstImage[0].naturalHeight;
  8185. var adjustedHeight = view.width() / naturalWidth * naturalHeight;
  8186. view.css('height', adjustedHeight);
  8187. }
  8188. } else {
  8189. // Get height when image is loaded normally
  8190. firstImage.on('load', function () {
  8191. view.css('height', $(this).height());
  8192. });
  8193. }
  8194. } else if (!imageOnly) {
  8195. var slideHeight = firstSlide.height();
  8196. view.css('height', slideHeight);
  8197. }
  8198. };
  8199. if (options.fullWidth) {
  8200. options.dist = 0;
  8201. setCarouselHeight();
  8202. // Offset fixed items when indicators.
  8203. if (showIndicators) {
  8204. view.find('.carousel-fixed-item').addClass('with-indicators');
  8205. }
  8206. }
  8207. // Don't double initialize.
  8208. if (view.hasClass('initialized')) {
  8209. // Recalculate variables
  8210. $(window).trigger('resize');
  8211. // Redraw carousel.
  8212. view.trigger('carouselNext', [0.000001]);
  8213. return true;
  8214. }
  8215. view.addClass('initialized');
  8216. pressed = false;
  8217. offset = target = 0;
  8218. images = [];
  8219. item_width = view.find('.carousel-item').first().innerWidth();
  8220. item_height = view.find('.carousel-item').first().innerHeight();
  8221. dim = item_width * 2 + options.padding;
  8222. view.find('.carousel-item').each(function (i) {
  8223. images.push($(this)[0]);
  8224. if (showIndicators) {
  8225. var $indicator = $('<li class="indicator-item"></li>');
  8226. // Add active to first by default.
  8227. if (i === 0) {
  8228. $indicator.addClass('active');
  8229. }
  8230. // Handle clicks on indicators.
  8231. $indicator.click(function (e) {
  8232. e.stopPropagation();
  8233. var index = $(this).index();
  8234. cycleTo(index);
  8235. });
  8236. $indicators.append($indicator);
  8237. }
  8238. });
  8239. if (showIndicators) {
  8240. view.append($indicators);
  8241. }
  8242. count = images.length;
  8243. function setupEvents() {
  8244. if (typeof window.ontouchstart !== 'undefined') {
  8245. view.on('touchstart.carousel', tap);
  8246. view.on('touchmove.carousel', drag);
  8247. view.on('touchend.carousel', release);
  8248. }
  8249. view.on('mousedown.carousel', tap);
  8250. view.on('mousemove.carousel', drag);
  8251. view.on('mouseup.carousel', release);
  8252. view.on('mouseleave.carousel', release);
  8253. view.on('click.carousel', click);
  8254. }
  8255. function xpos(e) {
  8256. // touch event
  8257. if (e.targetTouches && e.targetTouches.length >= 1) {
  8258. return e.targetTouches[0].clientX;
  8259. }
  8260. // mouse event
  8261. return e.clientX;
  8262. }
  8263. function ypos(e) {
  8264. // touch event
  8265. if (e.targetTouches && e.targetTouches.length >= 1) {
  8266. return e.targetTouches[0].clientY;
  8267. }
  8268. // mouse event
  8269. return e.clientY;
  8270. }
  8271. function wrap(x) {
  8272. return x >= count ? x % count : x < 0 ? wrap(count + x % count) : x;
  8273. }
  8274. function scroll(x) {
  8275. // Track scrolling state
  8276. scrolling = true;
  8277. if (!view.hasClass('scrolling')) {
  8278. view.addClass('scrolling');
  8279. }
  8280. if (scrollingTimeout != null) {
  8281. window.clearTimeout(scrollingTimeout);
  8282. }
  8283. scrollingTimeout = window.setTimeout(function () {
  8284. scrolling = false;
  8285. view.removeClass('scrolling');
  8286. }, options.duration);
  8287. // Start actual scroll
  8288. var i, half, delta, dir, tween, el, alignment, xTranslation;
  8289. var lastCenter = center;
  8290. offset = typeof x === 'number' ? x : offset;
  8291. center = Math.floor((offset + dim / 2) / dim);
  8292. delta = offset - center * dim;
  8293. dir = delta < 0 ? 1 : -1;
  8294. tween = -dir * delta * 2 / dim;
  8295. half = count >> 1;
  8296. if (!options.fullWidth) {
  8297. alignment = 'translateX(' + (view[0].clientWidth - item_width) / 2 + 'px) ';
  8298. alignment += 'translateY(' + (view[0].clientHeight - item_height) / 2 + 'px)';
  8299. } else {
  8300. alignment = 'translateX(0)';
  8301. }
  8302. // Set indicator active
  8303. if (showIndicators) {
  8304. var diff = center % count;
  8305. var activeIndicator = $indicators.find('.indicator-item.active');
  8306. if (activeIndicator.index() !== diff) {
  8307. activeIndicator.removeClass('active');
  8308. $indicators.find('.indicator-item').eq(diff).addClass('active');
  8309. }
  8310. }
  8311. // center
  8312. // Don't show wrapped items.
  8313. if (!noWrap || center >= 0 && center < count) {
  8314. el = images[wrap(center)];
  8315. // Add active class to center item.
  8316. if (!$(el).hasClass('active')) {
  8317. view.find('.carousel-item').removeClass('active');
  8318. $(el).addClass('active');
  8319. }
  8320. el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween * i + 'px)' + ' translateZ(' + options.dist * tween + 'px)';
  8321. el.style.zIndex = 0;
  8322. if (options.fullWidth) {
  8323. tweenedOpacity = 1;
  8324. } else {
  8325. tweenedOpacity = 1 - 0.2 * tween;
  8326. }
  8327. el.style.opacity = tweenedOpacity;
  8328. el.style.display = 'block';
  8329. }
  8330. for (i = 1; i <= half; ++i) {
  8331. // right side
  8332. if (options.fullWidth) {
  8333. zTranslation = options.dist;
  8334. tweenedOpacity = i === half && delta < 0 ? 1 - tween : 1;
  8335. } else {
  8336. zTranslation = options.dist * (i * 2 + tween * dir);
  8337. tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir);
  8338. }
  8339. // Don't show wrapped items.
  8340. if (!noWrap || center + i < count) {
  8341. el = images[wrap(center + i)];
  8342. el.style[xform] = alignment + ' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)';
  8343. el.style.zIndex = -i;
  8344. el.style.opacity = tweenedOpacity;
  8345. el.style.display = 'block';
  8346. }
  8347. // left side
  8348. if (options.fullWidth) {
  8349. zTranslation = options.dist;
  8350. tweenedOpacity = i === half && delta > 0 ? 1 - tween : 1;
  8351. } else {
  8352. zTranslation = options.dist * (i * 2 - tween * dir);
  8353. tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir);
  8354. }
  8355. // Don't show wrapped items.
  8356. if (!noWrap || center - i >= 0) {
  8357. el = images[wrap(center - i)];
  8358. el.style[xform] = alignment + ' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)';
  8359. el.style.zIndex = -i;
  8360. el.style.opacity = tweenedOpacity;
  8361. el.style.display = 'block';
  8362. }
  8363. }
  8364. // center
  8365. // Don't show wrapped items.
  8366. if (!noWrap || center >= 0 && center < count) {
  8367. el = images[wrap(center)];
  8368. el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween + 'px)' + ' translateZ(' + options.dist * tween + 'px)';
  8369. el.style.zIndex = 0;
  8370. if (options.fullWidth) {
  8371. tweenedOpacity = 1;
  8372. } else {
  8373. tweenedOpacity = 1 - 0.2 * tween;
  8374. }
  8375. el.style.opacity = tweenedOpacity;
  8376. el.style.display = 'block';
  8377. }
  8378. // onCycleTo callback
  8379. if (lastCenter !== center && typeof options.onCycleTo === "function") {
  8380. var $curr_item = view.find('.carousel-item').eq(wrap(center));
  8381. options.onCycleTo.call(this, $curr_item, dragged);
  8382. }
  8383. // One time callback
  8384. if (typeof oneTimeCallback === "function") {
  8385. oneTimeCallback.call(this, $curr_item, dragged);
  8386. oneTimeCallback = null;
  8387. }
  8388. }
  8389. function track() {
  8390. var now, elapsed, delta, v;
  8391. now = Date.now();
  8392. elapsed = now - timestamp;
  8393. timestamp = now;
  8394. delta = offset - frame;
  8395. frame = offset;
  8396. v = 1000 * delta / (1 + elapsed);
  8397. velocity = 0.8 * v + 0.2 * velocity;
  8398. }
  8399. function autoScroll() {
  8400. var elapsed, delta;
  8401. if (amplitude) {
  8402. elapsed = Date.now() - timestamp;
  8403. delta = amplitude * Math.exp(-elapsed / options.duration);
  8404. if (delta > 2 || delta < -2) {
  8405. scroll(target - delta);
  8406. requestAnimationFrame(autoScroll);
  8407. } else {
  8408. scroll(target);
  8409. }
  8410. }
  8411. }
  8412. function click(e) {
  8413. // Disable clicks if carousel was dragged.
  8414. if (dragged) {
  8415. e.preventDefault();
  8416. e.stopPropagation();
  8417. return false;
  8418. } else if (!options.fullWidth) {
  8419. var clickedIndex = $(e.target).closest('.carousel-item').index();
  8420. var diff = wrap(center) - clickedIndex;
  8421. // Disable clicks if carousel was shifted by click
  8422. if (diff !== 0) {
  8423. e.preventDefault();
  8424. e.stopPropagation();
  8425. }
  8426. cycleTo(clickedIndex);
  8427. }
  8428. }
  8429. function cycleTo(n) {
  8430. var diff = center % count - n;
  8431. // Account for wraparound.
  8432. if (!noWrap) {
  8433. if (diff < 0) {
  8434. if (Math.abs(diff + count) < Math.abs(diff)) {
  8435. diff += count;
  8436. }
  8437. } else if (diff > 0) {
  8438. if (Math.abs(diff - count) < diff) {
  8439. diff -= count;
  8440. }
  8441. }
  8442. }
  8443. // Call prev or next accordingly.
  8444. if (diff < 0) {
  8445. view.trigger('carouselNext', [Math.abs(diff)]);
  8446. } else if (diff > 0) {
  8447. view.trigger('carouselPrev', [diff]);
  8448. }
  8449. }
  8450. function tap(e) {
  8451. // Fixes firefox draggable image bug
  8452. if (e.type === 'mousedown' && $(e.target).is('img')) {
  8453. e.preventDefault();
  8454. }
  8455. pressed = true;
  8456. dragged = false;
  8457. vertical_dragged = false;
  8458. reference = xpos(e);
  8459. referenceY = ypos(e);
  8460. velocity = amplitude = 0;
  8461. frame = offset;
  8462. timestamp = Date.now();
  8463. clearInterval(ticker);
  8464. ticker = setInterval(track, 100);
  8465. }
  8466. function drag(e) {
  8467. var x, delta, deltaY;
  8468. if (pressed) {
  8469. x = xpos(e);
  8470. y = ypos(e);
  8471. delta = reference - x;
  8472. deltaY = Math.abs(referenceY - y);
  8473. if (deltaY < 30 && !vertical_dragged) {
  8474. // If vertical scrolling don't allow dragging.
  8475. if (delta > 2 || delta < -2) {
  8476. dragged = true;
  8477. reference = x;
  8478. scroll(offset + delta);
  8479. }
  8480. } else if (dragged) {
  8481. // If dragging don't allow vertical scroll.
  8482. e.preventDefault();
  8483. e.stopPropagation();
  8484. return false;
  8485. } else {
  8486. // Vertical scrolling.
  8487. vertical_dragged = true;
  8488. }
  8489. }
  8490. if (dragged) {
  8491. // If dragging don't allow vertical scroll.
  8492. e.preventDefault();
  8493. e.stopPropagation();
  8494. return false;
  8495. }
  8496. }
  8497. function release(e) {
  8498. if (pressed) {
  8499. pressed = false;
  8500. } else {
  8501. return;
  8502. }
  8503. clearInterval(ticker);
  8504. target = offset;
  8505. if (velocity > 10 || velocity < -10) {
  8506. amplitude = 0.9 * velocity;
  8507. target = offset + amplitude;
  8508. }
  8509. target = Math.round(target / dim) * dim;
  8510. // No wrap of items.
  8511. if (noWrap) {
  8512. if (target >= dim * (count - 1)) {
  8513. target = dim * (count - 1);
  8514. } else if (target < 0) {
  8515. target = 0;
  8516. }
  8517. }
  8518. amplitude = target - offset;
  8519. timestamp = Date.now();
  8520. requestAnimationFrame(autoScroll);
  8521. if (dragged) {
  8522. e.preventDefault();
  8523. e.stopPropagation();
  8524. }
  8525. return false;
  8526. }
  8527. xform = 'transform';
  8528. ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) {
  8529. var e = prefix + 'Transform';
  8530. if (typeof document.body.style[e] !== 'undefined') {
  8531. xform = e;
  8532. return false;
  8533. }
  8534. return true;
  8535. });
  8536. var throttledResize = Materialize.throttle(function () {
  8537. if (options.fullWidth) {
  8538. item_width = view.find('.carousel-item').first().innerWidth();
  8539. var imageHeight = view.find('.carousel-item.active').height();
  8540. dim = item_width * 2 + options.padding;
  8541. offset = center * 2 * item_width;
  8542. target = offset;
  8543. setCarouselHeight(true);
  8544. } else {
  8545. scroll();
  8546. }
  8547. }, 200);
  8548. $(window).off('resize.carousel-' + uniqueNamespace).on('resize.carousel-' + uniqueNamespace, throttledResize);
  8549. setupEvents();
  8550. scroll(offset);
  8551. $(this).on('carouselNext', function (e, n, callback) {
  8552. if (n === undefined) {
  8553. n = 1;
  8554. }
  8555. if (typeof callback === "function") {
  8556. oneTimeCallback = callback;
  8557. }
  8558. target = dim * Math.round(offset / dim) + dim * n;
  8559. if (offset !== target) {
  8560. amplitude = target - offset;
  8561. timestamp = Date.now();
  8562. requestAnimationFrame(autoScroll);
  8563. }
  8564. });
  8565. $(this).on('carouselPrev', function (e, n, callback) {
  8566. if (n === undefined) {
  8567. n = 1;
  8568. }
  8569. if (typeof callback === "function") {
  8570. oneTimeCallback = callback;
  8571. }
  8572. target = dim * Math.round(offset / dim) - dim * n;
  8573. if (offset !== target) {
  8574. amplitude = target - offset;
  8575. timestamp = Date.now();
  8576. requestAnimationFrame(autoScroll);
  8577. }
  8578. });
  8579. $(this).on('carouselSet', function (e, n, callback) {
  8580. if (n === undefined) {
  8581. n = 0;
  8582. }
  8583. if (typeof callback === "function") {
  8584. oneTimeCallback = callback;
  8585. }
  8586. cycleTo(n);
  8587. });
  8588. });
  8589. },
  8590. next: function (n, callback) {
  8591. $(this).trigger('carouselNext', [n, callback]);
  8592. },
  8593. prev: function (n, callback) {
  8594. $(this).trigger('carouselPrev', [n, callback]);
  8595. },
  8596. set: function (n, callback) {
  8597. $(this).trigger('carouselSet', [n, callback]);
  8598. },
  8599. destroy: function () {
  8600. var uniqueNamespace = $(this).attr('data-namespace');
  8601. $(this).removeAttr('data-namespace');
  8602. $(this).removeClass('initialized');
  8603. $(this).find('.indicators').remove();
  8604. // Remove event handlers
  8605. $(this).off('carouselNext carouselPrev carouselSet');
  8606. $(window).off('resize.carousel-' + uniqueNamespace);
  8607. if (typeof window.ontouchstart !== 'undefined') {
  8608. $(this).off('touchstart.carousel touchmove.carousel touchend.carousel');
  8609. }
  8610. $(this).off('mousedown.carousel mousemove.carousel mouseup.carousel mouseleave.carousel click.carousel');
  8611. }
  8612. };
  8613. $.fn.carousel = function (methodOrOptions) {
  8614. if (methods[methodOrOptions]) {
  8615. return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
  8616. } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
  8617. // Default to "init"
  8618. return methods.init.apply(this, arguments);
  8619. } else {
  8620. $.error('Method ' + methodOrOptions + ' does not exist on jQuery.carousel');
  8621. }
  8622. }; // Plugin end
  8623. })(jQuery);
  8624. ; (function ($) {
  8625. var methods = {
  8626. init: function (options) {
  8627. return this.each(function () {
  8628. var origin = $('#' + $(this).attr('data-activates'));
  8629. var screen = $('body');
  8630. // Creating tap target
  8631. var tapTargetEl = $(this);
  8632. var tapTargetWrapper = tapTargetEl.parent('.tap-target-wrapper');
  8633. var tapTargetWave = tapTargetWrapper.find('.tap-target-wave');
  8634. var tapTargetOriginEl = tapTargetWrapper.find('.tap-target-origin');
  8635. var tapTargetContentEl = tapTargetEl.find('.tap-target-content');
  8636. // Creating wrapper
  8637. if (!tapTargetWrapper.length) {
  8638. tapTargetWrapper = tapTargetEl.wrap($('<div class="tap-target-wrapper"></div>')).parent();
  8639. }
  8640. // Creating content
  8641. if (!tapTargetContentEl.length) {
  8642. tapTargetContentEl = $('<div class="tap-target-content"></div>');
  8643. tapTargetEl.append(tapTargetContentEl);
  8644. }
  8645. // Creating foreground wave
  8646. if (!tapTargetWave.length) {
  8647. tapTargetWave = $('<div class="tap-target-wave"></div>');
  8648. // Creating origin
  8649. if (!tapTargetOriginEl.length) {
  8650. tapTargetOriginEl = origin.clone(true, true);
  8651. tapTargetOriginEl.addClass('tap-target-origin');
  8652. tapTargetOriginEl.removeAttr('id');
  8653. tapTargetOriginEl.removeAttr('style');
  8654. tapTargetWave.append(tapTargetOriginEl);
  8655. }
  8656. tapTargetWrapper.append(tapTargetWave);
  8657. }
  8658. // Open
  8659. var openTapTarget = function () {
  8660. if (tapTargetWrapper.is('.open')) {
  8661. return;
  8662. }
  8663. // Adding open class
  8664. tapTargetWrapper.addClass('open');
  8665. setTimeout(function () {
  8666. tapTargetOriginEl.off('click.tapTarget').on('click.tapTarget', function (e) {
  8667. closeTapTarget();
  8668. tapTargetOriginEl.off('click.tapTarget');
  8669. });
  8670. $(document).off('click.tapTarget').on('click.tapTarget', function (e) {
  8671. closeTapTarget();
  8672. $(document).off('click.tapTarget');
  8673. });
  8674. var throttledCalc = Materialize.throttle(function () {
  8675. calculateTapTarget();
  8676. }, 200);
  8677. $(window).off('resize.tapTarget').on('resize.tapTarget', throttledCalc);
  8678. }, 0);
  8679. };
  8680. // Close
  8681. var closeTapTarget = function () {
  8682. if (!tapTargetWrapper.is('.open')) {
  8683. return;
  8684. }
  8685. tapTargetWrapper.removeClass('open');
  8686. tapTargetOriginEl.off('click.tapTarget');
  8687. $(document).off('click.tapTarget');
  8688. $(window).off('resize.tapTarget');
  8689. };
  8690. // Pre calculate
  8691. var calculateTapTarget = function () {
  8692. // Element or parent is fixed position?
  8693. var isFixed = origin.css('position') === 'fixed';
  8694. if (!isFixed) {
  8695. var parents = origin.parents();
  8696. for (var i = 0; i < parents.length; i++) {
  8697. isFixed = $(parents[i]).css('position') == 'fixed';
  8698. if (isFixed) {
  8699. break;
  8700. }
  8701. }
  8702. }
  8703. // Calculating origin
  8704. var originWidth = origin.outerWidth();
  8705. var originHeight = origin.outerHeight();
  8706. var originTop = isFixed ? origin.offset().top - $(document).scrollTop() : origin.offset().top;
  8707. var originLeft = isFixed ? origin.offset().left - $(document).scrollLeft() : origin.offset().left;
  8708. // Calculating screen
  8709. var windowWidth = $(window).width();
  8710. var windowHeight = $(window).height();
  8711. var centerX = windowWidth / 2;
  8712. var centerY = windowHeight / 2;
  8713. var isLeft = originLeft <= centerX;
  8714. var isRight = originLeft > centerX;
  8715. var isTop = originTop <= centerY;
  8716. var isBottom = originTop > centerY;
  8717. var isCenterX = originLeft >= windowWidth * 0.25 && originLeft <= windowWidth * 0.75;
  8718. var isCenterY = originTop >= windowHeight * 0.25 && originTop <= windowHeight * 0.75;
  8719. // Calculating tap target
  8720. var tapTargetWidth = tapTargetEl.outerWidth();
  8721. var tapTargetHeight = tapTargetEl.outerHeight();
  8722. var tapTargetTop = originTop + originHeight / 2 - tapTargetHeight / 2;
  8723. var tapTargetLeft = originLeft + originWidth / 2 - tapTargetWidth / 2;
  8724. var tapTargetPosition = isFixed ? 'fixed' : 'absolute';
  8725. // Calculating content
  8726. var tapTargetTextWidth = isCenterX ? tapTargetWidth : tapTargetWidth / 2 + originWidth;
  8727. var tapTargetTextHeight = tapTargetHeight / 2;
  8728. var tapTargetTextTop = isTop ? tapTargetHeight / 2 : 0;
  8729. var tapTargetTextBottom = 0;
  8730. var tapTargetTextLeft = isLeft && !isCenterX ? tapTargetWidth / 2 - originWidth : 0;
  8731. var tapTargetTextRight = 0;
  8732. var tapTargetTextPadding = originWidth;
  8733. var tapTargetTextAlign = isBottom ? 'bottom' : 'top';
  8734. // Calculating wave
  8735. var tapTargetWaveWidth = originWidth > originHeight ? originWidth * 2 : originWidth * 2;
  8736. var tapTargetWaveHeight = tapTargetWaveWidth;
  8737. var tapTargetWaveTop = tapTargetHeight / 2 - tapTargetWaveHeight / 2;
  8738. var tapTargetWaveLeft = tapTargetWidth / 2 - tapTargetWaveWidth / 2;
  8739. // Setting tap target
  8740. var tapTargetWrapperCssObj = {};
  8741. tapTargetWrapperCssObj.top = isTop ? tapTargetTop : '';
  8742. tapTargetWrapperCssObj.right = isRight ? windowWidth - tapTargetLeft - tapTargetWidth : '';
  8743. tapTargetWrapperCssObj.bottom = isBottom ? windowHeight - tapTargetTop - tapTargetHeight : '';
  8744. tapTargetWrapperCssObj.left = isLeft ? tapTargetLeft : '';
  8745. tapTargetWrapperCssObj.position = tapTargetPosition;
  8746. tapTargetWrapper.css(tapTargetWrapperCssObj);
  8747. // Setting content
  8748. tapTargetContentEl.css({
  8749. width: tapTargetTextWidth,
  8750. height: tapTargetTextHeight,
  8751. top: tapTargetTextTop,
  8752. right: tapTargetTextRight,
  8753. bottom: tapTargetTextBottom,
  8754. left: tapTargetTextLeft,
  8755. padding: tapTargetTextPadding,
  8756. verticalAlign: tapTargetTextAlign
  8757. });
  8758. // Setting wave
  8759. tapTargetWave.css({
  8760. top: tapTargetWaveTop,
  8761. left: tapTargetWaveLeft,
  8762. width: tapTargetWaveWidth,
  8763. height: tapTargetWaveHeight
  8764. });
  8765. };
  8766. if (options == 'open') {
  8767. calculateTapTarget();
  8768. openTapTarget();
  8769. }
  8770. if (options == 'close') closeTapTarget();
  8771. });
  8772. },
  8773. open: function () { },
  8774. close: function () { }
  8775. };
  8776. $.fn.tapTarget = function (methodOrOptions) {
  8777. if (methods[methodOrOptions] || typeof methodOrOptions === 'object') return methods.init.apply(this, arguments);
  8778. $.error('Method ' + methodOrOptions + ' does not exist on jQuery.tap-target');
  8779. };
  8780. })(jQuery);