| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624 |
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // identity function for calling harmony imports with the correct context
- /******/ __webpack_require__.i = function(value) { return value; };
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 28);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _jquery = __webpack_require__(1);
- var _jquery2 = _interopRequireDefault(_jquery);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- /**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-beta): util.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
- */
- var Util = function () {
- /**
- * ------------------------------------------------------------------------
- * Private TransitionEnd Helpers
- * ------------------------------------------------------------------------
- */
- var transition = false;
- var MAX_UID = 1000000;
- var TransitionEndEvent = {
- WebkitTransition: 'webkitTransitionEnd',
- MozTransition: 'transitionend',
- OTransition: 'oTransitionEnd otransitionend',
- transition: 'transitionend'
- // shoutout AngusCroll (https://goo.gl/pxwQGp)
- };function toType(obj) {
- return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
- }
- function getSpecialTransitionEndEvent() {
- return {
- bindType: transition.end,
- delegateType: transition.end,
- handle: function handle(event) {
- if ((0, _jquery2.default)(event.target).is(this)) {
- return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
- }
- return undefined; // eslint-disable-line no-undefined
- }
- };
- }
- function transitionEndTest() {
- if (window.QUnit) {
- return false;
- }
- var el = document.createElement('bootstrap');
- for (var name in TransitionEndEvent) {
- if (typeof el.style[name] !== 'undefined') {
- return {
- end: TransitionEndEvent[name]
- };
- }
- }
- return false;
- }
- function transitionEndEmulator(duration) {
- var _this = this;
- var called = false;
- (0, _jquery2.default)(this).one(Util.TRANSITION_END, function () {
- called = true;
- });
- setTimeout(function () {
- if (!called) {
- Util.triggerTransitionEnd(_this);
- }
- }, duration);
- return this;
- }
- function setTransitionEndSupport() {
- transition = transitionEndTest();
- _jquery2.default.fn.emulateTransitionEnd = transitionEndEmulator;
- if (Util.supportsTransitionEnd()) {
- _jquery2.default.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
- }
- }
- function parseOption(item) {
- if ('true' === item) {
- return true;
- } else if ('false' === item) {
- return false;
- } else if (!isNaN(item * 1)) {
- return parseFloat(item);
- } else {
- return item;
- }
- }
- /**
- * --------------------------------------------------------------------------
- * Public Util Api
- * --------------------------------------------------------------------------
- */
- var Util = {
- TRANSITION_END: 'bsTransitionEnd',
- getUID: function getUID(prefix) {
- do {
- // eslint-disable-next-line no-bitwise
- prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
- } while (document.getElementById(prefix));
- return prefix;
- },
- getSelectorFromElement: function getSelectorFromElement(element) {
- var selector = element.getAttribute('data-target');
- if (!selector || selector === '#') {
- selector = element.getAttribute('href') || '';
- }
- try {
- var $selector = (0, _jquery2.default)(document).find(selector);
- return $selector.length > 0 ? selector : null;
- } catch (error) {
- return null;
- }
- },
- reflow: function reflow(element) {
- return element.offsetHeight;
- },
- triggerTransitionEnd: function triggerTransitionEnd(element) {
- (0, _jquery2.default)(element).trigger(transition.end);
- },
- supportsTransitionEnd: function supportsTransitionEnd() {
- return Boolean(transition);
- },
- isElement: function isElement(obj) {
- return (obj[0] || obj).nodeType;
- },
- typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
- for (var property in configTypes) {
- if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
- var expectedTypes = configTypes[property];
- var value = config[property];
- var valueType = value && Util.isElement(value) ? 'element' : toType(value);
- if (!new RegExp(expectedTypes).test(valueType)) {
- throw new Error(componentName.toUpperCase() + ': ' + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".'));
- }
- }
- }
- },
- parseDataOptions: function parseDataOptions(dataOptions) {
- var options = [];
- var string = dataOptions.split(';');
- string.forEach(function (item, index) {
- var option = item.split(':');
- option = option.map(function (item) {
- return item.trim();
- });
- if (option[0]) {
- options[option[0]] = parseOption(option[1]);
- }
- });
- return options;
- }
- };
- setTransitionEndSupport();
- return Util;
- }(_jquery2.default);
- exports.default = Util;
- /***/ }),
- /* 1 */
- /***/ (function(module, exports) {
- module.exports = jQuery;
- /***/ }),
- /* 2 */,
- /* 3 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- inputsContainer: '[data-inputs-container]',
- virtualInput: '[data-virtual-input]',
- isChecked: 'is-selected',
- inputTarget: '[data-input-target]',
- dataTargetId: '[data-target-id]',
- content: '[data-content]',
- contentTarget: '[data-content-target]'
- };
- var selectInput = function () {
- function selectInput(inputGroup, drop) {
- _classCallCheck(this, selectInput);
- this.inputGroup = inputGroup;
- this.type = this.inputGroup.data('inputs-container');
- this.drop = drop;
- this.virtualInputs = this.inputGroup.find(SELECTORS.virtualInput);
- this.bindEvents();
- }
- _createClass(selectInput, [{
- key: 'bindEvents',
- value: function bindEvents() {
- var _this = this;
- this.virtualInputs.on('click', function (event) {
- return _this.selectItem(event);
- });
- }
- }, {
- key: 'selectItem',
- value: function selectItem(event) {
- if (this.type == 'checkboxes') {
- if ($(event.currentTarget).hasClass('is-selected')) {
- $(event.currentTarget).removeClass(SELECTORS.isChecked);
- $(event.currentTarget).find('input').prop("checked", false);
- } else {
- $(event.currentTarget).addClass(SELECTORS.isChecked);
- $(event.currentTarget).find('input').prop("checked", true);
- }
- } else {
- this.virtualInputs.removeClass(SELECTORS.isChecked);
- this.virtualInputs.find('input').prop("checked", false);
- $(event.currentTarget).addClass(SELECTORS.isChecked);
- $(event.currentTarget).find('input').prop("checked", true);
- }
- if (this.drop) {
- this.getDropdownContent(event);
- this.setDropdownContent();
- this.drop.close();
- }
- }
- }, {
- key: 'setDropdownContent',
- value: function setDropdownContent() {
- for (var property in this.data) {
- $(this.drop.target).find('[data-view-' + property + ']').text(this.data[property]);
- }
- }
- }, {
- key: 'getDropdownContent',
- value: function getDropdownContent(event) {
- this.data = $(event.currentTarget).data('config');
- }
- }], [{
- key: 'init',
- value: function init(container, drop) {
- if (container) {
- new selectInput($(container).find(SELECTORS.inputsContainer), drop);
- } else {
- $(SELECTORS.inputsContainer).each(function () {
- new selectInput($(this), drop);
- });
- }
- }
- }]);
- return selectInput;
- }();
- exports.default = selectInput;
- /***/ }),
- /* 4 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- /**
- * Swiper 3.4.2
- * Most modern mobile touch slider and framework with hardware accelerated transitions
- *
- * http://www.idangero.us/swiper/
- *
- * Copyright 2017, Vladimir Kharlampidi
- * The iDangero.us
- * http://www.idangero.us/
- *
- * Licensed under MIT
- *
- * Released on: March 10, 2017
- */
- (function () {
- 'use strict';
- var $;
- /*===========================
- Swiper
- ===========================*/
- var Swiper = function Swiper(container, params) {
- if (!(this instanceof Swiper)) return new Swiper(container, params);
- var defaults = {
- direction: 'horizontal',
- touchEventsTarget: 'lu-container',
- initialSlide: 0,
- speed: 300,
- // autoplay
- autoplay: false,
- autoplayDisableOnInteraction: true,
- autoplayStopOnLast: false,
- // To support iOS's swipe-to-go-back gesture (when being used in-app, with UIWebView).
- iOSEdgeSwipeDetection: false,
- iOSEdgeSwipeThreshold: 20,
- // Free mode
- freeMode: false,
- freeModeMomentum: true,
- freeModeMomentumRatio: 1,
- freeModeMomentumBounce: true,
- freeModeMomentumBounceRatio: 1,
- freeModeMomentumVelocityRatio: 1,
- freeModeSticky: false,
- freeModeMinimumVelocity: 0.02,
- // Autoheight
- autoHeight: false,
- // Set wrapper width
- setWrapperSize: false,
- // Virtual Translate
- virtualTranslate: false,
- // Effects
- effect: 'slide', // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
- coverflow: {
- rotate: 50,
- stretch: 0,
- depth: 100,
- modifier: 1,
- slideShadows: true
- },
- flip: {
- slideShadows: true,
- limitRotation: true
- },
- cube: {
- slideShadows: true,
- shadow: true,
- shadowOffset: 20,
- shadowScale: 0.94
- },
- fade: {
- crossFade: false
- },
- // Parallax
- parallax: false,
- // Zoom
- zoom: false,
- zoomMax: 3,
- zoomMin: 1,
- zoomToggle: true,
- // Scrollbar
- scrollbar: null,
- scrollbarHide: true,
- scrollbarDraggable: false,
- scrollbarSnapOnRelease: false,
- // Keyboard Mousewheel
- keyboardControl: false,
- mousewheelControl: false,
- mousewheelReleaseOnEdges: false,
- mousewheelInvert: false,
- mousewheelForceToAxis: false,
- mousewheelSensitivity: 1,
- mousewheelEventsTarged: 'lu-container',
- // Hash Navigation
- hashnav: false,
- hashnavWatchState: false,
- // History
- history: false,
- // Commong Nav State
- replaceState: false,
- // Breakpoints
- breakpoints: undefined,
- // Slides grid
- spaceBetween: 0,
- slidesPerView: 1,
- slidesPerColumn: 1,
- slidesPerColumnFill: 'column',
- slidesPerGroup: 1,
- centeredSlides: false,
- slidesOffsetBefore: 0, // in px
- slidesOffsetAfter: 0, // in px
- // Round length
- roundLengths: false,
- // Touches
- touchRatio: 1,
- touchAngle: 45,
- simulateTouch: true,
- shortSwipes: true,
- longSwipes: true,
- longSwipesRatio: 0.5,
- longSwipesMs: 300,
- followFinger: true,
- onlyExternal: false,
- threshold: 0,
- touchMoveStopPropagation: true,
- touchReleaseOnEdges: false,
- // Unique Navigation Elements
- uniqueNavElements: true,
- // Pagination
- pagination: null,
- paginationElement: 'span',
- paginationClickable: false,
- paginationHide: false,
- paginationBulletRender: null,
- paginationProgressRender: null,
- paginationFractionRender: null,
- paginationCustomRender: null,
- paginationType: 'bullets', // 'bullets' or 'progress' or 'fraction' or 'custom'
- // Resistance
- resistance: true,
- resistanceRatio: 0.85,
- // Next/prev buttons
- nextButton: null,
- prevButton: null,
- // Progress
- watchSlidesProgress: false,
- watchSlidesVisibility: false,
- // Cursor
- grabCursor: false,
- // Clicks
- preventClicks: true,
- preventClicksPropagation: true,
- slideToClickedSlide: false,
- // Lazy Loading
- lazyLoading: false,
- lazyLoadingInPrevNext: false,
- lazyLoadingInPrevNextAmount: 1,
- lazyLoadingOnTransitionStart: false,
- // Images
- preloadImages: true,
- updateOnImagesReady: true,
- // loop
- loop: false,
- loopAdditionalSlides: 0,
- loopedSlides: null,
- // Control
- control: undefined,
- controlInverse: false,
- controlBy: 'slide', //or 'container'
- normalizeSlideIndex: true,
- // Swiping/no swiping
- allowSwipeToPrev: true,
- allowSwipeToNext: true,
- swipeHandler: null, //'.swipe-handler',
- noSwiping: true,
- noSwipingClass: 'swiper-no-swiping',
- // Passive Listeners
- passiveListeners: true,
- // NS
- containerModifierClass: 'swiper-container-', // NEW
- slideClass: 'swiper-slide',
- slideActiveClass: 'swiper-slide-active',
- slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
- slideVisibleClass: 'swiper-slide-visible',
- slideDuplicateClass: 'swiper-slide-duplicate',
- slideNextClass: 'swiper-slide-next',
- slideDuplicateNextClass: 'swiper-slide-duplicate-next',
- slidePrevClass: 'swiper-slide-prev',
- slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
- wrapperClass: 'swiper-wrapper',
- bulletClass: 'swiper-pagination-bullet',
- bulletActiveClass: 'swiper-pagination-bullet-active',
- buttonDisabledClass: 'swiper-button-disabled',
- paginationCurrentClass: 'swiper-pagination-current',
- paginationTotalClass: 'swiper-pagination-total',
- paginationHiddenClass: 'swiper-pagination-hidden',
- paginationProgressbarClass: 'swiper-pagination-progressbar',
- paginationClickableClass: 'swiper-pagination-clickable', // NEW
- paginationModifierClass: 'swiper-pagination-', // NEW
- lazyLoadingClass: 'swiper-lazy',
- lazyStatusLoadingClass: 'swiper-lazy-loading',
- lazyStatusLoadedClass: 'swiper-lazy-loaded',
- lazyPreloaderClass: 'swiper-lazy-preloader',
- notificationClass: 'swiper-notification',
- preloaderClass: 'preloader',
- zoomContainerClass: 'swiper-zoom-container',
- // Observer
- observer: false,
- observeParents: false,
- // Accessibility
- a11y: false,
- prevSlideMessage: 'Previous slide',
- nextSlideMessage: 'Next slide',
- firstSlideMessage: 'This is the first slide',
- lastSlideMessage: 'This is the last slide',
- paginationBulletMessage: 'Go to slide {{index}}',
- // Callbacks
- runCallbacksOnInit: true
- /*
- Callbacks:
- onInit: function (swiper)
- onDestroy: function (swiper)
- onBeforeResize: function (swiper)
- onAfterResize: function (swiper)
- onClick: function (swiper, e)
- onTap: function (swiper, e)
- onDoubleTap: function (swiper, e)
- onSliderMove: function (swiper, e)
- onSlideChangeStart: function (swiper)
- onSlideChangeEnd: function (swiper)
- onTransitionStart: function (swiper)
- onTransitionEnd: function (swiper)
- onImagesReady: function (swiper)
- onProgress: function (swiper, progress)
- onTouchStart: function (swiper, e)
- onTouchMove: function (swiper, e)
- onTouchMoveOpposite: function (swiper, e)
- onTouchEnd: function (swiper, e)
- onReachBeginning: function (swiper)
- onReachEnd: function (swiper)
- onSetTransition: function (swiper, duration)
- onSetTranslate: function (swiper, translate)
- onAutoplayStart: function (swiper)
- onAutoplayStop: function (swiper),
- onLazyImageLoad: function (swiper, slide, image)
- onLazyImageReady: function (swiper, slide, image)
- onKeyPress: function (swiper, keyCode)
- */
- };
- var initialVirtualTranslate = params && params.virtualTranslate;
- params = params || {};
- var originalParams = {};
- for (var param in params) {
- if (_typeof(params[param]) === 'object' && params[param] !== null && !(params[param].nodeType || params[param] === window || params[param] === document || typeof Dom7 !== 'undefined' && params[param] instanceof Dom7 || typeof jQuery !== 'undefined' && params[param] instanceof jQuery)) {
- originalParams[param] = {};
- for (var deepParam in params[param]) {
- originalParams[param][deepParam] = params[param][deepParam];
- }
- } else {
- originalParams[param] = params[param];
- }
- }
- for (var def in defaults) {
- if (typeof params[def] === 'undefined') {
- params[def] = defaults[def];
- } else if (_typeof(params[def]) === 'object') {
- for (var deepDef in defaults[def]) {
- if (typeof params[def][deepDef] === 'undefined') {
- params[def][deepDef] = defaults[def][deepDef];
- }
- }
- }
- }
- // Swiper
- var s = this;
- // Params
- s.params = params;
- s.originalParams = originalParams;
- // Classname
- s.classNames = [];
- /*=========================
- Dom Library and plugins
- ===========================*/
- if (typeof $ !== 'undefined' && typeof Dom7 !== 'undefined') {
- $ = Dom7;
- }
- if (typeof $ === 'undefined') {
- if (typeof Dom7 === 'undefined') {
- $ = window.Dom7 || window.Zepto || window.jQuery;
- } else {
- $ = Dom7;
- }
- if (!$) return;
- }
- // Export it to Swiper instance
- s.$ = $;
- /*=========================
- Breakpoints
- ===========================*/
- s.currentBreakpoint = undefined;
- s.getActiveBreakpoint = function () {
- //Get breakpoint for window width
- if (!s.params.breakpoints) return false;
- var breakpoint = false;
- var points = [],
- point;
- for (point in s.params.breakpoints) {
- if (s.params.breakpoints.hasOwnProperty(point)) {
- points.push(point);
- }
- }
- points.sort(function (a, b) {
- return parseInt(a, 10) > parseInt(b, 10);
- });
- for (var i = 0; i < points.length; i++) {
- point = points[i];
- if (point >= window.innerWidth && !breakpoint) {
- breakpoint = point;
- }
- }
- return breakpoint || 'max';
- };
- s.setBreakpoint = function () {
- //Set breakpoint for window width and update parameters
- var breakpoint = s.getActiveBreakpoint();
- if (breakpoint && s.currentBreakpoint !== breakpoint) {
- var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams;
- var needsReLoop = s.params.loop && breakPointsParams.slidesPerView !== s.params.slidesPerView;
- for (var param in breakPointsParams) {
- s.params[param] = breakPointsParams[param];
- }
- s.currentBreakpoint = breakpoint;
- if (needsReLoop && s.destroyLoop) {
- s.reLoop(true);
- }
- }
- };
- // Set breakpoint on load
- if (s.params.breakpoints) {
- s.setBreakpoint();
- }
- /*=========================
- Preparation - Define Container, Wrapper and Pagination
- ===========================*/
- s.container = $(container);
- if (s.container.length === 0) return;
- if (s.container.length > 1) {
- var swipers = [];
- s.container.each(function () {
- var container = this;
- swipers.push(new Swiper(this, params));
- });
- return swipers;
- }
- // Save instance in container HTML Element and in data
- s.container[0].swiper = s;
- s.container.data('swiper', s);
- s.classNames.push(s.params.containerModifierClass + s.params.direction);
- if (s.params.freeMode) {
- s.classNames.push(s.params.containerModifierClass + 'free-mode');
- }
- if (!s.support.flexbox) {
- s.classNames.push(s.params.containerModifierClass + 'no-flexbox');
- s.params.slidesPerColumn = 1;
- }
- if (s.params.autoHeight) {
- s.classNames.push(s.params.containerModifierClass + 'autoheight');
- }
- // Enable slides progress when required
- if (s.params.parallax || s.params.watchSlidesVisibility) {
- s.params.watchSlidesProgress = true;
- }
- // Max resistance when touchReleaseOnEdges
- if (s.params.touchReleaseOnEdges) {
- s.params.resistanceRatio = 0;
- }
- // Coverflow / 3D
- if (['cube', 'coverflow', 'flip'].indexOf(s.params.effect) >= 0) {
- if (s.support.transforms3d) {
- s.params.watchSlidesProgress = true;
- s.classNames.push(s.params.containerModifierClass + '3d');
- } else {
- s.params.effect = 'slide';
- }
- }
- if (s.params.effect !== 'slide') {
- s.classNames.push(s.params.containerModifierClass + s.params.effect);
- }
- if (s.params.effect === 'cube') {
- s.params.resistanceRatio = 0;
- s.params.slidesPerView = 1;
- s.params.slidesPerColumn = 1;
- s.params.slidesPerGroup = 1;
- s.params.centeredSlides = false;
- s.params.spaceBetween = 0;
- s.params.virtualTranslate = true;
- }
- if (s.params.effect === 'fade' || s.params.effect === 'flip') {
- s.params.slidesPerView = 1;
- s.params.slidesPerColumn = 1;
- s.params.slidesPerGroup = 1;
- s.params.watchSlidesProgress = true;
- s.params.spaceBetween = 0;
- if (typeof initialVirtualTranslate === 'undefined') {
- s.params.virtualTranslate = true;
- }
- }
- // Grab Cursor
- if (s.params.grabCursor && s.support.touch) {
- s.params.grabCursor = false;
- }
- // Wrapper
- s.wrapper = s.container.children('.' + s.params.wrapperClass);
- // Pagination
- if (s.params.pagination) {
- s.paginationContainer = $(s.params.pagination);
- if (s.params.uniqueNavElements && typeof s.params.pagination === 'string' && s.paginationContainer.length > 1 && s.container.find(s.params.pagination).length === 1) {
- s.paginationContainer = s.container.find(s.params.pagination);
- }
- if (s.params.paginationType === 'bullets' && s.params.paginationClickable) {
- s.paginationContainer.addClass(s.params.paginationModifierClass + 'clickable');
- } else {
- s.params.paginationClickable = false;
- }
- s.paginationContainer.addClass(s.params.paginationModifierClass + s.params.paginationType);
- }
- // Next/Prev Buttons
- if (s.params.nextButton || s.params.prevButton) {
- if (s.params.nextButton) {
- s.nextButton = $(s.params.nextButton);
- if (s.params.uniqueNavElements && typeof s.params.nextButton === 'string' && s.nextButton.length > 1 && s.container.find(s.params.nextButton).length === 1) {
- s.nextButton = s.container.find(s.params.nextButton);
- }
- }
- if (s.params.prevButton) {
- s.prevButton = $(s.params.prevButton);
- if (s.params.uniqueNavElements && typeof s.params.prevButton === 'string' && s.prevButton.length > 1 && s.container.find(s.params.prevButton).length === 1) {
- s.prevButton = s.container.find(s.params.prevButton);
- }
- }
- }
- // Is Horizontal
- s.isHorizontal = function () {
- return s.params.direction === 'horizontal';
- };
- // s.isH = isH;
- // RTL
- s.rtl = s.isHorizontal() && (s.container[0].dir.toLowerCase() === 'rtl' || s.container.css('direction') === 'rtl');
- if (s.rtl) {
- s.classNames.push(s.params.containerModifierClass + 'rtl');
- }
- // Wrong RTL support
- if (s.rtl) {
- s.wrongRTL = s.wrapper.css('display') === '-webkit-box';
- }
- // Columns
- if (s.params.slidesPerColumn > 1) {
- s.classNames.push(s.params.containerModifierClass + 'multirow');
- }
- // Check for Android
- if (s.device.android) {
- s.classNames.push(s.params.containerModifierClass + 'android');
- }
- // Add classes
- s.container.addClass(s.classNames.join(' '));
- // Translate
- s.translate = 0;
- // Progress
- s.progress = 0;
- // Velocity
- s.velocity = 0;
- /*=========================
- Locks, unlocks
- ===========================*/
- s.lockSwipeToNext = function () {
- s.params.allowSwipeToNext = false;
- if (s.params.allowSwipeToPrev === false && s.params.grabCursor) {
- s.unsetGrabCursor();
- }
- };
- s.lockSwipeToPrev = function () {
- s.params.allowSwipeToPrev = false;
- if (s.params.allowSwipeToNext === false && s.params.grabCursor) {
- s.unsetGrabCursor();
- }
- };
- s.lockSwipes = function () {
- s.params.allowSwipeToNext = s.params.allowSwipeToPrev = false;
- if (s.params.grabCursor) s.unsetGrabCursor();
- };
- s.unlockSwipeToNext = function () {
- s.params.allowSwipeToNext = true;
- if (s.params.allowSwipeToPrev === true && s.params.grabCursor) {
- s.setGrabCursor();
- }
- };
- s.unlockSwipeToPrev = function () {
- s.params.allowSwipeToPrev = true;
- if (s.params.allowSwipeToNext === true && s.params.grabCursor) {
- s.setGrabCursor();
- }
- };
- s.unlockSwipes = function () {
- s.params.allowSwipeToNext = s.params.allowSwipeToPrev = true;
- if (s.params.grabCursor) s.setGrabCursor();
- };
- /*=========================
- Round helper
- ===========================*/
- function round(a) {
- return Math.floor(a);
- }
- /*=========================
- Set grab cursor
- ===========================*/
- s.setGrabCursor = function (moving) {
- s.container[0].style.cursor = 'move';
- s.container[0].style.cursor = moving ? '-webkit-grabbing' : '-webkit-grab';
- s.container[0].style.cursor = moving ? '-moz-grabbin' : '-moz-grab';
- s.container[0].style.cursor = moving ? 'grabbing' : 'grab';
- };
- s.unsetGrabCursor = function () {
- s.container[0].style.cursor = '';
- };
- if (s.params.grabCursor) {
- s.setGrabCursor();
- }
- /*=========================
- Update on Images Ready
- ===========================*/
- s.imagesToLoad = [];
- s.imagesLoaded = 0;
- s.loadImage = function (imgElement, src, srcset, sizes, checkForComplete, callback) {
- var image;
- function onReady() {
- if (callback) callback();
- }
- if (!imgElement.complete || !checkForComplete) {
- if (src) {
- image = new window.Image();
- image.onload = onReady;
- image.onerror = onReady;
- if (sizes) {
- image.sizes = sizes;
- }
- if (srcset) {
- image.srcset = srcset;
- }
- if (src) {
- image.src = src;
- }
- } else {
- onReady();
- }
- } else {
- //image already loaded...
- onReady();
- }
- };
- s.preloadImages = function () {
- s.imagesToLoad = s.container.find('img');
- function _onReady() {
- if (typeof s === 'undefined' || s === null || !s) return;
- if (s.imagesLoaded !== undefined) s.imagesLoaded++;
- if (s.imagesLoaded === s.imagesToLoad.length) {
- if (s.params.updateOnImagesReady) s.update();
- s.emit('onImagesReady', s);
- }
- }
- for (var i = 0; i < s.imagesToLoad.length; i++) {
- s.loadImage(s.imagesToLoad[i], s.imagesToLoad[i].currentSrc || s.imagesToLoad[i].getAttribute('src'), s.imagesToLoad[i].srcset || s.imagesToLoad[i].getAttribute('srcset'), s.imagesToLoad[i].sizes || s.imagesToLoad[i].getAttribute('sizes'), true, _onReady);
- }
- };
- /*=========================
- Autoplay
- ===========================*/
- s.autoplayTimeoutId = undefined;
- s.autoplaying = false;
- s.autoplayPaused = false;
- function autoplay() {
- var autoplayDelay = s.params.autoplay;
- var activeSlide = s.slides.eq(s.activeIndex);
- if (activeSlide.attr('data-swiper-autoplay')) {
- autoplayDelay = activeSlide.attr('data-swiper-autoplay') || s.params.autoplay;
- }
- s.autoplayTimeoutId = setTimeout(function () {
- if (s.params.loop) {
- s.fixLoop();
- s._slideNext();
- s.emit('onAutoplay', s);
- } else {
- if (!s.isEnd) {
- s._slideNext();
- s.emit('onAutoplay', s);
- } else {
- if (!params.autoplayStopOnLast) {
- s._slideTo(0);
- s.emit('onAutoplay', s);
- } else {
- s.stopAutoplay();
- }
- }
- }
- }, autoplayDelay);
- }
- s.startAutoplay = function () {
- if (typeof s.autoplayTimeoutId !== 'undefined') return false;
- if (!s.params.autoplay) return false;
- if (s.autoplaying) return false;
- s.autoplaying = true;
- s.emit('onAutoplayStart', s);
- autoplay();
- };
- s.stopAutoplay = function (internal) {
- if (!s.autoplayTimeoutId) return;
- if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId);
- s.autoplaying = false;
- s.autoplayTimeoutId = undefined;
- s.emit('onAutoplayStop', s);
- };
- s.pauseAutoplay = function (speed) {
- if (s.autoplayPaused) return;
- if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId);
- s.autoplayPaused = true;
- if (speed === 0) {
- s.autoplayPaused = false;
- autoplay();
- } else {
- s.wrapper.transitionEnd(function () {
- if (!s) return;
- s.autoplayPaused = false;
- if (!s.autoplaying) {
- s.stopAutoplay();
- } else {
- autoplay();
- }
- });
- }
- };
- /*=========================
- Min/Max Translate
- ===========================*/
- s.minTranslate = function () {
- return -s.snapGrid[0];
- };
- s.maxTranslate = function () {
- return -s.snapGrid[s.snapGrid.length - 1];
- };
- /*=========================
- Slider/slides sizes
- ===========================*/
- s.updateAutoHeight = function () {
- var activeSlides = [];
- var newHeight = 0;
- var i;
- // Find slides currently in view
- if (s.params.slidesPerView !== 'auto' && s.params.slidesPerView > 1) {
- for (i = 0; i < Math.ceil(s.params.slidesPerView); i++) {
- var index = s.activeIndex + i;
- if (index > s.slides.length) break;
- activeSlides.push(s.slides.eq(index)[0]);
- }
- } else {
- activeSlides.push(s.slides.eq(s.activeIndex)[0]);
- }
- // Find new height from heighest slide in view
- for (i = 0; i < activeSlides.length; i++) {
- if (typeof activeSlides[i] !== 'undefined') {
- var height = activeSlides[i].offsetHeight;
- newHeight = height > newHeight ? height : newHeight;
- }
- }
- // Update Height
- if (newHeight) s.wrapper.css('height', newHeight + 'px');
- };
- s.updateContainerSize = function () {
- var width, height;
- if (typeof s.params.width !== 'undefined') {
- width = s.params.width;
- } else {
- width = s.container[0].clientWidth;
- }
- if (typeof s.params.height !== 'undefined') {
- height = s.params.height;
- } else {
- height = s.container[0].clientHeight;
- }
- if (width === 0 && s.isHorizontal() || height === 0 && !s.isHorizontal()) {
- return;
- }
- //Subtract paddings
- width = width - parseInt(s.container.css('padding-left'), 10) - parseInt(s.container.css('padding-right'), 10);
- height = height - parseInt(s.container.css('padding-top'), 10) - parseInt(s.container.css('padding-bottom'), 10);
- // Store values
- s.width = width;
- s.height = height;
- s.size = s.isHorizontal() ? s.width : s.height;
- };
- s.updateSlidesSize = function () {
- s.slides = s.wrapper.children('.' + s.params.slideClass);
- s.snapGrid = [];
- s.slidesGrid = [];
- s.slidesSizesGrid = [];
- var spaceBetween = s.params.spaceBetween,
- slidePosition = -s.params.slidesOffsetBefore,
- i,
- prevSlideSize = 0,
- index = 0;
- if (typeof s.size === 'undefined') return;
- if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
- spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size;
- }
- s.virtualSize = -spaceBetween;
- // reset margins
- if (s.rtl) s.slides.css({ marginLeft: '', marginTop: '' });else s.slides.css({ marginRight: '', marginBottom: '' });
- var slidesNumberEvenToRows;
- if (s.params.slidesPerColumn > 1) {
- if (Math.floor(s.slides.length / s.params.slidesPerColumn) === s.slides.length / s.params.slidesPerColumn) {
- slidesNumberEvenToRows = s.slides.length;
- } else {
- slidesNumberEvenToRows = Math.ceil(s.slides.length / s.params.slidesPerColumn) * s.params.slidesPerColumn;
- }
- if (s.params.slidesPerView !== 'auto' && s.params.slidesPerColumnFill === 'row') {
- slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, s.params.slidesPerView * s.params.slidesPerColumn);
- }
- }
- // Calc slides
- var slideSize;
- var slidesPerColumn = s.params.slidesPerColumn;
- var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn;
- var numFullColumns = slidesPerRow - (s.params.slidesPerColumn * slidesPerRow - s.slides.length);
- for (i = 0; i < s.slides.length; i++) {
- slideSize = 0;
- var slide = s.slides.eq(i);
- if (s.params.slidesPerColumn > 1) {
- // Set slides order
- var newSlideOrderIndex;
- var column, row;
- if (s.params.slidesPerColumnFill === 'column') {
- column = Math.floor(i / slidesPerColumn);
- row = i - column * slidesPerColumn;
- if (column > numFullColumns || column === numFullColumns && row === slidesPerColumn - 1) {
- if (++row >= slidesPerColumn) {
- row = 0;
- column++;
- }
- }
- newSlideOrderIndex = column + row * slidesNumberEvenToRows / slidesPerColumn;
- slide.css({
- '-webkit-box-ordinal-group': newSlideOrderIndex,
- '-moz-box-ordinal-group': newSlideOrderIndex,
- '-ms-flex-order': newSlideOrderIndex,
- '-webkit-order': newSlideOrderIndex,
- 'order': newSlideOrderIndex
- });
- } else {
- row = Math.floor(i / slidesPerRow);
- column = i - row * slidesPerRow;
- }
- slide.css('margin-' + (s.isHorizontal() ? 'top' : 'left'), row !== 0 && s.params.spaceBetween && s.params.spaceBetween + 'px').attr('data-swiper-column', column).attr('data-swiper-row', row);
- }
- if (slide.css('display') === 'none') continue;
- if (s.params.slidesPerView === 'auto') {
- slideSize = s.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true);
- if (s.params.roundLengths) slideSize = round(slideSize);
- } else {
- slideSize = (s.size - (s.params.slidesPerView - 1) * spaceBetween) / s.params.slidesPerView;
- if (s.params.roundLengths) slideSize = round(slideSize);
- if (s.isHorizontal()) {
- s.slides[i].style.width = slideSize + 'px';
- } else {
- s.slides[i].style.height = slideSize + 'px';
- }
- }
- s.slides[i].swiperSlideSize = slideSize;
- s.slidesSizesGrid.push(slideSize);
- if (s.params.centeredSlides) {
- slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
- if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - s.size / 2 - spaceBetween;
- if (i === 0) slidePosition = slidePosition - s.size / 2 - spaceBetween;
- if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
- if (index % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition);
- s.slidesGrid.push(slidePosition);
- } else {
- if (index % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition);
- s.slidesGrid.push(slidePosition);
- slidePosition = slidePosition + slideSize + spaceBetween;
- }
- s.virtualSize += slideSize + spaceBetween;
- prevSlideSize = slideSize;
- index++;
- }
- s.virtualSize = Math.max(s.virtualSize, s.size) + s.params.slidesOffsetAfter;
- var newSlidesGrid;
- if (s.rtl && s.wrongRTL && (s.params.effect === 'slide' || s.params.effect === 'coverflow')) {
- s.wrapper.css({ width: s.virtualSize + s.params.spaceBetween + 'px' });
- }
- if (!s.support.flexbox || s.params.setWrapperSize) {
- if (s.isHorizontal()) s.wrapper.css({ width: s.virtualSize + s.params.spaceBetween + 'px' });else s.wrapper.css({ height: s.virtualSize + s.params.spaceBetween + 'px' });
- }
- if (s.params.slidesPerColumn > 1) {
- s.virtualSize = (slideSize + s.params.spaceBetween) * slidesNumberEvenToRows;
- s.virtualSize = Math.ceil(s.virtualSize / s.params.slidesPerColumn) - s.params.spaceBetween;
- if (s.isHorizontal()) s.wrapper.css({ width: s.virtualSize + s.params.spaceBetween + 'px' });else s.wrapper.css({ height: s.virtualSize + s.params.spaceBetween + 'px' });
- if (s.params.centeredSlides) {
- newSlidesGrid = [];
- for (i = 0; i < s.snapGrid.length; i++) {
- if (s.snapGrid[i] < s.virtualSize + s.snapGrid[0]) newSlidesGrid.push(s.snapGrid[i]);
- }
- s.snapGrid = newSlidesGrid;
- }
- }
- // Remove last grid elements depending on width
- if (!s.params.centeredSlides) {
- newSlidesGrid = [];
- for (i = 0; i < s.snapGrid.length; i++) {
- if (s.snapGrid[i] <= s.virtualSize - s.size) {
- newSlidesGrid.push(s.snapGrid[i]);
- }
- }
- s.snapGrid = newSlidesGrid;
- if (Math.floor(s.virtualSize - s.size) - Math.floor(s.snapGrid[s.snapGrid.length - 1]) > 1) {
- s.snapGrid.push(s.virtualSize - s.size);
- }
- }
- if (s.snapGrid.length === 0) s.snapGrid = [0];
- if (s.params.spaceBetween !== 0) {
- if (s.isHorizontal()) {
- if (s.rtl) s.slides.css({ marginLeft: spaceBetween + 'px' });else s.slides.css({ marginRight: spaceBetween + 'px' });
- } else s.slides.css({ marginBottom: spaceBetween + 'px' });
- }
- if (s.params.watchSlidesProgress) {
- s.updateSlidesOffset();
- }
- };
- s.updateSlidesOffset = function () {
- for (var i = 0; i < s.slides.length; i++) {
- s.slides[i].swiperSlideOffset = s.isHorizontal() ? s.slides[i].offsetLeft : s.slides[i].offsetTop;
- }
- };
- /*=========================
- Dynamic Slides Per View
- ===========================*/
- s.currentSlidesPerView = function () {
- var spv = 1,
- i,
- j;
- if (s.params.centeredSlides) {
- var size = s.slides[s.activeIndex].swiperSlideSize;
- var breakLoop;
- for (i = s.activeIndex + 1; i < s.slides.length; i++) {
- if (s.slides[i] && !breakLoop) {
- size += s.slides[i].swiperSlideSize;
- spv++;
- if (size > s.size) breakLoop = true;
- }
- }
- for (j = s.activeIndex - 1; j >= 0; j--) {
- if (s.slides[j] && !breakLoop) {
- size += s.slides[j].swiperSlideSize;
- spv++;
- if (size > s.size) breakLoop = true;
- }
- }
- } else {
- for (i = s.activeIndex + 1; i < s.slides.length; i++) {
- if (s.slidesGrid[i] - s.slidesGrid[s.activeIndex] < s.size) {
- spv++;
- }
- }
- }
- return spv;
- };
- /*=========================
- Slider/slides progress
- ===========================*/
- s.updateSlidesProgress = function (translate) {
- if (typeof translate === 'undefined') {
- translate = s.translate || 0;
- }
- if (s.slides.length === 0) return;
- if (typeof s.slides[0].swiperSlideOffset === 'undefined') s.updateSlidesOffset();
- var offsetCenter = -translate;
- if (s.rtl) offsetCenter = translate;
- // Visible Slides
- s.slides.removeClass(s.params.slideVisibleClass);
- for (var i = 0; i < s.slides.length; i++) {
- var slide = s.slides[i];
- var slideProgress = (offsetCenter + (s.params.centeredSlides ? s.minTranslate() : 0) - slide.swiperSlideOffset) / (slide.swiperSlideSize + s.params.spaceBetween);
- if (s.params.watchSlidesVisibility) {
- var slideBefore = -(offsetCenter - slide.swiperSlideOffset);
- var slideAfter = slideBefore + s.slidesSizesGrid[i];
- var isVisible = slideBefore >= 0 && slideBefore < s.size || slideAfter > 0 && slideAfter <= s.size || slideBefore <= 0 && slideAfter >= s.size;
- if (isVisible) {
- s.slides.eq(i).addClass(s.params.slideVisibleClass);
- }
- }
- slide.progress = s.rtl ? -slideProgress : slideProgress;
- }
- };
- s.updateProgress = function (translate) {
- if (typeof translate === 'undefined') {
- translate = s.translate || 0;
- }
- var translatesDiff = s.maxTranslate() - s.minTranslate();
- var wasBeginning = s.isBeginning;
- var wasEnd = s.isEnd;
- if (translatesDiff === 0) {
- s.progress = 0;
- s.isBeginning = s.isEnd = true;
- } else {
- s.progress = (translate - s.minTranslate()) / translatesDiff;
- s.isBeginning = s.progress <= 0;
- s.isEnd = s.progress >= 1;
- }
- if (s.isBeginning && !wasBeginning) s.emit('onReachBeginning', s);
- if (s.isEnd && !wasEnd) s.emit('onReachEnd', s);
- if (s.params.watchSlidesProgress) s.updateSlidesProgress(translate);
- s.emit('onProgress', s, s.progress);
- };
- s.updateActiveIndex = function () {
- var translate = s.rtl ? s.translate : -s.translate;
- var newActiveIndex, i, snapIndex;
- for (i = 0; i < s.slidesGrid.length; i++) {
- if (typeof s.slidesGrid[i + 1] !== 'undefined') {
- if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1] - (s.slidesGrid[i + 1] - s.slidesGrid[i]) / 2) {
- newActiveIndex = i;
- } else if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1]) {
- newActiveIndex = i + 1;
- }
- } else {
- if (translate >= s.slidesGrid[i]) {
- newActiveIndex = i;
- }
- }
- }
- // Normalize slideIndex
- if (s.params.normalizeSlideIndex) {
- if (newActiveIndex < 0 || typeof newActiveIndex === 'undefined') newActiveIndex = 0;
- }
- // for (i = 0; i < s.slidesGrid.length; i++) {
- // if (- translate >= s.slidesGrid[i]) {
- // newActiveIndex = i;
- // }
- // }
- snapIndex = Math.floor(newActiveIndex / s.params.slidesPerGroup);
- if (snapIndex >= s.snapGrid.length) snapIndex = s.snapGrid.length - 1;
- if (newActiveIndex === s.activeIndex) {
- return;
- }
- s.snapIndex = snapIndex;
- s.previousIndex = s.activeIndex;
- s.activeIndex = newActiveIndex;
- s.updateClasses();
- s.updateRealIndex();
- };
- s.updateRealIndex = function () {
- s.realIndex = parseInt(s.slides.eq(s.activeIndex).attr('data-swiper-slide-index') || s.activeIndex, 10);
- };
- /*=========================
- Classes
- ===========================*/
- s.updateClasses = function () {
- s.slides.removeClass(s.params.slideActiveClass + ' ' + s.params.slideNextClass + ' ' + s.params.slidePrevClass + ' ' + s.params.slideDuplicateActiveClass + ' ' + s.params.slideDuplicateNextClass + ' ' + s.params.slideDuplicatePrevClass);
- var activeSlide = s.slides.eq(s.activeIndex);
- // Active classes
- activeSlide.addClass(s.params.slideActiveClass);
- if (params.loop) {
- // Duplicate to all looped slides
- if (activeSlide.hasClass(s.params.slideDuplicateClass)) {
- s.wrapper.children('.' + s.params.slideClass + ':not(.' + s.params.slideDuplicateClass + ')[data-swiper-slide-index="' + s.realIndex + '"]').addClass(s.params.slideDuplicateActiveClass);
- } else {
- s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + s.realIndex + '"]').addClass(s.params.slideDuplicateActiveClass);
- }
- }
- // Next Slide
- var nextSlide = activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass);
- if (s.params.loop && nextSlide.length === 0) {
- nextSlide = s.slides.eq(0);
- nextSlide.addClass(s.params.slideNextClass);
- }
- // Prev Slide
- var prevSlide = activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass);
- if (s.params.loop && prevSlide.length === 0) {
- prevSlide = s.slides.eq(-1);
- prevSlide.addClass(s.params.slidePrevClass);
- }
- if (params.loop) {
- // Duplicate to all looped slides
- if (nextSlide.hasClass(s.params.slideDuplicateClass)) {
- s.wrapper.children('.' + s.params.slideClass + ':not(.' + s.params.slideDuplicateClass + ')[data-swiper-slide-index="' + nextSlide.attr('data-swiper-slide-index') + '"]').addClass(s.params.slideDuplicateNextClass);
- } else {
- s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + nextSlide.attr('data-swiper-slide-index') + '"]').addClass(s.params.slideDuplicateNextClass);
- }
- if (prevSlide.hasClass(s.params.slideDuplicateClass)) {
- s.wrapper.children('.' + s.params.slideClass + ':not(.' + s.params.slideDuplicateClass + ')[data-swiper-slide-index="' + prevSlide.attr('data-swiper-slide-index') + '"]').addClass(s.params.slideDuplicatePrevClass);
- } else {
- s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + prevSlide.attr('data-swiper-slide-index') + '"]').addClass(s.params.slideDuplicatePrevClass);
- }
- }
- // Pagination
- if (s.paginationContainer && s.paginationContainer.length > 0) {
- // Current/Total
- var current,
- total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
- if (s.params.loop) {
- current = Math.ceil((s.activeIndex - s.loopedSlides) / s.params.slidesPerGroup);
- if (current > s.slides.length - 1 - s.loopedSlides * 2) {
- current = current - (s.slides.length - s.loopedSlides * 2);
- }
- if (current > total - 1) current = current - total;
- if (current < 0 && s.params.paginationType !== 'bullets') current = total + current;
- } else {
- if (typeof s.snapIndex !== 'undefined') {
- current = s.snapIndex;
- } else {
- current = s.activeIndex || 0;
- }
- }
- // Types
- if (s.params.paginationType === 'bullets' && s.bullets && s.bullets.length > 0) {
- s.bullets.removeClass(s.params.bulletActiveClass);
- if (s.paginationContainer.length > 1) {
- s.bullets.each(function () {
- if ($(this).index() === current) $(this).addClass(s.params.bulletActiveClass);
- });
- } else {
- s.bullets.eq(current).addClass(s.params.bulletActiveClass);
- }
- }
- if (s.params.paginationType === 'fraction') {
- s.paginationContainer.find('.' + s.params.paginationCurrentClass).text(current + 1);
- s.paginationContainer.find('.' + s.params.paginationTotalClass).text(total);
- }
- if (s.params.paginationType === 'progress') {
- var scale = (current + 1) / total,
- scaleX = scale,
- scaleY = 1;
- if (!s.isHorizontal()) {
- scaleY = scale;
- scaleX = 1;
- }
- s.paginationContainer.find('.' + s.params.paginationProgressbarClass).transform('translate3d(0,0,0) scaleX(' + scaleX + ') scaleY(' + scaleY + ')').transition(s.params.speed);
- }
- if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) {
- s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total));
- s.emit('onPaginationRendered', s, s.paginationContainer[0]);
- }
- }
- // Next/active buttons
- if (!s.params.loop) {
- if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
- if (s.isBeginning) {
- s.prevButton.addClass(s.params.buttonDisabledClass);
- if (s.params.a11y && s.a11y) s.a11y.disable(s.prevButton);
- } else {
- s.prevButton.removeClass(s.params.buttonDisabledClass);
- if (s.params.a11y && s.a11y) s.a11y.enable(s.prevButton);
- }
- }
- if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
- if (s.isEnd) {
- s.nextButton.addClass(s.params.buttonDisabledClass);
- if (s.params.a11y && s.a11y) s.a11y.disable(s.nextButton);
- } else {
- s.nextButton.removeClass(s.params.buttonDisabledClass);
- if (s.params.a11y && s.a11y) s.a11y.enable(s.nextButton);
- }
- }
- }
- };
- /*=========================
- Pagination
- ===========================*/
- s.updatePagination = function () {
- if (!s.params.pagination) return;
- if (s.paginationContainer && s.paginationContainer.length > 0) {
- var paginationHTML = '';
- if (s.params.paginationType === 'bullets') {
- var numberOfBullets = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
- for (var i = 0; i < numberOfBullets; i++) {
- if (s.params.paginationBulletRender) {
- paginationHTML += s.params.paginationBulletRender(s, i, s.params.bulletClass);
- } else {
- paginationHTML += '<' + s.params.paginationElement + ' class="' + s.params.bulletClass + '"></' + s.params.paginationElement + '>';
- }
- }
- s.paginationContainer.html(paginationHTML);
- s.bullets = s.paginationContainer.find('.' + s.params.bulletClass);
- if (s.params.paginationClickable && s.params.a11y && s.a11y) {
- s.a11y.initPagination();
- }
- }
- if (s.params.paginationType === 'fraction') {
- if (s.params.paginationFractionRender) {
- paginationHTML = s.params.paginationFractionRender(s, s.params.paginationCurrentClass, s.params.paginationTotalClass);
- } else {
- paginationHTML = '<span class="' + s.params.paginationCurrentClass + '"></span>' + ' / ' + '<span class="' + s.params.paginationTotalClass + '"></span>';
- }
- s.paginationContainer.html(paginationHTML);
- }
- if (s.params.paginationType === 'progress') {
- if (s.params.paginationProgressRender) {
- paginationHTML = s.params.paginationProgressRender(s, s.params.paginationProgressbarClass);
- } else {
- paginationHTML = '<span class="' + s.params.paginationProgressbarClass + '"></span>';
- }
- s.paginationContainer.html(paginationHTML);
- }
- if (s.params.paginationType !== 'custom') {
- s.emit('onPaginationRendered', s, s.paginationContainer[0]);
- }
- }
- };
- /*=========================
- Common update method
- ===========================*/
- s.update = function (updateTranslate) {
- if (!s) return;
- s.updateContainerSize();
- s.updateSlidesSize();
- s.updateProgress();
- s.updatePagination();
- s.updateClasses();
- if (s.params.scrollbar && s.scrollbar) {
- s.scrollbar.set();
- }
- var newTranslate;
- function forceSetTranslate() {
- var translate = s.rtl ? -s.translate : s.translate;
- newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
- s.setWrapperTranslate(newTranslate);
- s.updateActiveIndex();
- s.updateClasses();
- }
- if (updateTranslate) {
- var translated;
- if (s.controller && s.controller.spline) {
- s.controller.spline = undefined;
- }
- if (s.params.freeMode) {
- forceSetTranslate();
- if (s.params.autoHeight) {
- s.updateAutoHeight();
- }
- } else {
- if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
- translated = s.slideTo(s.slides.length - 1, 0, false, true);
- } else {
- translated = s.slideTo(s.activeIndex, 0, false, true);
- }
- if (!translated) {
- forceSetTranslate();
- }
- }
- } else if (s.params.autoHeight) {
- s.updateAutoHeight();
- }
- };
- /*=========================
- Resize Handler
- ===========================*/
- s.onResize = function (forceUpdatePagination) {
- if (s.params.onBeforeResize) s.params.onBeforeResize(s);
- //Breakpoints
- if (s.params.breakpoints) {
- s.setBreakpoint();
- }
- // Disable locks on resize
- var allowSwipeToPrev = s.params.allowSwipeToPrev;
- var allowSwipeToNext = s.params.allowSwipeToNext;
- s.params.allowSwipeToPrev = s.params.allowSwipeToNext = true;
- s.updateContainerSize();
- s.updateSlidesSize();
- if (s.params.slidesPerView === 'auto' || s.params.freeMode || forceUpdatePagination) s.updatePagination();
- if (s.params.scrollbar && s.scrollbar) {
- s.scrollbar.set();
- }
- if (s.controller && s.controller.spline) {
- s.controller.spline = undefined;
- }
- var slideChangedBySlideTo = false;
- if (s.params.freeMode) {
- var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
- s.setWrapperTranslate(newTranslate);
- s.updateActiveIndex();
- s.updateClasses();
- if (s.params.autoHeight) {
- s.updateAutoHeight();
- }
- } else {
- s.updateClasses();
- if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
- slideChangedBySlideTo = s.slideTo(s.slides.length - 1, 0, false, true);
- } else {
- slideChangedBySlideTo = s.slideTo(s.activeIndex, 0, false, true);
- }
- }
- if (s.params.lazyLoading && !slideChangedBySlideTo && s.lazy) {
- s.lazy.load();
- }
- // Return locks after resize
- s.params.allowSwipeToPrev = allowSwipeToPrev;
- s.params.allowSwipeToNext = allowSwipeToNext;
- if (s.params.onAfterResize) s.params.onAfterResize(s);
- };
- /*=========================
- Events
- ===========================*/
- //Define Touch Events
- s.touchEventsDesktop = { start: 'mousedown', move: 'mousemove', end: 'mouseup' };
- if (window.navigator.pointerEnabled) s.touchEventsDesktop = { start: 'pointerdown', move: 'pointermove', end: 'pointerup' };else if (window.navigator.msPointerEnabled) s.touchEventsDesktop = { start: 'MSPointerDown', move: 'MSPointerMove', end: 'MSPointerUp' };
- s.touchEvents = {
- start: s.support.touch || !s.params.simulateTouch ? 'touchstart' : s.touchEventsDesktop.start,
- move: s.support.touch || !s.params.simulateTouch ? 'touchmove' : s.touchEventsDesktop.move,
- end: s.support.touch || !s.params.simulateTouch ? 'touchend' : s.touchEventsDesktop.end
- };
- // WP8 Touch Events Fix
- if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) {
- //console.log('1669', s.params.touchEventsTarget);
- (s.params.touchEventsTarget === 'container' ? s.container : s.wrapper).addClass('swiper-wp8-' + s.params.direction);
- }
- // Attach/detach events
- s.initEvents = function (detach) {
- var actionDom = detach ? 'off' : 'on';
- var action = detach ? 'removeEventListener' : 'addEventListener';
- var touchEventsTarget = s.params.touchEventsTarget === 'lu-container' ? s.container[0] : s.wrapper[0];
- var target = s.support.touch ? touchEventsTarget : document;
- var moveCapture = s.params.nested ? true : false;
- //Touch Events
- if (s.browser.ie) {
- touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, false);
- target[action](s.touchEvents.move, s.onTouchMove, moveCapture);
- target[action](s.touchEvents.end, s.onTouchEnd, false);
- } else {
- if (s.support.touch) {
- var passiveListener = s.touchEvents.start === 'touchstart' && s.support.passiveListener && s.params.passiveListeners ? { passive: true, capture: false } : false;
- touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, passiveListener);
- touchEventsTarget[action](s.touchEvents.move, s.onTouchMove, moveCapture);
- touchEventsTarget[action](s.touchEvents.end, s.onTouchEnd, passiveListener);
- }
- if (params.simulateTouch && !s.device.ios && !s.device.android || params.simulateTouch && !s.support.touch && s.device.ios) {
- touchEventsTarget[action]('mousedown', s.onTouchStart, false);
- document[action]('mousemove', s.onTouchMove, moveCapture);
- document[action]('mouseup', s.onTouchEnd, false);
- }
- }
- window[action]('resize', s.onResize);
- // Next, Prev, Index
- if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
- s.nextButton[actionDom]('click', s.onClickNext);
- if (s.params.a11y && s.a11y) s.nextButton[actionDom]('keydown', s.a11y.onEnterKey);
- }
- if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
- s.prevButton[actionDom]('click', s.onClickPrev);
- if (s.params.a11y && s.a11y) s.prevButton[actionDom]('keydown', s.a11y.onEnterKey);
- }
- if (s.params.pagination && s.params.paginationClickable) {
- s.paginationContainer[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex);
- if (s.params.a11y && s.a11y) s.paginationContainer[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey);
- }
- // Prevent Links Clicks
- if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true);
- };
- s.attachEvents = function () {
- s.initEvents();
- };
- s.detachEvents = function () {
- s.initEvents(true);
- };
- /*=========================
- Handle Clicks
- ===========================*/
- // Prevent Clicks
- s.allowClick = true;
- s.preventClicks = function (e) {
- if (!s.allowClick) {
- if (s.params.preventClicks) e.preventDefault();
- if (s.params.preventClicksPropagation && s.animating) {
- e.stopPropagation();
- e.stopImmediatePropagation();
- }
- }
- };
- // Clicks
- s.onClickNext = function (e) {
- e.preventDefault();
- if (s.isEnd && !s.params.loop) return;
- s.slideNext();
- };
- s.onClickPrev = function (e) {
- e.preventDefault();
- if (s.isBeginning && !s.params.loop) return;
- s.slidePrev();
- };
- s.onClickIndex = function (e) {
- e.preventDefault();
- var index = $(this).index() * s.params.slidesPerGroup;
- if (s.params.loop) index = index + s.loopedSlides;
- s.slideTo(index);
- };
- /*=========================
- Handle Touches
- ===========================*/
- function findElementInEvent(e, selector) {
- var el = $(e.target);
- if (!el.is(selector)) {
- if (typeof selector === 'string') {
- el = el.parents(selector);
- } else if (selector.nodeType) {
- var found;
- el.parents().each(function (index, _el) {
- if (_el === selector) found = selector;
- });
- if (!found) return undefined;else return selector;
- }
- }
- if (el.length === 0) {
- return undefined;
- }
- return el[0];
- }
- s.updateClickedSlide = function (e) {
- var slide = findElementInEvent(e, '.' + s.params.slideClass);
- var slideFound = false;
- if (slide) {
- for (var i = 0; i < s.slides.length; i++) {
- if (s.slides[i] === slide) slideFound = true;
- }
- }
- if (slide && slideFound) {
- s.clickedSlide = slide;
- s.clickedIndex = $(slide).index();
- } else {
- s.clickedSlide = undefined;
- s.clickedIndex = undefined;
- return;
- }
- if (s.params.slideToClickedSlide && s.clickedIndex !== undefined && s.clickedIndex !== s.activeIndex) {
- var slideToIndex = s.clickedIndex,
- realIndex,
- duplicatedSlides,
- slidesPerView = s.params.slidesPerView === 'auto' ? s.currentSlidesPerView() : s.params.slidesPerView;
- if (s.params.loop) {
- if (s.animating) return;
- realIndex = parseInt($(s.clickedSlide).attr('data-swiper-slide-index'), 10);
- if (s.params.centeredSlides) {
- if (slideToIndex < s.loopedSlides - slidesPerView / 2 || slideToIndex > s.slides.length - s.loopedSlides + slidesPerView / 2) {
- s.fixLoop();
- slideToIndex = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]:not(.' + s.params.slideDuplicateClass + ')').eq(0).index();
- setTimeout(function () {
- s.slideTo(slideToIndex);
- }, 0);
- } else {
- s.slideTo(slideToIndex);
- }
- } else {
- if (slideToIndex > s.slides.length - slidesPerView) {
- s.fixLoop();
- slideToIndex = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]:not(.' + s.params.slideDuplicateClass + ')').eq(0).index();
- setTimeout(function () {
- s.slideTo(slideToIndex);
- }, 0);
- } else {
- s.slideTo(slideToIndex);
- }
- }
- } else {
- s.slideTo(slideToIndex);
- }
- }
- };
- var isTouched,
- isMoved,
- allowTouchCallbacks,
- touchStartTime,
- isScrolling,
- currentTranslate,
- startTranslate,
- allowThresholdMove,
- // Form elements to match
- formElements = 'input, select, textarea, button, video',
- // Last click time
- lastClickTime = Date.now(),
- clickTimeout,
- //Velocities
- velocities = [],
- allowMomentumBounce;
- // Animating Flag
- s.animating = false;
- // Touches information
- s.touches = {
- startX: 0,
- startY: 0,
- currentX: 0,
- currentY: 0,
- diff: 0
- };
- // Touch handlers
- var isTouchEvent, startMoving;
- s.onTouchStart = function (e) {
- if (e.originalEvent) e = e.originalEvent;
- isTouchEvent = e.type === 'touchstart';
- if (!isTouchEvent && 'which' in e && e.which === 3) return;
- if (s.params.noSwiping && findElementInEvent(e, '.' + s.params.noSwipingClass)) {
- s.allowClick = true;
- return;
- }
- if (s.params.swipeHandler) {
- if (!findElementInEvent(e, s.params.swipeHandler)) return;
- }
- var startX = s.touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
- var startY = s.touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
- // Do NOT start if iOS edge swipe is detected. Otherwise iOS app (UIWebView) cannot swipe-to-go-back anymore
- if (s.device.ios && s.params.iOSEdgeSwipeDetection && startX <= s.params.iOSEdgeSwipeThreshold) {
- return;
- }
- isTouched = true;
- isMoved = false;
- allowTouchCallbacks = true;
- isScrolling = undefined;
- startMoving = undefined;
- s.touches.startX = startX;
- s.touches.startY = startY;
- touchStartTime = Date.now();
- s.allowClick = true;
- s.updateContainerSize();
- s.swipeDirection = undefined;
- if (s.params.threshold > 0) allowThresholdMove = false;
- if (e.type !== 'touchstart') {
- var preventDefault = true;
- if ($(e.target).is(formElements)) preventDefault = false;
- if (document.activeElement && $(document.activeElement).is(formElements)) {
- document.activeElement.blur();
- }
- if (preventDefault) {
- e.preventDefault();
- }
- }
- s.emit('onTouchStart', s, e);
- };
- s.onTouchMove = function (e) {
- if (e.originalEvent) e = e.originalEvent;
- if (isTouchEvent && e.type === 'mousemove') return;
- if (e.preventedByNestedSwiper) {
- s.touches.startX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
- s.touches.startY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
- return;
- }
- if (s.params.onlyExternal) {
- // isMoved = true;
- s.allowClick = false;
- if (isTouched) {
- s.touches.startX = s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
- s.touches.startY = s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
- touchStartTime = Date.now();
- }
- return;
- }
- if (isTouchEvent && s.params.touchReleaseOnEdges && !s.params.loop) {
- if (!s.isHorizontal()) {
- // Vertical
- if (s.touches.currentY < s.touches.startY && s.translate <= s.maxTranslate() || s.touches.currentY > s.touches.startY && s.translate >= s.minTranslate()) {
- return;
- }
- } else {
- if (s.touches.currentX < s.touches.startX && s.translate <= s.maxTranslate() || s.touches.currentX > s.touches.startX && s.translate >= s.minTranslate()) {
- return;
- }
- }
- }
- if (isTouchEvent && document.activeElement) {
- if (e.target === document.activeElement && $(e.target).is(formElements)) {
- isMoved = true;
- s.allowClick = false;
- return;
- }
- }
- if (allowTouchCallbacks) {
- s.emit('onTouchMove', s, e);
- }
- if (e.targetTouches && e.targetTouches.length > 1) return;
- s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
- s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
- if (typeof isScrolling === 'undefined') {
- var touchAngle;
- if (s.isHorizontal() && s.touches.currentY === s.touches.startY || !s.isHorizontal() && s.touches.currentX === s.touches.startX) {
- isScrolling = false;
- } else {
- touchAngle = Math.atan2(Math.abs(s.touches.currentY - s.touches.startY), Math.abs(s.touches.currentX - s.touches.startX)) * 180 / Math.PI;
- isScrolling = s.isHorizontal() ? touchAngle > s.params.touchAngle : 90 - touchAngle > s.params.touchAngle;
- }
- }
- if (isScrolling) {
- s.emit('onTouchMoveOpposite', s, e);
- }
- if (typeof startMoving === 'undefined') {
- if (s.touches.currentX !== s.touches.startX || s.touches.currentY !== s.touches.startY) {
- startMoving = true;
- }
- }
- if (!isTouched) return;
- if (isScrolling) {
- isTouched = false;
- return;
- }
- if (!startMoving) {
- return;
- }
- s.allowClick = false;
- s.emit('onSliderMove', s, e);
- e.preventDefault();
- if (s.params.touchMoveStopPropagation && !s.params.nested) {
- e.stopPropagation();
- }
- if (!isMoved) {
- if (params.loop) {
- s.fixLoop();
- }
- startTranslate = s.getWrapperTranslate();
- s.setWrapperTransition(0);
- if (s.animating) {
- s.wrapper.trigger('webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd msTransitionEnd');
- }
- if (s.params.autoplay && s.autoplaying) {
- if (s.params.autoplayDisableOnInteraction) {
- s.stopAutoplay();
- } else {
- s.pauseAutoplay();
- }
- }
- allowMomentumBounce = false;
- //Grab Cursor
- if (s.params.grabCursor && (s.params.allowSwipeToNext === true || s.params.allowSwipeToPrev === true)) {
- s.setGrabCursor(true);
- }
- }
- isMoved = true;
- var diff = s.touches.diff = s.isHorizontal() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY;
- diff = diff * s.params.touchRatio;
- if (s.rtl) diff = -diff;
- s.swipeDirection = diff > 0 ? 'prev' : 'next';
- currentTranslate = diff + startTranslate;
- var disableParentSwiper = true;
- if (diff > 0 && currentTranslate > s.minTranslate()) {
- disableParentSwiper = false;
- if (s.params.resistance) currentTranslate = s.minTranslate() - 1 + Math.pow(-s.minTranslate() + startTranslate + diff, s.params.resistanceRatio);
- } else if (diff < 0 && currentTranslate < s.maxTranslate()) {
- disableParentSwiper = false;
- if (s.params.resistance) currentTranslate = s.maxTranslate() + 1 - Math.pow(s.maxTranslate() - startTranslate - diff, s.params.resistanceRatio);
- }
- if (disableParentSwiper) {
- e.preventedByNestedSwiper = true;
- }
- // Directions locks
- if (!s.params.allowSwipeToNext && s.swipeDirection === 'next' && currentTranslate < startTranslate) {
- currentTranslate = startTranslate;
- }
- if (!s.params.allowSwipeToPrev && s.swipeDirection === 'prev' && currentTranslate > startTranslate) {
- currentTranslate = startTranslate;
- }
- // Threshold
- if (s.params.threshold > 0) {
- if (Math.abs(diff) > s.params.threshold || allowThresholdMove) {
- if (!allowThresholdMove) {
- allowThresholdMove = true;
- s.touches.startX = s.touches.currentX;
- s.touches.startY = s.touches.currentY;
- currentTranslate = startTranslate;
- s.touches.diff = s.isHorizontal() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY;
- return;
- }
- } else {
- currentTranslate = startTranslate;
- return;
- }
- }
- if (!s.params.followFinger) return;
- // Update active index in free mode
- if (s.params.freeMode || s.params.watchSlidesProgress) {
- s.updateActiveIndex();
- }
- if (s.params.freeMode) {
- //Velocity
- if (velocities.length === 0) {
- velocities.push({
- position: s.touches[s.isHorizontal() ? 'startX' : 'startY'],
- time: touchStartTime
- });
- }
- velocities.push({
- position: s.touches[s.isHorizontal() ? 'currentX' : 'currentY'],
- time: new window.Date().getTime()
- });
- }
- // Update progress
- s.updateProgress(currentTranslate);
- // Update translate
- s.setWrapperTranslate(currentTranslate);
- };
- s.onTouchEnd = function (e) {
- if (e.originalEvent) e = e.originalEvent;
- if (allowTouchCallbacks) {
- s.emit('onTouchEnd', s, e);
- }
- allowTouchCallbacks = false;
- if (!isTouched) return;
- //Return Grab Cursor
- if (s.params.grabCursor && isMoved && isTouched && (s.params.allowSwipeToNext === true || s.params.allowSwipeToPrev === true)) {
- s.setGrabCursor(false);
- }
- // Time diff
- var touchEndTime = Date.now();
- var timeDiff = touchEndTime - touchStartTime;
- // Tap, doubleTap, Click
- if (s.allowClick) {
- s.updateClickedSlide(e);
- s.emit('onTap', s, e);
- if (timeDiff < 300 && touchEndTime - lastClickTime > 300) {
- if (clickTimeout) clearTimeout(clickTimeout);
- clickTimeout = setTimeout(function () {
- if (!s) return;
- if (s.params.paginationHide && s.paginationContainer.length > 0 && !$(e.target).hasClass(s.params.bulletClass)) {
- s.paginationContainer.toggleClass(s.params.paginationHiddenClass);
- }
- s.emit('onClick', s, e);
- }, 300);
- }
- if (timeDiff < 300 && touchEndTime - lastClickTime < 300) {
- if (clickTimeout) clearTimeout(clickTimeout);
- s.emit('onDoubleTap', s, e);
- }
- }
- lastClickTime = Date.now();
- setTimeout(function () {
- if (s) s.allowClick = true;
- }, 0);
- if (!isTouched || !isMoved || !s.swipeDirection || s.touches.diff === 0 || currentTranslate === startTranslate) {
- isTouched = isMoved = false;
- return;
- }
- isTouched = isMoved = false;
- var currentPos;
- if (s.params.followFinger) {
- currentPos = s.rtl ? s.translate : -s.translate;
- } else {
- currentPos = -currentTranslate;
- }
- if (s.params.freeMode) {
- if (currentPos < -s.minTranslate()) {
- s.slideTo(s.activeIndex);
- return;
- } else if (currentPos > -s.maxTranslate()) {
- if (s.slides.length < s.snapGrid.length) {
- s.slideTo(s.snapGrid.length - 1);
- } else {
- s.slideTo(s.slides.length - 1);
- }
- return;
- }
- if (s.params.freeModeMomentum) {
- if (velocities.length > 1) {
- var lastMoveEvent = velocities.pop(),
- velocityEvent = velocities.pop();
- var distance = lastMoveEvent.position - velocityEvent.position;
- var time = lastMoveEvent.time - velocityEvent.time;
- s.velocity = distance / time;
- s.velocity = s.velocity / 2;
- if (Math.abs(s.velocity) < s.params.freeModeMinimumVelocity) {
- s.velocity = 0;
- }
- // this implies that the user stopped moving a finger then released.
- // There would be no events with distance zero, so the last event is stale.
- if (time > 150 || new window.Date().getTime() - lastMoveEvent.time > 300) {
- s.velocity = 0;
- }
- } else {
- s.velocity = 0;
- }
- s.velocity = s.velocity * s.params.freeModeMomentumVelocityRatio;
- velocities.length = 0;
- var momentumDuration = 1000 * s.params.freeModeMomentumRatio;
- var momentumDistance = s.velocity * momentumDuration;
- var newPosition = s.translate + momentumDistance;
- if (s.rtl) newPosition = -newPosition;
- var doBounce = false;
- var afterBouncePosition;
- var bounceAmount = Math.abs(s.velocity) * 20 * s.params.freeModeMomentumBounceRatio;
- if (newPosition < s.maxTranslate()) {
- if (s.params.freeModeMomentumBounce) {
- if (newPosition + s.maxTranslate() < -bounceAmount) {
- newPosition = s.maxTranslate() - bounceAmount;
- }
- afterBouncePosition = s.maxTranslate();
- doBounce = true;
- allowMomentumBounce = true;
- } else {
- newPosition = s.maxTranslate();
- }
- } else if (newPosition > s.minTranslate()) {
- if (s.params.freeModeMomentumBounce) {
- if (newPosition - s.minTranslate() > bounceAmount) {
- newPosition = s.minTranslate() + bounceAmount;
- }
- afterBouncePosition = s.minTranslate();
- doBounce = true;
- allowMomentumBounce = true;
- } else {
- newPosition = s.minTranslate();
- }
- } else if (s.params.freeModeSticky) {
- var j = 0,
- nextSlide;
- for (j = 0; j < s.snapGrid.length; j += 1) {
- if (s.snapGrid[j] > -newPosition) {
- nextSlide = j;
- break;
- }
- }
- if (Math.abs(s.snapGrid[nextSlide] - newPosition) < Math.abs(s.snapGrid[nextSlide - 1] - newPosition) || s.swipeDirection === 'next') {
- newPosition = s.snapGrid[nextSlide];
- } else {
- newPosition = s.snapGrid[nextSlide - 1];
- }
- if (!s.rtl) newPosition = -newPosition;
- }
- //Fix duration
- if (s.velocity !== 0) {
- if (s.rtl) {
- momentumDuration = Math.abs((-newPosition - s.translate) / s.velocity);
- } else {
- momentumDuration = Math.abs((newPosition - s.translate) / s.velocity);
- }
- } else if (s.params.freeModeSticky) {
- s.slideReset();
- return;
- }
- if (s.params.freeModeMomentumBounce && doBounce) {
- s.updateProgress(afterBouncePosition);
- s.setWrapperTransition(momentumDuration);
- s.setWrapperTranslate(newPosition);
- s.onTransitionStart();
- s.animating = true;
- s.wrapper.transitionEnd(function () {
- if (!s || !allowMomentumBounce) return;
- s.emit('onMomentumBounce', s);
- s.setWrapperTransition(s.params.speed);
- s.setWrapperTranslate(afterBouncePosition);
- s.wrapper.transitionEnd(function () {
- if (!s) return;
- s.onTransitionEnd();
- });
- });
- } else if (s.velocity) {
- s.updateProgress(newPosition);
- s.setWrapperTransition(momentumDuration);
- s.setWrapperTranslate(newPosition);
- s.onTransitionStart();
- if (!s.animating) {
- s.animating = true;
- s.wrapper.transitionEnd(function () {
- if (!s) return;
- s.onTransitionEnd();
- });
- }
- } else {
- s.updateProgress(newPosition);
- }
- s.updateActiveIndex();
- }
- if (!s.params.freeModeMomentum || timeDiff >= s.params.longSwipesMs) {
- s.updateProgress();
- s.updateActiveIndex();
- }
- return;
- }
- // Find current slide
- var i,
- stopIndex = 0,
- groupSize = s.slidesSizesGrid[0];
- for (i = 0; i < s.slidesGrid.length; i += s.params.slidesPerGroup) {
- if (typeof s.slidesGrid[i + s.params.slidesPerGroup] !== 'undefined') {
- if (currentPos >= s.slidesGrid[i] && currentPos < s.slidesGrid[i + s.params.slidesPerGroup]) {
- stopIndex = i;
- groupSize = s.slidesGrid[i + s.params.slidesPerGroup] - s.slidesGrid[i];
- }
- } else {
- if (currentPos >= s.slidesGrid[i]) {
- stopIndex = i;
- groupSize = s.slidesGrid[s.slidesGrid.length - 1] - s.slidesGrid[s.slidesGrid.length - 2];
- }
- }
- }
- // Find current slide size
- var ratio = (currentPos - s.slidesGrid[stopIndex]) / groupSize;
- if (timeDiff > s.params.longSwipesMs) {
- // Long touches
- if (!s.params.longSwipes) {
- s.slideTo(s.activeIndex);
- return;
- }
- if (s.swipeDirection === 'next') {
- if (ratio >= s.params.longSwipesRatio) s.slideTo(stopIndex + s.params.slidesPerGroup);else s.slideTo(stopIndex);
- }
- if (s.swipeDirection === 'prev') {
- if (ratio > 1 - s.params.longSwipesRatio) s.slideTo(stopIndex + s.params.slidesPerGroup);else s.slideTo(stopIndex);
- }
- } else {
- // Short swipes
- if (!s.params.shortSwipes) {
- s.slideTo(s.activeIndex);
- return;
- }
- if (s.swipeDirection === 'next') {
- s.slideTo(stopIndex + s.params.slidesPerGroup);
- }
- if (s.swipeDirection === 'prev') {
- s.slideTo(stopIndex);
- }
- }
- };
- /*=========================
- Transitions
- ===========================*/
- s._slideTo = function (slideIndex, speed) {
- return s.slideTo(slideIndex, speed, true, true);
- };
- s.slideTo = function (slideIndex, speed, runCallbacks, internal) {
- if (typeof runCallbacks === 'undefined') runCallbacks = true;
- if (typeof slideIndex === 'undefined') slideIndex = 0;
- if (slideIndex < 0) slideIndex = 0;
- s.snapIndex = Math.floor(slideIndex / s.params.slidesPerGroup);
- if (s.snapIndex >= s.snapGrid.length) s.snapIndex = s.snapGrid.length - 1;
- var translate = -s.snapGrid[s.snapIndex];
- // Stop autoplay
- if (s.params.autoplay && s.autoplaying) {
- if (internal || !s.params.autoplayDisableOnInteraction) {
- s.pauseAutoplay(speed);
- } else {
- s.stopAutoplay();
- }
- }
- // Update progress
- s.updateProgress(translate);
- // Normalize slideIndex
- if (s.params.normalizeSlideIndex) {
- for (var i = 0; i < s.slidesGrid.length; i++) {
- if (-Math.floor(translate * 100) >= Math.floor(s.slidesGrid[i] * 100)) {
- slideIndex = i;
- }
- }
- }
- // Directions locks
- if (!s.params.allowSwipeToNext && translate < s.translate && translate < s.minTranslate()) {
- return false;
- }
- if (!s.params.allowSwipeToPrev && translate > s.translate && translate > s.maxTranslate()) {
- if ((s.activeIndex || 0) !== slideIndex) return false;
- }
- // Update Index
- if (typeof speed === 'undefined') speed = s.params.speed;
- s.previousIndex = s.activeIndex || 0;
- s.activeIndex = slideIndex;
- s.updateRealIndex();
- if (s.rtl && -translate === s.translate || !s.rtl && translate === s.translate) {
- // Update Height
- if (s.params.autoHeight) {
- s.updateAutoHeight();
- }
- s.updateClasses();
- if (s.params.effect !== 'slide') {
- s.setWrapperTranslate(translate);
- }
- return false;
- }
- s.updateClasses();
- s.onTransitionStart(runCallbacks);
- if (speed === 0 || s.browser.lteIE9) {
- s.setWrapperTranslate(translate);
- s.setWrapperTransition(0);
- s.onTransitionEnd(runCallbacks);
- } else {
- s.setWrapperTranslate(translate);
- s.setWrapperTransition(speed);
- if (!s.animating) {
- s.animating = true;
- s.wrapper.transitionEnd(function () {
- if (!s) return;
- s.onTransitionEnd(runCallbacks);
- });
- }
- }
- return true;
- };
- s.onTransitionStart = function (runCallbacks) {
- if (typeof runCallbacks === 'undefined') runCallbacks = true;
- if (s.params.autoHeight) {
- s.updateAutoHeight();
- }
- if (s.lazy) s.lazy.onTransitionStart();
- if (runCallbacks) {
- s.emit('onTransitionStart', s);
- if (s.activeIndex !== s.previousIndex) {
- s.emit('onSlideChangeStart', s);
- if (s.activeIndex > s.previousIndex) {
- s.emit('onSlideNextStart', s);
- } else {
- s.emit('onSlidePrevStart', s);
- }
- }
- }
- };
- s.onTransitionEnd = function (runCallbacks) {
- s.animating = false;
- s.setWrapperTransition(0);
- if (typeof runCallbacks === 'undefined') runCallbacks = true;
- if (s.lazy) s.lazy.onTransitionEnd();
- if (runCallbacks) {
- s.emit('onTransitionEnd', s);
- if (s.activeIndex !== s.previousIndex) {
- s.emit('onSlideChangeEnd', s);
- if (s.activeIndex > s.previousIndex) {
- s.emit('onSlideNextEnd', s);
- } else {
- s.emit('onSlidePrevEnd', s);
- }
- }
- }
- if (s.params.history && s.history) {
- s.history.setHistory(s.params.history, s.activeIndex);
- }
- if (s.params.hashnav && s.hashnav) {
- s.hashnav.setHash();
- }
- };
- s.slideNext = function (runCallbacks, speed, internal) {
- if (s.params.loop) {
- if (s.animating) return false;
- s.fixLoop();
- var clientLeft = s.container[0].clientLeft;
- return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal);
- } else return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal);
- };
- s._slideNext = function (speed) {
- return s.slideNext(true, speed, true);
- };
- s.slidePrev = function (runCallbacks, speed, internal) {
- if (s.params.loop) {
- if (s.animating) return false;
- s.fixLoop();
- var clientLeft = s.container[0].clientLeft;
- return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal);
- } else return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal);
- };
- s._slidePrev = function (speed) {
- return s.slidePrev(true, speed, true);
- };
- s.slideReset = function (runCallbacks, speed, internal) {
- return s.slideTo(s.activeIndex, speed, runCallbacks);
- };
- s.disableTouchControl = function () {
- s.params.onlyExternal = true;
- return true;
- };
- s.enableTouchControl = function () {
- s.params.onlyExternal = false;
- return true;
- };
- /*=========================
- Translate/transition helpers
- ===========================*/
- s.setWrapperTransition = function (duration, byController) {
- s.wrapper.transition(duration);
- if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
- s.effects[s.params.effect].setTransition(duration);
- }
- if (s.params.parallax && s.parallax) {
- s.parallax.setTransition(duration);
- }
- if (s.params.scrollbar && s.scrollbar) {
- s.scrollbar.setTransition(duration);
- }
- if (s.params.control && s.controller) {
- s.controller.setTransition(duration, byController);
- }
- s.emit('onSetTransition', s, duration);
- };
- s.setWrapperTranslate = function (translate, updateActiveIndex, byController) {
- var x = 0,
- y = 0,
- z = 0;
- if (s.isHorizontal()) {
- x = s.rtl ? -translate : translate;
- } else {
- y = translate;
- }
- if (s.params.roundLengths) {
- x = round(x);
- y = round(y);
- }
- if (!s.params.virtualTranslate) {
- if (s.support.transforms3d) s.wrapper.transform('translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)');else s.wrapper.transform('translate(' + x + 'px, ' + y + 'px)');
- }
- s.translate = s.isHorizontal() ? x : y;
- // Check if we need to update progress
- var progress;
- var translatesDiff = s.maxTranslate() - s.minTranslate();
- if (translatesDiff === 0) {
- progress = 0;
- } else {
- progress = (translate - s.minTranslate()) / translatesDiff;
- }
- if (progress !== s.progress) {
- s.updateProgress(translate);
- }
- if (updateActiveIndex) s.updateActiveIndex();
- if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
- s.effects[s.params.effect].setTranslate(s.translate);
- }
- if (s.params.parallax && s.parallax) {
- s.parallax.setTranslate(s.translate);
- }
- if (s.params.scrollbar && s.scrollbar) {
- s.scrollbar.setTranslate(s.translate);
- }
- if (s.params.control && s.controller) {
- s.controller.setTranslate(s.translate, byController);
- }
- s.emit('onSetTranslate', s, s.translate);
- };
- s.getTranslate = function (el, axis) {
- var matrix, curTransform, curStyle, transformMatrix;
- // automatic axis detection
- if (typeof axis === 'undefined') {
- axis = 'x';
- }
- if (s.params.virtualTranslate) {
- return s.rtl ? -s.translate : s.translate;
- }
- //console.log(el)
- curStyle = window.getComputedStyle(el, null);
-
- if (window.WebKitCSSMatrix) {
- curTransform = curStyle.transform || curStyle.webkitTransform;
- if (curTransform.split(',').length > 6) {
- curTransform = curTransform.split(', ').map(function (a) {
- return a.replace(',', '.');
- }).join(', ');
- }
- // Some old versions of Webkit choke when 'none' is passed; pass
- // empty string instead in this case
- transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
- } else {
- transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
- matrix = transformMatrix.toString().split(',');
- }
- if (axis === 'x') {
- //Latest Chrome and webkits Fix
- if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
- //Crazy IE10 Matrix
- else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
- //Normal Browsers
- else curTransform = parseFloat(matrix[4]);
- }
- if (axis === 'y') {
- //Latest Chrome and webkits Fix
- if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
- //Crazy IE10 Matrix
- else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
- //Normal Browsers
- else curTransform = parseFloat(matrix[5]);
- }
- if (s.rtl && curTransform) curTransform = -curTransform;
- return curTransform || 0;
- };
- s.getWrapperTranslate = function (axis) {
- if (typeof axis === 'undefined') {
- axis = s.isHorizontal() ? 'x' : 'y';
- }
- return s.getTranslate(s.wrapper[0], axis);
- };
- /*=========================
- Observer
- ===========================*/
- s.observers = [];
- function initObserver(target, options) {
- options = options || {};
- // create an observer instance
- var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
- var observer = new ObserverFunc(function (mutations) {
- mutations.forEach(function (mutation) {
- s.onResize(true);
- s.emit('onObserverUpdate', s, mutation);
- });
- });
- observer.observe(target, {
- attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
- childList: typeof options.childList === 'undefined' ? true : options.childList,
- characterData: typeof options.characterData === 'undefined' ? true : options.characterData
- });
- s.observers.push(observer);
- }
- s.initObservers = function () {
- if (s.params.observeParents) {
- var containerParents = s.container.parents();
- for (var i = 0; i < containerParents.length; i++) {
- initObserver(containerParents[i]);
- }
- }
- // Observe container
- initObserver(s.container[0], { childList: false });
- // Observe wrapper
- initObserver(s.wrapper[0], { attributes: false });
- };
- s.disconnectObservers = function () {
- for (var i = 0; i < s.observers.length; i++) {
- s.observers[i].disconnect();
- }
- s.observers = [];
- };
- /*=========================
- Loop
- ===========================*/
- // Create looped slides
- s.createLoop = function () {
- // Remove duplicated slides
- s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
- var slides = s.wrapper.children('.' + s.params.slideClass);
- if (s.params.slidesPerView === 'auto' && !s.params.loopedSlides) s.params.loopedSlides = slides.length;
- s.loopedSlides = parseInt(s.params.loopedSlides || s.params.slidesPerView, 10);
- s.loopedSlides = s.loopedSlides + s.params.loopAdditionalSlides;
- if (s.loopedSlides > slides.length) {
- s.loopedSlides = slides.length;
- }
- var prependSlides = [],
- appendSlides = [],
- i;
- slides.each(function (index, el) {
- var slide = $(this);
- if (index < s.loopedSlides) appendSlides.push(el);
- if (index < slides.length && index >= slides.length - s.loopedSlides) prependSlides.push(el);
- slide.attr('data-swiper-slide-index', index);
- });
- for (i = 0; i < appendSlides.length; i++) {
- s.wrapper.append($(appendSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass));
- }
- for (i = prependSlides.length - 1; i >= 0; i--) {
- s.wrapper.prepend($(prependSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass));
- }
- };
- s.destroyLoop = function () {
- s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
- s.slides.removeAttr('data-swiper-slide-index');
- };
- s.reLoop = function (updatePosition) {
- var oldIndex = s.activeIndex - s.loopedSlides;
- s.destroyLoop();
- s.createLoop();
- s.updateSlidesSize();
- if (updatePosition) {
- s.slideTo(oldIndex + s.loopedSlides, 0, false);
- }
- };
- s.fixLoop = function () {
- var newIndex;
- //Fix For Negative Oversliding
- if (s.activeIndex < s.loopedSlides) {
- newIndex = s.slides.length - s.loopedSlides * 3 + s.activeIndex;
- newIndex = newIndex + s.loopedSlides;
- s.slideTo(newIndex, 0, false, true);
- }
- //Fix For Positive Oversliding
- else if (s.params.slidesPerView === 'auto' && s.activeIndex >= s.loopedSlides * 2 || s.activeIndex > s.slides.length - s.params.slidesPerView * 2) {
- newIndex = -s.slides.length + s.activeIndex + s.loopedSlides;
- newIndex = newIndex + s.loopedSlides;
- s.slideTo(newIndex, 0, false, true);
- }
- };
- /*=========================
- Append/Prepend/Remove Slides
- ===========================*/
- s.appendSlide = function (slides) {
- if (s.params.loop) {
- s.destroyLoop();
- }
- if ((typeof slides === 'undefined' ? 'undefined' : _typeof(slides)) === 'object' && slides.length) {
- for (var i = 0; i < slides.length; i++) {
- if (slides[i]) s.wrapper.append(slides[i]);
- }
- } else {
- s.wrapper.append(slides);
- }
- if (s.params.loop) {
- s.createLoop();
- }
- if (!(s.params.observer && s.support.observer)) {
- s.update(true);
- }
- };
- s.prependSlide = function (slides) {
- if (s.params.loop) {
- s.destroyLoop();
- }
- var newActiveIndex = s.activeIndex + 1;
- if ((typeof slides === 'undefined' ? 'undefined' : _typeof(slides)) === 'object' && slides.length) {
- for (var i = 0; i < slides.length; i++) {
- if (slides[i]) s.wrapper.prepend(slides[i]);
- }
- newActiveIndex = s.activeIndex + slides.length;
- } else {
- s.wrapper.prepend(slides);
- }
- if (s.params.loop) {
- s.createLoop();
- }
- if (!(s.params.observer && s.support.observer)) {
- s.update(true);
- }
- s.slideTo(newActiveIndex, 0, false);
- };
- s.removeSlide = function (slidesIndexes) {
- if (s.params.loop) {
- s.destroyLoop();
- s.slides = s.wrapper.children('.' + s.params.slideClass);
- }
- var newActiveIndex = s.activeIndex,
- indexToRemove;
- if ((typeof slidesIndexes === 'undefined' ? 'undefined' : _typeof(slidesIndexes)) === 'object' && slidesIndexes.length) {
- for (var i = 0; i < slidesIndexes.length; i++) {
- indexToRemove = slidesIndexes[i];
- if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove();
- if (indexToRemove < newActiveIndex) newActiveIndex--;
- }
- newActiveIndex = Math.max(newActiveIndex, 0);
- } else {
- indexToRemove = slidesIndexes;
- if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove();
- if (indexToRemove < newActiveIndex) newActiveIndex--;
- newActiveIndex = Math.max(newActiveIndex, 0);
- }
- if (s.params.loop) {
- s.createLoop();
- }
- if (!(s.params.observer && s.support.observer)) {
- s.update(true);
- }
- if (s.params.loop) {
- s.slideTo(newActiveIndex + s.loopedSlides, 0, false);
- } else {
- s.slideTo(newActiveIndex, 0, false);
- }
- };
- s.removeAllSlides = function () {
- var slidesIndexes = [];
- for (var i = 0; i < s.slides.length; i++) {
- slidesIndexes.push(i);
- }
- s.removeSlide(slidesIndexes);
- };
- /*=========================
- Effects
- ===========================*/
- s.effects = {
- fade: {
- setTranslate: function setTranslate() {
- for (var i = 0; i < s.slides.length; i++) {
- var slide = s.slides.eq(i);
- var offset = slide[0].swiperSlideOffset;
- var tx = -offset;
- if (!s.params.virtualTranslate) tx = tx - s.translate;
- var ty = 0;
- if (!s.isHorizontal()) {
- ty = tx;
- tx = 0;
- }
- var slideOpacity = s.params.fade.crossFade ? Math.max(1 - Math.abs(slide[0].progress), 0) : 1 + Math.min(Math.max(slide[0].progress, -1), 0);
- slide.css({
- opacity: slideOpacity
- }).transform('translate3d(' + tx + 'px, ' + ty + 'px, 0px)');
- }
- },
- setTransition: function setTransition(duration) {
- s.slides.transition(duration);
- if (s.params.virtualTranslate && duration !== 0) {
- var eventTriggered = false;
- s.slides.transitionEnd(function () {
- if (eventTriggered) return;
- if (!s) return;
- eventTriggered = true;
- s.animating = false;
- var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'];
- for (var i = 0; i < triggerEvents.length; i++) {
- s.wrapper.trigger(triggerEvents[i]);
- }
- });
- }
- }
- },
- flip: {
- setTranslate: function setTranslate() {
- for (var i = 0; i < s.slides.length; i++) {
- var slide = s.slides.eq(i);
- var progress = slide[0].progress;
- if (s.params.flip.limitRotation) {
- progress = Math.max(Math.min(slide[0].progress, 1), -1);
- }
- var offset = slide[0].swiperSlideOffset;
- var rotate = -180 * progress,
- rotateY = rotate,
- rotateX = 0,
- tx = -offset,
- ty = 0;
- if (!s.isHorizontal()) {
- ty = tx;
- tx = 0;
- rotateX = -rotateY;
- rotateY = 0;
- } else if (s.rtl) {
- rotateY = -rotateY;
- }
- slide[0].style.zIndex = -Math.abs(Math.round(progress)) + s.slides.length;
- if (s.params.flip.slideShadows) {
- //Set shadows
- var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
- var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
- if (shadowBefore.length === 0) {
- shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
- slide.append(shadowBefore);
- }
- if (shadowAfter.length === 0) {
- shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
- slide.append(shadowAfter);
- }
- if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
- if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
- }
- slide.transform('translate3d(' + tx + 'px, ' + ty + 'px, 0px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)');
- }
- },
- setTransition: function setTransition(duration) {
- s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
- if (s.params.virtualTranslate && duration !== 0) {
- var eventTriggered = false;
- s.slides.eq(s.activeIndex).transitionEnd(function () {
- if (eventTriggered) return;
- if (!s) return;
- if (!$(this).hasClass(s.params.slideActiveClass)) return;
- eventTriggered = true;
- s.animating = false;
- var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'];
- for (var i = 0; i < triggerEvents.length; i++) {
- s.wrapper.trigger(triggerEvents[i]);
- }
- });
- }
- }
- },
- cube: {
- setTranslate: function setTranslate() {
- var wrapperRotate = 0,
- cubeShadow;
- if (s.params.cube.shadow) {
- if (s.isHorizontal()) {
- cubeShadow = s.wrapper.find('.swiper-cube-shadow');
- if (cubeShadow.length === 0) {
- cubeShadow = $('<div class="swiper-cube-shadow"></div>');
- s.wrapper.append(cubeShadow);
- }
- cubeShadow.css({ height: s.width + 'px' });
- } else {
- cubeShadow = s.container.find('.swiper-cube-shadow');
- if (cubeShadow.length === 0) {
- cubeShadow = $('<div class="swiper-cube-shadow"></div>');
- s.container.append(cubeShadow);
- }
- }
- }
- for (var i = 0; i < s.slides.length; i++) {
- var slide = s.slides.eq(i);
- var slideAngle = i * 90;
- var round = Math.floor(slideAngle / 360);
- if (s.rtl) {
- slideAngle = -slideAngle;
- round = Math.floor(-slideAngle / 360);
- }
- var progress = Math.max(Math.min(slide[0].progress, 1), -1);
- var tx = 0,
- ty = 0,
- tz = 0;
- if (i % 4 === 0) {
- tx = -round * 4 * s.size;
- tz = 0;
- } else if ((i - 1) % 4 === 0) {
- tx = 0;
- tz = -round * 4 * s.size;
- } else if ((i - 2) % 4 === 0) {
- tx = s.size + round * 4 * s.size;
- tz = s.size;
- } else if ((i - 3) % 4 === 0) {
- tx = -s.size;
- tz = 3 * s.size + s.size * 4 * round;
- }
- if (s.rtl) {
- tx = -tx;
- }
- if (!s.isHorizontal()) {
- ty = tx;
- tx = 0;
- }
- var transform = 'rotateX(' + (s.isHorizontal() ? 0 : -slideAngle) + 'deg) rotateY(' + (s.isHorizontal() ? slideAngle : 0) + 'deg) translate3d(' + tx + 'px, ' + ty + 'px, ' + tz + 'px)';
- if (progress <= 1 && progress > -1) {
- wrapperRotate = i * 90 + progress * 90;
- if (s.rtl) wrapperRotate = -i * 90 - progress * 90;
- }
- slide.transform(transform);
- if (s.params.cube.slideShadows) {
- //Set shadows
- var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
- var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
- if (shadowBefore.length === 0) {
- shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
- slide.append(shadowBefore);
- }
- if (shadowAfter.length === 0) {
- shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
- slide.append(shadowAfter);
- }
- if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
- if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
- }
- }
- s.wrapper.css({
- '-webkit-transform-origin': '50% 50% -' + s.size / 2 + 'px',
- '-moz-transform-origin': '50% 50% -' + s.size / 2 + 'px',
- '-ms-transform-origin': '50% 50% -' + s.size / 2 + 'px',
- 'transform-origin': '50% 50% -' + s.size / 2 + 'px'
- });
- if (s.params.cube.shadow) {
- if (s.isHorizontal()) {
- cubeShadow.transform('translate3d(0px, ' + (s.width / 2 + s.params.cube.shadowOffset) + 'px, ' + -s.width / 2 + 'px) rotateX(90deg) rotateZ(0deg) scale(' + s.params.cube.shadowScale + ')');
- } else {
- var shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
- var multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
- var scale1 = s.params.cube.shadowScale,
- scale2 = s.params.cube.shadowScale / multiplier,
- offset = s.params.cube.shadowOffset;
- cubeShadow.transform('scale3d(' + scale1 + ', 1, ' + scale2 + ') translate3d(0px, ' + (s.height / 2 + offset) + 'px, ' + -s.height / 2 / scale2 + 'px) rotateX(-90deg)');
- }
- }
- var zFactor = s.isSafari || s.isUiWebView ? -s.size / 2 : 0;
- s.wrapper.transform('translate3d(0px,0,' + zFactor + 'px) rotateX(' + (s.isHorizontal() ? 0 : wrapperRotate) + 'deg) rotateY(' + (s.isHorizontal() ? -wrapperRotate : 0) + 'deg)');
- },
- setTransition: function setTransition(duration) {
- s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
- if (s.params.cube.shadow && !s.isHorizontal()) {
- s.container.find('.swiper-cube-shadow').transition(duration);
- }
- }
- },
- coverflow: {
- setTranslate: function setTranslate() {
- var transform = s.translate;
- var center = s.isHorizontal() ? -transform + s.width / 2 : -transform + s.height / 2;
- var rotate = s.isHorizontal() ? s.params.coverflow.rotate : -s.params.coverflow.rotate;
- var translate = s.params.coverflow.depth;
- //Each slide offset from center
- for (var i = 0, length = s.slides.length; i < length; i++) {
- var slide = s.slides.eq(i);
- var slideSize = s.slidesSizesGrid[i];
- var slideOffset = slide[0].swiperSlideOffset;
- var offsetMultiplier = (center - slideOffset - slideSize / 2) / slideSize * s.params.coverflow.modifier;
- var rotateY = s.isHorizontal() ? rotate * offsetMultiplier : 0;
- var rotateX = s.isHorizontal() ? 0 : rotate * offsetMultiplier;
- // var rotateZ = 0
- var translateZ = -translate * Math.abs(offsetMultiplier);
- var translateY = s.isHorizontal() ? 0 : s.params.coverflow.stretch * offsetMultiplier;
- var translateX = s.isHorizontal() ? s.params.coverflow.stretch * offsetMultiplier : 0;
- //Fix for ultra small values
- if (Math.abs(translateX) < 0.001) translateX = 0;
- if (Math.abs(translateY) < 0.001) translateY = 0;
- if (Math.abs(translateZ) < 0.001) translateZ = 0;
- if (Math.abs(rotateY) < 0.001) rotateY = 0;
- if (Math.abs(rotateX) < 0.001) rotateX = 0;
- var slideTransform = 'translate3d(' + translateX + 'px,' + translateY + 'px,' + translateZ + 'px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)';
- slide.transform(slideTransform);
- slide[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
- if (s.params.coverflow.slideShadows) {
- //Set shadows
- var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
- var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
- if (shadowBefore.length === 0) {
- shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
- slide.append(shadowBefore);
- }
- if (shadowAfter.length === 0) {
- shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
- slide.append(shadowAfter);
- }
- if (shadowBefore.length) shadowBefore[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
- if (shadowAfter.length) shadowAfter[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0;
- }
- }
- //Set correct perspective for IE10
- if (s.browser.ie) {
- var ws = s.wrapper[0].style;
- ws.perspectiveOrigin = center + 'px 50%';
- }
- },
- setTransition: function setTransition(duration) {
- s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
- }
- }
- };
- /*=========================
- Images Lazy Loading
- ===========================*/
- s.lazy = {
- initialImageLoaded: false,
- loadImageInSlide: function loadImageInSlide(index, loadInDuplicate) {
- if (typeof index === 'undefined') return;
- if (typeof loadInDuplicate === 'undefined') loadInDuplicate = true;
- if (s.slides.length === 0) return;
- var slide = s.slides.eq(index);
- var img = slide.find('.' + s.params.lazyLoadingClass + ':not(.' + s.params.lazyStatusLoadedClass + '):not(.' + s.params.lazyStatusLoadingClass + ')');
- if (slide.hasClass(s.params.lazyLoadingClass) && !slide.hasClass(s.params.lazyStatusLoadedClass) && !slide.hasClass(s.params.lazyStatusLoadingClass)) {
- img = img.add(slide[0]);
- }
- if (img.length === 0) return;
- img.each(function () {
- var _img = $(this);
- _img.addClass(s.params.lazyStatusLoadingClass);
- var background = _img.attr('data-background');
- var src = _img.attr('data-src'),
- srcset = _img.attr('data-srcset'),
- sizes = _img.attr('data-sizes');
- s.loadImage(_img[0], src || background, srcset, sizes, false, function () {
- if (typeof s === 'undefined' || s === null || !s) return;
- if (background) {
- _img.css('background-image', 'url("' + background + '")');
- _img.removeAttr('data-background');
- } else {
- if (srcset) {
- _img.attr('srcset', srcset);
- _img.removeAttr('data-srcset');
- }
- if (sizes) {
- _img.attr('sizes', sizes);
- _img.removeAttr('data-sizes');
- }
- if (src) {
- _img.attr('src', src);
- _img.removeAttr('data-src');
- }
- }
- _img.addClass(s.params.lazyStatusLoadedClass).removeClass(s.params.lazyStatusLoadingClass);
- slide.find('.' + s.params.lazyPreloaderClass + ', .' + s.params.preloaderClass).remove();
- if (s.params.loop && loadInDuplicate) {
- var slideOriginalIndex = slide.attr('data-swiper-slide-index');
- if (slide.hasClass(s.params.slideDuplicateClass)) {
- var originalSlide = s.wrapper.children('[data-swiper-slide-index="' + slideOriginalIndex + '"]:not(.' + s.params.slideDuplicateClass + ')');
- s.lazy.loadImageInSlide(originalSlide.index(), false);
- } else {
- var duplicatedSlide = s.wrapper.children('.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + slideOriginalIndex + '"]');
- s.lazy.loadImageInSlide(duplicatedSlide.index(), false);
- }
- }
- s.emit('onLazyImageReady', s, slide[0], _img[0]);
- });
- s.emit('onLazyImageLoad', s, slide[0], _img[0]);
- });
- },
- load: function load() {
- var i;
- var slidesPerView = s.params.slidesPerView;
- if (slidesPerView === 'auto') {
- slidesPerView = 0;
- }
- if (!s.lazy.initialImageLoaded) s.lazy.initialImageLoaded = true;
- if (s.params.watchSlidesVisibility) {
- s.wrapper.children('.' + s.params.slideVisibleClass).each(function () {
- s.lazy.loadImageInSlide($(this).index());
- });
- } else {
- if (slidesPerView > 1) {
- for (i = s.activeIndex; i < s.activeIndex + slidesPerView; i++) {
- if (s.slides[i]) s.lazy.loadImageInSlide(i);
- }
- } else {
- s.lazy.loadImageInSlide(s.activeIndex);
- }
- }
- if (s.params.lazyLoadingInPrevNext) {
- if (slidesPerView > 1 || s.params.lazyLoadingInPrevNextAmount && s.params.lazyLoadingInPrevNextAmount > 1) {
- var amount = s.params.lazyLoadingInPrevNextAmount;
- var spv = slidesPerView;
- var maxIndex = Math.min(s.activeIndex + spv + Math.max(amount, spv), s.slides.length);
- var minIndex = Math.max(s.activeIndex - Math.max(spv, amount), 0);
- // Next Slides
- for (i = s.activeIndex + slidesPerView; i < maxIndex; i++) {
- if (s.slides[i]) s.lazy.loadImageInSlide(i);
- }
- // Prev Slides
- for (i = minIndex; i < s.activeIndex; i++) {
- if (s.slides[i]) s.lazy.loadImageInSlide(i);
- }
- } else {
- var nextSlide = s.wrapper.children('.' + s.params.slideNextClass);
- if (nextSlide.length > 0) s.lazy.loadImageInSlide(nextSlide.index());
- var prevSlide = s.wrapper.children('.' + s.params.slidePrevClass);
- if (prevSlide.length > 0) s.lazy.loadImageInSlide(prevSlide.index());
- }
- }
- },
- onTransitionStart: function onTransitionStart() {
- if (s.params.lazyLoading) {
- if (s.params.lazyLoadingOnTransitionStart || !s.params.lazyLoadingOnTransitionStart && !s.lazy.initialImageLoaded) {
- s.lazy.load();
- }
- }
- },
- onTransitionEnd: function onTransitionEnd() {
- if (s.params.lazyLoading && !s.params.lazyLoadingOnTransitionStart) {
- s.lazy.load();
- }
- }
- };
- /*=========================
- Scrollbar
- ===========================*/
- s.scrollbar = {
- isTouched: false,
- setDragPosition: function setDragPosition(e) {
- var sb = s.scrollbar;
- var x = 0,
- y = 0;
- var translate;
- var pointerPosition = s.isHorizontal() ? e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX || e.clientX : e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY || e.clientY;
- var position = pointerPosition - sb.track.offset()[s.isHorizontal() ? 'left' : 'top'] - sb.dragSize / 2;
- var positionMin = -s.minTranslate() * sb.moveDivider;
- var positionMax = -s.maxTranslate() * sb.moveDivider;
- if (position < positionMin) {
- position = positionMin;
- } else if (position > positionMax) {
- position = positionMax;
- }
- position = -position / sb.moveDivider;
- s.updateProgress(position);
- s.setWrapperTranslate(position, true);
- },
- dragStart: function dragStart(e) {
- var sb = s.scrollbar;
- sb.isTouched = true;
- e.preventDefault();
- e.stopPropagation();
- sb.setDragPosition(e);
- clearTimeout(sb.dragTimeout);
- sb.track.transition(0);
- if (s.params.scrollbarHide) {
- sb.track.css('opacity', 1);
- }
- s.wrapper.transition(100);
- sb.drag.transition(100);
- s.emit('onScrollbarDragStart', s);
- },
- dragMove: function dragMove(e) {
- var sb = s.scrollbar;
- if (!sb.isTouched) return;
- if (e.preventDefault) e.preventDefault();else e.returnValue = false;
- sb.setDragPosition(e);
- s.wrapper.transition(0);
- sb.track.transition(0);
- sb.drag.transition(0);
- s.emit('onScrollbarDragMove', s);
- },
- dragEnd: function dragEnd(e) {
- var sb = s.scrollbar;
- if (!sb.isTouched) return;
- sb.isTouched = false;
- if (s.params.scrollbarHide) {
- clearTimeout(sb.dragTimeout);
- sb.dragTimeout = setTimeout(function () {
- sb.track.css('opacity', 0);
- sb.track.transition(400);
- }, 1000);
- }
- s.emit('onScrollbarDragEnd', s);
- if (s.params.scrollbarSnapOnRelease) {
- s.slideReset();
- }
- },
- draggableEvents: function () {
- if (s.params.simulateTouch === false && !s.support.touch) return s.touchEventsDesktop;else return s.touchEvents;
- }(),
- enableDraggable: function enableDraggable() {
- var sb = s.scrollbar;
- var target = s.support.touch ? sb.track : document;
- $(sb.track).on(sb.draggableEvents.start, sb.dragStart);
- $(target).on(sb.draggableEvents.move, sb.dragMove);
- $(target).on(sb.draggableEvents.end, sb.dragEnd);
- },
- disableDraggable: function disableDraggable() {
- var sb = s.scrollbar;
- var target = s.support.touch ? sb.track : document;
- $(sb.track).off(sb.draggableEvents.start, sb.dragStart);
- $(target).off(sb.draggableEvents.move, sb.dragMove);
- $(target).off(sb.draggableEvents.end, sb.dragEnd);
- },
- set: function set() {
- if (!s.params.scrollbar) return;
- var sb = s.scrollbar;
- sb.track = $(s.params.scrollbar);
- if (s.params.uniqueNavElements && typeof s.params.scrollbar === 'string' && sb.track.length > 1 && s.container.find(s.params.scrollbar).length === 1) {
- sb.track = s.container.find(s.params.scrollbar);
- }
- sb.drag = sb.track.find('.swiper-scrollbar-drag');
- if (sb.drag.length === 0) {
- sb.drag = $('<div class="swiper-scrollbar-drag"></div>');
- sb.track.append(sb.drag);
- }
- sb.drag[0].style.width = '';
- sb.drag[0].style.height = '';
- sb.trackSize = s.isHorizontal() ? sb.track[0].offsetWidth : sb.track[0].offsetHeight;
- sb.divider = s.size / s.virtualSize;
- sb.moveDivider = sb.divider * (sb.trackSize / s.size);
- sb.dragSize = sb.trackSize * sb.divider;
- if (s.isHorizontal()) {
- sb.drag[0].style.width = sb.dragSize + 'px';
- } else {
- sb.drag[0].style.height = sb.dragSize + 'px';
- }
- if (sb.divider >= 1) {
- sb.track[0].style.display = 'none';
- } else {
- sb.track[0].style.display = '';
- }
- if (s.params.scrollbarHide) {
- sb.track[0].style.opacity = 0;
- }
- },
- setTranslate: function setTranslate() {
- if (!s.params.scrollbar) return;
- var diff;
- var sb = s.scrollbar;
- var translate = s.translate || 0;
- var newPos;
- var newSize = sb.dragSize;
- newPos = (sb.trackSize - sb.dragSize) * s.progress;
- if (s.rtl && s.isHorizontal()) {
- newPos = -newPos;
- if (newPos > 0) {
- newSize = sb.dragSize - newPos;
- newPos = 0;
- } else if (-newPos + sb.dragSize > sb.trackSize) {
- newSize = sb.trackSize + newPos;
- }
- } else {
- if (newPos < 0) {
- newSize = sb.dragSize + newPos;
- newPos = 0;
- } else if (newPos + sb.dragSize > sb.trackSize) {
- newSize = sb.trackSize - newPos;
- }
- }
- if (s.isHorizontal()) {
- if (s.support.transforms3d) {
- sb.drag.transform('translate3d(' + newPos + 'px, 0, 0)');
- } else {
- sb.drag.transform('translateX(' + newPos + 'px)');
- }
- sb.drag[0].style.width = newSize + 'px';
- } else {
- if (s.support.transforms3d) {
- sb.drag.transform('translate3d(0px, ' + newPos + 'px, 0)');
- } else {
- sb.drag.transform('translateY(' + newPos + 'px)');
- }
- sb.drag[0].style.height = newSize + 'px';
- }
- if (s.params.scrollbarHide) {
- clearTimeout(sb.timeout);
- sb.track[0].style.opacity = 1;
- sb.timeout = setTimeout(function () {
- sb.track[0].style.opacity = 0;
- sb.track.transition(400);
- }, 1000);
- }
- },
- setTransition: function setTransition(duration) {
- if (!s.params.scrollbar) return;
- s.scrollbar.drag.transition(duration);
- }
- };
- /*=========================
- Controller
- ===========================*/
- s.controller = {
- LinearSpline: function LinearSpline(x, y) {
- var binarySearch = function () {
- var maxIndex, minIndex, guess;
- return function (array, val) {
- minIndex = -1;
- maxIndex = array.length;
- while (maxIndex - minIndex > 1) {
- if (array[guess = maxIndex + minIndex >> 1] <= val) {
- minIndex = guess;
- } else {
- maxIndex = guess;
- }
- }return maxIndex;
- };
- }();
- this.x = x;
- this.y = y;
- this.lastIndex = x.length - 1;
- // Given an x value (x2), return the expected y2 value:
- // (x1,y1) is the known point before given value,
- // (x3,y3) is the known point after given value.
- var i1, i3;
- var l = this.x.length;
- this.interpolate = function (x2) {
- if (!x2) return 0;
- // Get the indexes of x1 and x3 (the array indexes before and after given x2):
- i3 = binarySearch(this.x, x2);
- i1 = i3 - 1;
- // We have our indexes i1 & i3, so we can calculate already:
- // y2 := ((x2�x1) × (y3�y1)) ÷ (x3�x1) + y1
- return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1];
- };
- },
- //xxx: for now i will just save one spline function to to
- getInterpolateFunction: function getInterpolateFunction(c) {
- if (!s.controller.spline) s.controller.spline = s.params.loop ? new s.controller.LinearSpline(s.slidesGrid, c.slidesGrid) : new s.controller.LinearSpline(s.snapGrid, c.snapGrid);
- },
- setTranslate: function setTranslate(translate, byController) {
- var controlled = s.params.control;
- var multiplier, controlledTranslate;
- function setControlledTranslate(c) {
- // this will create an Interpolate function based on the snapGrids
- // x is the Grid of the scrolled scroller and y will be the controlled scroller
- // it makes sense to create this only once and recall it for the interpolation
- // the function does a lot of value caching for performance
- translate = c.rtl && c.params.direction === 'horizontal' ? -s.translate : s.translate;
- if (s.params.controlBy === 'slide') {
- s.controller.getInterpolateFunction(c);
- // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
- // but it did not work out
- controlledTranslate = -s.controller.spline.interpolate(-translate);
- }
- console.log('3402', s.params.controlBy);
- if (!controlledTranslate || s.params.controlBy === 'container') {
- multiplier = (c.maxTranslate() - c.minTranslate()) / (s.maxTranslate() - s.minTranslate());
- controlledTranslate = (translate - s.minTranslate()) * multiplier + c.minTranslate();
- }
- if (s.params.controlInverse) {
- controlledTranslate = c.maxTranslate() - controlledTranslate;
- }
- c.updateProgress(controlledTranslate);
- c.setWrapperTranslate(controlledTranslate, false, s);
- c.updateActiveIndex();
- }
- if (Array.isArray(controlled)) {
- for (var i = 0; i < controlled.length; i++) {
- if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
- setControlledTranslate(controlled[i]);
- }
- }
- } else if (controlled instanceof Swiper && byController !== controlled) {
- setControlledTranslate(controlled);
- }
- },
- setTransition: function setTransition(duration, byController) {
- var controlled = s.params.control;
- var i;
- function setControlledTransition(c) {
- c.setWrapperTransition(duration, s);
- if (duration !== 0) {
- c.onTransitionStart();
- c.wrapper.transitionEnd(function () {
- if (!controlled) return;
- if (c.params.loop && s.params.controlBy === 'slide') {
- c.fixLoop();
- }
- c.onTransitionEnd();
- });
- }
- }
- if (Array.isArray(controlled)) {
- for (i = 0; i < controlled.length; i++) {
- if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
- setControlledTransition(controlled[i]);
- }
- }
- } else if (controlled instanceof Swiper && byController !== controlled) {
- setControlledTransition(controlled);
- }
- }
- };
- /*=========================
- Hash Navigation
- ===========================*/
- s.hashnav = {
- onHashCange: function onHashCange(e, a) {
- var newHash = document.location.hash.replace('#', '');
- var activeSlideHash = s.slides.eq(s.activeIndex).attr('data-hash');
- if (newHash !== activeSlideHash) {
- s.slideTo(s.wrapper.children('.' + s.params.slideClass + '[data-hash="' + newHash + '"]').index());
- }
- },
- attachEvents: function attachEvents(detach) {
- var action = detach ? 'off' : 'on';
- $(window)[action]('hashchange', s.hashnav.onHashCange);
- },
- setHash: function setHash() {
- if (!s.hashnav.initialized || !s.params.hashnav) return;
- if (s.params.replaceState && window.history && window.history.replaceState) {
- window.history.replaceState(null, null, '#' + s.slides.eq(s.activeIndex).attr('data-hash') || '');
- } else {
- var slide = s.slides.eq(s.activeIndex);
- var hash = slide.attr('data-hash') || slide.attr('data-history');
- document.location.hash = hash || '';
- }
- },
- init: function init() {
- if (!s.params.hashnav || s.params.history) return;
- s.hashnav.initialized = true;
- var hash = document.location.hash.replace('#', '');
- if (hash) {
- var speed = 0;
- for (var i = 0, length = s.slides.length; i < length; i++) {
- var slide = s.slides.eq(i);
- var slideHash = slide.attr('data-hash') || slide.attr('data-history');
- if (slideHash === hash && !slide.hasClass(s.params.slideDuplicateClass)) {
- var index = slide.index();
- s.slideTo(index, speed, s.params.runCallbacksOnInit, true);
- }
- }
- }
- if (s.params.hashnavWatchState) s.hashnav.attachEvents();
- },
- destroy: function destroy() {
- if (s.params.hashnavWatchState) s.hashnav.attachEvents(true);
- }
- };
- /*=========================
- History Api with fallback to Hashnav
- ===========================*/
- s.history = {
- init: function init() {
- if (!s.params.history) return;
- if (!window.history || !window.history.pushState) {
- s.params.history = false;
- s.params.hashnav = true;
- return;
- }
- s.history.initialized = true;
- this.paths = this.getPathValues();
- if (!this.paths.key && !this.paths.value) return;
- this.scrollToSlide(0, this.paths.value, s.params.runCallbacksOnInit);
- if (!s.params.replaceState) {
- window.addEventListener('popstate', this.setHistoryPopState);
- }
- },
- setHistoryPopState: function setHistoryPopState() {
- s.history.paths = s.history.getPathValues();
- s.history.scrollToSlide(s.params.speed, s.history.paths.value, false);
- },
- getPathValues: function getPathValues() {
- var pathArray = window.location.pathname.slice(1).split('/');
- var total = pathArray.length;
- var key = pathArray[total - 2];
- var value = pathArray[total - 1];
- return { key: key, value: value };
- },
- setHistory: function setHistory(key, index) {
- if (!s.history.initialized || !s.params.history) return;
- var slide = s.slides.eq(index);
- var value = this.slugify(slide.attr('data-history'));
- if (!window.location.pathname.includes(key)) {
- value = key + '/' + value;
- }
- if (s.params.replaceState) {
- window.history.replaceState(null, null, value);
- } else {
- window.history.pushState(null, null, value);
- }
- },
- slugify: function slugify(text) {
- return text.toString().toLowerCase().replace(/\s+/g, '-').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
- },
- scrollToSlide: function scrollToSlide(speed, value, runCallbacks) {
- if (value) {
- for (var i = 0, length = s.slides.length; i < length; i++) {
- var slide = s.slides.eq(i);
- var slideHistory = this.slugify(slide.attr('data-history'));
- if (slideHistory === value && !slide.hasClass(s.params.slideDuplicateClass)) {
- var index = slide.index();
- s.slideTo(index, speed, runCallbacks);
- }
- }
- } else {
- s.slideTo(0, speed, runCallbacks);
- }
- }
- };
- /*=========================
- Keyboard Control
- ===========================*/
- function handleKeyboard(e) {
- if (e.originalEvent) e = e.originalEvent; //jquery fix
- var kc = e.keyCode || e.charCode;
- // Directions locks
- if (!s.params.allowSwipeToNext && (s.isHorizontal() && kc === 39 || !s.isHorizontal() && kc === 40)) {
- return false;
- }
- if (!s.params.allowSwipeToPrev && (s.isHorizontal() && kc === 37 || !s.isHorizontal() && kc === 38)) {
- return false;
- }
- if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
- return;
- }
- if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
- return;
- }
- if (kc === 37 || kc === 39 || kc === 38 || kc === 40) {
- var inView = false;
- //Check that swiper should be inside of visible area of window
- if (s.container.parents('.' + s.params.slideClass).length > 0 && s.container.parents('.' + s.params.slideActiveClass).length === 0) {
- return;
- }
- var windowScroll = {
- left: window.pageXOffset,
- top: window.pageYOffset
- };
- var windowWidth = window.innerWidth;
- var windowHeight = window.innerHeight;
- var swiperOffset = s.container.offset();
- if (s.rtl) swiperOffset.left = swiperOffset.left - s.container[0].scrollLeft;
- var swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + s.width, swiperOffset.top], [swiperOffset.left, swiperOffset.top + s.height], [swiperOffset.left + s.width, swiperOffset.top + s.height]];
- for (var i = 0; i < swiperCoord.length; i++) {
- var point = swiperCoord[i];
- if (point[0] >= windowScroll.left && point[0] <= windowScroll.left + windowWidth && point[1] >= windowScroll.top && point[1] <= windowScroll.top + windowHeight) {
- inView = true;
- }
- }
- if (!inView) return;
- }
- if (s.isHorizontal()) {
- if (kc === 37 || kc === 39) {
- if (e.preventDefault) e.preventDefault();else e.returnValue = false;
- }
- if (kc === 39 && !s.rtl || kc === 37 && s.rtl) s.slideNext();
- if (kc === 37 && !s.rtl || kc === 39 && s.rtl) s.slidePrev();
- } else {
- if (kc === 38 || kc === 40) {
- if (e.preventDefault) e.preventDefault();else e.returnValue = false;
- }
- if (kc === 40) s.slideNext();
- if (kc === 38) s.slidePrev();
- }
- s.emit('onKeyPress', s, kc);
- }
- s.disableKeyboardControl = function () {
- s.params.keyboardControl = false;
- $(document).off('keydown', handleKeyboard);
- };
- s.enableKeyboardControl = function () {
- s.params.keyboardControl = true;
- $(document).on('keydown', handleKeyboard);
- };
- /*=========================
- Mousewheel Control
- ===========================*/
- s.mousewheel = {
- event: false,
- lastScrollTime: new window.Date().getTime()
- };
- function isEventSupported() {
- var eventName = 'onwheel';
- var isSupported = eventName in document;
- if (!isSupported) {
- var element = document.createElement('div');
- element.setAttribute(eventName, 'return;');
- isSupported = typeof element[eventName] === 'function';
- }
- if (!isSupported && document.implementation && document.implementation.hasFeature &&
- // always returns true in newer browsers as per the standard.
- // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
- document.implementation.hasFeature('', '') !== true) {
- // This is the only way to test support for the `wheel` event in IE9+.
- isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
- }
- return isSupported;
- }
- /**
- * Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
- * complicated, thus this doc is long and (hopefully) detailed enough to answer
- * your questions.
- *
- * If you need to react to the mouse wheel in a predictable way, this code is
- * like your bestest friend. * hugs *
- *
- * As of today, there are 4 DOM event types you can listen to:
- *
- * 'wheel' -- Chrome(31+), FF(17+), IE(9+)
- * 'mousewheel' -- Chrome, IE(6+), Opera, Safari
- * 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
- * 'DOMMouseScroll' -- FF(0.9.7+) since 2003
- *
- * So what to do? The is the best:
- *
- * normalizeWheel.getEventType();
- *
- * In your event callback, use this code to get sane interpretation of the
- * deltas. This code will return an object with properties:
- *
- * spinX -- normalized spin speed (use for zoom) - x plane
- * spinY -- " - y plane
- * pixelX -- normalized distance (to pixels) - x plane
- * pixelY -- " - y plane
- *
- * Wheel values are provided by the browser assuming you are using the wheel to
- * scroll a web page by a number of lines or pixels (or pages). Values can vary
- * significantly on different platforms and browsers, forgetting that you can
- * scroll at different speeds. Some devices (like trackpads) emit more events
- * at smaller increments with fine granularity, and some emit massive jumps with
- * linear speed or acceleration.
- *
- * This code does its best to normalize the deltas for you:
- *
- * - spin is trying to normalize how far the wheel was spun (or trackpad
- * dragged). This is super useful for zoom support where you want to
- * throw away the chunky scroll steps on the PC and make those equal to
- * the slow and smooth tiny steps on the Mac. Key data: This code tries to
- * resolve a single slow step on a wheel to 1.
- *
- * - pixel is normalizing the desired scroll delta in pixel units. You'll
- * get the crazy differences between browsers, but at least it'll be in
- * pixels!
- *
- * - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
- * should translate to positive value zooming IN, negative zooming OUT.
- * This matches the newer 'wheel' event.
- *
- * Why are there spinX, spinY (or pixels)?
- *
- * - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
- * with a mouse. It results in side-scrolling in the browser by default.
- *
- * - spinY is what you expect -- it's the classic axis of a mouse wheel.
- *
- * - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
- * probably is by browsers in conjunction with fancy 3D controllers .. but
- * you know.
- *
- * Implementation info:
- *
- * Examples of 'wheel' event if you scroll slowly (down) by one step with an
- * average mouse:
- *
- * OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
- * OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
- * OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
- * Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
- * Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
- *
- * On the trackpad:
- *
- * OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
- * OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
- *
- * On other/older browsers.. it's more complicated as there can be multiple and
- * also missing delta values.
- *
- * The 'wheel' event is more standard:
- *
- * http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
- *
- * The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
- * deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
- * backward compatibility with older events. Those other values help us
- * better normalize spin speed. Example of what the browsers provide:
- *
- * | event.wheelDelta | event.detail
- * ------------------+------------------+--------------
- * Safari v5/OS X | -120 | 0
- * Safari v5/Win7 | -120 | 0
- * Chrome v17/OS X | -120 | 0
- * Chrome v17/Win7 | -120 | 0
- * IE9/Win7 | -120 | undefined
- * Firefox v4/OS X | undefined | 1
- * Firefox v4/Win7 | undefined | 3
- *
- */
- function normalizeWheel( /*object*/event) /*object*/{
- // Reasonable defaults
- var PIXEL_STEP = 10;
- var LINE_HEIGHT = 40;
- var PAGE_HEIGHT = 800;
- var sX = 0,
- sY = 0,
- // spinX, spinY
- pX = 0,
- pY = 0; // pixelX, pixelY
- // Legacy
- if ('detail' in event) {
- sY = event.detail;
- }
- if ('wheelDelta' in event) {
- sY = -event.wheelDelta / 120;
- }
- if ('wheelDeltaY' in event) {
- sY = -event.wheelDeltaY / 120;
- }
- if ('wheelDeltaX' in event) {
- sX = -event.wheelDeltaX / 120;
- }
- // side scrolling on FF with DOMMouseScroll
- if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {
- sX = sY;
- sY = 0;
- }
- pX = sX * PIXEL_STEP;
- pY = sY * PIXEL_STEP;
- if ('deltaY' in event) {
- pY = event.deltaY;
- }
- if ('deltaX' in event) {
- pX = event.deltaX;
- }
- if ((pX || pY) && event.deltaMode) {
- if (event.deltaMode === 1) {
- // delta in LINE units
- pX *= LINE_HEIGHT;
- pY *= LINE_HEIGHT;
- } else {
- // delta in PAGE units
- pX *= PAGE_HEIGHT;
- pY *= PAGE_HEIGHT;
- }
- }
- // Fall-back if spin cannot be determined
- if (pX && !sX) {
- sX = pX < 1 ? -1 : 1;
- }
- if (pY && !sY) {
- sY = pY < 1 ? -1 : 1;
- }
- return {
- spinX: sX,
- spinY: sY,
- pixelX: pX,
- pixelY: pY
- };
- }
- if (s.params.mousewheelControl) {
- /**
- * The best combination if you prefer spinX + spinY normalization. It favors
- * the older DOMMouseScroll for Firefox, as FF does not include wheelDelta with
- * 'wheel' event, making spin speed determination impossible.
- */
- s.mousewheel.event = navigator.userAgent.indexOf('firefox') > -1 ? 'DOMMouseScroll' : isEventSupported() ? 'wheel' : 'mousewheel';
- }
- function handleMousewheel(e) {
- if (e.originalEvent) e = e.originalEvent; //jquery fix
- var delta = 0;
- var rtlFactor = s.rtl ? -1 : 1;
- var data = normalizeWheel(e);
- if (s.params.mousewheelForceToAxis) {
- if (s.isHorizontal()) {
- if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = data.pixelX * rtlFactor;else return;
- } else {
- if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = data.pixelY;else return;
- }
- } else {
- delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY;
- }
- if (delta === 0) return;
- if (s.params.mousewheelInvert) delta = -delta;
- if (!s.params.freeMode) {
- if (new window.Date().getTime() - s.mousewheel.lastScrollTime > 60) {
- if (delta < 0) {
- if ((!s.isEnd || s.params.loop) && !s.animating) {
- s.slideNext();
- s.emit('onScroll', s, e);
- } else if (s.params.mousewheelReleaseOnEdges) return true;
- } else {
- if ((!s.isBeginning || s.params.loop) && !s.animating) {
- s.slidePrev();
- s.emit('onScroll', s, e);
- } else if (s.params.mousewheelReleaseOnEdges) return true;
- }
- }
- s.mousewheel.lastScrollTime = new window.Date().getTime();
- } else {
- //Freemode or scrollContainer:
- var position = s.getWrapperTranslate() + delta * s.params.mousewheelSensitivity;
- var wasBeginning = s.isBeginning,
- wasEnd = s.isEnd;
- if (position >= s.minTranslate()) position = s.minTranslate();
- if (position <= s.maxTranslate()) position = s.maxTranslate();
- s.setWrapperTransition(0);
- s.setWrapperTranslate(position);
- s.updateProgress();
- s.updateActiveIndex();
- if (!wasBeginning && s.isBeginning || !wasEnd && s.isEnd) {
- s.updateClasses();
- }
- if (s.params.freeModeSticky) {
- clearTimeout(s.mousewheel.timeout);
- s.mousewheel.timeout = setTimeout(function () {
- s.slideReset();
- }, 300);
- } else {
- if (s.params.lazyLoading && s.lazy) {
- s.lazy.load();
- }
- }
- // Emit event
- s.emit('onScroll', s, e);
- // Stop autoplay
- if (s.params.autoplay && s.params.autoplayDisableOnInteraction) s.stopAutoplay();
- // Return page scroll on edge positions
- if (position === 0 || position === s.maxTranslate()) return;
- }
- if (e.preventDefault) e.preventDefault();else e.returnValue = false;
- return false;
- }
- s.disableMousewheelControl = function () {
- if (!s.mousewheel.event) return false;
- var target = s.container;
- console.log('3913', s.params.mousewheelEventsTarged)
- if (s.params.mousewheelEventsTarged !== 'container') {
- target = $(s.params.mousewheelEventsTarged);
- }
- target.off(s.mousewheel.event, handleMousewheel);
- s.params.mousewheelControl = false;
- return true;
- };
- s.enableMousewheelControl = function () {
- if (!s.mousewheel.event) return false;
- var target = s.container;
- console.log('3925', s.params.mousewheelEventsTarged)
- if (s.params.mousewheelEventsTarged !== 'container') {
- target = $(s.params.mousewheelEventsTarged);
- }
- target.on(s.mousewheel.event, handleMousewheel);
- s.params.mousewheelControl = true;
- return true;
- };
- /*=========================
- Parallax
- ===========================*/
- function setParallaxTransform(el, progress) {
- el = $(el);
- var p, pX, pY;
- var rtlFactor = s.rtl ? -1 : 1;
- p = el.attr('data-swiper-parallax') || '0';
- pX = el.attr('data-swiper-parallax-x');
- pY = el.attr('data-swiper-parallax-y');
- if (pX || pY) {
- pX = pX || '0';
- pY = pY || '0';
- } else {
- if (s.isHorizontal()) {
- pX = p;
- pY = '0';
- } else {
- pY = p;
- pX = '0';
- }
- }
- if (pX.indexOf('%') >= 0) {
- pX = parseInt(pX, 10) * progress * rtlFactor + '%';
- } else {
- pX = pX * progress * rtlFactor + 'px';
- }
- if (pY.indexOf('%') >= 0) {
- pY = parseInt(pY, 10) * progress + '%';
- } else {
- pY = pY * progress + 'px';
- }
- el.transform('translate3d(' + pX + ', ' + pY + ',0px)');
- }
- s.parallax = {
- setTranslate: function setTranslate() {
- s.container.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function () {
- setParallaxTransform(this, s.progress);
- });
- s.slides.each(function () {
- var slide = $(this);
- slide.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function () {
- var progress = Math.min(Math.max(slide[0].progress, -1), 1);
- setParallaxTransform(this, progress);
- });
- });
- },
- setTransition: function setTransition(duration) {
- if (typeof duration === 'undefined') duration = s.params.speed;
- s.container.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function () {
- var el = $(this);
- var parallaxDuration = parseInt(el.attr('data-swiper-parallax-duration'), 10) || duration;
- if (duration === 0) parallaxDuration = 0;
- el.transition(parallaxDuration);
- });
- }
- };
- /*=========================
- Zoom
- ===========================*/
- s.zoom = {
- // "Global" Props
- scale: 1,
- currentScale: 1,
- isScaling: false,
- gesture: {
- slide: undefined,
- slideWidth: undefined,
- slideHeight: undefined,
- image: undefined,
- imageWrap: undefined,
- zoomMax: s.params.zoomMax
- },
- image: {
- isTouched: undefined,
- isMoved: undefined,
- currentX: undefined,
- currentY: undefined,
- minX: undefined,
- minY: undefined,
- maxX: undefined,
- maxY: undefined,
- width: undefined,
- height: undefined,
- startX: undefined,
- startY: undefined,
- touchesStart: {},
- touchesCurrent: {}
- },
- velocity: {
- x: undefined,
- y: undefined,
- prevPositionX: undefined,
- prevPositionY: undefined,
- prevTime: undefined
- },
- // Calc Scale From Multi-touches
- getDistanceBetweenTouches: function getDistanceBetweenTouches(e) {
- if (e.targetTouches.length < 2) return 1;
- var x1 = e.targetTouches[0].pageX,
- y1 = e.targetTouches[0].pageY,
- x2 = e.targetTouches[1].pageX,
- y2 = e.targetTouches[1].pageY;
- var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
- return distance;
- },
- // Events
- onGestureStart: function onGestureStart(e) {
- var z = s.zoom;
- if (!s.support.gestures) {
- if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) {
- return;
- }
- z.gesture.scaleStart = z.getDistanceBetweenTouches(e);
- }
- if (!z.gesture.slide || !z.gesture.slide.length) {
- z.gesture.slide = $(this);
- if (z.gesture.slide.length === 0) z.gesture.slide = s.slides.eq(s.activeIndex);
- z.gesture.image = z.gesture.slide.find('img, svg, canvas');
- z.gesture.imageWrap = z.gesture.image.parent('.' + s.params.zoomContainerClass);
- z.gesture.zoomMax = z.gesture.imageWrap.attr('data-swiper-zoom') || s.params.zoomMax;
- if (z.gesture.imageWrap.length === 0) {
- z.gesture.image = undefined;
- return;
- }
- }
- z.gesture.image.transition(0);
- z.isScaling = true;
- },
- onGestureChange: function onGestureChange(e) {
- var z = s.zoom;
- if (!s.support.gestures) {
- if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) {
- return;
- }
- z.gesture.scaleMove = z.getDistanceBetweenTouches(e);
- }
- if (!z.gesture.image || z.gesture.image.length === 0) return;
- if (s.support.gestures) {
- z.scale = e.scale * z.currentScale;
- } else {
- z.scale = z.gesture.scaleMove / z.gesture.scaleStart * z.currentScale;
- }
- if (z.scale > z.gesture.zoomMax) {
- z.scale = z.gesture.zoomMax - 1 + Math.pow(z.scale - z.gesture.zoomMax + 1, 0.5);
- }
- if (z.scale < s.params.zoomMin) {
- z.scale = s.params.zoomMin + 1 - Math.pow(s.params.zoomMin - z.scale + 1, 0.5);
- }
- z.gesture.image.transform('translate3d(0,0,0) scale(' + z.scale + ')');
- },
- onGestureEnd: function onGestureEnd(e) {
- var z = s.zoom;
- if (!s.support.gestures) {
- if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2) {
- return;
- }
- }
- if (!z.gesture.image || z.gesture.image.length === 0) return;
- z.scale = Math.max(Math.min(z.scale, z.gesture.zoomMax), s.params.zoomMin);
- z.gesture.image.transition(s.params.speed).transform('translate3d(0,0,0) scale(' + z.scale + ')');
- z.currentScale = z.scale;
- z.isScaling = false;
- if (z.scale === 1) z.gesture.slide = undefined;
- },
- onTouchStart: function onTouchStart(s, e) {
- var z = s.zoom;
- if (!z.gesture.image || z.gesture.image.length === 0) return;
- if (z.image.isTouched) return;
- if (s.device.os === 'android') e.preventDefault();
- z.image.isTouched = true;
- z.image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
- z.image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
- },
- onTouchMove: function onTouchMove(e) {
- var z = s.zoom;
- if (!z.gesture.image || z.gesture.image.length === 0) return;
- s.allowClick = false;
- if (!z.image.isTouched || !z.gesture.slide) return;
- if (!z.image.isMoved) {
- z.image.width = z.gesture.image[0].offsetWidth;
- z.image.height = z.gesture.image[0].offsetHeight;
- z.image.startX = s.getTranslate(z.gesture.imageWrap[0], 'x') || 0;
- z.image.startY = s.getTranslate(z.gesture.imageWrap[0], 'y') || 0;
- z.gesture.slideWidth = z.gesture.slide[0].offsetWidth;
- z.gesture.slideHeight = z.gesture.slide[0].offsetHeight;
- z.gesture.imageWrap.transition(0);
- if (s.rtl) z.image.startX = -z.image.startX;
- if (s.rtl) z.image.startY = -z.image.startY;
- }
- // Define if we need image drag
- var scaledWidth = z.image.width * z.scale;
- var scaledHeight = z.image.height * z.scale;
- if (scaledWidth < z.gesture.slideWidth && scaledHeight < z.gesture.slideHeight) return;
- z.image.minX = Math.min(z.gesture.slideWidth / 2 - scaledWidth / 2, 0);
- z.image.maxX = -z.image.minX;
- z.image.minY = Math.min(z.gesture.slideHeight / 2 - scaledHeight / 2, 0);
- z.image.maxY = -z.image.minY;
- z.image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
- z.image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
- if (!z.image.isMoved && !z.isScaling) {
- if (s.isHorizontal() && Math.floor(z.image.minX) === Math.floor(z.image.startX) && z.image.touchesCurrent.x < z.image.touchesStart.x || Math.floor(z.image.maxX) === Math.floor(z.image.startX) && z.image.touchesCurrent.x > z.image.touchesStart.x) {
- z.image.isTouched = false;
- return;
- } else if (!s.isHorizontal() && Math.floor(z.image.minY) === Math.floor(z.image.startY) && z.image.touchesCurrent.y < z.image.touchesStart.y || Math.floor(z.image.maxY) === Math.floor(z.image.startY) && z.image.touchesCurrent.y > z.image.touchesStart.y) {
- z.image.isTouched = false;
- return;
- }
- }
- e.preventDefault();
- e.stopPropagation();
- z.image.isMoved = true;
- z.image.currentX = z.image.touchesCurrent.x - z.image.touchesStart.x + z.image.startX;
- z.image.currentY = z.image.touchesCurrent.y - z.image.touchesStart.y + z.image.startY;
- if (z.image.currentX < z.image.minX) {
- z.image.currentX = z.image.minX + 1 - Math.pow(z.image.minX - z.image.currentX + 1, 0.8);
- }
- if (z.image.currentX > z.image.maxX) {
- z.image.currentX = z.image.maxX - 1 + Math.pow(z.image.currentX - z.image.maxX + 1, 0.8);
- }
- if (z.image.currentY < z.image.minY) {
- z.image.currentY = z.image.minY + 1 - Math.pow(z.image.minY - z.image.currentY + 1, 0.8);
- }
- if (z.image.currentY > z.image.maxY) {
- z.image.currentY = z.image.maxY - 1 + Math.pow(z.image.currentY - z.image.maxY + 1, 0.8);
- }
- //Velocity
- if (!z.velocity.prevPositionX) z.velocity.prevPositionX = z.image.touchesCurrent.x;
- if (!z.velocity.prevPositionY) z.velocity.prevPositionY = z.image.touchesCurrent.y;
- if (!z.velocity.prevTime) z.velocity.prevTime = Date.now();
- z.velocity.x = (z.image.touchesCurrent.x - z.velocity.prevPositionX) / (Date.now() - z.velocity.prevTime) / 2;
- z.velocity.y = (z.image.touchesCurrent.y - z.velocity.prevPositionY) / (Date.now() - z.velocity.prevTime) / 2;
- if (Math.abs(z.image.touchesCurrent.x - z.velocity.prevPositionX) < 2) z.velocity.x = 0;
- if (Math.abs(z.image.touchesCurrent.y - z.velocity.prevPositionY) < 2) z.velocity.y = 0;
- z.velocity.prevPositionX = z.image.touchesCurrent.x;
- z.velocity.prevPositionY = z.image.touchesCurrent.y;
- z.velocity.prevTime = Date.now();
- z.gesture.imageWrap.transform('translate3d(' + z.image.currentX + 'px, ' + z.image.currentY + 'px,0)');
- },
- onTouchEnd: function onTouchEnd(s, e) {
- var z = s.zoom;
- if (!z.gesture.image || z.gesture.image.length === 0) return;
- if (!z.image.isTouched || !z.image.isMoved) {
- z.image.isTouched = false;
- z.image.isMoved = false;
- return;
- }
- z.image.isTouched = false;
- z.image.isMoved = false;
- var momentumDurationX = 300;
- var momentumDurationY = 300;
- var momentumDistanceX = z.velocity.x * momentumDurationX;
- var newPositionX = z.image.currentX + momentumDistanceX;
- var momentumDistanceY = z.velocity.y * momentumDurationY;
- var newPositionY = z.image.currentY + momentumDistanceY;
- //Fix duration
- if (z.velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - z.image.currentX) / z.velocity.x);
- if (z.velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - z.image.currentY) / z.velocity.y);
- var momentumDuration = Math.max(momentumDurationX, momentumDurationY);
- z.image.currentX = newPositionX;
- z.image.currentY = newPositionY;
- // Define if we need image drag
- var scaledWidth = z.image.width * z.scale;
- var scaledHeight = z.image.height * z.scale;
- z.image.minX = Math.min(z.gesture.slideWidth / 2 - scaledWidth / 2, 0);
- z.image.maxX = -z.image.minX;
- z.image.minY = Math.min(z.gesture.slideHeight / 2 - scaledHeight / 2, 0);
- z.image.maxY = -z.image.minY;
- z.image.currentX = Math.max(Math.min(z.image.currentX, z.image.maxX), z.image.minX);
- z.image.currentY = Math.max(Math.min(z.image.currentY, z.image.maxY), z.image.minY);
- z.gesture.imageWrap.transition(momentumDuration).transform('translate3d(' + z.image.currentX + 'px, ' + z.image.currentY + 'px,0)');
- },
- onTransitionEnd: function onTransitionEnd(s) {
- var z = s.zoom;
- if (z.gesture.slide && s.previousIndex !== s.activeIndex) {
- z.gesture.image.transform('translate3d(0,0,0) scale(1)');
- z.gesture.imageWrap.transform('translate3d(0,0,0)');
- z.gesture.slide = z.gesture.image = z.gesture.imageWrap = undefined;
- z.scale = z.currentScale = 1;
- }
- },
- // Toggle Zoom
- toggleZoom: function toggleZoom(s, e) {
- var z = s.zoom;
- if (!z.gesture.slide) {
- z.gesture.slide = s.clickedSlide ? $(s.clickedSlide) : s.slides.eq(s.activeIndex);
- z.gesture.image = z.gesture.slide.find('img, svg, canvas');
- z.gesture.imageWrap = z.gesture.image.parent('.' + s.params.zoomContainerClass);
- }
- if (!z.gesture.image || z.gesture.image.length === 0) return;
- var touchX, touchY, offsetX, offsetY, diffX, diffY, translateX, translateY, imageWidth, imageHeight, scaledWidth, scaledHeight, translateMinX, translateMinY, translateMaxX, translateMaxY, slideWidth, slideHeight;
- if (typeof z.image.touchesStart.x === 'undefined' && e) {
- touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX;
- touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY;
- } else {
- touchX = z.image.touchesStart.x;
- touchY = z.image.touchesStart.y;
- }
- if (z.scale && z.scale !== 1) {
- // Zoom Out
- z.scale = z.currentScale = 1;
- z.gesture.imageWrap.transition(300).transform('translate3d(0,0,0)');
- z.gesture.image.transition(300).transform('translate3d(0,0,0) scale(1)');
- z.gesture.slide = undefined;
- } else {
- // Zoom In
- z.scale = z.currentScale = z.gesture.imageWrap.attr('data-swiper-zoom') || s.params.zoomMax;
- if (e) {
- slideWidth = z.gesture.slide[0].offsetWidth;
- slideHeight = z.gesture.slide[0].offsetHeight;
- offsetX = z.gesture.slide.offset().left;
- offsetY = z.gesture.slide.offset().top;
- diffX = offsetX + slideWidth / 2 - touchX;
- diffY = offsetY + slideHeight / 2 - touchY;
- imageWidth = z.gesture.image[0].offsetWidth;
- imageHeight = z.gesture.image[0].offsetHeight;
- scaledWidth = imageWidth * z.scale;
- scaledHeight = imageHeight * z.scale;
- translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
- translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
- translateMaxX = -translateMinX;
- translateMaxY = -translateMinY;
- translateX = diffX * z.scale;
- translateY = diffY * z.scale;
- if (translateX < translateMinX) {
- translateX = translateMinX;
- }
- if (translateX > translateMaxX) {
- translateX = translateMaxX;
- }
- if (translateY < translateMinY) {
- translateY = translateMinY;
- }
- if (translateY > translateMaxY) {
- translateY = translateMaxY;
- }
- } else {
- translateX = 0;
- translateY = 0;
- }
- z.gesture.imageWrap.transition(300).transform('translate3d(' + translateX + 'px, ' + translateY + 'px,0)');
- z.gesture.image.transition(300).transform('translate3d(0,0,0) scale(' + z.scale + ')');
- }
- },
- // Attach/Detach Events
- attachEvents: function attachEvents(detach) {
- var action = detach ? 'off' : 'on';
- if (s.params.zoom) {
- var target = s.slides;
- var passiveListener = s.touchEvents.start === 'touchstart' && s.support.passiveListener && s.params.passiveListeners ? { passive: true, capture: false } : false;
- // Scale image
- if (s.support.gestures) {
- s.slides[action]('gesturestart', s.zoom.onGestureStart, passiveListener);
- s.slides[action]('gesturechange', s.zoom.onGestureChange, passiveListener);
- s.slides[action]('gestureend', s.zoom.onGestureEnd, passiveListener);
- } else if (s.touchEvents.start === 'touchstart') {
- s.slides[action](s.touchEvents.start, s.zoom.onGestureStart, passiveListener);
- s.slides[action](s.touchEvents.move, s.zoom.onGestureChange, passiveListener);
- s.slides[action](s.touchEvents.end, s.zoom.onGestureEnd, passiveListener);
- }
- // Move image
- s[action]('touchStart', s.zoom.onTouchStart);
- s.slides.each(function (index, slide) {
- if ($(slide).find('.' + s.params.zoomContainerClass).length > 0) {
- $(slide)[action](s.touchEvents.move, s.zoom.onTouchMove);
- }
- });
- s[action]('touchEnd', s.zoom.onTouchEnd);
- // Scale Out
- s[action]('transitionEnd', s.zoom.onTransitionEnd);
- if (s.params.zoomToggle) {
- s.on('doubleTap', s.zoom.toggleZoom);
- }
- }
- },
- init: function init() {
- s.zoom.attachEvents();
- },
- destroy: function destroy() {
- s.zoom.attachEvents(true);
- }
- };
- /*=========================
- Plugins API. Collect all and init all plugins
- ===========================*/
- s._plugins = [];
- for (var plugin in s.plugins) {
- var p = s.plugins[plugin](s, s.params[plugin]);
- if (p) s._plugins.push(p);
- }
- // Method to call all plugins event/method
- s.callPlugins = function (eventName) {
- for (var i = 0; i < s._plugins.length; i++) {
- if (eventName in s._plugins[i]) {
- s._plugins[i][eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
- }
- }
- };
- /*=========================
- Events/Callbacks/Plugins Emitter
- ===========================*/
- function normalizeEventName(eventName) {
- if (eventName.indexOf('on') !== 0) {
- if (eventName[0] !== eventName[0].toUpperCase()) {
- eventName = 'on' + eventName[0].toUpperCase() + eventName.substring(1);
- } else {
- eventName = 'on' + eventName;
- }
- }
- return eventName;
- }
- s.emitterEventListeners = {};
- s.emit = function (eventName) {
- // Trigger callbacks
- if (s.params[eventName]) {
- s.params[eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
- }
- var i;
- // Trigger events
- if (s.emitterEventListeners[eventName]) {
- for (i = 0; i < s.emitterEventListeners[eventName].length; i++) {
- s.emitterEventListeners[eventName][i](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
- }
- }
- // Trigger plugins
- if (s.callPlugins) s.callPlugins(eventName, arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
- };
- s.on = function (eventName, handler) {
- eventName = normalizeEventName(eventName);
- if (!s.emitterEventListeners[eventName]) s.emitterEventListeners[eventName] = [];
- s.emitterEventListeners[eventName].push(handler);
- return s;
- };
- s.off = function (eventName, handler) {
- var i;
- eventName = normalizeEventName(eventName);
- if (typeof handler === 'undefined') {
- // Remove all handlers for such event
- s.emitterEventListeners[eventName] = [];
- return s;
- }
- if (!s.emitterEventListeners[eventName] || s.emitterEventListeners[eventName].length === 0) return;
- for (i = 0; i < s.emitterEventListeners[eventName].length; i++) {
- if (s.emitterEventListeners[eventName][i] === handler) s.emitterEventListeners[eventName].splice(i, 1);
- }
- return s;
- };
- s.once = function (eventName, handler) {
- eventName = normalizeEventName(eventName);
- var _handler = function _handler() {
- handler(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
- s.off(eventName, _handler);
- };
- s.on(eventName, _handler);
- return s;
- };
- // Accessibility tools
- s.a11y = {
- makeFocusable: function makeFocusable($el) {
- $el.attr('tabIndex', '0');
- return $el;
- },
- addRole: function addRole($el, role) {
- $el.attr('role', role);
- return $el;
- },
- addLabel: function addLabel($el, label) {
- $el.attr('aria-label', label);
- return $el;
- },
- disable: function disable($el) {
- $el.attr('aria-disabled', true);
- return $el;
- },
- enable: function enable($el) {
- $el.attr('aria-disabled', false);
- return $el;
- },
- onEnterKey: function onEnterKey(event) {
- if (event.keyCode !== 13) return;
- if ($(event.target).is(s.params.nextButton)) {
- s.onClickNext(event);
- if (s.isEnd) {
- s.a11y.notify(s.params.lastSlideMessage);
- } else {
- s.a11y.notify(s.params.nextSlideMessage);
- }
- } else if ($(event.target).is(s.params.prevButton)) {
- s.onClickPrev(event);
- if (s.isBeginning) {
- s.a11y.notify(s.params.firstSlideMessage);
- } else {
- s.a11y.notify(s.params.prevSlideMessage);
- }
- }
- if ($(event.target).is('.' + s.params.bulletClass)) {
- $(event.target)[0].click();
- }
- },
- liveRegion: $('<span class="' + s.params.notificationClass + '" aria-live="assertive" aria-atomic="true"></span>'),
- notify: function notify(message) {
- var notification = s.a11y.liveRegion;
- if (notification.length === 0) return;
- notification.html('');
- notification.html(message);
- },
- init: function init() {
- // Setup accessibility
- if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
- s.a11y.makeFocusable(s.nextButton);
- s.a11y.addRole(s.nextButton, 'button');
- s.a11y.addLabel(s.nextButton, s.params.nextSlideMessage);
- }
- if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
- s.a11y.makeFocusable(s.prevButton);
- s.a11y.addRole(s.prevButton, 'button');
- s.a11y.addLabel(s.prevButton, s.params.prevSlideMessage);
- }
- $(s.container).append(s.a11y.liveRegion);
- },
- initPagination: function initPagination() {
- if (s.params.pagination && s.params.paginationClickable && s.bullets && s.bullets.length) {
- s.bullets.each(function () {
- var bullet = $(this);
- s.a11y.makeFocusable(bullet);
- s.a11y.addRole(bullet, 'button');
- s.a11y.addLabel(bullet, s.params.paginationBulletMessage.replace(/{{index}}/, bullet.index() + 1));
- });
- }
- },
- destroy: function destroy() {
- if (s.a11y.liveRegion && s.a11y.liveRegion.length > 0) s.a11y.liveRegion.remove();
- }
- };
- /*=========================
- Init/Destroy
- ===========================*/
- s.init = function () {
- if (s.params.loop) s.createLoop();
- s.updateContainerSize();
- s.updateSlidesSize();
- s.updatePagination();
- if (s.params.scrollbar && s.scrollbar) {
- s.scrollbar.set();
- if (s.params.scrollbarDraggable) {
- s.scrollbar.enableDraggable();
- }
- }
- if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
- if (!s.params.loop) s.updateProgress();
- s.effects[s.params.effect].setTranslate();
- }
- if (s.params.loop) {
- s.slideTo(s.params.initialSlide + s.loopedSlides, 0, s.params.runCallbacksOnInit);
- } else {
- s.slideTo(s.params.initialSlide, 0, s.params.runCallbacksOnInit);
- if (s.params.initialSlide === 0) {
- if (s.parallax && s.params.parallax) s.parallax.setTranslate();
- if (s.lazy && s.params.lazyLoading) {
- s.lazy.load();
- s.lazy.initialImageLoaded = true;
- }
- }
- }
- s.attachEvents();
- if (s.params.observer && s.support.observer) {
- s.initObservers();
- }
- if (s.params.preloadImages && !s.params.lazyLoading) {
- s.preloadImages();
- }
- if (s.params.zoom && s.zoom) {
- s.zoom.init();
- }
- if (s.params.autoplay) {
- s.startAutoplay();
- }
- if (s.params.keyboardControl) {
- if (s.enableKeyboardControl) s.enableKeyboardControl();
- }
- if (s.params.mousewheelControl) {
- if (s.enableMousewheelControl) s.enableMousewheelControl();
- }
- // Deprecated hashnavReplaceState changed to replaceState for use in hashnav and history
- if (s.params.hashnavReplaceState) {
- s.params.replaceState = s.params.hashnavReplaceState;
- }
- if (s.params.history) {
- if (s.history) s.history.init();
- }
- if (s.params.hashnav) {
- if (s.hashnav) s.hashnav.init();
- }
- if (s.params.a11y && s.a11y) s.a11y.init();
- s.emit('onInit', s);
- };
- // Cleanup dynamic styles
- s.cleanupStyles = function () {
- // Container
- s.container.removeClass(s.classNames.join(' ')).removeAttr('style');
- // Wrapper
- s.wrapper.removeAttr('style');
- // Slides
- if (s.slides && s.slides.length) {
- s.slides.removeClass([s.params.slideVisibleClass, s.params.slideActiveClass, s.params.slideNextClass, s.params.slidePrevClass].join(' ')).removeAttr('style').removeAttr('data-swiper-column').removeAttr('data-swiper-row');
- }
- // Pagination/Bullets
- if (s.paginationContainer && s.paginationContainer.length) {
- s.paginationContainer.removeClass(s.params.paginationHiddenClass);
- }
- if (s.bullets && s.bullets.length) {
- s.bullets.removeClass(s.params.bulletActiveClass);
- }
- // Buttons
- if (s.params.prevButton) $(s.params.prevButton).removeClass(s.params.buttonDisabledClass);
- if (s.params.nextButton) $(s.params.nextButton).removeClass(s.params.buttonDisabledClass);
- // Scrollbar
- if (s.params.scrollbar && s.scrollbar) {
- if (s.scrollbar.track && s.scrollbar.track.length) s.scrollbar.track.removeAttr('style');
- if (s.scrollbar.drag && s.scrollbar.drag.length) s.scrollbar.drag.removeAttr('style');
- }
- };
- // Destroy
- s.destroy = function (deleteInstance, cleanupStyles) {
- // Detach evebts
- s.detachEvents();
- // Stop autoplay
- s.stopAutoplay();
- // Disable draggable
- if (s.params.scrollbar && s.scrollbar) {
- if (s.params.scrollbarDraggable) {
- s.scrollbar.disableDraggable();
- }
- }
- // Destroy loop
- if (s.params.loop) {
- s.destroyLoop();
- }
- // Cleanup styles
- if (cleanupStyles) {
- s.cleanupStyles();
- }
- // Disconnect observer
- s.disconnectObservers();
- // Destroy zoom
- if (s.params.zoom && s.zoom) {
- s.zoom.destroy();
- }
- // Disable keyboard/mousewheel
- if (s.params.keyboardControl) {
- if (s.disableKeyboardControl) s.disableKeyboardControl();
- }
- if (s.params.mousewheelControl) {
- if (s.disableMousewheelControl) s.disableMousewheelControl();
- }
- // Disable a11y
- if (s.params.a11y && s.a11y) s.a11y.destroy();
- // Delete history popstate
- if (s.params.history && !s.params.replaceState) {
- window.removeEventListener('popstate', s.history.setHistoryPopState);
- }
- if (s.params.hashnav && s.hashnav) {
- s.hashnav.destroy();
- }
- // Destroy callback
- s.emit('onDestroy');
- // Delete instance
- if (deleteInstance !== false) s = null;
- };
- s.init();
- // Return swiper instance
- return s;
- };
- /*==================================================
- Prototype
- ====================================================*/
- Swiper.prototype = {
- isSafari: function () {
- var ua = window.navigator.userAgent.toLowerCase();
- return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
- }(),
- isUiWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent),
- isArray: function isArray(arr) {
- return Object.prototype.toString.apply(arr) === '[object Array]';
- },
- /*==================================================
- Browser
- ====================================================*/
- browser: {
- ie: window.navigator.pointerEnabled || window.navigator.msPointerEnabled,
- ieTouch: window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 1 || window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 1,
- lteIE9: function () {
- // create temporary DIV
- var div = document.createElement('div');
- // add content to tmp DIV which is wrapped into the IE HTML conditional statement
- div.innerHTML = '<!--[if lte IE 9]><i></i><![endif]-->';
- // return true / false value based on what will browser render
- return div.getElementsByTagName('i').length === 1;
- }()
- },
- /*==================================================
- Devices
- ====================================================*/
- device: function () {
- var ua = window.navigator.userAgent;
- var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
- var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
- var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
- var iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
- return {
- ios: ipad || iphone || ipod,
- android: android
- };
- }(),
- /*==================================================
- Feature Detection
- ====================================================*/
- support: {
- touch: window.Modernizr && Modernizr.touch === true || function () {
- return !!('ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch);
- }(),
- transforms3d: window.Modernizr && Modernizr.csstransforms3d === true || function () {
- var div = document.createElement('div').style;
- return 'webkitPerspective' in div || 'MozPerspective' in div || 'OPerspective' in div || 'MsPerspective' in div || 'perspective' in div;
- }(),
- flexbox: function () {
- var div = document.createElement('div').style;
- var styles = 'alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient'.split(' ');
- for (var i = 0; i < styles.length; i++) {
- if (styles[i] in div) return true;
- }
- }(),
- observer: function () {
- return 'MutationObserver' in window || 'WebkitMutationObserver' in window;
- }(),
- passiveListener: function () {
- var supportsPassive = false;
- try {
- var opts = Object.defineProperty({}, 'passive', {
- get: function get() {
- supportsPassive = true;
- }
- });
- window.addEventListener('testPassiveListener', null, opts);
- } catch (e) {}
- return supportsPassive;
- }(),
- gestures: function () {
- return 'ongesturestart' in window;
- }()
- },
- /*==================================================
- Plugins
- ====================================================*/
- plugins: {}
- };
- /*===========================
- Dom7 Library
- ===========================*/
- var Dom7 = function () {
- var Dom7 = function Dom7(arr) {
- var _this = this,
- i = 0;
- // Create array-like object
- for (i = 0; i < arr.length; i++) {
- _this[i] = arr[i];
- }
- _this.length = arr.length;
- // Return collection with methods
- return this;
- };
- var $ = function $(selector, context) {
- var arr = [],
- i = 0;
- if (selector && !context) {
- if (selector instanceof Dom7) {
- return selector;
- }
- }
- if (selector) {
- // String
- if (typeof selector === 'string') {
- var els,
- tempParent,
- html = selector.trim();
- if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
- var toCreate = 'div';
- if (html.indexOf('<li') === 0) toCreate = 'ul';
- if (html.indexOf('<tr') === 0) toCreate = 'tbody';
- if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
- if (html.indexOf('<tbody') === 0) toCreate = 'table';
- if (html.indexOf('<option') === 0) toCreate = 'select';
- tempParent = document.createElement(toCreate);
- tempParent.innerHTML = selector;
- for (i = 0; i < tempParent.childNodes.length; i++) {
- arr.push(tempParent.childNodes[i]);
- }
- } else {
- if (!context && selector[0] === '#' && !selector.match(/[ .<>:~]/)) {
- // Pure ID selector
- els = [document.getElementById(selector.split('#')[1])];
- } else {
- // Other selectors
- els = (context || document).querySelectorAll(selector);
- }
- for (i = 0; i < els.length; i++) {
- if (els[i]) arr.push(els[i]);
- }
- }
- }
- // Node/element
- else if (selector.nodeType || selector === window || selector === document) {
- arr.push(selector);
- }
- //Array of elements or instance of Dom
- else if (selector.length > 0 && selector[0].nodeType) {
- for (i = 0; i < selector.length; i++) {
- arr.push(selector[i]);
- }
- }
- }
- return new Dom7(arr);
- };
- Dom7.prototype = {
- // Classes and attriutes
- addClass: function addClass(className) {
- if (typeof className === 'undefined') {
- return this;
- }
- var classes = className.split(' ');
- for (var i = 0; i < classes.length; i++) {
- for (var j = 0; j < this.length; j++) {
- this[j].classList.add(classes[i]);
- }
- }
- return this;
- },
- removeClass: function removeClass(className) {
- var classes = className.split(' ');
- for (var i = 0; i < classes.length; i++) {
- for (var j = 0; j < this.length; j++) {
- this[j].classList.remove(classes[i]);
- }
- }
- return this;
- },
- hasClass: function hasClass(className) {
- if (!this[0]) return false;else return this[0].classList.contains(className);
- },
- toggleClass: function toggleClass(className) {
- var classes = className.split(' ');
- for (var i = 0; i < classes.length; i++) {
- for (var j = 0; j < this.length; j++) {
- this[j].classList.toggle(classes[i]);
- }
- }
- return this;
- },
- attr: function attr(attrs, value) {
- if (arguments.length === 1 && typeof attrs === 'string') {
- // Get attr
- if (this[0]) return this[0].getAttribute(attrs);else return undefined;
- } else {
- // Set attrs
- for (var i = 0; i < this.length; i++) {
- if (arguments.length === 2) {
- // String
- this[i].setAttribute(attrs, value);
- } else {
- // Object
- for (var attrName in attrs) {
- this[i][attrName] = attrs[attrName];
- this[i].setAttribute(attrName, attrs[attrName]);
- }
- }
- }
- return this;
- }
- },
- removeAttr: function removeAttr(attr) {
- for (var i = 0; i < this.length; i++) {
- this[i].removeAttribute(attr);
- }
- return this;
- },
- data: function data(key, value) {
- if (typeof value === 'undefined') {
- // Get value
- if (this[0]) {
- var dataKey = this[0].getAttribute('data-' + key);
- if (dataKey) return dataKey;else if (this[0].dom7ElementDataStorage && key in this[0].dom7ElementDataStorage) return this[0].dom7ElementDataStorage[key];else return undefined;
- } else return undefined;
- } else {
- // Set value
- for (var i = 0; i < this.length; i++) {
- var el = this[i];
- if (!el.dom7ElementDataStorage) el.dom7ElementDataStorage = {};
- el.dom7ElementDataStorage[key] = value;
- }
- return this;
- }
- },
- // Transforms
- transform: function transform(_transform) {
- for (var i = 0; i < this.length; i++) {
- var elStyle = this[i].style;
- elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = _transform;
- }
- return this;
- },
- transition: function transition(duration) {
- if (typeof duration !== 'string') {
- duration = duration + 'ms';
- }
- for (var i = 0; i < this.length; i++) {
- var elStyle = this[i].style;
- elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration;
- }
- return this;
- },
- //Events
- on: function on(eventName, targetSelector, listener, capture) {
- function handleLiveEvent(e) {
- var target = e.target;
- if ($(target).is(targetSelector)) listener.call(target, e);else {
- var parents = $(target).parents();
- for (var k = 0; k < parents.length; k++) {
- if ($(parents[k]).is(targetSelector)) listener.call(parents[k], e);
- }
- }
- }
- var events = eventName.split(' ');
- var i, j;
- for (i = 0; i < this.length; i++) {
- if (typeof targetSelector === 'function' || targetSelector === false) {
- // Usual events
- if (typeof targetSelector === 'function') {
- listener = arguments[1];
- capture = arguments[2] || false;
- }
- for (j = 0; j < events.length; j++) {
- this[i].addEventListener(events[j], listener, capture);
- }
- } else {
- //Live events
- for (j = 0; j < events.length; j++) {
- if (!this[i].dom7LiveListeners) this[i].dom7LiveListeners = [];
- this[i].dom7LiveListeners.push({ listener: listener, liveListener: handleLiveEvent });
- this[i].addEventListener(events[j], handleLiveEvent, capture);
- }
- }
- }
- return this;
- },
- off: function off(eventName, targetSelector, listener, capture) {
- var events = eventName.split(' ');
- for (var i = 0; i < events.length; i++) {
- for (var j = 0; j < this.length; j++) {
- if (typeof targetSelector === 'function' || targetSelector === false) {
- // Usual events
- if (typeof targetSelector === 'function') {
- listener = arguments[1];
- capture = arguments[2] || false;
- }
- this[j].removeEventListener(events[i], listener, capture);
- } else {
- // Live event
- if (this[j].dom7LiveListeners) {
- for (var k = 0; k < this[j].dom7LiveListeners.length; k++) {
- if (this[j].dom7LiveListeners[k].listener === listener) {
- this[j].removeEventListener(events[i], this[j].dom7LiveListeners[k].liveListener, capture);
- }
- }
- }
- }
- }
- }
- return this;
- },
- once: function once(eventName, targetSelector, listener, capture) {
- var dom = this;
- if (typeof targetSelector === 'function') {
- targetSelector = false;
- listener = arguments[1];
- capture = arguments[2];
- }
- function proxy(e) {
- listener(e);
- dom.off(eventName, targetSelector, proxy, capture);
- }
- dom.on(eventName, targetSelector, proxy, capture);
- },
- trigger: function trigger(eventName, eventData) {
- for (var i = 0; i < this.length; i++) {
- var evt;
- try {
- evt = new window.CustomEvent(eventName, { detail: eventData, bubbles: true, cancelable: true });
- } catch (e) {
- evt = document.createEvent('Event');
- evt.initEvent(eventName, true, true);
- evt.detail = eventData;
- }
- this[i].dispatchEvent(evt);
- }
- return this;
- },
- transitionEnd: function transitionEnd(callback) {
- var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'],
- i,
- j,
- dom = this;
- function fireCallBack(e) {
- /*jshint validthis:true */
- if (e.target !== this) return;
- callback.call(this, e);
- for (i = 0; i < events.length; i++) {
- dom.off(events[i], fireCallBack);
- }
- }
- if (callback) {
- for (i = 0; i < events.length; i++) {
- dom.on(events[i], fireCallBack);
- }
- }
- return this;
- },
- // Sizing/Styles
- width: function width() {
- if (this[0] === window) {
- return window.innerWidth;
- } else {
- if (this.length > 0) {
- return parseFloat(this.css('width'));
- } else {
- return null;
- }
- }
- },
- outerWidth: function outerWidth(includeMargins) {
- if (this.length > 0) {
- if (includeMargins) return this[0].offsetWidth + parseFloat(this.css('margin-right')) + parseFloat(this.css('margin-left'));else return this[0].offsetWidth;
- } else return null;
- },
- height: function height() {
- if (this[0] === window) {
- return window.innerHeight;
- } else {
- if (this.length > 0) {
- return parseFloat(this.css('height'));
- } else {
- return null;
- }
- }
- },
- outerHeight: function outerHeight(includeMargins) {
- if (this.length > 0) {
- if (includeMargins) return this[0].offsetHeight + parseFloat(this.css('margin-top')) + parseFloat(this.css('margin-bottom'));else return this[0].offsetHeight;
- } else return null;
- },
- offset: function offset() {
- if (this.length > 0) {
- var el = this[0];
- var box = el.getBoundingClientRect();
- var body = document.body;
- var clientTop = el.clientTop || body.clientTop || 0;
- var clientLeft = el.clientLeft || body.clientLeft || 0;
- var scrollTop = window.pageYOffset || el.scrollTop;
- var scrollLeft = window.pageXOffset || el.scrollLeft;
- return {
- top: box.top + scrollTop - clientTop,
- left: box.left + scrollLeft - clientLeft
- };
- } else {
- return null;
- }
- },
- css: function css(props, value) {
- var i;
- if (arguments.length === 1) {
- if (typeof props === 'string') {
- if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);
- } else {
- for (i = 0; i < this.length; i++) {
- for (var prop in props) {
- this[i].style[prop] = props[prop];
- }
- }
- return this;
- }
- }
- if (arguments.length === 2 && typeof props === 'string') {
- for (i = 0; i < this.length; i++) {
- this[i].style[props] = value;
- }
- return this;
- }
- return this;
- },
- //Dom manipulation
- each: function each(callback) {
- for (var i = 0; i < this.length; i++) {
- callback.call(this[i], i, this[i]);
- }
- return this;
- },
- html: function html(_html) {
- if (typeof _html === 'undefined') {
- return this[0] ? this[0].innerHTML : undefined;
- } else {
- for (var i = 0; i < this.length; i++) {
- this[i].innerHTML = _html;
- }
- return this;
- }
- },
- text: function text(_text) {
- if (typeof _text === 'undefined') {
- if (this[0]) {
- return this[0].textContent.trim();
- } else return null;
- } else {
- for (var i = 0; i < this.length; i++) {
- this[i].textContent = _text;
- }
- return this;
- }
- },
- is: function is(selector) {
- if (!this[0]) return false;
- var compareWith, i;
- if (typeof selector === 'string') {
- var el = this[0];
- if (el === document) return selector === document;
- if (el === window) return selector === window;
- if (el.matches) return el.matches(selector);else if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);else if (el.mozMatchesSelector) return el.mozMatchesSelector(selector);else if (el.msMatchesSelector) return el.msMatchesSelector(selector);else {
- compareWith = $(selector);
- for (i = 0; i < compareWith.length; i++) {
- if (compareWith[i] === this[0]) return true;
- }
- return false;
- }
- } else if (selector === document) return this[0] === document;else if (selector === window) return this[0] === window;else {
- if (selector.nodeType || selector instanceof Dom7) {
- compareWith = selector.nodeType ? [selector] : selector;
- for (i = 0; i < compareWith.length; i++) {
- if (compareWith[i] === this[0]) return true;
- }
- return false;
- }
- return false;
- }
- },
- index: function index() {
- if (this[0]) {
- var child = this[0];
- var i = 0;
- while ((child = child.previousSibling) !== null) {
- if (child.nodeType === 1) i++;
- }
- return i;
- } else return undefined;
- },
- eq: function eq(index) {
- if (typeof index === 'undefined') return this;
- var length = this.length;
- var returnIndex;
- if (index > length - 1) {
- return new Dom7([]);
- }
- if (index < 0) {
- returnIndex = length + index;
- if (returnIndex < 0) return new Dom7([]);else return new Dom7([this[returnIndex]]);
- }
- return new Dom7([this[index]]);
- },
- append: function append(newChild) {
- var i, j;
- for (i = 0; i < this.length; i++) {
- if (typeof newChild === 'string') {
- var tempDiv = document.createElement('div');
- tempDiv.innerHTML = newChild;
- while (tempDiv.firstChild) {
- this[i].appendChild(tempDiv.firstChild);
- }
- } else if (newChild instanceof Dom7) {
- for (j = 0; j < newChild.length; j++) {
- this[i].appendChild(newChild[j]);
- }
- } else {
- this[i].appendChild(newChild);
- }
- }
- return this;
- },
- prepend: function prepend(newChild) {
- var i, j;
- for (i = 0; i < this.length; i++) {
- if (typeof newChild === 'string') {
- var tempDiv = document.createElement('div');
- tempDiv.innerHTML = newChild;
- for (j = tempDiv.childNodes.length - 1; j >= 0; j--) {
- this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);
- }
- // this[i].insertAdjacentHTML('afterbegin', newChild);
- } else if (newChild instanceof Dom7) {
- for (j = 0; j < newChild.length; j++) {
- this[i].insertBefore(newChild[j], this[i].childNodes[0]);
- }
- } else {
- this[i].insertBefore(newChild, this[i].childNodes[0]);
- }
- }
- return this;
- },
- insertBefore: function insertBefore(selector) {
- var before = $(selector);
- for (var i = 0; i < this.length; i++) {
- if (before.length === 1) {
- before[0].parentNode.insertBefore(this[i], before[0]);
- } else if (before.length > 1) {
- for (var j = 0; j < before.length; j++) {
- before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]);
- }
- }
- }
- },
- insertAfter: function insertAfter(selector) {
- var after = $(selector);
- for (var i = 0; i < this.length; i++) {
- if (after.length === 1) {
- after[0].parentNode.insertBefore(this[i], after[0].nextSibling);
- } else if (after.length > 1) {
- for (var j = 0; j < after.length; j++) {
- after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling);
- }
- }
- }
- },
- next: function next(selector) {
- if (this.length > 0) {
- if (selector) {
- if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) return new Dom7([this[0].nextElementSibling]);else return new Dom7([]);
- } else {
- if (this[0].nextElementSibling) return new Dom7([this[0].nextElementSibling]);else return new Dom7([]);
- }
- } else return new Dom7([]);
- },
- nextAll: function nextAll(selector) {
- var nextEls = [];
- var el = this[0];
- if (!el) return new Dom7([]);
- while (el.nextElementSibling) {
- var next = el.nextElementSibling;
- if (selector) {
- if ($(next).is(selector)) nextEls.push(next);
- } else nextEls.push(next);
- el = next;
- }
- return new Dom7(nextEls);
- },
- prev: function prev(selector) {
- if (this.length > 0) {
- if (selector) {
- if (this[0].previousElementSibling && $(this[0].previousElementSibling).is(selector)) return new Dom7([this[0].previousElementSibling]);else return new Dom7([]);
- } else {
- if (this[0].previousElementSibling) return new Dom7([this[0].previousElementSibling]);else return new Dom7([]);
- }
- } else return new Dom7([]);
- },
- prevAll: function prevAll(selector) {
- var prevEls = [];
- var el = this[0];
- if (!el) return new Dom7([]);
- while (el.previousElementSibling) {
- var prev = el.previousElementSibling;
- if (selector) {
- if ($(prev).is(selector)) prevEls.push(prev);
- } else prevEls.push(prev);
- el = prev;
- }
- return new Dom7(prevEls);
- },
- parent: function parent(selector) {
- var parents = [];
- for (var i = 0; i < this.length; i++) {
- if (selector) {
- if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);
- } else {
- parents.push(this[i].parentNode);
- }
- }
- return $($.unique(parents));
- },
- parents: function parents(selector) {
- var parents = [];
- for (var i = 0; i < this.length; i++) {
- var parent = this[i].parentNode;
- while (parent) {
- if (selector) {
- if ($(parent).is(selector)) parents.push(parent);
- } else {
- parents.push(parent);
- }
- parent = parent.parentNode;
- }
- }
- return $($.unique(parents));
- },
- find: function find(selector) {
- var foundElements = [];
- for (var i = 0; i < this.length; i++) {
- var found = this[i].querySelectorAll(selector);
- for (var j = 0; j < found.length; j++) {
- foundElements.push(found[j]);
- }
- }
- return new Dom7(foundElements);
- },
- children: function children(selector) {
- var children = [];
- for (var i = 0; i < this.length; i++) {
- var childNodes = this[i].childNodes;
- for (var j = 0; j < childNodes.length; j++) {
- if (!selector) {
- if (childNodes[j].nodeType === 1) children.push(childNodes[j]);
- } else {
- if (childNodes[j].nodeType === 1 && $(childNodes[j]).is(selector)) children.push(childNodes[j]);
- }
- }
- }
- return new Dom7($.unique(children));
- },
- remove: function remove() {
- for (var i = 0; i < this.length; i++) {
- if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);
- }
- return this;
- },
- add: function add() {
- var dom = this;
- var i, j;
- for (i = 0; i < arguments.length; i++) {
- var toAdd = $(arguments[i]);
- for (j = 0; j < toAdd.length; j++) {
- dom[dom.length] = toAdd[j];
- dom.length++;
- }
- }
- return dom;
- }
- };
- $.fn = Dom7.prototype;
- $.unique = function (arr) {
- var unique = [];
- for (var i = 0; i < arr.length; i++) {
- if (unique.indexOf(arr[i]) === -1) unique.push(arr[i]);
- }
- return unique;
- };
- return $;
- }();
- /*===========================
- Get Dom libraries
- ===========================*/
- var swiperDomPlugins = ['jQuery', 'Zepto', 'Dom7'];
- for (var i = 0; i < swiperDomPlugins.length; i++) {
- if (window[swiperDomPlugins[i]]) {
- addLibraryPlugin(window[swiperDomPlugins[i]]);
- }
- }
- // Required DOM Plugins
- var domLib;
- if (typeof Dom7 === 'undefined') {
- domLib = window.Dom7 || window.Zepto || window.jQuery;
- } else {
- domLib = Dom7;
- }
- /*===========================
- Add .swiper plugin from Dom libraries
- ===========================*/
- function addLibraryPlugin(lib) {
- lib.fn.swiper = function (params) {
- var firstInstance;
- lib(this).each(function () {
- var s = new Swiper(this, params);
- if (!firstInstance) firstInstance = s;
- });
- return firstInstance;
- };
- }
- if (domLib) {
- if (!('transitionEnd' in domLib.fn)) {
- domLib.fn.transitionEnd = function (callback) {
- var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'],
- i,
- j,
- dom = this;
- function fireCallBack(e) {
- /*jshint validthis:true */
- if (e.target !== this) return;
- callback.call(this, e);
- for (i = 0; i < events.length; i++) {
- dom.off(events[i], fireCallBack);
- }
- }
- if (callback) {
- for (i = 0; i < events.length; i++) {
- dom.on(events[i], fireCallBack);
- }
- }
- return this;
- };
- }
- if (!('transform' in domLib.fn)) {
- domLib.fn.transform = function (transform) {
- for (var i = 0; i < this.length; i++) {
- var elStyle = this[i].style;
- elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = transform;
- }
- return this;
- };
- }
- if (!('transition' in domLib.fn)) {
- domLib.fn.transition = function (duration) {
- if (typeof duration !== 'string') {
- duration = duration + 'ms';
- }
- for (var i = 0; i < this.length; i++) {
- var elStyle = this[i].style;
- elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration;
- }
- return this;
- };
- }
- if (!('outerWidth' in domLib.fn)) {
- domLib.fn.outerWidth = function (includeMargins) {
- if (this.length > 0) {
- if (includeMargins) return this[0].offsetWidth + parseFloat(this.css('margin-right')) + parseFloat(this.css('margin-left'));else return this[0].offsetWidth;
- } else return null;
- };
- }
- }
- window.Swiper = Swiper;
- })();
- /*===========================
- Swiper AMD Export
- ===========================*/
- if (true) {
- module.exports = window.Swiper;
- } else if (typeof define === 'function' && define.amd) {
- define([], function () {
- 'use strict';
- return window.Swiper;
- });
- }
- //# sourceMappingURL=maps/swiper.js.map
- /***/ }),
- /* 5 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- /*! tether-drop 1.4.1 */
- (function (root, factory) {
- if (true) {
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(34)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
- module.exports = factory(require('tether'));
- } else {
- root.Drop = factory(root.Tether);
- }
- })(undefined, function (Tether) {
- /* global Tether */
- 'use strict';
- var _bind = Function.prototype.bind;
- var _slicedToArray = function () {
- function sliceIterator(arr, i) {
- var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
- _arr.push(_s.value);if (i && _arr.length === i) break;
- }
- } catch (err) {
- _d = true;_e = err;
- } finally {
- try {
- if (!_n && _i['return']) _i['return']();
- } finally {
- if (_d) throw _e;
- }
- }return _arr;
- }return function (arr, i) {
- if (Array.isArray(arr)) {
- return arr;
- } else if (Symbol.iterator in Object(arr)) {
- return sliceIterator(arr, i);
- } else {
- throw new TypeError('Invalid attempt to destructure non-iterable instance');
- }
- };
- }();
- 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;
- };
- }();
- var _get = function get(_x2, _x3, _x4) {
- var _again = true;_function: while (_again) {
- var object = _x2,
- property = _x3,
- receiver = _x4;_again = false;if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) {
- var parent = Object.getPrototypeOf(object);if (parent === null) {
- return undefined;
- } else {
- _x2 = parent;_x3 = property;_x4 = receiver;_again = true;desc = parent = undefined;continue _function;
- }
- } else if ('value' in desc) {
- return desc.value;
- } else {
- var getter = desc.get;if (getter === undefined) {
- return undefined;
- }return getter.call(receiver);
- }
- }
- };
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError('Cannot call a class as a function');
- }
- }
- function _inherits(subClass, superClass) {
- if (typeof superClass !== 'function' && superClass !== null) {
- throw new TypeError('Super expression must either be null or a function, not ' + (typeof superClass === 'undefined' ? 'undefined' : _typeof(superClass)));
- }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
- var _Tether$Utils = Tether.Utils;
- var extend = _Tether$Utils.extend;
- var addClass = _Tether$Utils.addClass;
- var removeClass = _Tether$Utils.removeClass;
- var hasClass = _Tether$Utils.hasClass;
- var Evented = _Tether$Utils.Evented;
- function sortAttach(str) {
- var _str$split = str.split(' ');
- var _str$split2 = _slicedToArray(_str$split, 2);
- var first = _str$split2[0];
- var second = _str$split2[1];
- if (['left', 'right'].indexOf(first) >= 0) {
- var _ref = [second, first];
- first = _ref[0];
- second = _ref[1];
- }
- return [first, second].join(' ');
- }
- function removeFromArray(arr, item) {
- var index = undefined;
- var results = [];
- while ((index = arr.indexOf(item)) !== -1) {
- results.push(arr.splice(index, 1));
- }
- return results;
- }
- var clickEvents = ['click'];
- var transitionEndEvents = {
- 'WebkitTransition': 'webkitTransitionEnd',
- 'MozTransition': 'transitionend',
- 'OTransition': 'otransitionend',
- 'transition': 'transitionend'
- };
- var transitionEndEvent = '';
- for (var _name in transitionEndEvents) {
- if ({}.hasOwnProperty.call(transitionEndEvents, _name)) {
- var tempEl = document.createElement('p');
- if (typeof tempEl.style[_name] !== 'undefined') {
- transitionEndEvent = transitionEndEvents[_name];
- }
- }
- }
- var MIRROR_ATTACH = {
- left: 'right',
- right: 'left',
- top: 'bottom',
- bottom: 'top',
- middle: 'middle',
- center: 'center'
- };
- var allDrops = {};
- // Drop can be included in external libraries. Calling createContext gives you a fresh
- // copy of drop which won't interact with other copies on the page (beyond calling the document events).
- function createContext() {
- var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
- var drop = function drop() {
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- return new (_bind.apply(DropInstance, [null].concat(args)))();
- };
- extend(drop, {
- createContext: createContext,
- drops: [],
- defaults: {}
- });
- var defaultOptions = {
- classPrefix: 'drop',
- defaults: {
- position: 'bottom left',
- openOn: 'click',
- beforeClose: null,
- constrainToScrollParent: true,
- constrainToWindow: true,
- classes: '',
- remove: false,
- openDelay: 0,
- closeDelay: 50,
- // inherited from openDelay and closeDelay if not explicitly defined
- focusDelay: null,
- blurDelay: null,
- hoverOpenDelay: null,
- hoverCloseDelay: null,
- tetherOptions: {}
- }
- };
- extend(drop, defaultOptions, options);
- extend(drop.defaults, defaultOptions.defaults, options.defaults);
- if (typeof allDrops[drop.classPrefix] === 'undefined') {
- allDrops[drop.classPrefix] = [];
- }
- drop.updateBodyClasses = function () {
- // There is only one body, so despite the context concept, we still iterate through all
- // drops which share our classPrefix.
- var anyOpen = false;
- var drops = allDrops[drop.classPrefix];
- var len = drops.length;
- for (var i = 0; i < len; ++i) {
- if (drops[i].isOpened()) {
- anyOpen = true;
- break;
- }
- }
- if (anyOpen) {
- addClass(document.body, drop.classPrefix + '-open');
- } else {
- removeClass(document.body, drop.classPrefix + '-open');
- }
- };
- var DropInstance = function (_Evented) {
- _inherits(DropInstance, _Evented);
- function DropInstance(opts) {
- _classCallCheck(this, DropInstance);
- _get(Object.getPrototypeOf(DropInstance.prototype), 'constructor', this).call(this);
- this.options = extend({}, drop.defaults, opts);
- this.target = this.options.target;
- if (typeof this.target === 'undefined') {
- throw new Error('Drop Error: You must provide a target.');
- }
- var dataPrefix = 'data-' + drop.classPrefix;
- var contentAttr = this.target.getAttribute(dataPrefix);
- if (contentAttr && this.options.content == null) {
- this.options.content = contentAttr;
- }
- var attrsOverride = ['position', 'openOn'];
- for (var i = 0; i < attrsOverride.length; ++i) {
- var override = this.target.getAttribute(dataPrefix + '-' + attrsOverride[i]);
- if (override && this.options[attrsOverride[i]] == null) {
- this.options[attrsOverride[i]] = override;
- }
- }
- if (this.options.classes && this.options.addTargetClasses !== false) {
- addClass(this.target, this.options.classes);
- }
- drop.drops.push(this);
- allDrops[drop.classPrefix].push(this);
- this._boundEvents = [];
- this.bindMethods();
- this.setupElements();
- this.setupEvents();
- this.setupTether();
- }
- _createClass(DropInstance, [{
- key: '_on',
- value: function _on(element, event, handler) {
- this._boundEvents.push({ element: element, event: event, handler: handler });
- element.addEventListener(event, handler);
- }
- }, {
- key: 'bindMethods',
- value: function bindMethods() {
- this.transitionEndHandler = this._transitionEndHandler.bind(this);
- }
- }, {
- key: 'setupElements',
- value: function setupElements() {
- var _this = this;
- this.drop = document.createElement('div');
- addClass(this.drop, drop.classPrefix);
- if (this.options.classes) {
- addClass(this.drop, this.options.classes);
- }
- this.content = document.createElement('div');
- addClass(this.content, drop.classPrefix + '-content');
- if (typeof this.options.content === 'function') {
- var generateAndSetContent = function generateAndSetContent() {
- // content function might return a string or an element
- var contentElementOrHTML = _this.options.content.call(_this, _this);
- if (typeof contentElementOrHTML === 'string') {
- _this.content.innerHTML = contentElementOrHTML;
- } else if ((typeof contentElementOrHTML === 'undefined' ? 'undefined' : _typeof(contentElementOrHTML)) === 'object') {
- _this.content.innerHTML = '';
- _this.content.appendChild(contentElementOrHTML);
- } else {
- throw new Error('Drop Error: Content function should return a string or HTMLElement.');
- }
- };
- generateAndSetContent();
- this.on('open', generateAndSetContent.bind(this));
- } else if (_typeof(this.options.content) === 'object') {
- this.content.appendChild(this.options.content);
- } else {
- this.content.innerHTML = this.options.content;
- }
- this.drop.appendChild(this.content);
- }
- }, {
- key: 'setupTether',
- value: function setupTether() {
- // Tether expects two attachment points, one in the target element, one in the
- // drop. We use a single one, and use the order as well, to allow us to put
- // the drop on either side of any of the four corners. This magic converts between
- // the two:
- var dropAttach = this.options.position.split(' ');
- dropAttach[0] = MIRROR_ATTACH[dropAttach[0]];
- dropAttach = dropAttach.join(' ');
- var constraints = [];
- if (this.options.constrainToScrollParent) {
- constraints.push({
- to: 'scrollParent',
- pin: 'top, bottom',
- attachment: 'together none'
- });
- } else {
- // To get 'out of bounds' classes
- constraints.push({
- to: 'scrollParent'
- });
- }
- if (this.options.constrainToWindow !== false) {
- constraints.push({
- to: 'window',
- attachment: 'together'
- });
- } else {
- // To get 'out of bounds' classes
- constraints.push({
- to: 'window'
- });
- }
- var opts = {
- element: this.drop,
- target: this.target,
- attachment: sortAttach(dropAttach),
- targetAttachment: sortAttach(this.options.position),
- classPrefix: drop.classPrefix,
- offset: '0 0',
- targetOffset: '0 0',
- enabled: false,
- constraints: constraints,
- addTargetClasses: this.options.addTargetClasses
- };
- if (this.options.tetherOptions !== false) {
- this.tether = new Tether(extend({}, opts, this.options.tetherOptions));
- }
- }
- }, {
- key: 'setupEvents',
- value: function setupEvents() {
- var _this2 = this;
- if (!this.options.openOn) {
- return;
- }
- if (this.options.openOn === 'always') {
- setTimeout(this.open.bind(this));
- return;
- }
- var events = this.options.openOn.split(' ');
- if (events.indexOf('click') >= 0) {
- var openHandler = function openHandler(event) {
- _this2.toggle(event);
- event.preventDefault();
- };
- var closeHandler = function closeHandler(event) {
- if (!_this2.isOpened()) {
- return;
- }
- // Clicking inside dropdown
- if (event.target === _this2.drop || _this2.drop.contains(event.target)) {
- return;
- }
- // Clicking target
- if (event.target === _this2.target || _this2.target.contains(event.target)) {
- return;
- }
- _this2.close(event);
- };
- for (var i = 0; i < clickEvents.length; ++i) {
- var clickEvent = clickEvents[i];
- this._on(this.target, clickEvent, openHandler);
- this._on(document, clickEvent, closeHandler);
- }
- }
- var inTimeout = null;
- var outTimeout = null;
- var inHandler = function inHandler(event) {
- if (outTimeout !== null) {
- clearTimeout(outTimeout);
- } else {
- inTimeout = setTimeout(function () {
- _this2.open(event);
- inTimeout = null;
- }, (event.type === 'focus' ? _this2.options.focusDelay : _this2.options.hoverOpenDelay) || _this2.options.openDelay);
- }
- };
- var outHandler = function outHandler(event) {
- if (inTimeout !== null) {
- clearTimeout(inTimeout);
- } else {
- outTimeout = setTimeout(function () {
- _this2.close(event);
- outTimeout = null;
- }, (event.type === 'blur' ? _this2.options.blurDelay : _this2.options.hoverCloseDelay) || _this2.options.closeDelay);
- }
- };
- if (events.indexOf('hover') >= 0) {
- this._on(this.target, 'mouseover', inHandler);
- this._on(this.drop, 'mouseover', inHandler);
- this._on(this.target, 'mouseout', outHandler);
- this._on(this.drop, 'mouseout', outHandler);
- }
- if (events.indexOf('focus') >= 0) {
- this._on(this.target, 'focus', inHandler);
- this._on(this.drop, 'focus', inHandler);
- this._on(this.target, 'blur', outHandler);
- this._on(this.drop, 'blur', outHandler);
- }
- }
- }, {
- key: 'isOpened',
- value: function isOpened() {
- if (this.drop) {
- return hasClass(this.drop, drop.classPrefix + '-open');
- }
- }
- }, {
- key: 'toggle',
- value: function toggle(event) {
- if (this.isOpened()) {
- this.close(event);
- } else {
- this.open(event);
- }
- }
- }, {
- key: 'open',
- value: function open(event) {
- var _this3 = this;
- /* eslint no-unused-vars: 0 */
- if (this.isOpened()) {
- return;
- }
- if (!this.drop.parentNode) {
- document.body.appendChild(this.drop);
- }
- if (typeof this.tether !== 'undefined') {
- this.tether.enable();
- }
- addClass(this.drop, drop.classPrefix + '-open');
- addClass(this.drop, drop.classPrefix + '-open-transitionend');
- setTimeout(function () {
- if (_this3.drop) {
- addClass(_this3.drop, drop.classPrefix + '-after-open');
- }
- });
- if (typeof this.tether !== 'undefined') {
- this.tether.position();
- }
- this.trigger('open');
- drop.updateBodyClasses();
- }
- }, {
- key: '_transitionEndHandler',
- value: function _transitionEndHandler(e) {
- if (e.target !== e.currentTarget) {
- return;
- }
- if (!hasClass(this.drop, drop.classPrefix + '-open')) {
- removeClass(this.drop, drop.classPrefix + '-open-transitionend');
- }
- this.drop.removeEventListener(transitionEndEvent, this.transitionEndHandler);
- }
- }, {
- key: 'beforeCloseHandler',
- value: function beforeCloseHandler(event) {
- var shouldClose = true;
- if (!this.isClosing && typeof this.options.beforeClose === 'function') {
- this.isClosing = true;
- shouldClose = this.options.beforeClose(event, this) !== false;
- }
- this.isClosing = false;
- return shouldClose;
- }
- }, {
- key: 'close',
- value: function close(event) {
- if (!this.isOpened()) {
- return;
- }
- if (!this.beforeCloseHandler(event)) {
- return;
- }
- removeClass(this.drop, drop.classPrefix + '-open');
- removeClass(this.drop, drop.classPrefix + '-after-open');
- this.drop.addEventListener(transitionEndEvent, this.transitionEndHandler);
- this.trigger('close');
- if (typeof this.tether !== 'undefined') {
- this.tether.disable();
- }
- drop.updateBodyClasses();
- if (this.options.remove) {
- this.remove(event);
- }
- }
- }, {
- key: 'remove',
- value: function remove(event) {
- this.close(event);
- if (this.drop.parentNode) {
- this.drop.parentNode.removeChild(this.drop);
- }
- }
- }, {
- key: 'position',
- value: function position() {
- if (this.isOpened() && typeof this.tether !== 'undefined') {
- this.tether.position();
- }
- }
- }, {
- key: 'destroy',
- value: function destroy() {
- this.remove();
- if (typeof this.tether !== 'undefined') {
- this.tether.destroy();
- }
- for (var i = 0; i < this._boundEvents.length; ++i) {
- var _boundEvents$i = this._boundEvents[i];
- var element = _boundEvents$i.element;
- var _event = _boundEvents$i.event;
- var handler = _boundEvents$i.handler;
- element.removeEventListener(_event, handler);
- }
- this._boundEvents = [];
- this.tether = null;
- this.drop = null;
- this.content = null;
- this.target = null;
- removeFromArray(allDrops[drop.classPrefix], this);
- removeFromArray(drop.drops, this);
- }
- }]);
- return DropInstance;
- }(Evented);
- return drop;
- }
- var Drop = createContext();
- document.addEventListener('DOMContentLoaded', function () {
- Drop.updateBodyClasses();
- });
- return Drop;
- });
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- 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; }; }();
- var _jquery = __webpack_require__(1);
- var _jquery2 = _interopRequireDefault(_jquery);
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-beta): collapse.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
- */
- var Collapse = function () {
- /**
- * ------------------------------------------------------------------------
- * Constants
- * ------------------------------------------------------------------------
- */
- var NAME = 'collapse';
- var VERSION = '4.0.0-beta';
- var DATA_KEY = 'bs.collapse';
- var EVENT_KEY = '.' + DATA_KEY;
- var DATA_API_KEY = '.data-api';
- var JQUERY_NO_CONFLICT = _jquery2.default.fn[NAME];
- var TRANSITION_DURATION = 600;
- var Default = {
- toggle: true,
- parent: ''
- };
- var DefaultType = {
- toggle: 'boolean',
- parent: '(string|element)'
- };
- var Event = {
- SHOW: 'show' + EVENT_KEY,
- SHOWN: 'shown' + EVENT_KEY,
- HIDE: 'hide' + EVENT_KEY,
- HIDDEN: 'hidden' + EVENT_KEY,
- CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
- };
- var ClassName = {
- SHOW: 'show',
- COLLAPSE: 'collapse',
- COLLAPSING: 'collapsing',
- COLLAPSED: 'collapsed'
- };
- var Dimension = {
- WIDTH: 'width',
- HEIGHT: 'height'
- };
- var Selector = {
- ACTIVES: '.show, .collapsing',
- DATA_TOGGLE: '[data-toggle="lu-collapse"]'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
- };
- var Collapse = function () {
- function Collapse(element, config) {
- _classCallCheck(this, Collapse);
- this._isTransitioning = false;
- this._element = element;
- this._config = this._getConfig(config);
- this._triggerArray = _jquery2.default.makeArray((0, _jquery2.default)('[data-toggle="lu-collapse"][href="#' + element.id + '"],' + ('[data-toggle="lu-collapse"][data-target="#' + element.id + '"]')));
- var tabToggles = (0, _jquery2.default)(Selector.DATA_TOGGLE);
- for (var i = 0; i < tabToggles.length; i++) {
- var elem = tabToggles[i];
- var selector = _util2.default.getSelectorFromElement(elem);
- if (selector !== null && (0, _jquery2.default)(selector).filter(element).length > 0) {
- this._triggerArray.push(elem);
- }
- }
- this._parent = this._config.parent ? this._getParent() : null;
- if (!this._config.parent) {
- this._addAriaAndCollapsedClass(this._element, this._triggerArray);
- }
- if (this._config.toggle) {
- this.toggle();
- }
- }
- // getters
- _createClass(Collapse, [{
- key: 'toggle',
- // public
- value: function toggle() {
- if ((0, _jquery2.default)(this._element).hasClass(ClassName.SHOW)) {
- this.hide();
- } else {
- this.show();
- }
- }
- }, {
- key: 'show',
- value: function show() {
- var _this = this;
- if (this._isTransitioning || (0, _jquery2.default)(this._element).hasClass(ClassName.SHOW)) {
- return;
- }
- var actives = void 0;
- var activesData = void 0;
- if (this._parent) {
- actives = _jquery2.default.makeArray((0, _jquery2.default)(this._parent).children().children(Selector.ACTIVES));
- if (!actives.length) {
- actives = null;
- }
- }
- if (actives) {
- activesData = (0, _jquery2.default)(actives).data(DATA_KEY);
- if (activesData && activesData._isTransitioning) {
- return;
- }
- }
- var startEvent = _jquery2.default.Event(Event.SHOW);
- (0, _jquery2.default)(this._element).trigger(startEvent);
- if (startEvent.isDefaultPrevented()) {
- return;
- }
- if (actives) {
- Collapse._jQueryInterface.call((0, _jquery2.default)(actives), 'hide');
- if (!activesData) {
- (0, _jquery2.default)(actives).data(DATA_KEY, null);
- }
- }
- var dimension = this._getDimension();
- (0, _jquery2.default)(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING);
- this._element.style[dimension] = 0;
- if (this._triggerArray.length) {
- (0, _jquery2.default)(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true);
- }
- this.setTransitioning(true);
- var complete = function complete() {
- (0, _jquery2.default)(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW);
- _this._element.style[dimension] = '';
- _this.setTransitioning(false);
- (0, _jquery2.default)(_this._element).trigger(Event.SHOWN);
- };
- if (!_util2.default.supportsTransitionEnd()) {
- complete();
- return;
- }
- var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
- var scrollSize = 'scroll' + capitalizedDimension;
- (0, _jquery2.default)(this._element).one(_util2.default.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
- this._element.style[dimension] = this._element[scrollSize] + 'px';
- }
- }, {
- key: 'hide',
- value: function hide() {
- var _this2 = this;
- if (this._isTransitioning || !(0, _jquery2.default)(this._element).hasClass(ClassName.SHOW)) {
- return;
- }
- var startEvent = _jquery2.default.Event(Event.HIDE);
- (0, _jquery2.default)(this._element).trigger(startEvent);
- if (startEvent.isDefaultPrevented()) {
- return;
- }
- var dimension = this._getDimension();
- this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + 'px';
- _util2.default.reflow(this._element);
- (0, _jquery2.default)(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW);
- if (this._triggerArray.length) {
- for (var i = 0; i < this._triggerArray.length; i++) {
- var trigger = this._triggerArray[i];
- var selector = _util2.default.getSelectorFromElement(trigger);
- if (selector !== null) {
- var $elem = (0, _jquery2.default)(selector);
- if (!$elem.hasClass(ClassName.SHOW)) {
- (0, _jquery2.default)(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false);
- }
- }
- }
- }
- this.setTransitioning(true);
- var complete = function complete() {
- _this2.setTransitioning(false);
- (0, _jquery2.default)(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN);
- };
- this._element.style[dimension] = '';
- if (!_util2.default.supportsTransitionEnd()) {
- complete();
- return;
- }
- (0, _jquery2.default)(this._element).one(_util2.default.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
- }
- }, {
- key: 'setTransitioning',
- value: function setTransitioning(isTransitioning) {
- this._isTransitioning = isTransitioning;
- }
- }, {
- key: 'dispose',
- value: function dispose() {
- _jquery2.default.removeData(this._element, DATA_KEY);
- this._config = null;
- this._parent = null;
- this._element = null;
- this._triggerArray = null;
- this._isTransitioning = null;
- }
- // private
- }, {
- key: '_getConfig',
- value: function _getConfig(config) {
- config = _jquery2.default.extend({}, Default, config);
- config.toggle = Boolean(config.toggle); // coerce string values
- _util2.default.typeCheckConfig(NAME, config, DefaultType);
- return config;
- }
- }, {
- key: '_getDimension',
- value: function _getDimension() {
- var hasWidth = (0, _jquery2.default)(this._element).hasClass(Dimension.WIDTH);
- return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
- }
- }, {
- key: '_getParent',
- value: function _getParent() {
- var _this3 = this;
- var parent = null;
- if (_util2.default.isElement(this._config.parent)) {
- parent = this._config.parent;
- // it's a jQuery object
- if (typeof this._config.parent.jquery !== 'undefined') {
- parent = this._config.parent[0];
- }
- } else {
- parent = (0, _jquery2.default)(this._config.parent)[0];
- }
- var selector = '[data-toggle="lu-collapse"][data-parent="' + this._config.parent + '"]';
- (0, _jquery2.default)(parent).find(selector).each(function (i, element) {
- _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
- });
- return parent;
- }
- }, {
- key: '_addAriaAndCollapsedClass',
- value: function _addAriaAndCollapsedClass(element, triggerArray) {
- if (element) {
- var isOpen = (0, _jquery2.default)(element).hasClass(ClassName.SHOW);
- if (triggerArray.length) {
- (0, _jquery2.default)(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
- }
- }
- }
- // static
- }], [{
- key: '_getTargetFromElement',
- value: function _getTargetFromElement(element) {
- var selector = _util2.default.getSelectorFromElement(element);
- return selector ? (0, _jquery2.default)(selector)[0] : null;
- }
- }, {
- key: '_jQueryInterface',
- value: function _jQueryInterface(config) {
- return this.each(function () {
- var $this = (0, _jquery2.default)(this);
- var data = $this.data(DATA_KEY);
- var _config = _jquery2.default.extend({}, Default, $this.data(), (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config);
- if (!data && _config.toggle && /show|hide/.test(config)) {
- _config.toggle = false;
- }
- if (!data) {
- data = new Collapse(this, _config);
- $this.data(DATA_KEY, data);
- }
- if (typeof config === 'string') {
- if (typeof data[config] === 'undefined') {
- throw new Error('No method named "' + config + '"');
- }
- data[config]();
- }
- });
- }
- }, {
- key: 'VERSION',
- get: function get() {
- return VERSION;
- }
- }, {
- key: 'Default',
- get: function get() {
- return Default;
- }
- }]);
- return Collapse;
- }();
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
- (0, _jquery2.default)(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
- // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
- if (event.currentTarget.tagName === 'A') {
- event.preventDefault();
- }
- var $trigger = (0, _jquery2.default)(this);
- var selector = _util2.default.getSelectorFromElement(this);
- (0, _jquery2.default)(selector).each(function () {
- var $target = (0, _jquery2.default)(this);
- var data = $target.data(DATA_KEY);
- var config = data ? 'toggle' : $trigger.data();
- Collapse._jQueryInterface.call($target, config);
- });
- });
- /**
- * ------------------------------------------------------------------------
- * jQuery
- * ------------------------------------------------------------------------
- */
- _jquery2.default.fn[NAME] = Collapse._jQueryInterface;
- _jquery2.default.fn[NAME].Constructor = Collapse;
- _jquery2.default.fn[NAME].noConflict = function () {
- _jquery2.default.fn[NAME] = JQUERY_NO_CONFLICT;
- return Collapse._jQueryInterface;
- };
- return Collapse;
- }(_jquery2.default);
- exports.default = Collapse;
- /***/ }),
- /* 7 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _Swiper = __webpack_require__(4);
- var _Swiper2 = _interopRequireDefault(_Swiper);
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- container: '[data-content-slider]'
- };
- var Default = {
- slideToClickedSlide: false,
- navStorage: 'normal'
- };
- var contentSlider = function () {
- function contentSlider(container, options) {
- _classCallCheck(this, contentSlider);
- this.container = container;
- this.options = options;
- this.isInit = false;
- this.getConfig();
- this.initPLugin();
- this.bindEvents();
- }
- _createClass(contentSlider, [{
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.container.data();
- if (dataConfig.options) {
- this.dataOptions = _util2.default.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- }
- }, {
- key: 'bindEvents',
- value: function bindEvents() {}
- }, {
- key: 'initPLugin',
- value: function initPLugin() {
- var that = this;
- this.swiperInstance = new _Swiper2.default(this.container, {
- scrollbarHide: true,
- effect: false,
- resistance: true,
- resistanceRatio: 0,
- slidesPerView: 'auto',
- watchSlidesVisibility: true,
- onInit: function onInit(swiper) {
- that.onInit(swiper);
- },
- onTap: function onTap(swiper, event) {
- that.changeActiveSlide(swiper);
- if (that.config.slideToClickedSlide) {
- that.slideToClickedSlide(swiper, event);
- }
- that.onClick();
- }
- });
- }
- }, {
- key: 'changeActiveSlide',
- value: function changeActiveSlide(swiper) {
- if (!this.isInit) {
- return;
- }
- var slides = swiper.slides;
- switch (this.config.navStorage) {
- case 'normal':
- break;
- case 'hash':
- break;
- case 'localStorage':
- $(slides).removeClass('is-active');
- window.localStorage.setItem('content-slider-' + this.config.localStorageId, swiper.clickedIndex);
- break;
- }
- }
- }, {
- key: 'slideToClickedSlide',
- value: function slideToClickedSlide(swiper, event) {
- var clickedIndex = swiper.clickedIndex,
- slides = swiper.slides;
- swiper.updateActiveIndex();
- if (!$(slides[clickedIndex - 1]).hasClass('swiper-slide-visible')) {
- swiper.slideTo(swiper.activeIndex - 1);
- }
- if (!$(slides[clickedIndex + 1]).hasClass('swiper-slide-visible')) {
- swiper.slideTo(swiper.activeIndex + 1);
- }
- }
- }, {
- key: 'onInit',
- value: function onInit(swiper) {
- switch (this.config.navStorage) {
- case 'normal':
- var activeSlideIndex = 0,
- slides = swiper.slides;
- $(slides).each(function (index) {
- if ($(this).hasClass('is-active')) {
- activeSlideIndex = index;
- }
- });
- swiper.slideTo(activeSlideIndex, 0);
- break;
- case 'hash':
- if (window.location.hash) {
- var slide = $(swiper.container).find('[href="' + window.location.hash + '"]'),
- slideIndex = slide.closest('.swiper-slide').index();
- slide.trigger('click');
- swiper.slideTo(slideIndex, 0);
- }
- break;
- case 'localStorage':
- var index = window.localStorage.getItem('content-slider-' + this.config.localStorageId);
- if (index) {
- swiper.slideTo(index, 0);
- } else {
- swiper.slideTo(0, 0);
- }
- $(swiper.slides[index]).find('a').trigger('click');
- break;
- }
- this.showSlider(swiper);
- this.isInit = true;
- }
- }, {
- key: 'showSlider',
- value: function showSlider(swiper) {
- swiper.container.css({
- visibility: 'visible'
- });
- }
- }, {
- key: 'onClick',
- value: function onClick() {}
- }, {
- key: 'onSlideChangeStart',
- value: function onSlideChangeStart() {}
- }, {
- key: 'onSlideChangeEnd',
- value: function onSlideChangeEnd() {}
- }]);
- return contentSlider;
- }();
- function initDataSelectors() {
- $(SELECTORS.container).each(function () {
- new contentSlider($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luContentSlider = function (options) {
- return this.each(function () {
- new contentSlider($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _drop = __webpack_require__(5);
- var _drop2 = _interopRequireDefault(_drop);
- var _selectInput = __webpack_require__(3);
- var _selectInput2 = _interopRequireDefault(_selectInput);
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- dropdownToggle: '[data-toggle="lu-dropdown"], [data-dropdown]',
- dropdownParent: '.has-dropdown',
- dropdownMenu: '[data-dropdown-menu]',
- dropdownArrowTarget: '[data-arrow-target]',
- dropdownPlacement: '[data-placement]',
- dropdownOpen: '[data-open]',
- dropdownClasses: '[data-class]',
- width: '[data-width]'
- };
- var Default = {
- open: 'click',
- placement: 'bottom left',
- width: null,
- class: ''
- };
- var dropdown = function () {
- function dropdown(_dropdown, options) {
- _classCallCheck(this, dropdown);
- this.dropdown = $(_dropdown);
- this.options = options;
- this.dropdownParent = this.dropdown.closest(SELECTORS.dropdownParent);
- this.dropdownArrowTarget = $(this.dropdownParent).find(SELECTORS.dropdownArrowTarget);
- this.dropdownToggle = $(this.dropdownParent).find(SELECTORS.dropdownToggle);
- this.dropdownMenu = $(this.dropdownParent).find(SELECTORS.dropdownMenu);
- this.getConfig();
- this.initPlugin();
- this.bindEvents();
- if (this.dropdown.find('[data-input-content-target]').length) {
- this.initSelect();
- }
- }
- _createClass(dropdown, [{
- key: 'bindEvents',
- value: function bindEvents() {
- this.dropdown.on('closeDropdown', this.close.bind(this));
- this.dropdown.on('openDropdown', this.open.bind(this));
- }
- }, {
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.dropdown.data();
- if (dataConfig.options) {
- this.dataOptions = _util2.default.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- this.setDropdownWidth();
- if (!this.dropdownArrowTarget.length) {
- this.dropdownArrowTarget = this.dropdown;
- }
- }
- }, {
- key: 'initPlugin',
- value: function initPlugin() {
- this.drop = new _drop2.default({
- target: this.dropdown[0],
- content: this.dropdownMenu[0],
- position: this.config.placement,
- classes: this.config.class,
- openOn: this.config.open
- });
- if (this.config.onInit) {
- this.config.onInit(this.drop);
- }
- this.drop.on('open', this.onOpen.bind(this));
- this.drop.on('close', this.onClose.bind(this));
- }
- }, {
- key: 'getArrowTargetPoition',
- value: function getArrowTargetPoition() {
- var dropdownOffset = this.dropdown.offset();
- var arrowTargetOffset = this.dropdownArrowTarget.offset();
- var arrowTargetWidth = this.dropdownArrowTarget.outerWidth();
- if (/left/i.test(this.config.placement)) {
- this.arrowTargetPosition = arrowTargetOffset.left - dropdownOffset.left + arrowTargetWidth / 2;
- } else if (/right/i.test(this.config.placement)) {
- this.arrowTargetPosition = this.dropdown.outerWidth() - (arrowTargetOffset.left - dropdownOffset.left) - arrowTargetWidth / 2;
- }
- }
- }, {
- key: 'setArrowPostion',
- value: function setArrowPostion() {
- var arrow = $(this.drop.drop).find('[data-arrow]');
- if (!arrow) {
- return;
- }
- this.getArrowTargetPoition();
- var arrowBorderWidth = arrow.outerWidth() / 2;
- if (/center/i.test(this.config.placement)) {
- arrow.css({
- left: '0',
- right: '0',
- margin: 'auto'
- });
- } else if (/left/i.test(this.config.placement)) {
- arrow.css({
- left: this.arrowTargetPosition - arrowBorderWidth
- });
- } else if (/right/i.test(this.config.placement)) {
- arrow.css({
- left: 'auto',
- right: this.arrowTargetPosition - arrowBorderWidth
- });
- }
- }
- }, {
- key: 'setDropdownWidth',
- value: function setDropdownWidth() {
- if (!this.config.width) {
- return;
- }
- $(this.dropdownMenu).css({ opacity: 0, position: 'absolute', left: -10000 });
- var width = parseInt(this.config.width);
- var parentWidth = this.dropdownParent.outerWidth();
- $(this.dropdownMenu).css({
- width: width * parentWidth / 100,
- 'min-width': width * parentWidth / 100
- });
- $(this.dropdownMenu).css({ opacity: '', position: '', left: '' });
- }
- }, {
- key: 'onOpen',
- value: function onOpen() {
- this.setArrowPostion();
- this.setDropdownWidth();
- if (typeof this.config.onOpen === 'function') {
- this.config.onOpen(this.drop);
- }
- }
- }, {
- key: 'onClose',
- value: function onClose() {
- if (typeof this.config.onClose === 'function') {
- this.config.onClose(this.drop);
- }
- }
- }, {
- key: 'open',
- value: function open() {
- this.drop.open();
- }
- }, {
- key: 'close',
- value: function close() {
- this.drop.close();
- }
- }, {
- key: 'initSelect',
- value: function initSelect() {
- _selectInput2.default.init($(this.drop.drop), this.drop);
- }
- }]);
- return dropdown;
- }();
- function initDataSelectors() {
- $(SELECTORS.dropdownToggle).each(function () {
- new dropdown($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luDropdown = function (options) {
- return this.each(function () {
- new dropdown($(this), options);
- });
- };
- }
- function closeAllDropdowns() {
- for (var i = 0; i < _drop2.default.drops.length; i++) {
- _drop2.default.drops[i].close();
- }
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin,
- closeAllDropdowns: closeAllDropdowns
- };
- exports.default = init;
- /***/ }),
- /* 9 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _drop = __webpack_require__(5);
- var _drop2 = _interopRequireDefault(_drop);
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- toggle: '[data-toggle="lu-tooltip"], [data-tooltip]'
- };
- var Default = {
- open: 'hover',
- placement: 'top center',
- class: 'lu-tooltip'
- };
- var tooltip = function () {
- function tooltip(_tooltip, options) {
- _classCallCheck(this, tooltip);
- this.tooltip = $(_tooltip);
- this.options = options;
- this.getConfig();
- this.getContent();
- this.initPlugin();
- }
- _createClass(tooltip, [{
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.tooltip.data();
- if (dataConfig.options) {
- this.dataOptions = _util2.default.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- }
- }, {
- key: 'getContent',
- value: function getContent() {
- if ($(this.tooltip).attr('data-title')) {
- this.tooltipContent = $(this.tooltip).attr('data-title');
- } else {
- $(this.tooltip).attr('data-title', $(this.tooltip).attr('title'));
- $(this.tooltip).removeAttr('title');
- this.tooltipContent = $(this.tooltip).attr('data-title');
- }
- }
- }, {
- key: 'initPlugin',
- value: function initPlugin() {
- this.drop = new _drop2.default({
- target: this.tooltip[0],
- content: this.tooltipContent,
- position: this.config.placement,
- classes: this.config.class,
- openOn: this.config.open
- });
- this.drop.on('open', this.onOpen.bind(this));
- }
- }, {
- key: 'getArrowTargetPoition',
- value: function getArrowTargetPoition() {
- var tooltipwitdh = this.tooltip.outerWidth();
- if (/left/i.test(this.config.placement)) {
- this.arrowTargetPosition = tooltipwitdh / 2;
- } else if (/right/i.test(this.config.placement)) {
- this.arrowTargetPosition = tooltipwitdh / 2;
- }
- }
- }, {
- key: 'setArrowPostion',
- value: function setArrowPostion() {
- console.log(this.drop.drop);
- $(this.drop.drop).find('.lu-tooltip__arrow').remove();
- $(this.drop.drop).append('<div class="lu-tooltip__arrow" data-arrow></div>');
- var arrow = $(this.drop.drop).find('[data-arrow]');
- if (!arrow) {
- return;
- }
- this.getArrowTargetPoition();
- var arrowBorderWidth = arrow.outerWidth() / 2;
- if (/center/i.test(this.config.placement)) {
- arrow.css({
- left: '0',
- right: '0',
- margin: 'auto'
- });
- } else if (/left/i.test(this.config.placement)) {
- arrow.css({
- left: this.arrowTargetPosition,
- marginLeft: -arrowBorderWidth
- });
- } else if (/right/i.test(this.config.placement)) {
- arrow.css({
- left: 'auto',
- right: this.arrowTargetPosition,
- marginRight: -arrowBorderWidth
- });
- }
- }
- }, {
- key: 'onOpen',
- value: function onOpen() {
- this.setArrowPostion();
- }
- }]);
- return tooltip;
- }();
- function initDataSelectors() {
- $(SELECTORS.toggle).each(function () {
- new tooltip($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luTooltip = function (options) {
- return this.each(function () {
- new tooltip($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- container: '[data-check-container]',
- checkAll: '[data-check-all]',
- childs: 'input:checkbox.table-mass-action-check:enabled',
- counterView: '[data-checkbox-counter]'
- };
- var Default = {};
- var CheckAll = function () {
- function CheckAll(container, options) {
- _classCallCheck(this, CheckAll);
- this.container = container;
- this.checkAllBtn = this.container.find(SELECTORS.checkAll);
- this.childs = this.container.find(SELECTORS.childs).not(SELECTORS.checkAll);
- this.counterView = this.container.find(SELECTORS.counterView);
- this.checkCounter = 0;
- this.options = options;
- this.getConfig();
- this.initCounter();
- this.bindEvents();
- }
- _createClass(CheckAll, [{
- key: 'bindEvents',
- value: function bindEvents() {
- this.checkAllBtn.on('change', this.checkAll.bind(this));
- this.childs.on('change', this.updateCounter.bind(this));
- }
- }, {
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.container.data();
- if (dataConfig.options) {
- this.dataOptions = _util2.default.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- }
- }, {
- key: 'checkAll',
- value: function checkAll(event) {
- this.childs.prop('checked', event.target.checked);
- if (event.target.checked) {
- this.checkCounter = this.childs.length;
- } else {
- this.checkCounter = 0;
- }
- this.updateCounterView();
- }
- }, {
- key: 'toggleCheckAllBtn',
- value: function toggleCheckAllBtn() {
- if (this.childs.length == this.checkCounter) {
- this.checkAllBtn.prop('checked', true);
- } else {
- this.checkAllBtn.prop('checked', false);
- }
- if (typeof this.config.onCheckAll === 'function') {
- this.config.onCheckAll(this.container, this.checkCounter);
- }
- }
- }, {
- key: 'initCounter',
- value: function initCounter() {
- if (this.checkAllBtn.is(':checked')) {
- this.checkCounter = this.childs.length;
- this.childs.prop('checked', true);
- } else {
- this.checkCounter = this.childs.filter(':checked').length;
- }
- }
- }, {
- key: 'updateCounter',
- value: function updateCounter(event) {
- if (event.target.checked) {
- this.checkCounter++;
- this.toggleCheckAllBtn();
- } else {
- this.checkCounter--;
- this.toggleCheckAllBtn();
- }
- this.updateCounterView();
- }
- }, {
- key: 'updateCounterView',
- value: function updateCounterView() {
- if (typeof this.config.onCheck === 'function') {
- this.config.onCheck(this.container, this.checkCounter);
- }
- this.counterView.text(this.checkCounter);
- }
- }]);
- return CheckAll;
- }();
- function initDataSelectors() {
- $(SELECTORS.container).each(function () {
- new CheckAll($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luCheckAll = function (options) {
- return this.each(function () {
- new CheckAll($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 11 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var forms = [].slice.call(document.querySelectorAll('.lu-form-control'));
- forms.forEach(function (item) {
- var $item = $(item);
- item.addEventListener('focus', function () {
- $item.closest('.lu-input-group').addClass('is-focus');
- });
- item.addEventListener('blur', function () {
- $item.closest('.lu-input-group').removeClass('is-focus');
- });
- });
- /***/ }),
- /* 12 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- __webpack_require__(32);
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- container: '[data-range-slider]',
- input: 'input',
- slider: '[data-slider]'
- };
- var rangeSlider = function () {
- function rangeSlider(container) {
- _classCallCheck(this, rangeSlider);
- this.container = container;
- this.input = this.container.find(SELECTORS.input);
- this.slider = this.container.find(SELECTORS.slider);
- this.config = this.container.data();
- this.value = this.input.val();
- this.bindEvents();
- this.initSlider();
- }
- _createClass(rangeSlider, [{
- key: 'bindEvents',
- value: function bindEvents() {
- this.input.on('change', this.updateSlider.bind(this));
- }
- }, {
- key: 'initSlider',
- value: function initSlider() {
- var that = this;
- this.sliderInstance = $(this.slider).slider({
- range: "min",
- value: this.value,
- min: this.config.min,
- max: this.config.max,
- step: this.config.step,
- slide: function slide(event, ui) {
- that.updateInput(ui.value);
- }
- });
- }
- }, {
- key: 'updateInput',
- value: function updateInput(value) {
- this.input.val(value);
- }
- }, {
- key: 'updateSlider',
- value: function updateSlider(evnet) {
- this.sliderInstance.slider("value", event.target.value);
- }
- }], [{
- key: 'init',
- value: function init(container) {
- if (container) {
- new rangeSlider($(container).find(SELECTORS.container));
- } else {
- $(SELECTORS.container).each(function () {
- new rangeSlider($(this));
- });
- }
- }
- }, {
- key: 'reload',
- value: function reload(container) {}
- }]);
- return rangeSlider;
- }();
- function initDataSelectors() {
- $(SELECTORS.select).each(function () {
- new Select($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luSelect = function (options) {
- return this.each(function () {
- new Select($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = rangeSlider;
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _Selectize = __webpack_require__(29);
- var _Selectize2 = _interopRequireDefault(_Selectize);
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- //init selects only inside of #layers in order not to break other templates
- var SELECTORS = {
- select: '#layers select',
- rawSelect: '#layers .lu-form-control--basic'
- };
- var Default = {
- maxItems: 1,
- removeButton: false,
- resotreOnBackspace: false,
- dragAndDrop: false
- };
- var Select = function () {
- function Select(element, options) {
- _classCallCheck(this, Select);
- this.element = element;
- this.options = options;
- this.getConfig();
- this.directionDetector();
- this.additionalPlugins();
- this.initPlugin();
- }
- _createClass(Select, [{
- key: 'initPlugin',
- value: function initPlugin() {
- var plugins = this.additionalPlugins();
- this.element.selectize({
- placeholder: '',
- maxItems: this.config.maxItems,
- createOnBlur: true,
- plugins: plugins,
- copyClassesToDropdown: false
- });
- }
- }, {
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.element.data();
- if (dataConfig.options) {
- this.dataOptions = _util2.default.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- }
- }, {
- key: 'directionDetector',
- value: function directionDetector() {
- _Selectize2.default.define('directionDetector', function (options) {
- var self = this;
- this.positionDropdown = function () {
- var original = self.positionDropdown;
- return function () {
- this.offset = this.settings.dropdownParent === 'body' ? this.$control.offset() : this.$control.position();
- this.offset.top += this.$control.outerHeight(true);
- var controlHeight = this.$control.innerHeight();
- var controlPositon = $(this.$control).offset().top - $(window).scrollTop();
- var dropdownOffset = controlHeight + controlPositon + this.$dropdown.outerHeight(true);
- if ($(window).innerHeight() - dropdownOffset < 0) {
- this.$dropdown.css({
- 'top': 'auto',
- 'bottom': 8 + controlHeight,
- 'left': this.offset.left,
- 'width': this.$control[0].getBoundingClientRect().width
- });
- } else {
- this.$dropdown.css({
- 'width': this.$control[0].getBoundingClientRect().width,
- 'top': this.offset.top,
- 'left': this.offset.left,
- 'bottom': 'auto'
- });
- }
- };
- }();
- });
- }
- }, {
- key: 'additionalPlugins',
- value: function additionalPlugins() {
- var plugins = ['directionDetector'];
- if (this.config.removeButton) {
- plugins.push('remove_button');
- }
- if (this.config.resotreOnBackspace) {
- plugins.push('restore_on_backspace');
- }
- if (this.config.drag_drop) {
- plugins.push('drag_drop');
- }
- return plugins;
- }
- }]);
- return Select;
- }();
- function initDataSelectors() {
- // $(SELECTORS.select).not(SELECTORS.rawSelect).each(function () {
- // new Select($(this));
- // });
- }
- function initJqueryPlugin() {
- $.fn.luSelect = function (options) {
- return this.each(function () {
- new Select($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _autosize = __webpack_require__(30);
- var _autosize2 = _interopRequireDefault(_autosize);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- container: '[data-editable-cell]',
- input: '[data-editable-input]',
- content: '[data-editable-contnet]',
- init: '[data-init-edit]',
- abort: '[data-abort-edit]',
- accept: '[data-accept-edit]'
- };
- var Default = {};
- var editableCell = function () {
- function editableCell(container, options) {
- _classCallCheck(this, editableCell);
- this.container = container;
- this.options = options;
- this.input = this.container.find(SELECTORS.input);
- this.content = this.container.find(SELECTORS.content);
- this.init = this.container.find(SELECTORS.init);
- this.abort = this.container.find(SELECTORS.abort);
- this.accept = this.container.find(SELECTORS.accept);
- this.oldInputValue = this.input.val().trim();
- this.getConfig();
- this.initEvents();
- this.trimInputContent();
- this.textareaAutosize();
- this.blockNewLine();
- }
- _createClass(editableCell, [{
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.container.data();
- if (dataConfig.options) {
- this.dataOptions = util.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- }
- }, {
- key: 'bindEvents',
- value: function bindEvents() {
- $(this.init).on('click', this.initEdit.bind(this));
- $(this.abort).on('click', this.abortEdit.bind(this));
- $(this.accept).on('click', this.acceptEdit.bind(this));
- }
- }, {
- key: 'initEdit',
- value: function initEdit(event) {
- this.content.addClass('hidden');
- this.init.addClass('hidden');
- this.accept.removeClass('hidden');
- this.abort.removeClass('hidden');
- this.input.removeClass('hidden');
- this.textareaAutosizeUpdate();
- $(this.input).focus();
- }
- }, {
- key: 'abortEdit',
- value: function abortEdit(event) {
- this.content.removeClass('hidden');
- this.init.removeClass('hidden');
- this.accept.addClass('hidden');
- this.abort.addClass('hidden');
- this.input.addClass('hidden');
- this.input.val(this.oldInputValue);
- }
- }, {
- key: 'textareaAutosize',
- value: function textareaAutosize() {
- (0, _autosize2.default)(this.input);
- }
- }, {
- key: 'textareaAutosizeUpdate',
- value: function textareaAutosizeUpdate() {
- _autosize2.default.update(this.input);
- }
- }, {
- key: 'trimInputContent',
- value: function trimInputContent() {
- $(this.input).val($(this.input).val().trim());
- }
- }, {
- key: 'blockNewLine',
- value: function blockNewLine() {
- $(this.input).on('keypress', function (e) {
- if ((e.keyCode || e.which) == 13) {
- e.preventDefault();
- }
- });
- }
- }, {
- key: 'acceptEdit',
- value: function acceptEdit(event) {
- this.content.text(this.input.val());
- this.content.removeClass('hidden');
- this.init.removeClass('hidden');
- this.accept.addClass('hidden');
- this.abort.addClass('hidden');
- this.input.addClass('hidden');
- }
- }]);
- return editableCell;
- }();
- function initDataSelectors() {
- $(SELECTORS.container).each(function () {
- new editableCell($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luEditableCell = function (options) {
- return this.each(function () {
- new editableCell($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 15 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _toastr = __webpack_require__(35);
- var _toastr2 = _interopRequireDefault(_toastr);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- /**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-beta): alert.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
- */
- var alert = {
- init: function init() {
- this.cacheDom();
- this.bindEvents();
- },
- cacheDom: function cacheDom() {
- this.$showAlert = $("[data-toggle='lu-alert']");
- this.$alertFixedTop = $('.alert--fixed-top');
- this.$alertFixedBottom = $('.alert--fixed-bottom');
- },
- bindEvents: function bindEvents() {
- this.$showAlert.on('click', this.getData.bind(this));
- },
- //default settings
- settings: function settings() {
- // alert icon true by default
- if (this.$alertIcon == false) {
- this.$icon = '';
- } else {
- this.$icon = 'lu-alert--icon';
- }
- // default alert timeout if not defined in data attributes
- if (!this.$alertTimeout) {
- this.$alertTimeout = 100000;
- }
- if (this.$alertActions) {
- this.$actions = this.$alertActions;
- }
- },
- // create alert with data stored in array
- create: function create(event) {
- this.$alertPosition = event.$alertPosition;
- this.$alertSize = event.$alertSize;
- this.$alertStatus = event.$alertStatus;
- this.$alertTitle = event.$alertTitle;
- this.$alertBody = event.$alertBody;
- this.$alertIcon = event.$alertIcon;
- this.$alertActions = event.$alertActions;
- this.$alertTimeout = event.$alertTimeout;
- this.show(event);
- },
- // get data from data attributes
- getData: function getData(event) {
- var target = $(event.currentTarget);
- this.$alertPosition = target.data('alert-position');
- this.$alertSize = target.data('alert-size');
- this.$alertStatus = target.data('alert-status');
- this.$alertTitle = target.data('alert-title');
- this.$alertBody = target.data('alert-body');
- this.$alertIcon = target.data('alert-icon');
- this.$alertActions = target.data('alert-actions');
- this.$alertTimeout = target.data('alert-timeout');
- this.show(event);
- },
- // main function that showing alerts
- show: function show(event) {
- this.settings();
- if (this.$alertPosition == 'top' || this.$alertPosition == 'bottom') {
- // animation delay
- this.delay = 400;
- var that = this;
- if (this.$alertPosition == 'top') {
- var that = this;
- $('body').prepend(this.getTemplate());
- this.$alertFixedTop = $('.alert--fixed-top');
- this.$alertHeight = that.$alertFixedTop.outerHeight();
- this.$alertFixedTop.css('margin-top', -this.$alertHeight).animate({ 'margin-top': 0 }, this.delay);
- $(window).resize(function () {
- if (that.$alertFixedTop.hasClass('is-active')) {
- this.$alertHeight = that.$alertFixedTop.outerHeight();
- }
- });
- this.$hideAlert = this.$alertFixedTop.closest('.alert').find('.btn--close');
- this.$hideAlert.on('click', this.hideT.bind(this));
- } else {
- $('body').append(this.getTemplate());
- this.$alertFixedBottom = $('.alert--fixed-bottom');
- this.$alertBottomHeight = this.$alertFixedBottom.outerHeight();
- this.$alertFixedBottom.css('margin-bottom', -this.$alertBottomHeight).animate({ 'margin-bottom': '0' }, this.delay);
- this.$hideAlert = this.$alertFixedBottom.closest('.alert').find('.btn--close');
- this.$hideAlert.on('click', this.hideB.bind(this));
- }
- } else {
- _toastr2.default.success(this.getTemplate());
- }
- },
- hideT: function hideT(event) {
- var that = this;
- this.$alertHeight = this.$alertFixedTop.outerHeight();
- this.$alertFixedTop.animate({ 'margin-top': -this.$alertHeight }, this.delay);
- setTimeout(function () {
- that.$alertFixedTop.removeClass('is-active').remove();
- }, this.delay);
- },
- hideB: function hideB() {
- var that = this;
- this.$alertHeight = this.$alertFixedBottom.outerHeight();
- this.$alertFixedBottom.animate({ 'margin-bottom': -this.$alertHeight }, this.delay);
- setTimeout(function () {
- that.$alertFixedBottom.removeClass('is-active').remove();
- }, this.delay);
- },
- getTemplate: function getTemplate() {
- _toastr2.default.options = {
- "positionClass": "lu-toast--" + this.$alertPosition,
- "timeOut": this.$alertTimeout
- };
- this.$actions = '';
- if (this.$alertActions) {
- this.$actions = '<div class="lu-alert__actions">' + this.$alertActions + '</div>';
- }
- var $titleTemplate = '';
- if (this.$alertTitle) {
- $titleTemplate = '<div class="lu-alert__title">' + this.$alertTitle + ' </div>';
- }
- // main alert template
- var $primaryTemplate = '<div class="lu-alert lu-alert--' + this.$alertStatus + ' lu-alert--outline lu-alert--float lu-alert--border-left lu-has-icon">' + '<div class="lu-alert__body">' + $titleTemplate + '<p>' + this.$alertBody + '</p>' + '</div>' + this.$actions + '</div>';
- // template of top and bottom alert
- var $secondaryTemplate = '<div class="lu-alert lu-alert--' + this.$alertStatus + ' lu-alert--' + this.$alertSize + ' lu-alert--fixed lu-alert--fixed-' + this.$alertPosition + ' is-active">' + '<div class="lu-container">' + '<div class="lu-alert__body">' + '<b> ' + this.$alertTitle + ' </b> ' + this.$alertBody + '</div>' + this.$actions + '</div>' + '</div>';
- var $tmpl = $primaryTemplate;
- if (this.$alertPosition == 'top' || this.$alertPosition == 'bottom') {
- $tmpl = $secondaryTemplate;
- }
- return $tmpl;
- }
- };
- exports.default = alert;
- /***/ }),
- /* 16 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- 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; }; }();
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-beta.2): modal.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
- */
- var Modal = function () {
- /**
- * ------------------------------------------------------------------------
- * Constants
- * ------------------------------------------------------------------------
- */
- var NAME = 'luModal';
- var VERSION = '4.0.0-beta.2';
- var DATA_KEY = 'bs.modal';
- var EVENT_KEY = '.' + DATA_KEY;
- var DATA_API_KEY = '.data-api';
- var JQUERY_NO_CONFLICT = $.fn[NAME];
- var TRANSITION_DURATION = 300;
- var BACKDROP_TRANSITION_DURATION = 150;
- var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
- var Default = {
- backdrop: true,
- keyboard: true,
- focus: true,
- show: true
- };
- var DefaultType = {
- backdrop: '(boolean|string)',
- keyboard: 'boolean',
- focus: 'boolean',
- show: 'boolean'
- };
- var Event = {
- HIDE: 'hide' + EVENT_KEY,
- HIDDEN: 'hidden' + EVENT_KEY,
- SHOW: 'show' + EVENT_KEY,
- SHOWN: 'shown' + EVENT_KEY,
- FOCUSIN: 'focusin' + EVENT_KEY,
- RESIZE: 'resize' + EVENT_KEY,
- CLICK_DISMISS: 'click.dismiss' + EVENT_KEY,
- KEYDOWN_DISMISS: 'keydown.dismiss' + EVENT_KEY,
- MOUSEUP_DISMISS: 'mouseup.dismiss' + EVENT_KEY,
- MOUSEDOWN_DISMISS: 'mousedown.dismiss' + EVENT_KEY,
- CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
- };
- var ClassName = {
- SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
- BACKDROP: 'modal-backdrop',
- OPEN: 'modal-open',
- FADE: 'fade',
- SHOW: 'show'
- };
- var Selector = {
- DIALOG: '.modal-dialog, .lu-modal__dialog',
- DATA_TOGGLE: '[data-toggle="lu-modal"], [data-lu-modal]',
- DATA_DISMISS: '[data-dismiss="lu-modal"]',
- FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
- STICKY_CONTENT: '.sticky-top',
- NAVBAR_TOGGLER: '.navbar-toggler'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
- };
- var Modal = function () {
- function Modal(element, config) {
- _classCallCheck(this, Modal);
- this._config = this._getConfig(config);
- this._element = element;
- this._dialog = $(element).find(Selector.DIALOG)[0];
- this._backdrop = null;
- this._isShown = false;
- this._isBodyOverflowing = false;
- this._ignoreBackdropClick = false;
- this._originalBodyPadding = 0;
- this._scrollbarWidth = 0;
- }
- // getters
- _createClass(Modal, [{
- key: 'toggle',
- // public
- value: function toggle(relatedTarget) {
- return this._isShown ? this.hide() : this.show(relatedTarget);
- }
- }, {
- key: 'show',
- value: function show(relatedTarget) {
- var _this = this;
- if (this._isTransitioning || this._isShown) {
- return;
- }
- if (_util2.default.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
- this._isTransitioning = true;
- }
- var showEvent = $.Event(Event.SHOW, {
- relatedTarget: relatedTarget
- });
- $(this._element).trigger(showEvent);
- if (this._isShown || showEvent.isDefaultPrevented()) {
- return;
- }
- this._isShown = true;
- this._checkScrollbar();
- this._setScrollbar();
- this._adjustDialog();
- $(document.body).addClass(ClassName.OPEN);
- this._setEscapeEvent();
- this._setResizeEvent();
- $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function (event) {
- return _this.hide(event);
- });
- $(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () {
- $(_this._element).one(Event.MOUSEUP_DISMISS, function (event) {
- if ($(event.target).is(_this._element)) {
- _this._ignoreBackdropClick = true;
- }
- });
- });
- this._showBackdrop(function () {
- return _this._showElement(relatedTarget);
- });
- }
- }, {
- key: 'hide',
- value: function hide(event) {
- var _this2 = this;
- if (event) {
- event.preventDefault();
- }
- if (this._isTransitioning || !this._isShown) {
- return;
- }
- var hideEvent = $.Event(Event.HIDE);
- $(this._element).trigger(hideEvent);
- if (!this._isShown || hideEvent.isDefaultPrevented()) {
- return;
- }
- this._isShown = false;
- var transition = _util2.default.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE);
- if (transition) {
- this._isTransitioning = true;
- }
- this._setEscapeEvent();
- this._setResizeEvent();
- $(document).off(Event.FOCUSIN);
- $(this._element).removeClass(ClassName.SHOW);
- $(this._element).off(Event.CLICK_DISMISS);
- $(this._dialog).off(Event.MOUSEDOWN_DISMISS);
- if (transition) {
- $(this._element).one(_util2.default.TRANSITION_END, function (event) {
- return _this2._hideModal(event);
- }).emulateTransitionEnd(TRANSITION_DURATION);
- } else {
- this._hideModal();
- }
- }
- }, {
- key: 'dispose',
- value: function dispose() {
- $.removeData(this._element, DATA_KEY);
- $(window, document, this._element, this._backdrop).off(EVENT_KEY);
- this._config = null;
- this._element = null;
- this._dialog = null;
- this._backdrop = null;
- this._isShown = null;
- this._isBodyOverflowing = null;
- this._ignoreBackdropClick = null;
- this._scrollbarWidth = null;
- }
- }, {
- key: 'handleUpdate',
- value: function handleUpdate() {
- this._adjustDialog();
- }
- // private
- }, {
- key: '_getConfig',
- value: function _getConfig(config) {
- config = $.extend({}, Default, config);
- _util2.default.typeCheckConfig(NAME, config, DefaultType);
- return config;
- }
- }, {
- key: '_showElement',
- value: function _showElement(relatedTarget) {
- var _this3 = this;
- var transition = _util2.default.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE);
- if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
- // don't move modals dom position
- document.body.appendChild(this._element);
- }
- this._element.style.display = 'block';
- this._element.removeAttribute('aria-hidden');
- this._element.scrollTop = 0;
- if (transition) {
- _util2.default.reflow(this._element);
- }
- $(this._element).addClass(ClassName.SHOW);
- if (this._config.focus) {
- this._enforceFocus();
- }
- var shownEvent = $.Event(Event.SHOWN, {
- relatedTarget: relatedTarget
- });
- var transitionComplete = function transitionComplete() {
- if (_this3._config.focus) {
- _this3._element.focus();
- }
- _this3._isTransitioning = false;
- $(_this3._element).trigger(shownEvent);
- };
- if (transition) {
- $(this._dialog).one(_util2.default.TRANSITION_END, transitionComplete).emulateTransitionEnd(TRANSITION_DURATION);
- } else {
- transitionComplete();
- }
- }
- }, {
- key: '_enforceFocus',
- value: function _enforceFocus() {
- var _this4 = this;
- $(document).off(Event.FOCUSIN) // guard against infinite focus loop
- .on(Event.FOCUSIN, function (event) {
- if (document !== event.target && _this4._element !== event.target && !$(_this4._element).has(event.target).length) {
- _this4._element.focus();
- }
- });
- }
- }, {
- key: '_setEscapeEvent',
- value: function _setEscapeEvent() {
- var _this5 = this;
- if (this._isShown && this._config.keyboard) {
- $(this._element).on(Event.KEYDOWN_DISMISS, function (event) {
- if (event.which === ESCAPE_KEYCODE) {
- event.preventDefault();
- _this5.hide();
- }
- });
- } else if (!this._isShown) {
- $(this._element).off(Event.KEYDOWN_DISMISS);
- }
- }
- }, {
- key: '_setResizeEvent',
- value: function _setResizeEvent() {
- var _this6 = this;
- if (this._isShown) {
- $(window).on(Event.RESIZE, function (event) {
- return _this6.handleUpdate(event);
- });
- } else {
- $(window).off(Event.RESIZE);
- }
- }
- }, {
- key: '_hideModal',
- value: function _hideModal() {
- var _this7 = this;
- this._element.style.display = 'none';
- this._element.setAttribute('aria-hidden', true);
- this._isTransitioning = false;
- this._showBackdrop(function () {
- $(document.body).removeClass(ClassName.OPEN);
- _this7._resetAdjustments();
- _this7._resetScrollbar();
- $(_this7._element).trigger(Event.HIDDEN);
- });
- }
- }, {
- key: '_removeBackdrop',
- value: function _removeBackdrop() {
- if (this._backdrop) {
- $(this._backdrop).remove();
- this._backdrop = null;
- }
- }
- }, {
- key: '_showBackdrop',
- value: function _showBackdrop(callback) {
- var _this8 = this;
- var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '';
- if (this._isShown && this._config.backdrop) {
- var doAnimate = _util2.default.supportsTransitionEnd() && animate;
- this._backdrop = document.createElement('div');
- this._backdrop.className = ClassName.BACKDROP;
- if (animate) {
- $(this._backdrop).addClass(animate);
- }
- $(this._backdrop).appendTo(document.body);
- $(this._element).on(Event.CLICK_DISMISS, function (event) {
- if (_this8._ignoreBackdropClick) {
- _this8._ignoreBackdropClick = false;
- return;
- }
- if (event.target !== event.currentTarget) {
- return;
- }
- if (_this8._config.backdrop === 'static') {
- _this8._element.focus();
- } else {
- _this8.hide();
- }
- });
- if (doAnimate) {
- _util2.default.reflow(this._backdrop);
- }
- $(this._backdrop).addClass(ClassName.SHOW);
- if (!callback) {
- return;
- }
- if (!doAnimate) {
- callback();
- return;
- }
- $(this._backdrop).one(_util2.default.TRANSITION_END, callback).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION);
- } else if (!this._isShown && this._backdrop) {
- $(this._backdrop).removeClass(ClassName.SHOW);
- var callbackRemove = function callbackRemove() {
- _this8._removeBackdrop();
- if (callback) {
- callback();
- }
- };
- if (_util2.default.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
- $(this._backdrop).one(_util2.default.TRANSITION_END, callbackRemove).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION);
- } else {
- callbackRemove();
- }
- } else if (callback) {
- callback();
- }
- }
- // ----------------------------------------------------------------------
- // the following methods are used to handle overflowing modals
- // todo (fat): these should probably be refactored out of modal.js
- // ----------------------------------------------------------------------
- }, {
- key: '_adjustDialog',
- value: function _adjustDialog() {
- var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
- if (!this._isBodyOverflowing && isModalOverflowing) {
- this._element.style.paddingLeft = this._scrollbarWidth + 'px';
- }
- if (this._isBodyOverflowing && !isModalOverflowing) {
- this._element.style.paddingRight = this._scrollbarWidth + 'px';
- }
- }
- }, {
- key: '_resetAdjustments',
- value: function _resetAdjustments() {
- this._element.style.paddingLeft = '';
- this._element.style.paddingRight = '';
- }
- }, {
- key: '_checkScrollbar',
- value: function _checkScrollbar() {
- var rect = document.body.getBoundingClientRect();
- this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
- this._scrollbarWidth = this._getScrollbarWidth();
- }
- }, {
- key: '_setScrollbar',
- value: function _setScrollbar() {
- var _this9 = this;
- if (this._isBodyOverflowing) {
- // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
- // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
- // Adjust fixed content padding
- $(Selector.FIXED_CONTENT).each(function (index, element) {
- var actualPadding = $(element)[0].style.paddingRight;
- var calculatedPadding = $(element).css('padding-right');
- $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._scrollbarWidth + 'px');
- });
- // Adjust sticky content margin
- $(Selector.STICKY_CONTENT).each(function (index, element) {
- var actualMargin = $(element)[0].style.marginRight;
- var calculatedMargin = $(element).css('margin-right');
- $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this9._scrollbarWidth + 'px');
- });
- // Adjust navbar-toggler margin
- $(Selector.NAVBAR_TOGGLER).each(function (index, element) {
- var actualMargin = $(element)[0].style.marginRight;
- var calculatedMargin = $(element).css('margin-right');
- $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) + _this9._scrollbarWidth + 'px');
- });
- // Adjust body padding
- var actualPadding = document.body.style.paddingRight;
- var calculatedPadding = $('body').css('padding-right');
- $('body').data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + 'px');
- }
- }
- }, {
- key: '_resetScrollbar',
- value: function _resetScrollbar() {
- // Restore fixed content padding
- $(Selector.FIXED_CONTENT).each(function (index, element) {
- var padding = $(element).data('padding-right');
- if (typeof padding !== 'undefined') {
- $(element).css('padding-right', padding).removeData('padding-right');
- }
- });
- // Restore sticky content and navbar-toggler margin
- $(Selector.STICKY_CONTENT + ', ' + Selector.NAVBAR_TOGGLER).each(function (index, element) {
- var margin = $(element).data('margin-right');
- if (typeof margin !== 'undefined') {
- $(element).css('margin-right', margin).removeData('margin-right');
- }
- });
- // Restore body padding
- var padding = $('body').data('padding-right');
- if (typeof padding !== 'undefined') {
- $('body').css('padding-right', padding).removeData('padding-right');
- }
- }
- }, {
- key: '_getScrollbarWidth',
- value: function _getScrollbarWidth() {
- // thx d.walsh
- var scrollDiv = document.createElement('div');
- scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
- document.body.appendChild(scrollDiv);
- var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
- document.body.removeChild(scrollDiv);
- return scrollbarWidth;
- }
- // static
- }], [{
- key: '_jQueryInterface',
- value: function _jQueryInterface(config, relatedTarget) {
- return this.each(function () {
- var data = $(this).data(DATA_KEY);
- var _config = $.extend({}, Modal.Default, $(this).data(), (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config);
- if (!data) {
- data = new Modal(this, _config);
- $(this).data(DATA_KEY, data);
- }
- if (typeof config === 'string') {
- if (typeof data[config] === 'undefined') {
- throw new Error('No method named "' + config + '"');
- }
- data[config](relatedTarget);
- } else if (_config.show) {
- data.show(relatedTarget);
- }
- });
- }
- }, {
- key: 'VERSION',
- get: function get() {
- return VERSION;
- }
- }, {
- key: 'Default',
- get: function get() {
- return Default;
- }
- }]);
- return Modal;
- }();
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
- $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
- var _this10 = this;
- var target = void 0;
- var selector = _util2.default.getSelectorFromElement(this);
- if (selector) {
- target = $(selector)[0];
- }
- var config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data());
- if (this.tagName === 'A' || this.tagName === 'AREA') {
- event.preventDefault();
- }
- var $target = $(target).one(Event.SHOW, function (showEvent) {
- if (showEvent.isDefaultPrevented()) {
- // only register focus restorer if modal will actually get shown
- return;
- }
- $target.one(Event.HIDDEN, function () {
- if ($(_this10).is(':visible')) {
- _this10.focus();
- }
- });
- });
- Modal._jQueryInterface.call($(target), config, this);
- });
- /**
- * ------------------------------------------------------------------------
- * jQuery
- * ------------------------------------------------------------------------
- */
- $.fn[NAME] = Modal._jQueryInterface;
- $.fn[NAME].Constructor = Modal;
- $.fn[NAME].noConflict = function () {
- $.fn[NAME] = JQUERY_NO_CONFLICT;
- return Modal._jQueryInterface;
- };
- return Modal;
- }(_util2.default.jQuery);
- exports.default = Modal;
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _enquire = __webpack_require__(31);
- var _enquire2 = _interopRequireDefault(_enquire);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- var layersNav = {
- init: function init() {
- this.cacheDom();
- this.bindEvents();
- },
- cacheDom: function cacheDom() {
- this.$nav = $('.lu-nav');
- this.$navigationDroDownLi = this.$nav.find('.lu-nav__item.has-dropdown');
- },
- bindEvents: function bindEvents() {
- var that = this;
- this.$navigationDroDownLi.on('click', this.checkDropDownStatus.bind(this));
- var isMobile = false; //initiate as false
- // device detection
- if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4)) || window.ontouchstart !== undefined) {
- isMobile = true;
- };
- _enquire2.default.register("screen and (min-width: 0) and (max-width: 751px)", {
- match: function match() {
- $('.has-dropdown > a').on('click', function (event) {
- event.preventDefault();
- });
- },
- unmatch: function unmatch() {
- $('.has-dropdown > a').on('click', function (event) {
- if (isMobile == true || $(this).parents('.navbar--thin').length == 0) {
- event.preventDefault(); // I need to change that
- }
- });
- }
- });
- _enquire2.default.register("screen and (min-width: 752px)", {
- match: function match(event) {
- $('.has-dropdown > a').on('click', function (event) {
- if ($(this).parents('.navigation').length == 0 && (isMobile == true || $(this).parents('.navbar--thin').length == 0)) {
- event.preventDefault(); // I need to change that
- }
- });
- },
- unmatch: function unmatch() {
- $('.has-dropdown > a').on('click', function (event) {
- event.preventDefault();
- });
- }
- });
- $(window).on('click', function (event) {
- $('.nav .has-dropdown').removeClass('is-open');
- }.bind(this));
- },
- checkDropDownStatus: function checkDropDownStatus(event) {
- var toggleBack = this.$nav.find('[data-toggle="back"]');
- var toggleBackI = this.$nav.find('[data-toggle="back"] i');
- if (toggleBack.is(event.target) || toggleBackI.is(event.target)) {} else {
- if ($(event.currentTarget).hasClass('is-open')) {
- this.hideDropDown(event);
- } else {
- this.showDropDown(event);
- }
- }
- },
- showDropDown: function showDropDown(event) {
- event.stopPropagation(); // I need to change that
- var dropDownElement = $(event.currentTarget);
- var dropDownContainer = $(event.currentTarget).find('.has-dropdown');
- dropDownElement.closest('.lu-nav').find('.is-open').removeClass('is-open');
- dropDownElement.addClass('is-open');
- },
- hideDropDown: function hideDropDown(event) {
- var dropDownElement = $(event.currentTarget);
- var dropDownContainer = $(event.currentTarget).find('.has-dropdown');
- dropDownElement.removeClass('is-open');
- }
- }; // import enquire from 'enquire';
- // import superfish from 'superfish';
- // const SELECTORS = {
- // container: '.nav',
- // item: '.has-dropdown',
- // };
- // const Default = {
- // active: '.is-open',
- // open: 'hover'
- // };
- // class Nav{
- // constructor(container, options){
- // this.container = container;
- // this.items = $(container).find(SELECTORS.item);
- // this.options = options;
- // this.getConfig();
- // this.bindEvents();
- // }
- // bindEvents(){
- // this.items.on('click', this.checkStatus.bind(this));
- // $(document).on('click', this.clickOutside.bind(this));
- // }
- // getConfig(){
- // var dataConfig = this.container.data();
- // if(dataConfig.options){
- // this.dataOptions = util.parseDataOptions(dataConfig.options);
- // }else{
- // this.dataOptions = {};
- // }
- // this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- // }
- // checkStatus(event){
- // if ($(event.currentTarget).hasClass('is-open')) {
- // this.hide(event);
- // } else {
- // this.show(event);
- // }
- // }
- // show(event) {
- // let item = $(event.currentTarget);
- // event.stopPropagation();
- // if(this.config.open == 'click'){
- // this.hideOld();
- // item.addClass('is-open');
- // }else if(this.config.open == 'hover'){
- // this.initSuperFish();
- // console.log('test');
- // }
- // }
- // hide(event) {
- // let item = $(event.currentTarget);
- // item.removeClass('is-open');
- // }
- // hideOld(){
- // this.container.find('.is-open').removeClass('is-open');
- // }
- // initSuperFish(){
- // $(this.container).superfish({
- // hoverClass: 'is-open',
- // popUpSelector: '.has-dropdown',
- // delay: 600,
- // animation: {}
- // });
- // }
- // clickOutside(){
- // if(!$(event.target).closest(SELECTORS.container).length) {
- // if($(SELECTORS.container).is(":visible")) {
- // this.hideOld();
- // }
- // }
- // }
- // }
- // function initDataSelectors(){
- // $(SELECTORS.container).each(function(){
- // new Nav($(this));
- // });
- // }
- // function initJqueryPlugin(){
- // $.fn.luNav = function( options ) {
- // return this.each(function() {
- // new Nav($(this), options);
- // });
- // };
- // }
- // const init = {
- // initDataSelectors,
- // initJqueryPlugin,
- // };
- // export default init;
- exports.default = layersNav;
- /***/ }),
- /* 18 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Switcher.js
- * Copyright 2016, RSstudio
- *
- * http://rsstudio.net
- *
- * All rights reserved
- *
- */
- var SELECTORS = {
- container: '[data-switcher]',
- item: '[data-switcher-item]',
- itemHighlight: '[data-switcher-highlight]'
- };
- var Default = {
- activeElement: 2,
- transition: 'all 500ms cubic-bezier(.250, .250, .000, 1.015)'
- };
- var Switcher = function () {
- function Switcher(element, options) {
- _classCallCheck(this, Switcher);
- this.element = $(element);
- this.items = element.find(SELECTORS.item);
- this.itemHighlight = this.element.find(SELECTORS.itemHighlight);
- this.options = options;
- this.activeItemData = {};
- this.isInit = false;
- this.getConfig();
- this.setActiveItem(this.config.activeElement);
- this.bindEvents();
- }
- _createClass(Switcher, [{
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.element.data();
- if (dataConfig.options) {
- this.dataOptions = util.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- }
- }, {
- key: 'bindEvents',
- value: function bindEvents() {
- var _this = this;
- this.items.on('click', function (event) {
- return _this.slideToItem(event.currentTarget);
- });
- $(window).on('resize', function (event) {
- return _this.onResize(event);
- });
- }
- }, {
- key: 'setActiveItem',
- value: function setActiveItem(itemIndex) {
- this.slideToItem(this.items[itemIndex]);
- }
- }, {
- key: 'getItemPosition',
- value: function getItemPosition(element) {
- this.activeItemData.element = $(element);
- this.activeItemData.width = $(this.activeItemData.element).outerWidth();
- this.activeItemData.position = $(this.activeItemData.element).position().left;
- }
- }, {
- key: 'slideToItem',
- value: function slideToItem(element) {
- if (this.activeItemData.element) {
- this.activeItemData.element.removeClass('is-active');
- }
- this.getItemPosition(element);
- this.itemHighlight.css({
- 'transform': 'translateX(' + this.activeItemData.position + 'px)',
- 'width': this.activeItemData.width
- });
- if (this.isInit) {
- this.itemHighlight.css({
- transition: this.config.transition
- });
- } else {
- this.onInit();
- this.isInit = true;
- }
- this.onSlide();
- }
- }, {
- key: 'onInit',
- value: function onInit() {
- if (typeof this.config.onInit === 'function') {
- this.config.onInit(this.element, this.activeItemData.element);
- }
- }
- }, {
- key: 'onSlide',
- value: function onSlide() {
- if (typeof this.config.onSlide === 'function') {
- this.config.onSlide(this.element, this.activeItemData.element);
- }
- this.activeItemData.element.addClass('is-active');
- }
- }, {
- key: 'onResize',
- value: function onResize() {
- if (typeof this.config.onSlide === 'function') {
- this.config.onResize(this.element, this.activeItemData.element);
- }
- this.activeItemData.element.trigger('click');
- }
- }]);
- return Switcher;
- }();
- function initDataSelectors() {
- $(document).ready(function () {
- $(SELECTORS.container).each(function () {
- new Switcher($(this));
- });
- });
- }
- function initJqueryPlugin() {
- $.fn.luSwitcher = function (options) {
- return this.each(function () {
- var switcher = new Switcher($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-beta.2): tab.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
- */
- var Tab = function () {
- /**
- * ------------------------------------------------------------------------
- * Constants
- * ------------------------------------------------------------------------
- */
- var NAME = 'lu-tab';
- var VERSION = '4.0.0-beta.2';
- var DATA_KEY = 'bs.tab';
- var EVENT_KEY = '.' + DATA_KEY;
- var DATA_API_KEY = '.data-api';
- var JQUERY_NO_CONFLICT = $.fn[NAME];
- var TRANSITION_DURATION = 150;
- var Event = {
- HIDE: 'hide' + EVENT_KEY,
- HIDDEN: 'hidden' + EVENT_KEY,
- SHOW: 'show' + EVENT_KEY,
- SHOWN: 'shown' + EVENT_KEY,
- CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
- };
- var ClassName = {
- DROPDOWN_MENU: 'dropdown-menu',
- ACTIVE: 'is-active',
- DISABLED: 'disabled',
- FADE: 'fade',
- SHOW: 'show'
- };
- var Selector = {
- DROPDOWN: '.dropdown',
- NAV_LIST_GROUP: '.lu-nav, .lu-list-group',
- ACTIVE: '.is-active',
- ACTIVE_UL: '> .is-active',
- DATA_TOGGLE: '[data-toggle="lu-tab"], [data-toggle="pill"], [data-toggle="list"]',
- DROPDOWN_TOGGLE: '.dropdown-toggle',
- DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .is-active'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
- };
- var Tab = function () {
- function Tab(element) {
- _classCallCheck(this, Tab);
- this._element = element;
- }
- // getters
- _createClass(Tab, [{
- key: 'show',
- // public
- value: function show() {
- var _this = this;
- if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE) || $(this._element).hasClass(ClassName.DISABLED)) {
- return;
- }
- var target = void 0;
- var previous = void 0;
- var listElement = $(this._element).closest(Selector.NAV_LIST_GROUP)[0];
- var selector = _util2.default.getSelectorFromElement(this._element);
- if (listElement) {
- var itemSelector = listElement.nodeName === 'UL' ? Selector.ACTIVE_UL : Selector.ACTIVE;
- previous = $.makeArray($(listElement).find(itemSelector));
- previous = previous[previous.length - 1];
- }
- var hideEvent = $.Event(Event.HIDE, {
- relatedTarget: this._element
- });
- var showEvent = $.Event(Event.SHOW, {
- relatedTarget: previous
- });
- if (previous) {
- $(previous).trigger(hideEvent);
- }
- $(this._element).trigger(showEvent);
- if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
- return;
- }
- if (selector) {
- target = $(selector)[0];
- }
- this._activate(this._element, listElement);
- var complete = function complete() {
- var hiddenEvent = $.Event(Event.HIDDEN, {
- relatedTarget: _this._element
- });
- var shownEvent = $.Event(Event.SHOWN, {
- relatedTarget: previous
- });
- $(previous).trigger(hiddenEvent);
- $(_this._element).trigger(shownEvent);
- };
-
- if (target) {
- this._activate(target, target.parentNode, complete);
- } else {
- complete();
- }
- }
- }, {
- key: 'dispose',
- value: function dispose() {
- $.removeData(this._element, DATA_KEY);
- this._element = null;
- }
- // private
- }, {
- key: '_activate',
- value: function _activate(element, container, callback) {
- var _this2 = this;
- var activeElements = void 0;
- if (container.nodeName === 'UL') {
- activeElements = $(container).find(Selector.ACTIVE_UL);
- } else {
- activeElements = $(container).children(Selector.ACTIVE);
- }
- var active = activeElements[0];
- var isTransitioning = callback && _util2.default.supportsTransitionEnd() && active && $(active).hasClass(ClassName.FADE);
- var complete = function complete() {
- return _this2._transitionComplete(element, active, isTransitioning, callback);
- };
- if (active && isTransitioning) {
- $(active).one(_util2.default.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
- } else {
- complete();
- }
- if (active) {
- $(active).removeClass(ClassName.SHOW);
- }
- }
- }, {
- key: '_transitionComplete',
- value: function _transitionComplete(element, active, isTransitioning, callback) {
- if (active) {
- $(active).removeClass(ClassName.ACTIVE);
- var dropdownChild = $(active.parentNode).find(Selector.DROPDOWN_ACTIVE_CHILD)[0];
- if (dropdownChild) {
- $(dropdownChild).removeClass(ClassName.ACTIVE);
- }
- if (active.getAttribute('role') === 'tab') {
- active.setAttribute('aria-selected', false);
- }
- }
- if ($(element).is("a")) {
- $(element).parent().addClass(ClassName.ACTIVE);
- } else {
- $(element).addClass(ClassName.ACTIVE);
- }
- if (element.getAttribute('role') === 'tab') {
- element.setAttribute('aria-selected', true);
- }
- if (isTransitioning) {
- _util2.default.reflow(element);
- $(element).addClass(ClassName.SHOW);
- } else {
- $(element).removeClass(ClassName.FADE);
- }
- if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) {
- var dropdownElement = $(element).closest(Selector.DROPDOWN)[0];
- if (dropdownElement) {
- $(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
- }
- element.setAttribute('aria-expanded', true);
- }
- if (callback) {
- callback();
- }
- }
- // static
- }], [{
- key: '_jQueryInterface',
- value: function _jQueryInterface(config) {
- return this.each(function () {
- var $this = $(this);
- var data = $this.data(DATA_KEY);
- if (!data) {
- data = new Tab(this);
- $this.data(DATA_KEY, data);
- }
- if (typeof config === 'string') {
- if (typeof data[config] === 'undefined') {
- throw new Error('No method named "' + config + '"');
- }
- data[config]();
- }
- });
- }
- }, {
- key: 'VERSION',
- get: function get() {
- return VERSION;
- }
- }]);
- return Tab;
- }();
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
- $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
- event.preventDefault();
- Tab._jQueryInterface.call($(this), 'show');
- });
- /**
- * ------------------------------------------------------------------------
- * jQuery
- * ------------------------------------------------------------------------
- */
- $.fn[NAME] = Tab._jQueryInterface;
- $.fn[NAME].Constructor = Tab;
- $.fn[NAME].noConflict = function () {
- $.fn[NAME] = JQUERY_NO_CONFLICT;
- return Tab._jQueryInterface;
- };
- return Tab;
- }(_util2.default.jQuery);
- exports.default = Tab;
- /***/ }),
- /* 20 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _Swiper = __webpack_require__(4);
- var _Swiper2 = _interopRequireDefault(_Swiper);
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- button: '[data-toggle="offCanvas"]',
- overlayers: '.overlayer',
- dismiss: '[data-dismiss="offCanvas"]'
- };
- var Default = {
- position: 'right',
- activeClass: 'is-open',
- mode: 'normal',
- tranition: 400,
- overlayer: false,
- bodyClass: 'off-canvas-is-active'
- };
- var OffCanvas = function () {
- function OffCanvas(element, options) {
- _classCallCheck(this, OffCanvas);
- this.element = element;
- this.options = options;
- this.getConfig();
- this.bindEvents();
- }
- _createClass(OffCanvas, [{
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.element.data();
- if (dataConfig.options) {
- this.dataOptions = _util2.default.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- this.target = $(this.config.target);
- this.dismiss = this.target.find(SELECTORS.dismiss);
- }
- }, {
- key: 'bindEvents',
- value: function bindEvents() {
- var _this = this;
- this.element.on('click', function (event) {
- return _this.checkState(event);
- });
- this.dismiss.on('click', function () {
- return _this.close();
- });
- $(document).on('click', function (event) {
- return _this.addEventClickOutside(event);
- });
- }
- }, {
- key: 'checkState',
- value: function checkState() {
- if (this.target.hasClass(this.config.activeClass)) {
- this.close();
- } else {
- this.open();
- }
- }
- }, {
- key: 'open',
- value: function open(evnet) {
- $(this.target).addClass(this.config.activeClass);
- $('body').addClass(this.config.bodyClass);
- }
- }, {
- key: 'close',
- value: function close(event) {
- $(this.target).removeClass(this.config.activeClass);
- $('body').removeClass(this.config.bodyClass);
- }
- }, {
- key: 'addEventClickOutside',
- value: function addEventClickOutside(event) {
- if (!$(event.target).closest(this.target).length && !$(event.target).closest(this.element).length) {
- if ($(this.target).is(":visible")) {
- this.close();
- }
- }
- }
- }]);
- return OffCanvas;
- }();
- function initDataSelectors() {
- $(SELECTORS.button).each(function () {
- new OffCanvas($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luOffCanvas = function (options) {
- return this.each(function () {
- new OffCanvas($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 21 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- link: '[data-scroll-to]'
- };
- var Default = {
- topOffset: 10,
- animation: 'normal',
- speed: 400,
- constantSpeed: false
- };
- var ScrollTo = function () {
- function ScrollTo(element, options) {
- _classCallCheck(this, ScrollTo);
- this.element = element;
- this.options = options;
- this.hash = $(element).attr('href');
- this.target = $(this.hash);
- if (!this.target.length) {
- return;
- }
- this.getConfig();
- this.bindEvents();
- this.targetVisibility();
- }
- _createClass(ScrollTo, [{
- key: 'bindEvents',
- value: function bindEvents() {
- var _this = this;
- $(this.element).on('click', function (event) {
- return _this.startScroll(event);
- });
- $(window).on('scroll', function (event) {
- return _this.targetVisibility(event);
- });
- }
- }, {
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.element.data();
- if (dataConfig.options) {
- this.dataOptions = _util2.default.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- }
- }, {
- key: 'startScroll',
- value: function startScroll(event) {
- this.targetPosition = this.target.offset().top + this.config.topOffset;
- console.log(this.getAnimationSpeed());
- $("body, html").stop().animate({
- scrollTop: this.targetPosition
- }, this.config.speed);
- }
- }, {
- key: 'isOnScreen',
- value: function isOnScreen() {
- var win = $(window);
- var viewport = {
- top: win.scrollTop(),
- left: win.scrollLeft()
- };
- viewport.right = viewport.left + win.width();
- viewport.bottom = viewport.top + win.height();
- var bounds = this.target.offset();
- bounds.right = bounds.left + this.target.outerWidth();
- bounds.bottom = bounds.top + this.target.outerHeight();
- return !(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom);
- }
- }, {
- key: 'targetVisibility',
- value: function targetVisibility() {
- if (this.isOnScreen()) {
- this.onScreen();
- } else {
- this.outScreen();
- }
- }
- }, {
- key: 'onScreen',
- value: function onScreen() {
- if (typeof this.config.onScreen === 'function') {
- this.config.onScreen(this.element, this.target);
- }
- }
- }, {
- key: 'outScreen',
- value: function outScreen() {
- if (typeof this.config.outScreen === 'function') {
- this.config.outScreen(this.element, this.target);
- }
- }
- }, {
- key: 'getOffset',
- value: function getOffset() {
- return Math.abs(this.target.offset().top - $(window).scrollTop());
- }
- }, {
- key: 'getAnimationSpeed',
- value: function getAnimationSpeed() {
- return this.getOffset() / this.config.speed * this.config.speed;
- }
- }]);
- return ScrollTo;
- }();
- function initDataSelectors() {
- $(SELECTORS.link).each(function () {
- new ScrollTo($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luScrollTo = function (options) {
- return this.each(function () {
- new ScrollTo($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 22 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- 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; }; }();
- var _jquery = __webpack_require__(1);
- var _jquery2 = _interopRequireDefault(_jquery);
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-beta): scrollspy.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
- */
- var ScrollSpy = function () {
- /**
- * ------------------------------------------------------------------------
- * Constants
- * ------------------------------------------------------------------------
- */
- var NAME = 'scrollspy';
- var VERSION = '4.0.0-beta';
- var DATA_KEY = 'bs.scrollspy';
- var EVENT_KEY = '.' + DATA_KEY;
- var DATA_API_KEY = '.data-api';
- var JQUERY_NO_CONFLICT = _jquery2.default.fn[NAME];
- var Default = {
- offset: 10,
- method: 'auto',
- target: ''
- };
- var DefaultType = {
- offset: 'number',
- method: 'string',
- target: '(string|element)'
- };
- var Event = {
- ACTIVATE: 'activate' + EVENT_KEY,
- SCROLL: 'scroll' + EVENT_KEY,
- LOAD_DATA_API: 'load' + EVENT_KEY + DATA_API_KEY
- };
- var ClassName = {
- DROPDOWN_ITEM: 'dropdown-item',
- DROPDOWN_MENU: 'dropdown-menu',
- ACTIVE: 'is-active'
- };
- var Selector = {
- DATA_SPY: '[data-spy="scroll"]',
- ACTIVE: '.is-active',
- NAV_LIST_GROUP: '.nav, .list-group',
- NAV_LINKS: '.nav__link',
- NAV_ITEMS: '.nav__item',
- LIST_ITEMS: '.list-group-item',
- DROPDOWN: '.dropdown',
- DROPDOWN_ITEMS: '.dropdown-item',
- DROPDOWN_TOGGLE: '.dropdown-toggle'
- };
- var OffsetMethod = {
- OFFSET: 'offset',
- POSITION: 'position'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
- };
- var ScrollSpy = function () {
- function ScrollSpy(element, config) {
- var _this = this;
- _classCallCheck(this, ScrollSpy);
- this._element = element;
- this._scrollElement = element.tagName === 'BODY' ? window : element;
- this._config = this._getConfig(config);
- this._selector = this._config.target + ' ' + Selector.NAV_LINKS + ',' + (this._config.target + ' ' + Selector.LIST_ITEMS + ',') + (this._config.target + ' ' + Selector.DROPDOWN_ITEMS);
- this._offsets = [];
- this._targets = [];
- this._activeTarget = null;
- this._scrollHeight = 0;
- (0, _jquery2.default)(this._scrollElement).on(Event.SCROLL, function (event) {
- return _this._process(event);
- });
- this.refresh();
- this._process();
- }
- // getters
- _createClass(ScrollSpy, [{
- key: 'refresh',
- // public
- value: function refresh() {
- var _this2 = this;
- var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET;
- var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
- var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
- this._offsets = [];
- this._targets = [];
- this._scrollHeight = this._getScrollHeight();
- var targets = _jquery2.default.makeArray((0, _jquery2.default)(this._selector));
- targets.map(function (element) {
- var target = void 0;
- var targetSelector = _util2.default.getSelectorFromElement(element);
- if (targetSelector) {
- target = (0, _jquery2.default)(targetSelector)[0];
- }
- if (target) {
- var targetBCR = target.getBoundingClientRect();
- if (targetBCR.width || targetBCR.height) {
- // todo (fat): remove sketch reliance on jQuery position/offset
- return [(0, _jquery2.default)(target)[offsetMethod]().top + offsetBase, targetSelector];
- }
- }
- return null;
- }).filter(function (item) {
- return item;
- }).sort(function (a, b) {
- return a[0] - b[0];
- }).forEach(function (item) {
- _this2._offsets.push(item[0]);
- _this2._targets.push(item[1]);
- });
- }
- }, {
- key: 'dispose',
- value: function dispose() {
- _jquery2.default.removeData(this._element, DATA_KEY);
- (0, _jquery2.default)(this._scrollElement).off(EVENT_KEY);
- this._element = null;
- this._scrollElement = null;
- this._config = null;
- this._selector = null;
- this._offsets = null;
- this._targets = null;
- this._activeTarget = null;
- this._scrollHeight = null;
- }
- // private
- }, {
- key: '_getConfig',
- value: function _getConfig(config) {
- config = _jquery2.default.extend({}, Default, config);
- if (typeof config.target !== 'string') {
- var id = (0, _jquery2.default)(config.target).attr('id');
- if (!id) {
- id = _util2.default.getUID(NAME);
- (0, _jquery2.default)(config.target).attr('id', id);
- }
- config.target = '#' + id;
- }
- _util2.default.typeCheckConfig(NAME, config, DefaultType);
- return config;
- }
- }, {
- key: '_getScrollTop',
- value: function _getScrollTop() {
- return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
- }
- }, {
- key: '_getScrollHeight',
- value: function _getScrollHeight() {
- return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
- }
- }, {
- key: '_getOffsetHeight',
- value: function _getOffsetHeight() {
- return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
- }
- }, {
- key: '_process',
- value: function _process() {
- var scrollTop = this._getScrollTop() + this._config.offset;
- var scrollHeight = this._getScrollHeight();
- var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
- if (this._scrollHeight !== scrollHeight) {
- this.refresh();
- }
- if (scrollTop >= maxScroll) {
- var target = this._targets[this._targets.length - 1];
- if (this._activeTarget !== target) {
- this._activate(target);
- }
- return;
- }
- if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
- this._activeTarget = null;
- this._clear();
- return;
- }
- for (var i = this._offsets.length; i--;) {
- var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
- if (isActiveTarget) {
- this._activate(this._targets[i]);
- }
- }
- }
- }, {
- key: '_activate',
- value: function _activate(target) {
- this._activeTarget = target;
- this._clear();
- var queries = this._selector.split(',');
- // eslint-disable-next-line arrow-body-style
- queries = queries.map(function (selector) {
- return selector + '[data-target="' + target + '"],' + (selector + '[href="' + target + '"]');
- });
- var $link = (0, _jquery2.default)(queries.join(','));
- if ($link.hasClass(ClassName.DROPDOWN_ITEM)) {
- $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
- $link.addClass(ClassName.ACTIVE);
- } else {
- // Set triggered link as active
- $link.addClass(ClassName.ACTIVE);
- // Set triggered links parents as active
- // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
- $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_LINKS + ', ' + Selector.LIST_ITEMS).addClass(ClassName.ACTIVE);
- // Handle special case when .nav-link is inside .nav-item
- $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_ITEMS).addClass(ClassName.ACTIVE);
- }
- (0, _jquery2.default)(this._scrollElement).trigger(Event.ACTIVATE, {
- relatedTarget: target
- });
- }
- }, {
- key: '_clear',
- value: function _clear() {
- (0, _jquery2.default)(this._selector).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
- }
- // static
- }], [{
- key: '_jQueryInterface',
- value: function _jQueryInterface(config) {
- return this.each(function () {
- var data = (0, _jquery2.default)(this).data(DATA_KEY);
- var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config;
- if (!data) {
- data = new ScrollSpy(this, _config);
- (0, _jquery2.default)(this).data(DATA_KEY, data);
- }
- if (typeof config === 'string') {
- if (typeof data[config] === 'undefined') {
- throw new Error('No method named "' + config + '"');
- }
- data[config]();
- }
- });
- }
- }, {
- key: 'VERSION',
- get: function get() {
- return VERSION;
- }
- }, {
- key: 'Default',
- get: function get() {
- return Default;
- }
- }]);
- return ScrollSpy;
- }();
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
- (0, _jquery2.default)(window).on(Event.LOAD_DATA_API, function () {
- var scrollSpys = _jquery2.default.makeArray((0, _jquery2.default)(Selector.DATA_SPY));
- for (var i = scrollSpys.length; i--;) {
- var $spy = (0, _jquery2.default)(scrollSpys[i]);
- ScrollSpy._jQueryInterface.call($spy, $spy.data());
- }
- });
- /**
- * ------------------------------------------------------------------------
- * jQuery
- * ------------------------------------------------------------------------
- */
- _jquery2.default.fn[NAME] = ScrollSpy._jQueryInterface;
- _jquery2.default.fn[NAME].Constructor = ScrollSpy;
- _jquery2.default.fn[NAME].noConflict = function () {
- _jquery2.default.fn[NAME] = JQUERY_NO_CONFLICT;
- return ScrollSpy._jQueryInterface;
- };
- return ScrollSpy;
- }(_jquery2.default);
- exports.default = ScrollSpy;
- /***/ }),
- /* 23 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _stickySidebar = __webpack_require__(33);
- var _stickySidebar2 = _interopRequireDefault(_stickySidebar);
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- stickyElement: '[data-sticky]'
- };
- var Default = {
- topOffset: 0,
- bottomOffset: 0
- };
- var Sticky = function () {
- function Sticky(element, options) {
- _classCallCheck(this, Sticky);
- this.element = element;
- this.options = options;
- this.getConfig();
- this.initPlugn();
- this.bindEvents();
- }
- _createClass(Sticky, [{
- key: 'getConfig',
- value: function getConfig() {
- var dataConfig = this.element.data();
- if (dataConfig.options) {
- this.dataOptions = _util2.default.parseDataOptions(dataConfig.options);
- } else {
- this.dataOptions = {};
- }
- this.config = $.extend({}, Default, dataConfig, this.dataOptions, this.options);
- }
- }, {
- key: 'initPlugn',
- value: function initPlugn() {
- this.stickyInstance = new _stickySidebar2.default(this.element[0], {
- topSpacing: this.config.topOffset,
- bottomSpacing: this.config.bottomOffset,
- containerSelector: this.config.container,
- resizeSensor: true,
- stickyClass: 'is-sticky'
- });
- if (typeof this.config.onOpen === 'function') {
- this.config.onInit(this.stickyInstance);
- }
- }
- }, {
- key: 'bindEvents',
- value: function bindEvents() {}
- }]);
- return Sticky;
- }();
- function initDataSelectors() {
- $(SELECTORS.stickyElement).each(function () {
- new Sticky($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luSticky = function (options) {
- return this.each(function () {
- new Sticky($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 24 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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; }; }();
- var _util = __webpack_require__(0);
- var _util2 = _interopRequireDefault(_util);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- var SELECTORS = {
- toggler: '[data-toggler]',
- togglerOptions: '[data-toggler-options]'
- };
- var Default = {
- selectors: '',
- container: 'body'
- };
- var Toggler = function () {
- function Toggler(element, options) {
- _classCallCheck(this, Toggler);
- this.element = element;
- this.targets = [];
- this.getConfig();
- this.targetsNames = this.config.selectors.split(',');
- this.setTargetElements();
- this.bindEvents();
- }
- _createClass(Toggler, [{
- key: 'bindEvents',
- value: function bindEvents() {
- var _this = this;
- this.config = this.element.on('click', function () {
- return _this.toggle();
- });
- }
- }, {
- key: 'getConfig',
- value: function getConfig() {
- var dataToggler = this.getTogglerOptions(this.element.data('toggler'));
- this.config = $.extend({}, Default, dataToggler);
- }
- }, {
- key: 'getTogglerOptions',
- value: function getTogglerOptions(options) {
- if (options) {
- return _util2.default.parseDataOptions(options);
- } else {
- return [];
- }
- }
- }, {
- key: 'setTargetElements',
- value: function setTargetElements() {
- this.container = this.element.closest(this.config.container);
- if (this.targetsNames.length > 1) {
- var _iteratorNormalCompletion = true;
- var _didIteratorError = false;
- var _iteratorError = undefined;
- try {
- for (var _iterator = this.targetsNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
- var target = _step.value;
- var element = this.container.find(target);
- this.targets.push({
- element: element,
- options: this.getTogglerOptions(element.data('toggler-options'))
- });
- }
- } catch (err) {
- _didIteratorError = true;
- _iteratorError = err;
- } finally {
- try {
- if (!_iteratorNormalCompletion && _iterator.return) {
- _iterator.return();
- }
- } finally {
- if (_didIteratorError) {
- throw _iteratorError;
- }
- }
- }
- }
- if (this.container) {
- this.targets.push({
- element: this.container,
- options: this.getTogglerOptions(this.container.data('toggler-options'))
- });
- }
- }
- }, {
- key: 'toggle',
- value: function toggle() {
- for (var targetName in this.targets) {
- var _targets$targetName = this.targets[targetName],
- element = _targets$targetName.element,
- options = _targets$targetName.options;
- if (options.addClass) element.addClass(options.addClass);
- if (options.removeClass) element.removeClass(options.removeClass);
- if (options.toggleClass) element.toggleClass(options.toggleClass);
- }
- }
- }]);
- return Toggler;
- }();
- function initDataSelectors() {
- $(SELECTORS.toggler).each(function () {
- new Toggler($(this));
- });
- }
- function initJqueryPlugin() {
- $.fn.luToggler = function (options) {
- return this.each(function () {
- new Toggler($(this), options);
- });
- };
- }
- var init = {
- initDataSelectors: initDataSelectors,
- initJqueryPlugin: initJqueryPlugin
- };
- exports.default = init;
- /***/ }),
- /* 25 */,
- /* 26 */,
- /* 27 */,
- /* 28 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _navs = __webpack_require__(17);
- var _navs2 = _interopRequireDefault(_navs);
- var _switcher = __webpack_require__(18);
- var _switcher2 = _interopRequireDefault(_switcher);
- __webpack_require__(19);
- __webpack_require__(11);
- var _selects = __webpack_require__(13);
- var _selects2 = _interopRequireDefault(_selects);
- var _selectInput = __webpack_require__(3);
- var _selectInput2 = _interopRequireDefault(_selectInput);
- var _CheckAll = __webpack_require__(10);
- var _CheckAll2 = _interopRequireDefault(_CheckAll);
- var _rangeSlider = __webpack_require__(12);
- var _rangeSlider2 = _interopRequireDefault(_rangeSlider);
- var _dropdown = __webpack_require__(8);
- var _dropdown2 = _interopRequireDefault(_dropdown);
- var _tooltips = __webpack_require__(9);
- var _tooltips2 = _interopRequireDefault(_tooltips);
- __webpack_require__(16);
- var _alert = __webpack_require__(15);
- var _alert2 = _interopRequireDefault(_alert);
- var _contentSlider = __webpack_require__(7);
- var _contentSlider2 = _interopRequireDefault(_contentSlider);
- var _scrollTo = __webpack_require__(21);
- var _scrollTo2 = _interopRequireDefault(_scrollTo);
- var _offCanvas = __webpack_require__(20);
- var _offCanvas2 = _interopRequireDefault(_offCanvas);
- var _inlineEditor = __webpack_require__(14);
- var _inlineEditor2 = _interopRequireDefault(_inlineEditor);
- __webpack_require__(6);
- var _sticky = __webpack_require__(23);
- var _sticky2 = _interopRequireDefault(_sticky);
- var _toggler = __webpack_require__(24);
- var _toggler2 = _interopRequireDefault(_toggler);
- __webpack_require__(22);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- $ = window.jQuery;
- //navs
- //forms
- //dropdowns
- //modals
- //other
- // *** Init plugin via data atributes ***
- //init (old)
- _selectInput2.default.init();
- _rangeSlider2.default.init();
- window.layers = {
- alert: _alert2.default
- };
- $(document).ready(function () {
- //navs
- // navs.initDataSelectors();
- // navs.initJqueryPlugin();
- _navs2.default.init();
- //Alerts
- // alert.initDataSelectors();
- // alert.initJqueryPlugin();
- _alert2.default.init();
- //Dropdown
- _dropdown2.default.initDataSelectors();
- //Tooltips
- _tooltips2.default.initDataSelectors();
- //Inline Editor
- _inlineEditor2.default.initDataSelectors();
- //Content Slider
- _contentSlider2.default.initDataSelectors();
- //Selects
- _selects2.default.initDataSelectors();
- //Check all
- _CheckAll2.default.initDataSelectors();
- //Sticky
- _sticky2.default.initDataSelectors();
- //Scroll To
- _scrollTo2.default.initDataSelectors();
- //off Canvas
- _offCanvas2.default.initDataSelectors();
- //toggler
- _toggler2.default.initDataSelectors();
- //Switcher
- _switcher2.default.initDataSelectors();
- });
- //*** Add plugins to juqery interface ***
- //Dropdown
- _dropdown2.default.initJqueryPlugin();
- //Tooltips
- _tooltips2.default.initJqueryPlugin();
- //Inline Editor
- _inlineEditor2.default.initJqueryPlugin();
- //Content Slider
- _contentSlider2.default.initJqueryPlugin();
- //Switcher
- _switcher2.default.initJqueryPlugin();
- //Selects
- _selects2.default.initJqueryPlugin();
- //Check all
- _CheckAll2.default.initJqueryPlugin();
- //Sticky
- _sticky2.default.initJqueryPlugin();
- //Scroll To
- _scrollTo2.default.initJqueryPlugin();
- //off Canvas
- _offCanvas2.default.initJqueryPlugin();
- //toggler
- _toggler2.default.initJqueryPlugin();
- /***/ }),
- /* 29 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __WEBPACK_LOCAL_MODULE_0__, __WEBPACK_LOCAL_MODULE_0__factory, __WEBPACK_LOCAL_MODULE_0__module;var __WEBPACK_LOCAL_MODULE_1__, __WEBPACK_LOCAL_MODULE_1__factory, __WEBPACK_LOCAL_MODULE_1__module;var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- /**
- * sifter.js
- * Copyright (c) 2013 Brian Reavis & contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License. You may obtain a copy of the License at:
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
- * ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- *
- * @author Brian Reavis <brian@thirdroute.com>
- */
- (function (root, factory) {
- if (true) {
- !(__WEBPACK_LOCAL_MODULE_0__factory = (factory), (__WEBPACK_LOCAL_MODULE_0__module = { id: "sifter", exports: {}, loaded: false }), __WEBPACK_LOCAL_MODULE_0__ = (typeof __WEBPACK_LOCAL_MODULE_0__factory === 'function' ? (__WEBPACK_LOCAL_MODULE_0__factory.call(__WEBPACK_LOCAL_MODULE_0__module.exports, __webpack_require__, __WEBPACK_LOCAL_MODULE_0__module.exports, __WEBPACK_LOCAL_MODULE_0__module)) : __WEBPACK_LOCAL_MODULE_0__factory), (__WEBPACK_LOCAL_MODULE_0__module.loaded = true), __WEBPACK_LOCAL_MODULE_0__ === undefined && (__WEBPACK_LOCAL_MODULE_0__ = __WEBPACK_LOCAL_MODULE_0__module.exports));
- } else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
- module.exports = factory();
- } else {
- root.Sifter = factory();
- }
- })(undefined, function () {
- /**
- * Textually searches arrays and hashes of objects
- * by property (or multiple properties). Designed
- * specifically for autocomplete.
- *
- * @constructor
- * @param {array|object} items
- * @param {object} items
- */
- var Sifter = function Sifter(items, settings) {
- this.items = items;
- this.settings = settings || { diacritics: true };
- };
- /**
- * Splits a search string into an array of individual
- * regexps to be used to match results.
- *
- * @param {string} query
- * @returns {array}
- */
- Sifter.prototype.tokenize = function (query) {
- query = trim(String(query || '').toLowerCase());
- if (!query || !query.length) return [];
- var i, n, regex, letter;
- var tokens = [];
- var words = query.split(/ +/);
- for (i = 0, n = words.length; i < n; i++) {
- regex = escape_regex(words[i]);
- if (this.settings.diacritics) {
- for (letter in DIACRITICS) {
- if (DIACRITICS.hasOwnProperty(letter)) {
- regex = regex.replace(new RegExp(letter, 'g'), DIACRITICS[letter]);
- }
- }
- }
- tokens.push({
- string: words[i],
- regex: new RegExp(regex, 'i')
- });
- }
- return tokens;
- };
- /**
- * Iterates over arrays and hashes.
- *
- * ```
- * this.iterator(this.items, function(item, id) {
- * // invoked for each item
- * });
- * ```
- *
- * @param {array|object} object
- */
- Sifter.prototype.iterator = function (object, callback) {
- var iterator;
- if (is_array(object)) {
- iterator = Array.prototype.forEach || function (callback) {
- for (var i = 0, n = this.length; i < n; i++) {
- callback(this[i], i, this);
- }
- };
- } else {
- iterator = function iterator(callback) {
- for (var key in this) {
- if (this.hasOwnProperty(key)) {
- callback(this[key], key, this);
- }
- }
- };
- }
- iterator.apply(object, [callback]);
- };
- /**
- * Returns a function to be used to score individual results.
- *
- * Good matches will have a higher score than poor matches.
- * If an item is not a match, 0 will be returned by the function.
- *
- * @param {object|string} search
- * @param {object} options (optional)
- * @returns {function}
- */
- Sifter.prototype.getScoreFunction = function (search, options) {
- var self, fields, tokens, token_count, nesting;
- self = this;
- search = self.prepareSearch(search, options);
- tokens = search.tokens;
- fields = search.options.fields;
- token_count = tokens.length;
- nesting = search.options.nesting;
- /**
- * Calculates how close of a match the
- * given value is against a search token.
- *
- * @param {mixed} value
- * @param {object} token
- * @return {number}
- */
- var scoreValue = function scoreValue(value, token) {
- var score, pos;
- if (!value) return 0;
- value = String(value || '');
- pos = value.search(token.regex);
- if (pos === -1) return 0;
- score = token.string.length / value.length;
- if (pos === 0) score += 0.5;
- return score;
- };
- /**
- * Calculates the score of an object
- * against the search query.
- *
- * @param {object} token
- * @param {object} data
- * @return {number}
- */
- var scoreObject = function () {
- var field_count = fields.length;
- if (!field_count) {
- return function () {
- return 0;
- };
- }
- if (field_count === 1) {
- return function (token, data) {
- return scoreValue(getattr(data, fields[0], nesting), token);
- };
- }
- return function (token, data) {
- for (var i = 0, sum = 0; i < field_count; i++) {
- sum += scoreValue(getattr(data, fields[i], nesting), token);
- }
- return sum / field_count;
- };
- }();
- if (!token_count) {
- return function () {
- return 0;
- };
- }
- if (token_count === 1) {
- return function (data) {
- return scoreObject(tokens[0], data);
- };
- }
- if (search.options.conjunction === 'and') {
- return function (data) {
- var score;
- for (var i = 0, sum = 0; i < token_count; i++) {
- score = scoreObject(tokens[i], data);
- if (score <= 0) return 0;
- sum += score;
- }
- return sum / token_count;
- };
- } else {
- return function (data) {
- for (var i = 0, sum = 0; i < token_count; i++) {
- sum += scoreObject(tokens[i], data);
- }
- return sum / token_count;
- };
- }
- };
- /**
- * Returns a function that can be used to compare two
- * results, for sorting purposes. If no sorting should
- * be performed, `null` will be returned.
- *
- * @param {string|object} search
- * @param {object} options
- * @return function(a,b)
- */
- Sifter.prototype.getSortFunction = function (search, options) {
- var i, n, self, field, fields, fields_count, multiplier, multipliers, get_field, implicit_score, sort;
- self = this;
- search = self.prepareSearch(search, options);
- sort = !search.query && options.sort_empty || options.sort;
- /**
- * Fetches the specified sort field value
- * from a search result item.
- *
- * @param {string} name
- * @param {object} result
- * @return {mixed}
- */
- get_field = function get_field(name, result) {
- if (name === '$score') return result.score;
- return getattr(self.items[result.id], name, options.nesting);
- };
- // parse options
- fields = [];
- if (sort) {
- for (i = 0, n = sort.length; i < n; i++) {
- if (search.query || sort[i].field !== '$score') {
- fields.push(sort[i]);
- }
- }
- }
- // the "$score" field is implied to be the primary
- // sort field, unless it's manually specified
- if (search.query) {
- implicit_score = true;
- for (i = 0, n = fields.length; i < n; i++) {
- if (fields[i].field === '$score') {
- implicit_score = false;
- break;
- }
- }
- if (implicit_score) {
- fields.unshift({ field: '$score', direction: 'desc' });
- }
- } else {
- for (i = 0, n = fields.length; i < n; i++) {
- if (fields[i].field === '$score') {
- fields.splice(i, 1);
- break;
- }
- }
- }
- multipliers = [];
- for (i = 0, n = fields.length; i < n; i++) {
- multipliers.push(fields[i].direction === 'desc' ? -1 : 1);
- }
- // build function
- fields_count = fields.length;
- if (!fields_count) {
- return null;
- } else if (fields_count === 1) {
- field = fields[0].field;
- multiplier = multipliers[0];
- return function (a, b) {
- return multiplier * cmp(get_field(field, a), get_field(field, b));
- };
- } else {
- return function (a, b) {
- var i, result, a_value, b_value, field;
- for (i = 0; i < fields_count; i++) {
- field = fields[i].field;
- result = multipliers[i] * cmp(get_field(field, a), get_field(field, b));
- if (result) return result;
- }
- return 0;
- };
- }
- };
- /**
- * Parses a search query and returns an object
- * with tokens and fields ready to be populated
- * with results.
- *
- * @param {string} query
- * @param {object} options
- * @returns {object}
- */
- Sifter.prototype.prepareSearch = function (query, options) {
- if ((typeof query === 'undefined' ? 'undefined' : _typeof(query)) === 'object') return query;
- options = extend({}, options);
- var option_fields = options.fields;
- var option_sort = options.sort;
- var option_sort_empty = options.sort_empty;
- if (option_fields && !is_array(option_fields)) options.fields = [option_fields];
- if (option_sort && !is_array(option_sort)) options.sort = [option_sort];
- if (option_sort_empty && !is_array(option_sort_empty)) options.sort_empty = [option_sort_empty];
- return {
- options: options,
- query: String(query || '').toLowerCase(),
- tokens: this.tokenize(query),
- total: 0,
- items: []
- };
- };
- /**
- * Searches through all items and returns a sorted array of matches.
- *
- * The `options` parameter can contain:
- *
- * - fields {string|array}
- * - sort {array}
- * - score {function}
- * - filter {bool}
- * - limit {integer}
- *
- * Returns an object containing:
- *
- * - options {object}
- * - query {string}
- * - tokens {array}
- * - total {int}
- * - items {array}
- *
- * @param {string} query
- * @param {object} options
- * @returns {object}
- */
- Sifter.prototype.search = function (query, options) {
- var self = this,
- value,
- score,
- search,
- calculateScore;
- var fn_sort;
- var fn_score;
- search = this.prepareSearch(query, options);
- options = search.options;
- query = search.query;
- // generate result scoring function
- fn_score = options.score || self.getScoreFunction(search);
- // perform search and sort
- if (query.length) {
- self.iterator(self.items, function (item, id) {
- score = fn_score(item);
- if (options.filter === false || score > 0) {
- search.items.push({ 'score': score, 'id': id });
- }
- });
- } else {
- self.iterator(self.items, function (item, id) {
- search.items.push({ 'score': 1, 'id': id });
- });
- }
- fn_sort = self.getSortFunction(search, options);
- if (fn_sort) search.items.sort(fn_sort);
- // apply limits
- search.total = search.items.length;
- if (typeof options.limit === 'number') {
- search.items = search.items.slice(0, options.limit);
- }
- return search;
- };
- // utilities
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- var cmp = function cmp(a, b) {
- if (typeof a === 'number' && typeof b === 'number') {
- return a > b ? 1 : a < b ? -1 : 0;
- }
- a = asciifold(String(a || ''));
- b = asciifold(String(b || ''));
- if (a > b) return 1;
- if (b > a) return -1;
- return 0;
- };
- var extend = function extend(a, b) {
- var i, n, k, object;
- for (i = 1, n = arguments.length; i < n; i++) {
- object = arguments[i];
- if (!object) continue;
- for (k in object) {
- if (object.hasOwnProperty(k)) {
- a[k] = object[k];
- }
- }
- }
- return a;
- };
- /**
- * A property getter resolving dot-notation
- * @param {Object} obj The root object to fetch property on
- * @param {String} name The optionally dotted property name to fetch
- * @param {Boolean} nesting Handle nesting or not
- * @return {Object} The resolved property value
- */
- var getattr = function getattr(obj, name, nesting) {
- if (!obj || !name) return;
- if (!nesting) return obj[name];
- var names = name.split(".");
- while (names.length && (obj = obj[names.shift()])) {}
- return obj;
- };
- var trim = function trim(str) {
- return (str + '').replace(/^\s+|\s+$|/g, '');
- };
- var escape_regex = function escape_regex(str) {
- return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
- };
- var is_array = Array.isArray || typeof $ !== 'undefined' && $.isArray || function (object) {
- return Object.prototype.toString.call(object) === '[object Array]';
- };
- var DIACRITICS = {
- 'a': '[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]',
- 'b': '[b␢βΒB฿𐌁ᛒ]',
- 'c': '[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]',
- 'd': '[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]',
- 'e': '[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]',
- 'f': '[fƑƒḞḟ]',
- 'g': '[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]',
- 'h': '[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]',
- 'i': '[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]',
- 'j': '[jȷĴĵɈɉʝɟʲ]',
- 'k': '[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]',
- 'l': '[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]',
- 'n': '[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]',
- 'o': '[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]',
- 'p': '[pṔṕṖṗⱣᵽƤƥᵱ]',
- 'q': '[qꝖꝗʠɊɋꝘꝙq̃]',
- 'r': '[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]',
- 's': '[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]',
- 't': '[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]',
- 'u': '[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]',
- 'v': '[vṼṽṾṿƲʋꝞꝟⱱʋ]',
- 'w': '[wẂẃẀẁŴŵẄẅẆẇẈẉ]',
- 'x': '[xẌẍẊẋχ]',
- 'y': '[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]',
- 'z': '[zŹźẐẑŽžŻżẒẓẔẕƵƶ]'
- };
- var asciifold = function () {
- var i, n, k, chunk;
- var foreignletters = '';
- var lookup = {};
- for (k in DIACRITICS) {
- if (DIACRITICS.hasOwnProperty(k)) {
- chunk = DIACRITICS[k].substring(2, DIACRITICS[k].length - 1);
- foreignletters += chunk;
- for (i = 0, n = chunk.length; i < n; i++) {
- lookup[chunk.charAt(i)] = k;
- }
- }
- }
- var regexp = new RegExp('[' + foreignletters + ']', 'g');
- return function (str) {
- return str.replace(regexp, function (foreignletter) {
- return lookup[foreignletter];
- }).toLowerCase();
- };
- }();
- // export
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- return Sifter;
- });
- /**
- * microplugin.js
- * Copyright (c) 2013 Brian Reavis & contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License. You may obtain a copy of the License at:
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
- * ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- *
- * @author Brian Reavis <brian@thirdroute.com>
- */
- (function (root, factory) {
- if (true) {
- !(__WEBPACK_LOCAL_MODULE_1__factory = (factory), (__WEBPACK_LOCAL_MODULE_1__module = { id: "microplugin", exports: {}, loaded: false }), __WEBPACK_LOCAL_MODULE_1__ = (typeof __WEBPACK_LOCAL_MODULE_1__factory === 'function' ? (__WEBPACK_LOCAL_MODULE_1__factory.call(__WEBPACK_LOCAL_MODULE_1__module.exports, __webpack_require__, __WEBPACK_LOCAL_MODULE_1__module.exports, __WEBPACK_LOCAL_MODULE_1__module)) : __WEBPACK_LOCAL_MODULE_1__factory), (__WEBPACK_LOCAL_MODULE_1__module.loaded = true), __WEBPACK_LOCAL_MODULE_1__ === undefined && (__WEBPACK_LOCAL_MODULE_1__ = __WEBPACK_LOCAL_MODULE_1__module.exports));
- } else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
- module.exports = factory();
- } else {
- root.MicroPlugin = factory();
- }
- })(undefined, function () {
- var MicroPlugin = {};
- MicroPlugin.mixin = function (Interface) {
- Interface.plugins = {};
- /**
- * Initializes the listed plugins (with options).
- * Acceptable formats:
- *
- * List (without options):
- * ['a', 'b', 'c']
- *
- * List (with options):
- * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
- *
- * Hash (with options):
- * {'a': { ... }, 'b': { ... }, 'c': { ... }}
- *
- * @param {mixed} plugins
- */
- Interface.prototype.initializePlugins = function (plugins) {
- var i, n, key;
- var self = this;
- var queue = [];
- self.plugins = {
- names: [],
- settings: {},
- requested: {},
- loaded: {}
- };
- if (utils.isArray(plugins)) {
- for (i = 0, n = plugins.length; i < n; i++) {
- if (typeof plugins[i] === 'string') {
- queue.push(plugins[i]);
- } else {
- self.plugins.settings[plugins[i].name] = plugins[i].options;
- queue.push(plugins[i].name);
- }
- }
- } else if (plugins) {
- for (key in plugins) {
- if (plugins.hasOwnProperty(key)) {
- self.plugins.settings[key] = plugins[key];
- queue.push(key);
- }
- }
- }
- while (queue.length) {
- self.require(queue.shift());
- }
- };
- Interface.prototype.loadPlugin = function (name) {
- var self = this;
- var plugins = self.plugins;
- var plugin = Interface.plugins[name];
- if (!Interface.plugins.hasOwnProperty(name)) {
- //throw new Error('Unable to find "' + name + '" plugin');
- }
- else{
- plugins.requested[name] = true;
- plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
- plugins.names.push(name);
- }
- };
- /**
- * Initializes a plugin.
- *
- * @param {string} name
- */
- Interface.prototype.require = function (name) {
- var self = this;
- var plugins = self.plugins;
- if (!self.plugins.loaded.hasOwnProperty(name)) {
- if (plugins.requested[name]) {
- throw new Error('Plugin has circular dependency ("' + name + '")');
- }
- self.loadPlugin(name);
- }
- return plugins.loaded[name];
- };
- /**
- * Registers a plugin.
- *
- * @param {string} name
- * @param {function} fn
- */
- Interface.define = function (name, fn) {
- Interface.plugins[name] = {
- 'name': name,
- 'fn': fn
- };
- };
- };
- var utils = {
- isArray: Array.isArray || function (vArg) {
- return Object.prototype.toString.call(vArg) === '[object Array]';
- }
- };
- return MicroPlugin;
- });
- /**
- * selectize.js (v0.12.4)
- * Copyright (c) 2013–2015 Brian Reavis & contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License. You may obtain a copy of the License at:
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
- * ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- *
- * @author Brian Reavis <brian@thirdroute.com>
- */
- /*jshint curly:false */
- /*jshint browser:true */
- (function (root, factory) {
- if (true) {
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1), __WEBPACK_LOCAL_MODULE_0__, __WEBPACK_LOCAL_MODULE_1__], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
- module.exports = factory(require('jquery'), require('sifter'), require('microplugin'));
- } else {
- root.Selectize = factory(root.jQuery, root.Sifter, root.MicroPlugin);
- }
- })(undefined, function ($, Sifter, MicroPlugin) {
- 'use strict';
- var highlight = function highlight($element, pattern) {
- if (typeof pattern === 'string' && !pattern.length) return;
- var regex = typeof pattern === 'string' ? new RegExp(pattern, 'i') : pattern;
- var highlight = function highlight(node) {
- var skip = 0;
- if (node.nodeType === 3) {
- var pos = node.data.search(regex);
- if (pos >= 0 && node.data.length > 0) {
- var match = node.data.match(regex);
- var spannode = document.createElement('span');
- spannode.className = 'highlight';
- var middlebit = node.splitText(pos);
- var endbit = middlebit.splitText(match[0].length);
- var middleclone = middlebit.cloneNode(true);
- spannode.appendChild(middleclone);
- middlebit.parentNode.replaceChild(spannode, middlebit);
- skip = 1;
- }
- } else if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
- for (var i = 0; i < node.childNodes.length; ++i) {
- i += highlight(node.childNodes[i]);
- }
- }
- return skip;
- };
- return $element.each(function () {
- highlight(this);
- });
- };
- /**
- * removeHighlight fn copied from highlight v5 and
- * edited to remove with() and pass js strict mode
- */
- $.fn.removeHighlight = function () {
- return this.find("span.highlight").each(function () {
- this.parentNode.firstChild.nodeName;
- var parent = this.parentNode;
- parent.replaceChild(this.firstChild, this);
- parent.normalize();
- }).end();
- };
- var MicroEvent = function MicroEvent() {};
- MicroEvent.prototype = {
- on: function on(event, fct) {
- this._events = this._events || {};
- this._events[event] = this._events[event] || [];
- this._events[event].push(fct);
- },
- off: function off(event, fct) {
- var n = arguments.length;
- if (n === 0) return delete this._events;
- if (n === 1) return delete this._events[event];
- this._events = this._events || {};
- if (event in this._events === false) return;
- this._events[event].splice(this._events[event].indexOf(fct), 1);
- },
- trigger: function trigger(event /* , args... */) {
- this._events = this._events || {};
- if (event in this._events === false) return;
- for (var i = 0; i < this._events[event].length; i++) {
- this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
- }
- }
- };
- /**
- * Mixin will delegate all MicroEvent.js function in the destination object.
- *
- * - MicroEvent.mixin(Foobar) will make Foobar able to use MicroEvent
- *
- * @param {object} the object which will support MicroEvent
- */
- MicroEvent.mixin = function (destObject) {
- var props = ['on', 'off', 'trigger'];
- for (var i = 0; i < props.length; i++) {
- destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
- }
- };
- var IS_MAC = /Mac/.test(navigator.userAgent);
- var KEY_A = 65;
- var KEY_COMMA = 188;
- var KEY_RETURN = 13;
- var KEY_ESC = 27;
- var KEY_LEFT = 37;
- var KEY_UP = 38;
- var KEY_P = 80;
- var KEY_RIGHT = 39;
- var KEY_DOWN = 40;
- var KEY_N = 78;
- var KEY_BACKSPACE = 8;
- var KEY_DELETE = 46;
- var KEY_SHIFT = 16;
- var KEY_CMD = IS_MAC ? 91 : 17;
- var KEY_CTRL = IS_MAC ? 18 : 17;
- var KEY_TAB = 9;
- var TAG_SELECT = 1;
- var TAG_INPUT = 2;
- // for now, android support in general is too spotty to support validity
- var SUPPORTS_VALIDITY_API = !/android/i.test(window.navigator.userAgent) && !!document.createElement('input').validity;
- var isset = function isset(object) {
- return typeof object !== 'undefined';
- };
- /**
- * Converts a scalar to its best string representation
- * for hash keys and HTML attribute values.
- *
- * Transformations:
- * 'str' -> 'str'
- * null -> ''
- * undefined -> ''
- * true -> '1'
- * false -> '0'
- * 0 -> '0'
- * 1 -> '1'
- *
- * @param {string} value
- * @returns {string|null}
- */
- var hash_key = function hash_key(value) {
- if (typeof value === 'undefined' || value === null) return null;
- if (typeof value === 'boolean') return value ? '1' : '0';
- return value + '';
- };
- /**
- * Escapes a string for use within HTML.
- *
- * @param {string} str
- * @returns {string}
- */
- var escape_html = function escape_html(str) {
- return (str + '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
- };
- /**
- * Escapes "$" characters in replacement strings.
- *
- * @param {string} str
- * @returns {string}
- */
- var escape_replace = function escape_replace(str) {
- return (str + '').replace(/\$/g, '$$$$');
- };
- var hook = {};
- /**
- * Wraps `method` on `self` so that `fn`
- * is invoked before the original method.
- *
- * @param {object} self
- * @param {string} method
- * @param {function} fn
- */
- hook.before = function (self, method, fn) {
- var original = self[method];
- self[method] = function () {
- fn.apply(self, arguments);
- return original.apply(self, arguments);
- };
- };
- /**
- * Wraps `method` on `self` so that `fn`
- * is invoked after the original method.
- *
- * @param {object} self
- * @param {string} method
- * @param {function} fn
- */
- hook.after = function (self, method, fn) {
- var original = self[method];
- self[method] = function () {
- var result = original.apply(self, arguments);
- fn.apply(self, arguments);
- return result;
- };
- };
- /**
- * Wraps `fn` so that it can only be invoked once.
- *
- * @param {function} fn
- * @returns {function}
- */
- var once = function once(fn) {
- var called = false;
- return function () {
- if (called) return;
- called = true;
- fn.apply(this, arguments);
- };
- };
- /**
- * Wraps `fn` so that it can only be called once
- * every `delay` milliseconds (invoked on the falling edge).
- *
- * @param {function} fn
- * @param {int} delay
- * @returns {function}
- */
- var debounce = function debounce(fn, delay) {
- var timeout;
- return function () {
- var self = this;
- var args = arguments;
- window.clearTimeout(timeout);
- timeout = window.setTimeout(function () {
- fn.apply(self, args);
- }, delay);
- };
- };
- /**
- * Debounce all fired events types listed in `types`
- * while executing the provided `fn`.
- *
- * @param {object} self
- * @param {array} types
- * @param {function} fn
- */
- var debounce_events = function debounce_events(self, types, fn) {
- var type;
- var trigger = self.trigger;
- var event_args = {};
- // override trigger method
- self.trigger = function () {
- var type = arguments[0];
- if (types.indexOf(type) !== -1) {
- event_args[type] = arguments;
- } else {
- return trigger.apply(self, arguments);
- }
- };
- // invoke provided function
- fn.apply(self, []);
- self.trigger = trigger;
- // trigger queued events
- for (type in event_args) {
- if (event_args.hasOwnProperty(type)) {
- trigger.apply(self, event_args[type]);
- }
- }
- };
- /**
- * A workaround for http://bugs.jquery.com/ticket/6696
- *
- * @param {object} $parent - Parent element to listen on.
- * @param {string} event - Event name.
- * @param {string} selector - Descendant selector to filter by.
- * @param {function} fn - Event handler.
- */
- var watchChildEvent = function watchChildEvent($parent, event, selector, fn) {
- $parent.on(event, selector, function (e) {
- var child = e.target;
- while (child && child.parentNode !== $parent[0]) {
- child = child.parentNode;
- }
- e.currentTarget = child;
- return fn.apply(this, [e]);
- });
- };
- /**
- * Determines the current selection within a text input control.
- * Returns an object containing:
- * - start
- * - length
- *
- * @param {object} input
- * @returns {object}
- */
- var getSelection = function getSelection(input) {
- var result = {};
- if ('selectionStart' in input) {
- result.start = input.selectionStart;
- result.length = input.selectionEnd - result.start;
- } else if (document.selection) {
- input.focus();
- var sel = document.selection.createRange();
- var selLen = document.selection.createRange().text.length;
- sel.moveStart('character', -input.value.length);
- result.start = sel.text.length - selLen;
- result.length = selLen;
- }
- return result;
- };
- /**
- * Copies CSS properties from one element to another.
- *
- * @param {object} $from
- * @param {object} $to
- * @param {array} properties
- */
- var transferStyles = function transferStyles($from, $to, properties) {
- var i,
- n,
- styles = {};
- if (properties) {
- for (i = 0, n = properties.length; i < n; i++) {
- styles[properties[i]] = $from.css(properties[i]);
- }
- } else {
- styles = $from.css();
- }
- $to.css(styles);
- };
- /**
- * Measures the width of a string within a
- * parent element (in pixels).
- *
- * @param {string} str
- * @param {object} $parent
- * @returns {int}
- */
- var measureString = function measureString(str, $parent) {
- if (!str) {
- return 0;
- }
- var $test = $('<test>').css({
- position: 'absolute',
- top: -99999,
- left: -99999,
- width: 'auto',
- padding: 0,
- whiteSpace: 'pre'
- }).text(str).appendTo('body');
- transferStyles($parent, $test, ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform']);
- var width = $test.width();
- $test.remove();
- return width;
- };
- /**
- * Sets up an input to grow horizontally as the user
- * types. If the value is changed manually, you can
- * trigger the "update" handler to resize:
- *
- * $input.trigger('update');
- *
- * @param {object} $input
- */
- var autoGrow = function autoGrow($input) {
- var currentWidth = null;
- var update = function update(e, options) {
- var value, keyCode, printable, placeholder, width;
- var shift, character, selection;
- e = e || window.event || {};
- options = options || {};
- if (e.metaKey || e.altKey) return;
- if (!options.force && $input.data('grow') === false) return;
- value = $input.val();
- if (e.type && e.type.toLowerCase() === 'keydown') {
- keyCode = e.keyCode;
- printable = keyCode >= 97 && keyCode <= 122 || // a-z
- keyCode >= 65 && keyCode <= 90 || // A-Z
- keyCode >= 48 && keyCode <= 57 || // 0-9
- keyCode === 32 // space
- ;
- if (keyCode === KEY_DELETE || keyCode === KEY_BACKSPACE) {
- selection = getSelection($input[0]);
- if (selection.length) {
- value = value.substring(0, selection.start) + value.substring(selection.start + selection.length);
- } else if (keyCode === KEY_BACKSPACE && selection.start) {
- value = value.substring(0, selection.start - 1) + value.substring(selection.start + 1);
- } else if (keyCode === KEY_DELETE && typeof selection.start !== 'undefined') {
- value = value.substring(0, selection.start) + value.substring(selection.start + 1);
- }
- } else if (printable) {
- shift = e.shiftKey;
- character = String.fromCharCode(e.keyCode);
- if (shift) character = character.toUpperCase();else character = character.toLowerCase();
- value += character;
- }
- }
- placeholder = $input.attr('placeholder');
- if (!value && placeholder) {
- value = placeholder;
- }
- width = measureString(value, $input) + 4;
- if (width !== currentWidth) {
- currentWidth = width;
- $input.width(width);
- $input.triggerHandler('resize');
- }
- };
- $input.on('keydown keyup update blur', update);
- update();
- };
- var domToString = function domToString(d) {
- var tmp = document.createElement('div');
- tmp.appendChild(d.cloneNode(true));
- return tmp.innerHTML;
- };
- var logError = function logError(message, options) {
- if (!options) options = {};
- var component = "Selectize";
- console.error(component + ": " + message);
- if (options.explanation) {
- // console.group is undefined in <IE11
- if (console.group) console.group();
- console.error(options.explanation);
- if (console.group) console.groupEnd();
- }
- };
- var Selectize = function Selectize($input, settings) {
- var key,
- i,
- n,
- dir,
- input,
- self = this;
- input = $input[0];
- input.selectize = self;
- // detect rtl environment
- var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
- dir = computedStyle ? computedStyle.getPropertyValue('direction') : input.currentStyle && input.currentStyle.direction;
- dir = dir || $input.parents('[dir]:first').attr('dir') || '';
- // setup default state
- $.extend(self, {
- order: 0,
- settings: settings,
- $input: $input,
- tabIndex: $input.attr('tabindex') || '',
- tagType: input.tagName.toLowerCase() === 'select' ? TAG_SELECT : TAG_INPUT,
- rtl: /rtl/i.test(dir),
- eventNS: '.selectize' + ++Selectize.count,
- highlightedValue: null,
- isOpen: false,
- isDisabled: false,
- isRequired: $input.is('[required]'),
- isInvalid: false,
- isLocked: false,
- isFocused: false,
- isInputHidden: false,
- isSetup: false,
- isShiftDown: false,
- isCmdDown: false,
- isCtrlDown: false,
- ignoreFocus: false,
- ignoreBlur: false,
- ignoreHover: false,
- hasOptions: false,
- currentResults: null,
- lastValue: '',
- caretPos: 0,
- loading: 0,
- loadedSearches: {},
- $activeOption: null,
- $activeItems: [],
- optgroups: {},
- options: {},
- userOptions: {},
- items: [],
- renderCache: {},
- onSearchChange: settings.loadThrottle === null ? self.onSearchChange : debounce(self.onSearchChange, settings.loadThrottle)
- });
- // search system
- self.sifter = new Sifter(this.options, { diacritics: settings.diacritics });
- // build options table
- if (self.settings.options) {
- for (i = 0, n = self.settings.options.length; i < n; i++) {
- self.registerOption(self.settings.options[i]);
- }
- delete self.settings.options;
- }
- // build optgroup table
- if (self.settings.optgroups) {
- for (i = 0, n = self.settings.optgroups.length; i < n; i++) {
- self.registerOptionGroup(self.settings.optgroups[i]);
- }
- delete self.settings.optgroups;
- }
- // option-dependent defaults
- self.settings.mode = self.settings.mode || (self.settings.maxItems === 1 ? 'single' : 'multi');
- if (typeof self.settings.hideSelected !== 'boolean') {
- self.settings.hideSelected = self.settings.mode === 'multi';
- }
- self.initializePlugins(self.settings.plugins);
- self.setupCallbacks();
- self.setupTemplates();
- self.setup();
- };
- // mixins
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- MicroEvent.mixin(Selectize);
- if (typeof MicroPlugin !== "undefined") {
- MicroPlugin.mixin(Selectize);
- } else {
- logError("Dependency MicroPlugin is missing", { explanation: "Make sure you either: (1) are using the \"standalone\" " + "version of Selectize, or (2) require MicroPlugin before you " + "load Selectize." });
- }
- // methods
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- $.extend(Selectize.prototype, {
- /**
- * Creates all elements and sets up event bindings.
- */
- setup: function setup() {
- var self = this;
- var settings = self.settings;
- var eventNS = self.eventNS;
- var $window = $(window);
- var $document = $(document);
- var $input = self.$input;
- var $wrapper;
- var $control;
- var $control_input;
- var $dropdown;
- var $dropdown_content;
- var $dropdown_parent;
- var inputMode;
- var timeout_blur;
- var timeout_focus;
- var classes;
- var classes_plugins;
- var inputId;
- inputMode = self.settings.mode;
- classes = $input.attr('class') || '';
- $wrapper = $('<div>').addClass(settings.wrapperClass).addClass(inputMode);
- $control = $('<div>').addClass(settings.inputClass + ' ' + classes).addClass('items').appendTo($wrapper);
- $control_input = $('<input type="text" autocomplete="off" />').appendTo($control).attr('tabindex', $input.is(':disabled') ? '-1' : self.tabIndex);
- $dropdown_parent = $(settings.dropdownParent || $wrapper);
- $dropdown = $('<div>').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);
- $dropdown_content = $('<div>').addClass(settings.dropdownContentClass).appendTo($dropdown);
- if (inputId = $input.attr('id')) {
- $control_input.attr('id', inputId + '-selectized');
- $("label[for='" + inputId + "']").attr('for', inputId + '-selectized');
- }
- if (self.settings.copyClassesToDropdown) {
- $dropdown.addClass(classes);
- }
- $wrapper.css({
- width: $input[0].style.width
- });
- if (self.plugins.names.length) {
- classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
- $wrapper.addClass(classes_plugins);
- $dropdown.addClass(classes_plugins);
- }
- if ((settings.maxItems === null || settings.maxItems > 1) && self.tagType === TAG_SELECT) {
- $input.attr('multiple', 'multiple');
- }
- if (self.settings.placeholder) {
- $control_input.attr('placeholder', settings.placeholder);
- }
- // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
- if (!self.settings.splitOn && self.settings.delimiter) {
- var delimiterEscaped = self.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
- self.settings.splitOn = new RegExp('\\s*' + delimiterEscaped + '+\\s*');
- }
- if ($input.attr('autocorrect')) {
- $control_input.attr('autocorrect', $input.attr('autocorrect'));
- }
- if ($input.attr('autocapitalize')) {
- $control_input.attr('autocapitalize', $input.attr('autocapitalize'));
- }
- self.$wrapper = $wrapper;
- self.$control = $control;
- self.$control_input = $control_input;
- self.$dropdown = $dropdown;
- self.$dropdown_content = $dropdown_content;
- $dropdown.on('mouseenter', '[data-selectable]', function () {
- return self.onOptionHover.apply(self, arguments);
- });
- $dropdown.on('mousedown click', '[data-selectable]', function () {
- return self.onOptionSelect.apply(self, arguments);
- });
- watchChildEvent($control, 'mousedown', '*:not(input)', function () {
- return self.onItemSelect.apply(self, arguments);
- });
- autoGrow($control_input);
- $control.on({
- mousedown: function mousedown() {
- return self.onMouseDown.apply(self, arguments);
- },
- click: function click() {
- return self.onClick.apply(self, arguments);
- }
- });
- $control_input.on({
- mousedown: function mousedown(e) {
- e.stopPropagation();
- },
- keydown: function keydown() {
- return self.onKeyDown.apply(self, arguments);
- },
- keyup: function keyup() {
- return self.onKeyUp.apply(self, arguments);
- },
- keypress: function keypress() {
- return self.onKeyPress.apply(self, arguments);
- },
- resize: function resize() {
- self.positionDropdown.apply(self, []);
- },
- blur: function blur() {
- return self.onBlur.apply(self, arguments);
- },
- focus: function focus() {
- self.ignoreBlur = false;return self.onFocus.apply(self, arguments);
- },
- paste: function paste() {
- return self.onPaste.apply(self, arguments);
- }
- });
- $document.on('keydown' + eventNS, function (e) {
- self.isCmdDown = e[IS_MAC ? 'metaKey' : 'ctrlKey'];
- self.isCtrlDown = e[IS_MAC ? 'altKey' : 'ctrlKey'];
- self.isShiftDown = e.shiftKey;
- });
- $document.on('keyup' + eventNS, function (e) {
- if (e.keyCode === KEY_CTRL) self.isCtrlDown = false;
- if (e.keyCode === KEY_SHIFT) self.isShiftDown = false;
- if (e.keyCode === KEY_CMD) self.isCmdDown = false;
- });
- $document.on('mousedown' + eventNS, function (e) {
- if (self.isFocused) {
- // prevent events on the dropdown scrollbar from causing the control to blur
- if (e.target === self.$dropdown[0] || e.target.parentNode === self.$dropdown[0]) {
- return false;
- }
- // blur on click outside
- if (!self.$control.has(e.target).length && e.target !== self.$control[0]) {
- self.blur(e.target);
- }
- }
- });
- $window.on(['scroll' + eventNS, 'resize' + eventNS].join(' '), function () {
- if (self.isOpen) {
- self.positionDropdown.apply(self, arguments);
- }
- });
- $window.on('mousemove' + eventNS, function () {
- self.ignoreHover = false;
- });
- // store original children and tab index so that they can be
- // restored when the destroy() method is called.
- this.revertSettings = {
- $children: $input.children().detach(),
- tabindex: $input.attr('tabindex')
- };
- $input.attr('tabindex', -1).hide().after(self.$wrapper);
- if ($.isArray(settings.items)) {
- self.setValue(settings.items);
- delete settings.items;
- }
- // feature detect for the validation API
- if (SUPPORTS_VALIDITY_API) {
- $input.on('invalid' + eventNS, function (e) {
- e.preventDefault();
- self.isInvalid = true;
- self.refreshState();
- });
- }
- self.updateOriginalInput();
- self.refreshItems();
- self.refreshState();
- self.updatePlaceholder();
- self.isSetup = true;
- if ($input.is(':disabled')) {
- self.disable();
- }
- self.on('change', this.onChange);
- $input.data('selectize', self);
- $input.addClass('selectized');
- self.trigger('initialize');
- // preload options
- if (settings.preload === true) {
- self.onSearchChange('');
- }
- },
- /**
- * Sets up default rendering functions.
- */
- setupTemplates: function setupTemplates() {
- var self = this;
- var field_label = self.settings.labelField;
- var field_optgroup = self.settings.optgroupLabelField;
- var templates = {
- 'optgroup': function optgroup(data) {
- return '<div class="optgroup">' + data.html + '</div>';
- },
- 'optgroup_header': function optgroup_header(data, escape) {
- return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
- },
- 'option': function option(data, escape) {
- if(data.description) {
- return '<div class="option">'
- + '<div class="title" style="font-size: 16px;">'+escape(data[field_label])+'</div>'
- + '<div class="desc">'
- + data['description']
- + '</div>'
- + '</div>';
- }
- return '<div class="option">' + escape(data[field_label]) + '</div>';
- },
- 'item': function item(data, escape) {
- if(data.description) {
- return '<div class="item">'
- + '<div class="title" style="font-size: 16px;">'+escape(data[field_label])+'</div>'
- + '<div class="desc">'
- + data['description']
- + '</div>'
- + '</div>';
- }
- return '<div class="item">' + escape(data[field_label]) + '</div>';
- },
- 'option_create': function option_create(data, escape) {
- return '<div class="create">Add <strong>' + escape(data.input) + '</strong>…</div>';
- }
- };
- self.settings.render = $.extend({}, templates, self.settings.render);
- },
- /**
- * Maps fired events to callbacks provided
- * in the settings used when creating the control.
- */
- setupCallbacks: function setupCallbacks() {
- var key,
- fn,
- callbacks = {
- 'initialize': 'onInitialize',
- 'change': 'onChange',
- 'item_add': 'onItemAdd',
- 'item_remove': 'onItemRemove',
- 'clear': 'onClear',
- 'option_add': 'onOptionAdd',
- 'option_remove': 'onOptionRemove',
- 'option_clear': 'onOptionClear',
- 'optgroup_add': 'onOptionGroupAdd',
- 'optgroup_remove': 'onOptionGroupRemove',
- 'optgroup_clear': 'onOptionGroupClear',
- 'dropdown_open': 'onDropdownOpen',
- 'dropdown_close': 'onDropdownClose',
- 'type': 'onType',
- 'load': 'onLoad',
- 'focus': 'onFocus',
- 'blur': 'onBlur'
- };
- for (key in callbacks) {
- if (callbacks.hasOwnProperty(key)) {
- fn = this.settings[callbacks[key]];
- if (fn) this.on(key, fn);
- }
- }
- },
- /**
- * Triggered when the main control element
- * has a click event.
- *
- * @param {object} e
- * @return {boolean}
- */
- onClick: function onClick(e) {
- var self = this;
- // necessary for mobile webkit devices (manual focus triggering
- // is ignored unless invoked within a click event)
- if (!self.isFocused) {
- self.focus();
- e.preventDefault();
- }
- },
- /**
- * Triggered when the main control element
- * has a mouse down event.
- *
- * @param {object} e
- * @return {boolean}
- */
- onMouseDown: function onMouseDown(e) {
- var self = this;
- var defaultPrevented = e.isDefaultPrevented();
- var $target = $(e.target);
- if (self.isFocused) {
- // retain focus by preventing native handling. if the
- // event target is the input it should not be modified.
- // otherwise, text selection within the input won't work.
- if (e.target !== self.$control_input[0]) {
- if (self.settings.mode === 'single') {
- // toggle dropdown
- self.isOpen ? self.close() : self.open();
- } else if (!defaultPrevented) {
- self.setActiveItem(null);
- }
- return false;
- }
- } else {
- // give control focus
- if (!defaultPrevented) {
- window.setTimeout(function () {
- self.focus();
- }, 0);
- }
- }
- },
- /**
- * Triggered when the value of the control has been changed.
- * This should propagate the event to the original DOM
- * input / select element.
- */
- onChange: function onChange() {
- this.$input.trigger('change');
- },
- /**
- * Triggered on <input> paste.
- *
- * @param {object} e
- * @returns {boolean}
- */
- onPaste: function onPaste(e) {
- var self = this;
- if (self.isFull() || self.isInputHidden || self.isLocked) {
- e.preventDefault();
- return;
- }
- // If a regex or string is included, this will split the pasted
- // input and create Items for each separate value
- if (self.settings.splitOn) {
- // Wait for pasted text to be recognized in value
- setTimeout(function () {
- var pastedText = self.$control_input.val();
- if (!pastedText.match(self.settings.splitOn)) {
- return;
- }
- var splitInput = $.trim(pastedText).split(self.settings.splitOn);
- for (var i = 0, n = splitInput.length; i < n; i++) {
- self.createItem(splitInput[i]);
- }
- }, 0);
- }
- },
- /**
- * Triggered on <input> keypress.
- *
- * @param {object} e
- * @returns {boolean}
- */
- onKeyPress: function onKeyPress(e) {
- if (this.isLocked) return e && e.preventDefault();
- var character = String.fromCharCode(e.keyCode || e.which);
- if (this.settings.create && this.settings.mode === 'multi' && character === this.settings.delimiter) {
- this.createItem();
- e.preventDefault();
- return false;
- }
- },
- /**
- * Triggered on <input> keydown.
- *
- * @param {object} e
- * @returns {boolean}
- */
- onKeyDown: function onKeyDown(e) {
- var isInput = e.target === this.$control_input[0];
- var self = this;
- if (self.isLocked) {
- if (e.keyCode !== KEY_TAB) {
- e.preventDefault();
- }
- return;
- }
- switch (e.keyCode) {
- case KEY_A:
- if (self.isCmdDown) {
- self.selectAll();
- return;
- }
- break;
- case KEY_ESC:
- if (self.isOpen) {
- e.preventDefault();
- e.stopPropagation();
- self.close();
- }
- return;
- case KEY_N:
- if (!e.ctrlKey || e.altKey) break;
- case KEY_DOWN:
- if (!self.isOpen && self.hasOptions) {
- self.open();
- } else if (self.$activeOption) {
- self.ignoreHover = true;
- var $next = self.getAdjacentOption(self.$activeOption, 1);
- if ($next.length) self.setActiveOption($next, true, true);
- }
- e.preventDefault();
- return;
- case KEY_P:
- if (!e.ctrlKey || e.altKey) break;
- case KEY_UP:
- if (self.$activeOption) {
- self.ignoreHover = true;
- var $prev = self.getAdjacentOption(self.$activeOption, -1);
- if ($prev.length) self.setActiveOption($prev, true, true);
- }
- e.preventDefault();
- return;
- case KEY_RETURN:
- if (self.isOpen && self.$activeOption) {
- self.onOptionSelect({ currentTarget: self.$activeOption });
- e.preventDefault();
- }
- return;
- case KEY_LEFT:
- self.advanceSelection(-1, e);
- return;
- case KEY_RIGHT:
- self.advanceSelection(1, e);
- return;
- case KEY_TAB:
- if (self.settings.selectOnTab && self.isOpen && self.$activeOption) {
- self.onOptionSelect({ currentTarget: self.$activeOption });
- // Default behaviour is to jump to the next field, we only want this
- // if the current field doesn't accept any more entries
- if (!self.isFull()) {
- e.preventDefault();
- }
- }
- if (self.settings.create && self.createItem()) {
- e.preventDefault();
- }
- return;
- case KEY_BACKSPACE:
- case KEY_DELETE:
- self.deleteSelection(e);
- return;
- }
- if ((self.isFull() || self.isInputHidden) && !(IS_MAC ? e.metaKey : e.ctrlKey)) {
- e.preventDefault();
- return;
- }
- },
- /**
- * Triggered on <input> keyup.
- *
- * @param {object} e
- * @returns {boolean}
- */
- onKeyUp: function onKeyUp(e) {
- var self = this;
- if (self.isLocked) return e && e.preventDefault();
- var value = self.$control_input.val() || '';
- if (self.lastValue !== value) {
- self.lastValue = value;
- self.onSearchChange(value);
- self.refreshOptions();
- self.trigger('type', value);
- }
- },
- /**
- * Invokes the user-provide option provider / loader.
- *
- * Note: this function is debounced in the Selectize
- * constructor (by `settings.loadThrottle` milliseconds)
- *
- * @param {string} value
- */
- onSearchChange: function onSearchChange(value) {
- var self = this;
- var fn = self.settings.load;
- if (!fn) return;
- if (self.loadedSearches.hasOwnProperty(value)) return;
- self.loadedSearches[value] = true;
- self.load(function (callback) {
- fn.apply(self, [value, callback]);
- });
- },
- /**
- * Triggered on <input> focus.
- *
- * @param {object} e (optional)
- * @returns {boolean}
- */
- onFocus: function onFocus(e) {
- var self = this;
- var wasFocused = self.isFocused;
- if (self.isDisabled) {
- self.blur();
- e && e.preventDefault();
- return false;
- }
- if (self.ignoreFocus) return;
- self.isFocused = true;
- if (self.settings.preload === 'focus') self.onSearchChange('');
- if (!wasFocused) self.trigger('focus');
- if (!self.$activeItems.length) {
- self.showInput();
- self.setActiveItem(null);
- self.refreshOptions(!!self.settings.openOnFocus);
- }
- self.refreshState();
- },
- /**
- * Triggered on <input> blur.
- *
- * @param {object} e
- * @param {Element} dest
- */
- onBlur: function onBlur(e, dest) {
- var self = this;
- if (!self.isFocused) return;
- self.isFocused = false;
- if (self.ignoreFocus) {
- return;
- } else if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) {
- // necessary to prevent IE closing the dropdown when the scrollbar is clicked
- self.ignoreBlur = true;
- self.onFocus(e);
- return;
- }
- var deactivate = function deactivate() {
- self.close();
- self.setTextboxValue('');
- self.setActiveItem(null);
- self.setActiveOption(null);
- self.setCaret(self.items.length);
- self.refreshState();
- // IE11 bug: element still marked as active
- dest && dest.focus && dest.focus();
- self.ignoreFocus = false;
- self.trigger('blur');
- };
- self.ignoreFocus = true;
- if (self.settings.create && self.settings.createOnBlur) {
- self.createItem(null, false, deactivate);
- } else {
- deactivate();
- }
- },
- /**
- * Triggered when the user rolls over
- * an option in the autocomplete dropdown menu.
- *
- * @param {object} e
- * @returns {boolean}
- */
- onOptionHover: function onOptionHover(e) {
- if (this.ignoreHover) return;
- this.setActiveOption(e.currentTarget, false);
- },
- /**
- * Triggered when the user clicks on an option
- * in the autocomplete dropdown menu.
- *
- * @param {object} e
- * @returns {boolean}
- */
- onOptionSelect: function onOptionSelect(e) {
- var value,
- $target,
- $option,
- self = this;
- if (e.preventDefault) {
- e.preventDefault();
- e.stopPropagation();
- }
- $target = $(e.currentTarget);
- if ($target.hasClass('create')) {
- self.createItem(null, function () {
- if (self.settings.closeAfterSelect) {
- self.close();
- }
- });
- } else {
- value = $target.attr('data-value');
- if (typeof value !== 'undefined') {
- self.lastQuery = null;
- self.setTextboxValue('');
- self.addItem(value);
- if (self.settings.closeAfterSelect) {
- self.close();
- } else if (!self.settings.hideSelected && e.type && /mouse/.test(e.type)) {
- self.setActiveOption(self.getOption(value));
- }
- }
- }
- },
- /**
- * Triggered when the user clicks on an item
- * that has been selected.
- *
- * @param {object} e
- * @returns {boolean}
- */
- onItemSelect: function onItemSelect(e) {
- var self = this;
- if (self.isLocked) return;
- if (self.settings.mode === 'multi') {
- e.preventDefault();
- self.setActiveItem(e.currentTarget, e);
- }
- },
- /**
- * Invokes the provided method that provides
- * results to a callback---which are then added
- * as options to the control.
- *
- * @param {function} fn
- */
- load: function load(fn) {
- var self = this;
- var $wrapper = self.$wrapper.addClass(self.settings.loadingClass);
- self.loading++;
- fn.apply(self, [function (results) {
- self.loading = Math.max(self.loading - 1, 0);
- if (results && results.length) {
- self.addOption(results);
- self.refreshOptions(self.isFocused && !self.isInputHidden);
- }
- if (!self.loading) {
- $wrapper.removeClass(self.settings.loadingClass);
- }
- self.trigger('load', results);
- }]);
- },
- /**
- * Sets the input field of the control to the specified value.
- *
- * @param {string} value
- */
- setTextboxValue: function setTextboxValue(value) {
- var $input = this.$control_input;
- var changed = $input.val() !== value;
- if (changed) {
- $input.val(value).triggerHandler('update');
- this.lastValue = value;
- }
- },
- /**
- * Returns the value of the control. If multiple items
- * can be selected (e.g. <select multiple>), this returns
- * an array. If only one item can be selected, this
- * returns a string.
- *
- * @returns {mixed}
- */
- getValue: function getValue() {
- if (this.tagType === TAG_SELECT && this.$input.attr('multiple')) {
- return this.items;
- } else {
- return this.items.join(this.settings.delimiter);
- }
- },
- /**
- * Resets the selected items to the given value.
- *
- * @param {mixed} value
- */
- setValue: function setValue(value, silent) {
- var events = silent ? [] : ['change'];
- debounce_events(this, events, function () {
- this.clear(silent);
- this.addItems(value, silent);
- });
- },
- /**
- * Sets the selected item.
- *
- * @param {object} $item
- * @param {object} e (optional)
- */
- setActiveItem: function setActiveItem($item, e) {
- var self = this;
- var eventName;
- var i, idx, begin, end, item, swap;
- var $last;
- if (self.settings.mode === 'single') return;
- $item = $($item);
- // clear the active selection
- if (!$item.length) {
- $(self.$activeItems).removeClass('active');
- self.$activeItems = [];
- if (self.isFocused) {
- self.showInput();
- }
- return;
- }
- // modify selection
- eventName = e && e.type.toLowerCase();
- if (eventName === 'mousedown' && self.isShiftDown && self.$activeItems.length) {
- $last = self.$control.children('.active:last');
- begin = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$last[0]]);
- end = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$item[0]]);
- if (begin > end) {
- swap = begin;
- begin = end;
- end = swap;
- }
- for (i = begin; i <= end; i++) {
- item = self.$control[0].childNodes[i];
- if (self.$activeItems.indexOf(item) === -1) {
- $(item).addClass('active');
- self.$activeItems.push(item);
- }
- }
- e.preventDefault();
- } else if (eventName === 'mousedown' && self.isCtrlDown || eventName === 'keydown' && this.isShiftDown) {
- if ($item.hasClass('active')) {
- idx = self.$activeItems.indexOf($item[0]);
- self.$activeItems.splice(idx, 1);
- $item.removeClass('active');
- } else {
- self.$activeItems.push($item.addClass('active')[0]);
- }
- } else {
- $(self.$activeItems).removeClass('active');
- self.$activeItems = [$item.addClass('active')[0]];
- }
- // ensure control has focus
- self.hideInput();
- if (!this.isFocused) {
- self.focus();
- }
- },
- /**
- * Sets the selected item in the dropdown menu
- * of available options.
- *
- * @param {object} $object
- * @param {boolean} scroll
- * @param {boolean} animate
- */
- setActiveOption: function setActiveOption($option, scroll, animate) {
- var height_menu, height_item, y;
- var scroll_top, scroll_bottom;
- var self = this;
- if (self.$activeOption) self.$activeOption.removeClass('active');
- self.$activeOption = null;
- $option = $($option);
- if (!$option.length) return;
- self.$activeOption = $option.addClass('active');
- if (scroll || !isset(scroll)) {
- height_menu = self.$dropdown_content.height();
- height_item = self.$activeOption.outerHeight(true);
- scroll = self.$dropdown_content.scrollTop() || 0;
- y = self.$activeOption.offset().top - self.$dropdown_content.offset().top + scroll;
- scroll_top = y;
- scroll_bottom = y - height_menu + height_item;
- if (y + height_item > height_menu + scroll) {
- self.$dropdown_content.stop().animate({ scrollTop: scroll_bottom }, animate ? self.settings.scrollDuration : 0);
- } else if (y < scroll) {
- self.$dropdown_content.stop().animate({ scrollTop: scroll_top }, animate ? self.settings.scrollDuration : 0);
- }
- }
- },
- /**
- * Selects all items (CTRL + A).
- */
- selectAll: function selectAll() {
- var self = this;
- if (self.settings.mode === 'single') return;
- self.$activeItems = Array.prototype.slice.apply(self.$control.children(':not(input)').addClass('active'));
- if (self.$activeItems.length) {
- self.hideInput();
- self.close();
- }
- self.focus();
- },
- /**
- * Hides the input element out of view, while
- * retaining its focus.
- */
- hideInput: function hideInput() {
- var self = this;
- self.setTextboxValue('');
- self.$control_input.css({ opacity: 0, position: 'absolute', left: self.rtl ? 10000 : -10000 });
- self.isInputHidden = true;
- },
- /**
- * Restores input visibility.
- */
- showInput: function showInput() {
- this.$control_input.css({ opacity: 1, position: 'relative', left: 0 });
- this.isInputHidden = false;
- },
- /**
- * Gives the control focus.
- */
- focus: function focus() {
- var self = this;
- if (self.isDisabled) return;
- self.ignoreFocus = true;
- self.$control_input[0].focus();
- window.setTimeout(function () {
- self.ignoreFocus = false;
- self.onFocus();
- }, 0);
- },
- /**
- * Forces the control out of focus.
- *
- * @param {Element} dest
- */
- blur: function blur(dest) {
- this.$control_input[0].blur();
- this.onBlur(null, dest);
- },
- /**
- * Returns a function that scores an object
- * to show how good of a match it is to the
- * provided query.
- *
- * @param {string} query
- * @param {object} options
- * @return {function}
- */
- getScoreFunction: function getScoreFunction(query) {
- return this.sifter.getScoreFunction(query, this.getSearchOptions());
- },
- /**
- * Returns search options for sifter (the system
- * for scoring and sorting results).
- *
- * @see https://github.com/brianreavis/sifter.js
- * @return {object}
- */
- getSearchOptions: function getSearchOptions() {
- var settings = this.settings;
- var sort = settings.sortField;
- if (typeof sort === 'string') {
- sort = [{ field: sort }];
- }
- return {
- fields: settings.searchField,
- conjunction: settings.searchConjunction,
- sort: sort
- };
- },
- /**
- * Searches through available options and returns
- * a sorted array of matches.
- *
- * Returns an object containing:
- *
- * - query {string}
- * - tokens {array}
- * - total {int}
- * - items {array}
- *
- * @param {string} query
- * @returns {object}
- */
- search: function search(query) {
- var i, value, score, result, calculateScore;
- var self = this;
- var settings = self.settings;
- var options = this.getSearchOptions();
- // validate user-provided result scoring function
- if (settings.score) {
- calculateScore = self.settings.score.apply(this, [query]);
- if (typeof calculateScore !== 'function') {
- throw new Error('Selectize "score" setting must be a function that returns a function');
- }
- }
- // perform search
- if (query !== self.lastQuery) {
- self.lastQuery = query;
- result = self.sifter.search(query, $.extend(options, { score: calculateScore }));
- self.currentResults = result;
- } else {
- result = $.extend(true, {}, self.currentResults);
- }
- // filter out selected items
- if (settings.hideSelected) {
- for (i = result.items.length - 1; i >= 0; i--) {
- if (self.items.indexOf(hash_key(result.items[i].id)) !== -1) {
- result.items.splice(i, 1);
- }
- }
- }
- return result;
- },
- /**
- * Refreshes the list of available options shown
- * in the autocomplete dropdown menu.
- *
- * @param {boolean} triggerDropdown
- */
- refreshOptions: function refreshOptions(triggerDropdown) {
- var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
- var $active, $active_before, $create;
- if (typeof triggerDropdown === 'undefined') {
- triggerDropdown = true;
- }
- var self = this;
- var query = $.trim(self.$control_input.val());
- var results = self.search(query);
- var $dropdown_content = self.$dropdown_content;
- var active_before = self.$activeOption && hash_key(self.$activeOption.attr('data-value'));
- // build markup
- n = results.items.length;
- if (typeof self.settings.maxOptions === 'number') {
- n = Math.min(n, self.settings.maxOptions);
- }
- // render and group available options individually
- groups = {};
- groups_order = [];
- for (i = 0; i < n; i++) {
- option = self.options[results.items[i].id];
- option_html = self.render('option', option);
- optgroup = option[self.settings.optgroupField] || '';
- optgroups = $.isArray(optgroup) ? optgroup : [optgroup];
- for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
- optgroup = optgroups[j];
- if (!self.optgroups.hasOwnProperty(optgroup)) {
- optgroup = '';
- }
- if (!groups.hasOwnProperty(optgroup)) {
- groups[optgroup] = document.createDocumentFragment();
- groups_order.push(optgroup);
- }
- groups[optgroup].appendChild(option_html);
- }
- }
- // sort optgroups
- if (this.settings.lockOptgroupOrder) {
- groups_order.sort(function (a, b) {
- var a_order = self.optgroups[a].$order || 0;
- var b_order = self.optgroups[b].$order || 0;
- return a_order - b_order;
- });
- }
- // render optgroup headers & join groups
- html = document.createDocumentFragment();
- for (i = 0, n = groups_order.length; i < n; i++) {
- optgroup = groups_order[i];
- if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].childNodes.length) {
- // render the optgroup header and options within it,
- // then pass it to the wrapper template
- html_children = document.createDocumentFragment();
- html_children.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
- html_children.appendChild(groups[optgroup]);
- html.appendChild(self.render('optgroup', $.extend({}, self.optgroups[optgroup], {
- html: domToString(html_children),
- dom: html_children
- })));
- } else {
- html.appendChild(groups[optgroup]);
- }
- }
- $dropdown_content.html(html);
- // highlight matching terms inline
- if (self.settings.highlight && results.query.length && results.tokens.length) {
- $dropdown_content.removeHighlight();
- for (i = 0, n = results.tokens.length; i < n; i++) {
- highlight($dropdown_content, results.tokens[i].regex);
- }
- }
- // add "selected" class to selected options
- if (!self.settings.hideSelected) {
- for (i = 0, n = self.items.length; i < n; i++) {
- self.getOption(self.items[i]).addClass('selected');
- }
- }
- // add create option
- has_create_option = self.canCreate(query);
- if (has_create_option) {
- $dropdown_content.prepend(self.render('option_create', { input: query }));
- $create = $($dropdown_content[0].childNodes[0]);
- }
- // activate
- self.hasOptions = results.items.length > 0 || has_create_option;
- if (self.hasOptions) {
- if (results.items.length > 0) {
- $active_before = active_before && self.getOption(active_before);
- if ($active_before && $active_before.length) {
- $active = $active_before;
- } else if (self.settings.mode === 'single' && self.items.length) {
- $active = self.getOption(self.items[0]);
- }
- if (!$active || !$active.length) {
- if ($create && !self.settings.addPrecedence) {
- $active = self.getAdjacentOption($create, 1);
- } else {
- $active = $dropdown_content.find('[data-selectable]:first');
- }
- }
- } else {
- $active = $create;
- }
- self.setActiveOption($active);
- if (triggerDropdown && !self.isOpen) {
- self.open();
- }
- } else {
- self.setActiveOption(null);
- if (triggerDropdown && self.isOpen) {
- self.close();
- }
- }
- },
- /**
- * Adds an available option. If it already exists,
- * nothing will happen. Note: this does not refresh
- * the options list dropdown (use `refreshOptions`
- * for that).
- *
- * Usage:
- *
- * this.addOption(data)
- *
- * @param {object|array} data
- */
- addOption: function addOption(data) {
- var i,
- n,
- value,
- self = this;
- if ($.isArray(data)) {
- for (i = 0, n = data.length; i < n; i++) {
- self.addOption(data[i]);
- }
- return;
- }
- if (value = self.registerOption(data)) {
- self.userOptions[value] = true;
- self.lastQuery = null;
- self.trigger('option_add', value, data);
- }
- },
- /**
- * Registers an option to the pool of options.
- *
- * @param {object} data
- * @return {boolean|string}
- */
- registerOption: function registerOption(data) {
- var key = hash_key(data[this.settings.valueField]);
- if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) return false;
- data.$order = data.$order || ++this.order;
- this.options[key] = data;
- return key;
- },
- /**
- * Registers an option group to the pool of option groups.
- *
- * @param {object} data
- * @return {boolean|string}
- */
- registerOptionGroup: function registerOptionGroup(data) {
- var key = hash_key(data[this.settings.optgroupValueField]);
- if (!key) return false;
- data.$order = data.$order || ++this.order;
- this.optgroups[key] = data;
- return key;
- },
- /**
- * Registers a new optgroup for options
- * to be bucketed into.
- *
- * @param {string} id
- * @param {object} data
- */
- addOptionGroup: function addOptionGroup(id, data) {
- data[this.settings.optgroupValueField] = id;
- if (id = this.registerOptionGroup(data)) {
- this.trigger('optgroup_add', id, data);
- }
- },
- /**
- * Removes an existing option group.
- *
- * @param {string} id
- */
- removeOptionGroup: function removeOptionGroup(id) {
- if (this.optgroups.hasOwnProperty(id)) {
- delete this.optgroups[id];
- this.renderCache = {};
- this.trigger('optgroup_remove', id);
- }
- },
- /**
- * Clears all existing option groups.
- */
- clearOptionGroups: function clearOptionGroups() {
- this.optgroups = {};
- this.renderCache = {};
- this.trigger('optgroup_clear');
- },
- /**
- * Updates an option available for selection. If
- * it is visible in the selected items or options
- * dropdown, it will be re-rendered automatically.
- *
- * @param {string} value
- * @param {object} data
- */
- updateOption: function updateOption(value, data) {
- var self = this;
- var $item, $item_new;
- var value_new, index_item, cache_items, cache_options, order_old;
- value = hash_key(value);
- value_new = hash_key(data[self.settings.valueField]);
- // sanity checks
- if (value === null) return;
- if (!self.options.hasOwnProperty(value)) return;
- if (typeof value_new !== 'string') throw new Error('Value must be set in option data');
- order_old = self.options[value].$order;
- // update references
- if (value_new !== value) {
- delete self.options[value];
- index_item = self.items.indexOf(value);
- if (index_item !== -1) {
- self.items.splice(index_item, 1, value_new);
- }
- }
- data.$order = data.$order || order_old;
- self.options[value_new] = data;
- // invalidate render cache
- cache_items = self.renderCache['item'];
- cache_options = self.renderCache['option'];
- if (cache_items) {
- delete cache_items[value];
- delete cache_items[value_new];
- }
- if (cache_options) {
- delete cache_options[value];
- delete cache_options[value_new];
- }
- // update the item if it's selected
- if (self.items.indexOf(value_new) !== -1) {
- $item = self.getItem(value);
- $item_new = $(self.render('item', data));
- if ($item.hasClass('active')) $item_new.addClass('active');
- $item.replaceWith($item_new);
- }
- // invalidate last query because we might have updated the sortField
- self.lastQuery = null;
- // update dropdown contents
- if (self.isOpen) {
- self.refreshOptions(false);
- }
- },
- /**
- * Removes a single option.
- *
- * @param {string} value
- * @param {boolean} silent
- */
- removeOption: function removeOption(value, silent) {
- var self = this;
- value = hash_key(value);
- var cache_items = self.renderCache['item'];
- var cache_options = self.renderCache['option'];
- if (cache_items) delete cache_items[value];
- if (cache_options) delete cache_options[value];
- delete self.userOptions[value];
- delete self.options[value];
- self.lastQuery = null;
- self.trigger('option_remove', value);
- self.removeItem(value, silent);
- },
- /**
- * Clears all options.
- */
- clearOptions: function clearOptions() {
- var self = this;
- self.loadedSearches = {};
- self.userOptions = {};
- self.renderCache = {};
- self.options = self.sifter.items = {};
- self.lastQuery = null;
- self.trigger('option_clear');
- self.clear();
- },
- /**
- * Returns the jQuery element of the option
- * matching the given value.
- *
- * @param {string} value
- * @returns {object}
- */
- getOption: function getOption(value) {
- return this.getElementWithValue(value, this.$dropdown_content.find('[data-selectable]'));
- },
- /**
- * Returns the jQuery element of the next or
- * previous selectable option.
- *
- * @param {object} $option
- * @param {int} direction can be 1 for next or -1 for previous
- * @return {object}
- */
- getAdjacentOption: function getAdjacentOption($option, direction) {
- var $options = this.$dropdown.find('[data-selectable]');
- var index = $options.index($option) + direction;
- return index >= 0 && index < $options.length ? $options.eq(index) : $();
- },
- /**
- * Finds the first element with a "data-value" attribute
- * that matches the given value.
- *
- * @param {mixed} value
- * @param {object} $els
- * @return {object}
- */
- getElementWithValue: function getElementWithValue(value, $els) {
- value = hash_key(value);
- if (typeof value !== 'undefined' && value !== null) {
- for (var i = 0, n = $els.length; i < n; i++) {
- if ($els[i].getAttribute('data-value') === value) {
- return $($els[i]);
- }
- }
- }
- return $();
- },
- /**
- * Returns the jQuery element of the item
- * matching the given value.
- *
- * @param {string} value
- * @returns {object}
- */
- getItem: function getItem(value) {
- return this.getElementWithValue(value, this.$control.children());
- },
- /**
- * "Selects" multiple items at once. Adds them to the list
- * at the current caret position.
- *
- * @param {string} value
- * @param {boolean} silent
- */
- addItems: function addItems(values, silent) {
- var items = $.isArray(values) ? values : [values];
- for (var i = 0, n = items.length; i < n; i++) {
- this.isPending = i < n - 1;
- this.addItem(items[i], silent);
- }
- },
- /**
- * "Selects" an item. Adds it to the list
- * at the current caret position.
- *
- * @param {string} value
- * @param {boolean} silent
- */
- addItem: function addItem(value, silent) {
- var events = silent ? [] : ['change'];
- debounce_events(this, events, function () {
- var $item, $option, $options;
- var self = this;
- var inputMode = self.settings.mode;
- var i, active, value_next, wasFull;
- value = hash_key(value);
- if (self.items.indexOf(value) !== -1) {
- if (inputMode === 'single') self.close();
- return;
- }
- if (!self.options.hasOwnProperty(value)) return;
- if (inputMode === 'single') self.clear(silent);
- if (inputMode === 'multi' && self.isFull()) return;
- $item = $(self.render('item', self.options[value]));
- wasFull = self.isFull();
- self.items.splice(self.caretPos, 0, value);
- self.insertAtCaret($item);
- if (!self.isPending || !wasFull && self.isFull()) {
- self.refreshState();
- }
- if (self.isSetup) {
- $options = self.$dropdown_content.find('[data-selectable]');
- // update menu / remove the option (if this is not one item being added as part of series)
- if (!self.isPending) {
- $option = self.getOption(value);
- value_next = self.getAdjacentOption($option, 1).attr('data-value');
- self.refreshOptions(self.isFocused && inputMode !== 'single');
- if (value_next) {
- self.setActiveOption(self.getOption(value_next));
- }
- }
- // hide the menu if the maximum number of items have been selected or no options are left
- if (!$options.length || self.isFull()) {
- self.close();
- } else {
- self.positionDropdown();
- }
- self.updatePlaceholder();
- self.trigger('item_add', value, $item);
- self.updateOriginalInput({ silent: silent });
- }
- });
- },
- /**
- * Removes the selected item matching
- * the provided value.
- *
- * @param {string} value
- */
- removeItem: function removeItem(value, silent) {
- var self = this;
- var $item, i, idx;
- $item = value instanceof $ ? value : self.getItem(value);
- value = hash_key($item.attr('data-value'));
- i = self.items.indexOf(value);
- if (i !== -1) {
- $item.remove();
- if ($item.hasClass('active')) {
- idx = self.$activeItems.indexOf($item[0]);
- self.$activeItems.splice(idx, 1);
- }
- self.items.splice(i, 1);
- self.lastQuery = null;
- if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
- self.removeOption(value, silent);
- }
- if (i < self.caretPos) {
- self.setCaret(self.caretPos - 1);
- }
- self.refreshState();
- self.updatePlaceholder();
- self.updateOriginalInput({ silent: silent });
- self.positionDropdown();
- self.trigger('item_remove', value, $item);
- }
- },
- /**
- * Invokes the `create` method provided in the
- * selectize options that should provide the data
- * for the new item, given the user input.
- *
- * Once this completes, it will be added
- * to the item list.
- *
- * @param {string} value
- * @param {boolean} [triggerDropdown]
- * @param {function} [callback]
- * @return {boolean}
- */
- createItem: function createItem(input, triggerDropdown) {
- var self = this;
- var caret = self.caretPos;
- input = input || $.trim(self.$control_input.val() || '');
- var callback = arguments[arguments.length - 1];
- if (typeof callback !== 'function') callback = function callback() {};
- if (typeof triggerDropdown !== 'boolean') {
- triggerDropdown = true;
- }
- if (!self.canCreate(input)) {
- callback();
- return false;
- }
- self.lock();
- var setup = typeof self.settings.create === 'function' ? this.settings.create : function (input) {
- var data = {};
- data[self.settings.labelField] = input;
- data[self.settings.valueField] = input;
- return data;
- };
- var create = once(function (data) {
- self.unlock();
- if (!data || (typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') return callback();
- var value = hash_key(data[self.settings.valueField]);
- if (typeof value !== 'string') return callback();
- self.setTextboxValue('');
- self.addOption(data);
- self.setCaret(caret);
- self.addItem(value);
- self.refreshOptions(triggerDropdown && self.settings.mode !== 'single');
- callback(data);
- });
- var output = setup.apply(this, [input, create]);
- if (typeof output !== 'undefined') {
- create(output);
- }
- return true;
- },
- /**
- * Re-renders the selected item lists.
- */
- refreshItems: function refreshItems() {
- this.lastQuery = null;
- if (this.isSetup) {
- this.addItem(this.items);
- }
- this.refreshState();
- this.updateOriginalInput();
- },
- /**
- * Updates all state-dependent attributes
- * and CSS classes.
- */
- refreshState: function refreshState() {
- this.refreshValidityState();
- this.refreshClasses();
- },
- /**
- * Update the `required` attribute of both input and control input.
- *
- * The `required` property needs to be activated on the control input
- * for the error to be displayed at the right place. `required` also
- * needs to be temporarily deactivated on the input since the input is
- * hidden and can't show errors.
- */
- refreshValidityState: function refreshValidityState() {
- if (!this.isRequired) return false;
- var invalid = !this.items.length;
- this.isInvalid = invalid;
- this.$control_input.prop('required', invalid);
- this.$input.prop('required', !invalid);
- },
- /**
- * Updates all state-dependent CSS classes.
- */
- refreshClasses: function refreshClasses() {
- var self = this;
- var isFull = self.isFull();
- var isLocked = self.isLocked;
- self.$wrapper.toggleClass('rtl', self.rtl);
- self.$control.toggleClass('focus', self.isFocused).toggleClass('disabled', self.isDisabled).toggleClass('required', self.isRequired).toggleClass('invalid', self.isInvalid).toggleClass('locked', isLocked).toggleClass('full', isFull).toggleClass('not-full', !isFull).toggleClass('input-active', self.isFocused && !self.isInputHidden).toggleClass('dropdown-active', self.isOpen).toggleClass('has-options', !$.isEmptyObject(self.options)).toggleClass('has-items', self.items.length > 0);
- self.$control_input.data('grow', !isFull && !isLocked);
- },
- /**
- * Determines whether or not more items can be added
- * to the control without exceeding the user-defined maximum.
- *
- * @returns {boolean}
- */
- isFull: function isFull() {
- return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
- },
- /**
- * Refreshes the original <select> or <input>
- * element to reflect the current state.
- */
- updateOriginalInput: function updateOriginalInput(opts) {
- var i,
- n,
- options,
- label,
- self = this;
- opts = opts || {};
- if (self.tagType === TAG_SELECT) {
- options = [];
- for (i = 0, n = self.items.length; i < n; i++) {
- label = self.options[self.items[i]][self.settings.labelField] || '';
- options.push('<option value="' + escape_html(self.items[i]) + '" selected="selected">' + escape_html(label) + '</option>');
- }
- if (!options.length && !this.$input.attr('multiple')) {
- options.push('<option value="" selected="selected"></option>');
- }
- self.$input.html(options.join(''));
- } else {
- self.$input.val(self.getValue());
- self.$input.attr('value', self.$input.val());
- }
- if (self.isSetup) {
- if (!opts.silent) {
- self.trigger('change', self.$input.val());
- }
- }
- },
- /**
- * Shows/hide the input placeholder depending
- * on if there items in the list already.
- */
- updatePlaceholder: function updatePlaceholder() {
- if (!this.settings.placeholder) return;
- var $input = this.$control_input;
- if (this.items.length) {
- $input.removeAttr('placeholder');
- } else {
- $input.attr('placeholder', this.settings.placeholder);
- }
- $input.triggerHandler('update', { force: true });
- },
- /**
- * Shows the autocomplete dropdown containing
- * the available options.
- */
- open: function open() {
- var self = this;
- if (self.isLocked || self.isOpen || self.settings.mode === 'multi' && self.isFull()) return;
- self.focus();
- self.isOpen = true;
- self.refreshState();
- self.$dropdown.css({ visibility: 'hidden', display: 'block' });
- self.positionDropdown();
- self.$dropdown.css({ visibility: 'visible' });
- self.trigger('dropdown_open', self.$dropdown);
- },
- /**
- * Closes the autocomplete dropdown menu.
- */
- close: function close() {
- var self = this;
- var trigger = self.isOpen;
- if (self.settings.mode === 'single' && self.items.length) {
- self.hideInput();
- self.$control_input.blur(); // close keyboard on iOS
- }
- self.isOpen = false;
- self.$dropdown.hide();
- self.setActiveOption(null);
- self.refreshState();
- if (trigger) self.trigger('dropdown_close', self.$dropdown);
- },
- /**
- * Calculates and applies the appropriate
- * position of the dropdown.
- */
- positionDropdown: function positionDropdown() {
- var $control = this.$control;
- var offset = this.settings.dropdownParent === 'body' ? $control.offset() : $control.position();
- offset.top += $control.outerHeight(true);
- this.$dropdown.css({
- width: $control.outerWidth(),
- top: offset.top,
- left: offset.left
- });
- },
- /**
- * Resets / clears all selected items
- * from the control.
- *
- * @param {boolean} silent
- */
- clear: function clear(silent) {
- var self = this;
- if (!self.items.length) return;
- self.$control.children(':not(input)').remove();
- self.items = [];
- self.lastQuery = null;
- self.setCaret(0);
- self.setActiveItem(null);
- self.updatePlaceholder();
- self.updateOriginalInput({ silent: silent });
- self.refreshState();
- self.showInput();
- self.trigger('clear');
- },
- /**
- * A helper method for inserting an element
- * at the current caret position.
- *
- * @param {object} $el
- */
- insertAtCaret: function insertAtCaret($el) {
- var caret = Math.min(this.caretPos, this.items.length);
- if (caret === 0) {
- this.$control.prepend($el);
- } else {
- $(this.$control[0].childNodes[caret]).before($el);
- }
- this.setCaret(caret + 1);
- },
- /**
- * Removes the current selected item(s).
- *
- * @param {object} e (optional)
- * @returns {boolean}
- */
- deleteSelection: function deleteSelection(e) {
- var i, n, direction, selection, values, caret, option_select, $option_select, $tail;
- var self = this;
- direction = e && e.keyCode === KEY_BACKSPACE ? -1 : 1;
- selection = getSelection(self.$control_input[0]);
- if (self.$activeOption && !self.settings.hideSelected) {
- option_select = self.getAdjacentOption(self.$activeOption, -1).attr('data-value');
- }
- // determine items that will be removed
- values = [];
- if (self.$activeItems.length) {
- $tail = self.$control.children('.active:' + (direction > 0 ? 'last' : 'first'));
- caret = self.$control.children(':not(input)').index($tail);
- if (direction > 0) {
- caret++;
- }
- for (i = 0, n = self.$activeItems.length; i < n; i++) {
- values.push($(self.$activeItems[i]).attr('data-value'));
- }
- if (e) {
- e.preventDefault();
- e.stopPropagation();
- }
- } else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
- if (direction < 0 && selection.start === 0 && selection.length === 0) {
- values.push(self.items[self.caretPos - 1]);
- } else if (direction > 0 && selection.start === self.$control_input.val().length) {
- values.push(self.items[self.caretPos]);
- }
- }
- // allow the callback to abort
- if (!values.length || typeof self.settings.onDelete === 'function' && self.settings.onDelete.apply(self, [values]) === false) {
- return false;
- }
- // perform removal
- if (typeof caret !== 'undefined') {
- self.setCaret(caret);
- }
- while (values.length) {
- self.removeItem(values.pop());
- }
- self.showInput();
- self.positionDropdown();
- self.refreshOptions(true);
- // select previous option
- if (option_select) {
- $option_select = self.getOption(option_select);
- if ($option_select.length) {
- self.setActiveOption($option_select);
- }
- }
- return true;
- },
- /**
- * Selects the previous / next item (depending
- * on the `direction` argument).
- *
- * > 0 - right
- * < 0 - left
- *
- * @param {int} direction
- * @param {object} e (optional)
- */
- advanceSelection: function advanceSelection(direction, e) {
- var tail, selection, idx, valueLength, cursorAtEdge, $tail;
- var self = this;
- if (direction === 0) return;
- if (self.rtl) direction *= -1;
- tail = direction > 0 ? 'last' : 'first';
- selection = getSelection(self.$control_input[0]);
- if (self.isFocused && !self.isInputHidden) {
- valueLength = self.$control_input.val().length;
- cursorAtEdge = direction < 0 ? selection.start === 0 && selection.length === 0 : selection.start === valueLength;
- if (cursorAtEdge && !valueLength) {
- self.advanceCaret(direction, e);
- }
- } else {
- $tail = self.$control.children('.active:' + tail);
- if ($tail.length) {
- idx = self.$control.children(':not(input)').index($tail);
- self.setActiveItem(null);
- self.setCaret(direction > 0 ? idx + 1 : idx);
- }
- }
- },
- /**
- * Moves the caret left / right.
- *
- * @param {int} direction
- * @param {object} e (optional)
- */
- advanceCaret: function advanceCaret(direction, e) {
- var self = this,
- fn,
- $adj;
- if (direction === 0) return;
- fn = direction > 0 ? 'next' : 'prev';
- if (self.isShiftDown) {
- $adj = self.$control_input[fn]();
- if ($adj.length) {
- self.hideInput();
- self.setActiveItem($adj);
- e && e.preventDefault();
- }
- } else {
- self.setCaret(self.caretPos + direction);
- }
- },
- /**
- * Moves the caret to the specified index.
- *
- * @param {int} i
- */
- setCaret: function setCaret(i) {
- var self = this;
- if (self.settings.mode === 'single') {
- i = self.items.length;
- } else {
- i = Math.max(0, Math.min(self.items.length, i));
- }
- if (!self.isPending) {
- // the input must be moved by leaving it in place and moving the
- // siblings, due to the fact that focus cannot be restored once lost
- // on mobile webkit devices
- var j, n, fn, $children, $child;
- $children = self.$control.children(':not(input)');
- for (j = 0, n = $children.length; j < n; j++) {
- $child = $($children[j]).detach();
- if (j < i) {
- self.$control_input.before($child);
- } else {
- self.$control.append($child);
- }
- }
- }
- self.caretPos = i;
- },
- /**
- * Disables user input on the control. Used while
- * items are being asynchronously created.
- */
- lock: function lock() {
- this.close();
- this.isLocked = true;
- this.refreshState();
- },
- /**
- * Re-enables user input on the control.
- */
- unlock: function unlock() {
- this.isLocked = false;
- this.refreshState();
- },
- /**
- * Disables user input on the control completely.
- * While disabled, it cannot receive focus.
- */
- disable: function disable() {
- var self = this;
- self.$input.prop('disabled', true);
- self.$control_input.prop('disabled', true).prop('tabindex', -1);
- self.isDisabled = true;
- self.lock();
- },
- /**
- * Enables the control so that it can respond
- * to focus and user input.
- */
- enable: function enable() {
- var self = this;
- self.$input.prop('disabled', false);
- self.$control_input.prop('disabled', false).prop('tabindex', self.tabIndex);
- self.isDisabled = false;
- self.unlock();
- },
- /**
- * Completely destroys the control and
- * unbinds all event listeners so that it can
- * be garbage collected.
- */
- destroy: function destroy() {
- var self = this;
- var eventNS = self.eventNS;
- var revertSettings = self.revertSettings;
- self.trigger('destroy');
- self.off();
- self.$wrapper.remove();
- self.$dropdown.remove();
- self.$input.html('').append(revertSettings.$children).removeAttr('tabindex').removeClass('selectized').attr({ tabindex: revertSettings.tabindex }).show();
- self.$control_input.removeData('grow');
- self.$input.removeData('selectize');
- $(window).off(eventNS);
- $(document).off(eventNS);
- $(document.body).off(eventNS);
- delete self.$input[0].selectize;
- },
- /**
- * A helper method for rendering "item" and
- * "option" templates, given the data.
- *
- * @param {string} templateName
- * @param {object} data
- * @returns {string}
- */
- render: function render(templateName, data) {
- var value, id, label;
- var html = '';
- var cache = false;
- var self = this;
- var regex_tag = /^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;
- if (templateName === 'option' || templateName === 'item') {
- value = hash_key(data[self.settings.valueField]);
- cache = !!value;
- }
- // pull markup from cache if it exists
- if (cache) {
- if (!isset(self.renderCache[templateName])) {
- self.renderCache[templateName] = {};
- }
- if (self.renderCache[templateName].hasOwnProperty(value)) {
- return self.renderCache[templateName][value];
- }
- }
- // render markup
- html = $(self.settings.render[templateName].apply(this, [data, escape_html]));
- // add mandatory attributes
- if (templateName === 'option' || templateName === 'option_create') {
- html.attr('data-selectable', '');
- } else if (templateName === 'optgroup') {
- id = data[self.settings.optgroupValueField] || '';
- html.attr('data-group', id);
- }
- if (templateName === 'option' || templateName === 'item') {
- html.attr('data-value', value || '');
- }
- // update cache
- if (cache) {
- self.renderCache[templateName][value] = html[0];
- }
- return html[0];
- },
- /**
- * Clears the render cache for a template. If
- * no template is given, clears all render
- * caches.
- *
- * @param {string} templateName
- */
- clearCache: function clearCache(templateName) {
- var self = this;
- if (typeof templateName === 'undefined') {
- self.renderCache = {};
- } else {
- delete self.renderCache[templateName];
- }
- },
- /**
- * Determines whether or not to display the
- * create item prompt, given a user input.
- *
- * @param {string} input
- * @return {boolean}
- */
- canCreate: function canCreate(input) {
- var self = this;
- if (!self.settings.create) return false;
- var filter = self.settings.createFilter;
- return input.length && (typeof filter !== 'function' || filter.apply(self, [input])) && (typeof filter !== 'string' || new RegExp(filter).test(input)) && (!(filter instanceof RegExp) || filter.test(input));
- }
- });
- Selectize.count = 0;
- Selectize.defaults = {
- options: [],
- optgroups: [],
- plugins: [],
- delimiter: ',',
- splitOn: null, // regexp or string for splitting up values from a paste command
- persist: true,
- diacritics: true,
- create: false,
- createOnBlur: false,
- createFilter: null,
- highlight: true,
- openOnFocus: true,
- maxOptions: 1000,
- maxItems: null,
- hideSelected: null,
- addPrecedence: false,
- selectOnTab: false,
- preload: false,
- allowEmptyOption: false,
- closeAfterSelect: false,
- scrollDuration: 60,
- loadThrottle: 300,
- loadingClass: 'loading',
- dataAttr: 'data-data',
- optgroupField: 'optgroup',
- valueField: 'value',
- labelField: 'text',
- optgroupLabelField: 'label',
- optgroupValueField: 'value',
- lockOptgroupOrder: false,
- sortField: '$order',
- searchField: ['text'],
- searchConjunction: 'and',
- mode: null,
- wrapperClass: 'selectize-control',
- inputClass: 'selectize-input',
- dropdownClass: 'selectize-dropdown',
- dropdownContentClass: 'selectize-dropdown-content',
- dropdownParent: null,
- copyClassesToDropdown: true,
- /*
- load : null, // function(query, callback) { ... }
- score : null, // function(search) { ... }
- onInitialize : null, // function() { ... }
- onChange : null, // function(value) { ... }
- onItemAdd : null, // function(value, $item) { ... }
- onItemRemove : null, // function(value) { ... }
- onClear : null, // function() { ... }
- onOptionAdd : null, // function(value, data) { ... }
- onOptionRemove : null, // function(value) { ... }
- onOptionClear : null, // function() { ... }
- onOptionGroupAdd : null, // function(id, data) { ... }
- onOptionGroupRemove : null, // function(id) { ... }
- onOptionGroupClear : null, // function() { ... }
- onDropdownOpen : null, // function($dropdown) { ... }
- onDropdownClose : null, // function($dropdown) { ... }
- onType : null, // function(str) { ... }
- onDelete : null, // function(values) { ... }
- */
- render: {
- /*
- item: null,
- optgroup: null,
- optgroup_header: null,
- option: null,
- option_create: null
- */
- }
- };
- $.fn.selectize = function (settings_user) {
- var defaults = $.fn.selectize.defaults;
- var settings = $.extend({}, defaults, settings_user);
- var attr_data = settings.dataAttr;
- var field_label = settings.labelField;
- var field_value = settings.valueField;
- var field_optgroup = settings.optgroupField;
- var field_optgroup_label = settings.optgroupLabelField;
- var field_optgroup_value = settings.optgroupValueField;
- /**
- * Initializes selectize from a <input type="text"> element.
- *
- * @param {object} $input
- * @param {object} settings_element
- */
- var init_textbox = function init_textbox($input, settings_element) {
- var i, n, values, option;
- var data_raw = $input.attr(attr_data);
- if (!data_raw) {
- var value = $.trim($input.val() || '');
- if (!settings.allowEmptyOption && !value.length) return;
- values = value.split(settings.delimiter);
- for (i = 0, n = values.length; i < n; i++) {
- option = {};
- option[field_label] = values[i];
- option[field_value] = values[i];
- settings_element.options.push(option);
- }
- settings_element.items = values;
- } else {
- settings_element.options = JSON.parse(data_raw);
- for (i = 0, n = settings_element.options.length; i < n; i++) {
- settings_element.items.push(settings_element.options[i][field_value]);
- }
- }
- };
- /**
- * Initializes selectize from a <select> element.
- *
- * @param {object} $input
- * @param {object} settings_element
- */
- var init_select = function init_select($input, settings_element) {
- var i,
- n,
- tagName,
- $children,
- order = 0;
- var options = settings_element.options;
- var optionsMap = {};
- var readData = function readData($el) {
- var data = attr_data && $el.attr(attr_data);
- if (typeof data === 'string' && data.length) {
- return JSON.parse(data);
- }
- return null;
- };
- var addOption = function addOption($option, group) {
- $option = $($option);
- var value = hash_key($option.val());
- if (!value && !settings.allowEmptyOption) return;
- // if the option already exists, it's probably been
- // duplicated in another optgroup. in this case, push
- // the current group to the "optgroup" property on the
- // existing option so that it's rendered in both places.
- if (optionsMap.hasOwnProperty(value)) {
- if (group) {
- var arr = optionsMap[value][field_optgroup];
- if (!arr) {
- optionsMap[value][field_optgroup] = group;
- } else if (!$.isArray(arr)) {
- optionsMap[value][field_optgroup] = [arr, group];
- } else {
- arr.push(group);
- }
- }
- return;
- }
- var option = readData($option) || {};
- option[field_label] = option[field_label] || $option.text();
- option[field_value] = option[field_value] || value;
- option[field_optgroup] = option[field_optgroup] || group;
- optionsMap[value] = option;
- options.push(option);
- if ($option.is(':selected')) {
- settings_element.items.push(value);
- }
- };
- var addGroup = function addGroup($optgroup) {
- var i, n, id, optgroup, $options;
- $optgroup = $($optgroup);
- id = $optgroup.attr('label');
- if (id) {
- optgroup = readData($optgroup) || {};
- optgroup[field_optgroup_label] = id;
- optgroup[field_optgroup_value] = id;
- settings_element.optgroups.push(optgroup);
- }
- $options = $('option', $optgroup);
- for (i = 0, n = $options.length; i < n; i++) {
- addOption($options[i], id);
- }
- };
- settings_element.maxItems = $input.attr('multiple') ? null : 1;
- $children = $input.children();
- for (i = 0, n = $children.length; i < n; i++) {
- tagName = $children[i].tagName.toLowerCase();
- if (tagName === 'optgroup') {
- addGroup($children[i]);
- } else if (tagName === 'option') {
- addOption($children[i]);
- }
- }
- };
- return this.each(function () {
- if (this.selectize) return;
- var instance;
- var $input = $(this);
- var tag_name = this.tagName.toLowerCase();
- var placeholder = $input.attr('placeholder') || $input.attr('data-placeholder');
- if (!placeholder && !settings.allowEmptyOption) {
- placeholder = $input.children('option[value=""]').text();
- }
- var settings_element = {
- 'placeholder': placeholder,
- 'options': [],
- 'optgroups': [],
- 'items': []
- };
- if (tag_name === 'select') {
- init_select($input, settings_element);
- } else {
- init_textbox($input, settings_element);
- }
- instance = new Selectize($input, $.extend(true, {}, defaults, settings_element, settings_user));
- });
- };
- $.fn.selectize.defaults = Selectize.defaults;
- $.fn.selectize.support = {
- validity: SUPPORTS_VALIDITY_API
- };
- Selectize.define('drag_drop', function (options) {
- if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
- if (this.settings.mode !== 'multi') return;
- var self = this;
- self.lock = function () {
- var original = self.lock;
- return function () {
- var sortable = self.$control.data('sortable');
- if (sortable) sortable.disable();
- return original.apply(self, arguments);
- };
- }();
- self.unlock = function () {
- var original = self.unlock;
- return function () {
- var sortable = self.$control.data('sortable');
- if (sortable) sortable.enable();
- return original.apply(self, arguments);
- };
- }();
- self.setup = function () {
- var original = self.setup;
- return function () {
- original.apply(this, arguments);
- var $control = self.$control.sortable({
- items: '[data-value]',
- forcePlaceholderSize: true,
- disabled: self.isLocked,
- start: function start(e, ui) {
- ui.placeholder.css('width', ui.helper.css('width'));
- $control.css({ overflow: 'visible' });
- },
- stop: function stop() {
- $control.css({ overflow: 'hidden' });
- var active = self.$activeItems ? self.$activeItems.slice() : null;
- var values = [];
- $control.children('[data-value]').each(function () {
- values.push($(this).attr('data-value'));
- });
- self.setValue(values);
- self.setActiveItem(active);
- }
- });
- };
- }();
- });
- Selectize.define('dropdown_header', function (options) {
- var self = this;
- options = $.extend({
- title: 'Untitled',
- headerClass: 'selectize-dropdown-header',
- titleRowClass: 'selectize-dropdown-header-title',
- labelClass: 'selectize-dropdown-header-label',
- closeClass: 'selectize-dropdown-header-close',
- html: function html(data) {
- return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a href="javascript:void(0)" class="' + data.closeClass + '">×</a>' + '</div>' + '</div>';
- }
- }, options);
- self.setup = function () {
- var original = self.setup;
- return function () {
- original.apply(self, arguments);
- self.$dropdown_header = $(options.html(options));
- self.$dropdown.prepend(self.$dropdown_header);
- };
- }();
- });
- Selectize.define('optgroup_columns', function (options) {
- var self = this;
- options = $.extend({
- equalizeWidth: true,
- equalizeHeight: true
- }, options);
- this.getAdjacentOption = function ($option, direction) {
- var $options = $option.closest('[data-group]').find('[data-selectable]');
- var index = $options.index($option) + direction;
- return index >= 0 && index < $options.length ? $options.eq(index) : $();
- };
- this.onKeyDown = function () {
- var original = self.onKeyDown;
- return function (e) {
- var index, $option, $options, $optgroup;
- if (this.isOpen && (e.keyCode === KEY_LEFT || e.keyCode === KEY_RIGHT)) {
- self.ignoreHover = true;
- $optgroup = this.$activeOption.closest('[data-group]');
- index = $optgroup.find('[data-selectable]').index(this.$activeOption);
- if (e.keyCode === KEY_LEFT) {
- $optgroup = $optgroup.prev('[data-group]');
- } else {
- $optgroup = $optgroup.next('[data-group]');
- }
- $options = $optgroup.find('[data-selectable]');
- $option = $options.eq(Math.min($options.length - 1, index));
- if ($option.length) {
- this.setActiveOption($option);
- }
- return;
- }
- return original.apply(this, arguments);
- };
- }();
- var getScrollbarWidth = function getScrollbarWidth() {
- var div;
- var width = getScrollbarWidth.width;
- var doc = document;
- if (typeof width === 'undefined') {
- div = doc.createElement('div');
- div.innerHTML = '<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>';
- div = div.firstChild;
- doc.body.appendChild(div);
- width = getScrollbarWidth.width = div.offsetWidth - div.clientWidth;
- doc.body.removeChild(div);
- }
- return width;
- };
- var equalizeSizes = function equalizeSizes() {
- var i, n, height_max, width, width_last, width_parent, $optgroups;
- $optgroups = $('[data-group]', self.$dropdown_content);
- n = $optgroups.length;
- if (!n || !self.$dropdown_content.width()) return;
- if (options.equalizeHeight) {
- height_max = 0;
- for (i = 0; i < n; i++) {
- height_max = Math.max(height_max, $optgroups.eq(i).height());
- }
- $optgroups.css({ height: height_max });
- }
- if (options.equalizeWidth) {
- width_parent = self.$dropdown_content.innerWidth() - getScrollbarWidth();
- width = Math.round(width_parent / n);
- $optgroups.css({ width: width });
- if (n > 1) {
- width_last = width_parent - width * (n - 1);
- $optgroups.eq(n - 1).css({ width: width_last });
- }
- }
- };
- if (options.equalizeHeight || options.equalizeWidth) {
- hook.after(this, 'positionDropdown', equalizeSizes);
- hook.after(this, 'refreshOptions', equalizeSizes);
- }
- });
- Selectize.define('remove_button', function (options) {
- options = $.extend({
- label: '×',
- title: 'Remove',
- className: 'remove',
- append: true
- }, options);
- var singleClose = function singleClose(thisRef, options) {
- options.className = 'remove-single';
- var self = thisRef;
- var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
- /**
- * Appends an element as a child (with raw HTML).
- *
- * @param {string} html_container
- * @param {string} html_element
- * @return {string}
- */
- var append = function append(html_container, html_element) {
- return html_container + html_element;
- };
- thisRef.setup = function () {
- var original = self.setup;
- return function () {
- // override the item rendering method to add the button to each
- if (options.append) {
- var id = $(self.$input.context).attr('id');
- var selectizer = $('#' + id);
- var render_item = self.settings.render.item;
- self.settings.render.item = function (data) {
- return append(render_item.apply(thisRef, arguments), html);
- };
- }
- original.apply(thisRef, arguments);
- // add event listener
- thisRef.$control.on('click', '.' + options.className, function (e) {
- e.preventDefault();
- if (self.isLocked) return;
- self.clear();
- });
- };
- }();
- };
- var multiClose = function multiClose(thisRef, options) {
- var self = thisRef;
- var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
- /**
- * Appends an element as a child (with raw HTML).
- *
- * @param {string} html_container
- * @param {string} html_element
- * @return {string}
- */
- var append = function append(html_container, html_element) {
- var pos = html_container.search(/(<\/[^>]+>\s*)$/);
- return html_container.substring(0, pos) + html_element + html_container.substring(pos);
- };
- thisRef.setup = function () {
- var original = self.setup;
- return function () {
- // override the item rendering method to add the button to each
- if (options.append) {
- var render_item = self.settings.render.item;
- self.settings.render.item = function (data) {
- return append(render_item.apply(thisRef, arguments), html);
- };
- }
- original.apply(thisRef, arguments);
- // add event listener
- thisRef.$control.on('click', '.' + options.className, function (e) {
- e.preventDefault();
- if (self.isLocked) return;
- var $item = $(e.currentTarget).parent();
- self.setActiveItem($item);
- if (self.deleteSelection()) {
- self.setCaret(self.items.length);
- }
- });
- };
- }();
- };
- if (this.settings.mode === 'single') {
- singleClose(this, options);
- return;
- } else {
- multiClose(this, options);
- }
- });
- Selectize.define('restore_on_backspace', function (options) {
- var self = this;
- options.text = options.text || function (option) {
- return option[this.settings.labelField];
- };
- this.onKeyDown = function () {
- var original = self.onKeyDown;
- return function (e) {
- var index, option;
- if (e.keyCode === KEY_BACKSPACE && this.$control_input.val() === '' && !this.$activeItems.length) {
- index = this.caretPos - 1;
- if (index >= 0 && index < this.items.length) {
- option = this.options[this.items[index]];
- if (this.deleteSelection(e)) {
- this.setTextboxValue(options.text.apply(this, [option]));
- this.refreshOptions(true);
- }
- e.preventDefault();
- return;
- }
- }
- return original.apply(this, arguments);
- };
- }();
- });
- return Selectize;
- });
- /***/ }),
- /* 30 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
- /*!
- Autosize 4.0.0
- license: MIT
- http://www.jacklmoore.com/autosize
- */
- (function (global, factory) {
- if (true) {
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, module], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
- factory(exports, module);
- } else {
- var mod = {
- exports: {}
- };
- factory(mod.exports, mod);
- global.autosize = mod.exports;
- }
- })(undefined, function (exports, module) {
- 'use strict';
- var map = typeof Map === "function" ? new Map() : function () {
- var keys = [];
- var values = [];
- return {
- has: function has(key) {
- return keys.indexOf(key) > -1;
- },
- get: function get(key) {
- return values[keys.indexOf(key)];
- },
- set: function set(key, value) {
- if (keys.indexOf(key) === -1) {
- keys.push(key);
- values.push(value);
- }
- },
- 'delete': function _delete(key) {
- var index = keys.indexOf(key);
- if (index > -1) {
- keys.splice(index, 1);
- values.splice(index, 1);
- }
- }
- };
- }();
- var createEvent = function createEvent(name) {
- return new Event(name, { bubbles: true });
- };
- try {
- new Event('test');
- } catch (e) {
- // IE does not support `new Event()`
- createEvent = function createEvent(name) {
- var evt = document.createEvent('Event');
- evt.initEvent(name, true, false);
- return evt;
- };
- }
- function assign(ta) {
- if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
- var heightOffset = null;
- var clientWidth = ta.clientWidth;
- var cachedHeight = null;
- function init() {
- var style = window.getComputedStyle(ta, null);
- if (style.resize === 'vertical') {
- ta.style.resize = 'none';
- } else if (style.resize === 'both') {
- ta.style.resize = 'horizontal';
- }
- if (style.boxSizing === 'content-box') {
- heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
- } else {
- heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
- }
- // Fix when a textarea is not on document body and heightOffset is Not a Number
- if (isNaN(heightOffset)) {
- heightOffset = 0;
- }
- update();
- }
- function changeOverflow(value) {
- {
- // Chrome/Safari-specific fix:
- // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
- // made available by removing the scrollbar. The following forces the necessary text reflow.
- var width = ta.style.width;
- ta.style.width = '0px';
- // Force reflow:
- /* jshint ignore:start */
- ta.offsetWidth;
- /* jshint ignore:end */
- ta.style.width = width;
- }
- ta.style.overflowY = value;
- }
- function getParentOverflows(el) {
- var arr = [];
- while (el && el.parentNode && el.parentNode instanceof Element) {
- if (el.parentNode.scrollTop) {
- arr.push({
- node: el.parentNode,
- scrollTop: el.parentNode.scrollTop
- });
- }
- el = el.parentNode;
- }
- return arr;
- }
- function resize() {
- var originalHeight = ta.style.height;
- var overflows = getParentOverflows(ta);
- var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
- ta.style.height = '';
- var endHeight = ta.scrollHeight + heightOffset;
- if (ta.scrollHeight === 0) {
- // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
- ta.style.height = originalHeight;
- return;
- }
- ta.style.height = endHeight + 'px';
- // used to check if an update is actually necessary on window.resize
- clientWidth = ta.clientWidth;
- // prevents scroll-position jumping
- overflows.forEach(function (el) {
- el.node.scrollTop = el.scrollTop;
- });
- if (docTop) {
- document.documentElement.scrollTop = docTop;
- }
- }
- function update() {
- resize();
- var styleHeight = Math.round(parseFloat(ta.style.height));
- var computed = window.getComputedStyle(ta, null);
- // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
- var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
- // The actual height not matching the style height (set via the resize method) indicates that
- // the max-height has been exceeded, in which case the overflow should be allowed.
- if (actualHeight !== styleHeight) {
- if (computed.overflowY === 'hidden') {
- changeOverflow('scroll');
- resize();
- actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
- }
- } else {
- // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
- if (computed.overflowY !== 'hidden') {
- changeOverflow('hidden');
- resize();
- actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
- }
- }
- if (cachedHeight !== actualHeight) {
- cachedHeight = actualHeight;
- var evt = createEvent('autosize:resized');
- try {
- ta.dispatchEvent(evt);
- } catch (err) {
- // Firefox will throw an error on dispatchEvent for a detached element
- // https://bugzilla.mozilla.org/show_bug.cgi?id=889376
- }
- }
- }
- var pageResize = function pageResize() {
- if (ta.clientWidth !== clientWidth) {
- update();
- }
- };
- var destroy = function (style) {
- window.removeEventListener('resize', pageResize, false);
- ta.removeEventListener('input', update, false);
- ta.removeEventListener('keyup', update, false);
- ta.removeEventListener('autosize:destroy', destroy, false);
- ta.removeEventListener('autosize:update', update, false);
- Object.keys(style).forEach(function (key) {
- ta.style[key] = style[key];
- });
- map['delete'](ta);
- }.bind(ta, {
- height: ta.style.height,
- resize: ta.style.resize,
- overflowY: ta.style.overflowY,
- overflowX: ta.style.overflowX,
- wordWrap: ta.style.wordWrap
- });
- ta.addEventListener('autosize:destroy', destroy, false);
- // IE9 does not fire onpropertychange or oninput for deletions,
- // so binding to onkeyup to catch most of those events.
- // There is no way that I know of to detect something like 'cut' in IE9.
- if ('onpropertychange' in ta && 'oninput' in ta) {
- ta.addEventListener('keyup', update, false);
- }
- window.addEventListener('resize', pageResize, false);
- ta.addEventListener('input', update, false);
- ta.addEventListener('autosize:update', update, false);
- ta.style.overflowX = 'hidden';
- ta.style.wordWrap = 'break-word';
- map.set(ta, {
- destroy: destroy,
- update: update
- });
- init();
- }
- function destroy(ta) {
- var methods = map.get(ta);
- if (methods) {
- methods.destroy();
- }
- }
- function update(ta) {
- var methods = map.get(ta);
- if (methods) {
- methods.update();
- }
- }
- var autosize = null;
- // Do nothing in Node.js environment and IE8 (or lower)
- if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
- autosize = function autosize(el) {
- return el;
- };
- autosize.destroy = function (el) {
- return el;
- };
- autosize.update = function (el) {
- return el;
- };
- } else {
- autosize = function autosize(el, options) {
- if (el) {
- Array.prototype.forEach.call(el.length ? el : [el], function (x) {
- return assign(x, options);
- });
- }
- return el;
- };
- autosize.destroy = function (el) {
- if (el) {
- Array.prototype.forEach.call(el.length ? el : [el], destroy);
- }
- return el;
- };
- autosize.update = function (el) {
- if (el) {
- Array.prototype.forEach.call(el.length ? el : [el], update);
- }
- return el;
- };
- }
- module.exports = autosize;
- });
- /***/ }),
- /* 31 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;var require;
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- /*!
- * enquire.js v2.1.6 - Awesome Media Queries in JavaScript
- * Copyright (c) 2017 Nick Williams - http://wicky.nillia.ms/enquire.js
- * License: MIT */
- (function (f) {
- if (( false ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
- module.exports = f();
- } else if (true) {
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (f),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else {
- var g;if (typeof window !== "undefined") {
- g = window;
- } else if (typeof global !== "undefined") {
- g = global;
- } else if (typeof self !== "undefined") {
- g = self;
- } else {
- g = this;
- }g.enquire = f();
- }
- })(function () {
- var define, module, exports;return function e(t, n, r) {
- function s(o, u) {
- if (!n[o]) {
- if (!t[o]) {
- var a = typeof require == "function" && require;if (!u && a) return require(o, !0);if (i) return i(o, !0);var f = new Error("Cannot find module '" + o + "'");throw f.code = "MODULE_NOT_FOUND", f;
- }var l = n[o] = { exports: {} };t[o][0].call(l.exports, function (e) {
- var n = t[o][1][e];return s(n ? n : e);
- }, l, l.exports, e, t, n, r);
- }return n[o].exports;
- }var i = typeof require == "function" && require;for (var o = 0; o < r.length; o++) {
- s(r[o]);
- }return s;
- }({ 1: [function (require, module, exports) {
- var QueryHandler = require(3);
- var each = require(4).each;
- /**
- * Represents a single media query, manages it's state and registered handlers for this query
- *
- * @constructor
- * @param {string} query the media query string
- * @param {boolean} [isUnconditional=false] whether the media query should run regardless of whether the conditions are met. Primarily for helping older browsers deal with mobile-first design
- */
- function MediaQuery(query, isUnconditional) {
- this.query = query;
- this.isUnconditional = isUnconditional;
- this.handlers = [];
- this.mql = window.matchMedia(query);
- var self = this;
- this.listener = function (mql) {
- // Chrome passes an MediaQueryListEvent object, while other browsers pass MediaQueryList directly
- self.mql = mql.currentTarget || mql;
- self.assess();
- };
- this.mql.addListener(this.listener);
- }
- MediaQuery.prototype = {
- constuctor: MediaQuery,
- /**
- * add a handler for this query, triggering if already active
- *
- * @param {object} handler
- * @param {function} handler.match callback for when query is activated
- * @param {function} [handler.unmatch] callback for when query is deactivated
- * @param {function} [handler.setup] callback for immediate execution when a query handler is registered
- * @param {boolean} [handler.deferSetup=false] should the setup callback be deferred until the first time the handler is matched?
- */
- addHandler: function addHandler(handler) {
- var qh = new QueryHandler(handler);
- this.handlers.push(qh);
- this.matches() && qh.on();
- },
- /**
- * removes the given handler from the collection, and calls it's destroy methods
- *
- * @param {object || function} handler the handler to remove
- */
- removeHandler: function removeHandler(handler) {
- var handlers = this.handlers;
- each(handlers, function (h, i) {
- if (h.equals(handler)) {
- h.destroy();
- return !handlers.splice(i, 1); //remove from array and exit each early
- }
- });
- },
- /**
- * Determine whether the media query should be considered a match
- *
- * @return {Boolean} true if media query can be considered a match, false otherwise
- */
- matches: function matches() {
- return this.mql.matches || this.isUnconditional;
- },
- /**
- * Clears all handlers and unbinds events
- */
- clear: function clear() {
- each(this.handlers, function (handler) {
- handler.destroy();
- });
- this.mql.removeListener(this.listener);
- this.handlers.length = 0; //clear array
- },
- /*
- * Assesses the query, turning on all handlers if it matches, turning them off if it doesn't match
- */
- assess: function assess() {
- var action = this.matches() ? 'on' : 'off';
- each(this.handlers, function (handler) {
- handler[action]();
- });
- }
- };
- module.exports = MediaQuery;
- }, { "3": 3, "4": 4 }], 2: [function (require, module, exports) {
- var MediaQuery = require(1);
- var Util = require(4);
- var each = Util.each;
- var isFunction = Util.isFunction;
- var isArray = Util.isArray;
- /**
- * Allows for registration of query handlers.
- * Manages the query handler's state and is responsible for wiring up browser events
- *
- * @constructor
- */
- function MediaQueryDispatch() {
- if (!window.matchMedia) {
- throw new Error('matchMedia not present, legacy browsers require a polyfill');
- }
- this.queries = {};
- this.browserIsIncapable = !window.matchMedia('only all').matches;
- }
- MediaQueryDispatch.prototype = {
- constructor: MediaQueryDispatch,
- /**
- * Registers a handler for the given media query
- *
- * @param {string} q the media query
- * @param {object || Array || Function} options either a single query handler object, a function, or an array of query handlers
- * @param {function} options.match fired when query matched
- * @param {function} [options.unmatch] fired when a query is no longer matched
- * @param {function} [options.setup] fired when handler first triggered
- * @param {boolean} [options.deferSetup=false] whether setup should be run immediately or deferred until query is first matched
- * @param {boolean} [shouldDegrade=false] whether this particular media query should always run on incapable browsers
- */
- register: function register(q, options, shouldDegrade) {
- var queries = this.queries,
- isUnconditional = shouldDegrade && this.browserIsIncapable;
- if (!queries[q]) {
- queries[q] = new MediaQuery(q, isUnconditional);
- }
- //normalise to object in an array
- if (isFunction(options)) {
- options = { match: options };
- }
- if (!isArray(options)) {
- options = [options];
- }
- each(options, function (handler) {
- if (isFunction(handler)) {
- handler = { match: handler };
- }
- queries[q].addHandler(handler);
- });
- return this;
- },
- /**
- * unregisters a query and all it's handlers, or a specific handler for a query
- *
- * @param {string} q the media query to target
- * @param {object || function} [handler] specific handler to unregister
- */
- unregister: function unregister(q, handler) {
- var query = this.queries[q];
- if (query) {
- if (handler) {
- query.removeHandler(handler);
- } else {
- query.clear();
- delete this.queries[q];
- }
- }
- return this;
- }
- };
- module.exports = MediaQueryDispatch;
- }, { "1": 1, "4": 4 }], 3: [function (require, module, exports) {
- /**
- * Delegate to handle a media query being matched and unmatched.
- *
- * @param {object} options
- * @param {function} options.match callback for when the media query is matched
- * @param {function} [options.unmatch] callback for when the media query is unmatched
- * @param {function} [options.setup] one-time callback triggered the first time a query is matched
- * @param {boolean} [options.deferSetup=false] should the setup callback be run immediately, rather than first time query is matched?
- * @constructor
- */
- function QueryHandler(options) {
- this.options = options;
- !options.deferSetup && this.setup();
- }
- QueryHandler.prototype = {
- constructor: QueryHandler,
- /**
- * coordinates setup of the handler
- *
- * @function
- */
- setup: function setup() {
- if (this.options.setup) {
- this.options.setup();
- }
- this.initialised = true;
- },
- /**
- * coordinates setup and triggering of the handler
- *
- * @function
- */
- on: function on() {
- !this.initialised && this.setup();
- this.options.match && this.options.match();
- },
- /**
- * coordinates the unmatch event for the handler
- *
- * @function
- */
- off: function off() {
- this.options.unmatch && this.options.unmatch();
- },
- /**
- * called when a handler is to be destroyed.
- * delegates to the destroy or unmatch callbacks, depending on availability.
- *
- * @function
- */
- destroy: function destroy() {
- this.options.destroy ? this.options.destroy() : this.off();
- },
- /**
- * determines equality by reference.
- * if object is supplied compare options, if function, compare match callback
- *
- * @function
- * @param {object || function} [target] the target for comparison
- */
- equals: function equals(target) {
- return this.options === target || this.options.match === target;
- }
- };
- module.exports = QueryHandler;
- }, {}], 4: [function (require, module, exports) {
- /**
- * Helper function for iterating over a collection
- *
- * @param collection
- * @param fn
- */
- function each(collection, fn) {
- var i = 0,
- length = collection.length,
- cont;
- for (i; i < length; i++) {
- cont = fn(collection[i], i);
- if (cont === false) {
- break; //allow early exit
- }
- }
- }
- /**
- * Helper function for determining whether target object is an array
- *
- * @param target the object under test
- * @return {Boolean} true if array, false otherwise
- */
- function isArray(target) {
- return Object.prototype.toString.apply(target) === '[object Array]';
- }
- /**
- * Helper function for determining whether target object is a function
- *
- * @param target the object under test
- * @return {Boolean} true if function, false otherwise
- */
- function isFunction(target) {
- return typeof target === 'function';
- }
- module.exports = {
- isFunction: isFunction,
- isArray: isArray,
- each: each
- };
- }, {}], 5: [function (require, module, exports) {
- var MediaQueryDispatch = require(2);
- module.exports = new MediaQueryDispatch();
- }, { "2": 2 }] }, {}, [5])(5);
- });
- /***/ }),
- /* 32 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
- /*! jQuery UI - v1.12.1 - 2017-03-23
- * http://jqueryui.com
- * Includes: widget.js, keycode.js, widgets/mouse.js, widgets/slider.js
- * Copyright jQuery Foundation and other contributors; Licensed MIT */
- (function (factory) {
- if (true) {
- // AMD. Register as an anonymous module.
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else {
- // Browser globals
- factory(jQuery);
- }
- })(function ($) {
- $.ui = $.ui || {};
- var version = $.ui.version = "1.12.1";
- /*!
- * jQuery UI Widget 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
- //>>label: Widget
- //>>group: Core
- //>>description: Provides a factory for creating stateful widgets with a common API.
- //>>docs: http://api.jqueryui.com/jQuery.widget/
- //>>demos: http://jqueryui.com/widget/
- var widgetUuid = 0;
- var widgetSlice = Array.prototype.slice;
- $.cleanData = function (orig) {
- return function (elems) {
- var events, elem, i;
- for (i = 0; (elem = elems[i]) != null; i++) {
- try {
- // Only trigger remove when necessary to save time
- events = $._data(elem, "events");
- if (events && events.remove) {
- $(elem).triggerHandler("remove");
- }
- // Http://bugs.jquery.com/ticket/8235
- } catch (e) {}
- }
- orig(elems);
- };
- }($.cleanData);
- $.widget = function (name, base, prototype) {
- var existingConstructor, constructor, basePrototype;
- // ProxiedPrototype allows the provided prototype to remain unmodified
- // so that it can be used as a mixin for multiple widgets (#8876)
- var proxiedPrototype = {};
- var namespace = name.split(".")[0];
- name = name.split(".")[1];
- var fullName = namespace + "-" + name;
- if (!prototype) {
- prototype = base;
- base = $.Widget;
- }
- if ($.isArray(prototype)) {
- prototype = $.extend.apply(null, [{}].concat(prototype));
- }
- // Create selector for plugin
- $.expr[":"][fullName.toLowerCase()] = function (elem) {
- return !!$.data(elem, fullName);
- };
- $[namespace] = $[namespace] || {};
- existingConstructor = $[namespace][name];
- constructor = $[namespace][name] = function (options, element) {
- // Allow instantiation without "new" keyword
- if (!this._createWidget) {
- return new constructor(options, element);
- }
- // Allow instantiation without initializing for simple inheritance
- // must use "new" keyword (the code above always passes args)
- if (arguments.length) {
- this._createWidget(options, element);
- }
- };
- // Extend with the existing constructor to carry over any static properties
- $.extend(constructor, existingConstructor, {
- version: prototype.version,
- // Copy the object used to create the prototype in case we need to
- // redefine the widget later
- _proto: $.extend({}, prototype),
- // Track widgets that inherit from this widget in case this widget is
- // redefined after a widget inherits from it
- _childConstructors: []
- });
- basePrototype = new base();
- // We need to make the options hash a property directly on the new instance
- // otherwise we'll modify the options hash on the prototype that we're
- // inheriting from
- basePrototype.options = $.widget.extend({}, basePrototype.options);
- $.each(prototype, function (prop, value) {
- if (!$.isFunction(value)) {
- proxiedPrototype[prop] = value;
- return;
- }
- proxiedPrototype[prop] = function () {
- function _super() {
- return base.prototype[prop].apply(this, arguments);
- }
- function _superApply(args) {
- return base.prototype[prop].apply(this, args);
- }
- return function () {
- var __super = this._super;
- var __superApply = this._superApply;
- var returnValue;
- this._super = _super;
- this._superApply = _superApply;
- returnValue = value.apply(this, arguments);
- this._super = __super;
- this._superApply = __superApply;
- return returnValue;
- };
- }();
- });
- constructor.prototype = $.widget.extend(basePrototype, {
- // TODO: remove support for widgetEventPrefix
- // always use the name + a colon as the prefix, e.g., draggable:start
- // don't prefix for widgets that aren't DOM-based
- widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix || name : name
- }, proxiedPrototype, {
- constructor: constructor,
- namespace: namespace,
- widgetName: name,
- widgetFullName: fullName
- });
- // If this widget is being redefined then we need to find all widgets that
- // are inheriting from it and redefine all of them so that they inherit from
- // the new version of this widget. We're essentially trying to replace one
- // level in the prototype chain.
- if (existingConstructor) {
- $.each(existingConstructor._childConstructors, function (i, child) {
- var childPrototype = child.prototype;
- // Redefine the child widget using the same prototype that was
- // originally used, but inherit from the new version of the base
- $.widget(childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto);
- });
- // Remove the list of existing child constructors from the old constructor
- // so the old child constructors can be garbage collected
- delete existingConstructor._childConstructors;
- } else {
- base._childConstructors.push(constructor);
- }
- $.widget.bridge(name, constructor);
- return constructor;
- };
- $.widget.extend = function (target) {
- var input = widgetSlice.call(arguments, 1);
- var inputIndex = 0;
- var inputLength = input.length;
- var key;
- var value;
- for (; inputIndex < inputLength; inputIndex++) {
- for (key in input[inputIndex]) {
- value = input[inputIndex][key];
- if (input[inputIndex].hasOwnProperty(key) && value !== undefined) {
- // Clone objects
- if ($.isPlainObject(value)) {
- target[key] = $.isPlainObject(target[key]) ? $.widget.extend({}, target[key], value) :
- // Don't extend strings, arrays, etc. with objects
- $.widget.extend({}, value);
- // Copy everything else by reference
- } else {
- target[key] = value;
- }
- }
- }
- }
- return target;
- };
- $.widget.bridge = function (name, object) {
- var fullName = object.prototype.widgetFullName || name;
- $.fn[name] = function (options) {
- var isMethodCall = typeof options === "string";
- var args = widgetSlice.call(arguments, 1);
- var returnValue = this;
- if (isMethodCall) {
- // If this is an empty collection, we need to have the instance method
- // return undefined instead of the jQuery instance
- if (!this.length && options === "instance") {
- returnValue = undefined;
- } else {
- this.each(function () {
- var methodValue;
- var instance = $.data(this, fullName);
- if (options === "instance") {
- returnValue = instance;
- return false;
- }
- if (!instance) {
- return $.error("cannot call methods on " + name + " prior to initialization; " + "attempted to call method '" + options + "'");
- }
- if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
- return $.error("no such method '" + options + "' for " + name + " widget instance");
- }
- methodValue = instance[options].apply(instance, args);
- if (methodValue !== instance && methodValue !== undefined) {
- returnValue = methodValue && methodValue.jquery ? returnValue.pushStack(methodValue.get()) : methodValue;
- return false;
- }
- });
- }
- } else {
- // Allow multiple hashes to be passed on init
- if (args.length) {
- options = $.widget.extend.apply(null, [options].concat(args));
- }
- this.each(function () {
- var instance = $.data(this, fullName);
- if (instance) {
- instance.option(options || {});
- if (instance._init) {
- instance._init();
- }
- } else {
- $.data(this, fullName, new object(options, this));
- }
- });
- }
- return returnValue;
- };
- };
- $.Widget = function () /* options, element */{};
- $.Widget._childConstructors = [];
- $.Widget.prototype = {
- widgetName: "widget",
- widgetEventPrefix: "",
- defaultElement: "<div>",
- options: {
- classes: {},
- disabled: false,
- // Callbacks
- create: null
- },
- _createWidget: function _createWidget(options, element) {
- element = $(element || this.defaultElement || this)[0];
- this.element = $(element);
- this.uuid = widgetUuid++;
- this.eventNamespace = "." + this.widgetName + this.uuid;
- this.bindings = $();
- this.hoverable = $();
- this.focusable = $();
- this.classesElementLookup = {};
- if (element !== this) {
- $.data(element, this.widgetFullName, this);
- this._on(true, this.element, {
- remove: function remove(event) {
- if (event.target === element) {
- this.destroy();
- }
- }
- });
- this.document = $(element.style ?
- // Element within the document
- element.ownerDocument :
- // Element is window or document
- element.document || element);
- this.window = $(this.document[0].defaultView || this.document[0].parentWindow);
- }
- this.options = $.widget.extend({}, this.options, this._getCreateOptions(), options);
- this._create();
- if (this.options.disabled) {
- this._setOptionDisabled(this.options.disabled);
- }
- this._trigger("create", null, this._getCreateEventData());
- this._init();
- },
- _getCreateOptions: function _getCreateOptions() {
- return {};
- },
- _getCreateEventData: $.noop,
- _create: $.noop,
- _init: $.noop,
- destroy: function destroy() {
- var that = this;
- this._destroy();
- $.each(this.classesElementLookup, function (key, value) {
- that._removeClass(value, key);
- });
- // We can probably remove the unbind calls in 2.0
- // all event bindings should go through this._on()
- this.element.off(this.eventNamespace).removeData(this.widgetFullName);
- this.widget().off(this.eventNamespace).removeAttr("aria-disabled");
- // Clean up events and states
- this.bindings.off(this.eventNamespace);
- },
- _destroy: $.noop,
- widget: function widget() {
- return this.element;
- },
- option: function option(key, value) {
- var options = key;
- var parts;
- var curOption;
- var i;
- if (arguments.length === 0) {
- // Don't return a reference to the internal hash
- return $.widget.extend({}, this.options);
- }
- if (typeof key === "string") {
- // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
- options = {};
- parts = key.split(".");
- key = parts.shift();
- if (parts.length) {
- curOption = options[key] = $.widget.extend({}, this.options[key]);
- for (i = 0; i < parts.length - 1; i++) {
- curOption[parts[i]] = curOption[parts[i]] || {};
- curOption = curOption[parts[i]];
- }
- key = parts.pop();
- if (arguments.length === 1) {
- return curOption[key] === undefined ? null : curOption[key];
- }
- curOption[key] = value;
- } else {
- if (arguments.length === 1) {
- return this.options[key] === undefined ? null : this.options[key];
- }
- options[key] = value;
- }
- }
- this._setOptions(options);
- return this;
- },
- _setOptions: function _setOptions(options) {
- var key;
- for (key in options) {
- this._setOption(key, options[key]);
- }
- return this;
- },
- _setOption: function _setOption(key, value) {
- if (key === "classes") {
- this._setOptionClasses(value);
- }
- this.options[key] = value;
- if (key === "disabled") {
- this._setOptionDisabled(value);
- }
- return this;
- },
- _setOptionClasses: function _setOptionClasses(value) {
- var classKey, elements, currentElements;
- for (classKey in value) {
- currentElements = this.classesElementLookup[classKey];
- if (value[classKey] === this.options.classes[classKey] || !currentElements || !currentElements.length) {
- continue;
- }
- // We are doing this to create a new jQuery object because the _removeClass() call
- // on the next line is going to destroy the reference to the current elements being
- // tracked. We need to save a copy of this collection so that we can add the new classes
- // below.
- elements = $(currentElements.get());
- this._removeClass(currentElements, classKey);
- // We don't use _addClass() here, because that uses this.options.classes
- // for generating the string of classes. We want to use the value passed in from
- // _setOption(), this is the new value of the classes option which was passed to
- // _setOption(). We pass this value directly to _classes().
- elements.addClass(this._classes({
- element: elements,
- keys: classKey,
- classes: value,
- add: true
- }));
- }
- },
- _setOptionDisabled: function _setOptionDisabled(value) {
- this._toggleClass(this.widget(), this.widgetFullName + "-disabled", null, !!value);
- // If the widget is becoming disabled, then nothing is interactive
- if (value) {
- this._removeClass(this.hoverable, null, "ui-state-hover");
- this._removeClass(this.focusable, null, "ui-state-focus");
- }
- },
- enable: function enable() {
- return this._setOptions({ disabled: false });
- },
- disable: function disable() {
- return this._setOptions({ disabled: true });
- },
- _classes: function _classes(options) {
- var full = [];
- var that = this;
- options = $.extend({
- element: this.element,
- classes: this.options.classes || {}
- }, options);
- function processClassString(classes, checkOption) {
- var current, i;
- for (i = 0; i < classes.length; i++) {
- current = that.classesElementLookup[classes[i]] || $();
- if (options.add) {
- current = $($.unique(current.get().concat(options.element.get())));
- } else {
- current = $(current.not(options.element).get());
- }
- that.classesElementLookup[classes[i]] = current;
- full.push(classes[i]);
- if (checkOption && options.classes[classes[i]]) {
- full.push(options.classes[classes[i]]);
- }
- }
- }
- this._on(options.element, {
- "remove": "_untrackClassesElement"
- });
- if (options.keys) {
- processClassString(options.keys.match(/\S+/g) || [], true);
- }
- if (options.extra) {
- processClassString(options.extra.match(/\S+/g) || []);
- }
- return full.join(" ");
- },
- _untrackClassesElement: function _untrackClassesElement(event) {
- var that = this;
- $.each(that.classesElementLookup, function (key, value) {
- if ($.inArray(event.target, value) !== -1) {
- that.classesElementLookup[key] = $(value.not(event.target).get());
- }
- });
- },
- _removeClass: function _removeClass(element, keys, extra) {
- return this._toggleClass(element, keys, extra, false);
- },
- _addClass: function _addClass(element, keys, extra) {
- return this._toggleClass(element, keys, extra, true);
- },
- _toggleClass: function _toggleClass(element, keys, extra, add) {
- add = typeof add === "boolean" ? add : extra;
- var shift = typeof element === "string" || element === null,
- options = {
- extra: shift ? keys : extra,
- keys: shift ? element : keys,
- element: shift ? this.element : element,
- add: add
- };
- options.element.toggleClass(this._classes(options), add);
- return this;
- },
- _on: function _on(suppressDisabledCheck, element, handlers) {
- var delegateElement;
- var instance = this;
- // No suppressDisabledCheck flag, shuffle arguments
- if (typeof suppressDisabledCheck !== "boolean") {
- handlers = element;
- element = suppressDisabledCheck;
- suppressDisabledCheck = false;
- }
- // No element argument, shuffle and use this.element
- if (!handlers) {
- handlers = element;
- element = this.element;
- delegateElement = this.widget();
- } else {
- element = delegateElement = $(element);
- this.bindings = this.bindings.add(element);
- }
- $.each(handlers, function (event, handler) {
- function handlerProxy() {
- // Allow widgets to customize the disabled handling
- // - disabled as an array instead of boolean
- // - disabled class as method for disabling individual parts
- if (!suppressDisabledCheck && (instance.options.disabled === true || $(this).hasClass("ui-state-disabled"))) {
- return;
- }
- return (typeof handler === "string" ? instance[handler] : handler).apply(instance, arguments);
- }
- // Copy the guid so direct unbinding works
- if (typeof handler !== "string") {
- handlerProxy.guid = handler.guid = handler.guid || handlerProxy.guid || $.guid++;
- }
- var match = event.match(/^([\w:-]*)\s*(.*)$/);
- var eventName = match[1] + instance.eventNamespace;
- var selector = match[2];
- if (selector) {
- delegateElement.on(eventName, selector, handlerProxy);
- } else {
- element.on(eventName, handlerProxy);
- }
- });
- },
- _off: function _off(element, eventName) {
- eventName = (eventName || "").split(" ").join(this.eventNamespace + " ") + this.eventNamespace;
- element.off(eventName).off(eventName);
- // Clear the stack to avoid memory leaks (#10056)
- this.bindings = $(this.bindings.not(element).get());
- this.focusable = $(this.focusable.not(element).get());
- this.hoverable = $(this.hoverable.not(element).get());
- },
- _delay: function _delay(handler, delay) {
- function handlerProxy() {
- return (typeof handler === "string" ? instance[handler] : handler).apply(instance, arguments);
- }
- var instance = this;
- return setTimeout(handlerProxy, delay || 0);
- },
- _hoverable: function _hoverable(element) {
- this.hoverable = this.hoverable.add(element);
- this._on(element, {
- mouseenter: function mouseenter(event) {
- this._addClass($(event.currentTarget), null, "ui-state-hover");
- },
- mouseleave: function mouseleave(event) {
- this._removeClass($(event.currentTarget), null, "ui-state-hover");
- }
- });
- },
- _focusable: function _focusable(element) {
- this.focusable = this.focusable.add(element);
- this._on(element, {
- focusin: function focusin(event) {
- this._addClass($(event.currentTarget), null, "ui-state-focus");
- },
- focusout: function focusout(event) {
- this._removeClass($(event.currentTarget), null, "ui-state-focus");
- }
- });
- },
- _trigger: function _trigger(type, event, data) {
- var prop, orig;
- var callback = this.options[type];
- data = data || {};
- event = $.Event(event);
- event.type = (type === this.widgetEventPrefix ? type : this.widgetEventPrefix + type).toLowerCase();
- // The original event may come from any element
- // so we need to reset the target on the new event
- event.target = this.element[0];
- // Copy original event properties over to the new event
- orig = event.originalEvent;
- if (orig) {
- for (prop in orig) {
- if (!(prop in event)) {
- event[prop] = orig[prop];
- }
- }
- }
- this.element.trigger(event, data);
- return !($.isFunction(callback) && callback.apply(this.element[0], [event].concat(data)) === false || event.isDefaultPrevented());
- }
- };
- $.each({ show: "fadeIn", hide: "fadeOut" }, function (method, defaultEffect) {
- $.Widget.prototype["_" + method] = function (element, options, callback) {
- if (typeof options === "string") {
- options = { effect: options };
- }
- var hasOptions;
- var effectName = !options ? method : options === true || typeof options === "number" ? defaultEffect : options.effect || defaultEffect;
- options = options || {};
- if (typeof options === "number") {
- options = { duration: options };
- }
- hasOptions = !$.isEmptyObject(options);
- options.complete = callback;
- if (options.delay) {
- element.delay(options.delay);
- }
- if (hasOptions && $.effects && $.effects.effect[effectName]) {
- element[method](options);
- } else if (effectName !== method && element[effectName]) {
- element[effectName](options.duration, options.easing, callback);
- } else {
- element.queue(function (next) {
- $(this)[method]();
- if (callback) {
- callback.call(element[0]);
- }
- next();
- });
- }
- };
- });
- var widget = $.widget;
- /*!
- * jQuery UI Keycode 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
- //>>label: Keycode
- //>>group: Core
- //>>description: Provide keycodes as keynames
- //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
- var keycode = $.ui.keyCode = {
- BACKSPACE: 8,
- COMMA: 188,
- DELETE: 46,
- DOWN: 40,
- END: 35,
- ENTER: 13,
- ESCAPE: 27,
- HOME: 36,
- LEFT: 37,
- PAGE_DOWN: 34,
- PAGE_UP: 33,
- PERIOD: 190,
- RIGHT: 39,
- SPACE: 32,
- TAB: 9,
- UP: 38
- };
- // This file is deprecated
- var ie = $.ui.ie = !!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());
- /*!
- * jQuery UI Mouse 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
- //>>label: Mouse
- //>>group: Widgets
- //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
- //>>docs: http://api.jqueryui.com/mouse/
- var mouseHandled = false;
- $(document).on("mouseup", function () {
- mouseHandled = false;
- });
- var widgetsMouse = $.widget("ui.mouse", {
- version: "1.12.1",
- options: {
- cancel: "input, textarea, button, select, option",
- distance: 1,
- delay: 0
- },
- _mouseInit: function _mouseInit() {
- var that = this;
- this.element.on("mousedown." + this.widgetName, function (event) {
- return that._mouseDown(event);
- }).on("click." + this.widgetName, function (event) {
- if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
- $.removeData(event.target, that.widgetName + ".preventClickEvent");
- event.stopImmediatePropagation();
- return false;
- }
- });
- this.started = false;
- },
- // TODO: make sure destroying one instance of mouse doesn't mess with
- // other instances of mouse
- _mouseDestroy: function _mouseDestroy() {
- this.element.off("." + this.widgetName);
- if (this._mouseMoveDelegate) {
- this.document.off("mousemove." + this.widgetName, this._mouseMoveDelegate).off("mouseup." + this.widgetName, this._mouseUpDelegate);
- }
- },
- _mouseDown: function _mouseDown(event) {
- // don't let more than one widget handle mouseStart
- if (mouseHandled) {
- return;
- }
- this._mouseMoved = false;
- // We may have missed mouseup (out of window)
- this._mouseStarted && this._mouseUp(event);
- this._mouseDownEvent = event;
- var that = this,
- btnIsLeft = event.which === 1,
- // event.target.nodeName works around a bug in IE 8 with
- // disabled inputs (#7620)
- elIsCancel = typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false;
- if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
- return true;
- }
- this.mouseDelayMet = !this.options.delay;
- if (!this.mouseDelayMet) {
- this._mouseDelayTimer = setTimeout(function () {
- that.mouseDelayMet = true;
- }, this.options.delay);
- }
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
- this._mouseStarted = this._mouseStart(event) !== false;
- if (!this._mouseStarted) {
- event.preventDefault();
- return true;
- }
- }
- // Click event may never have fired (Gecko & Opera)
- if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
- $.removeData(event.target, this.widgetName + ".preventClickEvent");
- }
- // These delegates are required to keep context
- this._mouseMoveDelegate = function (event) {
- return that._mouseMove(event);
- };
- this._mouseUpDelegate = function (event) {
- return that._mouseUp(event);
- };
- this.document.on("mousemove." + this.widgetName, this._mouseMoveDelegate).on("mouseup." + this.widgetName, this._mouseUpDelegate);
- event.preventDefault();
- mouseHandled = true;
- return true;
- },
- _mouseMove: function _mouseMove(event) {
- // Only check for mouseups outside the document if you've moved inside the document
- // at least once. This prevents the firing of mouseup in the case of IE<9, which will
- // fire a mousemove event if content is placed under the cursor. See #7778
- // Support: IE <9
- if (this._mouseMoved) {
- // IE mouseup check - mouseup happened when mouse was out of window
- if ($.ui.ie && (!document.documentMode || document.documentMode < 9) && !event.button) {
- return this._mouseUp(event);
- // Iframe mouseup check - mouseup occurred in another document
- } else if (!event.which) {
- // Support: Safari <=8 - 9
- // Safari sets which to 0 if you press any of the following keys
- // during a drag (#14461)
- if (event.originalEvent.altKey || event.originalEvent.ctrlKey || event.originalEvent.metaKey || event.originalEvent.shiftKey) {
- this.ignoreMissingWhich = true;
- } else if (!this.ignoreMissingWhich) {
- return this._mouseUp(event);
- }
- }
- }
- if (event.which || event.button) {
- this._mouseMoved = true;
- }
- if (this._mouseStarted) {
- this._mouseDrag(event);
- return event.preventDefault();
- }
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
- this._mouseStarted = this._mouseStart(this._mouseDownEvent, event) !== false;
- this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event);
- }
- return !this._mouseStarted;
- },
- _mouseUp: function _mouseUp(event) {
- this.document.off("mousemove." + this.widgetName, this._mouseMoveDelegate).off("mouseup." + this.widgetName, this._mouseUpDelegate);
- if (this._mouseStarted) {
- this._mouseStarted = false;
- if (event.target === this._mouseDownEvent.target) {
- $.data(event.target, this.widgetName + ".preventClickEvent", true);
- }
- this._mouseStop(event);
- }
- if (this._mouseDelayTimer) {
- clearTimeout(this._mouseDelayTimer);
- delete this._mouseDelayTimer;
- }
- this.ignoreMissingWhich = false;
- mouseHandled = false;
- event.preventDefault();
- },
- _mouseDistanceMet: function _mouseDistanceMet(event) {
- return Math.max(Math.abs(this._mouseDownEvent.pageX - event.pageX), Math.abs(this._mouseDownEvent.pageY - event.pageY)) >= this.options.distance;
- },
- _mouseDelayMet: function _mouseDelayMet() /* event */{
- return this.mouseDelayMet;
- },
- // These are placeholder methods, to be overriden by extending plugin
- _mouseStart: function _mouseStart() /* event */{},
- _mouseDrag: function _mouseDrag() /* event */{},
- _mouseStop: function _mouseStop() /* event */{},
- _mouseCapture: function _mouseCapture() /* event */{
- return true;
- }
- });
- /*!
- * jQuery UI Slider 1.12.1
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
- //>>label: Slider
- //>>group: Widgets
- //>>description: Displays a flexible slider with ranges and accessibility via keyboard.
- //>>docs: http://api.jqueryui.com/slider/
- //>>demos: http://jqueryui.com/slider/
- //>>css.structure: ../../themes/base/core.css
- //>>css.structure: ../../themes/base/slider.css
- //>>css.theme: ../../themes/base/theme.css
- var widgetsSlider = $.widget("ui.slider", $.ui.mouse, {
- version: "1.12.1",
- widgetEventPrefix: "slide",
- options: {
- animate: false,
- classes: {
- "ui-slider": "ui-corner-all",
- "ui-slider-handle": "ui-corner-all",
- // Note: ui-widget-header isn't the most fittingly semantic framework class for this
- // element, but worked best visually with a variety of themes
- "ui-slider-range": "ui-corner-all ui-widget-header"
- },
- distance: 0,
- max: 100,
- min: 0,
- orientation: "horizontal",
- range: false,
- step: 1,
- value: 0,
- values: null,
- // Callbacks
- change: null,
- slide: null,
- start: null,
- stop: null
- },
- // Number of pages in a slider
- // (how many times can you page up/down to go through the whole range)
- numPages: 5,
- _create: function _create() {
- this._keySliding = false;
- this._mouseSliding = false;
- this._animateOff = true;
- this._handleIndex = null;
- this._detectOrientation();
- this._mouseInit();
- this._calculateNewMax();
- this._addClass("ui-slider ui-slider-" + this.orientation, "ui-widget ui-widget-content");
- this._refresh();
- this._animateOff = false;
- },
- _refresh: function _refresh() {
- this._createRange();
- this._createHandles();
- this._setupEvents();
- this._refreshValue();
- },
- _createHandles: function _createHandles() {
- var i,
- handleCount,
- options = this.options,
- existingHandles = this.element.find(".ui-slider-handle"),
- handle = "<span tabindex='0'></span>",
- handles = [];
- handleCount = options.values && options.values.length || 1;
- if (existingHandles.length > handleCount) {
- existingHandles.slice(handleCount).remove();
- existingHandles = existingHandles.slice(0, handleCount);
- }
- for (i = existingHandles.length; i < handleCount; i++) {
- handles.push(handle);
- }
- this.handles = existingHandles.add($(handles.join("")).appendTo(this.element));
- this._addClass(this.handles, "ui-slider-handle", "ui-state-default");
- this.handle = this.handles.eq(0);
- this.handles.each(function (i) {
- $(this).data("ui-slider-handle-index", i).attr("tabIndex", 0);
- });
- },
- _createRange: function _createRange() {
- var options = this.options;
- if (options.range) {
- if (options.range === true) {
- if (!options.values) {
- options.values = [this._valueMin(), this._valueMin()];
- } else if (options.values.length && options.values.length !== 2) {
- options.values = [options.values[0], options.values[0]];
- } else if ($.isArray(options.values)) {
- options.values = options.values.slice(0);
- }
- }
- if (!this.range || !this.range.length) {
- this.range = $("<div>").appendTo(this.element);
- this._addClass(this.range, "ui-slider-range");
- } else {
- this._removeClass(this.range, "ui-slider-range-min ui-slider-range-max");
- // Handle range switching from true to min/max
- this.range.css({
- "left": "",
- "bottom": ""
- });
- }
- if (options.range === "min" || options.range === "max") {
- this._addClass(this.range, "ui-slider-range-" + options.range);
- }
- } else {
- if (this.range) {
- this.range.remove();
- }
- this.range = null;
- }
- },
- _setupEvents: function _setupEvents() {
- this._off(this.handles);
- this._on(this.handles, this._handleEvents);
- this._hoverable(this.handles);
- this._focusable(this.handles);
- },
- _destroy: function _destroy() {
- this.handles.remove();
- if (this.range) {
- this.range.remove();
- }
- this._mouseDestroy();
- },
- _mouseCapture: function _mouseCapture(event) {
- var position,
- normValue,
- distance,
- closestHandle,
- index,
- allowed,
- offset,
- mouseOverHandle,
- that = this,
- o = this.options;
- if (o.disabled) {
- return false;
- }
- this.elementSize = {
- width: this.element.outerWidth(),
- height: this.element.outerHeight()
- };
- this.elementOffset = this.element.offset();
- position = { x: event.pageX, y: event.pageY };
- normValue = this._normValueFromMouse(position);
- distance = this._valueMax() - this._valueMin() + 1;
- this.handles.each(function (i) {
- var thisDistance = Math.abs(normValue - that.values(i));
- if (distance > thisDistance || distance === thisDistance && (i === that._lastChangedValue || that.values(i) === o.min)) {
- distance = thisDistance;
- closestHandle = $(this);
- index = i;
- }
- });
- allowed = this._start(event, index);
- if (allowed === false) {
- return false;
- }
- this._mouseSliding = true;
- this._handleIndex = index;
- this._addClass(closestHandle, null, "ui-state-active");
- closestHandle.trigger("focus");
- offset = closestHandle.offset();
- mouseOverHandle = !$(event.target).parents().addBack().is(".ui-slider-handle");
- this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
- left: event.pageX - offset.left - closestHandle.width() / 2,
- top: event.pageY - offset.top - closestHandle.height() / 2 - (parseInt(closestHandle.css("borderTopWidth"), 10) || 0) - (parseInt(closestHandle.css("borderBottomWidth"), 10) || 0) + (parseInt(closestHandle.css("marginTop"), 10) || 0)
- };
- if (!this.handles.hasClass("ui-state-hover")) {
- this._slide(event, index, normValue);
- }
- this._animateOff = true;
- return true;
- },
- _mouseStart: function _mouseStart() {
- return true;
- },
- _mouseDrag: function _mouseDrag(event) {
- var position = { x: event.pageX, y: event.pageY },
- normValue = this._normValueFromMouse(position);
- this._slide(event, this._handleIndex, normValue);
- return false;
- },
- _mouseStop: function _mouseStop(event) {
- this._removeClass(this.handles, null, "ui-state-active");
- this._mouseSliding = false;
- this._stop(event, this._handleIndex);
- this._change(event, this._handleIndex);
- this._handleIndex = null;
- this._clickOffset = null;
- this._animateOff = false;
- return false;
- },
- _detectOrientation: function _detectOrientation() {
- this.orientation = this.options.orientation === "vertical" ? "vertical" : "horizontal";
- },
- _normValueFromMouse: function _normValueFromMouse(position) {
- var pixelTotal, pixelMouse, percentMouse, valueTotal, valueMouse;
- if (this.orientation === "horizontal") {
- pixelTotal = this.elementSize.width;
- pixelMouse = position.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0);
- } else {
- pixelTotal = this.elementSize.height;
- pixelMouse = position.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0);
- }
- percentMouse = pixelMouse / pixelTotal;
- if (percentMouse > 1) {
- percentMouse = 1;
- }
- if (percentMouse < 0) {
- percentMouse = 0;
- }
- if (this.orientation === "vertical") {
- percentMouse = 1 - percentMouse;
- }
- valueTotal = this._valueMax() - this._valueMin();
- valueMouse = this._valueMin() + percentMouse * valueTotal;
- return this._trimAlignValue(valueMouse);
- },
- _uiHash: function _uiHash(index, value, values) {
- var uiHash = {
- handle: this.handles[index],
- handleIndex: index,
- value: value !== undefined ? value : this.value()
- };
- if (this._hasMultipleValues()) {
- uiHash.value = value !== undefined ? value : this.values(index);
- uiHash.values = values || this.values();
- }
- return uiHash;
- },
- _hasMultipleValues: function _hasMultipleValues() {
- return this.options.values && this.options.values.length;
- },
- _start: function _start(event, index) {
- return this._trigger("start", event, this._uiHash(index));
- },
- _slide: function _slide(event, index, newVal) {
- var allowed,
- otherVal,
- currentValue = this.value(),
- newValues = this.values();
- if (this._hasMultipleValues()) {
- otherVal = this.values(index ? 0 : 1);
- currentValue = this.values(index);
- if (this.options.values.length === 2 && this.options.range === true) {
- newVal = index === 0 ? Math.min(otherVal, newVal) : Math.max(otherVal, newVal);
- }
- newValues[index] = newVal;
- }
- if (newVal === currentValue) {
- return;
- }
- allowed = this._trigger("slide", event, this._uiHash(index, newVal, newValues));
- // A slide can be canceled by returning false from the slide callback
- if (allowed === false) {
- return;
- }
- if (this._hasMultipleValues()) {
- this.values(index, newVal);
- } else {
- this.value(newVal);
- }
- },
- _stop: function _stop(event, index) {
- this._trigger("stop", event, this._uiHash(index));
- },
- _change: function _change(event, index) {
- if (!this._keySliding && !this._mouseSliding) {
- //store the last changed value index for reference when handles overlap
- this._lastChangedValue = index;
- this._trigger("change", event, this._uiHash(index));
- }
- },
- value: function value(newValue) {
- if (arguments.length) {
- this.options.value = this._trimAlignValue(newValue);
- this._refreshValue();
- this._change(null, 0);
- return;
- }
- return this._value();
- },
- values: function values(index, newValue) {
- var vals, newValues, i;
- if (arguments.length > 1) {
- this.options.values[index] = this._trimAlignValue(newValue);
- this._refreshValue();
- this._change(null, index);
- return;
- }
- if (arguments.length) {
- if ($.isArray(arguments[0])) {
- vals = this.options.values;
- newValues = arguments[0];
- for (i = 0; i < vals.length; i += 1) {
- vals[i] = this._trimAlignValue(newValues[i]);
- this._change(null, i);
- }
- this._refreshValue();
- } else {
- if (this._hasMultipleValues()) {
- return this._values(index);
- } else {
- return this.value();
- }
- }
- } else {
- return this._values();
- }
- },
- _setOption: function _setOption(key, value) {
- var i,
- valsLength = 0;
- if (key === "range" && this.options.range === true) {
- if (value === "min") {
- this.options.value = this._values(0);
- this.options.values = null;
- } else if (value === "max") {
- this.options.value = this._values(this.options.values.length - 1);
- this.options.values = null;
- }
- }
- if ($.isArray(this.options.values)) {
- valsLength = this.options.values.length;
- }
- this._super(key, value);
- switch (key) {
- case "orientation":
- this._detectOrientation();
- this._removeClass("ui-slider-horizontal ui-slider-vertical")._addClass("ui-slider-" + this.orientation);
- this._refreshValue();
- if (this.options.range) {
- this._refreshRange(value);
- }
- // Reset positioning from previous orientation
- this.handles.css(value === "horizontal" ? "bottom" : "left", "");
- break;
- case "value":
- this._animateOff = true;
- this._refreshValue();
- this._change(null, 0);
- this._animateOff = false;
- break;
- case "values":
- this._animateOff = true;
- this._refreshValue();
- // Start from the last handle to prevent unreachable handles (#9046)
- for (i = valsLength - 1; i >= 0; i--) {
- this._change(null, i);
- }
- this._animateOff = false;
- break;
- case "step":
- case "min":
- case "max":
- this._animateOff = true;
- this._calculateNewMax();
- this._refreshValue();
- this._animateOff = false;
- break;
- case "range":
- this._animateOff = true;
- this._refresh();
- this._animateOff = false;
- break;
- }
- },
- _setOptionDisabled: function _setOptionDisabled(value) {
- this._super(value);
- this._toggleClass(null, "ui-state-disabled", !!value);
- },
- //internal value getter
- // _value() returns value trimmed by min and max, aligned by step
- _value: function _value() {
- var val = this.options.value;
- val = this._trimAlignValue(val);
- return val;
- },
- //internal values getter
- // _values() returns array of values trimmed by min and max, aligned by step
- // _values( index ) returns single value trimmed by min and max, aligned by step
- _values: function _values(index) {
- var val, vals, i;
- if (arguments.length) {
- val = this.options.values[index];
- val = this._trimAlignValue(val);
- return val;
- } else if (this._hasMultipleValues()) {
- // .slice() creates a copy of the array
- // this copy gets trimmed by min and max and then returned
- vals = this.options.values.slice();
- for (i = 0; i < vals.length; i += 1) {
- vals[i] = this._trimAlignValue(vals[i]);
- }
- return vals;
- } else {
- return [];
- }
- },
- // Returns the step-aligned value that val is closest to, between (inclusive) min and max
- _trimAlignValue: function _trimAlignValue(val) {
- if (val <= this._valueMin()) {
- return this._valueMin();
- }
- if (val >= this._valueMax()) {
- return this._valueMax();
- }
- var step = this.options.step > 0 ? this.options.step : 1,
- valModStep = (val - this._valueMin()) % step,
- alignValue = val - valModStep;
- if (Math.abs(valModStep) * 2 >= step) {
- alignValue += valModStep > 0 ? step : -step;
- }
- // Since JavaScript has problems with large floats, round
- // the final value to 5 digits after the decimal point (see #4124)
- return parseFloat(alignValue.toFixed(5));
- },
- _calculateNewMax: function _calculateNewMax() {
- var max = this.options.max,
- min = this._valueMin(),
- step = this.options.step,
- aboveMin = Math.round((max - min) / step) * step;
- max = aboveMin + min;
- if (max > this.options.max) {
- //If max is not divisible by step, rounding off may increase its value
- max -= step;
- }
- this.max = parseFloat(max.toFixed(this._precision()));
- },
- _precision: function _precision() {
- var precision = this._precisionOf(this.options.step);
- if (this.options.min !== null) {
- precision = Math.max(precision, this._precisionOf(this.options.min));
- }
- return precision;
- },
- _precisionOf: function _precisionOf(num) {
- var str = num.toString(),
- decimal = str.indexOf(".");
- return decimal === -1 ? 0 : str.length - decimal - 1;
- },
- _valueMin: function _valueMin() {
- return this.options.min;
- },
- _valueMax: function _valueMax() {
- return this.max;
- },
- _refreshRange: function _refreshRange(orientation) {
- if (orientation === "vertical") {
- this.range.css({ "width": "", "left": "" });
- }
- if (orientation === "horizontal") {
- this.range.css({ "height": "", "bottom": "" });
- }
- },
- _refreshValue: function _refreshValue() {
- var lastValPercent,
- valPercent,
- value,
- valueMin,
- valueMax,
- oRange = this.options.range,
- o = this.options,
- that = this,
- animate = !this._animateOff ? o.animate : false,
- _set = {};
- if (this._hasMultipleValues()) {
- this.handles.each(function (i) {
- valPercent = (that.values(i) - that._valueMin()) / (that._valueMax() - that._valueMin()) * 100;
- _set[that.orientation === "horizontal" ? "left" : "bottom"] = valPercent + "%";
- $(this).stop(1, 1)[animate ? "animate" : "css"](_set, o.animate);
- if (that.options.range === true) {
- if (that.orientation === "horizontal") {
- if (i === 0) {
- that.range.stop(1, 1)[animate ? "animate" : "css"]({
- left: valPercent + "%"
- }, o.animate);
- }
- if (i === 1) {
- that.range[animate ? "animate" : "css"]({
- width: valPercent - lastValPercent + "%"
- }, {
- queue: false,
- duration: o.animate
- });
- }
- } else {
- if (i === 0) {
- that.range.stop(1, 1)[animate ? "animate" : "css"]({
- bottom: valPercent + "%"
- }, o.animate);
- }
- if (i === 1) {
- that.range[animate ? "animate" : "css"]({
- height: valPercent - lastValPercent + "%"
- }, {
- queue: false,
- duration: o.animate
- });
- }
- }
- }
- lastValPercent = valPercent;
- });
- } else {
- value = this.value();
- valueMin = this._valueMin();
- valueMax = this._valueMax();
- valPercent = valueMax !== valueMin ? (value - valueMin) / (valueMax - valueMin) * 100 : 0;
- _set[this.orientation === "horizontal" ? "left" : "bottom"] = valPercent + "%";
- this.handle.stop(1, 1)[animate ? "animate" : "css"](_set, o.animate);
- if (oRange === "min" && this.orientation === "horizontal") {
- this.range.stop(1, 1)[animate ? "animate" : "css"]({
- width: valPercent + "%"
- }, o.animate);
- }
- if (oRange === "max" && this.orientation === "horizontal") {
- this.range.stop(1, 1)[animate ? "animate" : "css"]({
- width: 100 - valPercent + "%"
- }, o.animate);
- }
- if (oRange === "min" && this.orientation === "vertical") {
- this.range.stop(1, 1)[animate ? "animate" : "css"]({
- height: valPercent + "%"
- }, o.animate);
- }
- if (oRange === "max" && this.orientation === "vertical") {
- this.range.stop(1, 1)[animate ? "animate" : "css"]({
- height: 100 - valPercent + "%"
- }, o.animate);
- }
- }
- },
- _handleEvents: {
- keydown: function keydown(event) {
- var allowed,
- curVal,
- newVal,
- step,
- index = $(event.target).data("ui-slider-handle-index");
- switch (event.keyCode) {
- case $.ui.keyCode.HOME:
- case $.ui.keyCode.END:
- case $.ui.keyCode.PAGE_UP:
- case $.ui.keyCode.PAGE_DOWN:
- case $.ui.keyCode.UP:
- case $.ui.keyCode.RIGHT:
- case $.ui.keyCode.DOWN:
- case $.ui.keyCode.LEFT:
- event.preventDefault();
- if (!this._keySliding) {
- this._keySliding = true;
- this._addClass($(event.target), null, "ui-state-active");
- allowed = this._start(event, index);
- if (allowed === false) {
- return;
- }
- }
- break;
- }
- step = this.options.step;
- if (this._hasMultipleValues()) {
- curVal = newVal = this.values(index);
- } else {
- curVal = newVal = this.value();
- }
- switch (event.keyCode) {
- case $.ui.keyCode.HOME:
- newVal = this._valueMin();
- break;
- case $.ui.keyCode.END:
- newVal = this._valueMax();
- break;
- case $.ui.keyCode.PAGE_UP:
- newVal = this._trimAlignValue(curVal + (this._valueMax() - this._valueMin()) / this.numPages);
- break;
- case $.ui.keyCode.PAGE_DOWN:
- newVal = this._trimAlignValue(curVal - (this._valueMax() - this._valueMin()) / this.numPages);
- break;
- case $.ui.keyCode.UP:
- case $.ui.keyCode.RIGHT:
- if (curVal === this._valueMax()) {
- return;
- }
- newVal = this._trimAlignValue(curVal + step);
- break;
- case $.ui.keyCode.DOWN:
- case $.ui.keyCode.LEFT:
- if (curVal === this._valueMin()) {
- return;
- }
- newVal = this._trimAlignValue(curVal - step);
- break;
- }
- this._slide(event, index, newVal);
- },
- keyup: function keyup(event) {
- var index = $(event.target).data("ui-slider-handle-index");
- if (this._keySliding) {
- this._keySliding = false;
- this._stop(event, index);
- this._change(event, index);
- this._removeClass($(event.target), null, "ui-state-active");
- }
- }
- }
- });
- });
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- (function (global, factory) {
- ( false ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : true ? !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
- __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : global.StickySidebar = factory();
- })(undefined, function () {
- 'use strict';
- 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;
- };
- }();
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- /**
- * Sticky Sidebar JavaScript Plugin.
- * @version 3.2.0
- * @author Ahmed Bouhuolia <a.bouhuolia@gmail.com>
- * @license The MIT License (MIT)
- */
- var StickySidebar = function () {
- // ---------------------------------
- // # Define Constants
- // ---------------------------------
- //
- var EVENT_KEY = '.stickySidebar';
- var DEFAULTS = {
- /**
- * Additional top spacing of the element when it becomes sticky.
- * @type {Numeric|Function}
- */
- topSpacing: 0,
- /**
- * Additional bottom spacing of the element when it becomes sticky.
- * @type {Numeric|Function}
- */
- bottomSpacing: 0,
- /**
- * Container sidebar selector to know what the beginning and end of sticky element.
- * @type {String|False}
- */
- containerSelector: false,
- /**
- * Inner wrapper selector.
- * @type {String}
- */
- innerWrapperSelector: '.inner-wrapper-sticky',
- /**
- * The name of CSS class to apply to elements when they have become stuck.
- * @type {String|False}
- */
- stickyClass: 'is-affixed',
- /**
- * Detect when sidebar and its container change height so re-calculate their dimensions.
- * @type {Boolean}
- */
- resizeSensor: true,
- /**
- * The sidebar returns to its normal position if its width below this value.
- * @type {Numeric}
- */
- minWidth: false
- };
- // ---------------------------------
- // # Class Definition
- // ---------------------------------
- //
- /**
- * Sticky Sidebar Class.
- * @public
- */
- var StickySidebar = function () {
- /**
- * Sticky Sidebar Constructor.
- * @constructor
- * @param {HTMLElement|String} sidebar - The sidebar element or sidebar selector.
- * @param {Object} options - The options of sticky sidebar.
- */
- function StickySidebar(sidebar) {
- var _this = this;
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- _classCallCheck(this, StickySidebar);
- this.options = StickySidebar.extend(DEFAULTS, options);
- // Sidebar element query if there's no one, throw error.
- this.sidebar = 'string' === typeof sidebar ? document.querySelector(sidebar) : sidebar;
- if ('undefined' === typeof this.sidebar) throw new Error("There is no specific sidebar element.");
- this.sidebarInner = false;
- this.container = this.sidebar.parentElement;
- // Current Affix Type of sidebar element.
- this.affixedType = 'STATIC';
- this.direction = 'down';
- this.support = {
- transform: false,
- transform3d: false
- };
- this._initialized = false;
- this._breakpoint = false;
- this._resizeListeners = [];
- // Dimenstions of sidebar, container and screen viewport.
- this.dimensions = {
- translateY: 0,
- topSpacing: 0,
- bottomSpacing: 0,
- sidebarHeight: 0,
- sidebarWidth: 0,
- containerTop: 0,
- containerHeight: 0,
- viewportHeight: 0,
- viewportTop: 0,
- lastViewportTop: 0
- };
- // Bind event handlers for referencability.
- ['handleEvent'].forEach(function (method) {
- _this[method] = _this[method].bind(_this);
- });
- // Initialize sticky sidebar for first time.
- this.initialize();
- }
- /**
- * Initializes the sticky sidebar by adding inner wrapper, define its container,
- * min-width breakpoint, calculating dimenstions, adding helper classes and inline style.
- * @private
- */
- _createClass(StickySidebar, [{
- key: 'initialize',
- value: function initialize() {
- var _this2 = this;
- this._setSupportFeatures();
- // Get sticky sidebar inner wrapper, if not found, will create one.
- if (this.options.innerWrapperSelector) {
- this.sidebarInner = this.sidebar.querySelector(this.options.innerWrapperSelector);
- if (null === this.sidebarInner) this.sidebarInner = false;
- }
- if (!this.sidebarInner) {
- var wrapper = document.createElement('div');
- wrapper.setAttribute('class', 'inner-wrapper-sticky');
- this.sidebar.appendChild(wrapper);
- while (this.sidebar.firstChild != wrapper) {
- wrapper.appendChild(this.sidebar.firstChild);
- }this.sidebarInner = this.sidebar.querySelector('.inner-wrapper-sticky');
- }
- // Container wrapper of the sidebar.
- if (this.options.containerSelector) {
- var containers = document.querySelectorAll(this.options.containerSelector);
- containers = Array.prototype.slice.call(containers);
- containers.forEach(function (container, item) {
- if (!container.contains(_this2.sidebar)) return;
- _this2.container = container;
- });
- if (!containers.length) throw new Error("The container does not contains on the sidebar.");
- }
- // If top/bottom spacing is not function parse value to integer.
- if ('function' !== typeof this.options.topSpacing) this.options.topSpacing = parseInt(this.options.topSpacing) || 0;
- if ('function' !== typeof this.options.bottomSpacing) this.options.bottomSpacing = parseInt(this.options.bottomSpacing) || 0;
- // Breakdown sticky sidebar if screen width below `options.minWidth`.
- this._widthBreakpoint();
- // Calculate dimensions of sidebar, container and viewport.
- this.calcDimensions();
- // Affix sidebar in proper position.
- this.stickyPosition();
- // Bind all events.
- this.bindEvents();
- // Inform other properties the sticky sidebar is initialized.
- this._initialized = true;
- }
- /**
- * Bind all events of sticky sidebar plugin.
- * @protected
- */
- }, {
- key: 'bindEvents',
- value: function bindEvents() {
- window.addEventListener('resize', this, { passive: true });
- window.addEventListener('scroll', this, { passive: true });
- this.sidebar.addEventListener('update' + EVENT_KEY, this);
- if (this.options.resizeSensor && 'undefined' !== typeof ResizeSensor) {
- new ResizeSensor(this.sidebarInner, this.handleEvent);
- new ResizeSensor(this.container, this.handleEvent);
- }
- }
- /**
- * Handles all events of the plugin.
- * @param {Object} event - Event object passed from listener.
- */
- }, {
- key: 'handleEvent',
- value: function handleEvent(event) {
- this.updateSticky(event);
- }
- /**
- * Calculates dimesntions of sidebar, container and screen viewpoint
- * @public
- */
- }, {
- key: 'calcDimensions',
- value: function calcDimensions() {
- if (this._breakpoint) return;
- var dims = this.dimensions;
- // Container of sticky sidebar dimensions.
- dims.containerTop = StickySidebar.offsetRelative(this.container).top;
- dims.containerHeight = this.container.clientHeight;
- dims.containerBottom = dims.containerTop + dims.containerHeight;
- // Sidebar dimensions.
- dims.sidebarHeight = this.sidebarInner.offsetHeight;
- dims.sidebarWidth = this.sidebar.offsetWidth;
- // Screen viewport dimensions.
- dims.viewportHeight = window.innerHeight;
- this._calcDimensionsWithScroll();
- }
- /**
- * Some dimensions values need to be up-to-date when scrolling the page.
- * @private
- */
- }, {
- key: '_calcDimensionsWithScroll',
- value: function _calcDimensionsWithScroll() {
- var dims = this.dimensions;
- dims.sidebarLeft = StickySidebar.offsetRelative(this.sidebar).left;
- dims.viewportTop = document.documentElement.scrollTop || document.body.scrollTop;
- dims.viewportBottom = dims.viewportTop + dims.viewportHeight;
- dims.viewportLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
- dims.topSpacing = this.options.topSpacing;
- dims.bottomSpacing = this.options.bottomSpacing;
- if ('function' === typeof dims.topSpacing) dims.topSpacing = parseInt(dims.topSpacing(this.sidebar)) || 0;
- if ('function' === typeof dims.bottomSpacing) dims.bottomSpacing = parseInt(dims.bottomSpacing(this.sidebar)) || 0;
- }
- /**
- * Detarmine wheather the sidebar is bigger than viewport.
- * @public
- * @return {Boolean}
- */
- }, {
- key: 'isSidebarFitsViewport',
- value: function isSidebarFitsViewport() {
- return this.dimensions.sidebarHeight < this.dimensions.viewportHeight;
- }
- /**
- * Observe browser scrolling direction top and down.
- */
- }, {
- key: 'observeScrollDir',
- value: function observeScrollDir() {
- var dims = this.dimensions;
- if (dims.lastViewportTop === dims.viewportTop) return;
- var furthest = 'down' === this.direction ? Math.min : Math.max;
- // If the browser is scrolling not in the same direction.
- if (dims.viewportTop === furthest(dims.viewportTop, dims.lastViewportTop)) this.direction = 'down' === this.direction ? 'up' : 'down';
- }
- /**
- * Gets affix type of sidebar according to current scrollTop and scrollLeft.
- * Holds all logical affix of the sidebar when scrolling up and down and when sidebar
- * is bigger than viewport and vice versa.
- * @public
- * @return {String|False} - Proper affix type.
- */
- }, {
- key: 'getAffixType',
- value: function getAffixType() {
- var dims = this.dimensions,
- affixType = false;
- this._calcDimensionsWithScroll();
- var sidebarBottom = dims.sidebarHeight + dims.containerTop;
- var colliderTop = dims.viewportTop + dims.topSpacing;
- var colliderBottom = dims.viewportBottom - dims.bottomSpacing;
- // When browser is scrolling top.
- if ('up' === this.direction) {
- if (colliderTop <= dims.containerTop) {
- dims.translateY = 0;
- affixType = 'STATIC';
- } else if (colliderTop <= dims.translateY + dims.containerTop) {
- dims.translateY = colliderTop - dims.containerTop;
- affixType = 'VIEWPORT-TOP';
- } else if (!this.isSidebarFitsViewport() && dims.containerTop <= colliderTop) {
- affixType = 'VIEWPORT-UNBOTTOM';
- }
- // When browser is scrolling up.
- } else {
- // When sidebar element is not bigger than screen viewport.
- if (this.isSidebarFitsViewport()) {
- if (dims.sidebarHeight + colliderTop >= dims.containerBottom) {
- dims.translateY = dims.containerBottom - sidebarBottom;
- affixType = 'CONTAINER-BOTTOM';
- } else if (colliderTop >= dims.containerTop) {
- dims.translateY = colliderTop - dims.containerTop;
- affixType = 'VIEWPORT-TOP';
- }
- // When sidebar element is bigger than screen viewport.
- } else {
- if (dims.containerBottom <= colliderBottom) {
- dims.translateY = dims.containerBottom - sidebarBottom;
- affixType = 'CONTAINER-BOTTOM';
- } else if (sidebarBottom + dims.translateY <= colliderBottom) {
- dims.translateY = colliderBottom - sidebarBottom;
- affixType = 'VIEWPORT-BOTTOM';
- } else if (dims.containerTop + dims.translateY <= colliderTop) {
- affixType = 'VIEWPORT-UNBOTTOM';
- }
- }
- }
- // Make sure the translate Y is not bigger than container height.
- dims.translateY = Math.max(0, dims.translateY);
- dims.translateY = Math.min(dims.containerHeight, dims.translateY);
- dims.lastViewportTop = dims.viewportTop;
- return affixType;
- }
- /**
- * Gets inline style of sticky sidebar wrapper and inner wrapper according
- * to its affix type.
- * @private
- * @param {String} affixType - Affix type of sticky sidebar.
- * @return {Object}
- */
- }, {
- key: '_getStyle',
- value: function _getStyle(affixType) {
- if ('undefined' === typeof affixType) return;
- var style = { inner: {}, outer: {} };
- var dims = this.dimensions;
- switch (affixType) {
- case 'VIEWPORT-TOP':
- style.inner = { position: 'fixed', top: this.options.topSpacing,
- left: dims.sidebarLeft - dims.viewportLeft, width: dims.sidebarWidth };
- break;
- case 'VIEWPORT-BOTTOM':
- style.inner = { position: 'fixed', top: 'auto', left: dims.sidebarLeft,
- bottom: this.options.bottomSpacing, width: dims.sidebarWidth };
- break;
- case 'CONTAINER-BOTTOM':
- case 'VIEWPORT-UNBOTTOM':
- var translate = this._getTranslate(0, dims.translateY + 'px');
- if (translate) style.inner = { transform: translate };else style.inner = { position: 'absolute', top: dims.translateY, width: dims.sidebarWidth };
- break;
- }
- switch (affixType) {
- case 'VIEWPORT-TOP':
- case 'VIEWPORT-BOTTOM':
- case 'VIEWPORT-UNBOTTOM':
- case 'CONTAINER-BOTTOM':
- style.outer = { height: dims.sidebarHeight, position: 'relative' };
- break;
- }
- style.outer = StickySidebar.extend({ height: '', position: '' }, style.outer);
- style.inner = StickySidebar.extend({ position: 'relative', top: '', left: '',
- bottom: '', width: '', transform: this._getTranslate() }, style.inner);
- return style;
- }
- /**
- * Cause the sidebar to be sticky according to affix type by adding inline
- * style, adding helper class and trigger events.
- * @function
- * @protected
- * @param {string} force - Update sticky sidebar position by force.
- */
- }, {
- key: 'stickyPosition',
- value: function stickyPosition(force) {
- if (this._breakpoint) return;
- force = force || false;
- var affixType = this.getAffixType();
- var style = this._getStyle(affixType);
- if ((this.affixedType != affixType || force) && affixType) {
- var affixEvent = 'affix.' + affixType.toLowerCase().replace('viewport-', '') + EVENT_KEY;
- StickySidebar.eventTrigger(this.sidebar, affixEvent);
- if ('STATIC' === affixType) StickySidebar.removeClass(this.sidebar, this.options.stickyClass);else StickySidebar.addClass(this.sidebar, this.options.stickyClass);
- for (var key in style.outer) {
- this.sidebar.style[key] = style.outer[key];
- }
- for (var _key in style.inner) {
- var _unit2 = 'number' === typeof style.inner[_key] ? 'px' : '';
- this.sidebarInner.style[_key] = style.inner[_key] + _unit2;
- }
- var affixedEvent = 'affixed.' + affixType.toLowerCase().replace('viewport', '') + EVENT_KEY;
- StickySidebar.eventTrigger(this.sidebar, affixedEvent);
- } else {
- if (this._initialized) this.sidebarInner.style.left = style.inner.left;
- }
- this.affixedType = affixType;
- }
- /**
- * Breakdown sticky sidebar when window width is below `options.minWidth` value.
- * @protected
- */
- }, {
- key: '_widthBreakpoint',
- value: function _widthBreakpoint() {
- if (window.innerWidth <= this.options.minWidth) {
- this._breakpoint = true;
- this.affixedType = 'STATIC';
- this.sidebar.removeAttribute('style');
- StickySidebar.removeClass(this.sidebar, this.options.stickyClass);
- this.sidebarInner.removeAttribute('style');
- } else {
- this._breakpoint = false;
- }
- }
- /**
- * Switchs between functions stack for each event type, if there's no
- * event, it will re-initialize sticky sidebar.
- * @public
- */
- }, {
- key: 'updateSticky',
- value: function updateSticky() {
- var _this3 = this;
- var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- if (this._running) return;
- this._running = true;
- (function (eventType) {
- requestAnimationFrame(function () {
- switch (eventType) {
- // When browser is scrolling and re-calculate just dimensions
- // within scroll.
- case 'scroll':
- _this3._calcDimensionsWithScroll();
- _this3.observeScrollDir();
- _this3.stickyPosition();
- break;
- // When browser is resizing or there's no event, observe width
- // breakpoint and re-calculate dimensions.
- case 'resize':
- default:
- _this3._widthBreakpoint();
- _this3.calcDimensions();
- _this3.stickyPosition(true);
- break;
- }
- _this3._running = false;
- });
- })(event.type);
- }
- /**
- * Set browser support features to the public property.
- * @private
- */
- }, {
- key: '_setSupportFeatures',
- value: function _setSupportFeatures() {
- var support = this.support;
- support.transform = StickySidebar.supportTransform();
- support.transform3d = StickySidebar.supportTransform(true);
- }
- /**
- * Get translate value, if the browser supports transfrom3d, it will adopt it.
- * and the same with translate. if browser doesn't support both return false.
- * @param {Number} y - Value of Y-axis.
- * @param {Number} x - Value of X-axis.
- * @param {Number} z - Value of Z-axis.
- * @return {String|False}
- */
- }, {
- key: '_getTranslate',
- value: function _getTranslate() {
- var y = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
- var x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
- var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
- if (this.support.transform3d) return 'translate3d(' + y + ', ' + x + ', ' + z + ')';else if (this.support.translate) return 'translate(' + y + ', ' + x + ')';else return false;
- }
- /**
- * Destroy sticky sidebar plugin.
- * @public
- */
- }, {
- key: 'destroy',
- value: function destroy() {
- window.removeEventListener('resize', this);
- window.removeEventListener('scroll', this);
- this.sidebar.classList.remove(this.options.stickyClass);
- this.sidebar.style.minHeight = '';
- this.sidebar.removeEventListener('update' + EVENT_KEY, this);
- var styleReset = { inner: {}, outer: {} };
- styleReset.inner = { position: '', top: '', left: '', bottom: '', width: '', transform: '' };
- styleReset.outer = { height: '', position: '' };
- for (var key in styleReset.outer) {
- this.sidebar.style[key] = styleReset.outer[key];
- }for (var _key2 in styleReset.inner) {
- this.sidebarInner.style[_key2] = styleReset.inner[_key2];
- }if (this.options.resizeSensor && 'undefined' !== typeof ResizeSensor) {
- ResizeSensor.detach(this.sidebarInner, this.handleEvent);
- ResizeSensor.detach(this.container, this.handleEvent);
- }
- }
- /**
- * Detarmine if the browser supports CSS transfrom feature.
- * @function
- * @static
- * @param {Boolean} transform3d - Detect transform with translate3d.
- * @return {String}
- */
- }], [{
- key: 'supportTransform',
- value: function supportTransform(transform3d) {
- var result = false,
- property = transform3d ? 'perspective' : 'transform',
- upper = property.charAt(0).toUpperCase() + property.slice(1),
- prefixes = ['Webkit', 'Moz', 'O', 'ms'],
- support = document.createElement('support'),
- style = support.style;
- (property + ' ' + prefixes.join(upper + ' ') + upper).split(' ').forEach(function (property, i) {
- if (style[property] !== undefined) {
- result = property;
- return false;
- }
- });
- return result;
- }
- /**
- * Trigger custom event.
- * @static
- * @param {DOMObject} element - Target element on the DOM.
- * @param {String} eventName - Event name.
- * @param {Object} data -
- */
- }, {
- key: 'eventTrigger',
- value: function eventTrigger(element, eventName, data) {
- try {
- var event = new CustomEvent(eventName, { detail: data });
- } catch (e) {
- var event = document.createEvent('CustomEvent');
- event.initCustomEvent(eventName, true, true, data);
- }
- element.dispatchEvent(event);
- }
- /**
- * Extend options object with defaults.
- * @function
- * @static
- */
- }, {
- key: 'extend',
- value: function extend(defaults, options) {
- var results = {};
- for (var key in defaults) {
- if ('undefined' !== typeof options[key]) results[key] = options[key];else results[key] = defaults[key];
- }
- return results;
- }
- /**
- * Get current coordinates left and top of specific element.
- * @static
- */
- }, {
- key: 'offsetRelative',
- value: function offsetRelative(element) {
- var result = { left: 0, top: 0 };
- do {
- var offsetTop = element.offsetTop;
- var offsetLeft = element.offsetLeft;
- if (!isNaN(offsetTop)) result.top += offsetTop;
- if (!isNaN(offsetLeft)) result.left += offsetLeft;
- } while (element = element.offsetParent);
- return result;
- }
- /**
- * Add specific class name to specific element.
- * @static
- * @param {ObjectDOM} element
- * @param {String} className
- */
- }, {
- key: 'addClass',
- value: function addClass(element, className) {
- if (!StickySidebar.hasClass(element, className)) {
- if (element.classList) element.classList.add(className);else element.className += ' ' + className;
- }
- }
- /**
- * Remove specific class name to specific element
- * @static
- * @param {ObjectDOM} element
- * @param {String} className
- */
- }, {
- key: 'removeClass',
- value: function removeClass(element, className) {
- if (StickySidebar.hasClass(element, className)) {
- if (element.classList) element.classList.remove(className);else element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
- }
- }
- /**
- * Detarmine weather the element has specific class name.
- * @static
- * @param {ObjectDOM} element
- * @param {String} className
- */
- }, {
- key: 'hasClass',
- value: function hasClass(element, className) {
- if (element.classList) return element.classList.contains(className);else return new RegExp('(^| )' + className + '( |$)', 'gi').test(element.className);
- }
- }]);
- return StickySidebar;
- }();
- return StickySidebar;
- }();
- // Global
- // -------------------------
- window.StickySidebar = StickySidebar;
- return StickySidebar;
- });
- //# sourceMappingURL=sticky-sidebar.js.map
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- /*! tether 1.4.0 */
- (function (root, factory) {
- if (true) {
- !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
- __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
- module.exports = factory(require, exports, module);
- } else {
- root.Tether = factory();
- }
- })(undefined, function (require, exports, module) {
- 'use strict';
- 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;
- };
- }();
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError('Cannot call a class as a function');
- }
- }
- var TetherBase = undefined;
- if (typeof TetherBase === 'undefined') {
- TetherBase = { modules: [] };
- }
- var zeroElement = null;
- // Same as native getBoundingClientRect, except it takes into account parent <frame> offsets
- // if the element lies within a nested document (<frame> or <iframe>-like).
- function getActualBoundingClientRect(node) {
- var boundingRect = node.getBoundingClientRect();
- // The original object returned by getBoundingClientRect is immutable, so we clone it
- // We can't use extend because the properties are not considered part of the object by hasOwnProperty in IE9
- var rect = {};
- for (var k in boundingRect) {
- rect[k] = boundingRect[k];
- }
- if (node.ownerDocument !== document) {
- var _frameElement = node.ownerDocument.defaultView.frameElement;
- if (_frameElement) {
- var frameRect = getActualBoundingClientRect(_frameElement);
- rect.top += frameRect.top;
- rect.bottom += frameRect.top;
- rect.left += frameRect.left;
- rect.right += frameRect.left;
- }
- }
- return rect;
- }
- function getScrollParents(el) {
- // In firefox if the el is inside an iframe with display: none; window.getComputedStyle() will return null;
- // https://bugzilla.mozilla.org/show_bug.cgi?id=548397
- var computedStyle = getComputedStyle(el) || {};
- var position = computedStyle.position;
- var parents = [];
- if (position === 'fixed') {
- return [el];
- }
- var parent = el;
- while ((parent = parent.parentNode) && parent && parent.nodeType === 1) {
- var style = undefined;
- try {
- style = getComputedStyle(parent);
- } catch (err) {}
- if (typeof style === 'undefined' || style === null) {
- parents.push(parent);
- return parents;
- }
- var _style = style;
- var overflow = _style.overflow;
- var overflowX = _style.overflowX;
- var overflowY = _style.overflowY;
- if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {
- if (position !== 'absolute' || ['relative', 'absolute', 'fixed'].indexOf(style.position) >= 0) {
- parents.push(parent);
- }
- }
- }
- parents.push(el.ownerDocument.body);
- // If the node is within a frame, account for the parent window scroll
- if (el.ownerDocument !== document) {
- parents.push(el.ownerDocument.defaultView);
- }
- return parents;
- }
- var uniqueId = function () {
- var id = 0;
- return function () {
- return ++id;
- };
- }();
- var zeroPosCache = {};
- var getOrigin = function getOrigin() {
- // getBoundingClientRect is unfortunately too accurate. It introduces a pixel or two of
- // jitter as the user scrolls that messes with our ability to detect if two positions
- // are equivilant or not. We place an element at the top left of the page that will
- // get the same jitter, so we can cancel the two out.
- var node = zeroElement;
- if (!node || !document.body.contains(node)) {
- node = document.createElement('div');
- node.setAttribute('data-tether-id', uniqueId());
- extend(node.style, {
- top: 0,
- left: 0,
- position: 'absolute'
- });
- document.body.appendChild(node);
- zeroElement = node;
- }
- var id = node.getAttribute('data-tether-id');
- if (typeof zeroPosCache[id] === 'undefined') {
- zeroPosCache[id] = getActualBoundingClientRect(node);
- // Clear the cache when this position call is done
- defer(function () {
- delete zeroPosCache[id];
- });
- }
- return zeroPosCache[id];
- };
- function removeUtilElements() {
- if (zeroElement) {
- document.body.removeChild(zeroElement);
- }
- zeroElement = null;
- };
- function getBounds(el) {
- var doc = undefined;
- if (el === document) {
- doc = document;
- el = document.documentElement;
- } else {
- doc = el.ownerDocument;
- }
- var docEl = doc.documentElement;
- var box = getActualBoundingClientRect(el);
- var origin = getOrigin();
- box.top -= origin.top;
- box.left -= origin.left;
- if (typeof box.width === 'undefined') {
- box.width = document.body.scrollWidth - box.left - box.right;
- }
- if (typeof box.height === 'undefined') {
- box.height = document.body.scrollHeight - box.top - box.bottom;
- }
- box.top = box.top - docEl.clientTop;
- box.left = box.left - docEl.clientLeft;
- box.right = doc.body.clientWidth - box.width - box.left;
- box.bottom = doc.body.clientHeight - box.height - box.top;
- return box;
- }
- function getOffsetParent(el) {
- return el.offsetParent || document.documentElement;
- }
- var _scrollBarSize = null;
- function getScrollBarSize() {
- if (_scrollBarSize) {
- return _scrollBarSize;
- }
- var inner = document.createElement('div');
- inner.style.width = '100%';
- inner.style.height = '200px';
- var outer = document.createElement('div');
- extend(outer.style, {
- position: 'absolute',
- top: 0,
- left: 0,
- pointerEvents: 'none',
- visibility: 'hidden',
- width: '200px',
- height: '150px',
- overflow: 'hidden'
- });
- outer.appendChild(inner);
- document.body.appendChild(outer);
- var widthContained = inner.offsetWidth;
- outer.style.overflow = 'scroll';
- var widthScroll = inner.offsetWidth;
- if (widthContained === widthScroll) {
- widthScroll = outer.clientWidth;
- }
- document.body.removeChild(outer);
- var width = widthContained - widthScroll;
- _scrollBarSize = { width: width, height: width };
- return _scrollBarSize;
- }
- function extend() {
- var out = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
- var args = [];
- Array.prototype.push.apply(args, arguments);
- args.slice(1).forEach(function (obj) {
- if (obj) {
- for (var key in obj) {
- if ({}.hasOwnProperty.call(obj, key)) {
- out[key] = obj[key];
- }
- }
- }
- });
- return out;
- }
- function removeClass(el, name) {
- if (typeof el.classList !== 'undefined') {
- name.split(' ').forEach(function (cls) {
- if (cls.trim()) {
- el.classList.remove(cls);
- }
- });
- } else {
- var regex = new RegExp('(^| )' + name.split(' ').join('|') + '( |$)', 'gi');
- var className = getClassName(el).replace(regex, ' ');
- setClassName(el, className);
- }
- }
- function addClass(el, name) {
- if (typeof el.classList !== 'undefined') {
- name.split(' ').forEach(function (cls) {
- if (cls.trim()) {
- el.classList.add(cls);
- }
- });
- } else {
- removeClass(el, name);
- var cls = getClassName(el) + (' ' + name);
- setClassName(el, cls);
- }
- }
- function hasClass(el, name) {
- if (typeof el.classList !== 'undefined') {
- return el.classList.contains(name);
- }
- var className = getClassName(el);
- return new RegExp('(^| )' + name + '( |$)', 'gi').test(className);
- }
- function getClassName(el) {
- // Can't use just SVGAnimatedString here since nodes within a Frame in IE have
- // completely separately SVGAnimatedString base classes
- if (el.className instanceof el.ownerDocument.defaultView.SVGAnimatedString) {
- return el.className.baseVal;
- }
- return el.className;
- }
- function setClassName(el, className) {
- el.setAttribute('class', className);
- }
- function updateClasses(el, add, all) {
- // Of the set of 'all' classes, we need the 'add' classes, and only the
- // 'add' classes to be set.
- all.forEach(function (cls) {
- if (add.indexOf(cls) === -1 && hasClass(el, cls)) {
- removeClass(el, cls);
- }
- });
- add.forEach(function (cls) {
- if (!hasClass(el, cls)) {
- addClass(el, cls);
- }
- });
- }
- var deferred = [];
- var defer = function defer(fn) {
- deferred.push(fn);
- };
- var flush = function flush() {
- var fn = undefined;
- while (fn = deferred.pop()) {
- fn();
- }
- };
- var Evented = function () {
- function Evented() {
- _classCallCheck(this, Evented);
- }
- _createClass(Evented, [{
- key: 'on',
- value: function on(event, handler, ctx) {
- var once = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
- if (typeof this.bindings === 'undefined') {
- this.bindings = {};
- }
- if (typeof this.bindings[event] === 'undefined') {
- this.bindings[event] = [];
- }
- this.bindings[event].push({ handler: handler, ctx: ctx, once: once });
- }
- }, {
- key: 'once',
- value: function once(event, handler, ctx) {
- this.on(event, handler, ctx, true);
- }
- }, {
- key: 'off',
- value: function off(event, handler) {
- if (typeof this.bindings === 'undefined' || typeof this.bindings[event] === 'undefined') {
- return;
- }
- if (typeof handler === 'undefined') {
- delete this.bindings[event];
- } else {
- var i = 0;
- while (i < this.bindings[event].length) {
- if (this.bindings[event][i].handler === handler) {
- this.bindings[event].splice(i, 1);
- } else {
- ++i;
- }
- }
- }
- }
- }, {
- key: 'trigger',
- value: function trigger(event) {
- if (typeof this.bindings !== 'undefined' && this.bindings[event]) {
- var i = 0;
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
- while (i < this.bindings[event].length) {
- var _bindings$event$i = this.bindings[event][i];
- var handler = _bindings$event$i.handler;
- var ctx = _bindings$event$i.ctx;
- var once = _bindings$event$i.once;
- var context = ctx;
- if (typeof context === 'undefined') {
- context = this;
- }
- handler.apply(context, args);
- if (once) {
- this.bindings[event].splice(i, 1);
- } else {
- ++i;
- }
- }
- }
- }
- }]);
- return Evented;
- }();
- TetherBase.Utils = {
- getActualBoundingClientRect: getActualBoundingClientRect,
- getScrollParents: getScrollParents,
- getBounds: getBounds,
- getOffsetParent: getOffsetParent,
- extend: extend,
- addClass: addClass,
- removeClass: removeClass,
- hasClass: hasClass,
- updateClasses: updateClasses,
- defer: defer,
- flush: flush,
- uniqueId: uniqueId,
- Evented: Evented,
- getScrollBarSize: getScrollBarSize,
- removeUtilElements: removeUtilElements
- };
- /* globals TetherBase, performance */
- 'use strict';
- var _slicedToArray = function () {
- function sliceIterator(arr, i) {
- var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
- _arr.push(_s.value);if (i && _arr.length === i) break;
- }
- } catch (err) {
- _d = true;_e = err;
- } finally {
- try {
- if (!_n && _i['return']) _i['return']();
- } finally {
- if (_d) throw _e;
- }
- }return _arr;
- }return function (arr, i) {
- if (Array.isArray(arr)) {
- return arr;
- } else if (Symbol.iterator in Object(arr)) {
- return sliceIterator(arr, i);
- } else {
- throw new TypeError('Invalid attempt to destructure non-iterable instance');
- }
- };
- }();
- 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;
- };
- }();
- var _get = function get(_x6, _x7, _x8) {
- var _again = true;_function: while (_again) {
- var object = _x6,
- property = _x7,
- receiver = _x8;_again = false;if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) {
- var parent = Object.getPrototypeOf(object);if (parent === null) {
- return undefined;
- } else {
- _x6 = parent;_x7 = property;_x8 = receiver;_again = true;desc = parent = undefined;continue _function;
- }
- } else if ('value' in desc) {
- return desc.value;
- } else {
- var getter = desc.get;if (getter === undefined) {
- return undefined;
- }return getter.call(receiver);
- }
- }
- };
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError('Cannot call a class as a function');
- }
- }
- function _inherits(subClass, superClass) {
- if (typeof superClass !== 'function' && superClass !== null) {
- throw new TypeError('Super expression must either be null or a function, not ' + (typeof superClass === 'undefined' ? 'undefined' : _typeof(superClass)));
- }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
- if (typeof TetherBase === 'undefined') {
- throw new Error('You must include the utils.js file before tether.js');
- }
- var _TetherBase$Utils = TetherBase.Utils;
- var getScrollParents = _TetherBase$Utils.getScrollParents;
- var getBounds = _TetherBase$Utils.getBounds;
- var getOffsetParent = _TetherBase$Utils.getOffsetParent;
- var extend = _TetherBase$Utils.extend;
- var addClass = _TetherBase$Utils.addClass;
- var removeClass = _TetherBase$Utils.removeClass;
- var updateClasses = _TetherBase$Utils.updateClasses;
- var defer = _TetherBase$Utils.defer;
- var flush = _TetherBase$Utils.flush;
- var getScrollBarSize = _TetherBase$Utils.getScrollBarSize;
- var removeUtilElements = _TetherBase$Utils.removeUtilElements;
- function within(a, b) {
- var diff = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];
- return a + diff >= b && b >= a - diff;
- }
- var transformKey = function () {
- if (typeof document === 'undefined') {
- return '';
- }
- var el = document.createElement('div');
- var transforms = ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform'];
- for (var i = 0; i < transforms.length; ++i) {
- var key = transforms[i];
- if (el.style[key] !== undefined) {
- return key;
- }
- }
- }();
- var tethers = [];
- var position = function position() {
- tethers.forEach(function (tether) {
- tether.position(false);
- });
- flush();
- };
- function now() {
- if (typeof performance !== 'undefined' && typeof performance.now !== 'undefined') {
- return performance.now();
- }
- return +new Date();
- }
- (function () {
- var lastCall = null;
- var lastDuration = null;
- var pendingTimeout = null;
- var tick = function tick() {
- if (typeof lastDuration !== 'undefined' && lastDuration > 16) {
- // We voluntarily throttle ourselves if we can't manage 60fps
- lastDuration = Math.min(lastDuration - 16, 250);
- // Just in case this is the last event, remember to position just once more
- pendingTimeout = setTimeout(tick, 250);
- return;
- }
- if (typeof lastCall !== 'undefined' && now() - lastCall < 10) {
- // Some browsers call events a little too frequently, refuse to run more than is reasonable
- return;
- }
- if (pendingTimeout != null) {
- clearTimeout(pendingTimeout);
- pendingTimeout = null;
- }
- lastCall = now();
- position();
- lastDuration = now() - lastCall;
- };
- if (typeof window !== 'undefined' && typeof window.addEventListener !== 'undefined') {
- ['resize', 'scroll', 'touchmove'].forEach(function (event) {
- window.addEventListener(event, tick);
- });
- }
- })();
- var MIRROR_LR = {
- center: 'center',
- left: 'right',
- right: 'left'
- };
- var MIRROR_TB = {
- middle: 'middle',
- top: 'bottom',
- bottom: 'top'
- };
- var OFFSET_MAP = {
- top: 0,
- left: 0,
- middle: '50%',
- center: '50%',
- bottom: '100%',
- right: '100%'
- };
- var autoToFixedAttachment = function autoToFixedAttachment(attachment, relativeToAttachment) {
- var left = attachment.left;
- var top = attachment.top;
- if (left === 'auto') {
- left = MIRROR_LR[relativeToAttachment.left];
- }
- if (top === 'auto') {
- top = MIRROR_TB[relativeToAttachment.top];
- }
- return { left: left, top: top };
- };
- var attachmentToOffset = function attachmentToOffset(attachment) {
- var left = attachment.left;
- var top = attachment.top;
- if (typeof OFFSET_MAP[attachment.left] !== 'undefined') {
- left = OFFSET_MAP[attachment.left];
- }
- if (typeof OFFSET_MAP[attachment.top] !== 'undefined') {
- top = OFFSET_MAP[attachment.top];
- }
- return { left: left, top: top };
- };
- function addOffset() {
- var out = { top: 0, left: 0 };
- for (var _len = arguments.length, offsets = Array(_len), _key = 0; _key < _len; _key++) {
- offsets[_key] = arguments[_key];
- }
- offsets.forEach(function (_ref) {
- var top = _ref.top;
- var left = _ref.left;
- if (typeof top === 'string') {
- top = parseFloat(top, 10);
- }
- if (typeof left === 'string') {
- left = parseFloat(left, 10);
- }
- out.top += top;
- out.left += left;
- });
- return out;
- }
- function offsetToPx(offset, size) {
- if (typeof offset.left === 'string' && offset.left.indexOf('%') !== -1) {
- offset.left = parseFloat(offset.left, 10) / 100 * size.width;
- }
- if (typeof offset.top === 'string' && offset.top.indexOf('%') !== -1) {
- offset.top = parseFloat(offset.top, 10) / 100 * size.height;
- }
- return offset;
- }
- var parseOffset = function parseOffset(value) {
- var _value$split = value.split(' ');
- var _value$split2 = _slicedToArray(_value$split, 2);
- var top = _value$split2[0];
- var left = _value$split2[1];
- return { top: top, left: left };
- };
- var parseAttachment = parseOffset;
- var TetherClass = function (_Evented) {
- _inherits(TetherClass, _Evented);
- function TetherClass(options) {
- var _this = this;
- _classCallCheck(this, TetherClass);
- _get(Object.getPrototypeOf(TetherClass.prototype), 'constructor', this).call(this);
- this.position = this.position.bind(this);
- tethers.push(this);
- this.history = [];
- this.setOptions(options, false);
- TetherBase.modules.forEach(function (module) {
- if (typeof module.initialize !== 'undefined') {
- module.initialize.call(_this);
- }
- });
- this.position();
- }
- _createClass(TetherClass, [{
- key: 'getClass',
- value: function getClass() {
- var key = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
- var classes = this.options.classes;
- if (typeof classes !== 'undefined' && classes[key]) {
- return this.options.classes[key];
- } else if (this.options.classPrefix) {
- return this.options.classPrefix + '-' + key;
- } else {
- return key;
- }
- }
- }, {
- key: 'setOptions',
- value: function setOptions(options) {
- var _this2 = this;
- var pos = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
- var defaults = {
- offset: '0 0',
- targetOffset: '0 0',
- targetAttachment: 'auto auto',
- classPrefix: 'tether'
- };
- this.options = extend(defaults, options);
- var _options = this.options;
- var element = _options.element;
- var target = _options.target;
- var targetModifier = _options.targetModifier;
- this.element = element;
- this.target = target;
- this.targetModifier = targetModifier;
- if (this.target === 'viewport') {
- this.target = document.body;
- this.targetModifier = 'visible';
- } else if (this.target === 'scroll-handle') {
- this.target = document.body;
- this.targetModifier = 'scroll-handle';
- }
- ['element', 'target'].forEach(function (key) {
- if (typeof _this2[key] === 'undefined') {
- throw new Error('Tether Error: Both element and target must be defined');
- }
- if (typeof _this2[key].jquery !== 'undefined') {
- _this2[key] = _this2[key][0];
- } else if (typeof _this2[key] === 'string') {
- _this2[key] = document.querySelector(_this2[key]);
- }
- });
- addClass(this.element, this.getClass('element'));
- if (!(this.options.addTargetClasses === false)) {
- addClass(this.target, this.getClass('target'));
- }
- if (!this.options.attachment) {
- throw new Error('Tether Error: You must provide an attachment');
- }
- this.targetAttachment = parseAttachment(this.options.targetAttachment);
- this.attachment = parseAttachment(this.options.attachment);
- this.offset = parseOffset(this.options.offset);
- this.targetOffset = parseOffset(this.options.targetOffset);
- if (typeof this.scrollParents !== 'undefined') {
- this.disable();
- }
- if (this.targetModifier === 'scroll-handle') {
- this.scrollParents = [this.target];
- } else {
- this.scrollParents = getScrollParents(this.target);
- }
- if (!(this.options.enabled === false)) {
- this.enable(pos);
- }
- }
- }, {
- key: 'getTargetBounds',
- value: function getTargetBounds() {
- if (typeof this.targetModifier !== 'undefined') {
- if (this.targetModifier === 'visible') {
- if (this.target === document.body) {
- return { top: pageYOffset, left: pageXOffset, height: innerHeight, width: innerWidth };
- } else {
- var bounds = getBounds(this.target);
- var out = {
- height: bounds.height,
- width: bounds.width,
- top: bounds.top,
- left: bounds.left
- };
- out.height = Math.min(out.height, bounds.height - (pageYOffset - bounds.top));
- out.height = Math.min(out.height, bounds.height - (bounds.top + bounds.height - (pageYOffset + innerHeight)));
- out.height = Math.min(innerHeight, out.height);
- out.height -= 2;
- out.width = Math.min(out.width, bounds.width - (pageXOffset - bounds.left));
- out.width = Math.min(out.width, bounds.width - (bounds.left + bounds.width - (pageXOffset + innerWidth)));
- out.width = Math.min(innerWidth, out.width);
- out.width -= 2;
- if (out.top < pageYOffset) {
- out.top = pageYOffset;
- }
- if (out.left < pageXOffset) {
- out.left = pageXOffset;
- }
- return out;
- }
- } else if (this.targetModifier === 'scroll-handle') {
- var bounds = undefined;
- var target = this.target;
- if (target === document.body) {
- target = document.documentElement;
- bounds = {
- left: pageXOffset,
- top: pageYOffset,
- height: innerHeight,
- width: innerWidth
- };
- } else {
- bounds = getBounds(target);
- }
- var style = getComputedStyle(target);
- var hasBottomScroll = target.scrollWidth > target.clientWidth || [style.overflow, style.overflowX].indexOf('scroll') >= 0 || this.target !== document.body;
- var scrollBottom = 0;
- if (hasBottomScroll) {
- scrollBottom = 15;
- }
- var height = bounds.height - parseFloat(style.borderTopWidth) - parseFloat(style.borderBottomWidth) - scrollBottom;
- var out = {
- width: 15,
- height: height * 0.975 * (height / target.scrollHeight),
- left: bounds.left + bounds.width - parseFloat(style.borderLeftWidth) - 15
- };
- var fitAdj = 0;
- if (height < 408 && this.target === document.body) {
- fitAdj = -0.00011 * Math.pow(height, 2) - 0.00727 * height + 22.58;
- }
- if (this.target !== document.body) {
- out.height = Math.max(out.height, 24);
- }
- var scrollPercentage = this.target.scrollTop / (target.scrollHeight - height);
- out.top = scrollPercentage * (height - out.height - fitAdj) + bounds.top + parseFloat(style.borderTopWidth);
- if (this.target === document.body) {
- out.height = Math.max(out.height, 24);
- }
- return out;
- }
- } else {
- return getBounds(this.target);
- }
- }
- }, {
- key: 'clearCache',
- value: function clearCache() {
- this._cache = {};
- }
- }, {
- key: 'cache',
- value: function cache(k, getter) {
- // More than one module will often need the same DOM info, so
- // we keep a cache which is cleared on each position call
- if (typeof this._cache === 'undefined') {
- this._cache = {};
- }
- if (typeof this._cache[k] === 'undefined') {
- this._cache[k] = getter.call(this);
- }
- return this._cache[k];
- }
- }, {
- key: 'enable',
- value: function enable() {
- var _this3 = this;
- var pos = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
- if (!(this.options.addTargetClasses === false)) {
- addClass(this.target, this.getClass('enabled'));
- }
- addClass(this.element, this.getClass('enabled'));
- this.enabled = true;
- this.scrollParents.forEach(function (parent) {
- if (parent !== _this3.target.ownerDocument) {
- parent.addEventListener('scroll', _this3.position);
- }
- });
- if (pos) {
- this.position();
- }
- }
- }, {
- key: 'disable',
- value: function disable() {
- var _this4 = this;
- removeClass(this.target, this.getClass('enabled'));
- removeClass(this.element, this.getClass('enabled'));
- this.enabled = false;
- if (typeof this.scrollParents !== 'undefined') {
- this.scrollParents.forEach(function (parent) {
- parent.removeEventListener('scroll', _this4.position);
- });
- }
- }
- }, {
- key: 'destroy',
- value: function destroy() {
- var _this5 = this;
- this.disable();
- tethers.forEach(function (tether, i) {
- if (tether === _this5) {
- tethers.splice(i, 1);
- }
- });
- // Remove any elements we were using for convenience from the DOM
- if (tethers.length === 0) {
- removeUtilElements();
- }
- }
- }, {
- key: 'updateAttachClasses',
- value: function updateAttachClasses(elementAttach, targetAttach) {
- var _this6 = this;
- elementAttach = elementAttach || this.attachment;
- targetAttach = targetAttach || this.targetAttachment;
- var sides = ['left', 'top', 'bottom', 'right', 'middle', 'center'];
- if (typeof this._addAttachClasses !== 'undefined' && this._addAttachClasses.length) {
- // updateAttachClasses can be called more than once in a position call, so
- // we need to clean up after ourselves such that when the last defer gets
- // ran it doesn't add any extra classes from previous calls.
- this._addAttachClasses.splice(0, this._addAttachClasses.length);
- }
- if (typeof this._addAttachClasses === 'undefined') {
- this._addAttachClasses = [];
- }
- var add = this._addAttachClasses;
- if (elementAttach.top) {
- add.push(this.getClass('element-attached') + '-' + elementAttach.top);
- }
- if (elementAttach.left) {
- add.push(this.getClass('element-attached') + '-' + elementAttach.left);
- }
- if (targetAttach.top) {
- add.push(this.getClass('target-attached') + '-' + targetAttach.top);
- }
- if (targetAttach.left) {
- add.push(this.getClass('target-attached') + '-' + targetAttach.left);
- }
- var all = [];
- sides.forEach(function (side) {
- all.push(_this6.getClass('element-attached') + '-' + side);
- all.push(_this6.getClass('target-attached') + '-' + side);
- });
- defer(function () {
- if (!(typeof _this6._addAttachClasses !== 'undefined')) {
- return;
- }
- updateClasses(_this6.element, _this6._addAttachClasses, all);
- if (!(_this6.options.addTargetClasses === false)) {
- updateClasses(_this6.target, _this6._addAttachClasses, all);
- }
- delete _this6._addAttachClasses;
- });
- }
- }, {
- key: 'position',
- value: function position() {
- var _this7 = this;
- var flushChanges = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
- // flushChanges commits the changes immediately, leave true unless you are positioning multiple
- // tethers (in which case call Tether.Utils.flush yourself when you're done)
- if (!this.enabled) {
- return;
- }
- this.clearCache();
- // Turn 'auto' attachments into the appropriate corner or edge
- var targetAttachment = autoToFixedAttachment(this.targetAttachment, this.attachment);
- this.updateAttachClasses(this.attachment, targetAttachment);
- var elementPos = this.cache('element-bounds', function () {
- return getBounds(_this7.element);
- });
- var width = elementPos.width;
- var height = elementPos.height;
- if (width === 0 && height === 0 && typeof this.lastSize !== 'undefined') {
- var _lastSize = this.lastSize;
- // We cache the height and width to make it possible to position elements that are
- // getting hidden.
- width = _lastSize.width;
- height = _lastSize.height;
- } else {
- this.lastSize = { width: width, height: height };
- }
- var targetPos = this.cache('target-bounds', function () {
- return _this7.getTargetBounds();
- });
- var targetSize = targetPos;
- // Get an actual px offset from the attachment
- var offset = offsetToPx(attachmentToOffset(this.attachment), { width: width, height: height });
- var targetOffset = offsetToPx(attachmentToOffset(targetAttachment), targetSize);
- var manualOffset = offsetToPx(this.offset, { width: width, height: height });
- var manualTargetOffset = offsetToPx(this.targetOffset, targetSize);
- // Add the manually provided offset
- offset = addOffset(offset, manualOffset);
- targetOffset = addOffset(targetOffset, manualTargetOffset);
- // It's now our goal to make (element position + offset) == (target position + target offset)
- var left = targetPos.left + targetOffset.left - offset.left;
- var top = targetPos.top + targetOffset.top - offset.top;
- for (var i = 0; i < TetherBase.modules.length; ++i) {
- var _module2 = TetherBase.modules[i];
- var ret = _module2.position.call(this, {
- left: left,
- top: top,
- targetAttachment: targetAttachment,
- targetPos: targetPos,
- elementPos: elementPos,
- offset: offset,
- targetOffset: targetOffset,
- manualOffset: manualOffset,
- manualTargetOffset: manualTargetOffset,
- scrollbarSize: scrollbarSize,
- attachment: this.attachment
- });
- if (ret === false) {
- return false;
- } else if (typeof ret === 'undefined' || (typeof ret === 'undefined' ? 'undefined' : _typeof(ret)) !== 'object') {
- continue;
- } else {
- top = ret.top;
- left = ret.left;
- }
- }
- // We describe the position three different ways to give the optimizer
- // a chance to decide the best possible way to position the element
- // with the fewest repaints.
- var next = {
- // It's position relative to the page (absolute positioning when
- // the element is a child of the body)
- page: {
- top: top,
- left: left
- },
- // It's position relative to the viewport (fixed positioning)
- viewport: {
- top: top - pageYOffset,
- bottom: pageYOffset - top - height + innerHeight,
- left: left - pageXOffset,
- right: pageXOffset - left - width + innerWidth
- }
- };
- var doc = this.target.ownerDocument;
- var win = doc.defaultView;
- var scrollbarSize = undefined;
- if (win.innerHeight > doc.documentElement.clientHeight) {
- scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
- next.viewport.bottom -= scrollbarSize.height;
- }
- if (win.innerWidth > doc.documentElement.clientWidth) {
- scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
- next.viewport.right -= scrollbarSize.width;
- }
- if (['', 'static'].indexOf(doc.body.style.position) === -1 || ['', 'static'].indexOf(doc.body.parentElement.style.position) === -1) {
- // Absolute positioning in the body will be relative to the page, not the 'initial containing block'
- next.page.bottom = doc.body.scrollHeight - top - height;
- next.page.right = doc.body.scrollWidth - left - width;
- }
- if (typeof this.options.optimizations !== 'undefined' && this.options.optimizations.moveElement !== false && !(typeof this.targetModifier !== 'undefined')) {
- (function () {
- var offsetParent = _this7.cache('target-offsetparent', function () {
- return getOffsetParent(_this7.target);
- });
- var offsetPosition = _this7.cache('target-offsetparent-bounds', function () {
- return getBounds(offsetParent);
- });
- var offsetParentStyle = getComputedStyle(offsetParent);
- var offsetParentSize = offsetPosition;
- var offsetBorder = {};
- ['Top', 'Left', 'Bottom', 'Right'].forEach(function (side) {
- offsetBorder[side.toLowerCase()] = parseFloat(offsetParentStyle['border' + side + 'Width']);
- });
- offsetPosition.right = doc.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right;
- offsetPosition.bottom = doc.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom;
- if (next.page.top >= offsetPosition.top + offsetBorder.top && next.page.bottom >= offsetPosition.bottom) {
- if (next.page.left >= offsetPosition.left + offsetBorder.left && next.page.right >= offsetPosition.right) {
- // We're within the visible part of the target's scroll parent
- var scrollTop = offsetParent.scrollTop;
- var scrollLeft = offsetParent.scrollLeft;
- // It's position relative to the target's offset parent (absolute positioning when
- // the element is moved to be a child of the target's offset parent).
- next.offset = {
- top: next.page.top - offsetPosition.top + scrollTop - offsetBorder.top,
- left: next.page.left - offsetPosition.left + scrollLeft - offsetBorder.left
- };
- }
- }
- })();
- }
- // We could also travel up the DOM and try each containing context, rather than only
- // looking at the body, but we're gonna get diminishing returns.
- this.move(next);
- this.history.unshift(next);
- if (this.history.length > 3) {
- this.history.pop();
- }
- if (flushChanges) {
- flush();
- }
- return true;
- }
- // THE ISSUE
- }, {
- key: 'move',
- value: function move(pos) {
- var _this8 = this;
- if (!(typeof this.element.parentNode !== 'undefined')) {
- return;
- }
- var same = {};
- for (var type in pos) {
- same[type] = {};
- for (var key in pos[type]) {
- var found = false;
- for (var i = 0; i < this.history.length; ++i) {
- var point = this.history[i];
- if (typeof point[type] !== 'undefined' && !within(point[type][key], pos[type][key])) {
- found = true;
- break;
- }
- }
- if (!found) {
- same[type][key] = true;
- }
- }
- }
- var css = { top: '', left: '', right: '', bottom: '' };
- var transcribe = function transcribe(_same, _pos) {
- var hasOptimizations = typeof _this8.options.optimizations !== 'undefined';
- var gpu = hasOptimizations ? _this8.options.optimizations.gpu : null;
- if (gpu !== false) {
- var yPos = undefined,
- xPos = undefined;
- if (_same.top) {
- css.top = 0;
- yPos = _pos.top;
- } else {
- css.bottom = 0;
- yPos = -_pos.bottom;
- }
- if (_same.left) {
- css.left = 0;
- xPos = _pos.left;
- } else {
- css.right = 0;
- xPos = -_pos.right;
- }
- if (window.matchMedia) {
- // HubSpot/tether#207
- var retina = window.matchMedia('only screen and (min-resolution: 1.3dppx)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3)').matches;
- if (!retina) {
- xPos = Math.round(xPos);
- yPos = Math.round(yPos);
- }
- }
- css[transformKey] = 'translateX(' + xPos + 'px) translateY(' + yPos + 'px)';
- if (transformKey !== 'msTransform') {
- // The Z transform will keep this in the GPU (faster, and prevents artifacts),
- // but IE9 doesn't support 3d transforms and will choke.
- css[transformKey] += " translateZ(0)";
- }
- } else {
- if (_same.top) {
- css.top = _pos.top + 'px';
- } else {
- css.bottom = _pos.bottom + 'px';
- }
- if (_same.left) {
- css.left = _pos.left + 'px';
- } else {
- css.right = _pos.right + 'px';
- }
- }
- };
- var moved = false;
- if ((same.page.top || same.page.bottom) && (same.page.left || same.page.right)) {
- css.position = 'absolute';
- transcribe(same.page, pos.page);
- } else if ((same.viewport.top || same.viewport.bottom) && (same.viewport.left || same.viewport.right)) {
- css.position = 'fixed';
- transcribe(same.viewport, pos.viewport);
- } else if (typeof same.offset !== 'undefined' && same.offset.top && same.offset.left) {
- (function () {
- css.position = 'absolute';
- var offsetParent = _this8.cache('target-offsetparent', function () {
- return getOffsetParent(_this8.target);
- });
- if (getOffsetParent(_this8.element) !== offsetParent) {
- defer(function () {
- _this8.element.parentNode.removeChild(_this8.element);
- offsetParent.appendChild(_this8.element);
- });
- }
- transcribe(same.offset, pos.offset);
- moved = true;
- })();
- } else {
- css.position = 'absolute';
- transcribe({ top: true, left: true }, pos.page);
- }
- if (!moved) {
- if (this.options.bodyElement) {
- this.options.bodyElement.appendChild(this.element);
- } else {
- var offsetParentIsBody = true;
- var currentNode = this.element.parentNode;
- while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') {
- if (getComputedStyle(currentNode).position !== 'static') {
- offsetParentIsBody = false;
- break;
- }
- currentNode = currentNode.parentNode;
- }
- if (!offsetParentIsBody) {
- this.element.parentNode.removeChild(this.element);
- this.element.ownerDocument.body.appendChild(this.element);
- }
- }
- }
- // Any css change will trigger a repaint, so let's avoid one if nothing changed
- var writeCSS = {};
- var write = false;
- for (var key in css) {
- var val = css[key];
- var elVal = this.element.style[key];
- if (elVal !== val) {
- write = true;
- writeCSS[key] = val;
- }
- }
- if (write) {
- defer(function () {
- extend(_this8.element.style, writeCSS);
- _this8.trigger('repositioned');
- });
- }
- }
- }]);
- return TetherClass;
- }(Evented);
- TetherClass.modules = [];
- TetherBase.position = position;
- var Tether = extend(TetherClass, TetherBase);
- /* globals TetherBase */
- 'use strict';
- var _slicedToArray = function () {
- function sliceIterator(arr, i) {
- var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
- _arr.push(_s.value);if (i && _arr.length === i) break;
- }
- } catch (err) {
- _d = true;_e = err;
- } finally {
- try {
- if (!_n && _i['return']) _i['return']();
- } finally {
- if (_d) throw _e;
- }
- }return _arr;
- }return function (arr, i) {
- if (Array.isArray(arr)) {
- return arr;
- } else if (Symbol.iterator in Object(arr)) {
- return sliceIterator(arr, i);
- } else {
- throw new TypeError('Invalid attempt to destructure non-iterable instance');
- }
- };
- }();
- var _TetherBase$Utils = TetherBase.Utils;
- var getBounds = _TetherBase$Utils.getBounds;
- var extend = _TetherBase$Utils.extend;
- var updateClasses = _TetherBase$Utils.updateClasses;
- var defer = _TetherBase$Utils.defer;
- var BOUNDS_FORMAT = ['left', 'top', 'right', 'bottom'];
- function getBoundingRect(tether, to) {
- if (to === 'scrollParent') {
- to = tether.scrollParents[0];
- } else if (to === 'window') {
- to = [pageXOffset, pageYOffset, innerWidth + pageXOffset, innerHeight + pageYOffset];
- }
- if (to === document) {
- to = to.documentElement;
- }
- if (typeof to.nodeType !== 'undefined') {
- (function () {
- var node = to;
- var size = getBounds(to);
- var pos = size;
- var style = getComputedStyle(to);
- to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top];
- // Account any parent Frames scroll offset
- if (node.ownerDocument !== document) {
- var win = node.ownerDocument.defaultView;
- to[0] += win.pageXOffset;
- to[1] += win.pageYOffset;
- to[2] += win.pageXOffset;
- to[3] += win.pageYOffset;
- }
- BOUNDS_FORMAT.forEach(function (side, i) {
- side = side[0].toUpperCase() + side.substr(1);
- if (side === 'Top' || side === 'Left') {
- to[i] += parseFloat(style['border' + side + 'Width']);
- } else {
- to[i] -= parseFloat(style['border' + side + 'Width']);
- }
- });
- })();
- }
- return to;
- }
- TetherBase.modules.push({
- position: function position(_ref) {
- var _this = this;
- var top = _ref.top;
- var left = _ref.left;
- var targetAttachment = _ref.targetAttachment;
- if (!this.options.constraints) {
- return true;
- }
- var _cache = this.cache('element-bounds', function () {
- return getBounds(_this.element);
- });
- var height = _cache.height;
- var width = _cache.width;
- if (width === 0 && height === 0 && typeof this.lastSize !== 'undefined') {
- var _lastSize = this.lastSize;
- // Handle the item getting hidden as a result of our positioning without glitching
- // the classes in and out
- width = _lastSize.width;
- height = _lastSize.height;
- }
- var targetSize = this.cache('target-bounds', function () {
- return _this.getTargetBounds();
- });
- var targetHeight = targetSize.height;
- var targetWidth = targetSize.width;
- var allClasses = [this.getClass('pinned'), this.getClass('out-of-bounds')];
- this.options.constraints.forEach(function (constraint) {
- var outOfBoundsClass = constraint.outOfBoundsClass;
- var pinnedClass = constraint.pinnedClass;
- if (outOfBoundsClass) {
- allClasses.push(outOfBoundsClass);
- }
- if (pinnedClass) {
- allClasses.push(pinnedClass);
- }
- });
- allClasses.forEach(function (cls) {
- ['left', 'top', 'right', 'bottom'].forEach(function (side) {
- allClasses.push(cls + '-' + side);
- });
- });
- var addClasses = [];
- var tAttachment = extend({}, targetAttachment);
- var eAttachment = extend({}, this.attachment);
- this.options.constraints.forEach(function (constraint) {
- var to = constraint.to;
- var attachment = constraint.attachment;
- var pin = constraint.pin;
- if (typeof attachment === 'undefined') {
- attachment = '';
- }
- var changeAttachX = undefined,
- changeAttachY = undefined;
- if (attachment.indexOf(' ') >= 0) {
- var _attachment$split = attachment.split(' ');
- var _attachment$split2 = _slicedToArray(_attachment$split, 2);
- changeAttachY = _attachment$split2[0];
- changeAttachX = _attachment$split2[1];
- } else {
- changeAttachX = changeAttachY = attachment;
- }
- var bounds = getBoundingRect(_this, to);
- if (changeAttachY === 'target' || changeAttachY === 'both') {
- if (top < bounds[1] && tAttachment.top === 'top') {
- top += targetHeight;
- tAttachment.top = 'bottom';
- }
- if (top + height > bounds[3] && tAttachment.top === 'bottom') {
- top -= targetHeight;
- tAttachment.top = 'top';
- }
- }
- if (changeAttachY === 'together') {
- if (tAttachment.top === 'top') {
- if (eAttachment.top === 'bottom' && top < bounds[1]) {
- top += targetHeight;
- tAttachment.top = 'bottom';
- top += height;
- eAttachment.top = 'top';
- } else if (eAttachment.top === 'top' && top + height > bounds[3] && top - (height - targetHeight) >= bounds[1]) {
- top -= height - targetHeight;
- tAttachment.top = 'bottom';
- eAttachment.top = 'bottom';
- }
- }
- if (tAttachment.top === 'bottom') {
- if (eAttachment.top === 'top' && top + height > bounds[3]) {
- top -= targetHeight;
- tAttachment.top = 'top';
- top -= height;
- eAttachment.top = 'bottom';
- } else if (eAttachment.top === 'bottom' && top < bounds[1] && top + (height * 2 - targetHeight) <= bounds[3]) {
- top += height - targetHeight;
- tAttachment.top = 'top';
- eAttachment.top = 'top';
- }
- }
- if (tAttachment.top === 'middle') {
- if (top + height > bounds[3] && eAttachment.top === 'top') {
- top -= height;
- eAttachment.top = 'bottom';
- } else if (top < bounds[1] && eAttachment.top === 'bottom') {
- top += height;
- eAttachment.top = 'top';
- }
- }
- }
- if (changeAttachX === 'target' || changeAttachX === 'both') {
- if (left < bounds[0] && tAttachment.left === 'left') {
- left += targetWidth;
- tAttachment.left = 'right';
- }
- if (left + width > bounds[2] && tAttachment.left === 'right') {
- left -= targetWidth;
- tAttachment.left = 'left';
- }
- }
- if (changeAttachX === 'together') {
- if (left < bounds[0] && tAttachment.left === 'left') {
- if (eAttachment.left === 'right') {
- left += targetWidth;
- tAttachment.left = 'right';
- left += width;
- eAttachment.left = 'left';
- } else if (eAttachment.left === 'left') {
- left += targetWidth;
- tAttachment.left = 'right';
- left -= width;
- eAttachment.left = 'right';
- }
- } else if (left + width > bounds[2] && tAttachment.left === 'right') {
- if (eAttachment.left === 'left') {
- left -= targetWidth;
- tAttachment.left = 'left';
- left -= width;
- eAttachment.left = 'right';
- } else if (eAttachment.left === 'right') {
- left -= targetWidth;
- tAttachment.left = 'left';
- left += width;
- eAttachment.left = 'left';
- }
- } else if (tAttachment.left === 'center') {
- if (left + width > bounds[2] && eAttachment.left === 'left') {
- left -= width;
- eAttachment.left = 'right';
- } else if (left < bounds[0] && eAttachment.left === 'right') {
- left += width;
- eAttachment.left = 'left';
- }
- }
- }
- if (changeAttachY === 'element' || changeAttachY === 'both') {
- if (top < bounds[1] && eAttachment.top === 'bottom') {
- top += height;
- eAttachment.top = 'top';
- }
- if (top + height > bounds[3] && eAttachment.top === 'top') {
- top -= height;
- eAttachment.top = 'bottom';
- }
- }
- if (changeAttachX === 'element' || changeAttachX === 'both') {
- if (left < bounds[0]) {
- if (eAttachment.left === 'right') {
- left += width;
- eAttachment.left = 'left';
- } else if (eAttachment.left === 'center') {
- left += width / 2;
- eAttachment.left = 'left';
- }
- }
- if (left + width > bounds[2]) {
- if (eAttachment.left === 'left') {
- left -= width;
- eAttachment.left = 'right';
- } else if (eAttachment.left === 'center') {
- left -= width / 2;
- eAttachment.left = 'right';
- }
- }
- }
- if (typeof pin === 'string') {
- pin = pin.split(',').map(function (p) {
- return p.trim();
- });
- } else if (pin === true) {
- pin = ['top', 'left', 'right', 'bottom'];
- }
- pin = pin || [];
- var pinned = [];
- var oob = [];
- if (top < bounds[1]) {
- if (pin.indexOf('top') >= 0) {
- top = bounds[1];
- pinned.push('top');
- } else {
- oob.push('top');
- }
- }
- if (top + height > bounds[3]) {
- if (pin.indexOf('bottom') >= 0) {
- top = bounds[3] - height;
- pinned.push('bottom');
- } else {
- oob.push('bottom');
- }
- }
- if (left < bounds[0]) {
- if (pin.indexOf('left') >= 0) {
- left = bounds[0];
- pinned.push('left');
- } else {
- oob.push('left');
- }
- }
- if (left + width > bounds[2]) {
- if (pin.indexOf('right') >= 0) {
- left = bounds[2] - width;
- pinned.push('right');
- } else {
- oob.push('right');
- }
- }
- if (pinned.length) {
- (function () {
- var pinnedClass = undefined;
- if (typeof _this.options.pinnedClass !== 'undefined') {
- pinnedClass = _this.options.pinnedClass;
- } else {
- pinnedClass = _this.getClass('pinned');
- }
- addClasses.push(pinnedClass);
- pinned.forEach(function (side) {
- addClasses.push(pinnedClass + '-' + side);
- });
- })();
- }
- if (oob.length) {
- (function () {
- var oobClass = undefined;
- if (typeof _this.options.outOfBoundsClass !== 'undefined') {
- oobClass = _this.options.outOfBoundsClass;
- } else {
- oobClass = _this.getClass('out-of-bounds');
- }
- addClasses.push(oobClass);
- oob.forEach(function (side) {
- addClasses.push(oobClass + '-' + side);
- });
- })();
- }
- if (pinned.indexOf('left') >= 0 || pinned.indexOf('right') >= 0) {
- eAttachment.left = tAttachment.left = false;
- }
- if (pinned.indexOf('top') >= 0 || pinned.indexOf('bottom') >= 0) {
- eAttachment.top = tAttachment.top = false;
- }
- if (tAttachment.top !== targetAttachment.top || tAttachment.left !== targetAttachment.left || eAttachment.top !== _this.attachment.top || eAttachment.left !== _this.attachment.left) {
- _this.updateAttachClasses(eAttachment, tAttachment);
- _this.trigger('update', {
- attachment: eAttachment,
- targetAttachment: tAttachment
- });
- }
- });
- defer(function () {
- if (!(_this.options.addTargetClasses === false)) {
- updateClasses(_this.target, addClasses, allClasses);
- }
- updateClasses(_this.element, addClasses, allClasses);
- });
- return { top: top, left: left };
- }
- });
- /* globals TetherBase */
- 'use strict';
- var _TetherBase$Utils = TetherBase.Utils;
- var getBounds = _TetherBase$Utils.getBounds;
- var updateClasses = _TetherBase$Utils.updateClasses;
- var defer = _TetherBase$Utils.defer;
- TetherBase.modules.push({
- position: function position(_ref) {
- var _this = this;
- var top = _ref.top;
- var left = _ref.left;
- var _cache = this.cache('element-bounds', function () {
- return getBounds(_this.element);
- });
- var height = _cache.height;
- var width = _cache.width;
- var targetPos = this.getTargetBounds();
- var bottom = top + height;
- var right = left + width;
- var abutted = [];
- if (top <= targetPos.bottom && bottom >= targetPos.top) {
- ['left', 'right'].forEach(function (side) {
- var targetPosSide = targetPos[side];
- if (targetPosSide === left || targetPosSide === right) {
- abutted.push(side);
- }
- });
- }
- if (left <= targetPos.right && right >= targetPos.left) {
- ['top', 'bottom'].forEach(function (side) {
- var targetPosSide = targetPos[side];
- if (targetPosSide === top || targetPosSide === bottom) {
- abutted.push(side);
- }
- });
- }
- var allClasses = [];
- var addClasses = [];
- var sides = ['left', 'top', 'right', 'bottom'];
- allClasses.push(this.getClass('abutted'));
- sides.forEach(function (side) {
- allClasses.push(_this.getClass('abutted') + '-' + side);
- });
- if (abutted.length) {
- addClasses.push(this.getClass('abutted'));
- }
- abutted.forEach(function (side) {
- addClasses.push(_this.getClass('abutted') + '-' + side);
- });
- defer(function () {
- if (!(_this.options.addTargetClasses === false)) {
- updateClasses(_this.target, addClasses, allClasses);
- }
- updateClasses(_this.element, addClasses, allClasses);
- });
- return true;
- }
- });
- /* globals TetherBase */
- 'use strict';
- var _slicedToArray = function () {
- function sliceIterator(arr, i) {
- var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
- _arr.push(_s.value);if (i && _arr.length === i) break;
- }
- } catch (err) {
- _d = true;_e = err;
- } finally {
- try {
- if (!_n && _i['return']) _i['return']();
- } finally {
- if (_d) throw _e;
- }
- }return _arr;
- }return function (arr, i) {
- if (Array.isArray(arr)) {
- return arr;
- } else if (Symbol.iterator in Object(arr)) {
- return sliceIterator(arr, i);
- } else {
- throw new TypeError('Invalid attempt to destructure non-iterable instance');
- }
- };
- }();
- TetherBase.modules.push({
- position: function position(_ref) {
- var top = _ref.top;
- var left = _ref.left;
- if (!this.options.shift) {
- return;
- }
- var shift = this.options.shift;
- if (typeof this.options.shift === 'function') {
- shift = this.options.shift.call(this, { top: top, left: left });
- }
- var shiftTop = undefined,
- shiftLeft = undefined;
- if (typeof shift === 'string') {
- shift = shift.split(' ');
- shift[1] = shift[1] || shift[0];
- var _shift = shift;
- var _shift2 = _slicedToArray(_shift, 2);
- shiftTop = _shift2[0];
- shiftLeft = _shift2[1];
- shiftTop = parseFloat(shiftTop, 10);
- shiftLeft = parseFloat(shiftLeft, 10);
- } else {
- shiftTop = shift.top;
- shiftLeft = shift.left;
- }
- top += shiftTop;
- left += shiftLeft;
- return { top: top, left: left };
- }
- });
- return Tether;
- });
- /***/ }),
- /* 35 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
- /*
- * Toastr
- * Copyright 2012-2015
- * Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
- * All Rights Reserved.
- * Use, reproduction, distribution, and modification of this code is subject to the terms and
- * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
- *
- * ARIA Support: Greta Krafsig
- *
- * Project: https://github.com/CodeSeven/toastr
- */
- /* global define */
- (function (define) {
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1)], __WEBPACK_AMD_DEFINE_RESULT__ = function ($) {
- return function () {
- var $container;
- var listener;
- var toastId = 0;
- var toastType = {
- error: 'error',
- info: 'info',
- success: 'success',
- warning: 'warning'
- };
- var toastr = {
- clear: clear,
- remove: remove,
- error: error,
- getContainer: getContainer,
- info: info,
- options: {},
- subscribe: subscribe,
- success: success,
- version: '2.1.3',
- warning: warning
- };
- var previousToast;
- return toastr;
- ////////////////
- function error(message, title, optionsOverride) {
- return notify({
- type: toastType.error,
- iconClass: getOptions().iconClasses.error,
- message: message,
- optionsOverride: optionsOverride,
- title: title
- });
- }
- function getContainer(options, create) {
- if (!options) {
- options = getOptions();
- }
- $container = $('#' + options.containerId);
- if ($container.length) {
- return $container;
- }
- if (create) {
- $container = createContainer(options);
- }
- return $container;
- }
- function info(message, title, optionsOverride) {
- return notify({
- type: toastType.info,
- iconClass: getOptions().iconClasses.info,
- message: message,
- optionsOverride: optionsOverride,
- title: title
- });
- }
- function subscribe(callback) {
- listener = callback;
- }
- function success(message, title, optionsOverride) {
- return notify({
- type: toastType.success,
- iconClass: getOptions().iconClasses.success,
- message: message,
- optionsOverride: optionsOverride,
- title: title
- });
- }
- function warning(message, title, optionsOverride) {
- return notify({
- type: toastType.warning,
- iconClass: getOptions().iconClasses.warning,
- message: message,
- optionsOverride: optionsOverride,
- title: title
- });
- }
- function clear($toastElement, clearOptions) {
- var options = getOptions();
- if (!$container) {
- getContainer(options);
- }
- if (!clearToast($toastElement, options, clearOptions)) {
- clearContainer(options);
- }
- }
- function remove($toastElement) {
- var options = getOptions();
- if (!$container) {
- getContainer(options);
- }
- if ($toastElement && $(':focus', $toastElement).length === 0) {
- removeToast($toastElement);
- return;
- }
- if ($container.children().length) {
- $container.remove();
- }
- }
- // internal functions
- function clearContainer(options) {
- var toastsToClear = $container.children();
- for (var i = toastsToClear.length - 1; i >= 0; i--) {
- clearToast($(toastsToClear[i]), options);
- }
- }
- function clearToast($toastElement, options, clearOptions) {
- var force = clearOptions && clearOptions.force ? clearOptions.force : false;
- if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
- $toastElement[options.hideMethod]({
- duration: options.hideDuration,
- easing: options.hideEasing,
- complete: function complete() {
- removeToast($toastElement);
- }
- });
- return true;
- }
- return false;
- }
- function createContainer(options) {
- $container = $('<div/>').attr('id', options.containerId).addClass(options.positionClass);
- $container.appendTo($(options.target));
- return $container;
- }
- function getDefaults() {
- return {
- tapToDismiss: true,
- toastClass: 'toast',
- containerId: 'toast-container',
- debug: false,
- showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
- showDuration: 300,
- showEasing: 'swing', //swing and linear are built into jQuery
- onShown: undefined,
- hideMethod: 'fadeOut',
- hideDuration: 1000,
- hideEasing: 'swing',
- onHidden: undefined,
- closeMethod: false,
- closeDuration: false,
- closeEasing: false,
- closeOnHover: true,
- extendedTimeOut: 1000,
- iconClasses: {
- error: 'toast-error',
- info: 'toast-info',
- success: 'toast-success',
- warning: 'toast-warning'
- },
- iconClass: 'toast-info',
- positionClass: 'toast-top-right',
- timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
- titleClass: 'toast-title',
- messageClass: 'toast-message',
- escapeHtml: false,
- target: 'body',
- closeHtml: '<button type="button">×</button>',
- closeClass: 'toast-close-button',
- newestOnTop: true,
- preventDuplicates: false,
- progressBar: false,
- progressClass: 'toast-progress',
- rtl: false
- };
- }
- function publish(args) {
- if (!listener) {
- return;
- }
- listener(args);
- }
- function notify(map) {
- var options = getOptions();
- var iconClass = map.iconClass || options.iconClass;
- if (typeof map.optionsOverride !== 'undefined') {
- options = $.extend(options, map.optionsOverride);
- iconClass = map.optionsOverride.iconClass || iconClass;
- }
- if (shouldExit(options, map)) {
- return;
- }
- toastId++;
- $container = getContainer(options, true);
- var intervalId = null;
- var $toastElement = $('<div/>');
- var $titleElement = $('<div/>');
- var $messageElement = $('<div/>');
- var $progressElement = $('<div/>');
- var $closeElement = $(options.closeHtml);
- var progressBar = {
- intervalId: null,
- hideEta: null,
- maxHideTime: null
- };
- var response = {
- toastId: toastId,
- state: 'visible',
- startTime: new Date(),
- options: options,
- map: map
- };
- personalizeToast();
- displayToast();
- handleEvents();
- publish(response);
- if (options.debug && console) {
- console.log(response);
- }
- return $toastElement;
- function escapeHtml(source) {
- if (source == null) {
- source = '';
- }
- return source.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>');
- }
- function personalizeToast() {
- setIcon();
- setTitle();
- setMessage();
- setCloseButton();
- setProgressBar();
- setRTL();
- setSequence();
- setAria();
- }
- function setAria() {
- var ariaValue = '';
- switch (map.iconClass) {
- case 'toast-success':
- case 'toast-info':
- ariaValue = 'polite';
- break;
- default:
- ariaValue = 'assertive';
- }
- $toastElement.attr('aria-live', ariaValue);
- }
- function handleEvents() {
- if (options.closeOnHover) {
- $toastElement.hover(stickAround, delayedHideToast);
- }
- if (!options.onclick && options.tapToDismiss) {
- $toastElement.click(hideToast);
- }
- if (options.closeButton && $closeElement) {
- $closeElement.click(function (event) {
- if (event.stopPropagation) {
- event.stopPropagation();
- } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
- event.cancelBubble = true;
- }
- if (options.onCloseClick) {
- options.onCloseClick(event);
- }
- hideToast(true);
- });
- }
- if (options.onclick) {
- $toastElement.click(function (event) {
- options.onclick(event);
- hideToast();
- });
- }
- }
- function displayToast() {
- $toastElement.hide();
- $toastElement[options.showMethod]({ duration: options.showDuration, easing: options.showEasing, complete: options.onShown });
- if (options.timeOut > 0) {
- intervalId = setTimeout(hideToast, options.timeOut);
- progressBar.maxHideTime = parseFloat(options.timeOut);
- progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
- if (options.progressBar) {
- progressBar.intervalId = setInterval(updateProgress, 10);
- }
- }
- }
- function setIcon() {
- if (map.iconClass) {
- $toastElement.addClass(options.toastClass).addClass(iconClass).addClass('mg-toast');
- }
- }
- function setSequence() {
- if (options.newestOnTop) {
- $container.prepend($toastElement);
- } else {
- $container.append($toastElement);
- }
- }
- function setTitle() {
- if (map.title) {
- var suffix = map.title;
- if (options.escapeHtml) {
- suffix = escapeHtml(map.title);
- }
- $titleElement.append(suffix).addClass(options.titleClass);
- $toastElement.append($titleElement);
- }
- }
- function setMessage() {
- if (map.message) {
- var suffix = map.message;
- if (options.escapeHtml) {
- suffix = escapeHtml(map.message);
- }
- $messageElement.append(suffix).addClass(options.messageClass);
- $toastElement.append($messageElement);
- }
- }
- function setCloseButton() {
- if (options.closeButton) {
- $closeElement.addClass(options.closeClass).attr('role', 'button');
- $toastElement.prepend($closeElement);
- }
- }
- function setProgressBar() {
- if (options.progressBar) {
- $progressElement.addClass(options.progressClass);
- $toastElement.prepend($progressElement);
- }
- }
- function setRTL() {
- if (options.rtl) {
- $toastElement.addClass('rtl');
- }
- }
- function shouldExit(options, map) {
- if (options.preventDuplicates) {
- if (map.message === previousToast) {
- return true;
- } else {
- previousToast = map.message;
- }
- }
- return false;
- }
- function hideToast(override) {
- var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
- var duration = override && options.closeDuration !== false ? options.closeDuration : options.hideDuration;
- var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
- if ($(':focus', $toastElement).length && !override) {
- return;
- }
- clearTimeout(progressBar.intervalId);
- return $toastElement[method]({
- duration: duration,
- easing: easing,
- complete: function complete() {
- removeToast($toastElement);
- clearTimeout(intervalId);
- if (options.onHidden && response.state !== 'hidden') {
- options.onHidden();
- }
- response.state = 'hidden';
- response.endTime = new Date();
- publish(response);
- }
- });
- }
- function delayedHideToast() {
- if (options.timeOut > 0 || options.extendedTimeOut > 0) {
- intervalId = setTimeout(hideToast, options.extendedTimeOut);
- progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
- progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
- }
- }
- function stickAround() {
- clearTimeout(intervalId);
- progressBar.hideEta = 0;
- $toastElement.stop(true, true)[options.showMethod]({ duration: options.showDuration, easing: options.showEasing });
- }
- function updateProgress() {
- var percentage = (progressBar.hideEta - new Date().getTime()) / progressBar.maxHideTime * 100;
- $progressElement.width(percentage + '%');
- }
- }
- function getOptions() {
- return $.extend({}, getDefaults(), toastr.options);
- }
- function removeToast($toastElement) {
- if (!$container) {
- $container = getContainer();
- }
- if ($toastElement.is(':visible')) {
- return;
- }
- $toastElement.remove();
- $toastElement = null;
- if ($container.children().length === 0) {
- $container.remove();
- previousToast = undefined;
- }
- }
- }();
- }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- })(__webpack_require__(36));
- /***/ }),
- /* 36 */
- /***/ (function(module, exports) {
- module.exports = function() {
- throw new Error("define cannot be used indirect");
- };
- /***/ })
- /******/ ]);
|