amazeui.js 665 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526
  1. /*! Amaze UI v2.5.1 | by Amaze UI Team | (c) 2016 AllMobilize, Inc. | Licensed under MIT | 2016-01-19T14:45:42+0800 */
  2. (function webpackUniversalModuleDefinition(root, factory) {
  3. if(typeof exports === 'object' && typeof module === 'object')
  4. module.exports = factory(require("jquery"));
  5. else if(typeof define === 'function' && define.amd)
  6. define(["jquery"], factory);
  7. else if(typeof exports === 'object')
  8. exports["AMUI"] = factory(require("jquery"));
  9. else
  10. root["AMUI"] = factory(root["jQuery"]);
  11. })(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {
  12. return /******/ (function(modules) { // webpackBootstrap
  13. /******/ // The module cache
  14. /******/ var installedModules = {};
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/ // Check if module is in cache
  18. /******/ if(installedModules[moduleId])
  19. /******/ return installedModules[moduleId].exports;
  20. /******/ // Create a new module (and put it into the cache)
  21. /******/ var module = installedModules[moduleId] = {
  22. /******/ exports: {},
  23. /******/ id: moduleId,
  24. /******/ loaded: false
  25. /******/ };
  26. /******/ // Execute the module function
  27. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  28. /******/ // Flag the module as loaded
  29. /******/ module.loaded = true;
  30. /******/ // Return the exports of the module
  31. /******/ return module.exports;
  32. /******/ }
  33. /******/ // expose the modules object (__webpack_modules__)
  34. /******/ __webpack_require__.m = modules;
  35. /******/ // expose the module cache
  36. /******/ __webpack_require__.c = installedModules;
  37. /******/ // __webpack_public_path__
  38. /******/ __webpack_require__.p = "";
  39. /******/ // Load entry module and return exports
  40. /******/ return __webpack_require__(0);
  41. /******/ })
  42. /************************************************************************/
  43. /******/ ([
  44. /* 0 */
  45. /***/ function(module, exports, __webpack_require__) {
  46. 'use strict';
  47. var $ = __webpack_require__(1);
  48. var UI = __webpack_require__(2);
  49. __webpack_require__(3);
  50. __webpack_require__(4);
  51. __webpack_require__(5);
  52. __webpack_require__(6);
  53. __webpack_require__(7);
  54. __webpack_require__(8);
  55. __webpack_require__(9);
  56. __webpack_require__(10);
  57. __webpack_require__(11);
  58. __webpack_require__(14);
  59. __webpack_require__(15);
  60. __webpack_require__(16);
  61. __webpack_require__(17);
  62. __webpack_require__(18);
  63. __webpack_require__(19);
  64. __webpack_require__(20);
  65. __webpack_require__(21);
  66. __webpack_require__(22);
  67. __webpack_require__(24);
  68. __webpack_require__(25);
  69. __webpack_require__(23);
  70. __webpack_require__(27);
  71. __webpack_require__(28);
  72. __webpack_require__(29);
  73. __webpack_require__(30);
  74. __webpack_require__(31);
  75. __webpack_require__(32);
  76. __webpack_require__(33);
  77. __webpack_require__(26);
  78. __webpack_require__(34);
  79. __webpack_require__(35);
  80. __webpack_require__(36);
  81. __webpack_require__(37);
  82. __webpack_require__(38);
  83. __webpack_require__(39);
  84. __webpack_require__(40);
  85. __webpack_require__(41);
  86. __webpack_require__(42);
  87. __webpack_require__(43);
  88. __webpack_require__(44);
  89. __webpack_require__(45);
  90. __webpack_require__(46);
  91. __webpack_require__(47);
  92. __webpack_require__(48);
  93. __webpack_require__(49);
  94. __webpack_require__(50);
  95. __webpack_require__(51);
  96. __webpack_require__(52);
  97. __webpack_require__(53);
  98. __webpack_require__(54);
  99. module.exports = $.AMUI = UI;
  100. /***/ },
  101. /* 1 */
  102. /***/ function(module, exports) {
  103. module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
  104. /***/ },
  105. /* 2 */
  106. /***/ function(module, exports, __webpack_require__) {
  107. 'use strict';
  108. /* jshint -W040 */
  109. var $ = __webpack_require__(1);
  110. if (typeof $ === 'undefined') {
  111. throw new Error('Amaze UI 2.x requires jQuery :-(\n' +
  112. '\u7231\u4e0a\u4e00\u5339\u91ce\u9a6c\uff0c\u53ef\u4f60' +
  113. '\u7684\u5bb6\u91cc\u6ca1\u6709\u8349\u539f\u2026');
  114. }
  115. var UI = $.AMUI || {};
  116. var $win = $(window);
  117. var doc = window.document;
  118. var $html = $('html');
  119. UI.VERSION = '2.5.1';
  120. UI.support = {};
  121. UI.support.transition = (function() {
  122. var transitionEnd = (function() {
  123. // https://developer.mozilla.org/en-US/docs/Web/Events/transitionend#Browser_compatibility
  124. var element = doc.body || doc.documentElement;
  125. var transEndEventNames = {
  126. WebkitTransition: 'webkitTransitionEnd',
  127. MozTransition: 'transitionend',
  128. OTransition: 'oTransitionEnd otransitionend',
  129. transition: 'transitionend'
  130. };
  131. for (var name in transEndEventNames) {
  132. if (element.style[name] !== undefined) {
  133. return transEndEventNames[name];
  134. }
  135. }
  136. })();
  137. return transitionEnd && {end: transitionEnd};
  138. })();
  139. UI.support.animation = (function() {
  140. var animationEnd = (function() {
  141. var element = doc.body || doc.documentElement;
  142. var animEndEventNames = {
  143. WebkitAnimation: 'webkitAnimationEnd',
  144. MozAnimation: 'animationend',
  145. OAnimation: 'oAnimationEnd oanimationend',
  146. animation: 'animationend'
  147. };
  148. for (var name in animEndEventNames) {
  149. if (element.style[name] !== undefined) {
  150. return animEndEventNames[name];
  151. }
  152. }
  153. })();
  154. return animationEnd && {end: animationEnd};
  155. })();
  156. /* jshint -W069 */
  157. UI.support.touch = (
  158. ('ontouchstart' in window &&
  159. navigator.userAgent.toLowerCase().match(/mobile|tablet/)) ||
  160. (window.DocumentTouch && document instanceof window.DocumentTouch) ||
  161. (window.navigator['msPointerEnabled'] &&
  162. window.navigator['msMaxTouchPoints'] > 0) || //IE 10
  163. (window.navigator['pointerEnabled'] &&
  164. window.navigator['maxTouchPoints'] > 0) || //IE >=11
  165. false);
  166. // https://developer.mozilla.org/zh-CN/docs/DOM/MutationObserver
  167. UI.support.mutationobserver = (window.MutationObserver ||
  168. window.WebKitMutationObserver || null);
  169. // https://github.com/Modernizr/Modernizr/blob/924c7611c170ef2dc502582e5079507aff61e388/feature-detects/forms/validation.js#L20
  170. UI.support.formValidation = (typeof document.createElement('form').
  171. checkValidity === 'function');
  172. UI.utils = {};
  173. /**
  174. * Debounce function
  175. * @param {function} func Function to be debounced
  176. * @param {number} wait Function execution threshold in milliseconds
  177. * @param {bool} immediate Whether the function should be called at
  178. * the beginning of the delay instead of the
  179. * end. Default is false.
  180. * @desc Executes a function when it stops being invoked for n seconds
  181. * @via _.debounce() http://underscorejs.org
  182. */
  183. UI.utils.debounce = function(func, wait, immediate) {
  184. var timeout;
  185. return function() {
  186. var context = this;
  187. var args = arguments;
  188. var later = function() {
  189. timeout = null;
  190. if (!immediate) {
  191. func.apply(context, args);
  192. }
  193. };
  194. var callNow = immediate && !timeout;
  195. clearTimeout(timeout);
  196. timeout = setTimeout(later, wait);
  197. if (callNow) {
  198. func.apply(context, args);
  199. }
  200. };
  201. };
  202. UI.utils.isInView = function(element, options) {
  203. var $element = $(element);
  204. var visible = !!($element.width() || $element.height()) &&
  205. $element.css('display') !== 'none';
  206. if (!visible) {
  207. return false;
  208. }
  209. var windowLeft = $win.scrollLeft();
  210. var windowTop = $win.scrollTop();
  211. var offset = $element.offset();
  212. var left = offset.left;
  213. var top = offset.top;
  214. options = $.extend({topOffset: 0, leftOffset: 0}, options);
  215. return (top + $element.height() >= windowTop &&
  216. top - options.topOffset <= windowTop + $win.height() &&
  217. left + $element.width() >= windowLeft &&
  218. left - options.leftOffset <= windowLeft + $win.width());
  219. };
  220. /* jshint -W054 */
  221. UI.utils.parseOptions = UI.utils.options = function(string) {
  222. if ($.isPlainObject(string)) {
  223. return string;
  224. }
  225. var start = (string ? string.indexOf('{') : -1);
  226. var options = {};
  227. if (start != -1) {
  228. try {
  229. options = (new Function('',
  230. 'var json = ' + string.substr(start) +
  231. '; return JSON.parse(JSON.stringify(json));'))();
  232. } catch (e) {
  233. }
  234. }
  235. return options;
  236. };
  237. /* jshint +W054 */
  238. UI.utils.generateGUID = function(namespace) {
  239. var uid = namespace + '-' || 'am-';
  240. do {
  241. uid += Math.random().toString(36).substring(2, 7);
  242. } while (document.getElementById(uid));
  243. return uid;
  244. };
  245. // @see https://davidwalsh.name/get-absolute-url
  246. UI.utils.getAbsoluteUrl = (function() {
  247. var a;
  248. return function(url) {
  249. if (!a) {
  250. a = document.createElement('a');
  251. }
  252. a.href = url;
  253. return a.href;
  254. };
  255. })();
  256. /**
  257. * Plugin AMUI Component to jQuery
  258. *
  259. * @param {String} name - plugin name
  260. * @param {Function} Component - plugin constructor
  261. * @param {Object} [pluginOption]
  262. * @param {String} pluginOption.dataOptions
  263. * @param {Function} pluginOption.methodCall - custom method call
  264. * @param {Function} pluginOption.before
  265. * @param {Function} pluginOption.after
  266. * @since v2.4.1
  267. */
  268. UI.plugin = function UIPlugin(name, Component, pluginOption) {
  269. var old = $.fn[name];
  270. pluginOption = pluginOption || {};
  271. $.fn[name] = function(option) {
  272. var allArgs = Array.prototype.slice.call(arguments, 0);
  273. var args = allArgs.slice(1);
  274. var propReturn;
  275. var $set = this.each(function() {
  276. var $this = $(this);
  277. var dataName = 'amui.' + name;
  278. var dataOptionsName = pluginOption.dataOptions || ('data-am-' + name);
  279. var instance = $this.data(dataName);
  280. var options = $.extend({},
  281. UI.utils.parseOptions($this.attr(dataOptionsName)),
  282. typeof option === 'object' && option);
  283. if (!instance && option === 'destroy') {
  284. return;
  285. }
  286. if (!instance) {
  287. $this.data(dataName, (instance = new Component(this, options)));
  288. }
  289. // custom method call
  290. if (pluginOption.methodCall) {
  291. pluginOption.methodCall.call($this, allArgs, instance);
  292. } else {
  293. // before method call
  294. pluginOption.before &&
  295. pluginOption.before.call($this, allArgs, instance);
  296. if (typeof option === 'string') {
  297. propReturn = typeof instance[option] === 'function' ?
  298. instance[option].apply(instance, args) : instance[option];
  299. }
  300. // after method call
  301. pluginOption.after && pluginOption.after.call($this, allArgs, instance);
  302. }
  303. });
  304. return (propReturn === undefined) ? $set : propReturn;
  305. };
  306. $.fn[name].Constructor = Component;
  307. // no conflict
  308. $.fn[name].noConflict = function() {
  309. $.fn[name] = old;
  310. return this;
  311. };
  312. UI[name] = Component;
  313. };
  314. // http://blog.alexmaccaw.com/css-transitions
  315. $.fn.emulateTransitionEnd = function(duration) {
  316. var called = false;
  317. var $el = this;
  318. $(this).one(UI.support.transition.end, function() {
  319. called = true;
  320. });
  321. var callback = function() {
  322. if (!called) {
  323. $($el).trigger(UI.support.transition.end);
  324. }
  325. $el.transitionEndTimmer = undefined;
  326. };
  327. this.transitionEndTimmer = setTimeout(callback, duration);
  328. return this;
  329. };
  330. $.fn.redraw = function() {
  331. return this.each(function() {
  332. /* jshint unused:false */
  333. var redraw = this.offsetHeight;
  334. });
  335. };
  336. /* jshint unused:true */
  337. $.fn.transitionEnd = function(callback) {
  338. var endEvent = UI.support.transition.end;
  339. var dom = this;
  340. function fireCallBack(e) {
  341. callback.call(this, e);
  342. endEvent && dom.off(endEvent, fireCallBack);
  343. }
  344. if (callback && endEvent) {
  345. dom.on(endEvent, fireCallBack);
  346. }
  347. return this;
  348. };
  349. $.fn.removeClassRegEx = function() {
  350. return this.each(function(regex) {
  351. var classes = $(this).attr('class');
  352. if (!classes || !regex) {
  353. return false;
  354. }
  355. var classArray = [];
  356. classes = classes.split(' ');
  357. for (var i = 0, len = classes.length; i < len; i++) {
  358. if (!classes[i].match(regex)) {
  359. classArray.push(classes[i]);
  360. }
  361. }
  362. $(this).attr('class', classArray.join(' '));
  363. });
  364. };
  365. //
  366. $.fn.alterClass = function(removals, additions) {
  367. var self = this;
  368. if (removals.indexOf('*') === -1) {
  369. // Use native jQuery methods if there is no wildcard matching
  370. self.removeClass(removals);
  371. return !additions ? self : self.addClass(additions);
  372. }
  373. var classPattern = new RegExp('\\s' +
  374. removals.
  375. replace(/\*/g, '[A-Za-z0-9-_]+').
  376. split(' ').
  377. join('\\s|\\s') +
  378. '\\s', 'g');
  379. self.each(function(i, it) {
  380. var cn = ' ' + it.className + ' ';
  381. while (classPattern.test(cn)) {
  382. cn = cn.replace(classPattern, ' ');
  383. }
  384. it.className = $.trim(cn);
  385. });
  386. return !additions ? self : self.addClass(additions);
  387. };
  388. // handle multiple browsers for requestAnimationFrame()
  389. // http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
  390. // https://github.com/gnarf/jquery-requestAnimationFrame
  391. UI.utils.rAF = (function() {
  392. return window.requestAnimationFrame ||
  393. window.webkitRequestAnimationFrame ||
  394. window.mozRequestAnimationFrame ||
  395. window.oRequestAnimationFrame ||
  396. // if all else fails, use setTimeout
  397. function(callback) {
  398. return window.setTimeout(callback, 1000 / 60); // shoot for 60 fps
  399. };
  400. })();
  401. // handle multiple browsers for cancelAnimationFrame()
  402. UI.utils.cancelAF = (function() {
  403. return window.cancelAnimationFrame ||
  404. window.webkitCancelAnimationFrame ||
  405. window.mozCancelAnimationFrame ||
  406. window.oCancelAnimationFrame ||
  407. function(id) {
  408. window.clearTimeout(id);
  409. };
  410. })();
  411. // via http://davidwalsh.name/detect-scrollbar-width
  412. UI.utils.measureScrollbar = function() {
  413. if (document.body.clientWidth >= window.innerWidth) {
  414. return 0;
  415. }
  416. // if ($html.width() >= window.innerWidth) return;
  417. // var scrollbarWidth = window.innerWidth - $html.width();
  418. var $measure = $('<div ' +
  419. 'style="width: 100px;height: 100px;overflow: scroll;' +
  420. 'position: absolute;top: -9999px;"></div>');
  421. $(document.body).append($measure);
  422. var scrollbarWidth = $measure[0].offsetWidth - $measure[0].clientWidth;
  423. $measure.remove();
  424. return scrollbarWidth;
  425. };
  426. UI.utils.imageLoader = function($image, callback) {
  427. function loaded() {
  428. callback($image[0]);
  429. }
  430. function bindLoad() {
  431. this.one('load', loaded);
  432. if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
  433. var src = this.attr('src');
  434. var param = src.match(/\?/) ? '&' : '?';
  435. param += 'random=' + (new Date()).getTime();
  436. this.attr('src', src + param);
  437. }
  438. }
  439. if (!$image.attr('src')) {
  440. loaded();
  441. return;
  442. }
  443. if ($image[0].complete || $image[0].readyState === 4) {
  444. loaded();
  445. } else {
  446. bindLoad.call($image);
  447. }
  448. };
  449. /**
  450. * https://github.com/cho45/micro-template.js
  451. * (c) cho45 http://cho45.github.com/mit-license
  452. */
  453. /* jshint -W109 */
  454. UI.template = function(id, data) {
  455. var me = UI.template;
  456. if (!me.cache[id]) {
  457. me.cache[id] = (function() {
  458. var name = id;
  459. var string = /^[\w\-]+$/.test(id) ?
  460. me.get(id) : (name = 'template(string)', id); // no warnings
  461. var line = 1;
  462. var body = ('try { ' + (me.variable ?
  463. 'var ' + me.variable + ' = this.stash;' : 'with (this.stash) { ') +
  464. "this.ret += '" +
  465. string.
  466. replace(/<%/g, '\x11').replace(/%>/g, '\x13'). // if you want other tag, just edit this line
  467. replace(/'(?![^\x11\x13]+?\x13)/g, '\\x27').
  468. replace(/^\s*|\s*$/g, '').
  469. replace(/\n/g, function() {
  470. return "';\nthis.line = " + (++line) + "; this.ret += '\\n";
  471. }).
  472. replace(/\x11-(.+?)\x13/g, "' + ($1) + '").
  473. replace(/\x11=(.+?)\x13/g, "' + this.escapeHTML($1) + '").
  474. replace(/\x11(.+?)\x13/g, "'; $1; this.ret += '") +
  475. "'; " + (me.variable ? "" : "}") + "return this.ret;" +
  476. "} catch (e) { throw 'TemplateError: ' + e + ' (on " + name +
  477. "' + ' line ' + this.line + ')'; } " +
  478. "//@ sourceURL=" + name + "\n" // source map
  479. ).replace(/this\.ret \+= '';/g, '');
  480. /* jshint -W054 */
  481. var func = new Function(body);
  482. var map = {
  483. '&': '&amp;',
  484. '<': '&lt;',
  485. '>': '&gt;',
  486. '\x22': '&#x22;',
  487. '\x27': '&#x27;'
  488. };
  489. var escapeHTML = function(string) {
  490. return ('' + string).replace(/[&<>\'\"]/g, function(_) {
  491. return map[_];
  492. });
  493. };
  494. return function(stash) {
  495. return func.call(me.context = {
  496. escapeHTML: escapeHTML,
  497. line: 1,
  498. ret: '',
  499. stash: stash
  500. });
  501. };
  502. })();
  503. }
  504. return data ? me.cache[id](data) : me.cache[id];
  505. };
  506. /* jshint +W109 */
  507. /* jshint +W054 */
  508. UI.template.cache = {};
  509. UI.template.get = function(id) {
  510. if (id) {
  511. var element = document.getElementById(id);
  512. return element && element.innerHTML || '';
  513. }
  514. };
  515. // Dom mutation watchers
  516. UI.DOMWatchers = [];
  517. UI.DOMReady = false;
  518. UI.ready = function(callback) {
  519. UI.DOMWatchers.push(callback);
  520. if (UI.DOMReady) {
  521. // console.log('Ready call');
  522. callback(document);
  523. }
  524. };
  525. UI.DOMObserve = function(elements, options, callback) {
  526. var Observer = UI.support.mutationobserver;
  527. if (!Observer) {
  528. return;
  529. }
  530. options = $.isPlainObject(options) ?
  531. options : {childList: true, subtree: true};
  532. callback = typeof callback === 'function' && callback || function() {
  533. };
  534. $(elements).each(function() {
  535. var element = this;
  536. var $element = $(element);
  537. if ($element.data('am.observer')) {
  538. return;
  539. }
  540. try {
  541. var observer = new Observer(UI.utils.debounce(
  542. function(mutations, instance) {
  543. callback.call(element, mutations, instance);
  544. // trigger this event manually if MutationObserver not supported
  545. $element.trigger('changed.dom.amui');
  546. }, 50));
  547. observer.observe(element, options);
  548. $element.data('am.observer', observer);
  549. } catch (e) {
  550. }
  551. });
  552. };
  553. $.fn.DOMObserve = function(options, callback) {
  554. return this.each(function() {
  555. UI.DOMObserve(this, options, callback);
  556. });
  557. };
  558. if (UI.support.touch) {
  559. $html.addClass('am-touch');
  560. }
  561. $(document).on('changed.dom.amui', function(e) {
  562. var element = e.target;
  563. // TODO: just call changed element's watcher
  564. // every watcher callback should have a key
  565. // use like this: <div data-am-observe='key1, key2'>
  566. // get keys via $(element).data('amObserve')
  567. // call functions store with these keys
  568. $.each(UI.DOMWatchers, function(i, watcher) {
  569. watcher(element);
  570. });
  571. });
  572. $(function() {
  573. var $body = $('body');
  574. UI.DOMReady = true;
  575. // Run default init
  576. $.each(UI.DOMWatchers, function(i, watcher) {
  577. watcher(document);
  578. });
  579. // watches DOM
  580. UI.DOMObserve('[data-am-observe]');
  581. $html.removeClass('no-js').addClass('js');
  582. UI.support.animation && $html.addClass('cssanimations');
  583. // iOS standalone mode
  584. if (window.navigator.standalone) {
  585. $html.addClass('am-standalone');
  586. }
  587. $('.am-topbar-fixed-top').length &&
  588. $body.addClass('am-with-topbar-fixed-top');
  589. $('.am-topbar-fixed-bottom').length &&
  590. $body.addClass('am-with-topbar-fixed-bottom');
  591. // Remove responsive classes in .am-layout
  592. var $layout = $('.am-layout');
  593. $layout.find('[class*="md-block-grid"]').alterClass('md-block-grid-*');
  594. $layout.find('[class*="lg-block-grid"]').alterClass('lg-block-grid');
  595. // widgets not in .am-layout
  596. $('[data-am-widget]').each(function() {
  597. var $widget = $(this);
  598. // console.log($widget.parents('.am-layout').length)
  599. if ($widget.parents('.am-layout').length === 0) {
  600. $widget.addClass('am-no-layout');
  601. }
  602. });
  603. });
  604. module.exports = UI;
  605. /***/ },
  606. /* 3 */
  607. /***/ function(module, exports, __webpack_require__) {
  608. /*! Hammer.JS - v2.0.4 - 2014-09-28
  609. * http://hammerjs.github.io/
  610. *
  611. * Copyright (c) 2014 Jorik Tangelder;
  612. * Licensed under the MIT license */
  613. 'use strict';
  614. var $ = __webpack_require__(1);
  615. var UI = __webpack_require__(2);
  616. var VENDOR_PREFIXES = ['', 'webkit', 'moz', 'MS', 'ms', 'o'];
  617. var TEST_ELEMENT = document.createElement('div');
  618. var TYPE_FUNCTION = 'function';
  619. var round = Math.round;
  620. var abs = Math.abs;
  621. var now = Date.now;
  622. /**
  623. * set a timeout with a given scope
  624. * @param {Function} fn
  625. * @param {Number} timeout
  626. * @param {Object} context
  627. * @returns {number}
  628. */
  629. function setTimeoutContext(fn, timeout, context) {
  630. return setTimeout(bindFn(fn, context), timeout);
  631. }
  632. /**
  633. * if the argument is an array, we want to execute the fn on each entry
  634. * if it aint an array we don't want to do a thing.
  635. * this is used by all the methods that accept a single and array argument.
  636. * @param {*|Array} arg
  637. * @param {String} fn
  638. * @param {Object} [context]
  639. * @returns {Boolean}
  640. */
  641. function invokeArrayArg(arg, fn, context) {
  642. if (Array.isArray(arg)) {
  643. each(arg, context[fn], context);
  644. return true;
  645. }
  646. return false;
  647. }
  648. /**
  649. * walk objects and arrays
  650. * @param {Object} obj
  651. * @param {Function} iterator
  652. * @param {Object} context
  653. */
  654. function each(obj, iterator, context) {
  655. var i;
  656. if (!obj) {
  657. return;
  658. }
  659. if (obj.forEach) {
  660. obj.forEach(iterator, context);
  661. } else if (obj.length !== undefined) {
  662. i = 0;
  663. while (i < obj.length) {
  664. iterator.call(context, obj[i], i, obj);
  665. i++;
  666. }
  667. } else {
  668. for (i in obj) {
  669. obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
  670. }
  671. }
  672. }
  673. /**
  674. * extend object.
  675. * means that properties in dest will be overwritten by the ones in src.
  676. * @param {Object} dest
  677. * @param {Object} src
  678. * @param {Boolean} [merge]
  679. * @returns {Object} dest
  680. */
  681. function extend(dest, src, merge) {
  682. var keys = Object.keys(src);
  683. var i = 0;
  684. while (i < keys.length) {
  685. if (!merge || (merge && dest[keys[i]] === undefined)) {
  686. dest[keys[i]] = src[keys[i]];
  687. }
  688. i++;
  689. }
  690. return dest;
  691. }
  692. /**
  693. * merge the values from src in the dest.
  694. * means that properties that exist in dest will not be overwritten by src
  695. * @param {Object} dest
  696. * @param {Object} src
  697. * @returns {Object} dest
  698. */
  699. function merge(dest, src) {
  700. return extend(dest, src, true);
  701. }
  702. /**
  703. * simple class inheritance
  704. * @param {Function} child
  705. * @param {Function} base
  706. * @param {Object} [properties]
  707. */
  708. function inherit(child, base, properties) {
  709. var baseP = base.prototype,
  710. childP;
  711. childP = child.prototype = Object.create(baseP);
  712. childP.constructor = child;
  713. childP._super = baseP;
  714. if (properties) {
  715. extend(childP, properties);
  716. }
  717. }
  718. /**
  719. * simple function bind
  720. * @param {Function} fn
  721. * @param {Object} context
  722. * @returns {Function}
  723. */
  724. function bindFn(fn, context) {
  725. return function boundFn() {
  726. return fn.apply(context, arguments);
  727. };
  728. }
  729. /**
  730. * let a boolean value also be a function that must return a boolean
  731. * this first item in args will be used as the context
  732. * @param {Boolean|Function} val
  733. * @param {Array} [args]
  734. * @returns {Boolean}
  735. */
  736. function boolOrFn(val, args) {
  737. if (typeof val == TYPE_FUNCTION) {
  738. return val.apply(args ? args[0] || undefined : undefined, args);
  739. }
  740. return val;
  741. }
  742. /**
  743. * use the val2 when val1 is undefined
  744. * @param {*} val1
  745. * @param {*} val2
  746. * @returns {*}
  747. */
  748. function ifUndefined(val1, val2) {
  749. return (val1 === undefined) ? val2 : val1;
  750. }
  751. /**
  752. * addEventListener with multiple events at once
  753. * @param {EventTarget} target
  754. * @param {String} types
  755. * @param {Function} handler
  756. */
  757. function addEventListeners(target, types, handler) {
  758. each(splitStr(types), function(type) {
  759. target.addEventListener(type, handler, false);
  760. });
  761. }
  762. /**
  763. * removeEventListener with multiple events at once
  764. * @param {EventTarget} target
  765. * @param {String} types
  766. * @param {Function} handler
  767. */
  768. function removeEventListeners(target, types, handler) {
  769. each(splitStr(types), function(type) {
  770. target.removeEventListener(type, handler, false);
  771. });
  772. }
  773. /**
  774. * find if a node is in the given parent
  775. * @method hasParent
  776. * @param {HTMLElement} node
  777. * @param {HTMLElement} parent
  778. * @return {Boolean} found
  779. */
  780. function hasParent(node, parent) {
  781. while (node) {
  782. if (node == parent) {
  783. return true;
  784. }
  785. node = node.parentNode;
  786. }
  787. return false;
  788. }
  789. /**
  790. * small indexOf wrapper
  791. * @param {String} str
  792. * @param {String} find
  793. * @returns {Boolean} found
  794. */
  795. function inStr(str, find) {
  796. return str.indexOf(find) > -1;
  797. }
  798. /**
  799. * split string on whitespace
  800. * @param {String} str
  801. * @returns {Array} words
  802. */
  803. function splitStr(str) {
  804. return str.trim().split(/\s+/g);
  805. }
  806. /**
  807. * find if a array contains the object using indexOf or a simple polyFill
  808. * @param {Array} src
  809. * @param {String} find
  810. * @param {String} [findByKey]
  811. * @return {Boolean|Number} false when not found, or the index
  812. */
  813. function inArray(src, find, findByKey) {
  814. if (src.indexOf && !findByKey) {
  815. return src.indexOf(find);
  816. } else {
  817. var i = 0;
  818. while (i < src.length) {
  819. if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
  820. return i;
  821. }
  822. i++;
  823. }
  824. return -1;
  825. }
  826. }
  827. /**
  828. * convert array-like objects to real arrays
  829. * @param {Object} obj
  830. * @returns {Array}
  831. */
  832. function toArray(obj) {
  833. return Array.prototype.slice.call(obj, 0);
  834. }
  835. /**
  836. * unique array with objects based on a key (like 'id') or just by the array's value
  837. * @param {Array} src [{id:1},{id:2},{id:1}]
  838. * @param {String} [key]
  839. * @param {Boolean} [sort=False]
  840. * @returns {Array} [{id:1},{id:2}]
  841. */
  842. function uniqueArray(src, key, sort) {
  843. var results = [];
  844. var values = [];
  845. var i = 0;
  846. while (i < src.length) {
  847. var val = key ? src[i][key] : src[i];
  848. if (inArray(values, val) < 0) {
  849. results.push(src[i]);
  850. }
  851. values[i] = val;
  852. i++;
  853. }
  854. if (sort) {
  855. if (!key) {
  856. results = results.sort();
  857. } else {
  858. results = results.sort(function sortUniqueArray(a, b) {
  859. return a[key] > b[key];
  860. });
  861. }
  862. }
  863. return results;
  864. }
  865. /**
  866. * get the prefixed property
  867. * @param {Object} obj
  868. * @param {String} property
  869. * @returns {String|Undefined} prefixed
  870. */
  871. function prefixed(obj, property) {
  872. var prefix, prop;
  873. var camelProp = property[0].toUpperCase() + property.slice(1);
  874. var i = 0;
  875. while (i < VENDOR_PREFIXES.length) {
  876. prefix = VENDOR_PREFIXES[i];
  877. prop = (prefix) ? prefix + camelProp : property;
  878. if (prop in obj) {
  879. return prop;
  880. }
  881. i++;
  882. }
  883. return undefined;
  884. }
  885. /**
  886. * get a unique id
  887. * @returns {number} uniqueId
  888. */
  889. var _uniqueId = 1;
  890. function uniqueId() {
  891. return _uniqueId++;
  892. }
  893. /**
  894. * get the window object of an element
  895. * @param {HTMLElement} element
  896. * @returns {DocumentView|Window}
  897. */
  898. function getWindowForElement(element) {
  899. var doc = element.ownerDocument;
  900. return (doc.defaultView || doc.parentWindow);
  901. }
  902. var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
  903. var SUPPORT_TOUCH = ('ontouchstart' in window);
  904. var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
  905. var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
  906. var INPUT_TYPE_TOUCH = 'touch';
  907. var INPUT_TYPE_PEN = 'pen';
  908. var INPUT_TYPE_MOUSE = 'mouse';
  909. var INPUT_TYPE_KINECT = 'kinect';
  910. var COMPUTE_INTERVAL = 25;
  911. var INPUT_START = 1;
  912. var INPUT_MOVE = 2;
  913. var INPUT_END = 4;
  914. var INPUT_CANCEL = 8;
  915. var DIRECTION_NONE = 1;
  916. var DIRECTION_LEFT = 2;
  917. var DIRECTION_RIGHT = 4;
  918. var DIRECTION_UP = 8;
  919. var DIRECTION_DOWN = 16;
  920. var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
  921. var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
  922. var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
  923. var PROPS_XY = ['x', 'y'];
  924. var PROPS_CLIENT_XY = ['clientX', 'clientY'];
  925. /**
  926. * create new input type manager
  927. * @param {Manager} manager
  928. * @param {Function} callback
  929. * @returns {Input}
  930. * @constructor
  931. */
  932. function Input(manager, callback) {
  933. var self = this;
  934. this.manager = manager;
  935. this.callback = callback;
  936. this.element = manager.element;
  937. this.target = manager.options.inputTarget;
  938. // smaller wrapper around the handler, for the scope and the enabled state of the manager,
  939. // so when disabled the input events are completely bypassed.
  940. this.domHandler = function(ev) {
  941. if (boolOrFn(manager.options.enable, [manager])) {
  942. self.handler(ev);
  943. }
  944. };
  945. this.init();
  946. }
  947. Input.prototype = {
  948. /**
  949. * should handle the inputEvent data and trigger the callback
  950. * @virtual
  951. */
  952. handler: function() {
  953. },
  954. /**
  955. * bind the events
  956. */
  957. init: function() {
  958. this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
  959. this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
  960. this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
  961. },
  962. /**
  963. * unbind the events
  964. */
  965. destroy: function() {
  966. this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
  967. this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
  968. this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
  969. }
  970. };
  971. /**
  972. * create new input type manager
  973. * called by the Manager constructor
  974. * @param {Hammer} manager
  975. * @returns {Input}
  976. */
  977. function createInputInstance(manager) {
  978. var Type;
  979. var inputClass = manager.options.inputClass;
  980. if (inputClass) {
  981. Type = inputClass;
  982. } else if (SUPPORT_POINTER_EVENTS) {
  983. Type = PointerEventInput;
  984. } else if (SUPPORT_ONLY_TOUCH) {
  985. Type = TouchInput;
  986. } else if (!SUPPORT_TOUCH) {
  987. Type = MouseInput;
  988. } else {
  989. Type = TouchMouseInput;
  990. }
  991. return new (Type)(manager, inputHandler);
  992. }
  993. /**
  994. * handle input events
  995. * @param {Manager} manager
  996. * @param {String} eventType
  997. * @param {Object} input
  998. */
  999. function inputHandler(manager, eventType, input) {
  1000. var pointersLen = input.pointers.length;
  1001. var changedPointersLen = input.changedPointers.length;
  1002. var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
  1003. var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0));
  1004. input.isFirst = !!isFirst;
  1005. input.isFinal = !!isFinal;
  1006. if (isFirst) {
  1007. manager.session = {};
  1008. }
  1009. // source event is the normalized value of the domEvents
  1010. // like 'touchstart, mouseup, pointerdown'
  1011. input.eventType = eventType;
  1012. // compute scale, rotation etc
  1013. computeInputData(manager, input);
  1014. // emit secret event
  1015. manager.emit('hammer.input', input);
  1016. manager.recognize(input);
  1017. manager.session.prevInput = input;
  1018. }
  1019. /**
  1020. * extend the data with some usable properties like scale, rotate, velocity etc
  1021. * @param {Object} manager
  1022. * @param {Object} input
  1023. */
  1024. function computeInputData(manager, input) {
  1025. var session = manager.session;
  1026. var pointers = input.pointers;
  1027. var pointersLength = pointers.length;
  1028. // store the first input to calculate the distance and direction
  1029. if (!session.firstInput) {
  1030. session.firstInput = simpleCloneInputData(input);
  1031. }
  1032. // to compute scale and rotation we need to store the multiple touches
  1033. if (pointersLength > 1 && !session.firstMultiple) {
  1034. session.firstMultiple = simpleCloneInputData(input);
  1035. } else if (pointersLength === 1) {
  1036. session.firstMultiple = false;
  1037. }
  1038. var firstInput = session.firstInput;
  1039. var firstMultiple = session.firstMultiple;
  1040. var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
  1041. var center = input.center = getCenter(pointers);
  1042. input.timeStamp = now();
  1043. input.deltaTime = input.timeStamp - firstInput.timeStamp;
  1044. input.angle = getAngle(offsetCenter, center);
  1045. input.distance = getDistance(offsetCenter, center);
  1046. computeDeltaXY(session, input);
  1047. input.offsetDirection = getDirection(input.deltaX, input.deltaY);
  1048. input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
  1049. input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
  1050. computeIntervalInputData(session, input);
  1051. // find the correct target
  1052. var target = manager.element;
  1053. if (hasParent(input.srcEvent.target, target)) {
  1054. target = input.srcEvent.target;
  1055. }
  1056. input.target = target;
  1057. }
  1058. function computeDeltaXY(session, input) {
  1059. var center = input.center;
  1060. var offset = session.offsetDelta || {};
  1061. var prevDelta = session.prevDelta || {};
  1062. var prevInput = session.prevInput || {};
  1063. if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
  1064. prevDelta = session.prevDelta = {
  1065. x: prevInput.deltaX || 0,
  1066. y: prevInput.deltaY || 0
  1067. };
  1068. offset = session.offsetDelta = {
  1069. x: center.x,
  1070. y: center.y
  1071. };
  1072. }
  1073. input.deltaX = prevDelta.x + (center.x - offset.x);
  1074. input.deltaY = prevDelta.y + (center.y - offset.y);
  1075. }
  1076. /**
  1077. * velocity is calculated every x ms
  1078. * @param {Object} session
  1079. * @param {Object} input
  1080. */
  1081. function computeIntervalInputData(session, input) {
  1082. var last = session.lastInterval || input,
  1083. deltaTime = input.timeStamp - last.timeStamp,
  1084. velocity, velocityX, velocityY, direction;
  1085. if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
  1086. var deltaX = last.deltaX - input.deltaX;
  1087. var deltaY = last.deltaY - input.deltaY;
  1088. var v = getVelocity(deltaTime, deltaX, deltaY);
  1089. velocityX = v.x;
  1090. velocityY = v.y;
  1091. velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
  1092. direction = getDirection(deltaX, deltaY);
  1093. session.lastInterval = input;
  1094. } else {
  1095. // use latest velocity info if it doesn't overtake a minimum period
  1096. velocity = last.velocity;
  1097. velocityX = last.velocityX;
  1098. velocityY = last.velocityY;
  1099. direction = last.direction;
  1100. }
  1101. input.velocity = velocity;
  1102. input.velocityX = velocityX;
  1103. input.velocityY = velocityY;
  1104. input.direction = direction;
  1105. }
  1106. /**
  1107. * create a simple clone from the input used for storage of firstInput and firstMultiple
  1108. * @param {Object} input
  1109. * @returns {Object} clonedInputData
  1110. */
  1111. function simpleCloneInputData(input) {
  1112. // make a simple copy of the pointers because we will get a reference if we don't
  1113. // we only need clientXY for the calculations
  1114. var pointers = [];
  1115. var i = 0;
  1116. while (i < input.pointers.length) {
  1117. pointers[i] = {
  1118. clientX: round(input.pointers[i].clientX),
  1119. clientY: round(input.pointers[i].clientY)
  1120. };
  1121. i++;
  1122. }
  1123. return {
  1124. timeStamp: now(),
  1125. pointers: pointers,
  1126. center: getCenter(pointers),
  1127. deltaX: input.deltaX,
  1128. deltaY: input.deltaY
  1129. };
  1130. }
  1131. /**
  1132. * get the center of all the pointers
  1133. * @param {Array} pointers
  1134. * @return {Object} center contains `x` and `y` properties
  1135. */
  1136. function getCenter(pointers) {
  1137. var pointersLength = pointers.length;
  1138. // no need to loop when only one touch
  1139. if (pointersLength === 1) {
  1140. return {
  1141. x: round(pointers[0].clientX),
  1142. y: round(pointers[0].clientY)
  1143. };
  1144. }
  1145. var x = 0, y = 0, i = 0;
  1146. while (i < pointersLength) {
  1147. x += pointers[i].clientX;
  1148. y += pointers[i].clientY;
  1149. i++;
  1150. }
  1151. return {
  1152. x: round(x / pointersLength),
  1153. y: round(y / pointersLength)
  1154. };
  1155. }
  1156. /**
  1157. * calculate the velocity between two points. unit is in px per ms.
  1158. * @param {Number} deltaTime
  1159. * @param {Number} x
  1160. * @param {Number} y
  1161. * @return {Object} velocity `x` and `y`
  1162. */
  1163. function getVelocity(deltaTime, x, y) {
  1164. return {
  1165. x: x / deltaTime || 0,
  1166. y: y / deltaTime || 0
  1167. };
  1168. }
  1169. /**
  1170. * get the direction between two points
  1171. * @param {Number} x
  1172. * @param {Number} y
  1173. * @return {Number} direction
  1174. */
  1175. function getDirection(x, y) {
  1176. if (x === y) {
  1177. return DIRECTION_NONE;
  1178. }
  1179. if (abs(x) >= abs(y)) {
  1180. return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
  1181. }
  1182. return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
  1183. }
  1184. /**
  1185. * calculate the absolute distance between two points
  1186. * @param {Object} p1 {x, y}
  1187. * @param {Object} p2 {x, y}
  1188. * @param {Array} [props] containing x and y keys
  1189. * @return {Number} distance
  1190. */
  1191. function getDistance(p1, p2, props) {
  1192. if (!props) {
  1193. props = PROPS_XY;
  1194. }
  1195. var x = p2[props[0]] - p1[props[0]],
  1196. y = p2[props[1]] - p1[props[1]];
  1197. return Math.sqrt((x * x) + (y * y));
  1198. }
  1199. /**
  1200. * calculate the angle between two coordinates
  1201. * @param {Object} p1
  1202. * @param {Object} p2
  1203. * @param {Array} [props] containing x and y keys
  1204. * @return {Number} angle
  1205. */
  1206. function getAngle(p1, p2, props) {
  1207. if (!props) {
  1208. props = PROPS_XY;
  1209. }
  1210. var x = p2[props[0]] - p1[props[0]],
  1211. y = p2[props[1]] - p1[props[1]];
  1212. return Math.atan2(y, x) * 180 / Math.PI;
  1213. }
  1214. /**
  1215. * calculate the rotation degrees between two pointersets
  1216. * @param {Array} start array of pointers
  1217. * @param {Array} end array of pointers
  1218. * @return {Number} rotation
  1219. */
  1220. function getRotation(start, end) {
  1221. return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
  1222. }
  1223. /**
  1224. * calculate the scale factor between two pointersets
  1225. * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
  1226. * @param {Array} start array of pointers
  1227. * @param {Array} end array of pointers
  1228. * @return {Number} scale
  1229. */
  1230. function getScale(start, end) {
  1231. return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
  1232. }
  1233. var MOUSE_INPUT_MAP = {
  1234. mousedown: INPUT_START,
  1235. mousemove: INPUT_MOVE,
  1236. mouseup: INPUT_END
  1237. };
  1238. var MOUSE_ELEMENT_EVENTS = 'mousedown';
  1239. var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
  1240. /**
  1241. * Mouse events input
  1242. * @constructor
  1243. * @extends Input
  1244. */
  1245. function MouseInput() {
  1246. this.evEl = MOUSE_ELEMENT_EVENTS;
  1247. this.evWin = MOUSE_WINDOW_EVENTS;
  1248. this.allow = true; // used by Input.TouchMouse to disable mouse events
  1249. this.pressed = false; // mousedown state
  1250. Input.apply(this, arguments);
  1251. }
  1252. inherit(MouseInput, Input, {
  1253. /**
  1254. * handle mouse events
  1255. * @param {Object} ev
  1256. */
  1257. handler: function MEhandler(ev) {
  1258. var eventType = MOUSE_INPUT_MAP[ev.type];
  1259. // on start we want to have the left mouse button down
  1260. if (eventType & INPUT_START && ev.button === 0) {
  1261. this.pressed = true;
  1262. }
  1263. if (eventType & INPUT_MOVE && ev.which !== 1) {
  1264. eventType = INPUT_END;
  1265. }
  1266. // mouse must be down, and mouse events are allowed (see the TouchMouse input)
  1267. if (!this.pressed || !this.allow) {
  1268. return;
  1269. }
  1270. if (eventType & INPUT_END) {
  1271. this.pressed = false;
  1272. }
  1273. this.callback(this.manager, eventType, {
  1274. pointers: [ev],
  1275. changedPointers: [ev],
  1276. pointerType: INPUT_TYPE_MOUSE,
  1277. srcEvent: ev
  1278. });
  1279. }
  1280. });
  1281. var POINTER_INPUT_MAP = {
  1282. pointerdown: INPUT_START,
  1283. pointermove: INPUT_MOVE,
  1284. pointerup: INPUT_END,
  1285. pointercancel: INPUT_CANCEL,
  1286. pointerout: INPUT_CANCEL
  1287. };
  1288. // in IE10 the pointer types is defined as an enum
  1289. var IE10_POINTER_TYPE_ENUM = {
  1290. 2: INPUT_TYPE_TOUCH,
  1291. 3: INPUT_TYPE_PEN,
  1292. 4: INPUT_TYPE_MOUSE,
  1293. 5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
  1294. };
  1295. var POINTER_ELEMENT_EVENTS = 'pointerdown';
  1296. var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
  1297. // IE10 has prefixed support, and case-sensitive
  1298. if (window.MSPointerEvent) {
  1299. POINTER_ELEMENT_EVENTS = 'MSPointerDown';
  1300. POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
  1301. }
  1302. /**
  1303. * Pointer events input
  1304. * @constructor
  1305. * @extends Input
  1306. */
  1307. function PointerEventInput() {
  1308. this.evEl = POINTER_ELEMENT_EVENTS;
  1309. this.evWin = POINTER_WINDOW_EVENTS;
  1310. Input.apply(this, arguments);
  1311. this.store = (this.manager.session.pointerEvents = []);
  1312. }
  1313. inherit(PointerEventInput, Input, {
  1314. /**
  1315. * handle mouse events
  1316. * @param {Object} ev
  1317. */
  1318. handler: function PEhandler(ev) {
  1319. var store = this.store;
  1320. var removePointer = false;
  1321. var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
  1322. var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
  1323. var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
  1324. var isTouch = (pointerType == INPUT_TYPE_TOUCH);
  1325. // get index of the event in the store
  1326. var storeIndex = inArray(store, ev.pointerId, 'pointerId');
  1327. // start and mouse must be down
  1328. if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
  1329. if (storeIndex < 0) {
  1330. store.push(ev);
  1331. storeIndex = store.length - 1;
  1332. }
  1333. } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
  1334. removePointer = true;
  1335. }
  1336. // it not found, so the pointer hasn't been down (so it's probably a hover)
  1337. if (storeIndex < 0) {
  1338. return;
  1339. }
  1340. // update the event in the store
  1341. store[storeIndex] = ev;
  1342. this.callback(this.manager, eventType, {
  1343. pointers: store,
  1344. changedPointers: [ev],
  1345. pointerType: pointerType,
  1346. srcEvent: ev
  1347. });
  1348. if (removePointer) {
  1349. // remove from the store
  1350. store.splice(storeIndex, 1);
  1351. }
  1352. }
  1353. });
  1354. var SINGLE_TOUCH_INPUT_MAP = {
  1355. touchstart: INPUT_START,
  1356. touchmove: INPUT_MOVE,
  1357. touchend: INPUT_END,
  1358. touchcancel: INPUT_CANCEL
  1359. };
  1360. var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
  1361. var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
  1362. /**
  1363. * Touch events input
  1364. * @constructor
  1365. * @extends Input
  1366. */
  1367. function SingleTouchInput() {
  1368. this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
  1369. this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
  1370. this.started = false;
  1371. Input.apply(this, arguments);
  1372. }
  1373. inherit(SingleTouchInput, Input, {
  1374. handler: function TEhandler(ev) {
  1375. var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
  1376. // should we handle the touch events?
  1377. if (type === INPUT_START) {
  1378. this.started = true;
  1379. }
  1380. if (!this.started) {
  1381. return;
  1382. }
  1383. var touches = normalizeSingleTouches.call(this, ev, type);
  1384. // when done, reset the started state
  1385. if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
  1386. this.started = false;
  1387. }
  1388. this.callback(this.manager, type, {
  1389. pointers: touches[0],
  1390. changedPointers: touches[1],
  1391. pointerType: INPUT_TYPE_TOUCH,
  1392. srcEvent: ev
  1393. });
  1394. }
  1395. });
  1396. /**
  1397. * @this {TouchInput}
  1398. * @param {Object} ev
  1399. * @param {Number} type flag
  1400. * @returns {undefined|Array} [all, changed]
  1401. */
  1402. function normalizeSingleTouches(ev, type) {
  1403. var all = toArray(ev.touches);
  1404. var changed = toArray(ev.changedTouches);
  1405. if (type & (INPUT_END | INPUT_CANCEL)) {
  1406. all = uniqueArray(all.concat(changed), 'identifier', true);
  1407. }
  1408. return [all, changed];
  1409. }
  1410. var TOUCH_INPUT_MAP = {
  1411. touchstart: INPUT_START,
  1412. touchmove: INPUT_MOVE,
  1413. touchend: INPUT_END,
  1414. touchcancel: INPUT_CANCEL
  1415. };
  1416. var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
  1417. /**
  1418. * Multi-user touch events input
  1419. * @constructor
  1420. * @extends Input
  1421. */
  1422. function TouchInput() {
  1423. this.evTarget = TOUCH_TARGET_EVENTS;
  1424. this.targetIds = {};
  1425. Input.apply(this, arguments);
  1426. }
  1427. inherit(TouchInput, Input, {
  1428. handler: function MTEhandler(ev) {
  1429. var type = TOUCH_INPUT_MAP[ev.type];
  1430. var touches = getTouches.call(this, ev, type);
  1431. if (!touches) {
  1432. return;
  1433. }
  1434. this.callback(this.manager, type, {
  1435. pointers: touches[0],
  1436. changedPointers: touches[1],
  1437. pointerType: INPUT_TYPE_TOUCH,
  1438. srcEvent: ev
  1439. });
  1440. }
  1441. });
  1442. /**
  1443. * @this {TouchInput}
  1444. * @param {Object} ev
  1445. * @param {Number} type flag
  1446. * @returns {undefined|Array} [all, changed]
  1447. */
  1448. function getTouches(ev, type) {
  1449. var allTouches = toArray(ev.touches);
  1450. var targetIds = this.targetIds;
  1451. // when there is only one touch, the process can be simplified
  1452. if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
  1453. targetIds[allTouches[0].identifier] = true;
  1454. return [allTouches, allTouches];
  1455. }
  1456. var i,
  1457. targetTouches,
  1458. changedTouches = toArray(ev.changedTouches),
  1459. changedTargetTouches = [],
  1460. target = this.target;
  1461. // get target touches from touches
  1462. targetTouches = allTouches.filter(function(touch) {
  1463. return hasParent(touch.target, target);
  1464. });
  1465. // collect touches
  1466. if (type === INPUT_START) {
  1467. i = 0;
  1468. while (i < targetTouches.length) {
  1469. targetIds[targetTouches[i].identifier] = true;
  1470. i++;
  1471. }
  1472. }
  1473. // filter changed touches to only contain touches that exist in the collected target ids
  1474. i = 0;
  1475. while (i < changedTouches.length) {
  1476. if (targetIds[changedTouches[i].identifier]) {
  1477. changedTargetTouches.push(changedTouches[i]);
  1478. }
  1479. // cleanup removed touches
  1480. if (type & (INPUT_END | INPUT_CANCEL)) {
  1481. delete targetIds[changedTouches[i].identifier];
  1482. }
  1483. i++;
  1484. }
  1485. if (!changedTargetTouches.length) {
  1486. return;
  1487. }
  1488. return [
  1489. // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
  1490. uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
  1491. changedTargetTouches
  1492. ];
  1493. }
  1494. /**
  1495. * Combined touch and mouse input
  1496. *
  1497. * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
  1498. * This because touch devices also emit mouse events while doing a touch.
  1499. *
  1500. * @constructor
  1501. * @extends Input
  1502. */
  1503. function TouchMouseInput() {
  1504. Input.apply(this, arguments);
  1505. var handler = bindFn(this.handler, this);
  1506. this.touch = new TouchInput(this.manager, handler);
  1507. this.mouse = new MouseInput(this.manager, handler);
  1508. }
  1509. inherit(TouchMouseInput, Input, {
  1510. /**
  1511. * handle mouse and touch events
  1512. * @param {Hammer} manager
  1513. * @param {String} inputEvent
  1514. * @param {Object} inputData
  1515. */
  1516. handler: function TMEhandler(manager, inputEvent, inputData) {
  1517. var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
  1518. isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
  1519. // when we're in a touch event, so block all upcoming mouse events
  1520. // most mobile browser also emit mouseevents, right after touchstart
  1521. if (isTouch) {
  1522. this.mouse.allow = false;
  1523. } else if (isMouse && !this.mouse.allow) {
  1524. return;
  1525. }
  1526. // reset the allowMouse when we're done
  1527. if (inputEvent & (INPUT_END | INPUT_CANCEL)) {
  1528. this.mouse.allow = true;
  1529. }
  1530. this.callback(manager, inputEvent, inputData);
  1531. },
  1532. /**
  1533. * remove the event listeners
  1534. */
  1535. destroy: function destroy() {
  1536. this.touch.destroy();
  1537. this.mouse.destroy();
  1538. }
  1539. });
  1540. var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
  1541. var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
  1542. // magical touchAction value
  1543. var TOUCH_ACTION_COMPUTE = 'compute';
  1544. var TOUCH_ACTION_AUTO = 'auto';
  1545. var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
  1546. var TOUCH_ACTION_NONE = 'none';
  1547. var TOUCH_ACTION_PAN_X = 'pan-x';
  1548. var TOUCH_ACTION_PAN_Y = 'pan-y';
  1549. /**
  1550. * Touch Action
  1551. * sets the touchAction property or uses the js alternative
  1552. * @param {Manager} manager
  1553. * @param {String} value
  1554. * @constructor
  1555. */
  1556. function TouchAction(manager, value) {
  1557. this.manager = manager;
  1558. this.set(value);
  1559. }
  1560. TouchAction.prototype = {
  1561. /**
  1562. * set the touchAction value on the element or enable the polyfill
  1563. * @param {String} value
  1564. */
  1565. set: function(value) {
  1566. // find out the touch-action by the event handlers
  1567. if (value == TOUCH_ACTION_COMPUTE) {
  1568. value = this.compute();
  1569. }
  1570. if (NATIVE_TOUCH_ACTION) {
  1571. this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
  1572. }
  1573. this.actions = value.toLowerCase().trim();
  1574. },
  1575. /**
  1576. * just re-set the touchAction value
  1577. */
  1578. update: function() {
  1579. this.set(this.manager.options.touchAction);
  1580. },
  1581. /**
  1582. * compute the value for the touchAction property based on the recognizer's settings
  1583. * @returns {String} value
  1584. */
  1585. compute: function() {
  1586. var actions = [];
  1587. each(this.manager.recognizers, function(recognizer) {
  1588. if (boolOrFn(recognizer.options.enable, [recognizer])) {
  1589. actions = actions.concat(recognizer.getTouchAction());
  1590. }
  1591. });
  1592. return cleanTouchActions(actions.join(' '));
  1593. },
  1594. /**
  1595. * this method is called on each input cycle and provides the preventing of the browser behavior
  1596. * @param {Object} input
  1597. */
  1598. preventDefaults: function(input) {
  1599. // not needed with native support for the touchAction property
  1600. if (NATIVE_TOUCH_ACTION) {
  1601. return;
  1602. }
  1603. var srcEvent = input.srcEvent;
  1604. var direction = input.offsetDirection;
  1605. // if the touch action did prevented once this session
  1606. if (this.manager.session.prevented) {
  1607. srcEvent.preventDefault();
  1608. return;
  1609. }
  1610. var actions = this.actions;
  1611. var hasNone = inStr(actions, TOUCH_ACTION_NONE);
  1612. var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
  1613. var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
  1614. if (hasNone ||
  1615. (hasPanY && direction & DIRECTION_HORIZONTAL) ||
  1616. (hasPanX && direction & DIRECTION_VERTICAL)) {
  1617. return this.preventSrc(srcEvent);
  1618. }
  1619. },
  1620. /**
  1621. * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
  1622. * @param {Object} srcEvent
  1623. */
  1624. preventSrc: function(srcEvent) {
  1625. this.manager.session.prevented = true;
  1626. srcEvent.preventDefault();
  1627. }
  1628. };
  1629. /**
  1630. * when the touchActions are collected they are not a valid value, so we need to clean things up. *
  1631. * @param {String} actions
  1632. * @returns {*}
  1633. */
  1634. function cleanTouchActions(actions) {
  1635. // none
  1636. if (inStr(actions, TOUCH_ACTION_NONE)) {
  1637. return TOUCH_ACTION_NONE;
  1638. }
  1639. var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
  1640. var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
  1641. // pan-x and pan-y can be combined
  1642. if (hasPanX && hasPanY) {
  1643. return TOUCH_ACTION_PAN_X + ' ' + TOUCH_ACTION_PAN_Y;
  1644. }
  1645. // pan-x OR pan-y
  1646. if (hasPanX || hasPanY) {
  1647. return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
  1648. }
  1649. // manipulation
  1650. if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
  1651. return TOUCH_ACTION_MANIPULATION;
  1652. }
  1653. return TOUCH_ACTION_AUTO;
  1654. }
  1655. /**
  1656. * Recognizer flow explained; *
  1657. * All recognizers have the initial state of POSSIBLE when a input session starts.
  1658. * The definition of a input session is from the first input until the last input, with all it's movement in it. *
  1659. * Example session for mouse-input: mousedown -> mousemove -> mouseup
  1660. *
  1661. * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
  1662. * which determines with state it should be.
  1663. *
  1664. * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
  1665. * POSSIBLE to give it another change on the next cycle.
  1666. *
  1667. * Possible
  1668. * |
  1669. * +-----+---------------+
  1670. * | |
  1671. * +-----+-----+ |
  1672. * | | |
  1673. * Failed Cancelled |
  1674. * +-------+------+
  1675. * | |
  1676. * Recognized Began
  1677. * |
  1678. * Changed
  1679. * |
  1680. * Ended/Recognized
  1681. */
  1682. var STATE_POSSIBLE = 1;
  1683. var STATE_BEGAN = 2;
  1684. var STATE_CHANGED = 4;
  1685. var STATE_ENDED = 8;
  1686. var STATE_RECOGNIZED = STATE_ENDED;
  1687. var STATE_CANCELLED = 16;
  1688. var STATE_FAILED = 32;
  1689. /**
  1690. * Recognizer
  1691. * Every recognizer needs to extend from this class.
  1692. * @constructor
  1693. * @param {Object} options
  1694. */
  1695. function Recognizer(options) {
  1696. this.id = uniqueId();
  1697. this.manager = null;
  1698. this.options = merge(options || {}, this.defaults);
  1699. // default is enable true
  1700. this.options.enable = ifUndefined(this.options.enable, true);
  1701. this.state = STATE_POSSIBLE;
  1702. this.simultaneous = {};
  1703. this.requireFail = [];
  1704. }
  1705. Recognizer.prototype = {
  1706. /**
  1707. * @virtual
  1708. * @type {Object}
  1709. */
  1710. defaults: {},
  1711. /**
  1712. * set options
  1713. * @param {Object} options
  1714. * @return {Recognizer}
  1715. */
  1716. set: function(options) {
  1717. extend(this.options, options);
  1718. // also update the touchAction, in case something changed about the directions/enabled state
  1719. this.manager && this.manager.touchAction.update();
  1720. return this;
  1721. },
  1722. /**
  1723. * recognize simultaneous with an other recognizer.
  1724. * @param {Recognizer} otherRecognizer
  1725. * @returns {Recognizer} this
  1726. */
  1727. recognizeWith: function(otherRecognizer) {
  1728. if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
  1729. return this;
  1730. }
  1731. var simultaneous = this.simultaneous;
  1732. otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
  1733. if (!simultaneous[otherRecognizer.id]) {
  1734. simultaneous[otherRecognizer.id] = otherRecognizer;
  1735. otherRecognizer.recognizeWith(this);
  1736. }
  1737. return this;
  1738. },
  1739. /**
  1740. * drop the simultaneous link. it doesnt remove the link on the other recognizer.
  1741. * @param {Recognizer} otherRecognizer
  1742. * @returns {Recognizer} this
  1743. */
  1744. dropRecognizeWith: function(otherRecognizer) {
  1745. if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
  1746. return this;
  1747. }
  1748. otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
  1749. delete this.simultaneous[otherRecognizer.id];
  1750. return this;
  1751. },
  1752. /**
  1753. * recognizer can only run when an other is failing
  1754. * @param {Recognizer} otherRecognizer
  1755. * @returns {Recognizer} this
  1756. */
  1757. requireFailure: function(otherRecognizer) {
  1758. if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
  1759. return this;
  1760. }
  1761. var requireFail = this.requireFail;
  1762. otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
  1763. if (inArray(requireFail, otherRecognizer) === -1) {
  1764. requireFail.push(otherRecognizer);
  1765. otherRecognizer.requireFailure(this);
  1766. }
  1767. return this;
  1768. },
  1769. /**
  1770. * drop the requireFailure link. it does not remove the link on the other recognizer.
  1771. * @param {Recognizer} otherRecognizer
  1772. * @returns {Recognizer} this
  1773. */
  1774. dropRequireFailure: function(otherRecognizer) {
  1775. if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
  1776. return this;
  1777. }
  1778. otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
  1779. var index = inArray(this.requireFail, otherRecognizer);
  1780. if (index > -1) {
  1781. this.requireFail.splice(index, 1);
  1782. }
  1783. return this;
  1784. },
  1785. /**
  1786. * has require failures boolean
  1787. * @returns {boolean}
  1788. */
  1789. hasRequireFailures: function() {
  1790. return this.requireFail.length > 0;
  1791. },
  1792. /**
  1793. * if the recognizer can recognize simultaneous with an other recognizer
  1794. * @param {Recognizer} otherRecognizer
  1795. * @returns {Boolean}
  1796. */
  1797. canRecognizeWith: function(otherRecognizer) {
  1798. return !!this.simultaneous[otherRecognizer.id];
  1799. },
  1800. /**
  1801. * You should use `tryEmit` instead of `emit` directly to check
  1802. * that all the needed recognizers has failed before emitting.
  1803. * @param {Object} input
  1804. */
  1805. emit: function(input) {
  1806. var self = this;
  1807. var state = this.state;
  1808. function emit(withState) {
  1809. self.manager.emit(self.options.event + (withState ? stateStr(state) : ''), input);
  1810. }
  1811. // 'panstart' and 'panmove'
  1812. if (state < STATE_ENDED) {
  1813. emit(true);
  1814. }
  1815. emit(); // simple 'eventName' events
  1816. // panend and pancancel
  1817. if (state >= STATE_ENDED) {
  1818. emit(true);
  1819. }
  1820. },
  1821. /**
  1822. * Check that all the require failure recognizers has failed,
  1823. * if true, it emits a gesture event,
  1824. * otherwise, setup the state to FAILED.
  1825. * @param {Object} input
  1826. */
  1827. tryEmit: function(input) {
  1828. if (this.canEmit()) {
  1829. return this.emit(input);
  1830. }
  1831. // it's failing anyway
  1832. this.state = STATE_FAILED;
  1833. },
  1834. /**
  1835. * can we emit?
  1836. * @returns {boolean}
  1837. */
  1838. canEmit: function() {
  1839. var i = 0;
  1840. while (i < this.requireFail.length) {
  1841. if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
  1842. return false;
  1843. }
  1844. i++;
  1845. }
  1846. return true;
  1847. },
  1848. /**
  1849. * update the recognizer
  1850. * @param {Object} inputData
  1851. */
  1852. recognize: function(inputData) {
  1853. // make a new copy of the inputData
  1854. // so we can change the inputData without messing up the other recognizers
  1855. var inputDataClone = extend({}, inputData);
  1856. // is is enabled and allow recognizing?
  1857. if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
  1858. this.reset();
  1859. this.state = STATE_FAILED;
  1860. return;
  1861. }
  1862. // reset when we've reached the end
  1863. if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
  1864. this.state = STATE_POSSIBLE;
  1865. }
  1866. this.state = this.process(inputDataClone);
  1867. // the recognizer has recognized a gesture
  1868. // so trigger an event
  1869. if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
  1870. this.tryEmit(inputDataClone);
  1871. }
  1872. },
  1873. /**
  1874. * return the state of the recognizer
  1875. * the actual recognizing happens in this method
  1876. * @virtual
  1877. * @param {Object} inputData
  1878. * @returns {Const} STATE
  1879. */
  1880. process: function(inputData) {
  1881. }, // jshint ignore:line
  1882. /**
  1883. * return the preferred touch-action
  1884. * @virtual
  1885. * @returns {Array}
  1886. */
  1887. getTouchAction: function() {
  1888. },
  1889. /**
  1890. * called when the gesture isn't allowed to recognize
  1891. * like when another is being recognized or it is disabled
  1892. * @virtual
  1893. */
  1894. reset: function() {
  1895. }
  1896. };
  1897. /**
  1898. * get a usable string, used as event postfix
  1899. * @param {Const} state
  1900. * @returns {String} state
  1901. */
  1902. function stateStr(state) {
  1903. if (state & STATE_CANCELLED) {
  1904. return 'cancel';
  1905. } else if (state & STATE_ENDED) {
  1906. return 'end';
  1907. } else if (state & STATE_CHANGED) {
  1908. return 'move';
  1909. } else if (state & STATE_BEGAN) {
  1910. return 'start';
  1911. }
  1912. return '';
  1913. }
  1914. /**
  1915. * direction cons to string
  1916. * @param {Const} direction
  1917. * @returns {String}
  1918. */
  1919. function directionStr(direction) {
  1920. if (direction == DIRECTION_DOWN) {
  1921. return 'down';
  1922. } else if (direction == DIRECTION_UP) {
  1923. return 'up';
  1924. } else if (direction == DIRECTION_LEFT) {
  1925. return 'left';
  1926. } else if (direction == DIRECTION_RIGHT) {
  1927. return 'right';
  1928. }
  1929. return '';
  1930. }
  1931. /**
  1932. * get a recognizer by name if it is bound to a manager
  1933. * @param {Recognizer|String} otherRecognizer
  1934. * @param {Recognizer} recognizer
  1935. * @returns {Recognizer}
  1936. */
  1937. function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
  1938. var manager = recognizer.manager;
  1939. if (manager) {
  1940. return manager.get(otherRecognizer);
  1941. }
  1942. return otherRecognizer;
  1943. }
  1944. /**
  1945. * This recognizer is just used as a base for the simple attribute recognizers.
  1946. * @constructor
  1947. * @extends Recognizer
  1948. */
  1949. function AttrRecognizer() {
  1950. Recognizer.apply(this, arguments);
  1951. }
  1952. inherit(AttrRecognizer, Recognizer, {
  1953. /**
  1954. * @namespace
  1955. * @memberof AttrRecognizer
  1956. */
  1957. defaults: {
  1958. /**
  1959. * @type {Number}
  1960. * @default 1
  1961. */
  1962. pointers: 1
  1963. },
  1964. /**
  1965. * Used to check if it the recognizer receives valid input, like input.distance > 10.
  1966. * @memberof AttrRecognizer
  1967. * @param {Object} input
  1968. * @returns {Boolean} recognized
  1969. */
  1970. attrTest: function(input) {
  1971. var optionPointers = this.options.pointers;
  1972. return optionPointers === 0 || input.pointers.length === optionPointers;
  1973. },
  1974. /**
  1975. * Process the input and return the state for the recognizer
  1976. * @memberof AttrRecognizer
  1977. * @param {Object} input
  1978. * @returns {*} State
  1979. */
  1980. process: function(input) {
  1981. var state = this.state;
  1982. var eventType = input.eventType;
  1983. var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
  1984. var isValid = this.attrTest(input);
  1985. // on cancel input and we've recognized before, return STATE_CANCELLED
  1986. if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
  1987. return state | STATE_CANCELLED;
  1988. } else if (isRecognized || isValid) {
  1989. if (eventType & INPUT_END) {
  1990. return state | STATE_ENDED;
  1991. } else if (!(state & STATE_BEGAN)) {
  1992. return STATE_BEGAN;
  1993. }
  1994. return state | STATE_CHANGED;
  1995. }
  1996. return STATE_FAILED;
  1997. }
  1998. });
  1999. /**
  2000. * Pan
  2001. * Recognized when the pointer is down and moved in the allowed direction.
  2002. * @constructor
  2003. * @extends AttrRecognizer
  2004. */
  2005. function PanRecognizer() {
  2006. AttrRecognizer.apply(this, arguments);
  2007. this.pX = null;
  2008. this.pY = null;
  2009. }
  2010. inherit(PanRecognizer, AttrRecognizer, {
  2011. /**
  2012. * @namespace
  2013. * @memberof PanRecognizer
  2014. */
  2015. defaults: {
  2016. event: 'pan',
  2017. threshold: 10,
  2018. pointers: 1,
  2019. direction: DIRECTION_ALL
  2020. },
  2021. getTouchAction: function() {
  2022. var direction = this.options.direction;
  2023. var actions = [];
  2024. if (direction & DIRECTION_HORIZONTAL) {
  2025. actions.push(TOUCH_ACTION_PAN_Y);
  2026. }
  2027. if (direction & DIRECTION_VERTICAL) {
  2028. actions.push(TOUCH_ACTION_PAN_X);
  2029. }
  2030. return actions;
  2031. },
  2032. directionTest: function(input) {
  2033. var options = this.options;
  2034. var hasMoved = true;
  2035. var distance = input.distance;
  2036. var direction = input.direction;
  2037. var x = input.deltaX;
  2038. var y = input.deltaY;
  2039. // lock to axis?
  2040. if (!(direction & options.direction)) {
  2041. if (options.direction & DIRECTION_HORIZONTAL) {
  2042. direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT;
  2043. hasMoved = x != this.pX;
  2044. distance = Math.abs(input.deltaX);
  2045. } else {
  2046. direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN;
  2047. hasMoved = y != this.pY;
  2048. distance = Math.abs(input.deltaY);
  2049. }
  2050. }
  2051. input.direction = direction;
  2052. return hasMoved && distance > options.threshold && direction & options.direction;
  2053. },
  2054. attrTest: function(input) {
  2055. return AttrRecognizer.prototype.attrTest.call(this, input) &&
  2056. (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
  2057. },
  2058. emit: function(input) {
  2059. this.pX = input.deltaX;
  2060. this.pY = input.deltaY;
  2061. var direction = directionStr(input.direction);
  2062. if (direction) {
  2063. this.manager.emit(this.options.event + direction, input);
  2064. }
  2065. this._super.emit.call(this, input);
  2066. }
  2067. });
  2068. /**
  2069. * Pinch
  2070. * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
  2071. * @constructor
  2072. * @extends AttrRecognizer
  2073. */
  2074. function PinchRecognizer() {
  2075. AttrRecognizer.apply(this, arguments);
  2076. }
  2077. inherit(PinchRecognizer, AttrRecognizer, {
  2078. /**
  2079. * @namespace
  2080. * @memberof PinchRecognizer
  2081. */
  2082. defaults: {
  2083. event: 'pinch',
  2084. threshold: 0,
  2085. pointers: 2
  2086. },
  2087. getTouchAction: function() {
  2088. return [TOUCH_ACTION_NONE];
  2089. },
  2090. attrTest: function(input) {
  2091. return this._super.attrTest.call(this, input) &&
  2092. (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
  2093. },
  2094. emit: function(input) {
  2095. this._super.emit.call(this, input);
  2096. if (input.scale !== 1) {
  2097. var inOut = input.scale < 1 ? 'in' : 'out';
  2098. this.manager.emit(this.options.event + inOut, input);
  2099. }
  2100. }
  2101. });
  2102. /**
  2103. * Press
  2104. * Recognized when the pointer is down for x ms without any movement.
  2105. * @constructor
  2106. * @extends Recognizer
  2107. */
  2108. function PressRecognizer() {
  2109. Recognizer.apply(this, arguments);
  2110. this._timer = null;
  2111. this._input = null;
  2112. }
  2113. inherit(PressRecognizer, Recognizer, {
  2114. /**
  2115. * @namespace
  2116. * @memberof PressRecognizer
  2117. */
  2118. defaults: {
  2119. event: 'press',
  2120. pointers: 1,
  2121. time: 500, // minimal time of the pointer to be pressed
  2122. threshold: 5 // a minimal movement is ok, but keep it low
  2123. },
  2124. getTouchAction: function() {
  2125. return [TOUCH_ACTION_AUTO];
  2126. },
  2127. process: function(input) {
  2128. var options = this.options;
  2129. var validPointers = input.pointers.length === options.pointers;
  2130. var validMovement = input.distance < options.threshold;
  2131. var validTime = input.deltaTime > options.time;
  2132. this._input = input;
  2133. // we only allow little movement
  2134. // and we've reached an end event, so a tap is possible
  2135. if (!validMovement || !validPointers || (input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime)) {
  2136. this.reset();
  2137. } else if (input.eventType & INPUT_START) {
  2138. this.reset();
  2139. this._timer = setTimeoutContext(function() {
  2140. this.state = STATE_RECOGNIZED;
  2141. this.tryEmit();
  2142. }, options.time, this);
  2143. } else if (input.eventType & INPUT_END) {
  2144. return STATE_RECOGNIZED;
  2145. }
  2146. return STATE_FAILED;
  2147. },
  2148. reset: function() {
  2149. clearTimeout(this._timer);
  2150. },
  2151. emit: function(input) {
  2152. if (this.state !== STATE_RECOGNIZED) {
  2153. return;
  2154. }
  2155. if (input && (input.eventType & INPUT_END)) {
  2156. this.manager.emit(this.options.event + 'up', input);
  2157. } else {
  2158. this._input.timeStamp = now();
  2159. this.manager.emit(this.options.event, this._input);
  2160. }
  2161. }
  2162. });
  2163. /**
  2164. * Rotate
  2165. * Recognized when two or more pointer are moving in a circular motion.
  2166. * @constructor
  2167. * @extends AttrRecognizer
  2168. */
  2169. function RotateRecognizer() {
  2170. AttrRecognizer.apply(this, arguments);
  2171. }
  2172. inherit(RotateRecognizer, AttrRecognizer, {
  2173. /**
  2174. * @namespace
  2175. * @memberof RotateRecognizer
  2176. */
  2177. defaults: {
  2178. event: 'rotate',
  2179. threshold: 0,
  2180. pointers: 2
  2181. },
  2182. getTouchAction: function() {
  2183. return [TOUCH_ACTION_NONE];
  2184. },
  2185. attrTest: function(input) {
  2186. return this._super.attrTest.call(this, input) &&
  2187. (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
  2188. }
  2189. });
  2190. /**
  2191. * Swipe
  2192. * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
  2193. * @constructor
  2194. * @extends AttrRecognizer
  2195. */
  2196. function SwipeRecognizer() {
  2197. AttrRecognizer.apply(this, arguments);
  2198. }
  2199. inherit(SwipeRecognizer, AttrRecognizer, {
  2200. /**
  2201. * @namespace
  2202. * @memberof SwipeRecognizer
  2203. */
  2204. defaults: {
  2205. event: 'swipe',
  2206. threshold: 10,
  2207. velocity: 0.65,
  2208. direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
  2209. pointers: 1
  2210. },
  2211. getTouchAction: function() {
  2212. return PanRecognizer.prototype.getTouchAction.call(this);
  2213. },
  2214. attrTest: function(input) {
  2215. var direction = this.options.direction;
  2216. var velocity;
  2217. if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
  2218. velocity = input.velocity;
  2219. } else if (direction & DIRECTION_HORIZONTAL) {
  2220. velocity = input.velocityX;
  2221. } else if (direction & DIRECTION_VERTICAL) {
  2222. velocity = input.velocityY;
  2223. }
  2224. return this._super.attrTest.call(this, input) &&
  2225. direction & input.direction &&
  2226. input.distance > this.options.threshold &&
  2227. abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
  2228. },
  2229. emit: function(input) {
  2230. var direction = directionStr(input.direction);
  2231. if (direction) {
  2232. this.manager.emit(this.options.event + direction, input);
  2233. }
  2234. this.manager.emit(this.options.event, input);
  2235. }
  2236. });
  2237. /**
  2238. * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
  2239. * between the given interval and position. The delay option can be used to recognize multi-taps without firing
  2240. * a single tap.
  2241. *
  2242. * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
  2243. * multi-taps being recognized.
  2244. * @constructor
  2245. * @extends Recognizer
  2246. */
  2247. function TapRecognizer() {
  2248. Recognizer.apply(this, arguments);
  2249. // previous time and center,
  2250. // used for tap counting
  2251. this.pTime = false;
  2252. this.pCenter = false;
  2253. this._timer = null;
  2254. this._input = null;
  2255. this.count = 0;
  2256. }
  2257. inherit(TapRecognizer, Recognizer, {
  2258. /**
  2259. * @namespace
  2260. * @memberof PinchRecognizer
  2261. */
  2262. defaults: {
  2263. event: 'tap',
  2264. pointers: 1,
  2265. taps: 1,
  2266. interval: 300, // max time between the multi-tap taps
  2267. time: 250, // max time of the pointer to be down (like finger on the screen)
  2268. threshold: 2, // a minimal movement is ok, but keep it low
  2269. posThreshold: 10 // a multi-tap can be a bit off the initial position
  2270. },
  2271. getTouchAction: function() {
  2272. return [TOUCH_ACTION_MANIPULATION];
  2273. },
  2274. process: function(input) {
  2275. var options = this.options;
  2276. var validPointers = input.pointers.length === options.pointers;
  2277. var validMovement = input.distance < options.threshold;
  2278. var validTouchTime = input.deltaTime < options.time;
  2279. this.reset();
  2280. if ((input.eventType & INPUT_START) && (this.count === 0)) {
  2281. return this.failTimeout();
  2282. }
  2283. // we only allow little movement
  2284. // and we've reached an end event, so a tap is possible
  2285. if (validMovement && validTouchTime && validPointers) {
  2286. if (input.eventType != INPUT_END) {
  2287. return this.failTimeout();
  2288. }
  2289. var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true;
  2290. var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
  2291. this.pTime = input.timeStamp;
  2292. this.pCenter = input.center;
  2293. if (!validMultiTap || !validInterval) {
  2294. this.count = 1;
  2295. } else {
  2296. this.count += 1;
  2297. }
  2298. this._input = input;
  2299. // if tap count matches we have recognized it,
  2300. // else it has began recognizing...
  2301. var tapCount = this.count % options.taps;
  2302. if (tapCount === 0) {
  2303. // no failing requirements, immediately trigger the tap event
  2304. // or wait as long as the multitap interval to trigger
  2305. if (!this.hasRequireFailures()) {
  2306. return STATE_RECOGNIZED;
  2307. } else {
  2308. this._timer = setTimeoutContext(function() {
  2309. this.state = STATE_RECOGNIZED;
  2310. this.tryEmit();
  2311. }, options.interval, this);
  2312. return STATE_BEGAN;
  2313. }
  2314. }
  2315. }
  2316. return STATE_FAILED;
  2317. },
  2318. failTimeout: function() {
  2319. this._timer = setTimeoutContext(function() {
  2320. this.state = STATE_FAILED;
  2321. }, this.options.interval, this);
  2322. return STATE_FAILED;
  2323. },
  2324. reset: function() {
  2325. clearTimeout(this._timer);
  2326. },
  2327. emit: function() {
  2328. if (this.state == STATE_RECOGNIZED) {
  2329. this._input.tapCount = this.count;
  2330. this.manager.emit(this.options.event, this._input);
  2331. }
  2332. }
  2333. });
  2334. /**
  2335. * Simple way to create an manager with a default set of recognizers.
  2336. * @param {HTMLElement} element
  2337. * @param {Object} [options]
  2338. * @constructor
  2339. */
  2340. function Hammer(element, options) {
  2341. options = options || {};
  2342. options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
  2343. return new Manager(element, options);
  2344. }
  2345. /**
  2346. * @const {string}
  2347. */
  2348. Hammer.VERSION = '2.0.4';
  2349. /**
  2350. * default settings
  2351. * @namespace
  2352. */
  2353. Hammer.defaults = {
  2354. /**
  2355. * set if DOM events are being triggered.
  2356. * But this is slower and unused by simple implementations, so disabled by default.
  2357. * @type {Boolean}
  2358. * @default false
  2359. */
  2360. domEvents: false,
  2361. /**
  2362. * The value for the touchAction property/fallback.
  2363. * When set to `compute` it will magically set the correct value based on the added recognizers.
  2364. * @type {String}
  2365. * @default compute
  2366. */
  2367. touchAction: TOUCH_ACTION_COMPUTE,
  2368. /**
  2369. * @type {Boolean}
  2370. * @default true
  2371. */
  2372. enable: true,
  2373. /**
  2374. * EXPERIMENTAL FEATURE -- can be removed/changed
  2375. * Change the parent input target element.
  2376. * If Null, then it is being set the to main element.
  2377. * @type {Null|EventTarget}
  2378. * @default null
  2379. */
  2380. inputTarget: null,
  2381. /**
  2382. * force an input class
  2383. * @type {Null|Function}
  2384. * @default null
  2385. */
  2386. inputClass: null,
  2387. /**
  2388. * Default recognizer setup when calling `Hammer()`
  2389. * When creating a new Manager these will be skipped.
  2390. * @type {Array}
  2391. */
  2392. preset: [
  2393. // RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
  2394. [RotateRecognizer, {enable: false}],
  2395. [PinchRecognizer, {enable: false}, ['rotate']],
  2396. [SwipeRecognizer, {direction: DIRECTION_HORIZONTAL}],
  2397. [PanRecognizer, {direction: DIRECTION_HORIZONTAL}, ['swipe']],
  2398. [TapRecognizer],
  2399. [TapRecognizer, {event: 'doubletap', taps: 2}, ['tap']],
  2400. [PressRecognizer]
  2401. ],
  2402. /**
  2403. * Some CSS properties can be used to improve the working of Hammer.
  2404. * Add them to this method and they will be set when creating a new Manager.
  2405. * @namespace
  2406. */
  2407. cssProps: {
  2408. /**
  2409. * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
  2410. * @type {String}
  2411. * @default 'none'
  2412. */
  2413. userSelect: 'none',
  2414. /**
  2415. * Disable the Windows Phone grippers when pressing an element.
  2416. * @type {String}
  2417. * @default 'none'
  2418. */
  2419. touchSelect: 'none',
  2420. /**
  2421. * Disables the default callout shown when you touch and hold a touch target.
  2422. * On iOS, when you touch and hold a touch target such as a link, Safari displays
  2423. * a callout containing information about the link. This property allows you to disable that callout.
  2424. * @type {String}
  2425. * @default 'none'
  2426. */
  2427. touchCallout: 'none',
  2428. /**
  2429. * Specifies whether zooming is enabled. Used by IE10>
  2430. * @type {String}
  2431. * @default 'none'
  2432. */
  2433. contentZooming: 'none',
  2434. /**
  2435. * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
  2436. * @type {String}
  2437. * @default 'none'
  2438. */
  2439. userDrag: 'none',
  2440. /**
  2441. * Overrides the highlight color shown when the user taps a link or a JavaScript
  2442. * clickable element in iOS. This property obeys the alpha value, if specified.
  2443. * @type {String}
  2444. * @default 'rgba(0,0,0,0)'
  2445. */
  2446. tapHighlightColor: 'rgba(0,0,0,0)'
  2447. }
  2448. };
  2449. var STOP = 1;
  2450. var FORCED_STOP = 2;
  2451. /**
  2452. * Manager
  2453. * @param {HTMLElement} element
  2454. * @param {Object} [options]
  2455. * @constructor
  2456. */
  2457. function Manager(element, options) {
  2458. options = options || {};
  2459. this.options = merge(options, Hammer.defaults);
  2460. this.options.inputTarget = this.options.inputTarget || element;
  2461. this.handlers = {};
  2462. this.session = {};
  2463. this.recognizers = [];
  2464. this.element = element;
  2465. this.input = createInputInstance(this);
  2466. this.touchAction = new TouchAction(this, this.options.touchAction);
  2467. toggleCssProps(this, true);
  2468. each(options.recognizers, function(item) {
  2469. var recognizer = this.add(new (item[0])(item[1]));
  2470. item[2] && recognizer.recognizeWith(item[2]);
  2471. item[3] && recognizer.requireFailure(item[3]);
  2472. }, this);
  2473. }
  2474. Manager.prototype = {
  2475. /**
  2476. * set options
  2477. * @param {Object} options
  2478. * @returns {Manager}
  2479. */
  2480. set: function(options) {
  2481. extend(this.options, options);
  2482. // Options that need a little more setup
  2483. if (options.touchAction) {
  2484. this.touchAction.update();
  2485. }
  2486. if (options.inputTarget) {
  2487. // Clean up existing event listeners and reinitialize
  2488. this.input.destroy();
  2489. this.input.target = options.inputTarget;
  2490. this.input.init();
  2491. }
  2492. return this;
  2493. },
  2494. /**
  2495. * stop recognizing for this session.
  2496. * This session will be discarded, when a new [input]start event is fired.
  2497. * When forced, the recognizer cycle is stopped immediately.
  2498. * @param {Boolean} [force]
  2499. */
  2500. stop: function(force) {
  2501. this.session.stopped = force ? FORCED_STOP : STOP;
  2502. },
  2503. /**
  2504. * run the recognizers!
  2505. * called by the inputHandler function on every movement of the pointers (touches)
  2506. * it walks through all the recognizers and tries to detect the gesture that is being made
  2507. * @param {Object} inputData
  2508. */
  2509. recognize: function(inputData) {
  2510. var session = this.session;
  2511. if (session.stopped) {
  2512. return;
  2513. }
  2514. // run the touch-action polyfill
  2515. this.touchAction.preventDefaults(inputData);
  2516. var recognizer;
  2517. var recognizers = this.recognizers;
  2518. // this holds the recognizer that is being recognized.
  2519. // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
  2520. // if no recognizer is detecting a thing, it is set to `null`
  2521. var curRecognizer = session.curRecognizer;
  2522. // reset when the last recognizer is recognized
  2523. // or when we're in a new session
  2524. if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) {
  2525. curRecognizer = session.curRecognizer = null;
  2526. }
  2527. var i = 0;
  2528. while (i < recognizers.length) {
  2529. recognizer = recognizers[i];
  2530. // find out if we are allowed try to recognize the input for this one.
  2531. // 1. allow if the session is NOT forced stopped (see the .stop() method)
  2532. // 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
  2533. // that is being recognized.
  2534. // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
  2535. // this can be setup with the `recognizeWith()` method on the recognizer.
  2536. if (session.stopped !== FORCED_STOP && ( // 1
  2537. !curRecognizer || recognizer == curRecognizer || // 2
  2538. recognizer.canRecognizeWith(curRecognizer))) { // 3
  2539. recognizer.recognize(inputData);
  2540. } else {
  2541. recognizer.reset();
  2542. }
  2543. // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
  2544. // current active recognizer. but only if we don't already have an active recognizer
  2545. if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
  2546. curRecognizer = session.curRecognizer = recognizer;
  2547. }
  2548. i++;
  2549. }
  2550. },
  2551. /**
  2552. * get a recognizer by its event name.
  2553. * @param {Recognizer|String} recognizer
  2554. * @returns {Recognizer|Null}
  2555. */
  2556. get: function(recognizer) {
  2557. if (recognizer instanceof Recognizer) {
  2558. return recognizer;
  2559. }
  2560. var recognizers = this.recognizers;
  2561. for (var i = 0; i < recognizers.length; i++) {
  2562. if (recognizers[i].options.event == recognizer) {
  2563. return recognizers[i];
  2564. }
  2565. }
  2566. return null;
  2567. },
  2568. /**
  2569. * add a recognizer to the manager
  2570. * existing recognizers with the same event name will be removed
  2571. * @param {Recognizer} recognizer
  2572. * @returns {Recognizer|Manager}
  2573. */
  2574. add: function(recognizer) {
  2575. if (invokeArrayArg(recognizer, 'add', this)) {
  2576. return this;
  2577. }
  2578. // remove existing
  2579. var existing = this.get(recognizer.options.event);
  2580. if (existing) {
  2581. this.remove(existing);
  2582. }
  2583. this.recognizers.push(recognizer);
  2584. recognizer.manager = this;
  2585. this.touchAction.update();
  2586. return recognizer;
  2587. },
  2588. /**
  2589. * remove a recognizer by name or instance
  2590. * @param {Recognizer|String} recognizer
  2591. * @returns {Manager}
  2592. */
  2593. remove: function(recognizer) {
  2594. if (invokeArrayArg(recognizer, 'remove', this)) {
  2595. return this;
  2596. }
  2597. var recognizers = this.recognizers;
  2598. recognizer = this.get(recognizer);
  2599. recognizers.splice(inArray(recognizers, recognizer), 1);
  2600. this.touchAction.update();
  2601. return this;
  2602. },
  2603. /**
  2604. * bind event
  2605. * @param {String} events
  2606. * @param {Function} handler
  2607. * @returns {EventEmitter} this
  2608. */
  2609. on: function(events, handler) {
  2610. var handlers = this.handlers;
  2611. each(splitStr(events), function(event) {
  2612. handlers[event] = handlers[event] || [];
  2613. handlers[event].push(handler);
  2614. });
  2615. return this;
  2616. },
  2617. /**
  2618. * unbind event, leave emit blank to remove all handlers
  2619. * @param {String} events
  2620. * @param {Function} [handler]
  2621. * @returns {EventEmitter} this
  2622. */
  2623. off: function(events, handler) {
  2624. var handlers = this.handlers;
  2625. each(splitStr(events), function(event) {
  2626. if (!handler) {
  2627. delete handlers[event];
  2628. } else {
  2629. handlers[event].splice(inArray(handlers[event], handler), 1);
  2630. }
  2631. });
  2632. return this;
  2633. },
  2634. /**
  2635. * emit event to the listeners
  2636. * @param {String} event
  2637. * @param {Object} data
  2638. */
  2639. emit: function(event, data) {
  2640. // we also want to trigger dom events
  2641. if (this.options.domEvents) {
  2642. triggerDomEvent(event, data);
  2643. }
  2644. // no handlers, so skip it all
  2645. var handlers = this.handlers[event] && this.handlers[event].slice();
  2646. if (!handlers || !handlers.length) {
  2647. return;
  2648. }
  2649. data.type = event;
  2650. data.preventDefault = function() {
  2651. data.srcEvent.preventDefault();
  2652. };
  2653. var i = 0;
  2654. while (i < handlers.length) {
  2655. handlers[i](data);
  2656. i++;
  2657. }
  2658. },
  2659. /**
  2660. * destroy the manager and unbinds all events
  2661. * it doesn't unbind dom events, that is the user own responsibility
  2662. */
  2663. destroy: function() {
  2664. this.element && toggleCssProps(this, false);
  2665. this.handlers = {};
  2666. this.session = {};
  2667. this.input.destroy();
  2668. this.element = null;
  2669. }
  2670. };
  2671. /**
  2672. * add/remove the css properties as defined in manager.options.cssProps
  2673. * @param {Manager} manager
  2674. * @param {Boolean} add
  2675. */
  2676. function toggleCssProps(manager, add) {
  2677. var element = manager.element;
  2678. each(manager.options.cssProps, function(value, name) {
  2679. element.style[prefixed(element.style, name)] = add ? value : '';
  2680. });
  2681. }
  2682. /**
  2683. * trigger dom event
  2684. * @param {String} event
  2685. * @param {Object} data
  2686. */
  2687. function triggerDomEvent(event, data) {
  2688. var gestureEvent = document.createEvent('Event');
  2689. gestureEvent.initEvent(event, true, true);
  2690. gestureEvent.gesture = data;
  2691. data.target.dispatchEvent(gestureEvent);
  2692. }
  2693. extend(Hammer, {
  2694. INPUT_START: INPUT_START,
  2695. INPUT_MOVE: INPUT_MOVE,
  2696. INPUT_END: INPUT_END,
  2697. INPUT_CANCEL: INPUT_CANCEL,
  2698. STATE_POSSIBLE: STATE_POSSIBLE,
  2699. STATE_BEGAN: STATE_BEGAN,
  2700. STATE_CHANGED: STATE_CHANGED,
  2701. STATE_ENDED: STATE_ENDED,
  2702. STATE_RECOGNIZED: STATE_RECOGNIZED,
  2703. STATE_CANCELLED: STATE_CANCELLED,
  2704. STATE_FAILED: STATE_FAILED,
  2705. DIRECTION_NONE: DIRECTION_NONE,
  2706. DIRECTION_LEFT: DIRECTION_LEFT,
  2707. DIRECTION_RIGHT: DIRECTION_RIGHT,
  2708. DIRECTION_UP: DIRECTION_UP,
  2709. DIRECTION_DOWN: DIRECTION_DOWN,
  2710. DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
  2711. DIRECTION_VERTICAL: DIRECTION_VERTICAL,
  2712. DIRECTION_ALL: DIRECTION_ALL,
  2713. Manager: Manager,
  2714. Input: Input,
  2715. TouchAction: TouchAction,
  2716. TouchInput: TouchInput,
  2717. MouseInput: MouseInput,
  2718. PointerEventInput: PointerEventInput,
  2719. TouchMouseInput: TouchMouseInput,
  2720. SingleTouchInput: SingleTouchInput,
  2721. Recognizer: Recognizer,
  2722. AttrRecognizer: AttrRecognizer,
  2723. Tap: TapRecognizer,
  2724. Pan: PanRecognizer,
  2725. Swipe: SwipeRecognizer,
  2726. Pinch: PinchRecognizer,
  2727. Rotate: RotateRecognizer,
  2728. Press: PressRecognizer,
  2729. on: addEventListeners,
  2730. off: removeEventListeners,
  2731. each: each,
  2732. merge: merge,
  2733. extend: extend,
  2734. inherit: inherit,
  2735. bindFn: bindFn,
  2736. prefixed: prefixed
  2737. });
  2738. // jquery.hammer.js
  2739. // This jQuery plugin is just a small wrapper around the Hammer() class.
  2740. // It also extends the Manager.emit method by triggering jQuery events.
  2741. // $(element).hammer(options).bind("pan", myPanHandler);
  2742. // The Hammer instance is stored at $element.data("hammer").
  2743. // https://github.com/hammerjs/jquery.hammer.js
  2744. (function($, Hammer) {
  2745. function hammerify(el, options) {
  2746. var $el = $(el);
  2747. if (!$el.data('hammer')) {
  2748. $el.data('hammer', new Hammer($el[0], options));
  2749. }
  2750. }
  2751. $.fn.hammer = function(options) {
  2752. return this.each(function() {
  2753. hammerify(this, options);
  2754. });
  2755. };
  2756. // extend the emit method to also trigger jQuery events
  2757. Hammer.Manager.prototype.emit = (function(originalEmit) {
  2758. return function(type, data) {
  2759. originalEmit.call(this, type, data);
  2760. $(this.element).trigger({
  2761. type: type,
  2762. gesture: data
  2763. });
  2764. };
  2765. })(Hammer.Manager.prototype.emit);
  2766. })($, Hammer);
  2767. module.exports = UI.Hammer = Hammer;
  2768. /***/ },
  2769. /* 4 */
  2770. /***/ function(module, exports, __webpack_require__) {
  2771. 'use strict';
  2772. var UI = __webpack_require__(2);
  2773. /* jshint -W101, -W106 */
  2774. /**
  2775. * Add to Homescreen v3.2.2
  2776. * (c) 2015 Matteo Spinelli
  2777. * @license: http://cubiq.org/license
  2778. */
  2779. // Check for addEventListener browser support (prevent errors in IE<9)
  2780. var _eventListener = 'addEventListener' in window;
  2781. // Check if document is loaded, needed by autostart
  2782. var _DOMReady = false;
  2783. if (document.readyState === 'complete') {
  2784. _DOMReady = true;
  2785. } else if (_eventListener) {
  2786. window.addEventListener('load', loaded, false);
  2787. }
  2788. function loaded() {
  2789. window.removeEventListener('load', loaded, false);
  2790. _DOMReady = true;
  2791. }
  2792. // regex used to detect if app has been added to the homescreen
  2793. var _reSmartURL = /\/ath(\/)?$/;
  2794. var _reQueryString = /([\?&]ath=[^&]*$|&ath=[^&]*(&))/;
  2795. // singleton
  2796. var _instance;
  2797. function ath(options) {
  2798. _instance = _instance || new ath.Class(options);
  2799. return _instance;
  2800. }
  2801. // message in all supported languages
  2802. ath.intl = {
  2803. en_us: {
  2804. ios: 'To add this web app to the home screen: tap %icon and then <strong>Add to Home Screen</strong>.',
  2805. android: 'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'
  2806. },
  2807. zh_cn: {
  2808. ios: '��Ҫ��Ӧ�ó�ʽ��������Ļ,����%icon, Ȼ��<strong>��������Ļ</strong>',
  2809. android: 'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'
  2810. },
  2811. zh_tw: {
  2812. ios: '��Ҫ�ё��ó�ʽ��������Ļ, Ո�c��%icon, Ȼ��<strong>��������Ļ</strong>.',
  2813. android: 'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'
  2814. }
  2815. };
  2816. // Add 2 characters language support (Android mostly)
  2817. for (var lang in ath.intl) {
  2818. ath.intl[lang.substr(0, 2)] = ath.intl[lang];
  2819. }
  2820. // default options
  2821. ath.defaults = {
  2822. appID: 'org.cubiq.addtohome', // local storage name (no need to change)
  2823. fontSize: 15, // base font size, used to properly resize the popup based on viewport scale factor
  2824. debug: false, // override browser checks
  2825. logging: false, // log reasons for showing or not showing to js console; defaults to true when debug is true
  2826. modal: false, // prevent further actions until the message is closed
  2827. mandatory: false, // you can't proceed if you don't add the app to the homescreen
  2828. autostart: true, // show the message automatically
  2829. skipFirstVisit: false, // show only to returning visitors (ie: skip the first time you visit)
  2830. startDelay: 1, // display the message after that many seconds from page load
  2831. lifespan: 15, // life of the message in seconds
  2832. displayPace: 1440, // minutes before the message is shown again (0: display every time, default 24 hours)
  2833. maxDisplayCount: 0, // absolute maximum number of times the message will be shown to the user (0: no limit)
  2834. icon: true, // add touch icon to the message
  2835. message: '', // the message can be customized
  2836. validLocation: [], // list of pages where the message will be shown (array of regexes)
  2837. onInit: null, // executed on instance creation
  2838. onShow: null, // executed when the message is shown
  2839. onRemove: null, // executed when the message is removed
  2840. onAdd: null, // when the application is launched the first time from the homescreen (guesstimate)
  2841. onPrivate: null, // executed if user is in private mode
  2842. privateModeOverride: false, // show the message even in private mode (very rude)
  2843. detectHomescreen: false // try to detect if the site has been added to the homescreen (false | true | 'hash' | 'queryString' | 'smartURL')
  2844. };
  2845. // browser info and capability
  2846. var _ua = window.navigator.userAgent;
  2847. var _nav = window.navigator;
  2848. _extend(ath, {
  2849. hasToken: document.location.hash == '#ath' || _reSmartURL.test(document.location.href) || _reQueryString.test(document.location.search),
  2850. isRetina: window.devicePixelRatio && window.devicePixelRatio > 1,
  2851. isIDevice: (/iphone|ipod|ipad/i).test(_ua),
  2852. isMobileChrome: _ua.indexOf('Android') > -1 && (/Chrome\/[.0-9]*/).test(_ua) && _ua.indexOf("Version") == -1,
  2853. isMobileIE: _ua.indexOf('Windows Phone') > -1,
  2854. language: _nav.language && _nav.language.toLowerCase().replace('-', '_') || ''
  2855. });
  2856. // falls back to en_us if language is unsupported
  2857. ath.language = ath.language && ath.language in ath.intl ? ath.language : 'en_us';
  2858. ath.isMobileSafari = ath.isIDevice && _ua.indexOf('Safari') > -1 && _ua.indexOf('CriOS') < 0;
  2859. ath.OS = ath.isIDevice ? 'ios' : ath.isMobileChrome ? 'android' : ath.isMobileIE ? 'windows' : 'unsupported';
  2860. ath.OSVersion = _ua.match(/(OS|Android) (\d+[_\.]\d+)/);
  2861. ath.OSVersion = ath.OSVersion && ath.OSVersion[2] ? +ath.OSVersion[2].replace('_', '.') : 0;
  2862. ath.isStandalone = 'standalone' in window.navigator && window.navigator.standalone;
  2863. ath.isTablet = (ath.isMobileSafari && _ua.indexOf('iPad') > -1) || (ath.isMobileChrome && _ua.indexOf('Mobile') < 0);
  2864. ath.isCompatible = (ath.isMobileSafari && ath.OSVersion >= 6) || ath.isMobileChrome; // TODO: add winphone
  2865. var _defaultSession = {
  2866. lastDisplayTime: 0, // last time we displayed the message
  2867. returningVisitor: false, // is this the first time you visit
  2868. displayCount: 0, // number of times the message has been shown
  2869. optedout: false, // has the user opted out
  2870. added: false // has been actually added to the homescreen
  2871. };
  2872. ath.removeSession = function(appID) {
  2873. try {
  2874. if (!localStorage) {
  2875. throw new Error('localStorage is not defined');
  2876. }
  2877. localStorage.removeItem(appID || ath.defaults.appID);
  2878. } catch (e) {
  2879. // we are most likely in private mode
  2880. }
  2881. };
  2882. ath.doLog = function(logStr) {
  2883. if (this.options.logging) {
  2884. console.log(logStr);
  2885. }
  2886. };
  2887. ath.Class = function(options) {
  2888. // class methods
  2889. this.doLog = ath.doLog;
  2890. // merge default options with user config
  2891. this.options = _extend({}, ath.defaults);
  2892. _extend(this.options, options);
  2893. // override defaults that are dependent on each other
  2894. if (this.options.debug) {
  2895. this.options.logging = true;
  2896. }
  2897. // IE<9 so exit (I hate you, really)
  2898. if (!_eventListener) {
  2899. return;
  2900. }
  2901. // normalize some options
  2902. this.options.mandatory = this.options.mandatory && ( 'standalone' in window.navigator || this.options.debug );
  2903. this.options.modal = this.options.modal || this.options.mandatory;
  2904. if (this.options.mandatory) {
  2905. this.options.startDelay = -0.5; // make the popup hasty
  2906. }
  2907. this.options.detectHomescreen = this.options.detectHomescreen === true ? 'hash' : this.options.detectHomescreen;
  2908. // setup the debug environment
  2909. if (this.options.debug) {
  2910. ath.isCompatible = true;
  2911. ath.OS = typeof this.options.debug == 'string' ? this.options.debug : ath.OS == 'unsupported' ? 'android' : ath.OS;
  2912. ath.OSVersion = ath.OS == 'ios' ? '8' : '4';
  2913. }
  2914. // the element the message will be appended to
  2915. this.container = document.documentElement;
  2916. // load session
  2917. this.session = this.getItem(this.options.appID);
  2918. this.session = this.session ? JSON.parse(this.session) : undefined;
  2919. // user most likely came from a direct link containing our token, we don't need it and we remove it
  2920. if (ath.hasToken && ( !ath.isCompatible || !this.session )) {
  2921. ath.hasToken = false;
  2922. _removeToken();
  2923. }
  2924. // the device is not supported
  2925. if (!ath.isCompatible) {
  2926. this.doLog("Add to homescreen: not displaying callout because device not supported");
  2927. return;
  2928. }
  2929. this.session = this.session || _defaultSession;
  2930. // check if we can use the local storage
  2931. try {
  2932. if (!localStorage) {
  2933. throw new Error('localStorage is not defined');
  2934. }
  2935. localStorage.setItem(this.options.appID, JSON.stringify(this.session));
  2936. ath.hasLocalStorage = true;
  2937. } catch (e) {
  2938. // we are most likely in private mode
  2939. ath.hasLocalStorage = false;
  2940. if (this.options.onPrivate) {
  2941. this.options.onPrivate.call(this);
  2942. }
  2943. }
  2944. // check if this is a valid location
  2945. var isValidLocation = !this.options.validLocation.length;
  2946. for (var i = this.options.validLocation.length; i--;) {
  2947. if (this.options.validLocation[i].test(document.location.href)) {
  2948. isValidLocation = true;
  2949. break;
  2950. }
  2951. }
  2952. // check compatibility with old versions of add to homescreen. Opt-out if an old session is found
  2953. if (this.getItem('addToHome')) {
  2954. this.optOut();
  2955. }
  2956. // critical errors:
  2957. if (this.session.optedout) {
  2958. this.doLog("Add to homescreen: not displaying callout because user opted out");
  2959. return;
  2960. }
  2961. if (this.session.added) {
  2962. this.doLog("Add to homescreen: not displaying callout because already added to the homescreen");
  2963. return;
  2964. }
  2965. if (!isValidLocation) {
  2966. this.doLog("Add to homescreen: not displaying callout because not a valid location");
  2967. return;
  2968. }
  2969. // check if the app is in stand alone mode
  2970. if (ath.isStandalone) {
  2971. // execute the onAdd event if we haven't already
  2972. if (!this.session.added) {
  2973. this.session.added = true;
  2974. this.updateSession();
  2975. if (this.options.onAdd && ath.hasLocalStorage) { // double check on localstorage to avoid multiple calls to the custom event
  2976. this.options.onAdd.call(this);
  2977. }
  2978. }
  2979. this.doLog("Add to homescreen: not displaying callout because in standalone mode");
  2980. return;
  2981. }
  2982. // (try to) check if the page has been added to the homescreen
  2983. if (this.options.detectHomescreen) {
  2984. // the URL has the token, we are likely coming from the homescreen
  2985. if (ath.hasToken) {
  2986. _removeToken(); // we don't actually need the token anymore, we remove it to prevent redistribution
  2987. // this is called the first time the user opens the app from the homescreen
  2988. if (!this.session.added) {
  2989. this.session.added = true;
  2990. this.updateSession();
  2991. if (this.options.onAdd && ath.hasLocalStorage) { // double check on localstorage to avoid multiple calls to the custom event
  2992. this.options.onAdd.call(this);
  2993. }
  2994. }
  2995. this.doLog("Add to homescreen: not displaying callout because URL has token, so we are likely coming from homescreen");
  2996. return;
  2997. }
  2998. // URL doesn't have the token, so add it
  2999. if (this.options.detectHomescreen == 'hash') {
  3000. history.replaceState('', window.document.title, document.location.href + '#ath');
  3001. } else if (this.options.detectHomescreen == 'smartURL') {
  3002. history.replaceState('', window.document.title, document.location.href.replace(/(\/)?$/, '/ath$1'));
  3003. } else {
  3004. history.replaceState('', window.document.title, document.location.href + (document.location.search ? '&' : '?' ) + 'ath=');
  3005. }
  3006. }
  3007. // check if this is a returning visitor
  3008. if (!this.session.returningVisitor) {
  3009. this.session.returningVisitor = true;
  3010. this.updateSession();
  3011. // we do not show the message if this is your first visit
  3012. if (this.options.skipFirstVisit) {
  3013. this.doLog("Add to homescreen: not displaying callout because skipping first visit");
  3014. return;
  3015. }
  3016. }
  3017. // we do no show the message in private mode
  3018. if (!this.options.privateModeOverride && !ath.hasLocalStorage) {
  3019. this.doLog("Add to homescreen: not displaying callout because browser is in private mode");
  3020. return;
  3021. }
  3022. // all checks passed, ready to display
  3023. this.ready = true;
  3024. if (this.options.onInit) {
  3025. this.options.onInit.call(this);
  3026. }
  3027. if (this.options.autostart) {
  3028. this.doLog("Add to homescreen: autostart displaying callout");
  3029. this.show();
  3030. }
  3031. };
  3032. ath.Class.prototype = {
  3033. // event type to method conversion
  3034. events: {
  3035. load: '_delayedShow',
  3036. error: '_delayedShow',
  3037. orientationchange: 'resize',
  3038. resize: 'resize',
  3039. scroll: 'resize',
  3040. click: 'remove',
  3041. touchmove: '_preventDefault',
  3042. transitionend: '_removeElements',
  3043. webkitTransitionEnd: '_removeElements',
  3044. MSTransitionEnd: '_removeElements'
  3045. },
  3046. handleEvent: function(e) {
  3047. var type = this.events[e.type];
  3048. if (type) {
  3049. this[type](e);
  3050. }
  3051. },
  3052. show: function(force) {
  3053. // in autostart mode wait for the document to be ready
  3054. if (this.options.autostart && !_DOMReady) {
  3055. setTimeout(this.show.bind(this), 50);
  3056. // we are not displaying callout because DOM not ready, but don't log that because
  3057. // it would log too frequently
  3058. return;
  3059. }
  3060. // message already on screen
  3061. if (this.shown) {
  3062. this.doLog("Add to homescreen: not displaying callout because already shown on screen");
  3063. return;
  3064. }
  3065. var now = Date.now();
  3066. var lastDisplayTime = this.session.lastDisplayTime;
  3067. if (force !== true) {
  3068. // this is needed if autostart is disabled and you programmatically call the show() method
  3069. if (!this.ready) {
  3070. this.doLog("Add to homescreen: not displaying callout because not ready");
  3071. return;
  3072. }
  3073. // we obey the display pace (prevent the message to popup too often)
  3074. if (now - lastDisplayTime < this.options.displayPace * 60000) {
  3075. this.doLog("Add to homescreen: not displaying callout because displayed recently");
  3076. return;
  3077. }
  3078. // obey the maximum number of display count
  3079. if (this.options.maxDisplayCount && this.session.displayCount >= this.options.maxDisplayCount) {
  3080. this.doLog("Add to homescreen: not displaying callout because displayed too many times already");
  3081. return;
  3082. }
  3083. }
  3084. this.shown = true;
  3085. // increment the display count
  3086. this.session.lastDisplayTime = now;
  3087. this.session.displayCount++;
  3088. this.updateSession();
  3089. // try to get the highest resolution application icon
  3090. if (!this.applicationIcon) {
  3091. if (ath.OS == 'ios') {
  3092. this.applicationIcon = document.querySelector('head link[rel^=apple-touch-icon][sizes="152x152"],head link[rel^=apple-touch-icon][sizes="144x144"],head link[rel^=apple-touch-icon][sizes="120x120"],head link[rel^=apple-touch-icon][sizes="114x114"],head link[rel^=apple-touch-icon]');
  3093. } else {
  3094. this.applicationIcon = document.querySelector('head link[rel^="shortcut icon"][sizes="196x196"],head link[rel^=apple-touch-icon]');
  3095. }
  3096. }
  3097. var message = '';
  3098. if (typeof this.options.message == 'object' && ath.language in this.options.message) { // use custom language message
  3099. message = this.options.message[ath.language][ath.OS];
  3100. } else if (typeof this.options.message == 'object' && ath.OS in this.options.message) { // use custom os message
  3101. message = this.options.message[ath.OS];
  3102. } else if (this.options.message in ath.intl) { // you can force the locale
  3103. message = ath.intl[this.options.message][ath.OS];
  3104. } else if (this.options.message !== '') { // use a custom message
  3105. message = this.options.message;
  3106. } else if (ath.OS in ath.intl[ath.language]) { // otherwise we use our message
  3107. message = ath.intl[ath.language][ath.OS];
  3108. }
  3109. // add the action icon
  3110. message = '<p>' + message.replace('%icon', '<span class="ath-action-icon">icon</span>') + '</p>';
  3111. // create the message container
  3112. this.viewport = document.createElement('div');
  3113. this.viewport.className = 'ath-viewport';
  3114. if (this.options.modal) {
  3115. this.viewport.className += ' ath-modal';
  3116. }
  3117. if (this.options.mandatory) {
  3118. this.viewport.className += ' ath-mandatory';
  3119. }
  3120. this.viewport.style.position = 'absolute';
  3121. // create the actual message element
  3122. this.element = document.createElement('div');
  3123. this.element.className = 'ath-container ath-' + ath.OS + ' ath-' + ath.OS + (ath.OSVersion + '').substr(0, 1) + ' ath-' + (ath.isTablet ? 'tablet' : 'phone');
  3124. this.element.style.cssText = '-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:0s;-webkit-transition-timing-function:ease-out;transition-property:transform,opacity;transition-duration:0s;transition-timing-function:ease-out;';
  3125. this.element.style.webkitTransform = 'translate3d(0,-' + window.innerHeight + 'px,0)';
  3126. this.element.style.transform = 'translate3d(0,-' + window.innerHeight + 'px,0)';
  3127. // add the application icon
  3128. if (this.options.icon && this.applicationIcon) {
  3129. this.element.className += ' ath-icon';
  3130. this.img = document.createElement('img');
  3131. this.img.className = 'ath-application-icon';
  3132. this.img.addEventListener('load', this, false);
  3133. this.img.addEventListener('error', this, false);
  3134. this.img.src = this.applicationIcon.href;
  3135. this.element.appendChild(this.img);
  3136. }
  3137. this.element.innerHTML += message;
  3138. // we are not ready to show, place the message out of sight
  3139. this.viewport.style.left = '-99999em';
  3140. // attach all elements to the DOM
  3141. this.viewport.appendChild(this.element);
  3142. this.container.appendChild(this.viewport);
  3143. // if we don't have to wait for an image to load, show the message right away
  3144. if (this.img) {
  3145. this.doLog("Add to homescreen: not displaying callout because waiting for img to load");
  3146. } else {
  3147. this._delayedShow();
  3148. }
  3149. },
  3150. _delayedShow: function(e) {
  3151. setTimeout(this._show.bind(this), this.options.startDelay * 1000 + 500);
  3152. },
  3153. _show: function() {
  3154. var that = this;
  3155. // update the viewport size and orientation
  3156. this.updateViewport();
  3157. // reposition/resize the message on orientation change
  3158. window.addEventListener('resize', this, false);
  3159. window.addEventListener('scroll', this, false);
  3160. window.addEventListener('orientationchange', this, false);
  3161. if (this.options.modal) {
  3162. // lock any other interaction
  3163. document.addEventListener('touchmove', this, true);
  3164. }
  3165. // Enable closing after 1 second
  3166. if (!this.options.mandatory) {
  3167. setTimeout(function() {
  3168. that.element.addEventListener('click', that, true);
  3169. }, 1000);
  3170. }
  3171. // kick the animation
  3172. setTimeout(function() {
  3173. that.element.style.webkitTransitionDuration = '1.2s';
  3174. that.element.style.transitionDuration = '1.2s';
  3175. that.element.style.webkitTransform = 'translate3d(0,0,0)';
  3176. that.element.style.transform = 'translate3d(0,0,0)';
  3177. }, 0);
  3178. // set the destroy timer
  3179. if (this.options.lifespan) {
  3180. this.removeTimer = setTimeout(this.remove.bind(this), this.options.lifespan * 1000);
  3181. }
  3182. // fire the custom onShow event
  3183. if (this.options.onShow) {
  3184. this.options.onShow.call(this);
  3185. }
  3186. },
  3187. remove: function() {
  3188. clearTimeout(this.removeTimer);
  3189. // clear up the event listeners
  3190. if (this.img) {
  3191. this.img.removeEventListener('load', this, false);
  3192. this.img.removeEventListener('error', this, false);
  3193. }
  3194. window.removeEventListener('resize', this, false);
  3195. window.removeEventListener('scroll', this, false);
  3196. window.removeEventListener('orientationchange', this, false);
  3197. document.removeEventListener('touchmove', this, true);
  3198. this.element.removeEventListener('click', this, true);
  3199. // remove the message element on transition end
  3200. this.element.addEventListener('transitionend', this, false);
  3201. this.element.addEventListener('webkitTransitionEnd', this, false);
  3202. this.element.addEventListener('MSTransitionEnd', this, false);
  3203. // start the fade out animation
  3204. this.element.style.webkitTransitionDuration = '0.3s';
  3205. this.element.style.opacity = '0';
  3206. },
  3207. _removeElements: function() {
  3208. this.element.removeEventListener('transitionend', this, false);
  3209. this.element.removeEventListener('webkitTransitionEnd', this, false);
  3210. this.element.removeEventListener('MSTransitionEnd', this, false);
  3211. // remove the message from the DOM
  3212. this.container.removeChild(this.viewport);
  3213. this.shown = false;
  3214. // fire the custom onRemove event
  3215. if (this.options.onRemove) {
  3216. this.options.onRemove.call(this);
  3217. }
  3218. },
  3219. updateViewport: function() {
  3220. if (!this.shown) {
  3221. return;
  3222. }
  3223. this.viewport.style.width = window.innerWidth + 'px';
  3224. this.viewport.style.height = window.innerHeight + 'px';
  3225. this.viewport.style.left = window.scrollX + 'px';
  3226. this.viewport.style.top = window.scrollY + 'px';
  3227. var clientWidth = document.documentElement.clientWidth;
  3228. this.orientation = clientWidth > document.documentElement.clientHeight ? 'landscape' : 'portrait';
  3229. var screenWidth = ath.OS == 'ios' ? this.orientation == 'portrait' ? screen.width : screen.height : screen.width;
  3230. this.scale = screen.width > clientWidth ? 1 : screenWidth / window.innerWidth;
  3231. this.element.style.fontSize = this.options.fontSize / this.scale + 'px';
  3232. },
  3233. resize: function() {
  3234. clearTimeout(this.resizeTimer);
  3235. this.resizeTimer = setTimeout(this.updateViewport.bind(this), 100);
  3236. },
  3237. updateSession: function() {
  3238. if (ath.hasLocalStorage === false) {
  3239. return;
  3240. }
  3241. if (localStorage) {
  3242. localStorage.setItem(this.options.appID, JSON.stringify(this.session));
  3243. }
  3244. },
  3245. clearSession: function() {
  3246. this.session = _defaultSession;
  3247. this.updateSession();
  3248. },
  3249. getItem: function(item) {
  3250. try {
  3251. if (!localStorage) {
  3252. throw new Error('localStorage is not defined');
  3253. }
  3254. return localStorage.getItem(item);
  3255. } catch (e) {
  3256. // Preventing exception for some browsers when fetching localStorage key
  3257. ath.hasLocalStorage = false;
  3258. }
  3259. },
  3260. optOut: function() {
  3261. this.session.optedout = true;
  3262. this.updateSession();
  3263. },
  3264. optIn: function() {
  3265. this.session.optedout = false;
  3266. this.updateSession();
  3267. },
  3268. clearDisplayCount: function() {
  3269. this.session.displayCount = 0;
  3270. this.updateSession();
  3271. },
  3272. _preventDefault: function(e) {
  3273. e.preventDefault();
  3274. e.stopPropagation();
  3275. }
  3276. };
  3277. // utility
  3278. function _extend(target, obj) {
  3279. for (var i in obj) {
  3280. target[i] = obj[i];
  3281. }
  3282. return target;
  3283. }
  3284. function _removeToken() {
  3285. if (document.location.hash == '#ath') {
  3286. history.replaceState('', window.document.title, document.location.href.split('#')[0]);
  3287. }
  3288. if (_reSmartURL.test(document.location.href)) {
  3289. history.replaceState('', window.document.title, document.location.href.replace(_reSmartURL, '$1'));
  3290. }
  3291. if (_reQueryString.test(document.location.search)) {
  3292. history.replaceState('', window.document.title, document.location.href.replace(_reQueryString, '$2'));
  3293. }
  3294. }
  3295. /* jshint +W101, +W106 */
  3296. ath.VERSION = '3.2.2';
  3297. module.exports = UI.addToHomescreen = ath;
  3298. /***/ },
  3299. /* 5 */
  3300. /***/ function(module, exports, __webpack_require__) {
  3301. 'use strict';
  3302. var $ = __webpack_require__(1);
  3303. var UI = __webpack_require__(2);
  3304. /**
  3305. * @via https://github.com/Minwe/bootstrap/blob/master/js/alert.js
  3306. * @copyright Copyright 2013 Twitter, Inc.
  3307. * @license Apache 2.0
  3308. */
  3309. // Alert Class
  3310. // NOTE: removeElement option is unavailable now
  3311. var Alert = function(element, options) {
  3312. var _this = this;
  3313. this.options = $.extend({}, Alert.DEFAULTS, options);
  3314. this.$element = $(element);
  3315. this.$element
  3316. .addClass('am-fade am-in')
  3317. .on('click.alert.amui', '.am-close', function() {
  3318. _this.close();
  3319. });
  3320. };
  3321. Alert.DEFAULTS = {
  3322. removeElement: true
  3323. };
  3324. Alert.prototype.close = function() {
  3325. var $element = this.$element;
  3326. $element.trigger('close.alert.amui').removeClass('am-in');
  3327. function processAlert() {
  3328. $element.trigger('closed.alert.amui').remove();
  3329. }
  3330. UI.support.transition && $element.hasClass('am-fade') ?
  3331. $element
  3332. .one(UI.support.transition.end, processAlert)
  3333. .emulateTransitionEnd(200) :
  3334. processAlert();
  3335. };
  3336. // plugin
  3337. UI.plugin('alert', Alert);
  3338. // Init code
  3339. $(document).on('click.alert.amui.data-api', '[data-am-alert]', function(e) {
  3340. var $target = $(e.target);
  3341. $target.is('.am-close') && $(this).alert('close');
  3342. });
  3343. module.exports = Alert;
  3344. /***/ },
  3345. /* 6 */
  3346. /***/ function(module, exports, __webpack_require__) {
  3347. 'use strict';
  3348. var $ = __webpack_require__(1);
  3349. var UI = __webpack_require__(2);
  3350. /**
  3351. * @via https://github.com/twbs/bootstrap/blob/master/js/button.js
  3352. * @copyright (c) 2011-2014 Twitter, Inc
  3353. * @license The MIT License
  3354. */
  3355. var Button = function(element, options) {
  3356. this.$element = $(element);
  3357. this.options = $.extend({}, Button.DEFAULTS, options);
  3358. this.isLoading = false;
  3359. this.hasSpinner = false;
  3360. };
  3361. Button.DEFAULTS = {
  3362. loadingText: 'loading...',
  3363. disabledClassName: 'am-disabled',
  3364. spinner: undefined
  3365. };
  3366. Button.prototype.setState = function(state, stateText) {
  3367. var $element = this.$element;
  3368. var disabled = 'disabled';
  3369. var data = $element.data();
  3370. var options = this.options;
  3371. var val = $element.is('input') ? 'val' : 'html';
  3372. var stateClassName = 'am-btn-' + state + ' ' + options.disabledClassName;
  3373. state += 'Text';
  3374. if (!options.resetText) {
  3375. options.resetText = $element[val]();
  3376. }
  3377. // add spinner for element with html()
  3378. if (UI.support.animation && options.spinner &&
  3379. val === 'html' && !this.hasSpinner) {
  3380. options.loadingText = '<span class="am-icon-' + options.spinner +
  3381. ' am-icon-spin"></span>' + options.loadingText;
  3382. this.hasSpinner = true;
  3383. }
  3384. stateText = stateText ||
  3385. (data[state] === undefined ? options[state] : data[state]);
  3386. $element[val](stateText);
  3387. // push to event loop to allow forms to submit
  3388. setTimeout($.proxy(function() {
  3389. // TODO: add stateClass for other states
  3390. if (state === 'loadingText') {
  3391. $element.addClass(stateClassName).attr(disabled, disabled);
  3392. this.isLoading = true;
  3393. } else if (this.isLoading) {
  3394. $element.removeClass(stateClassName).removeAttr(disabled);
  3395. this.isLoading = false;
  3396. }
  3397. }, this), 0);
  3398. };
  3399. Button.prototype.toggle = function() {
  3400. var changed = true;
  3401. var $element = this.$element;
  3402. var $parent = this.$element.parent('[class*="am-btn-group"]');
  3403. if ($parent.length) {
  3404. var $input = this.$element.find('input');
  3405. if ($input.prop('type') == 'radio') {
  3406. if ($input.prop('checked') && $element.hasClass('am-active')) {
  3407. changed = false;
  3408. } else {
  3409. $parent.find('.am-active').removeClass('am-active');
  3410. }
  3411. }
  3412. if (changed) {
  3413. $input.prop('checked',
  3414. !$element.hasClass('am-active')).trigger('change');
  3415. }
  3416. }
  3417. if (changed) {
  3418. $element.toggleClass('am-active');
  3419. if (!$element.hasClass('am-active')) {
  3420. $element.blur();
  3421. }
  3422. }
  3423. };
  3424. UI.plugin('button', Button, {
  3425. dataOptions: 'data-am-loading',
  3426. methodCall: function(args, instance) {
  3427. if (args[0] === 'toggle') {
  3428. instance.toggle();
  3429. } else if (typeof args[0] === 'string') {
  3430. instance.setState.apply(instance, args);
  3431. }
  3432. }
  3433. });
  3434. // Init code
  3435. $(document).on('click.button.amui.data-api', '[data-am-button]', function(e) {
  3436. e.preventDefault();
  3437. var $btn = $(e.target);
  3438. if (!$btn.hasClass('am-btn')) {
  3439. $btn = $btn.closest('.am-btn');
  3440. }
  3441. $btn.button('toggle');
  3442. });
  3443. UI.ready(function(context) {
  3444. $('[data-am-loading]', context).button();
  3445. });
  3446. module.exports = UI.button = Button;
  3447. /***/ },
  3448. /* 7 */
  3449. /***/ function(module, exports, __webpack_require__) {
  3450. 'use strict';
  3451. var $ = __webpack_require__(1);
  3452. var UI = __webpack_require__(2);
  3453. /**
  3454. * @via https://github.com/twbs/bootstrap/blob/master/js/collapse.js
  3455. * @copyright (c) 2011-2014 Twitter, Inc
  3456. * @license The MIT License
  3457. */
  3458. var Collapse = function(element, options) {
  3459. this.$element = $(element);
  3460. this.options = $.extend({}, Collapse.DEFAULTS, options);
  3461. this.transitioning = null;
  3462. if (this.options.parent) {
  3463. this.$parent = $(this.options.parent);
  3464. }
  3465. if (this.options.toggle) {
  3466. this.toggle();
  3467. }
  3468. };
  3469. Collapse.DEFAULTS = {
  3470. toggle: true
  3471. };
  3472. Collapse.prototype.open = function() {
  3473. if (this.transitioning || this.$element.hasClass('am-in')) {
  3474. return;
  3475. }
  3476. var startEvent = $.Event('open.collapse.amui');
  3477. this.$element.trigger(startEvent);
  3478. if (startEvent.isDefaultPrevented()) {
  3479. return;
  3480. }
  3481. var actives = this.$parent && this.$parent.find('> .am-panel > .am-in');
  3482. if (actives && actives.length) {
  3483. var hasData = actives.data('amui.collapse');
  3484. if (hasData && hasData.transitioning) {
  3485. return;
  3486. }
  3487. Plugin.call(actives, 'close');
  3488. hasData || actives.data('amui.collapse', null);
  3489. }
  3490. this.$element
  3491. .removeClass('am-collapse')
  3492. .addClass('am-collapsing').height(0);
  3493. this.transitioning = 1;
  3494. var complete = function() {
  3495. this.$element
  3496. .removeClass('am-collapsing')
  3497. .addClass('am-collapse am-in')
  3498. .height('')
  3499. .trigger('opened.collapse.amui');
  3500. this.transitioning = 0;
  3501. };
  3502. if (!UI.support.transition) {
  3503. return complete.call(this);
  3504. }
  3505. var scrollHeight = this.$element[0].scrollHeight;
  3506. this.$element
  3507. .one(UI.support.transition.end, $.proxy(complete, this))
  3508. .emulateTransitionEnd(300)
  3509. .css({height: scrollHeight}); // ���۵��������� padding ʱ������� height() ֻ���������ݵĿ��
  3510. };
  3511. Collapse.prototype.close = function() {
  3512. if (this.transitioning || !this.$element.hasClass('am-in')) {
  3513. return;
  3514. }
  3515. var startEvent = $.Event('close.collapse.amui');
  3516. this.$element.trigger(startEvent);
  3517. if (startEvent.isDefaultPrevented()) {
  3518. return;
  3519. }
  3520. this.$element.height(this.$element.height()).redraw();
  3521. this.$element.addClass('am-collapsing').
  3522. removeClass('am-collapse am-in');
  3523. this.transitioning = 1;
  3524. var complete = function() {
  3525. this.transitioning = 0;
  3526. this.$element
  3527. .trigger('closed.collapse.amui')
  3528. .removeClass('am-collapsing')
  3529. .addClass('am-collapse');
  3530. // css({height: '0'});
  3531. };
  3532. if (!UI.support.transition) {
  3533. return complete.call(this);
  3534. }
  3535. this.$element.height(0)
  3536. .one(UI.support.transition.end, $.proxy(complete, this))
  3537. .emulateTransitionEnd(300);
  3538. };
  3539. Collapse.prototype.toggle = function() {
  3540. this[this.$element.hasClass('am-in') ? 'close' : 'open']();
  3541. };
  3542. // Collapse Plugin
  3543. function Plugin(option) {
  3544. return this.each(function() {
  3545. var $this = $(this);
  3546. var data = $this.data('amui.collapse');
  3547. var options = $.extend({}, Collapse.DEFAULTS,
  3548. UI.utils.options($this.attr('data-am-collapse')),
  3549. typeof option == 'object' && option);
  3550. if (!data && options.toggle && option === 'open') {
  3551. option = !option;
  3552. }
  3553. if (!data) {
  3554. $this.data('amui.collapse', (data = new Collapse(this, options)));
  3555. }
  3556. if (typeof option == 'string') {
  3557. data[option]();
  3558. }
  3559. });
  3560. }
  3561. $.fn.collapse = Plugin;
  3562. // Init code
  3563. $(document).on('click.collapse.amui.data-api', '[data-am-collapse]',
  3564. function(e) {
  3565. var href;
  3566. var $this = $(this);
  3567. var options = UI.utils.options($this.attr('data-am-collapse'));
  3568. var target = options.target ||
  3569. e.preventDefault() ||
  3570. (href = $this.attr('href')) &&
  3571. href.replace(/.*(?=#[^\s]+$)/, '');
  3572. var $target = $(target);
  3573. var data = $target.data('amui.collapse');
  3574. var option = data ? 'toggle' : options;
  3575. var parent = options.parent;
  3576. var $parent = parent && $(parent);
  3577. if (!data || !data.transitioning) {
  3578. if ($parent) {
  3579. // '[data-am-collapse*="{parent: \'' + parent + '"]
  3580. $parent.find('[data-am-collapse]').not($this).addClass('am-collapsed');
  3581. }
  3582. $this[$target.hasClass('am-in') ?
  3583. 'addClass' : 'removeClass']('am-collapsed');
  3584. }
  3585. Plugin.call($target, option);
  3586. });
  3587. module.exports = UI.collapse = Collapse;
  3588. // TODO: ���õ� target ѡ��ʽ
  3589. // �۵�����������û�� border/padding ���������������򶯻�����һЩС����
  3590. // Ѱ�Ҹ��õ�δ֪�߶� transition �������������max-height ֮��ľ�����
  3591. /***/ },
  3592. /* 8 */
  3593. /***/ function(module, exports, __webpack_require__) {
  3594. 'use strict';
  3595. var $ = __webpack_require__(1);
  3596. var UI = __webpack_require__(2);
  3597. var $doc = $(document);
  3598. /**
  3599. * bootstrap-datepicker.js
  3600. * @via http://www.eyecon.ro/bootstrap-datepicker
  3601. * @license http://www.apache.org/licenses/LICENSE-2.0
  3602. */
  3603. var Datepicker = function(element, options) {
  3604. this.$element = $(element);
  3605. this.options = $.extend({}, Datepicker.DEFAULTS, options);
  3606. this.format = DPGlobal.parseFormat(this.options.format);
  3607. this.$element.data('date', this.options.date);
  3608. this.language = this.getLocale(this.options.locale);
  3609. this.theme = this.options.theme;
  3610. this.$picker = $(DPGlobal.template).appendTo('body').on({
  3611. click: $.proxy(this.click, this)
  3612. // mousedown: $.proxy(this.mousedown, this)
  3613. });
  3614. this.isInput = this.$element.is('input');
  3615. this.component = this.$element.is('.am-datepicker-date') ?
  3616. this.$element.find('.am-datepicker-add-on') : false;
  3617. if (this.isInput) {
  3618. this.$element.on({
  3619. 'click.datepicker.amui': $.proxy(this.open, this),
  3620. // blur: $.proxy(this.close, this),
  3621. 'keyup.datepicker.amui': $.proxy(this.update, this)
  3622. });
  3623. } else {
  3624. if (this.component) {
  3625. this.component.on('click.datepicker.amui', $.proxy(this.open, this));
  3626. } else {
  3627. this.$element.on('click.datepicker.amui', $.proxy(this.open, this));
  3628. }
  3629. }
  3630. this.minViewMode = this.options.minViewMode;
  3631. if (typeof this.minViewMode === 'string') {
  3632. switch (this.minViewMode) {
  3633. case 'months':
  3634. this.minViewMode = 1;
  3635. break;
  3636. case 'years':
  3637. this.minViewMode = 2;
  3638. break;
  3639. default:
  3640. this.minViewMode = 0;
  3641. break;
  3642. }
  3643. }
  3644. this.viewMode = this.options.viewMode;
  3645. if (typeof this.viewMode === 'string') {
  3646. switch (this.viewMode) {
  3647. case 'months':
  3648. this.viewMode = 1;
  3649. break;
  3650. case 'years':
  3651. this.viewMode = 2;
  3652. break;
  3653. default:
  3654. this.viewMode = 0;
  3655. break;
  3656. }
  3657. }
  3658. this.startViewMode = this.viewMode;
  3659. this.weekStart = ((this.options.weekStart ||
  3660. Datepicker.locales[this.language].weekStart || 0) % 7);
  3661. this.weekEnd = ((this.weekStart + 6) % 7);
  3662. this.onRender = this.options.onRender;
  3663. this.setTheme();
  3664. this.fillDow();
  3665. this.fillMonths();
  3666. this.update();
  3667. this.showMode();
  3668. };
  3669. Datepicker.DEFAULTS = {
  3670. locale: 'zh_CN',
  3671. format: 'yyyy-mm-dd',
  3672. weekStart: undefined,
  3673. viewMode: 0,
  3674. minViewMode: 0,
  3675. date: '',
  3676. theme: '',
  3677. autoClose: 1,
  3678. onRender: function(date) {
  3679. return '';
  3680. }
  3681. };
  3682. Datepicker.prototype.open = function(e) {
  3683. this.$picker.show();
  3684. this.height = this.component ?
  3685. this.component.outerHeight() : this.$element.outerHeight();
  3686. this.place();
  3687. $(window).on('resize.datepicker.amui', $.proxy(this.place, this));
  3688. if (e) {
  3689. e.stopPropagation();
  3690. e.preventDefault();
  3691. }
  3692. var that = this;
  3693. $doc.on('mousedown.datapicker.amui touchstart.datepicker.amui', function(ev) {
  3694. if ($(ev.target).closest('.am-datepicker').length === 0) {
  3695. that.close();
  3696. }
  3697. });
  3698. this.$element.trigger({
  3699. type: 'open.datepicker.amui',
  3700. date: this.date
  3701. });
  3702. };
  3703. Datepicker.prototype.close = function() {
  3704. this.$picker.hide();
  3705. $(window).off('resize.datepicker.amui', this.place);
  3706. this.viewMode = this.startViewMode;
  3707. this.showMode();
  3708. if (!this.isInput) {
  3709. $(document).off('mousedown.datapicker.amui touchstart.datepicker.amui',
  3710. this.close);
  3711. }
  3712. // this.set();
  3713. this.$element.trigger({
  3714. type: 'close.datepicker.amui',
  3715. date: this.date
  3716. });
  3717. };
  3718. Datepicker.prototype.set = function() {
  3719. var formatted = DPGlobal.formatDate(this.date, this.format);
  3720. var $input;
  3721. if (!this.isInput) {
  3722. if (this.component) {
  3723. $input = this.$element.find('input').attr('value', formatted);
  3724. }
  3725. this.$element.data('date', formatted);
  3726. } else {
  3727. $input = this.$element.attr('value', formatted);
  3728. }
  3729. // fixes https://github.com/amazeui/amazeui/issues/711
  3730. $input.trigger('change');
  3731. };
  3732. Datepicker.prototype.setValue = function(newDate) {
  3733. if (typeof newDate === 'string') {
  3734. this.date = DPGlobal.parseDate(newDate, this.format);
  3735. } else {
  3736. this.date = new Date(newDate);
  3737. }
  3738. this.set();
  3739. this.viewDate = new Date(this.date.getFullYear(),
  3740. this.date.getMonth(), 1, 0, 0, 0, 0);
  3741. this.fill();
  3742. };
  3743. Datepicker.prototype.place = function() {
  3744. var offset = this.component ?
  3745. this.component.offset() : this.$element.offset();
  3746. var $width = this.component ?
  3747. this.component.width() : this.$element.width();
  3748. var top = offset.top + this.height;
  3749. var left = offset.left;
  3750. var right = $doc.width() - offset.left - $width;
  3751. var isOutView = this.isOutView();
  3752. this.$picker.removeClass('am-datepicker-right');
  3753. this.$picker.removeClass('am-datepicker-up');
  3754. if ($doc.width() > 640) {
  3755. if (isOutView.outRight) {
  3756. this.$picker.addClass('am-datepicker-right');
  3757. this.$picker.css({
  3758. top: top,
  3759. left: 'auto',
  3760. right: right
  3761. });
  3762. return;
  3763. }
  3764. if (isOutView.outBottom) {
  3765. this.$picker.addClass('am-datepicker-up');
  3766. top = offset.top - this.$picker.outerHeight(true);
  3767. }
  3768. } else {
  3769. left = 0;
  3770. }
  3771. this.$picker.css({
  3772. top: top,
  3773. left: left
  3774. });
  3775. };
  3776. Datepicker.prototype.update = function(newDate) {
  3777. this.date = DPGlobal.parseDate(
  3778. typeof newDate === 'string' ? newDate : (this.isInput ?
  3779. this.$element.prop('value') : this.$element.data('date')),
  3780. this.format
  3781. );
  3782. this.viewDate = new Date(this.date.getFullYear(),
  3783. this.date.getMonth(), 1, 0, 0, 0, 0);
  3784. this.fill();
  3785. };
  3786. // Days of week
  3787. Datepicker.prototype.fillDow = function() {
  3788. var dowCount = this.weekStart;
  3789. var html = '<tr>';
  3790. while (dowCount < this.weekStart + 7) {
  3791. // NOTE: do % then add 1
  3792. html += '<th class="am-datepicker-dow">' +
  3793. Datepicker.locales[this.language].daysMin[(dowCount++) % 7] +
  3794. '</th>';
  3795. }
  3796. html += '</tr>';
  3797. this.$picker.find('.am-datepicker-days thead').append(html);
  3798. };
  3799. Datepicker.prototype.fillMonths = function() {
  3800. var html = '';
  3801. var i = 0;
  3802. while (i < 12) {
  3803. html += '<span class="am-datepicker-month">' +
  3804. Datepicker.locales[this.language].monthsShort[i++] + '</span>';
  3805. }
  3806. this.$picker.find('.am-datepicker-months td').append(html);
  3807. };
  3808. Datepicker.prototype.fill = function() {
  3809. var d = new Date(this.viewDate);
  3810. var year = d.getFullYear();
  3811. var month = d.getMonth();
  3812. var currentDate = this.date.valueOf();
  3813. var prevMonth = new Date(year, month - 1, 28, 0, 0, 0, 0);
  3814. var day = DPGlobal
  3815. .getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
  3816. var daysSelect = this.$picker
  3817. .find('.am-datepicker-days .am-datepicker-select');
  3818. if (this.language === 'zh_CN') {
  3819. daysSelect.text(year + Datepicker.locales[this.language].year[0] +
  3820. ' ' + Datepicker.locales[this.language].months[month]);
  3821. } else {
  3822. daysSelect.text(Datepicker.locales[this.language].months[month] +
  3823. ' ' + year);
  3824. }
  3825. prevMonth.setDate(day);
  3826. prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7) % 7);
  3827. var nextMonth = new Date(prevMonth);
  3828. nextMonth.setDate(nextMonth.getDate() + 42);
  3829. nextMonth = nextMonth.valueOf();
  3830. var html = [];
  3831. var className;
  3832. var prevY;
  3833. var prevM;
  3834. while (prevMonth.valueOf() < nextMonth) {
  3835. if (prevMonth.getDay() === this.weekStart) {
  3836. html.push('<tr>');
  3837. }
  3838. className = this.onRender(prevMonth, 0);
  3839. prevY = prevMonth.getFullYear();
  3840. prevM = prevMonth.getMonth();
  3841. if ((prevM < month && prevY === year) || prevY < year) {
  3842. className += ' am-datepicker-old';
  3843. } else if ((prevM > month && prevY === year) || prevY > year) {
  3844. className += ' am-datepicker-new';
  3845. }
  3846. if (prevMonth.valueOf() === currentDate) {
  3847. className += ' am-active';
  3848. }
  3849. html.push('<td class="am-datepicker-day ' +
  3850. className + '">' + prevMonth.getDate() + '</td>');
  3851. if (prevMonth.getDay() === this.weekEnd) {
  3852. html.push('</tr>');
  3853. }
  3854. prevMonth.setDate(prevMonth.getDate() + 1);
  3855. }
  3856. this.$picker.find('.am-datepicker-days tbody')
  3857. .empty().append(html.join(''));
  3858. var currentYear = this.date.getFullYear();
  3859. var months = this.$picker.find('.am-datepicker-months')
  3860. .find('.am-datepicker-select')
  3861. .text(year);
  3862. months = months.end()
  3863. .find('span').removeClass('am-active').removeClass('am-disabled');
  3864. var monthLen = 0;
  3865. while (monthLen < 12) {
  3866. if (this.onRender(d.setFullYear(year, monthLen), 1)) {
  3867. months.eq(monthLen).addClass('am-disabled');
  3868. }
  3869. monthLen++;
  3870. }
  3871. if (currentYear === year) {
  3872. months.eq(this.date.getMonth())
  3873. .removeClass('am-disabled')
  3874. .addClass('am-active');
  3875. }
  3876. html = '';
  3877. year = parseInt(year / 10, 10) * 10;
  3878. var yearCont = this.$picker
  3879. .find('.am-datepicker-years')
  3880. .find('.am-datepicker-select')
  3881. .text(year + '-' + (year + 9))
  3882. .end()
  3883. .find('td');
  3884. var yearClassName;
  3885. // fixes https://github.com/amazeui/amazeui/issues/770
  3886. // maybe not need now
  3887. var viewDate = new Date(this.viewDate);
  3888. year -= 1;
  3889. for (var i = -1; i < 11; i++) {
  3890. yearClassName = this.onRender(viewDate.setFullYear(year), 2);
  3891. html += '<span class="' + yearClassName + '' +
  3892. (i === -1 || i === 10 ? ' am-datepicker-old' : '') +
  3893. (currentYear === year ? ' am-active' : '') + '">' + year + '</span>';
  3894. year += 1;
  3895. }
  3896. yearCont.html(html);
  3897. };
  3898. Datepicker.prototype.click = function(event) {
  3899. event.stopPropagation();
  3900. event.preventDefault();
  3901. var month;
  3902. var year;
  3903. var $dayActive = this.$picker.find('.am-datepicker-days').find('.am-active');
  3904. var $months = this.$picker.find('.am-datepicker-months');
  3905. var $monthIndex = $months.find('.am-active').index();
  3906. var $target = $(event.target).closest('span, td, th');
  3907. if ($target.length === 1) {
  3908. switch ($target[0].nodeName.toLowerCase()) {
  3909. case 'th':
  3910. switch ($target[0].className) {
  3911. case 'am-datepicker-switch':
  3912. this.showMode(1);
  3913. break;
  3914. case 'am-datepicker-prev':
  3915. case 'am-datepicker-next':
  3916. this.viewDate['set' + DPGlobal.modes[this.viewMode].navFnc].call(
  3917. this.viewDate,
  3918. this.viewDate
  3919. ['get' + DPGlobal.modes[this.viewMode].navFnc]
  3920. .call(this.viewDate) +
  3921. DPGlobal.modes[this.viewMode].navStep *
  3922. ($target[0].className === 'am-datepicker-prev' ? -1 : 1)
  3923. );
  3924. this.fill();
  3925. this.set();
  3926. break;
  3927. }
  3928. break;
  3929. case 'span':
  3930. if ($target.is('.am-disabled')) {
  3931. return;
  3932. }
  3933. if ($target.is('.am-datepicker-month')) {
  3934. month = $target.parent().find('span').index($target);
  3935. if ($target.is('.am-active')) {
  3936. this.viewDate.setMonth(month, $dayActive.text());
  3937. } else {
  3938. this.viewDate.setMonth(month);
  3939. }
  3940. } else {
  3941. year = parseInt($target.text(), 10) || 0;
  3942. if ($target.is('.am-active')) {
  3943. this.viewDate.setFullYear(year, $monthIndex, $dayActive.text());
  3944. } else {
  3945. this.viewDate.setFullYear(year);
  3946. }
  3947. }
  3948. if (this.viewMode !== 0) {
  3949. this.date = new Date(this.viewDate);
  3950. this.$element.trigger({
  3951. type: 'changeDate.datepicker.amui',
  3952. date: this.date,
  3953. viewMode: DPGlobal.modes[this.viewMode].clsName
  3954. });
  3955. }
  3956. this.showMode(-1);
  3957. this.fill();
  3958. this.set();
  3959. break;
  3960. case 'td':
  3961. if ($target.is('.am-datepicker-day') && !$target.is('.am-disabled')) {
  3962. var day = parseInt($target.text(), 10) || 1;
  3963. month = this.viewDate.getMonth();
  3964. if ($target.is('.am-datepicker-old')) {
  3965. month -= 1;
  3966. } else if ($target.is('.am-datepicker-new')) {
  3967. month += 1;
  3968. }
  3969. year = this.viewDate.getFullYear();
  3970. this.date = new Date(year, month, day, 0, 0, 0, 0);
  3971. this.viewDate = new Date(year, month, Math.min(28, day), 0, 0, 0, 0);
  3972. this.fill();
  3973. this.set();
  3974. this.$element.trigger({
  3975. type: 'changeDate.datepicker.amui',
  3976. date: this.date,
  3977. viewMode: DPGlobal.modes[this.viewMode].clsName
  3978. });
  3979. this.options.autoClose && this.close();
  3980. }
  3981. break;
  3982. }
  3983. }
  3984. };
  3985. Datepicker.prototype.mousedown = function(event) {
  3986. event.stopPropagation();
  3987. event.preventDefault();
  3988. };
  3989. Datepicker.prototype.showMode = function(dir) {
  3990. if (dir) {
  3991. this.viewMode = Math.max(this.minViewMode,
  3992. Math.min(2, this.viewMode + dir));
  3993. }
  3994. this.$picker.find('>div').hide().
  3995. filter('.am-datepicker-' + DPGlobal.modes[this.viewMode].clsName).show();
  3996. };
  3997. Datepicker.prototype.isOutView = function() {
  3998. var offset = this.component ?
  3999. this.component.offset() : this.$element.offset();
  4000. var isOutView = {
  4001. outRight: false,
  4002. outBottom: false
  4003. };
  4004. var $picker = this.$picker;
  4005. var width = offset.left + $picker.outerWidth(true);
  4006. var height = offset.top + $picker.outerHeight(true) +
  4007. this.$element.innerHeight();
  4008. if (width > $doc.width()) {
  4009. isOutView.outRight = true;
  4010. }
  4011. if (height > $doc.height()) {
  4012. isOutView.outBottom = true;
  4013. }
  4014. return isOutView;
  4015. };
  4016. Datepicker.prototype.getLocale = function(locale) {
  4017. if (!locale) {
  4018. locale = navigator.language && navigator.language.split('-');
  4019. locale[1] = locale[1].toUpperCase();
  4020. locale = locale.join('_');
  4021. }
  4022. if (!Datepicker.locales[locale]) {
  4023. locale = 'en_US';
  4024. }
  4025. return locale;
  4026. };
  4027. Datepicker.prototype.setTheme = function() {
  4028. if (this.theme) {
  4029. this.$picker.addClass('am-datepicker-' + this.theme);
  4030. }
  4031. };
  4032. // Datepicker locales
  4033. Datepicker.locales = {
  4034. en_US: {
  4035. days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
  4036. 'Friday', 'Saturday'],
  4037. daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  4038. daysMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
  4039. months: ['January', 'February', 'March', 'April', 'May', 'June',
  4040. 'July', 'August', 'September', 'October', 'November', 'December'],
  4041. monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
  4042. 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  4043. weekStart: 0
  4044. },
  4045. zh_CN: {
  4046. days: ['������', '����һ', '���ڶ�', '������', '������', '������', '������'],
  4047. daysShort: ['����', '��һ', '�ܶ�', '����', '����', '����', '����'],
  4048. daysMin: ['��', 'һ', '��', '��', '��', '��', '��'],
  4049. months: ['һ��', '����', '����', '����', '����', '����', '����',
  4050. '����', '����', 'ʮ��', 'ʮһ��', 'ʮ����'],
  4051. monthsShort: ['һ��', '����', '����', '����', '����', '����',
  4052. '����', '����', '����', 'ʮ��', 'ʮһ��', 'ʮ����'],
  4053. weekStart: 1,
  4054. year: ['��']
  4055. }
  4056. };
  4057. var DPGlobal = {
  4058. modes: [
  4059. {
  4060. clsName: 'days',
  4061. navFnc: 'Month',
  4062. navStep: 1
  4063. },
  4064. {
  4065. clsName: 'months',
  4066. navFnc: 'FullYear',
  4067. navStep: 1
  4068. },
  4069. {
  4070. clsName: 'years',
  4071. navFnc: 'FullYear',
  4072. navStep: 10
  4073. }
  4074. ],
  4075. isLeapYear: function(year) {
  4076. return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
  4077. },
  4078. getDaysInMonth: function(year, month) {
  4079. return [31, (DPGlobal.isLeapYear(year) ? 29 : 28),
  4080. 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
  4081. },
  4082. parseFormat: function(format) {
  4083. var separator = format.match(/[.\/\-\s].*?/);
  4084. var parts = format.split(/\W+/);
  4085. if (!separator || !parts || parts.length === 0) {
  4086. throw new Error('Invalid date format.');
  4087. }
  4088. return {
  4089. separator: separator,
  4090. parts: parts
  4091. };
  4092. },
  4093. parseDate: function(date, format) {
  4094. var parts = date.split(format.separator);
  4095. var val;
  4096. date = new Date();
  4097. date.setHours(0);
  4098. date.setMinutes(0);
  4099. date.setSeconds(0);
  4100. date.setMilliseconds(0);
  4101. if (parts.length === format.parts.length) {
  4102. var year = date.getFullYear();
  4103. var day = date.getDate();
  4104. var month = date.getMonth();
  4105. for (var i = 0, cnt = format.parts.length; i < cnt; i++) {
  4106. val = parseInt(parts[i], 10) || 1;
  4107. switch (format.parts[i]) {
  4108. case 'dd':
  4109. case 'd':
  4110. day = val;
  4111. date.setDate(val);
  4112. break;
  4113. case 'mm':
  4114. case 'm':
  4115. month = val - 1;
  4116. date.setMonth(val - 1);
  4117. break;
  4118. case 'yy':
  4119. year = 2000 + val;
  4120. date.setFullYear(2000 + val);
  4121. break;
  4122. case 'yyyy':
  4123. year = val;
  4124. date.setFullYear(val);
  4125. break;
  4126. }
  4127. }
  4128. date = new Date(year, month, day, 0, 0, 0);
  4129. }
  4130. return date;
  4131. },
  4132. formatDate: function(date, format) {
  4133. var val = {
  4134. d: date.getDate(),
  4135. m: date.getMonth() + 1,
  4136. yy: date.getFullYear().toString().substring(2),
  4137. yyyy: date.getFullYear()
  4138. };
  4139. var dateArray = [];
  4140. val.dd = (val.d < 10 ? '0' : '') + val.d;
  4141. val.mm = (val.m < 10 ? '0' : '') + val.m;
  4142. for (var i = 0, cnt = format.parts.length; i < cnt; i++) {
  4143. dateArray.push(val[format.parts[i]]);
  4144. }
  4145. return dateArray.join(format.separator);
  4146. },
  4147. headTemplate: '<thead>' +
  4148. '<tr class="am-datepicker-header">' +
  4149. '<th class="am-datepicker-prev">' +
  4150. '<i class="am-datepicker-prev-icon"></i></th>' +
  4151. '<th colspan="5" class="am-datepicker-switch">' +
  4152. '<div class="am-datepicker-select"></div></th>' +
  4153. '<th class="am-datepicker-next"><i class="am-datepicker-next-icon"></i>' +
  4154. '</th></tr></thead>',
  4155. contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
  4156. };
  4157. DPGlobal.template = '<div class="am-datepicker am-datepicker-dropdown">' +
  4158. '<div class="am-datepicker-caret"></div>' +
  4159. '<div class="am-datepicker-days">' +
  4160. '<table class="am-datepicker-table">' +
  4161. DPGlobal.headTemplate +
  4162. '<tbody></tbody>' +
  4163. '</table>' +
  4164. '</div>' +
  4165. '<div class="am-datepicker-months">' +
  4166. '<table class="am-datepicker-table">' +
  4167. DPGlobal.headTemplate +
  4168. DPGlobal.contTemplate +
  4169. '</table>' +
  4170. '</div>' +
  4171. '<div class="am-datepicker-years">' +
  4172. '<table class="am-datepicker-table">' +
  4173. DPGlobal.headTemplate +
  4174. DPGlobal.contTemplate +
  4175. '</table>' +
  4176. '</div>' +
  4177. '</div>';
  4178. // jQuery plugin
  4179. UI.plugin('datepicker', Datepicker);
  4180. // Init code
  4181. UI.ready(function(context) {
  4182. $('[data-am-datepicker]').datepicker();
  4183. });
  4184. module.exports = UI.datepicker = Datepicker;
  4185. // TODO: 1. ���붯��
  4186. // 2. less �Ż�
  4187. /***/ },
  4188. /* 9 */
  4189. /***/ function(module, exports, __webpack_require__) {
  4190. 'use strict';
  4191. var $ = __webpack_require__(1);
  4192. var UI = __webpack_require__(2);
  4193. var $doc = $(document);
  4194. var transition = UI.support.transition;
  4195. var Dimmer = function() {
  4196. this.id = UI.utils.generateGUID('am-dimmer');
  4197. this.$element = $(Dimmer.DEFAULTS.tpl, {
  4198. id: this.id
  4199. });
  4200. this.inited = false;
  4201. this.scrollbarWidth = 0;
  4202. this.$used = $([]);
  4203. };
  4204. Dimmer.DEFAULTS = {
  4205. tpl: '<div class="am-dimmer" data-am-dimmer></div>'
  4206. };
  4207. Dimmer.prototype.init = function() {
  4208. if (!this.inited) {
  4209. $(document.body).append(this.$element);
  4210. this.inited = true;
  4211. $doc.trigger('init.dimmer.amui');
  4212. this.$element.on('touchmove.dimmer.amui', function(e) {
  4213. e.preventDefault();
  4214. });
  4215. }
  4216. return this;
  4217. };
  4218. Dimmer.prototype.open = function(relatedElement) {
  4219. if (!this.inited) {
  4220. this.init();
  4221. }
  4222. var $element = this.$element;
  4223. // ���ڶ��ص���
  4224. if (relatedElement) {
  4225. this.$used = this.$used.add($(relatedElement));
  4226. }
  4227. this.checkScrollbar().setScrollbar();
  4228. $element.show().trigger('open.dimmer.amui');
  4229. transition && $element.off(transition.end);
  4230. setTimeout(function() {
  4231. $element.addClass('am-active');
  4232. }, 0);
  4233. return this;
  4234. };
  4235. Dimmer.prototype.close = function(relatedElement, force) {
  4236. this.$used = this.$used.not($(relatedElement));
  4237. if (!force && this.$used.length) {
  4238. return this;
  4239. }
  4240. var $element = this.$element;
  4241. $element.removeClass('am-active').trigger('close.dimmer.amui');
  4242. function complete() {
  4243. $element.hide();
  4244. this.resetScrollbar();
  4245. }
  4246. // transition ? $element.one(transition.end, $.proxy(complete, this)) :
  4247. complete.call(this);
  4248. return this;
  4249. };
  4250. Dimmer.prototype.checkScrollbar = function() {
  4251. this.scrollbarWidth = UI.utils.measureScrollbar();
  4252. return this;
  4253. };
  4254. Dimmer.prototype.setScrollbar = function() {
  4255. var $body = $(document.body);
  4256. var bodyPaddingRight = parseInt(($body.css('padding-right') || 0), 10);
  4257. if (this.scrollbarWidth) {
  4258. $body.css('padding-right', bodyPaddingRight + this.scrollbarWidth);
  4259. }
  4260. $body.addClass('am-dimmer-active');
  4261. return this;
  4262. };
  4263. Dimmer.prototype.resetScrollbar = function() {
  4264. $(document.body).css('padding-right', '').removeClass('am-dimmer-active');
  4265. return this;
  4266. };
  4267. module.exports = UI.dimmer = new Dimmer();
  4268. /***/ },
  4269. /* 10 */
  4270. /***/ function(module, exports, __webpack_require__) {
  4271. 'use strict';
  4272. var $ = __webpack_require__(1);
  4273. var UI = __webpack_require__(2);
  4274. var animation = UI.support.animation;
  4275. /**
  4276. * @via https://github.com/Minwe/bootstrap/blob/master/js/dropdown.js
  4277. * @copyright (c) 2011-2014 Twitter, Inc
  4278. * @license The MIT License
  4279. */
  4280. // var toggle = '[data-am-dropdown] > .am-dropdown-toggle';
  4281. var Dropdown = function(element, options) {
  4282. this.options = $.extend({}, Dropdown.DEFAULTS, options);
  4283. options = this.options;
  4284. this.$element = $(element);
  4285. this.$toggle = this.$element.find(options.selector.toggle);
  4286. this.$dropdown = this.$element.find(options.selector.dropdown);
  4287. this.$boundary = (options.boundary === window) ? $(window) :
  4288. this.$element.closest(options.boundary);
  4289. this.$justify = (options.justify && $(options.justify).length &&
  4290. $(options.justify)) || undefined;
  4291. !this.$boundary.length && (this.$boundary = $(window));
  4292. this.active = this.$element.hasClass('am-active') ? true : false;
  4293. this.animating = null;
  4294. this.events();
  4295. };
  4296. Dropdown.DEFAULTS = {
  4297. animation: 'am-animation-slide-top-fixed',
  4298. boundary: window,
  4299. justify: undefined,
  4300. selector: {
  4301. dropdown: '.am-dropdown-content',
  4302. toggle: '.am-dropdown-toggle'
  4303. },
  4304. trigger: 'click'
  4305. };
  4306. Dropdown.prototype.toggle = function() {
  4307. this.clear();
  4308. if (this.animating) {
  4309. return;
  4310. }
  4311. this[this.active ? 'close' : 'open']();
  4312. };
  4313. Dropdown.prototype.open = function(e) {
  4314. var $toggle = this.$toggle;
  4315. var $element = this.$element;
  4316. var $dropdown = this.$dropdown;
  4317. if ($toggle.is('.am-disabled, :disabled')) {
  4318. return;
  4319. }
  4320. if (this.active) {
  4321. return;
  4322. }
  4323. $element.trigger('open.dropdown.amui').addClass('am-active');
  4324. $toggle.trigger('focus');
  4325. this.checkDimensions();
  4326. var complete = $.proxy(function() {
  4327. $element.trigger('opened.dropdown.amui');
  4328. this.active = true;
  4329. this.animating = 0;
  4330. }, this);
  4331. if (animation) {
  4332. this.animating = 1;
  4333. $dropdown.addClass(this.options.animation).
  4334. on(animation.end + '.open.dropdown.amui', $.proxy(function() {
  4335. complete();
  4336. $dropdown.removeClass(this.options.animation);
  4337. }, this));
  4338. } else {
  4339. complete();
  4340. }
  4341. };
  4342. Dropdown.prototype.close = function() {
  4343. if (!this.active) {
  4344. return;
  4345. }
  4346. // fix #165
  4347. // var animationName = this.options.animation + ' am-animation-reverse';
  4348. var animationName = 'am-dropdown-animation';
  4349. var $element = this.$element;
  4350. var $dropdown = this.$dropdown;
  4351. $element.trigger('close.dropdown.amui');
  4352. var complete = $.proxy(function complete() {
  4353. $element.
  4354. removeClass('am-active').
  4355. trigger('closed.dropdown.amui');
  4356. this.active = false;
  4357. this.animating = 0;
  4358. this.$toggle.blur();
  4359. }, this);
  4360. if (animation) {
  4361. $dropdown.removeClass(this.options.animation);
  4362. $dropdown.addClass(animationName);
  4363. this.animating = 1;
  4364. // animation
  4365. $dropdown.one(animation.end + '.close.dropdown.amui', function() {
  4366. $dropdown.removeClass(animationName);
  4367. complete();
  4368. });
  4369. } else {
  4370. complete();
  4371. }
  4372. };
  4373. Dropdown.prototype.enable = function() {
  4374. this.$toggle.prop('disabled', false);
  4375. },
  4376. Dropdown.prototype.disable = function() {
  4377. this.$toggle.prop('disabled', true);
  4378. },
  4379. Dropdown.prototype.checkDimensions = function() {
  4380. if (!this.$dropdown.length) {
  4381. return;
  4382. }
  4383. var $dropdown = this.$dropdown;
  4384. var offset = $dropdown.offset();
  4385. var width = $dropdown.outerWidth();
  4386. var boundaryWidth = this.$boundary.width();
  4387. var boundaryOffset = $.isWindow(this.boundary) && this.$boundary.offset() ?
  4388. this.$boundary.offset().left : 0;
  4389. if (this.$justify) {
  4390. // jQuery.fn.width() is really...
  4391. $dropdown.css({'min-width': this.$justify.css('width')});
  4392. }
  4393. if ((width + (offset.left - boundaryOffset)) > boundaryWidth) {
  4394. this.$element.addClass('am-dropdown-flip');
  4395. }
  4396. };
  4397. Dropdown.prototype.clear = function() {
  4398. $('[data-am-dropdown]').not(this.$element).each(function() {
  4399. var data = $(this).data('amui.dropdown');
  4400. data && data.close();
  4401. });
  4402. };
  4403. Dropdown.prototype.events = function() {
  4404. var eventNS = 'dropdown.amui';
  4405. // triggers = this.options.trigger.split(' '),
  4406. var $toggle = this.$toggle;
  4407. $toggle.on('click.' + eventNS, $.proxy(function(e) {
  4408. e.preventDefault();
  4409. this.toggle();
  4410. }, this));
  4411. /*for (var i = triggers.length; i--;) {
  4412. var trigger = triggers[i];
  4413. if (trigger === 'click') {
  4414. $toggle.on('click.' + eventNS, $.proxy(this.toggle, this))
  4415. }
  4416. if (trigger === 'focus' || trigger === 'hover') {
  4417. var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
  4418. var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
  4419. this.$element.on(eventIn + '.' + eventNS, $.proxy(this.open, this))
  4420. .on(eventOut + '.' + eventNS, $.proxy(this.close, this));
  4421. }
  4422. }*/
  4423. $(document).on('keydown.dropdown.amui', $.proxy(function(e) {
  4424. e.keyCode === 27 && this.active && this.close();
  4425. }, this)).on('click.outer.dropdown.amui', $.proxy(function(e) {
  4426. // var $target = $(e.target);
  4427. if (this.active &&
  4428. (this.$element[0] === e.target || !this.$element.find(e.target).length)) {
  4429. this.close();
  4430. }
  4431. }, this));
  4432. };
  4433. // Dropdown Plugin
  4434. UI.plugin('dropdown', Dropdown);
  4435. // Init code
  4436. UI.ready(function(context) {
  4437. $('[data-am-dropdown]', context).dropdown();
  4438. });
  4439. $(document).on('click.dropdown.amui.data-api', '.am-dropdown form',
  4440. function(e) {
  4441. e.stopPropagation();
  4442. });
  4443. module.exports = UI.dropdown = Dropdown;
  4444. // TODO: 1. �������� focus
  4445. // 2. ���� mouseenter / mouseleave ѡ��
  4446. // 3. �����Ӧ
  4447. /***/ },
  4448. /* 11 */
  4449. /***/ function(module, exports, __webpack_require__) {
  4450. /* WEBPACK VAR INJECTION */(function(setImmediate) {var $ = __webpack_require__(1);
  4451. var UI = __webpack_require__(2);
  4452. // MODIFIED:
  4453. // - LINE 226: add `<i></i>`
  4454. // - namespace
  4455. // - Init code
  4456. // TODO: start after x ms when pause on actions
  4457. /*
  4458. * jQuery FlexSlider v2.4.0
  4459. * Copyright 2012 WooThemes
  4460. * Contributing Author: Tyler Smith
  4461. */
  4462. // FlexSlider: Object Instance
  4463. $.flexslider = function(el, options) {
  4464. var slider = $(el);
  4465. // making variables public
  4466. slider.vars = $.extend({}, $.flexslider.defaults, options);
  4467. var namespace = slider.vars.namespace,
  4468. msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture,
  4469. touch = (( "ontouchstart" in window ) || msGesture || window.DocumentTouch && document instanceof DocumentTouch) && slider.vars.touch,
  4470. // depricating this idea, as devices are being released with both of these events
  4471. //eventType = (touch) ? "touchend" : "click",
  4472. eventType = "click touchend MSPointerUp keyup",
  4473. watchedEvent = "",
  4474. watchedEventClearTimer,
  4475. vertical = slider.vars.direction === "vertical",
  4476. reverse = slider.vars.reverse,
  4477. carousel = (slider.vars.itemWidth > 0),
  4478. fade = slider.vars.animation === "fade",
  4479. asNav = slider.vars.asNavFor !== "",
  4480. methods = {},
  4481. focused = true;
  4482. // Store a reference to the slider object
  4483. $.data(el, 'flexslider', slider);
  4484. // Private slider methods
  4485. methods = {
  4486. init: function() {
  4487. slider.animating = false;
  4488. // Get current slide and make sure it is a number
  4489. slider.currentSlide = parseInt((slider.vars.startAt ? slider.vars.startAt : 0), 10);
  4490. if (isNaN(slider.currentSlide)) {
  4491. slider.currentSlide = 0;
  4492. }
  4493. slider.animatingTo = slider.currentSlide;
  4494. slider.atEnd = (slider.currentSlide === 0 || slider.currentSlide === slider.last);
  4495. slider.containerSelector = slider.vars.selector.substr(0, slider.vars.selector.search(' '));
  4496. slider.slides = $(slider.vars.selector, slider);
  4497. slider.container = $(slider.containerSelector, slider);
  4498. slider.count = slider.slides.length;
  4499. // SYNC:
  4500. slider.syncExists = $(slider.vars.sync).length > 0;
  4501. // SLIDE:
  4502. if (slider.vars.animation === "slide") {
  4503. slider.vars.animation = "swing";
  4504. }
  4505. slider.prop = (vertical) ? "top" : "marginLeft";
  4506. slider.args = {};
  4507. // SLIDESHOW:
  4508. slider.manualPause = false;
  4509. slider.stopped = false;
  4510. //PAUSE WHEN INVISIBLE
  4511. slider.started = false;
  4512. slider.startTimeout = null;
  4513. // TOUCH/USECSS:
  4514. slider.transitions = !slider.vars.video && !fade && slider.vars.useCSS && (function() {
  4515. var obj = document.createElement('div'),
  4516. props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
  4517. for (var i in props) {
  4518. if (obj.style[props[i]] !== undefined) {
  4519. slider.pfx = props[i].replace('Perspective', '').toLowerCase();
  4520. slider.prop = "-" + slider.pfx + "-transform";
  4521. return true;
  4522. }
  4523. }
  4524. return false;
  4525. }());
  4526. slider.ensureAnimationEnd = '';
  4527. // CONTROLSCONTAINER:
  4528. if (slider.vars.controlsContainer !== "") slider.controlsContainer = $(slider.vars.controlsContainer).length > 0 && $(slider.vars.controlsContainer);
  4529. // MANUAL:
  4530. if (slider.vars.manualControls !== "") slider.manualControls = $(slider.vars.manualControls).length > 0 && $(slider.vars.manualControls);
  4531. // RANDOMIZE:
  4532. if (slider.vars.randomize) {
  4533. slider.slides.sort(function() {
  4534. return (Math.round(Math.random()) - 0.5);
  4535. });
  4536. slider.container.empty().append(slider.slides);
  4537. }
  4538. slider.doMath();
  4539. // INIT
  4540. slider.setup("init");
  4541. // CONTROLNAV:
  4542. if (slider.vars.controlNav) {
  4543. methods.controlNav.setup();
  4544. }
  4545. // DIRECTIONNAV:
  4546. if (slider.vars.directionNav) {
  4547. methods.directionNav.setup();
  4548. }
  4549. // KEYBOARD:
  4550. if (slider.vars.keyboard && ($(slider.containerSelector).length === 1 || slider.vars.multipleKeyboard)) {
  4551. $(document).bind('keyup', function(event) {
  4552. var keycode = event.keyCode;
  4553. if (!slider.animating && (keycode === 39 || keycode === 37)) {
  4554. var target = (keycode === 39) ? slider.getTarget('next') :
  4555. (keycode === 37) ? slider.getTarget('prev') : false;
  4556. slider.flexAnimate(target, slider.vars.pauseOnAction);
  4557. }
  4558. });
  4559. }
  4560. // MOUSEWHEEL:
  4561. if (slider.vars.mousewheel) {
  4562. slider.bind('mousewheel', function(event, delta, deltaX, deltaY) {
  4563. event.preventDefault();
  4564. var target = (delta < 0) ? slider.getTarget('next') : slider.getTarget('prev');
  4565. slider.flexAnimate(target, slider.vars.pauseOnAction);
  4566. });
  4567. }
  4568. // PAUSEPLAY
  4569. if (slider.vars.pausePlay) {
  4570. methods.pausePlay.setup();
  4571. }
  4572. //PAUSE WHEN INVISIBLE
  4573. if (slider.vars.slideshow && slider.vars.pauseInvisible) {
  4574. methods.pauseInvisible.init();
  4575. }
  4576. // SLIDSESHOW
  4577. if (slider.vars.slideshow) {
  4578. if (slider.vars.pauseOnHover) {
  4579. slider.hover(function() {
  4580. if (!slider.manualPlay && !slider.manualPause) {slider.pause();}
  4581. }, function() {
  4582. if (!slider.manualPause && !slider.manualPlay && !slider.stopped) {slider.play();}
  4583. });
  4584. }
  4585. // initialize animation
  4586. // If we're visible, or we don't use PageVisibility API
  4587. if (!slider.vars.pauseInvisible || !methods.pauseInvisible.isHidden()) {
  4588. (slider.vars.initDelay > 0) ? slider.startTimeout = setTimeout(slider.play, slider.vars.initDelay) : slider.play();
  4589. }
  4590. }
  4591. // ASNAV:
  4592. if (asNav) {methods.asNav.setup();}
  4593. // TOUCH
  4594. if (touch && slider.vars.touch) {methods.touch();}
  4595. // FADE&&SMOOTHHEIGHT || SLIDE:
  4596. if (!fade || (fade && slider.vars.smoothHeight)) {$(window).bind("resize orientationchange focus", methods.resize);}
  4597. slider.find("img").attr("draggable", "false");
  4598. // API: start() Callback
  4599. setTimeout(function() {
  4600. slider.vars.start(slider);
  4601. }, 200);
  4602. },
  4603. asNav: {
  4604. setup: function() {
  4605. slider.asNav = true;
  4606. slider.animatingTo = Math.floor(slider.currentSlide / slider.move);
  4607. slider.currentItem = slider.currentSlide;
  4608. slider.slides.removeClass(namespace + "active-slide").eq(slider.currentItem).addClass(namespace + "active-slide");
  4609. if (!msGesture) {
  4610. slider.slides.on(eventType, function(e) {
  4611. e.preventDefault();
  4612. var $slide = $(this),
  4613. target = $slide.index();
  4614. var posFromLeft = $slide.offset().left - $(slider).scrollLeft(); // Find position of slide relative to left of slider container
  4615. if (posFromLeft <= 0 && $slide.hasClass(namespace + 'active-slide')) {
  4616. slider.flexAnimate(slider.getTarget("prev"), true);
  4617. } else if (!$(slider.vars.asNavFor).data('flexslider').animating && !$slide.hasClass(namespace + "active-slide")) {
  4618. slider.direction = (slider.currentItem < target) ? "next" : "prev";
  4619. slider.flexAnimate(target, slider.vars.pauseOnAction, false, true, true);
  4620. }
  4621. });
  4622. } else {
  4623. el._slider = slider;
  4624. slider.slides.each(function() {
  4625. var that = this;
  4626. that._gesture = new MSGesture();
  4627. that._gesture.target = that;
  4628. that.addEventListener("MSPointerDown", function(e) {
  4629. e.preventDefault();
  4630. if (e.currentTarget._gesture) {
  4631. e.currentTarget._gesture.addPointer(e.pointerId);
  4632. }
  4633. }, false);
  4634. that.addEventListener("MSGestureTap", function(e) {
  4635. e.preventDefault();
  4636. var $slide = $(this),
  4637. target = $slide.index();
  4638. if (!$(slider.vars.asNavFor).data('flexslider').animating && !$slide.hasClass('active')) {
  4639. slider.direction = (slider.currentItem < target) ? "next" : "prev";
  4640. slider.flexAnimate(target, slider.vars.pauseOnAction, false, true, true);
  4641. }
  4642. });
  4643. });
  4644. }
  4645. }
  4646. },
  4647. controlNav: {
  4648. setup: function() {
  4649. if (!slider.manualControls) {
  4650. methods.controlNav.setupPaging();
  4651. } else { // MANUALCONTROLS:
  4652. methods.controlNav.setupManual();
  4653. }
  4654. },
  4655. setupPaging: function() {
  4656. var type = (slider.vars.controlNav === "thumbnails") ? 'control-thumbs' : 'control-paging',
  4657. j = 1,
  4658. item,
  4659. slide;
  4660. slider.controlNavScaffold = $('<ol class="' + namespace + 'control-nav ' + namespace + type + '"></ol>');
  4661. if (slider.pagingCount > 1) {
  4662. for (var i = 0; i < slider.pagingCount; i++) {
  4663. slide = slider.slides.eq(i);
  4664. item = (slider.vars.controlNav === "thumbnails") ? '<img src="' + slide.attr('data-thumb') + '"/>' : '<a>' + j + '</a>';
  4665. if ('thumbnails' === slider.vars.controlNav && true === slider.vars.thumbCaptions) {
  4666. var captn = slide.attr('data-thumbcaption');
  4667. if ('' != captn && undefined != captn) {item += '<span class="' + namespace + 'caption">' + captn + '</span>'};
  4668. }
  4669. // slider.controlNavScaffold.append('<li>' + item + '</li>');
  4670. slider.controlNavScaffold.append('<li>' + item + '<i></i></li>');
  4671. j++;
  4672. }
  4673. }
  4674. // CONTROLSCONTAINER:
  4675. (slider.controlsContainer) ? $(slider.controlsContainer).append(slider.controlNavScaffold) : slider.append(slider.controlNavScaffold);
  4676. methods.controlNav.set();
  4677. methods.controlNav.active();
  4678. slider.controlNavScaffold.delegate('a, img', eventType, function(event) {
  4679. event.preventDefault();
  4680. if (watchedEvent === "" || watchedEvent === event.type) {
  4681. var $this = $(this),
  4682. target = slider.controlNav.index($this);
  4683. if (!$this.hasClass(namespace + 'active')) {
  4684. slider.direction = (target > slider.currentSlide) ? "next" : "prev";
  4685. slider.flexAnimate(target, slider.vars.pauseOnAction);
  4686. }
  4687. }
  4688. // setup flags to prevent event duplication
  4689. if (watchedEvent === "") {
  4690. watchedEvent = event.type;
  4691. }
  4692. methods.setToClearWatchedEvent();
  4693. });
  4694. },
  4695. setupManual: function() {
  4696. slider.controlNav = slider.manualControls;
  4697. methods.controlNav.active();
  4698. slider.controlNav.bind(eventType, function(event) {
  4699. event.preventDefault();
  4700. if (watchedEvent === "" || watchedEvent === event.type) {
  4701. var $this = $(this),
  4702. target = slider.controlNav.index($this);
  4703. if (!$this.hasClass(namespace + 'active')) {
  4704. (target > slider.currentSlide) ? slider.direction = "next" : slider.direction = "prev";
  4705. slider.flexAnimate(target, slider.vars.pauseOnAction);
  4706. }
  4707. }
  4708. // setup flags to prevent event duplication
  4709. if (watchedEvent === "") {
  4710. watchedEvent = event.type;
  4711. }
  4712. methods.setToClearWatchedEvent();
  4713. });
  4714. },
  4715. set: function() {
  4716. var selector = (slider.vars.controlNav === "thumbnails") ? 'img' : 'a';
  4717. slider.controlNav = $('.' + namespace + 'control-nav li ' + selector, (slider.controlsContainer) ? slider.controlsContainer : slider);
  4718. },
  4719. active: function() {
  4720. slider.controlNav.removeClass(namespace + "active").eq(slider.animatingTo).addClass(namespace + "active");
  4721. },
  4722. update: function(action, pos) {
  4723. if (slider.pagingCount > 1 && action === "add") {
  4724. slider.controlNavScaffold.append($('<li><a>' + slider.count + '</a></li>'));
  4725. } else if (slider.pagingCount === 1) {
  4726. slider.controlNavScaffold.find('li').remove();
  4727. } else {
  4728. slider.controlNav.eq(pos).closest('li').remove();
  4729. }
  4730. methods.controlNav.set();
  4731. (slider.pagingCount > 1 && slider.pagingCount !== slider.controlNav.length) ? slider.update(pos, action) : methods.controlNav.active();
  4732. }
  4733. },
  4734. directionNav: {
  4735. setup: function() {
  4736. var directionNavScaffold = $('<ul class="' + namespace + 'direction-nav"><li class="' + namespace + 'nav-prev"><a class="' + namespace + 'prev" href="#">' + slider.vars.prevText + '</a></li><li class="' + namespace + 'nav-next"><a class="' + namespace + 'next" href="#">' + slider.vars.nextText + '</a></li></ul>');
  4737. // CONTROLSCONTAINER:
  4738. if (slider.controlsContainer) {
  4739. $(slider.controlsContainer).append(directionNavScaffold);
  4740. slider.directionNav = $('.' + namespace + 'direction-nav li a', slider.controlsContainer);
  4741. } else {
  4742. slider.append(directionNavScaffold);
  4743. slider.directionNav = $('.' + namespace + 'direction-nav li a', slider);
  4744. }
  4745. methods.directionNav.update();
  4746. slider.directionNav.bind(eventType, function(event) {
  4747. event.preventDefault();
  4748. var target;
  4749. if (watchedEvent === "" || watchedEvent === event.type) {
  4750. target = ($(this).hasClass(namespace + 'next')) ? slider.getTarget('next') : slider.getTarget('prev');
  4751. slider.flexAnimate(target, slider.vars.pauseOnAction);
  4752. }
  4753. // setup flags to prevent event duplication
  4754. if (watchedEvent === "") {
  4755. watchedEvent = event.type;
  4756. }
  4757. methods.setToClearWatchedEvent();
  4758. });
  4759. },
  4760. update: function() {
  4761. var disabledClass = namespace + 'disabled';
  4762. if (slider.pagingCount === 1) {
  4763. slider.directionNav.addClass(disabledClass).attr('tabindex', '-1');
  4764. } else if (!slider.vars.animationLoop) {
  4765. if (slider.animatingTo === 0) {
  4766. slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "prev").addClass(disabledClass).attr('tabindex', '-1');
  4767. } else if (slider.animatingTo === slider.last) {
  4768. slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "next").addClass(disabledClass).attr('tabindex', '-1');
  4769. } else {
  4770. slider.directionNav.removeClass(disabledClass).removeAttr('tabindex');
  4771. }
  4772. } else {
  4773. slider.directionNav.removeClass(disabledClass).removeAttr('tabindex');
  4774. }
  4775. }
  4776. },
  4777. pausePlay: {
  4778. setup: function() {
  4779. var pausePlayScaffold = $('<div class="' + namespace + 'pauseplay"><a></a></div>');
  4780. // CONTROLSCONTAINER:
  4781. if (slider.controlsContainer) {
  4782. slider.controlsContainer.append(pausePlayScaffold);
  4783. slider.pausePlay = $('.' + namespace + 'pauseplay a', slider.controlsContainer);
  4784. } else {
  4785. slider.append(pausePlayScaffold);
  4786. slider.pausePlay = $('.' + namespace + 'pauseplay a', slider);
  4787. }
  4788. methods.pausePlay.update((slider.vars.slideshow) ? namespace + 'pause' : namespace + 'play');
  4789. slider.pausePlay.bind(eventType, function(event) {
  4790. event.preventDefault();
  4791. if (watchedEvent === "" || watchedEvent === event.type) {
  4792. if ($(this).hasClass(namespace + 'pause')) {
  4793. slider.manualPause = true;
  4794. slider.manualPlay = false;
  4795. slider.pause();
  4796. } else {
  4797. slider.manualPause = false;
  4798. slider.manualPlay = true;
  4799. slider.play();
  4800. }
  4801. }
  4802. // setup flags to prevent event duplication
  4803. if (watchedEvent === "") {
  4804. watchedEvent = event.type;
  4805. }
  4806. methods.setToClearWatchedEvent();
  4807. });
  4808. },
  4809. update: function(state) {
  4810. (state === "play") ? slider.pausePlay.removeClass(namespace + 'pause').addClass(namespace + 'play').html(slider.vars.playText) : slider.pausePlay.removeClass(namespace + 'play').addClass(namespace + 'pause').html(slider.vars.pauseText);
  4811. }
  4812. },
  4813. touch: function() {
  4814. var startX,
  4815. startY,
  4816. offset,
  4817. cwidth,
  4818. dx,
  4819. startT,
  4820. scrolling = false,
  4821. localX = 0,
  4822. localY = 0,
  4823. accDx = 0;
  4824. if (!msGesture) {
  4825. el.addEventListener('touchstart', onTouchStart, false);
  4826. function onTouchStart(e) {
  4827. if (slider.animating) {
  4828. e.preventDefault();
  4829. } else if (( window.navigator.msPointerEnabled ) || e.touches.length === 1) {
  4830. slider.pause();
  4831. // CAROUSEL:
  4832. cwidth = (vertical) ? slider.h : slider.w;
  4833. startT = Number(new Date());
  4834. // CAROUSEL:
  4835. // Local vars for X and Y points.
  4836. localX = e.touches[0].pageX;
  4837. localY = e.touches[0].pageY;
  4838. offset = (carousel && reverse && slider.animatingTo === slider.last) ? 0 :
  4839. (carousel && reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
  4840. (carousel && slider.currentSlide === slider.last) ? slider.limit :
  4841. (carousel) ? ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.currentSlide :
  4842. (reverse) ? (slider.last - slider.currentSlide + slider.cloneOffset) * cwidth : (slider.currentSlide + slider.cloneOffset) * cwidth;
  4843. startX = (vertical) ? localY : localX;
  4844. startY = (vertical) ? localX : localY;
  4845. el.addEventListener('touchmove', onTouchMove, false);
  4846. el.addEventListener('touchend', onTouchEnd, false);
  4847. }
  4848. }
  4849. function onTouchMove(e) {
  4850. // Local vars for X and Y points.
  4851. localX = e.touches[0].pageX;
  4852. localY = e.touches[0].pageY;
  4853. dx = (vertical) ? startX - localY : startX - localX;
  4854. scrolling = (vertical) ? (Math.abs(dx) < Math.abs(localX - startY)) : (Math.abs(dx) < Math.abs(localY - startY));
  4855. var fxms = 500;
  4856. if (!scrolling || Number(new Date()) - startT > fxms) {
  4857. e.preventDefault();
  4858. if (!fade && slider.transitions) {
  4859. if (!slider.vars.animationLoop) {
  4860. dx = dx / ((slider.currentSlide === 0 && dx < 0 || slider.currentSlide === slider.last && dx > 0) ? (Math.abs(dx) / cwidth + 2) : 1);
  4861. }
  4862. slider.setProps(offset + dx, "setTouch");
  4863. }
  4864. }
  4865. }
  4866. function onTouchEnd(e) {
  4867. // finish the touch by undoing the touch session
  4868. el.removeEventListener('touchmove', onTouchMove, false);
  4869. if (slider.animatingTo === slider.currentSlide && !scrolling && !(dx === null)) {
  4870. var updateDx = (reverse) ? -dx : dx,
  4871. target = (updateDx > 0) ? slider.getTarget('next') : slider.getTarget('prev');
  4872. if (slider.canAdvance(target) && (Number(new Date()) - startT < 550 && Math.abs(updateDx) > 50 || Math.abs(updateDx) > cwidth / 2)) {
  4873. slider.flexAnimate(target, slider.vars.pauseOnAction);
  4874. } else {
  4875. if (!fade) {slider.flexAnimate(slider.currentSlide, slider.vars.pauseOnAction, true);}
  4876. }
  4877. }
  4878. el.removeEventListener('touchend', onTouchEnd, false);
  4879. startX = null;
  4880. startY = null;
  4881. dx = null;
  4882. offset = null;
  4883. }
  4884. } else {
  4885. el.style.msTouchAction = "none";
  4886. el._gesture = new MSGesture();
  4887. el._gesture.target = el;
  4888. el.addEventListener("MSPointerDown", onMSPointerDown, false);
  4889. el._slider = slider;
  4890. el.addEventListener("MSGestureChange", onMSGestureChange, false);
  4891. el.addEventListener("MSGestureEnd", onMSGestureEnd, false);
  4892. function onMSPointerDown(e) {
  4893. e.stopPropagation();
  4894. if (slider.animating) {
  4895. e.preventDefault();
  4896. } else {
  4897. slider.pause();
  4898. el._gesture.addPointer(e.pointerId);
  4899. accDx = 0;
  4900. cwidth = (vertical) ? slider.h : slider.w;
  4901. startT = Number(new Date());
  4902. // CAROUSEL:
  4903. offset = (carousel && reverse && slider.animatingTo === slider.last) ? 0 :
  4904. (carousel && reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
  4905. (carousel && slider.currentSlide === slider.last) ? slider.limit :
  4906. (carousel) ? ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.currentSlide :
  4907. (reverse) ? (slider.last - slider.currentSlide + slider.cloneOffset) * cwidth : (slider.currentSlide + slider.cloneOffset) * cwidth;
  4908. }
  4909. }
  4910. function onMSGestureChange(e) {
  4911. e.stopPropagation();
  4912. var slider = e.target._slider;
  4913. if (!slider) {
  4914. return;
  4915. }
  4916. var transX = -e.translationX,
  4917. transY = -e.translationY;
  4918. //Accumulate translations.
  4919. accDx = accDx + ((vertical) ? transY : transX);
  4920. dx = accDx;
  4921. scrolling = (vertical) ? (Math.abs(accDx) < Math.abs(-transX)) : (Math.abs(accDx) < Math.abs(-transY));
  4922. if (e.detail === e.MSGESTURE_FLAG_INERTIA) {
  4923. setImmediate(function() {
  4924. el._gesture.stop();
  4925. });
  4926. return;
  4927. }
  4928. if (!scrolling || Number(new Date()) - startT > 500) {
  4929. e.preventDefault();
  4930. if (!fade && slider.transitions) {
  4931. if (!slider.vars.animationLoop) {
  4932. dx = accDx / ((slider.currentSlide === 0 && accDx < 0 || slider.currentSlide === slider.last && accDx > 0) ? (Math.abs(accDx) / cwidth + 2) : 1);
  4933. }
  4934. slider.setProps(offset + dx, "setTouch");
  4935. }
  4936. }
  4937. }
  4938. function onMSGestureEnd(e) {
  4939. e.stopPropagation();
  4940. var slider = e.target._slider;
  4941. if (!slider) {
  4942. return;
  4943. }
  4944. if (slider.animatingTo === slider.currentSlide && !scrolling && !(dx === null)) {
  4945. var updateDx = (reverse) ? -dx : dx,
  4946. target = (updateDx > 0) ? slider.getTarget('next') : slider.getTarget('prev');
  4947. if (slider.canAdvance(target) && (Number(new Date()) - startT < 550 && Math.abs(updateDx) > 50 || Math.abs(updateDx) > cwidth / 2)) {
  4948. slider.flexAnimate(target, slider.vars.pauseOnAction);
  4949. } else {
  4950. if (!fade) {slider.flexAnimate(slider.currentSlide, slider.vars.pauseOnAction, true);}
  4951. }
  4952. }
  4953. startX = null;
  4954. startY = null;
  4955. dx = null;
  4956. offset = null;
  4957. accDx = 0;
  4958. }
  4959. }
  4960. },
  4961. resize: function() {
  4962. if (!slider.animating && slider.is(':visible')) {
  4963. if (!carousel) {slider.doMath()};
  4964. if (fade) {
  4965. // SMOOTH HEIGHT:
  4966. methods.smoothHeight();
  4967. } else if (carousel) { //CAROUSEL:
  4968. slider.slides.width(slider.computedW);
  4969. slider.update(slider.pagingCount);
  4970. slider.setProps();
  4971. }
  4972. else if (vertical) { //VERTICAL:
  4973. slider.viewport.height(slider.h);
  4974. slider.setProps(slider.h, "setTotal");
  4975. } else {
  4976. // SMOOTH HEIGHT:
  4977. if (slider.vars.smoothHeight) {methods.smoothHeight();}
  4978. slider.newSlides.width(slider.computedW);
  4979. slider.setProps(slider.computedW, "setTotal");
  4980. }
  4981. }
  4982. },
  4983. smoothHeight: function(dur) {
  4984. if (!vertical || fade) {
  4985. var $obj = (fade) ? slider : slider.viewport;
  4986. (dur) ? $obj.animate({"height": slider.slides.eq(slider.animatingTo).height()}, dur) : $obj.height(slider.slides.eq(slider.animatingTo).height());
  4987. }
  4988. },
  4989. sync: function(action) {
  4990. var $obj = $(slider.vars.sync).data("flexslider"),
  4991. target = slider.animatingTo;
  4992. switch (action) {
  4993. case "animate":
  4994. $obj.flexAnimate(target, slider.vars.pauseOnAction, false, true);
  4995. break;
  4996. case "play":
  4997. if (!$obj.playing && !$obj.asNav) {
  4998. $obj.play();
  4999. }
  5000. break;
  5001. case "pause":
  5002. $obj.pause();
  5003. break;
  5004. }
  5005. },
  5006. uniqueID: function($clone) {
  5007. // Append _clone to current level and children elements with id attributes
  5008. $clone.filter('[id]').add($clone.find('[id]')).each(function() {
  5009. var $this = $(this);
  5010. $this.attr('id', $this.attr('id') + '_clone');
  5011. });
  5012. return $clone;
  5013. },
  5014. pauseInvisible: {
  5015. visProp: null,
  5016. init: function() {
  5017. var visProp = methods.pauseInvisible.getHiddenProp();
  5018. if (visProp) {
  5019. var evtname = visProp.replace(/[H|h]idden/,'') + 'visibilitychange';
  5020. document.addEventListener(evtname, function() {
  5021. if (methods.pauseInvisible.isHidden()) {
  5022. if(slider.startTimeout) {
  5023. clearTimeout(slider.startTimeout); //If clock is ticking, stop timer and prevent from starting while invisible
  5024. } else {
  5025. slider.pause(); //Or just pause
  5026. }
  5027. }
  5028. else {
  5029. if(slider.started) {
  5030. slider.play(); //Initiated before, just play
  5031. } else {
  5032. if (slider.vars.initDelay > 0) {
  5033. setTimeout(slider.play, slider.vars.initDelay);
  5034. } else {
  5035. slider.play(); //Didn't init before: simply init or wait for it
  5036. }
  5037. }
  5038. }
  5039. });
  5040. }
  5041. },
  5042. isHidden: function() {
  5043. var prop = methods.pauseInvisible.getHiddenProp();
  5044. if (!prop) {
  5045. return false;
  5046. }
  5047. return document[prop];
  5048. },
  5049. getHiddenProp: function() {
  5050. var prefixes = ['webkit','moz','ms','o'];
  5051. // if 'hidden' is natively supported just return it
  5052. if ('hidden' in document) {
  5053. return 'hidden';
  5054. }
  5055. // otherwise loop over all the known prefixes until we find one
  5056. for (var i = 0; i < prefixes.length; i++ ) {
  5057. if ((prefixes[i] + 'Hidden') in document) {
  5058. return prefixes[i] + 'Hidden';
  5059. }
  5060. }
  5061. // otherwise it's not supported
  5062. return null;
  5063. }
  5064. },
  5065. setToClearWatchedEvent: function() {
  5066. clearTimeout(watchedEventClearTimer);
  5067. watchedEventClearTimer = setTimeout(function() {
  5068. watchedEvent = "";
  5069. }, 3000);
  5070. }
  5071. };
  5072. // public methods
  5073. slider.flexAnimate = function(target, pause, override, withSync, fromNav) {
  5074. if (!slider.vars.animationLoop && target !== slider.currentSlide) {
  5075. slider.direction = (target > slider.currentSlide) ? "next" : "prev";
  5076. }
  5077. if (asNav && slider.pagingCount === 1) slider.direction = (slider.currentItem < target) ? "next" : "prev";
  5078. if (!slider.animating && (slider.canAdvance(target, fromNav) || override) && slider.is(":visible")) {
  5079. if (asNav && withSync) {
  5080. var master = $(slider.vars.asNavFor).data('flexslider');
  5081. slider.atEnd = target === 0 || target === slider.count - 1;
  5082. master.flexAnimate(target, true, false, true, fromNav);
  5083. slider.direction = (slider.currentItem < target) ? "next" : "prev";
  5084. master.direction = slider.direction;
  5085. if (Math.ceil((target + 1) / slider.visible) - 1 !== slider.currentSlide && target !== 0) {
  5086. slider.currentItem = target;
  5087. slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
  5088. target = Math.floor(target / slider.visible);
  5089. } else {
  5090. slider.currentItem = target;
  5091. slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
  5092. return false;
  5093. }
  5094. }
  5095. slider.animating = true;
  5096. slider.animatingTo = target;
  5097. // SLIDESHOW:
  5098. if (pause) {slider.pause();}
  5099. // API: before() animation Callback
  5100. slider.vars.before(slider);
  5101. // SYNC:
  5102. if (slider.syncExists && !fromNav) {methods.sync("animate");}
  5103. // CONTROLNAV
  5104. if (slider.vars.controlNav) {methods.controlNav.active();}
  5105. // !CAROUSEL:
  5106. // CANDIDATE: slide active class (for add/remove slide)
  5107. if (!carousel) {slider.slides.removeClass(namespace + 'active-slide').eq(target).addClass(namespace + 'active-slide');}
  5108. // INFINITE LOOP:
  5109. // CANDIDATE: atEnd
  5110. slider.atEnd = target === 0 || target === slider.last;
  5111. // DIRECTIONNAV:
  5112. if (slider.vars.directionNav) {methods.directionNav.update();}
  5113. if (target === slider.last) {
  5114. // API: end() of cycle Callback
  5115. slider.vars.end(slider);
  5116. // SLIDESHOW && !INFINITE LOOP:
  5117. if (!slider.vars.animationLoop) {slider.pause();}
  5118. }
  5119. // SLIDE:
  5120. if (!fade) {
  5121. var dimension = (vertical) ? slider.slides.filter(':first').height() : slider.computedW,
  5122. margin, slideString, calcNext;
  5123. // INFINITE LOOP / REVERSE:
  5124. if (carousel) {
  5125. //margin = (slider.vars.itemWidth > slider.w) ? slider.vars.itemMargin * 2 : slider.vars.itemMargin;
  5126. margin = slider.vars.itemMargin;
  5127. calcNext = ((slider.itemW + margin) * slider.move) * slider.animatingTo;
  5128. slideString = (calcNext > slider.limit && slider.visible !== 1) ? slider.limit : calcNext;
  5129. } else if (slider.currentSlide === 0 && target === slider.count - 1 && slider.vars.animationLoop && slider.direction !== "next") {
  5130. slideString = (reverse) ? (slider.count + slider.cloneOffset) * dimension : 0;
  5131. } else if (slider.currentSlide === slider.last && target === 0 && slider.vars.animationLoop && slider.direction !== "prev") {
  5132. slideString = (reverse) ? 0 : (slider.count + 1) * dimension;
  5133. } else {
  5134. slideString = (reverse) ? ((slider.count - 1) - target + slider.cloneOffset) * dimension : (target + slider.cloneOffset) * dimension;
  5135. }
  5136. slider.setProps(slideString, "", slider.vars.animationSpeed);
  5137. if (slider.transitions) {
  5138. if (!slider.vars.animationLoop || !slider.atEnd) {
  5139. slider.animating = false;
  5140. slider.currentSlide = slider.animatingTo;
  5141. }
  5142. // Unbind previous transitionEnd events and re-bind new transitionEnd event
  5143. slider.container.unbind("webkitTransitionEnd transitionend");
  5144. slider.container.bind("webkitTransitionEnd transitionend", function() {
  5145. clearTimeout(slider.ensureAnimationEnd);
  5146. slider.wrapup(dimension);
  5147. });
  5148. // Insurance for the ever-so-fickle transitionEnd event
  5149. clearTimeout(slider.ensureAnimationEnd);
  5150. slider.ensureAnimationEnd = setTimeout(function() {
  5151. slider.wrapup(dimension);
  5152. }, slider.vars.animationSpeed + 100);
  5153. } else {
  5154. slider.container.animate(slider.args, slider.vars.animationSpeed, slider.vars.easing, function(){
  5155. slider.wrapup(dimension);
  5156. });
  5157. }
  5158. } else { // FADE:
  5159. if (!touch) {
  5160. //slider.slides.eq(slider.currentSlide).fadeOut(slider.vars.animationSpeed, slider.vars.easing);
  5161. //slider.slides.eq(target).fadeIn(slider.vars.animationSpeed, slider.vars.easing, slider.wrapup);
  5162. slider.slides.eq(slider.currentSlide).css({"zIndex": 1}).animate({"opacity": 0}, slider.vars.animationSpeed, slider.vars.easing);
  5163. slider.slides.eq(target).css({"zIndex": 2}).animate({"opacity": 1}, slider.vars.animationSpeed, slider.vars.easing, slider.wrapup);
  5164. } else {
  5165. slider.slides.eq(slider.currentSlide).css({
  5166. "opacity": 0,
  5167. "zIndex": 1
  5168. });
  5169. slider.slides.eq(target).css({"opacity": 1, "zIndex": 2});
  5170. slider.wrapup(dimension);
  5171. }
  5172. }
  5173. // SMOOTH HEIGHT:
  5174. if (slider.vars.smoothHeight) {methods.smoothHeight(slider.vars.animationSpeed)};
  5175. }
  5176. };
  5177. slider.wrapup = function(dimension) {
  5178. // SLIDE:
  5179. if (!fade && !carousel) {
  5180. if (slider.currentSlide === 0 && slider.animatingTo === slider.last && slider.vars.animationLoop) {
  5181. slider.setProps(dimension, "jumpEnd");
  5182. } else if (slider.currentSlide === slider.last && slider.animatingTo === 0 && slider.vars.animationLoop) {
  5183. slider.setProps(dimension, "jumpStart");
  5184. }
  5185. }
  5186. slider.animating = false;
  5187. slider.currentSlide = slider.animatingTo;
  5188. // API: after() animation Callback
  5189. slider.vars.after(slider);
  5190. };
  5191. // SLIDESHOW:
  5192. slider.animateSlides = function() {
  5193. if (!slider.animating && focused) {slider.flexAnimate(slider.getTarget("next"));}
  5194. };
  5195. // SLIDESHOW:
  5196. slider.pause = function() {
  5197. clearInterval(slider.animatedSlides);
  5198. slider.animatedSlides = null;
  5199. slider.playing = false;
  5200. // PAUSEPLAY:
  5201. if (slider.vars.pausePlay) {methods.pausePlay.update("play");}
  5202. // SYNC:
  5203. if (slider.syncExists) {methods.sync("pause");}
  5204. };
  5205. // SLIDESHOW:
  5206. slider.play = function() {
  5207. if (slider.playing) {clearInterval(slider.animatedSlides);}
  5208. slider.animatedSlides = slider.animatedSlides || setInterval(slider.animateSlides, slider.vars.slideshowSpeed);
  5209. slider.started = slider.playing = true;
  5210. // PAUSEPLAY:
  5211. if (slider.vars.pausePlay) {methods.pausePlay.update("pause");}
  5212. // SYNC:
  5213. if (slider.syncExists) {methods.sync("play");}
  5214. };
  5215. // STOP:
  5216. slider.stop = function() {
  5217. slider.pause();
  5218. slider.stopped = true;
  5219. };
  5220. slider.canAdvance = function(target, fromNav) {
  5221. // ASNAV:
  5222. var last = (asNav) ? slider.pagingCount - 1 : slider.last;
  5223. return (fromNav) ? true :
  5224. (asNav && slider.currentItem === slider.count - 1 && target === 0 && slider.direction === "prev") ? true :
  5225. (asNav && slider.currentItem === 0 && target === slider.pagingCount - 1 && slider.direction !== "next") ? false :
  5226. (target === slider.currentSlide && !asNav) ? false :
  5227. (slider.vars.animationLoop) ? true :
  5228. (slider.atEnd && slider.currentSlide === 0 && target === last && slider.direction !== "next") ? false :
  5229. (slider.atEnd && slider.currentSlide === last && target === 0 && slider.direction === "next") ? false :
  5230. true;
  5231. };
  5232. slider.getTarget = function(dir) {
  5233. slider.direction = dir;
  5234. if (dir === "next") {
  5235. return (slider.currentSlide === slider.last) ? 0 : slider.currentSlide + 1;
  5236. } else {
  5237. return (slider.currentSlide === 0) ? slider.last : slider.currentSlide - 1;
  5238. }
  5239. };
  5240. // SLIDE:
  5241. slider.setProps = function(pos, special, dur) {
  5242. var target = (function() {
  5243. var posCheck = (pos) ? pos : ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo,
  5244. posCalc = (function() {
  5245. if (carousel) {
  5246. return (special === "setTouch") ? pos :
  5247. (reverse && slider.animatingTo === slider.last) ? 0 :
  5248. (reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
  5249. (slider.animatingTo === slider.last) ? slider.limit : posCheck;
  5250. } else {
  5251. switch (special) {
  5252. case "setTotal":
  5253. return (reverse) ? ((slider.count - 1) - slider.currentSlide + slider.cloneOffset) * pos : (slider.currentSlide + slider.cloneOffset) * pos;
  5254. case "setTouch":
  5255. return (reverse) ? pos : pos;
  5256. case "jumpEnd":
  5257. return (reverse) ? pos : slider.count * pos;
  5258. case "jumpStart":
  5259. return (reverse) ? slider.count * pos : pos;
  5260. default:
  5261. return pos;
  5262. }
  5263. }
  5264. }());
  5265. return (posCalc * -1) + "px";
  5266. }());
  5267. if (slider.transitions) {
  5268. target = (vertical) ? "translate3d(0," + target + ",0)" : "translate3d(" + target + ",0,0)";
  5269. dur = (dur !== undefined) ? (dur / 1000) + "s" : "0s";
  5270. slider.container.css("-" + slider.pfx + "-transition-duration", dur);
  5271. slider.container.css("transition-duration", dur);
  5272. }
  5273. slider.args[slider.prop] = target;
  5274. if (slider.transitions || dur === undefined) {slider.container.css(slider.args);}
  5275. slider.container.css('transform', target);
  5276. };
  5277. slider.setup = function(type) {
  5278. // SLIDE:
  5279. if (!fade) {
  5280. var sliderOffset, arr;
  5281. if (type === "init") {
  5282. slider.viewport = $('<div class="' + namespace + 'viewport"></div>').css({
  5283. "overflow": "hidden",
  5284. "position": "relative"
  5285. }).appendTo(slider).append(slider.container);
  5286. // INFINITE LOOP:
  5287. slider.cloneCount = 0;
  5288. slider.cloneOffset = 0;
  5289. // REVERSE:
  5290. if (reverse) {
  5291. arr = $.makeArray(slider.slides).reverse();
  5292. slider.slides = $(arr);
  5293. slider.container.empty().append(slider.slides);
  5294. }
  5295. }
  5296. // INFINITE LOOP && !CAROUSEL:
  5297. if (slider.vars.animationLoop && !carousel) {
  5298. slider.cloneCount = 2;
  5299. slider.cloneOffset = 1;
  5300. // clear out old clones
  5301. if (type !== "init") { slider.container.find('.clone').remove(); }
  5302. slider.container.append(methods.uniqueID(slider.slides.first().clone().addClass('clone')).attr('aria-hidden', 'true'))
  5303. .prepend(methods.uniqueID(slider.slides.last().clone().addClass('clone')).attr('aria-hidden', 'true'));
  5304. }
  5305. slider.newSlides = $(slider.vars.selector, slider);
  5306. sliderOffset = (reverse) ? slider.count - 1 - slider.currentSlide + slider.cloneOffset : slider.currentSlide + slider.cloneOffset;
  5307. // VERTICAL:
  5308. if (vertical && !carousel) {
  5309. slider.container.height((slider.count + slider.cloneCount) * 200 + "%").css("position", "absolute").width("100%");
  5310. setTimeout(function() {
  5311. slider.newSlides.css({"display": "block"});
  5312. slider.doMath();
  5313. slider.viewport.height(slider.h);
  5314. slider.setProps(sliderOffset * slider.h, "init");
  5315. }, (type === "init") ? 100 : 0);
  5316. } else {
  5317. slider.container.width((slider.count + slider.cloneCount) * 200 + "%");
  5318. slider.setProps(sliderOffset * slider.computedW, "init");
  5319. setTimeout(function() {
  5320. slider.doMath();
  5321. slider.newSlides.css({
  5322. "width": slider.computedW,
  5323. "float": "left",
  5324. "display": "block"
  5325. });
  5326. // SMOOTH HEIGHT:
  5327. if (slider.vars.smoothHeight) {methods.smoothHeight();}
  5328. }, (type === "init") ? 100 : 0);
  5329. }
  5330. } else { // FADE:
  5331. slider.slides.css({
  5332. "width": "100%",
  5333. "float": "left",
  5334. "marginRight": "-100%",
  5335. "position": "relative"
  5336. });
  5337. if (type === "init") {
  5338. if (!touch) {
  5339. //slider.slides.eq(slider.currentSlide).fadeIn(slider.vars.animationSpeed, slider.vars.easing);
  5340. if (slider.vars.fadeFirstSlide == false) {
  5341. slider.slides.css({ "opacity": 0, "display": "block", "zIndex": 1 }).eq(slider.currentSlide).css({"zIndex": 2}).css({"opacity": 1});
  5342. } else {
  5343. slider.slides.css({ "opacity": 0, "display": "block", "zIndex": 1 }).eq(slider.currentSlide).css({"zIndex": 2}).animate({"opacity": 1},slider.vars.animationSpeed,slider.vars.easing);
  5344. }
  5345. } else {
  5346. slider.slides.css({ "opacity": 0, "display": "block", "webkitTransition": "opacity " + slider.vars.animationSpeed / 1000 + "s ease", "zIndex": 1 }).eq(slider.currentSlide).css({ "opacity": 1, "zIndex": 2});
  5347. }
  5348. }
  5349. // SMOOTH HEIGHT:
  5350. if (slider.vars.smoothHeight) {methods.smoothHeight();}
  5351. }
  5352. // !CAROUSEL:
  5353. // CANDIDATE: active slide
  5354. if (!carousel) {slider.slides.removeClass(namespace + "active-slide").eq(slider.currentSlide).addClass(namespace + "active-slide");}
  5355. //FlexSlider: init() Callback
  5356. slider.vars.init(slider);
  5357. };
  5358. slider.doMath = function() {
  5359. var slide = slider.slides.first(),
  5360. slideMargin = slider.vars.itemMargin,
  5361. minItems = slider.vars.minItems,
  5362. maxItems = slider.vars.maxItems;
  5363. slider.w = (slider.viewport === undefined) ? slider.width() : slider.viewport.width();
  5364. slider.h = slide.height();
  5365. slider.boxPadding = slide.outerWidth() - slide.width();
  5366. // CAROUSEL:
  5367. if (carousel) {
  5368. slider.itemT = slider.vars.itemWidth + slideMargin;
  5369. slider.minW = (minItems) ? minItems * slider.itemT : slider.w;
  5370. slider.maxW = (maxItems) ? (maxItems * slider.itemT) - slideMargin : slider.w;
  5371. slider.itemW = (slider.minW > slider.w) ? (slider.w - (slideMargin * (minItems - 1))) / minItems :
  5372. (slider.maxW < slider.w) ? (slider.w - (slideMargin * (maxItems - 1))) / maxItems :
  5373. (slider.vars.itemWidth > slider.w) ? slider.w : slider.vars.itemWidth;
  5374. slider.visible = Math.floor(slider.w / (slider.itemW));
  5375. slider.move = (slider.vars.move > 0 && slider.vars.move < slider.visible ) ? slider.vars.move : slider.visible;
  5376. slider.pagingCount = Math.ceil(((slider.count - slider.visible) / slider.move) + 1);
  5377. slider.last = slider.pagingCount - 1;
  5378. slider.limit = (slider.pagingCount === 1) ? 0 :
  5379. (slider.vars.itemWidth > slider.w) ? (slider.itemW * (slider.count - 1)) + (slideMargin * (slider.count - 1)) : ((slider.itemW + slideMargin) * slider.count) - slider.w - slideMargin;
  5380. } else {
  5381. slider.itemW = slider.w;
  5382. slider.pagingCount = slider.count;
  5383. slider.last = slider.count - 1;
  5384. }
  5385. slider.computedW = slider.itemW - slider.boxPadding;
  5386. };
  5387. slider.update = function(pos, action) {
  5388. slider.doMath();
  5389. // update currentSlide and slider.animatingTo if necessary
  5390. if (!carousel) {
  5391. if (pos < slider.currentSlide) {
  5392. slider.currentSlide += 1;
  5393. } else if (pos <= slider.currentSlide && pos !== 0) {
  5394. slider.currentSlide -= 1;
  5395. }
  5396. slider.animatingTo = slider.currentSlide;
  5397. }
  5398. // update controlNav
  5399. if (slider.vars.controlNav && !slider.manualControls) {
  5400. if ((action === "add" && !carousel) || slider.pagingCount > slider.controlNav.length) {
  5401. methods.controlNav.update("add");
  5402. } else if ((action === "remove" && !carousel) || slider.pagingCount < slider.controlNav.length) {
  5403. if (carousel && slider.currentSlide > slider.last) {
  5404. slider.currentSlide -= 1;
  5405. slider.animatingTo -= 1;
  5406. }
  5407. methods.controlNav.update("remove", slider.last);
  5408. }
  5409. }
  5410. // update directionNav
  5411. if (slider.vars.directionNav) {methods.directionNav.update();}
  5412. };
  5413. slider.addSlide = function(obj, pos) {
  5414. var $obj = $(obj);
  5415. slider.count += 1;
  5416. slider.last = slider.count - 1;
  5417. // append new slide
  5418. if (vertical && reverse) {
  5419. (pos !== undefined) ? slider.slides.eq(slider.count - pos).after($obj) : slider.container.prepend($obj);
  5420. } else {
  5421. (pos !== undefined) ? slider.slides.eq(pos).before($obj) : slider.container.append($obj);
  5422. }
  5423. // update currentSlide, animatingTo, controlNav, and directionNav
  5424. slider.update(pos, "add");
  5425. // update slider.slides
  5426. slider.slides = $(slider.vars.selector + ':not(.clone)', slider);
  5427. // re-setup the slider to accomdate new slide
  5428. slider.setup();
  5429. //FlexSlider: added() Callback
  5430. slider.vars.added(slider);
  5431. };
  5432. slider.removeSlide = function(obj) {
  5433. var pos = (isNaN(obj)) ? slider.slides.index($(obj)) : obj;
  5434. // update count
  5435. slider.count -= 1;
  5436. slider.last = slider.count - 1;
  5437. // remove slide
  5438. if (isNaN(obj)) {
  5439. $(obj, slider.slides).remove();
  5440. } else {
  5441. (vertical && reverse) ? slider.slides.eq(slider.last).remove() : slider.slides.eq(obj).remove();
  5442. }
  5443. // update currentSlide, animatingTo, controlNav, and directionNav
  5444. slider.doMath();
  5445. slider.update(pos, "remove");
  5446. // update slider.slides
  5447. slider.slides = $(slider.vars.selector + ':not(.clone)', slider);
  5448. // re-setup the slider to accomdate new slide
  5449. slider.setup();
  5450. // FlexSlider: removed() Callback
  5451. slider.vars.removed(slider);
  5452. };
  5453. //FlexSlider: Initialize
  5454. methods.init();
  5455. };
  5456. // Ensure the slider isn't focussed if the window loses focus.
  5457. $(window).blur(function(e) {
  5458. focused = false;
  5459. }).focus(function(e) {
  5460. focused = true;
  5461. });
  5462. // FlexSlider: Default Settings
  5463. $.flexslider.defaults = {
  5464. namespace: 'am-', // {NEW} String: Prefix string attached to the class of every element generated by the plugin
  5465. selector: '.am-slides > li', // {NEW} Selector: Must match a simple pattern. '{container} > {slide}' -- Ignore pattern at your own peril
  5466. animation: 'slide', // String: Select your animation type, 'fade' or 'slide'
  5467. easing: 'swing', // {NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported!
  5468. direction: 'horizontal', // String: Select the sliding direction, "horizontal" or "vertical"
  5469. reverse: false, // {NEW} Boolean: Reverse the animation direction
  5470. animationLoop: true, // Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
  5471. smoothHeight: false, // {NEW} Boolean: Allow height of the slider to animate smoothly in horizontal mode
  5472. startAt: 0, // Integer: The slide that the slider should start on. Array notation (0 = first slide)
  5473. slideshow: true, // Boolean: Animate slider automatically
  5474. slideshowSpeed: 5000, // Integer: Set the speed of the slideshow cycling, in milliseconds
  5475. animationSpeed: 600, // Integer: Set the speed of animations, in milliseconds
  5476. initDelay: 0, // {NEW} Integer: Set an initialization delay, in milliseconds
  5477. randomize: false, // Boolean: Randomize slide order
  5478. fadeFirstSlide: true, // Boolean: Fade in the first slide when animation type is "fade"
  5479. thumbCaptions: false, // Boolean: Whether or not to put captions on thumbnails when using the "thumbnails" controlNav.
  5480. // Usability features
  5481. pauseOnAction: true, // Boolean: Pause the slideshow when interacting with control elements, highly recommended.
  5482. pauseOnHover: false, // Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
  5483. pauseInvisible: true, // {NEW} Boolean: Pause the slideshow when tab is invisible, resume when visible. Provides better UX, lower CPU usage.
  5484. useCSS: true, // {NEW} Boolean: Slider will use CSS3 transitions if available
  5485. touch: true, // {NEW} Boolean: Allow touch swipe navigation of the slider on touch-enabled devices
  5486. video: false, // {NEW} Boolean: If using video in the slider, will prevent CSS3 3D Transforms to avoid graphical glitches
  5487. // Primary Controls
  5488. controlNav: true, // Boolean: Create navigation for paging control of each slide? Note: Leave true for manualControls usage
  5489. directionNav: true, // Boolean: Create navigation for previous/next navigation? (true/false)
  5490. prevText: ' ', // String: Set the text for the "previous" directionNav item
  5491. nextText: ' ', // String: Set the text for the "next" directionNav item
  5492. // Secondary Navigation
  5493. keyboard: true, // Boolean: Allow slider navigating via keyboard left/right keys
  5494. multipleKeyboard: false, // {NEW} Boolean: Allow keyboard navigation to affect multiple sliders. Default behavior cuts out keyboard navigation with more than one slider present.
  5495. mousewheel: false, // {UPDATED} Boolean: Requires jquery.mousewheel.js (https://github.com/brandonaaron/jquery-mousewheel) - Allows slider navigating via mousewheel
  5496. pausePlay: false, // Boolean: Create pause/play dynamic element
  5497. pauseText: 'Pause', // String: Set the text for the 'pause' pausePlay item
  5498. playText: 'Play', // String: Set the text for the 'play' pausePlay item
  5499. // Special properties
  5500. controlsContainer: '', // {UPDATED} jQuery Object/Selector: Declare which container the navigation elements should be appended too. Default container is the FlexSlider element. Example use would be $('.flexslider-container'). Property is ignored if given element is not found.
  5501. manualControls: '', // {UPDATED} jQuery Object/Selector: Declare custom control navigation. Examples would be $(".flex-control-nav li") or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
  5502. sync: '', // {NEW} Selector: Mirror the actions performed on this slider with another slider. Use with care.
  5503. asNavFor: '', // {NEW} Selector: Internal property exposed for turning the slider into a thumbnail navigation for another slider
  5504. // Carousel Options
  5505. itemWidth: 0, // {NEW} Integer: Box-model width of individual carousel items, including horizontal borders and padding.
  5506. itemMargin: 0, // {NEW} Integer: Margin between carousel items.
  5507. minItems: 1, // {NEW} Integer: Minimum number of carousel items that should be visible. Items will resize fluidly when below this.
  5508. maxItems: 0, // {NEW} Integer: Maxmimum number of carousel items that should be visible. Items will resize fluidly when above this limit.
  5509. move: 0, // {NEW} Integer: Number of carousel items that should move on animation. If 0, slider will move all visible items.
  5510. allowOneSlide: true, // {NEW} Boolean: Whether or not to allow a slider comprised of a single slide
  5511. // Callback API
  5512. start: function() {
  5513. }, // Callback: function(slider) - Fires when the slider loads the first slide
  5514. before: function() {
  5515. }, // Callback: function(slider) - Fires asynchronously with each slider animation
  5516. after: function() {
  5517. }, // Callback: function(slider) - Fires after each slider animation completes
  5518. end: function() {
  5519. }, // Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
  5520. added: function() {
  5521. }, // {NEW} Callback: function(slider) - Fires after a slide is added
  5522. removed: function() {
  5523. }, // {NEW} Callback: function(slider) - Fires after a slide is removed
  5524. init: function() {
  5525. } // {NEW} Callback: function(slider) - Fires after the slider is initially setup
  5526. };
  5527. // FlexSlider: Plugin Function
  5528. $.fn.flexslider = function(options) {
  5529. var args = Array.prototype.slice.call(arguments, 1);
  5530. if (options === undefined) {options = {};}
  5531. if (typeof options === 'object') {
  5532. return this.each(function() {
  5533. var $this = $(this);
  5534. var selector = (options.selector) ? options.selector : '.am-slides > li';
  5535. var $slides = $this.find(selector);
  5536. if (($slides.length === 1 && options.allowOneSlide === true) || $slides.length === 0) {
  5537. $slides.fadeIn(400);
  5538. if (options.start) {options.start($this);}
  5539. } else if ($this.data('flexslider') === undefined) {
  5540. new $.flexslider(this, options);
  5541. }
  5542. });
  5543. } else {
  5544. // Helper strings to quickly pecdrform functions on the slider
  5545. var $slider = $(this).data('flexslider');
  5546. var methodReturn;
  5547. switch (options) {
  5548. case 'next':
  5549. $slider.flexAnimate($slider.getTarget('next'), true);
  5550. break;
  5551. case 'prev':
  5552. case 'previous':
  5553. $slider.flexAnimate($slider.getTarget('prev'), true);
  5554. break;
  5555. default:
  5556. if (typeof options === 'number') {
  5557. $slider.flexAnimate(options, true);
  5558. } else if (typeof options === 'string') {
  5559. methodReturn = (typeof $slider[options] === 'function') ?
  5560. $slider[options].apply($slider, args) : $slider[options];
  5561. }
  5562. }
  5563. return methodReturn === undefined ? this : methodReturn;
  5564. }
  5565. };
  5566. // Init code
  5567. UI.ready(function(context) {
  5568. $('[data-am-flexslider]', context).each(function(i, item) {
  5569. var $slider = $(item);
  5570. var options = UI.utils.parseOptions($slider.data('amFlexslider'));
  5571. options.before = function(slider) {
  5572. if (slider._pausedTimer) {
  5573. window.clearTimeout(slider._pausedTimer);
  5574. slider._pausedTimer = null;
  5575. }
  5576. };
  5577. options.after = function(slider) {
  5578. var pauseTime = slider.vars.playAfterPaused;
  5579. if (pauseTime && !isNaN(pauseTime) && !slider.playing) {
  5580. if (!slider.manualPause && !slider.manualPlay && !slider.stopped) {
  5581. slider._pausedTimer = window.setTimeout(function() {
  5582. slider.play();
  5583. }, pauseTime);
  5584. }
  5585. }
  5586. };
  5587. $slider.flexslider(options);
  5588. });
  5589. });
  5590. module.exports = $.flexslider;
  5591. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(12).setImmediate))
  5592. /***/ },
  5593. /* 12 */
  5594. /***/ function(module, exports, __webpack_require__) {
  5595. /* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(13).nextTick;
  5596. var apply = Function.prototype.apply;
  5597. var slice = Array.prototype.slice;
  5598. var immediateIds = {};
  5599. var nextImmediateId = 0;
  5600. // DOM APIs, for completeness
  5601. exports.setTimeout = function() {
  5602. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  5603. };
  5604. exports.setInterval = function() {
  5605. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  5606. };
  5607. exports.clearTimeout =
  5608. exports.clearInterval = function(timeout) { timeout.close(); };
  5609. function Timeout(id, clearFn) {
  5610. this._id = id;
  5611. this._clearFn = clearFn;
  5612. }
  5613. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  5614. Timeout.prototype.close = function() {
  5615. this._clearFn.call(window, this._id);
  5616. };
  5617. // Does not start the time, just sets up the members needed.
  5618. exports.enroll = function(item, msecs) {
  5619. clearTimeout(item._idleTimeoutId);
  5620. item._idleTimeout = msecs;
  5621. };
  5622. exports.unenroll = function(item) {
  5623. clearTimeout(item._idleTimeoutId);
  5624. item._idleTimeout = -1;
  5625. };
  5626. exports._unrefActive = exports.active = function(item) {
  5627. clearTimeout(item._idleTimeoutId);
  5628. var msecs = item._idleTimeout;
  5629. if (msecs >= 0) {
  5630. item._idleTimeoutId = setTimeout(function onTimeout() {
  5631. if (item._onTimeout)
  5632. item._onTimeout();
  5633. }, msecs);
  5634. }
  5635. };
  5636. // That's not how node.js implements it but the exposed api is the same.
  5637. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
  5638. var id = nextImmediateId++;
  5639. var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  5640. immediateIds[id] = true;
  5641. nextTick(function onNextTick() {
  5642. if (immediateIds[id]) {
  5643. // fn.call() is faster so we optimize for the common use-case
  5644. // @see http://jsperf.com/call-apply-segu
  5645. if (args) {
  5646. fn.apply(null, args);
  5647. } else {
  5648. fn.call(null);
  5649. }
  5650. // Prevent ids from leaking
  5651. exports.clearImmediate(id);
  5652. }
  5653. });
  5654. return id;
  5655. };
  5656. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
  5657. delete immediateIds[id];
  5658. };
  5659. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(12).setImmediate, __webpack_require__(12).clearImmediate))
  5660. /***/ },
  5661. /* 13 */
  5662. /***/ function(module, exports) {
  5663. // shim for using process in browser
  5664. var process = module.exports = {};
  5665. var queue = [];
  5666. var draining = false;
  5667. var currentQueue;
  5668. var queueIndex = -1;
  5669. function cleanUpNextTick() {
  5670. draining = false;
  5671. if (currentQueue.length) {
  5672. queue = currentQueue.concat(queue);
  5673. } else {
  5674. queueIndex = -1;
  5675. }
  5676. if (queue.length) {
  5677. drainQueue();
  5678. }
  5679. }
  5680. function drainQueue() {
  5681. if (draining) {
  5682. return;
  5683. }
  5684. var timeout = setTimeout(cleanUpNextTick);
  5685. draining = true;
  5686. var len = queue.length;
  5687. while(len) {
  5688. currentQueue = queue;
  5689. queue = [];
  5690. while (++queueIndex < len) {
  5691. if (currentQueue) {
  5692. currentQueue[queueIndex].run();
  5693. }
  5694. }
  5695. queueIndex = -1;
  5696. len = queue.length;
  5697. }
  5698. currentQueue = null;
  5699. draining = false;
  5700. clearTimeout(timeout);
  5701. }
  5702. process.nextTick = function (fun) {
  5703. var args = new Array(arguments.length - 1);
  5704. if (arguments.length > 1) {
  5705. for (var i = 1; i < arguments.length; i++) {
  5706. args[i - 1] = arguments[i];
  5707. }
  5708. }
  5709. queue.push(new Item(fun, args));
  5710. if (queue.length === 1 && !draining) {
  5711. setTimeout(drainQueue, 0);
  5712. }
  5713. };
  5714. // v8 likes predictible objects
  5715. function Item(fun, array) {
  5716. this.fun = fun;
  5717. this.array = array;
  5718. }
  5719. Item.prototype.run = function () {
  5720. this.fun.apply(null, this.array);
  5721. };
  5722. process.title = 'browser';
  5723. process.browser = true;
  5724. process.env = {};
  5725. process.argv = [];
  5726. process.version = ''; // empty string to avoid regexp issues
  5727. process.versions = {};
  5728. function noop() {}
  5729. process.on = noop;
  5730. process.addListener = noop;
  5731. process.once = noop;
  5732. process.off = noop;
  5733. process.removeListener = noop;
  5734. process.removeAllListeners = noop;
  5735. process.emit = noop;
  5736. process.binding = function (name) {
  5737. throw new Error('process.binding is not supported');
  5738. };
  5739. process.cwd = function () { return '/' };
  5740. process.chdir = function (dir) {
  5741. throw new Error('process.chdir is not supported');
  5742. };
  5743. process.umask = function() { return 0; };
  5744. /***/ },
  5745. /* 14 */
  5746. /***/ function(module, exports, __webpack_require__) {
  5747. 'use strict';
  5748. var UI = __webpack_require__(2);
  5749. /* jshint unused: false */
  5750. /* jshint -W101, -W116, -W109 */
  5751. /*! iScroll v5.1.3
  5752. * (c) 2008-2014 Matteo Spinelli
  5753. * http://cubiq.org/license
  5754. */
  5755. var rAF = window.requestAnimationFrame ||
  5756. window.webkitRequestAnimationFrame ||
  5757. window.mozRequestAnimationFrame ||
  5758. window.oRequestAnimationFrame ||
  5759. window.msRequestAnimationFrame ||
  5760. function(callback) {
  5761. window.setTimeout(callback, 1000 / 60);
  5762. };
  5763. var utils = (function() {
  5764. var me = {};
  5765. var _elementStyle = document.createElement('div').style;
  5766. var _vendor = (function() {
  5767. var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
  5768. transform,
  5769. i = 0,
  5770. l = vendors.length;
  5771. for (; i < l; i++) {
  5772. transform = vendors[i] + 'ransform';
  5773. if (transform in _elementStyle) return vendors[i].substr(0, vendors[i].length - 1);
  5774. }
  5775. return false;
  5776. })();
  5777. function _prefixStyle(style) {
  5778. if (_vendor === false) return false;
  5779. if (_vendor === '') return style;
  5780. return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
  5781. }
  5782. me.getTime = Date.now || function getTime() {
  5783. return new Date().getTime();
  5784. };
  5785. me.extend = function(target, obj) {
  5786. for (var i in obj) {
  5787. target[i] = obj[i];
  5788. }
  5789. };
  5790. me.addEvent = function(el, type, fn, capture) {
  5791. el.addEventListener(type, fn, !!capture);
  5792. };
  5793. me.removeEvent = function(el, type, fn, capture) {
  5794. el.removeEventListener(type, fn, !!capture);
  5795. };
  5796. me.prefixPointerEvent = function(pointerEvent) {
  5797. return window.MSPointerEvent ?
  5798. 'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10) :
  5799. pointerEvent;
  5800. };
  5801. me.momentum = function(current, start, time, lowerMargin, wrapperSize, deceleration) {
  5802. var distance = current - start,
  5803. speed = Math.abs(distance) / time,
  5804. destination,
  5805. duration;
  5806. deceleration = deceleration === undefined ? 0.0006 : deceleration;
  5807. destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
  5808. duration = speed / deceleration;
  5809. if (destination < lowerMargin) {
  5810. destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
  5811. distance = Math.abs(destination - current);
  5812. duration = distance / speed;
  5813. } else if (destination > 0) {
  5814. destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
  5815. distance = Math.abs(current) + destination;
  5816. duration = distance / speed;
  5817. }
  5818. return {
  5819. destination: Math.round(destination),
  5820. duration: duration
  5821. };
  5822. };
  5823. var _transform = _prefixStyle('transform');
  5824. me.extend(me, {
  5825. hasTransform: _transform !== false,
  5826. hasPerspective: _prefixStyle('perspective') in _elementStyle,
  5827. hasTouch: 'ontouchstart' in window,
  5828. hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed
  5829. hasTransition: _prefixStyle('transition') in _elementStyle
  5830. });
  5831. // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
  5832. me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
  5833. me.extend(me.style = {}, {
  5834. transform: _transform,
  5835. transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
  5836. transitionDuration: _prefixStyle('transitionDuration'),
  5837. transitionDelay: _prefixStyle('transitionDelay'),
  5838. transformOrigin: _prefixStyle('transformOrigin')
  5839. });
  5840. me.hasClass = function(e, c) {
  5841. var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
  5842. return re.test(e.className);
  5843. };
  5844. me.addClass = function(e, c) {
  5845. if (me.hasClass(e, c)) {
  5846. return;
  5847. }
  5848. var newclass = e.className.split(' ');
  5849. newclass.push(c);
  5850. e.className = newclass.join(' ');
  5851. };
  5852. me.removeClass = function(e, c) {
  5853. if (!me.hasClass(e, c)) {
  5854. return;
  5855. }
  5856. var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
  5857. e.className = e.className.replace(re, ' ');
  5858. };
  5859. me.offset = function(el) {
  5860. var left = -el.offsetLeft,
  5861. top = -el.offsetTop;
  5862. // jshint -W084
  5863. while (el = el.offsetParent) {
  5864. left -= el.offsetLeft;
  5865. top -= el.offsetTop;
  5866. }
  5867. // jshint +W084
  5868. return {
  5869. left: left,
  5870. top: top
  5871. };
  5872. };
  5873. me.preventDefaultException = function(el, exceptions) {
  5874. for (var i in exceptions) {
  5875. if (exceptions[i].test(el[i])) {
  5876. return true;
  5877. }
  5878. }
  5879. return false;
  5880. };
  5881. me.extend(me.eventType = {}, {
  5882. touchstart: 1,
  5883. touchmove: 1,
  5884. touchend: 1,
  5885. mousedown: 2,
  5886. mousemove: 2,
  5887. mouseup: 2,
  5888. pointerdown: 3,
  5889. pointermove: 3,
  5890. pointerup: 3,
  5891. MSPointerDown: 3,
  5892. MSPointerMove: 3,
  5893. MSPointerUp: 3
  5894. });
  5895. me.extend(me.ease = {}, {
  5896. quadratic: {
  5897. style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
  5898. fn: function(k) {
  5899. return k * ( 2 - k );
  5900. }
  5901. },
  5902. circular: {
  5903. style: 'cubic-bezier(0.1, 0.57, 0.1, 1)', // Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1)
  5904. fn: function(k) {
  5905. return Math.sqrt(1 - ( --k * k ));
  5906. }
  5907. },
  5908. back: {
  5909. style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
  5910. fn: function(k) {
  5911. var b = 4;
  5912. return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
  5913. }
  5914. },
  5915. bounce: {
  5916. style: '',
  5917. fn: function(k) {
  5918. if (( k /= 1 ) < ( 1 / 2.75 )) {
  5919. return 7.5625 * k * k;
  5920. } else if (k < ( 2 / 2.75 )) {
  5921. return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
  5922. } else if (k < ( 2.5 / 2.75 )) {
  5923. return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
  5924. } else {
  5925. return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
  5926. }
  5927. }
  5928. },
  5929. elastic: {
  5930. style: '',
  5931. fn: function(k) {
  5932. var f = 0.22,
  5933. e = 0.4;
  5934. if (k === 0) {
  5935. return 0;
  5936. }
  5937. if (k == 1) {
  5938. return 1;
  5939. }
  5940. return ( e * Math.pow(2, -10 * k) * Math.sin(( k - f / 4 ) * ( 2 * Math.PI ) / f) + 1 );
  5941. }
  5942. }
  5943. });
  5944. me.tap = function(e, eventName) {
  5945. var ev = document.createEvent('Event');
  5946. ev.initEvent(eventName, true, true);
  5947. ev.pageX = e.pageX;
  5948. ev.pageY = e.pageY;
  5949. e.target.dispatchEvent(ev);
  5950. };
  5951. me.click = function(e) {
  5952. var target = e.target,
  5953. ev;
  5954. if (!(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName)) {
  5955. ev = document.createEvent('MouseEvents');
  5956. ev.initMouseEvent('click', true, true, e.view, 1,
  5957. target.screenX, target.screenY, target.clientX, target.clientY,
  5958. e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
  5959. 0, null);
  5960. ev._constructed = true;
  5961. target.dispatchEvent(ev);
  5962. }
  5963. };
  5964. return me;
  5965. })();
  5966. function IScroll(el, options) {
  5967. this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
  5968. this.scroller = this.wrapper.children[0];
  5969. this.scrollerStyle = this.scroller.style; // cache style for better performance
  5970. this.options = {
  5971. // INSERT POINT: OPTIONS
  5972. startX: 0,
  5973. startY: 0,
  5974. scrollY: true,
  5975. directionLockThreshold: 5,
  5976. momentum: true,
  5977. bounce: true,
  5978. bounceTime: 600,
  5979. bounceEasing: '',
  5980. preventDefault: true,
  5981. preventDefaultException: {tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/},
  5982. HWCompositing: true,
  5983. useTransition: true,
  5984. useTransform: true
  5985. };
  5986. for (var i in options) {
  5987. this.options[i] = options[i];
  5988. }
  5989. // Normalize options
  5990. this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
  5991. this.options.useTransition = utils.hasTransition && this.options.useTransition;
  5992. this.options.useTransform = utils.hasTransform && this.options.useTransform;
  5993. this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
  5994. this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
  5995. // If you want eventPassthrough I have to lock one of the axes
  5996. this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
  5997. this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
  5998. // With eventPassthrough we also need lockDirection mechanism
  5999. this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
  6000. this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
  6001. this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
  6002. this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
  6003. if (this.options.tap === true) {
  6004. this.options.tap = 'tap';
  6005. }
  6006. // INSERT POINT: NORMALIZATION
  6007. // Some defaults
  6008. this.x = 0;
  6009. this.y = 0;
  6010. this.directionX = 0;
  6011. this.directionY = 0;
  6012. this._events = {};
  6013. // INSERT POINT: DEFAULTS
  6014. this._init();
  6015. this.refresh();
  6016. this.scrollTo(this.options.startX, this.options.startY);
  6017. this.enable();
  6018. }
  6019. IScroll.prototype = {
  6020. version: '5.1.3',
  6021. _init: function() {
  6022. this._initEvents();
  6023. // INSERT POINT: _init
  6024. },
  6025. destroy: function() {
  6026. this._initEvents(true);
  6027. this._execEvent('destroy');
  6028. },
  6029. _transitionEnd: function(e) {
  6030. if (e.target != this.scroller || !this.isInTransition) {
  6031. return;
  6032. }
  6033. this._transitionTime();
  6034. if (!this.resetPosition(this.options.bounceTime)) {
  6035. this.isInTransition = false;
  6036. this._execEvent('scrollEnd');
  6037. }
  6038. },
  6039. _start: function(e) {
  6040. // React to left mouse button only
  6041. if (utils.eventType[e.type] != 1) {
  6042. if (e.button !== 0) {
  6043. return;
  6044. }
  6045. }
  6046. if (!this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated)) {
  6047. return;
  6048. }
  6049. if (this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException)) {
  6050. e.preventDefault();
  6051. }
  6052. var point = e.touches ? e.touches[0] : e,
  6053. pos;
  6054. this.initiated = utils.eventType[e.type];
  6055. this.moved = false;
  6056. this.distX = 0;
  6057. this.distY = 0;
  6058. this.directionX = 0;
  6059. this.directionY = 0;
  6060. this.directionLocked = 0;
  6061. this._transitionTime();
  6062. this.startTime = utils.getTime();
  6063. if (this.options.useTransition && this.isInTransition) {
  6064. this.isInTransition = false;
  6065. pos = this.getComputedPosition();
  6066. this._translate(Math.round(pos.x), Math.round(pos.y));
  6067. this._execEvent('scrollEnd');
  6068. } else if (!this.options.useTransition && this.isAnimating) {
  6069. this.isAnimating = false;
  6070. this._execEvent('scrollEnd');
  6071. }
  6072. this.startX = this.x;
  6073. this.startY = this.y;
  6074. this.absStartX = this.x;
  6075. this.absStartY = this.y;
  6076. this.pointX = point.pageX;
  6077. this.pointY = point.pageY;
  6078. this._execEvent('beforeScrollStart');
  6079. },
  6080. _move: function(e) {
  6081. if (!this.enabled || utils.eventType[e.type] !== this.initiated) {
  6082. return;
  6083. }
  6084. if (this.options.preventDefault) { // increases performance on Android? TODO: check!
  6085. e.preventDefault();
  6086. }
  6087. var point = e.touches ? e.touches[0] : e,
  6088. deltaX = point.pageX - this.pointX,
  6089. deltaY = point.pageY - this.pointY,
  6090. timestamp = utils.getTime(),
  6091. newX, newY,
  6092. absDistX, absDistY;
  6093. this.pointX = point.pageX;
  6094. this.pointY = point.pageY;
  6095. this.distX += deltaX;
  6096. this.distY += deltaY;
  6097. absDistX = Math.abs(this.distX);
  6098. absDistY = Math.abs(this.distY);
  6099. // We need to move at least 10 pixels for the scrolling to initiate
  6100. if (timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10)) {
  6101. return;
  6102. }
  6103. // If you are scrolling in one direction lock the other
  6104. if (!this.directionLocked && !this.options.freeScroll) {
  6105. if (absDistX > absDistY + this.options.directionLockThreshold) {
  6106. this.directionLocked = 'h'; // lock horizontally
  6107. } else if (absDistY >= absDistX + this.options.directionLockThreshold) {
  6108. this.directionLocked = 'v'; // lock vertically
  6109. } else {
  6110. this.directionLocked = 'n'; // no lock
  6111. }
  6112. }
  6113. if (this.directionLocked == 'h') {
  6114. if (this.options.eventPassthrough == 'vertical') {
  6115. e.preventDefault();
  6116. } else if (this.options.eventPassthrough == 'horizontal') {
  6117. this.initiated = false;
  6118. return;
  6119. }
  6120. deltaY = 0;
  6121. } else if (this.directionLocked == 'v') {
  6122. if (this.options.eventPassthrough == 'horizontal') {
  6123. e.preventDefault();
  6124. } else if (this.options.eventPassthrough == 'vertical') {
  6125. this.initiated = false;
  6126. return;
  6127. }
  6128. deltaX = 0;
  6129. }
  6130. deltaX = this.hasHorizontalScroll ? deltaX : 0;
  6131. deltaY = this.hasVerticalScroll ? deltaY : 0;
  6132. newX = this.x + deltaX;
  6133. newY = this.y + deltaY;
  6134. // Slow down if outside of the boundaries
  6135. if (newX > 0 || newX < this.maxScrollX) {
  6136. newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
  6137. }
  6138. if (newY > 0 || newY < this.maxScrollY) {
  6139. newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
  6140. }
  6141. this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
  6142. this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
  6143. if (!this.moved) {
  6144. this._execEvent('scrollStart');
  6145. }
  6146. this.moved = true;
  6147. this._translate(newX, newY);
  6148. /* REPLACE START: _move */
  6149. if (timestamp - this.startTime > 300) {
  6150. this.startTime = timestamp;
  6151. this.startX = this.x;
  6152. this.startY = this.y;
  6153. }
  6154. /* REPLACE END: _move */
  6155. },
  6156. _end: function(e) {
  6157. if (!this.enabled || utils.eventType[e.type] !== this.initiated) {
  6158. return;
  6159. }
  6160. if (this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException)) {
  6161. e.preventDefault();
  6162. }
  6163. var point = e.changedTouches ? e.changedTouches[0] : e,
  6164. momentumX,
  6165. momentumY,
  6166. duration = utils.getTime() - this.startTime,
  6167. newX = Math.round(this.x),
  6168. newY = Math.round(this.y),
  6169. distanceX = Math.abs(newX - this.startX),
  6170. distanceY = Math.abs(newY - this.startY),
  6171. time = 0,
  6172. easing = '';
  6173. this.isInTransition = 0;
  6174. this.initiated = 0;
  6175. this.endTime = utils.getTime();
  6176. // reset if we are outside of the boundaries
  6177. if (this.resetPosition(this.options.bounceTime)) {
  6178. return;
  6179. }
  6180. this.scrollTo(newX, newY); // ensures that the last position is rounded
  6181. // we scrolled less than 10 pixels
  6182. if (!this.moved) {
  6183. if (this.options.tap) {
  6184. utils.tap(e, this.options.tap);
  6185. }
  6186. if (this.options.click) {
  6187. utils.click(e);
  6188. }
  6189. this._execEvent('scrollCancel');
  6190. return;
  6191. }
  6192. if (this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100) {
  6193. this._execEvent('flick');
  6194. return;
  6195. }
  6196. // start momentum animation if needed
  6197. if (this.options.momentum && duration < 300) {
  6198. momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : {
  6199. destination: newX,
  6200. duration: 0
  6201. };
  6202. momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : {
  6203. destination: newY,
  6204. duration: 0
  6205. };
  6206. newX = momentumX.destination;
  6207. newY = momentumY.destination;
  6208. time = Math.max(momentumX.duration, momentumY.duration);
  6209. this.isInTransition = 1;
  6210. }
  6211. // INSERT POINT: _end
  6212. if (newX != this.x || newY != this.y) {
  6213. // change easing function when scroller goes out of the boundaries
  6214. if (newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY) {
  6215. easing = utils.ease.quadratic;
  6216. }
  6217. this.scrollTo(newX, newY, time, easing);
  6218. return;
  6219. }
  6220. this._execEvent('scrollEnd');
  6221. },
  6222. _resize: function() {
  6223. var that = this;
  6224. clearTimeout(this.resizeTimeout);
  6225. this.resizeTimeout = setTimeout(function() {
  6226. that.refresh();
  6227. }, this.options.resizePolling);
  6228. },
  6229. resetPosition: function(time) {
  6230. var x = this.x,
  6231. y = this.y;
  6232. time = time || 0;
  6233. if (!this.hasHorizontalScroll || this.x > 0) {
  6234. x = 0;
  6235. } else if (this.x < this.maxScrollX) {
  6236. x = this.maxScrollX;
  6237. }
  6238. if (!this.hasVerticalScroll || this.y > 0) {
  6239. y = 0;
  6240. } else if (this.y < this.maxScrollY) {
  6241. y = this.maxScrollY;
  6242. }
  6243. if (x == this.x && y == this.y) {
  6244. return false;
  6245. }
  6246. this.scrollTo(x, y, time, this.options.bounceEasing);
  6247. return true;
  6248. },
  6249. disable: function() {
  6250. this.enabled = false;
  6251. },
  6252. enable: function() {
  6253. this.enabled = true;
  6254. },
  6255. refresh: function() {
  6256. var rf = this.wrapper.offsetHeight; // Force reflow
  6257. this.wrapperWidth = this.wrapper.clientWidth;
  6258. this.wrapperHeight = this.wrapper.clientHeight;
  6259. /* REPLACE START: refresh */
  6260. this.scrollerWidth = this.scroller.offsetWidth;
  6261. this.scrollerHeight = this.scroller.offsetHeight;
  6262. this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
  6263. this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
  6264. /* REPLACE END: refresh */
  6265. this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
  6266. this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
  6267. if (!this.hasHorizontalScroll) {
  6268. this.maxScrollX = 0;
  6269. this.scrollerWidth = this.wrapperWidth;
  6270. }
  6271. if (!this.hasVerticalScroll) {
  6272. this.maxScrollY = 0;
  6273. this.scrollerHeight = this.wrapperHeight;
  6274. }
  6275. this.endTime = 0;
  6276. this.directionX = 0;
  6277. this.directionY = 0;
  6278. this.wrapperOffset = utils.offset(this.wrapper);
  6279. this._execEvent('refresh');
  6280. this.resetPosition();
  6281. // INSERT POINT: _refresh
  6282. },
  6283. on: function(type, fn) {
  6284. if (!this._events[type]) {
  6285. this._events[type] = [];
  6286. }
  6287. this._events[type].push(fn);
  6288. },
  6289. off: function(type, fn) {
  6290. if (!this._events[type]) {
  6291. return;
  6292. }
  6293. var index = this._events[type].indexOf(fn);
  6294. if (index > -1) {
  6295. this._events[type].splice(index, 1);
  6296. }
  6297. },
  6298. _execEvent: function(type) {
  6299. if (!this._events[type]) {
  6300. return;
  6301. }
  6302. var i = 0,
  6303. l = this._events[type].length;
  6304. if (!l) {
  6305. return;
  6306. }
  6307. for (; i < l; i++) {
  6308. this._events[type][i].apply(this, [].slice.call(arguments, 1));
  6309. }
  6310. },
  6311. scrollBy: function(x, y, time, easing) {
  6312. x = this.x + x;
  6313. y = this.y + y;
  6314. time = time || 0;
  6315. this.scrollTo(x, y, time, easing);
  6316. },
  6317. scrollTo: function(x, y, time, easing) {
  6318. easing = easing || utils.ease.circular;
  6319. this.isInTransition = this.options.useTransition && time > 0;
  6320. if (!time || (this.options.useTransition && easing.style)) {
  6321. this._transitionTimingFunction(easing.style);
  6322. this._transitionTime(time);
  6323. this._translate(x, y);
  6324. } else {
  6325. this._animate(x, y, time, easing.fn);
  6326. }
  6327. },
  6328. scrollToElement: function(el, time, offsetX, offsetY, easing) {
  6329. el = el.nodeType ? el : this.scroller.querySelector(el);
  6330. if (!el) {
  6331. return;
  6332. }
  6333. var pos = utils.offset(el);
  6334. pos.left -= this.wrapperOffset.left;
  6335. pos.top -= this.wrapperOffset.top;
  6336. // if offsetX/Y are true we center the element to the screen
  6337. if (offsetX === true) {
  6338. offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
  6339. }
  6340. if (offsetY === true) {
  6341. offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
  6342. }
  6343. pos.left -= offsetX || 0;
  6344. pos.top -= offsetY || 0;
  6345. pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
  6346. pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
  6347. time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x - pos.left), Math.abs(this.y - pos.top)) : time;
  6348. this.scrollTo(pos.left, pos.top, time, easing);
  6349. },
  6350. _transitionTime: function(time) {
  6351. time = time || 0;
  6352. this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
  6353. if (!time && utils.isBadAndroid) {
  6354. this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
  6355. }
  6356. // INSERT POINT: _transitionTime
  6357. },
  6358. _transitionTimingFunction: function(easing) {
  6359. this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
  6360. // INSERT POINT: _transitionTimingFunction
  6361. },
  6362. _translate: function(x, y) {
  6363. if (this.options.useTransform) {
  6364. /* REPLACE START: _translate */
  6365. this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
  6366. /* REPLACE END: _translate */
  6367. } else {
  6368. x = Math.round(x);
  6369. y = Math.round(y);
  6370. this.scrollerStyle.left = x + 'px';
  6371. this.scrollerStyle.top = y + 'px';
  6372. }
  6373. this.x = x;
  6374. this.y = y;
  6375. // INSERT POINT: _translate
  6376. },
  6377. _initEvents: function(remove) {
  6378. var eventType = remove ? utils.removeEvent : utils.addEvent,
  6379. target = this.options.bindToWrapper ? this.wrapper : window;
  6380. eventType(window, 'orientationchange', this);
  6381. eventType(window, 'resize', this);
  6382. if (this.options.click) {
  6383. eventType(this.wrapper, 'click', this, true);
  6384. }
  6385. if (!this.options.disableMouse) {
  6386. eventType(this.wrapper, 'mousedown', this);
  6387. eventType(target, 'mousemove', this);
  6388. eventType(target, 'mousecancel', this);
  6389. eventType(target, 'mouseup', this);
  6390. }
  6391. if (utils.hasPointer && !this.options.disablePointer) {
  6392. eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this);
  6393. eventType(target, utils.prefixPointerEvent('pointermove'), this);
  6394. eventType(target, utils.prefixPointerEvent('pointercancel'), this);
  6395. eventType(target, utils.prefixPointerEvent('pointerup'), this);
  6396. }
  6397. if (utils.hasTouch && !this.options.disableTouch) {
  6398. eventType(this.wrapper, 'touchstart', this);
  6399. eventType(target, 'touchmove', this);
  6400. eventType(target, 'touchcancel', this);
  6401. eventType(target, 'touchend', this);
  6402. }
  6403. eventType(this.scroller, 'transitionend', this);
  6404. eventType(this.scroller, 'webkitTransitionEnd', this);
  6405. eventType(this.scroller, 'oTransitionEnd', this);
  6406. eventType(this.scroller, 'MSTransitionEnd', this);
  6407. },
  6408. getComputedPosition: function() {
  6409. var matrix = window.getComputedStyle(this.scroller, null),
  6410. x, y;
  6411. if (this.options.useTransform) {
  6412. matrix = matrix[utils.style.transform].split(')')[0].split(', ');
  6413. x = +(matrix[12] || matrix[4]);
  6414. y = +(matrix[13] || matrix[5]);
  6415. } else {
  6416. x = +matrix.left.replace(/[^-\d.]/g, '');
  6417. y = +matrix.top.replace(/[^-\d.]/g, '');
  6418. }
  6419. return {x: x, y: y};
  6420. },
  6421. _animate: function(destX, destY, duration, easingFn) {
  6422. var that = this,
  6423. startX = this.x,
  6424. startY = this.y,
  6425. startTime = utils.getTime(),
  6426. destTime = startTime + duration;
  6427. function step() {
  6428. var now = utils.getTime(),
  6429. newX, newY,
  6430. easing;
  6431. if (now >= destTime) {
  6432. that.isAnimating = false;
  6433. that._translate(destX, destY);
  6434. if (!that.resetPosition(that.options.bounceTime)) {
  6435. that._execEvent('scrollEnd');
  6436. }
  6437. return;
  6438. }
  6439. now = ( now - startTime ) / duration;
  6440. easing = easingFn(now);
  6441. newX = ( destX - startX ) * easing + startX;
  6442. newY = ( destY - startY ) * easing + startY;
  6443. that._translate(newX, newY);
  6444. if (that.isAnimating) {
  6445. rAF(step);
  6446. }
  6447. }
  6448. this.isAnimating = true;
  6449. step();
  6450. },
  6451. handleEvent: function(e) {
  6452. switch (e.type) {
  6453. case 'touchstart':
  6454. case 'pointerdown':
  6455. case 'MSPointerDown':
  6456. case 'mousedown':
  6457. this._start(e);
  6458. break;
  6459. case 'touchmove':
  6460. case 'pointermove':
  6461. case 'MSPointerMove':
  6462. case 'mousemove':
  6463. this._move(e);
  6464. break;
  6465. case 'touchend':
  6466. case 'pointerup':
  6467. case 'MSPointerUp':
  6468. case 'mouseup':
  6469. case 'touchcancel':
  6470. case 'pointercancel':
  6471. case 'MSPointerCancel':
  6472. case 'mousecancel':
  6473. this._end(e);
  6474. break;
  6475. case 'orientationchange':
  6476. case 'resize':
  6477. this._resize();
  6478. break;
  6479. case 'transitionend':
  6480. case 'webkitTransitionEnd':
  6481. case 'oTransitionEnd':
  6482. case 'MSTransitionEnd':
  6483. this._transitionEnd(e);
  6484. break;
  6485. case 'wheel':
  6486. case 'DOMMouseScroll':
  6487. case 'mousewheel':
  6488. this._wheel(e);
  6489. break;
  6490. case 'keydown':
  6491. this._key(e);
  6492. break;
  6493. case 'click':
  6494. if (!e._constructed) {
  6495. e.preventDefault();
  6496. e.stopPropagation();
  6497. }
  6498. break;
  6499. }
  6500. }
  6501. };
  6502. IScroll.utils = utils;
  6503. module.exports = UI.iScroll = IScroll;
  6504. /* jshint unused: true */
  6505. /* jshint +W101, +W116, +W109 */
  6506. /***/ },
  6507. /* 15 */
  6508. /***/ function(module, exports, __webpack_require__) {
  6509. 'use strict';
  6510. var $ = __webpack_require__(1);
  6511. var UI = __webpack_require__(2);
  6512. var dimmer = __webpack_require__(9);
  6513. var $doc = $(document);
  6514. var supportTransition = UI.support.transition;
  6515. /**
  6516. * @reference https://github.com/nolimits4web/Framework7/blob/master/src/js/modals.js
  6517. * @license https://github.com/nolimits4web/Framework7/blob/master/LICENSE
  6518. */
  6519. var Modal = function(element, options) {
  6520. this.options = $.extend({}, Modal.DEFAULTS, options || {});
  6521. this.$element = $(element);
  6522. this.$dialog = this.$element.find('.am-modal-dialog');
  6523. if (!this.$element.attr('id')) {
  6524. this.$element.attr('id', UI.utils.generateGUID('am-modal'));
  6525. }
  6526. this.isPopup = this.$element.hasClass('am-popup');
  6527. this.isActions = this.$element.hasClass('am-modal-actions');
  6528. this.isPrompt = this.$element.hasClass('am-modal-prompt');
  6529. this.isLoading = this.$element.hasClass('am-modal-loading');
  6530. this.active = this.transitioning = this.relatedTarget = null;
  6531. this.dimmer = this.options.dimmer ? dimmer : {
  6532. open: function() {},
  6533. close: function() {}
  6534. };
  6535. this.events();
  6536. };
  6537. Modal.DEFAULTS = {
  6538. className: {
  6539. active: 'am-modal-active',
  6540. out: 'am-modal-out'
  6541. },
  6542. selector: {
  6543. modal: '.am-modal',
  6544. active: '.am-modal-active'
  6545. },
  6546. closeViaDimmer: true,
  6547. cancelable: true,
  6548. onConfirm: function() {
  6549. },
  6550. onCancel: function() {
  6551. },
  6552. closeOnCancel: true,
  6553. closeOnConfirm: true,
  6554. dimmer: true,
  6555. height: undefined,
  6556. width: undefined,
  6557. duration: 300, // must equal the CSS transition duration
  6558. transitionEnd: supportTransition && supportTransition.end + '.modal.amui'
  6559. };
  6560. Modal.prototype.toggle = function(relatedTarget) {
  6561. return this.active ? this.close() : this.open(relatedTarget);
  6562. };
  6563. Modal.prototype.open = function(relatedTarget) {
  6564. var $element = this.$element;
  6565. var options = this.options;
  6566. var isPopup = this.isPopup;
  6567. var width = options.width;
  6568. var height = options.height;
  6569. var style = {};
  6570. if (this.active) {
  6571. return;
  6572. }
  6573. if (!this.$element.length) {
  6574. return;
  6575. }
  6576. // callback hook
  6577. relatedTarget && (this.relatedTarget = relatedTarget);
  6578. // �ж�������ڶ��������ȴ���֮ǰ��closed�¼�
  6579. if (this.transitioning) {
  6580. clearTimeout($element.transitionEndTimmer);
  6581. $element.transitionEndTimmer = null;
  6582. $element.trigger(options.transitionEnd).off(options.transitionEnd);
  6583. }
  6584. isPopup && this.$element.show();
  6585. this.active = true;
  6586. $element.trigger($.Event('open.modal.amui', {relatedTarget: relatedTarget}));
  6587. this.dimmer.open($element);
  6588. $element.show().redraw();
  6589. // apply Modal width/height if set
  6590. if (!isPopup && !this.isActions) {
  6591. if (width) {
  6592. width = parseInt(width, 10);
  6593. style.width = width + 'px';
  6594. style.marginLeft = -parseInt(width / 2) + 'px';
  6595. }
  6596. if (height) {
  6597. height = parseInt(height, 10);
  6598. // style.height = height + 'px';
  6599. style.marginTop = -parseInt(height / 2) + 'px';
  6600. // the background color is styled to $dialog
  6601. // so the height should set to $dialog
  6602. this.$dialog.css({height: height + 'px'});
  6603. } else {
  6604. style.marginTop = -parseInt($element.height() / 2, 10) + 'px';
  6605. }
  6606. $element.css(style);
  6607. }
  6608. $element.
  6609. removeClass(options.className.out).
  6610. addClass(options.className.active);
  6611. this.transitioning = 1;
  6612. var complete = function() {
  6613. $element.trigger($.Event('opened.modal.amui',
  6614. {relatedTarget: relatedTarget}));
  6615. this.transitioning = 0;
  6616. // Prompt auto focus
  6617. if (this.isPrompt) {
  6618. this.$dialog.find('input').eq(0).focus();
  6619. }
  6620. };
  6621. if (!supportTransition) {
  6622. return complete.call(this);
  6623. }
  6624. $element.
  6625. one(options.transitionEnd, $.proxy(complete, this)).
  6626. emulateTransitionEnd(options.duration);
  6627. };
  6628. Modal.prototype.close = function(relatedTarget) {
  6629. if (!this.active) {
  6630. return;
  6631. }
  6632. var $element = this.$element;
  6633. var options = this.options;
  6634. var isPopup = this.isPopup;
  6635. // �ж�������ڶ��������ȴ���֮ǰ��opened�¼�
  6636. if (this.transitioning) {
  6637. clearTimeout($element.transitionEndTimmer);
  6638. $element.transitionEndTimmer = null;
  6639. $element.trigger(options.transitionEnd).off(options.transitionEnd);
  6640. this.dimmer.close($element, true);
  6641. }
  6642. this.$element.trigger($.Event('close.modal.amui',
  6643. {relatedTarget: relatedTarget}));
  6644. this.transitioning = 1;
  6645. var complete = function() {
  6646. $element.trigger('closed.modal.amui');
  6647. isPopup && $element.removeClass(options.className.out);
  6648. $element.hide();
  6649. this.transitioning = 0;
  6650. // ��ǿ�ƹر� Dimmer���Ա��� Modal ���Թ��� Dimmer
  6651. this.dimmer.close($element, false);
  6652. this.active = false;
  6653. };
  6654. $element.removeClass(options.className.active).
  6655. addClass(options.className.out);
  6656. if (!supportTransition) {
  6657. return complete.call(this);
  6658. }
  6659. $element.one(options.transitionEnd, $.proxy(complete, this)).
  6660. emulateTransitionEnd(options.duration);
  6661. };
  6662. Modal.prototype.events = function() {
  6663. var options = this.options;
  6664. var _this = this;
  6665. var $element = this.$element;
  6666. var $ipt = $element.find('.am-modal-prompt-input');
  6667. var $confirm = $element.find('[data-am-modal-confirm]');
  6668. var $cancel = $element.find('[data-am-modal-cancel]');
  6669. var getData = function() {
  6670. var data = [];
  6671. $ipt.each(function() {
  6672. data.push($(this).val());
  6673. });
  6674. return (data.length === 0) ? undefined :
  6675. ((data.length === 1) ? data[0] : data);
  6676. };
  6677. // close via Esc key
  6678. if (this.options.cancelable) {
  6679. $element.on('keyup.modal.amui', function(e) {
  6680. if (_this.active && e.which === 27) {
  6681. $element.trigger('cancel.modal.amui');
  6682. _this.close();
  6683. }
  6684. });
  6685. }
  6686. // Close Modal when dimmer clicked
  6687. if (this.options.dimmer && this.options.closeViaDimmer && !this.isLoading) {
  6688. this.dimmer.$element.on('click.dimmer.modal.amui', function(e) {
  6689. _this.close();
  6690. });
  6691. }
  6692. // Close Modal when button clicked
  6693. $element.on('click.close.modal.amui', '[data-am-modal-close], .am-modal-btn', function(e) {
  6694. e.preventDefault();
  6695. var $this = $(this);
  6696. if ($this.is($confirm)) {
  6697. options.closeOnConfirm && _this.close();
  6698. } else if ($this.is($cancel)) {
  6699. options.closeOnCancel && _this.close();
  6700. } else {
  6701. _this.close();
  6702. }
  6703. });
  6704. $confirm.on('click.confirm.modal.amui',
  6705. function() {
  6706. $element.trigger($.Event('confirm.modal.amui', {
  6707. trigger: this
  6708. }));
  6709. });
  6710. $cancel.on('click.cancel.modal.amui', function() {
  6711. $element.trigger($.Event('cancel.modal.amui', {
  6712. trigger: this
  6713. }));
  6714. });
  6715. $element.on('confirm.modal.amui', function(e) {
  6716. e.data = getData();
  6717. _this.options.onConfirm.call(_this, e);
  6718. }).on('cancel.modal.amui', function(e) {
  6719. e.data = getData();
  6720. _this.options.onCancel.call(_this, e);
  6721. });
  6722. };
  6723. function Plugin(option, relatedTarget) {
  6724. return this.each(function() {
  6725. var $this = $(this);
  6726. var data = $this.data('amui.modal');
  6727. var options = typeof option == 'object' && option;
  6728. if (!data) {
  6729. $this.data('amui.modal', (data = new Modal(this, options)));
  6730. }
  6731. if (typeof option == 'string') {
  6732. data[option] && data[option](relatedTarget);
  6733. } else {
  6734. data.toggle(option && option.relatedTarget || undefined);
  6735. }
  6736. });
  6737. }
  6738. $.fn.modal = Plugin;
  6739. // Init
  6740. $doc.on('click.modal.amui.data-api', '[data-am-modal]', function() {
  6741. var $this = $(this);
  6742. var options = UI.utils.parseOptions($this.attr('data-am-modal'));
  6743. var $target = $(options.target ||
  6744. (this.href && this.href.replace(/.*(?=#[^\s]+$)/, '')));
  6745. var option = $target.data('amui.modal') ? 'toggle' : options;
  6746. Plugin.call($target, option, this);
  6747. });
  6748. module.exports = UI.modal = Modal;
  6749. /***/ },
  6750. /* 16 */
  6751. /***/ function(module, exports, __webpack_require__) {
  6752. 'use strict';
  6753. var $ = __webpack_require__(1);
  6754. var UI = __webpack_require__(2);
  6755. __webpack_require__(3);
  6756. var $win = $(window);
  6757. var $doc = $(document);
  6758. var scrollPos;
  6759. /**
  6760. * @via https://github.com/uikit/uikit/blob/master/src/js/offcanvas.js
  6761. * @license https://github.com/uikit/uikit/blob/master/LICENSE.md
  6762. */
  6763. var OffCanvas = function(element, options) {
  6764. this.$element = $(element);
  6765. this.options = $.extend({}, OffCanvas.DEFAULTS, options);
  6766. this.active = null;
  6767. this.bindEvents();
  6768. };
  6769. OffCanvas.DEFAULTS = {
  6770. duration: 300,
  6771. effect: 'overlay' // {push|overlay}, push is too expensive
  6772. };
  6773. OffCanvas.prototype.open = function(relatedElement) {
  6774. var _this = this;
  6775. var $element = this.$element;
  6776. if (!$element.length || $element.hasClass('am-active')) {
  6777. return;
  6778. }
  6779. var effect = this.options.effect;
  6780. var $html = $('html');
  6781. var $body = $('body');
  6782. var $bar = $element.find('.am-offcanvas-bar').first();
  6783. var dir = $bar.hasClass('am-offcanvas-bar-flip') ? -1 : 1;
  6784. $bar.addClass('am-offcanvas-bar-' + effect);
  6785. scrollPos = {x: window.scrollX, y: window.scrollY};
  6786. $element.addClass('am-active');
  6787. $body.css({
  6788. width: window.innerWidth,
  6789. height: $win.height()
  6790. }).addClass('am-offcanvas-page');
  6791. if (effect !== 'overlay') {
  6792. $body.css({
  6793. 'margin-left': $bar.outerWidth() * dir
  6794. }).width(); // force redraw
  6795. }
  6796. $html.css('margin-top', scrollPos.y * -1);
  6797. setTimeout(function() {
  6798. $bar.addClass('am-offcanvas-bar-active').width();
  6799. }, 0);
  6800. $element.trigger('open.offcanvas.amui');
  6801. this.active = 1;
  6802. // Close OffCanvas when none content area clicked
  6803. $element.on('click.offcanvas.amui', function(e) {
  6804. var $target = $(e.target);
  6805. if ($target.hasClass('am-offcanvas-bar')) {
  6806. return;
  6807. }
  6808. if ($target.parents('.am-offcanvas-bar').first().length) {
  6809. return;
  6810. }
  6811. // https://developer.mozilla.org/zh-CN/docs/DOM/event.stopImmediatePropagation
  6812. e.stopImmediatePropagation();
  6813. _this.close();
  6814. });
  6815. $html.on('keydown.offcanvas.amui', function(e) {
  6816. (e.keyCode === 27) && _this.close();
  6817. });
  6818. };
  6819. OffCanvas.prototype.close = function(relatedElement) {
  6820. var _this = this;
  6821. var $html = $('html');
  6822. var $body = $('body');
  6823. var $element = this.$element;
  6824. var $bar = $element.find('.am-offcanvas-bar').first();
  6825. if (!$element.length || !this.active || !$element.hasClass('am-active')) {
  6826. return;
  6827. }
  6828. $element.trigger('close.offcanvas.amui');
  6829. function complete() {
  6830. $body
  6831. .removeClass('am-offcanvas-page')
  6832. .css({
  6833. width: '',
  6834. height: '',
  6835. 'margin-left': '',
  6836. 'margin-right': ''
  6837. });
  6838. $element.removeClass('am-active');
  6839. $bar.removeClass('am-offcanvas-bar-active');
  6840. $html.css('margin-top', '');
  6841. window.scrollTo(scrollPos.x, scrollPos.y);
  6842. $element.trigger('closed.offcanvas.amui');
  6843. _this.active = 0;
  6844. }
  6845. if (UI.support.transition) {
  6846. setTimeout(function() {
  6847. $bar.removeClass('am-offcanvas-bar-active');
  6848. }, 0);
  6849. $body.css('margin-left', '').one(UI.support.transition.end, function() {
  6850. complete();
  6851. }).emulateTransitionEnd(this.options.duration);
  6852. } else {
  6853. complete();
  6854. }
  6855. $element.off('click.offcanvas.amui');
  6856. $html.off('.offcanvas.amui');
  6857. };
  6858. OffCanvas.prototype.bindEvents = function() {
  6859. var _this = this;
  6860. $doc.on('click.offcanvas.amui', '[data-am-dismiss="offcanvas"]', function(e) {
  6861. e.preventDefault();
  6862. _this.close();
  6863. });
  6864. $win.on('resize.offcanvas.amui orientationchange.offcanvas.amui',
  6865. function() {
  6866. _this.active && _this.close();
  6867. });
  6868. this.$element.hammer().on('swipeleft swipeleft', function(e) {
  6869. e.preventDefault();
  6870. _this.close();
  6871. });
  6872. return this;
  6873. };
  6874. function Plugin(option, relatedElement) {
  6875. var args = Array.prototype.slice.call(arguments, 1);
  6876. return this.each(function() {
  6877. var $this = $(this);
  6878. var data = $this.data('amui.offcanvas');
  6879. var options = $.extend({}, typeof option == 'object' && option);
  6880. if (!data) {
  6881. $this.data('amui.offcanvas', (data = new OffCanvas(this, options)));
  6882. (!option || typeof option == 'object') && data.open(relatedElement);
  6883. }
  6884. if (typeof option == 'string') {
  6885. data[option] && data[option].apply(data, args);
  6886. }
  6887. });
  6888. }
  6889. $.fn.offCanvas = Plugin;
  6890. // Init code
  6891. $doc.on('click.offcanvas.amui', '[data-am-offcanvas]', function(e) {
  6892. e.preventDefault();
  6893. var $this = $(this);
  6894. var options = UI.utils.parseOptions($this.data('amOffcanvas'));
  6895. var $target = $(options.target ||
  6896. (this.href && this.href.replace(/.*(?=#[^\s]+$)/, '')));
  6897. var option = $target.data('amui.offcanvas') ? 'open' : options;
  6898. Plugin.call($target, option, this);
  6899. });
  6900. module.exports = UI.offcanvas = OffCanvas;
  6901. // TODO: �Ż�����Ч��
  6902. // http://dbushell.github.io/Responsive-Off-Canvas-Menu/step4.html
  6903. /***/ },
  6904. /* 17 */
  6905. /***/ function(module, exports, __webpack_require__) {
  6906. 'use strict';
  6907. var $ = __webpack_require__(1);
  6908. var UI = __webpack_require__(2);
  6909. /**
  6910. * @via https://github.com/manuelstofer/pinchzoom/blob/master/src/pinchzoom.js
  6911. * @license the MIT License.
  6912. */
  6913. var definePinchZoom = function($) {
  6914. /**
  6915. * Pinch zoom using jQuery
  6916. * @version 0.0.2
  6917. * @author Manuel Stofer <mst@rtp.ch>
  6918. * @param el
  6919. * @param options
  6920. * @constructor
  6921. */
  6922. var PinchZoom = function(el, options) {
  6923. this.el = $(el);
  6924. this.zoomFactor = 1;
  6925. this.lastScale = 1;
  6926. this.offset = {
  6927. x: 0,
  6928. y: 0
  6929. };
  6930. this.options = $.extend({}, this.defaults, options);
  6931. this.setupMarkup();
  6932. this.bindEvents();
  6933. this.update();
  6934. // default enable.
  6935. this.enable();
  6936. },
  6937. sum = function(a, b) {
  6938. return a + b;
  6939. },
  6940. isCloseTo = function(value, expected) {
  6941. return value > expected - 0.01 && value < expected + 0.01;
  6942. };
  6943. PinchZoom.prototype = {
  6944. defaults: {
  6945. tapZoomFactor: 2,
  6946. zoomOutFactor: 1.3,
  6947. animationDuration: 300,
  6948. animationInterval: 5,
  6949. maxZoom: 5,
  6950. minZoom: 0.5,
  6951. lockDragAxis: false,
  6952. use2d: false,
  6953. zoomStartEventName: 'pz_zoomstart',
  6954. zoomEndEventName: 'pz_zoomend',
  6955. dragStartEventName: 'pz_dragstart',
  6956. dragEndEventName: 'pz_dragend',
  6957. doubleTapEventName: 'pz_doubletap'
  6958. },
  6959. /**
  6960. * Event handler for 'dragstart'
  6961. * @param event
  6962. */
  6963. handleDragStart: function(event) {
  6964. this.el.trigger(this.options.dragStartEventName);
  6965. this.stopAnimation();
  6966. this.lastDragPosition = false;
  6967. this.hasInteraction = true;
  6968. this.handleDrag(event);
  6969. },
  6970. /**
  6971. * Event handler for 'drag'
  6972. * @param event
  6973. */
  6974. handleDrag: function(event) {
  6975. if (this.zoomFactor > 1.0) {
  6976. var touch = this.getTouches(event)[0];
  6977. this.drag(touch, this.lastDragPosition);
  6978. this.offset = this.sanitizeOffset(this.offset);
  6979. this.lastDragPosition = touch;
  6980. }
  6981. },
  6982. handleDragEnd: function() {
  6983. this.el.trigger(this.options.dragEndEventName);
  6984. this.end();
  6985. },
  6986. /**
  6987. * Event handler for 'zoomstart'
  6988. * @param event
  6989. */
  6990. handleZoomStart: function(event) {
  6991. this.el.trigger(this.options.zoomStartEventName);
  6992. this.stopAnimation();
  6993. this.lastScale = 1;
  6994. this.nthZoom = 0;
  6995. this.lastZoomCenter = false;
  6996. this.hasInteraction = true;
  6997. },
  6998. /**
  6999. * Event handler for 'zoom'
  7000. * @param event
  7001. */
  7002. handleZoom: function(event, newScale) {
  7003. // a relative scale factor is used
  7004. var touchCenter = this.getTouchCenter(this.getTouches(event)),
  7005. scale = newScale / this.lastScale;
  7006. this.lastScale = newScale;
  7007. // the first touch events are thrown away since they are not precise
  7008. this.nthZoom += 1;
  7009. if (this.nthZoom > 3) {
  7010. this.scale(scale, touchCenter);
  7011. this.drag(touchCenter, this.lastZoomCenter);
  7012. }
  7013. this.lastZoomCenter = touchCenter;
  7014. },
  7015. handleZoomEnd: function() {
  7016. this.el.trigger(this.options.zoomEndEventName);
  7017. this.end();
  7018. },
  7019. /**
  7020. * Event handler for 'doubletap'
  7021. * @param event
  7022. */
  7023. handleDoubleTap: function(event) {
  7024. var center = this.getTouches(event)[0],
  7025. zoomFactor = this.zoomFactor > 1 ? 1 : this.options.tapZoomFactor,
  7026. startZoomFactor = this.zoomFactor,
  7027. updateProgress = (function(progress) {
  7028. this.scaleTo(startZoomFactor + progress * (zoomFactor - startZoomFactor), center);
  7029. }).bind(this);
  7030. if (this.hasInteraction) {
  7031. return;
  7032. }
  7033. if (startZoomFactor > zoomFactor) {
  7034. center = this.getCurrentZoomCenter();
  7035. }
  7036. this.animate(this.options.animationDuration, this.options.animationInterval, updateProgress, this.swing);
  7037. this.el.trigger(this.options.doubleTapEventName);
  7038. },
  7039. /**
  7040. * Max / min values for the offset
  7041. * @param offset
  7042. * @return {Object} the sanitized offset
  7043. */
  7044. sanitizeOffset: function(offset) {
  7045. var maxX = (this.zoomFactor - 1) * this.getContainerX(),
  7046. maxY = (this.zoomFactor - 1) * this.getContainerY(),
  7047. maxOffsetX = Math.max(maxX, 0),
  7048. maxOffsetY = Math.max(maxY, 0),
  7049. minOffsetX = Math.min(maxX, 0),
  7050. minOffsetY = Math.min(maxY, 0);
  7051. return {
  7052. x: Math.min(Math.max(offset.x, minOffsetX), maxOffsetX),
  7053. y: Math.min(Math.max(offset.y, minOffsetY), maxOffsetY)
  7054. };
  7055. },
  7056. /**
  7057. * Scale to a specific zoom factor (not relative)
  7058. * @param zoomFactor
  7059. * @param center
  7060. */
  7061. scaleTo: function(zoomFactor, center) {
  7062. this.scale(zoomFactor / this.zoomFactor, center);
  7063. },
  7064. /**
  7065. * Scales the element from specified center
  7066. * @param scale
  7067. * @param center
  7068. */
  7069. scale: function(scale, center) {
  7070. scale = this.scaleZoomFactor(scale);
  7071. this.addOffset({
  7072. x: (scale - 1) * (center.x + this.offset.x),
  7073. y: (scale - 1) * (center.y + this.offset.y)
  7074. });
  7075. },
  7076. /**
  7077. * Scales the zoom factor relative to current state
  7078. * @param scale
  7079. * @return the actual scale (can differ because of max min zoom factor)
  7080. */
  7081. scaleZoomFactor: function(scale) {
  7082. var originalZoomFactor = this.zoomFactor;
  7083. this.zoomFactor *= scale;
  7084. this.zoomFactor = Math.min(this.options.maxZoom, Math.max(this.zoomFactor, this.options.minZoom));
  7085. return this.zoomFactor / originalZoomFactor;
  7086. },
  7087. /**
  7088. * Drags the element
  7089. * @param center
  7090. * @param lastCenter
  7091. */
  7092. drag: function(center, lastCenter) {
  7093. if (lastCenter) {
  7094. if (this.options.lockDragAxis) {
  7095. // lock scroll to position that was changed the most
  7096. if (Math.abs(center.x - lastCenter.x) > Math.abs(center.y - lastCenter.y)) {
  7097. this.addOffset({
  7098. x: -(center.x - lastCenter.x),
  7099. y: 0
  7100. });
  7101. }
  7102. else {
  7103. this.addOffset({
  7104. y: -(center.y - lastCenter.y),
  7105. x: 0
  7106. });
  7107. }
  7108. }
  7109. else {
  7110. this.addOffset({
  7111. y: -(center.y - lastCenter.y),
  7112. x: -(center.x - lastCenter.x)
  7113. });
  7114. }
  7115. }
  7116. },
  7117. /**
  7118. * Calculates the touch center of multiple touches
  7119. * @param touches
  7120. * @return {Object}
  7121. */
  7122. getTouchCenter: function(touches) {
  7123. return this.getVectorAvg(touches);
  7124. },
  7125. /**
  7126. * Calculates the average of multiple vectors (x, y values)
  7127. */
  7128. getVectorAvg: function(vectors) {
  7129. return {
  7130. x: vectors.map(function(v) {
  7131. return v.x;
  7132. }).reduce(sum) / vectors.length,
  7133. y: vectors.map(function(v) {
  7134. return v.y;
  7135. }).reduce(sum) / vectors.length
  7136. };
  7137. },
  7138. /**
  7139. * Adds an offset
  7140. * @param offset the offset to add
  7141. * @return return true when the offset change was accepted
  7142. */
  7143. addOffset: function(offset) {
  7144. this.offset = {
  7145. x: this.offset.x + offset.x,
  7146. y: this.offset.y + offset.y
  7147. };
  7148. },
  7149. sanitize: function() {
  7150. if (this.zoomFactor < this.options.zoomOutFactor) {
  7151. this.zoomOutAnimation();
  7152. } else if (this.isInsaneOffset(this.offset)) {
  7153. this.sanitizeOffsetAnimation();
  7154. }
  7155. },
  7156. /**
  7157. * Checks if the offset is ok with the current zoom factor
  7158. * @param offset
  7159. * @return {Boolean}
  7160. */
  7161. isInsaneOffset: function(offset) {
  7162. var sanitizedOffset = this.sanitizeOffset(offset);
  7163. return sanitizedOffset.x !== offset.x ||
  7164. sanitizedOffset.y !== offset.y;
  7165. },
  7166. /**
  7167. * Creates an animation moving to a sane offset
  7168. */
  7169. sanitizeOffsetAnimation: function() {
  7170. var targetOffset = this.sanitizeOffset(this.offset),
  7171. startOffset = {
  7172. x: this.offset.x,
  7173. y: this.offset.y
  7174. },
  7175. updateProgress = (function(progress) {
  7176. this.offset.x = startOffset.x + progress * (targetOffset.x - startOffset.x);
  7177. this.offset.y = startOffset.y + progress * (targetOffset.y - startOffset.y);
  7178. this.update();
  7179. }).bind(this);
  7180. this.animate(
  7181. this.options.animationDuration,
  7182. this.options.animationInterval,
  7183. updateProgress,
  7184. this.swing
  7185. );
  7186. },
  7187. /**
  7188. * Zooms back to the original position,
  7189. * (no offset and zoom factor 1)
  7190. */
  7191. zoomOutAnimation: function() {
  7192. var startZoomFactor = this.zoomFactor,
  7193. zoomFactor = 1,
  7194. center = this.getCurrentZoomCenter(),
  7195. updateProgress = (function(progress) {
  7196. this.scaleTo(startZoomFactor + progress * (zoomFactor - startZoomFactor), center);
  7197. }).bind(this);
  7198. this.animate(
  7199. this.options.animationDuration,
  7200. this.options.animationInterval,
  7201. updateProgress,
  7202. this.swing
  7203. );
  7204. },
  7205. /**
  7206. * Updates the aspect ratio
  7207. */
  7208. updateAspectRatio: function() {
  7209. // this.setContainerY(this.getContainerX() / this.getAspectRatio());
  7210. // @modified
  7211. this.setContainerY()
  7212. },
  7213. /**
  7214. * Calculates the initial zoom factor (for the element to fit into the container)
  7215. * @return the initial zoom factor
  7216. */
  7217. getInitialZoomFactor: function() {
  7218. // use .offsetWidth instead of width()
  7219. // because jQuery-width() return the original width but Zepto-width() will calculate width with transform.
  7220. // the same as .height()
  7221. return this.container[0].offsetWidth / this.el[0].offsetWidth;
  7222. },
  7223. /**
  7224. * Calculates the aspect ratio of the element
  7225. * @return the aspect ratio
  7226. */
  7227. getAspectRatio: function() {
  7228. return this.el[0].offsetWidth / this.el[0].offsetHeight;
  7229. },
  7230. /**
  7231. * Calculates the virtual zoom center for the current offset and zoom factor
  7232. * (used for reverse zoom)
  7233. * @return {Object} the current zoom center
  7234. */
  7235. getCurrentZoomCenter: function() {
  7236. // uses following formula to calculate the zoom center x value
  7237. // offset_left / offset_right = zoomcenter_x / (container_x - zoomcenter_x)
  7238. var length = this.container[0].offsetWidth * this.zoomFactor,
  7239. offsetLeft = this.offset.x,
  7240. offsetRight = length - offsetLeft - this.container[0].offsetWidth,
  7241. widthOffsetRatio = offsetLeft / offsetRight,
  7242. centerX = widthOffsetRatio * this.container[0].offsetWidth / (widthOffsetRatio + 1),
  7243. // the same for the zoomcenter y
  7244. height = this.container[0].offsetHeight * this.zoomFactor,
  7245. offsetTop = this.offset.y,
  7246. offsetBottom = height - offsetTop - this.container[0].offsetHeight,
  7247. heightOffsetRatio = offsetTop / offsetBottom,
  7248. centerY = heightOffsetRatio * this.container[0].offsetHeight / (heightOffsetRatio + 1);
  7249. // prevents division by zero
  7250. if (offsetRight === 0) {
  7251. centerX = this.container[0].offsetWidth;
  7252. }
  7253. if (offsetBottom === 0) {
  7254. centerY = this.container[0].offsetHeight;
  7255. }
  7256. return {
  7257. x: centerX,
  7258. y: centerY
  7259. };
  7260. },
  7261. canDrag: function() {
  7262. return !isCloseTo(this.zoomFactor, 1);
  7263. },
  7264. /**
  7265. * Returns the touches of an event relative to the container offset
  7266. * @param event
  7267. * @return array touches
  7268. */
  7269. getTouches: function(event) {
  7270. var position = this.container.offset();
  7271. return Array.prototype.slice.call(event.touches).map(function(touch) {
  7272. return {
  7273. x: touch.pageX - position.left,
  7274. y: touch.pageY - position.top
  7275. };
  7276. });
  7277. },
  7278. /**
  7279. * Animation loop
  7280. * does not support simultaneous animations
  7281. * @param duration
  7282. * @param interval
  7283. * @param framefn
  7284. * @param timefn
  7285. * @param callback
  7286. */
  7287. animate: function(duration, interval, framefn, timefn, callback) {
  7288. var startTime = new Date().getTime(),
  7289. renderFrame = (function() {
  7290. if (!this.inAnimation) {
  7291. return;
  7292. }
  7293. var frameTime = new Date().getTime() - startTime,
  7294. progress = frameTime / duration;
  7295. if (frameTime >= duration) {
  7296. framefn(1);
  7297. if (callback) {
  7298. callback();
  7299. }
  7300. this.update();
  7301. this.stopAnimation();
  7302. this.update();
  7303. } else {
  7304. if (timefn) {
  7305. progress = timefn(progress);
  7306. }
  7307. framefn(progress);
  7308. this.update();
  7309. setTimeout(renderFrame, interval);
  7310. }
  7311. }).bind(this);
  7312. this.inAnimation = true;
  7313. renderFrame();
  7314. },
  7315. /**
  7316. * Stops the animation
  7317. */
  7318. stopAnimation: function() {
  7319. this.inAnimation = false;
  7320. },
  7321. /**
  7322. * Swing timing function for animations
  7323. * @param p
  7324. * @return {Number}
  7325. */
  7326. swing: function(p) {
  7327. return -Math.cos(p * Math.PI) / 2 + 0.5;
  7328. },
  7329. getContainerX: function() {
  7330. // return this.container[0].offsetWidth;
  7331. // @modified
  7332. return window.innerWidth
  7333. },
  7334. getContainerY: function() {
  7335. // return this.container[0].offsetHeight;
  7336. // @modified
  7337. return window.innerHeight
  7338. },
  7339. setContainerY: function(y) {
  7340. // return this.container.height(y);
  7341. // @modified
  7342. var t = window.innerHeight;
  7343. return this.el.css({height: t}), this.container.height(t);
  7344. },
  7345. /**
  7346. * Creates the expected html structure
  7347. */
  7348. setupMarkup: function() {
  7349. this.container = $('<div class="pinch-zoom-container"></div>');
  7350. this.el.before(this.container);
  7351. this.container.append(this.el);
  7352. this.container.css({
  7353. 'overflow': 'hidden',
  7354. 'position': 'relative'
  7355. });
  7356. // Zepto doesn't recognize `webkitTransform..` style
  7357. this.el.css({
  7358. '-webkit-transform-origin': '0% 0%',
  7359. '-moz-transform-origin': '0% 0%',
  7360. '-ms-transform-origin': '0% 0%',
  7361. '-o-transform-origin': '0% 0%',
  7362. 'transform-origin': '0% 0%',
  7363. 'position': 'absolute'
  7364. });
  7365. },
  7366. end: function() {
  7367. this.hasInteraction = false;
  7368. this.sanitize();
  7369. this.update();
  7370. },
  7371. /**
  7372. * Binds all required event listeners
  7373. */
  7374. bindEvents: function() {
  7375. detectGestures(this.container.get(0), this);
  7376. // Zepto and jQuery both know about `on`
  7377. $(window).on('resize', this.update.bind(this));
  7378. $(this.el).find('img').on('load', this.update.bind(this));
  7379. },
  7380. /**
  7381. * Updates the css values according to the current zoom factor and offset
  7382. */
  7383. update: function() {
  7384. if (this.updatePlaned) {
  7385. return;
  7386. }
  7387. this.updatePlaned = true;
  7388. setTimeout((function() {
  7389. this.updatePlaned = false;
  7390. this.updateAspectRatio();
  7391. var zoomFactor = this.getInitialZoomFactor() * this.zoomFactor,
  7392. offsetX = -this.offset.x / zoomFactor,
  7393. offsetY = -this.offset.y / zoomFactor,
  7394. transform3d = 'scale3d(' + zoomFactor + ', ' + zoomFactor + ',1) ' +
  7395. 'translate3d(' + offsetX + 'px,' + offsetY + 'px,0px)',
  7396. transform2d = 'scale(' + zoomFactor + ', ' + zoomFactor + ') ' +
  7397. 'translate(' + offsetX + 'px,' + offsetY + 'px)',
  7398. removeClone = (function() {
  7399. if (this.clone) {
  7400. this.clone.remove();
  7401. delete this.clone;
  7402. }
  7403. }).bind(this);
  7404. // Scale 3d and translate3d are faster (at least on ios)
  7405. // but they also reduce the quality.
  7406. // PinchZoom uses the 3d transformations during interactions
  7407. // after interactions it falls back to 2d transformations
  7408. if (!this.options.use2d || this.hasInteraction || this.inAnimation) {
  7409. this.is3d = true;
  7410. removeClone();
  7411. this.el.css({
  7412. '-webkit-transform': transform3d,
  7413. '-o-transform': transform2d,
  7414. '-ms-transform': transform2d,
  7415. '-moz-transform': transform2d,
  7416. 'transform': transform3d
  7417. });
  7418. } else {
  7419. // When changing from 3d to 2d transform webkit has some glitches.
  7420. // To avoid this, a copy of the 3d transformed element is displayed in the
  7421. // foreground while the element is converted from 3d to 2d transform
  7422. if (this.is3d) {
  7423. this.clone = this.el.clone();
  7424. this.clone.css('pointer-events', 'none');
  7425. this.clone.appendTo(this.container);
  7426. setTimeout(removeClone, 200);
  7427. }
  7428. this.el.css({
  7429. '-webkit-transform': transform2d,
  7430. '-o-transform': transform2d,
  7431. '-ms-transform': transform2d,
  7432. '-moz-transform': transform2d,
  7433. 'transform': transform2d
  7434. });
  7435. this.is3d = false;
  7436. }
  7437. }).bind(this), 0);
  7438. },
  7439. /**
  7440. * Enables event handling for gestures
  7441. */
  7442. enable: function() {
  7443. this.enabled = true;
  7444. },
  7445. /**
  7446. * Disables event handling for gestures
  7447. */
  7448. disable: function() {
  7449. this.enabled = false;
  7450. }
  7451. };
  7452. var detectGestures = function(el, target) {
  7453. var interaction = null,
  7454. fingers = 0,
  7455. lastTouchStart = null,
  7456. startTouches = null,
  7457. setInteraction = function(newInteraction, event) {
  7458. if (interaction !== newInteraction) {
  7459. if (interaction && !newInteraction) {
  7460. switch (interaction) {
  7461. case "zoom":
  7462. target.handleZoomEnd(event);
  7463. break;
  7464. case 'drag':
  7465. target.handleDragEnd(event);
  7466. break;
  7467. }
  7468. }
  7469. switch (newInteraction) {
  7470. case 'zoom':
  7471. target.handleZoomStart(event);
  7472. break;
  7473. case 'drag':
  7474. target.handleDragStart(event);
  7475. break;
  7476. }
  7477. }
  7478. interaction = newInteraction;
  7479. },
  7480. updateInteraction = function(event) {
  7481. if (fingers === 2) {
  7482. setInteraction('zoom');
  7483. } else if (fingers === 1 && target.canDrag()) {
  7484. setInteraction('drag', event);
  7485. } else {
  7486. setInteraction(null, event);
  7487. }
  7488. },
  7489. targetTouches = function(touches) {
  7490. return Array.prototype.slice.call(touches).map(function(touch) {
  7491. return {
  7492. x: touch.pageX,
  7493. y: touch.pageY
  7494. };
  7495. });
  7496. },
  7497. getDistance = function(a, b) {
  7498. var x, y;
  7499. x = a.x - b.x;
  7500. y = a.y - b.y;
  7501. return Math.sqrt(x * x + y * y);
  7502. },
  7503. calculateScale = function(startTouches, endTouches) {
  7504. var startDistance = getDistance(startTouches[0], startTouches[1]),
  7505. endDistance = getDistance(endTouches[0], endTouches[1]);
  7506. return endDistance / startDistance;
  7507. },
  7508. cancelEvent = function(event) {
  7509. event.stopPropagation();
  7510. event.preventDefault();
  7511. },
  7512. detectDoubleTap = function(event) {
  7513. var time = (new Date()).getTime();
  7514. if (fingers > 1) {
  7515. lastTouchStart = null;
  7516. }
  7517. if (time - lastTouchStart < 300) {
  7518. cancelEvent(event);
  7519. target.handleDoubleTap(event);
  7520. switch (interaction) {
  7521. case "zoom":
  7522. target.handleZoomEnd(event);
  7523. break;
  7524. case 'drag':
  7525. target.handleDragEnd(event);
  7526. break;
  7527. }
  7528. }
  7529. if (fingers === 1) {
  7530. lastTouchStart = time;
  7531. }
  7532. },
  7533. firstMove = true;
  7534. el.addEventListener('touchstart', function(event) {
  7535. if (target.enabled) {
  7536. firstMove = true;
  7537. fingers = event.touches.length;
  7538. detectDoubleTap(event);
  7539. }
  7540. });
  7541. el.addEventListener('touchmove', function(event) {
  7542. if (target.enabled) {
  7543. if (firstMove) {
  7544. updateInteraction(event);
  7545. if (interaction) {
  7546. cancelEvent(event);
  7547. }
  7548. startTouches = targetTouches(event.touches);
  7549. } else {
  7550. switch (interaction) {
  7551. case 'zoom':
  7552. target.handleZoom(event, calculateScale(startTouches, targetTouches(event.touches)));
  7553. break;
  7554. case 'drag':
  7555. target.handleDrag(event);
  7556. break;
  7557. }
  7558. if (interaction) {
  7559. cancelEvent(event);
  7560. target.update();
  7561. }
  7562. }
  7563. firstMove = false;
  7564. }
  7565. });
  7566. el.addEventListener('touchend', function(event) {
  7567. if (target.enabled) {
  7568. fingers = event.touches.length;
  7569. updateInteraction(event);
  7570. }
  7571. });
  7572. };
  7573. return PinchZoom;
  7574. };
  7575. module.exports = UI.pichzoom = definePinchZoom($);
  7576. /***/ },
  7577. /* 18 */
  7578. /***/ function(module, exports, __webpack_require__) {
  7579. 'use strict';
  7580. var $ = __webpack_require__(1);
  7581. var UI = __webpack_require__(2);
  7582. var $w = $(window);
  7583. /**
  7584. * @reference https://github.com/nolimits4web/Framework7/blob/master/src/js/modals.js
  7585. * @license https://github.com/nolimits4web/Framework7/blob/master/LICENSE
  7586. */
  7587. var Popover = function(element, options) {
  7588. this.options = $.extend({}, Popover.DEFAULTS, options);
  7589. this.$element = $(element);
  7590. this.active = null;
  7591. this.$popover = (this.options.target && $(this.options.target)) || null;
  7592. this.init();
  7593. this._bindEvents();
  7594. };
  7595. Popover.DEFAULTS = {
  7596. theme: null,
  7597. trigger: 'click',
  7598. content: '',
  7599. open: false,
  7600. target: null,
  7601. tpl: '<div class="am-popover">' +
  7602. '<div class="am-popover-inner"></div>' +
  7603. '<div class="am-popover-caret"></div></div>'
  7604. };
  7605. Popover.prototype.init = function() {
  7606. var _this = this;
  7607. var $element = this.$element;
  7608. var $popover;
  7609. if (!this.options.target) {
  7610. this.$popover = this.getPopover();
  7611. this.setContent();
  7612. }
  7613. $popover = this.$popover;
  7614. $popover.appendTo($('body'));
  7615. this.sizePopover();
  7616. function sizePopover() {
  7617. _this.sizePopover();
  7618. }
  7619. // TODO: ����ҳ�����ݱ仯�����µ���λ��
  7620. $element.on('open.popover.amui', function() {
  7621. $(window).on('resize.popover.amui', UI.utils.debounce(sizePopover, 50));
  7622. });
  7623. $element.on('close.popover.amui', function() {
  7624. $(window).off('resize.popover.amui', sizePopover);
  7625. });
  7626. this.options.open && this.open();
  7627. };
  7628. Popover.prototype.sizePopover = function sizePopover() {
  7629. var $element = this.$element;
  7630. var $popover = this.$popover;
  7631. if (!$popover || !$popover.length) {
  7632. return;
  7633. }
  7634. var popWidth = $popover.outerWidth();
  7635. var popHeight = $popover.outerHeight();
  7636. var $popCaret = $popover.find('.am-popover-caret');
  7637. var popCaretSize = ($popCaret.outerWidth() / 2) || 8;
  7638. // ȡ���� $popCaret.outerHeight() ��ֵ������ֱ�Ӽ� 8
  7639. var popTotalHeight = popHeight + 8; // $popCaret.outerHeight();
  7640. var triggerWidth = $element.outerWidth();
  7641. var triggerHeight = $element.outerHeight();
  7642. var triggerOffset = $element.offset();
  7643. var triggerRect = $element[0].getBoundingClientRect();
  7644. var winHeight = $w.height();
  7645. var winWidth = $w.width();
  7646. var popTop = 0;
  7647. var popLeft = 0;
  7648. var diff = 0;
  7649. var spacing = 2;
  7650. var popPosition = 'top';
  7651. $popover.css({left: '', top: ''}).removeClass('am-popover-left ' +
  7652. 'am-popover-right am-popover-top am-popover-bottom');
  7653. // $popCaret.css({left: '', top: ''});
  7654. if (popTotalHeight - spacing < triggerRect.top + spacing) {
  7655. // Popover on the top of trigger
  7656. popTop = triggerOffset.top - popTotalHeight - spacing;
  7657. } else if (popTotalHeight <
  7658. winHeight - triggerRect.top - triggerRect.height) {
  7659. // On bottom
  7660. popPosition = 'bottom';
  7661. popTop = triggerOffset.top + triggerHeight + popCaretSize + spacing;
  7662. } else { // On middle
  7663. popPosition = 'middle';
  7664. popTop = triggerHeight / 2 + triggerOffset.top - popHeight / 2;
  7665. }
  7666. // Horizontal Position
  7667. if (popPosition === 'top' || popPosition === 'bottom') {
  7668. popLeft = triggerWidth / 2 + triggerOffset.left - popWidth / 2;
  7669. diff = popLeft;
  7670. if (popLeft < 5) {
  7671. popLeft = 5;
  7672. }
  7673. if (popLeft + popWidth > winWidth) {
  7674. popLeft = (winWidth - popWidth - 20);
  7675. // console.log('left %d, win %d, popw %d', popLeft, winWidth, popWidth);
  7676. }
  7677. if (popPosition === 'top') {
  7678. // This is the Popover position, NOT caret position
  7679. // Popover on the Top of trigger, caret on the bottom of Popover
  7680. $popover.addClass('am-popover-top');
  7681. }
  7682. if (popPosition === 'bottom') {
  7683. $popover.addClass('am-popover-bottom');
  7684. }
  7685. diff = diff - popLeft;
  7686. // $popCaret.css({left: (popWidth / 2 - popCaretSize + diff) + 'px'});
  7687. } else if (popPosition === 'middle') {
  7688. popLeft = triggerOffset.left - popWidth - popCaretSize;
  7689. $popover.addClass('am-popover-left');
  7690. if (popLeft < 5) {
  7691. popLeft = triggerOffset.left + triggerWidth + popCaretSize;
  7692. $popover.removeClass('am-popover-left').addClass('am-popover-right');
  7693. }
  7694. if (popLeft + popWidth > winWidth) {
  7695. popLeft = winWidth - popWidth - 5;
  7696. $popover.removeClass('am-popover-left').addClass('am-popover-right');
  7697. }
  7698. // $popCaret.css({top: (popHeight / 2 - popCaretSize / 2) + 'px'});
  7699. }
  7700. // Apply position style
  7701. $popover.css({top: popTop + 'px', left: popLeft + 'px'});
  7702. };
  7703. Popover.prototype.toggle = function() {
  7704. return this[this.active ? 'close' : 'open']();
  7705. };
  7706. Popover.prototype.open = function() {
  7707. var $popover = this.$popover;
  7708. this.$element.trigger('open.popover.amui');
  7709. this.sizePopover();
  7710. $popover.show().addClass('am-active');
  7711. this.active = true;
  7712. };
  7713. Popover.prototype.close = function() {
  7714. var $popover = this.$popover;
  7715. this.$element.trigger('close.popover.amui');
  7716. $popover
  7717. .removeClass('am-active')
  7718. .trigger('closed.popover.amui')
  7719. .hide();
  7720. this.active = false;
  7721. };
  7722. Popover.prototype.getPopover = function() {
  7723. var uid = UI.utils.generateGUID('am-popover');
  7724. var theme = [];
  7725. if (this.options.theme) {
  7726. $.each(this.options.theme.split(' '), function(i, item) {
  7727. theme.push('am-popover-' + $.trim(item));
  7728. });
  7729. }
  7730. return $(this.options.tpl).attr('id', uid).addClass(theme.join(' '));
  7731. };
  7732. Popover.prototype.setContent = function(content) {
  7733. content = content || this.options.content;
  7734. this.$popover && this.$popover.find('.am-popover-inner')
  7735. .empty().html(content);
  7736. };
  7737. Popover.prototype._bindEvents = function() {
  7738. var eventNS = 'popover.amui';
  7739. var triggers = this.options.trigger.split(' ');
  7740. for (var i = triggers.length; i--;) {
  7741. var trigger = triggers[i];
  7742. if (trigger === 'click') {
  7743. this.$element.on('click.' + eventNS, $.proxy(this.toggle, this));
  7744. } else { // hover or focus
  7745. var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
  7746. var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
  7747. this.$element.on(eventIn + '.' + eventNS, $.proxy(this.open, this));
  7748. this.$element.on(eventOut + '.' + eventNS, $.proxy(this.close, this));
  7749. }
  7750. }
  7751. };
  7752. Popover.prototype.destroy = function() {
  7753. this.$element.off('.popover.amui').removeData('amui.popover');
  7754. this.$popover.remove();
  7755. };
  7756. UI.plugin('popover', Popover);
  7757. // Init code
  7758. UI.ready(function(context) {
  7759. $('[data-am-popover]', context).popover();
  7760. });
  7761. module.exports = Popover;
  7762. // TODO: �����û�����λ��
  7763. /***/ },
  7764. /* 19 */
  7765. /***/ function(module, exports, __webpack_require__) {
  7766. 'use strict';
  7767. var UI = __webpack_require__(2);
  7768. var Progress = (function() {
  7769. /**
  7770. * NProgress (c) 2013, Rico Sta. Cruz
  7771. * @via http://ricostacruz.com/nprogress
  7772. */
  7773. var NProgress = {};
  7774. NProgress.version = '0.2.0';
  7775. var Settings = NProgress.settings = {
  7776. minimum: 0.08,
  7777. easing: 'ease',
  7778. positionUsing: '',
  7779. speed: 200,
  7780. trickle: true,
  7781. trickleRate: 0.02,
  7782. trickleSpeed: 800,
  7783. showSpinner: true,
  7784. parent: 'body',
  7785. barSelector: '[role="nprogress-bar"]',
  7786. spinnerSelector: '[role="nprogress-spinner"]',
  7787. template: '<div class="nprogress-bar" role="nprogress-bar">' +
  7788. '<div class="nprogress-peg"></div></div>' +
  7789. '<div class="nprogress-spinner" role="nprogress-spinner">' +
  7790. '<div class="nprogress-spinner-icon"></div></div>'
  7791. };
  7792. /**
  7793. * Updates configuration.
  7794. *
  7795. * NProgress.configure({
  7796. * minimum: 0.1
  7797. * });
  7798. */
  7799. NProgress.configure = function(options) {
  7800. var key, value;
  7801. for (key in options) {
  7802. value = options[key];
  7803. if (value !== undefined && options.hasOwnProperty(key)) Settings[key] = value;
  7804. }
  7805. return this;
  7806. };
  7807. /**
  7808. * Last number.
  7809. */
  7810. NProgress.status = null;
  7811. /**
  7812. * Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
  7813. *
  7814. * NProgress.set(0.4);
  7815. * NProgress.set(1.0);
  7816. */
  7817. NProgress.set = function(n) {
  7818. var started = NProgress.isStarted();
  7819. n = clamp(n, Settings.minimum, 1);
  7820. NProgress.status = (n === 1 ? null : n);
  7821. var progress = NProgress.render(!started),
  7822. bar = progress.querySelector(Settings.barSelector),
  7823. speed = Settings.speed,
  7824. ease = Settings.easing;
  7825. progress.offsetWidth; /* Repaint */
  7826. queue(function(next) {
  7827. // Set positionUsing if it hasn't already been set
  7828. if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
  7829. // Add transition
  7830. css(bar, barPositionCSS(n, speed, ease));
  7831. if (n === 1) {
  7832. // Fade out
  7833. css(progress, {
  7834. transition: 'none',
  7835. opacity: 1
  7836. });
  7837. progress.offsetWidth; /* Repaint */
  7838. setTimeout(function() {
  7839. css(progress, {
  7840. transition: 'all ' + speed + 'ms linear',
  7841. opacity: 0
  7842. });
  7843. setTimeout(function() {
  7844. NProgress.remove();
  7845. next();
  7846. }, speed);
  7847. }, speed);
  7848. } else {
  7849. setTimeout(next, speed);
  7850. }
  7851. });
  7852. return this;
  7853. };
  7854. NProgress.isStarted = function() {
  7855. return typeof NProgress.status === 'number';
  7856. };
  7857. /**
  7858. * Shows the progress bar.
  7859. * This is the same as setting the status to 0%, except that it doesn't go backwards.
  7860. *
  7861. * NProgress.start();
  7862. *
  7863. */
  7864. NProgress.start = function() {
  7865. if (!NProgress.status) NProgress.set(0);
  7866. var work = function() {
  7867. setTimeout(function() {
  7868. if (!NProgress.status) return;
  7869. NProgress.trickle();
  7870. work();
  7871. }, Settings.trickleSpeed);
  7872. };
  7873. if (Settings.trickle) work();
  7874. return this;
  7875. };
  7876. /**
  7877. * Hides the progress bar.
  7878. * This is the *sort of* the same as setting the status to 100%, with the
  7879. * difference being `done()` makes some placebo effect of some realistic motion.
  7880. *
  7881. * NProgress.done();
  7882. *
  7883. * If `true` is passed, it will show the progress bar even if its hidden.
  7884. *
  7885. * NProgress.done(true);
  7886. */
  7887. NProgress.done = function(force) {
  7888. if (!force && !NProgress.status) return this;
  7889. return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
  7890. };
  7891. /**
  7892. * Increments by a random amount.
  7893. */
  7894. NProgress.inc = function(amount) {
  7895. var n = NProgress.status;
  7896. if (!n) {
  7897. return NProgress.start();
  7898. } else {
  7899. if (typeof amount !== 'number') {
  7900. amount = (1 - n) * clamp(Math.random() * n, 0.1, 0.95);
  7901. }
  7902. n = clamp(n + amount, 0, 0.994);
  7903. return NProgress.set(n);
  7904. }
  7905. };
  7906. NProgress.trickle = function() {
  7907. return NProgress.inc(Math.random() * Settings.trickleRate);
  7908. };
  7909. /**
  7910. * Waits for all supplied jQuery promises and
  7911. * increases the progress as the promises resolve.
  7912. *
  7913. * @param $promise jQUery Promise
  7914. */
  7915. (function() {
  7916. var initial = 0, current = 0;
  7917. NProgress.promise = function($promise) {
  7918. if (!$promise || $promise.state() === "resolved") {
  7919. return this;
  7920. }
  7921. if (current === 0) {
  7922. NProgress.start();
  7923. }
  7924. initial++;
  7925. current++;
  7926. $promise.always(function() {
  7927. current--;
  7928. if (current === 0) {
  7929. initial = 0;
  7930. NProgress.done();
  7931. } else {
  7932. NProgress.set((initial - current) / initial);
  7933. }
  7934. });
  7935. return this;
  7936. };
  7937. })();
  7938. /**
  7939. * (Internal) renders the progress bar markup based on the `template`
  7940. * setting.
  7941. */
  7942. NProgress.render = function(fromStart) {
  7943. if (NProgress.isRendered()) return document.getElementById('nprogress');
  7944. addClass(document.documentElement, 'nprogress-busy');
  7945. var progress = document.createElement('div');
  7946. progress.id = 'nprogress';
  7947. progress.innerHTML = Settings.template;
  7948. var bar = progress.querySelector(Settings.barSelector),
  7949. perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
  7950. parent = document.querySelector(Settings.parent),
  7951. spinner;
  7952. css(bar, {
  7953. transition: 'all 0 linear',
  7954. transform: 'translate3d(' + perc + '%,0,0)'
  7955. });
  7956. if (!Settings.showSpinner) {
  7957. spinner = progress.querySelector(Settings.spinnerSelector);
  7958. spinner && removeElement(spinner);
  7959. }
  7960. if (parent != document.body) {
  7961. addClass(parent, 'nprogress-custom-parent');
  7962. }
  7963. parent.appendChild(progress);
  7964. return progress;
  7965. };
  7966. /**
  7967. * Removes the element. Opposite of render().
  7968. */
  7969. NProgress.remove = function() {
  7970. removeClass(document.documentElement, 'nprogress-busy');
  7971. removeClass(document.querySelector(Settings.parent), 'nprogress-custom-parent');
  7972. var progress = document.getElementById('nprogress');
  7973. progress && removeElement(progress);
  7974. };
  7975. /**
  7976. * Checks if the progress bar is rendered.
  7977. */
  7978. NProgress.isRendered = function() {
  7979. return !!document.getElementById('nprogress');
  7980. };
  7981. /**
  7982. * Determine which positioning CSS rule to use.
  7983. */
  7984. NProgress.getPositioningCSS = function() {
  7985. // Sniff on document.body.style
  7986. var bodyStyle = document.body.style;
  7987. // Sniff prefixes
  7988. var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' :
  7989. ('MozTransform' in bodyStyle) ? 'Moz' :
  7990. ('msTransform' in bodyStyle) ? 'ms' :
  7991. ('OTransform' in bodyStyle) ? 'O' : '';
  7992. if (vendorPrefix + 'Perspective' in bodyStyle) {
  7993. // Modern browsers with 3D support, e.g. Webkit, IE10
  7994. return 'translate3d';
  7995. } else if (vendorPrefix + 'Transform' in bodyStyle) {
  7996. // Browsers without 3D support, e.g. IE9
  7997. return 'translate';
  7998. } else {
  7999. // Browsers without translate() support, e.g. IE7-8
  8000. return 'margin';
  8001. }
  8002. };
  8003. /**
  8004. * Helpers
  8005. */
  8006. function clamp(n, min, max) {
  8007. if (n < min) return min;
  8008. if (n > max) return max;
  8009. return n;
  8010. }
  8011. /**
  8012. * (Internal) converts a percentage (`0..1`) to a bar translateX
  8013. * percentage (`-100%..0%`).
  8014. */
  8015. function toBarPerc(n) {
  8016. return (-1 + n) * 100;
  8017. }
  8018. /**
  8019. * (Internal) returns the correct CSS for changing the bar's
  8020. * position given an n percentage, and speed and ease from Settings
  8021. */
  8022. function barPositionCSS(n, speed, ease) {
  8023. var barCSS;
  8024. if (Settings.positionUsing === 'translate3d') {
  8025. barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
  8026. } else if (Settings.positionUsing === 'translate') {
  8027. barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
  8028. } else {
  8029. barCSS = { 'margin-left': toBarPerc(n)+'%' };
  8030. }
  8031. barCSS.transition = 'all '+speed+'ms '+ease;
  8032. return barCSS;
  8033. }
  8034. /**
  8035. * (Internal) Queues a function to be executed.
  8036. */
  8037. var queue = (function() {
  8038. var pending = [];
  8039. function next() {
  8040. var fn = pending.shift();
  8041. if (fn) {
  8042. fn(next);
  8043. }
  8044. }
  8045. return function(fn) {
  8046. pending.push(fn);
  8047. if (pending.length == 1) next();
  8048. };
  8049. })();
  8050. /**
  8051. * (Internal) Applies css properties to an element, similar to the jQuery
  8052. * css method.
  8053. *
  8054. * While this helper does assist with vendor prefixed property names, it
  8055. * does not perform any manipulation of values prior to setting styles.
  8056. */
  8057. var css = (function() {
  8058. var cssPrefixes = [ 'Webkit', 'O', 'Moz', 'ms' ],
  8059. cssProps = {};
  8060. function camelCase(string) {
  8061. return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function(match, letter) {
  8062. return letter.toUpperCase();
  8063. });
  8064. }
  8065. function getVendorProp(name) {
  8066. var style = document.body.style;
  8067. if (name in style) return name;
  8068. var i = cssPrefixes.length,
  8069. capName = name.charAt(0).toUpperCase() + name.slice(1),
  8070. vendorName;
  8071. while (i--) {
  8072. vendorName = cssPrefixes[i] + capName;
  8073. if (vendorName in style) return vendorName;
  8074. }
  8075. return name;
  8076. }
  8077. function getStyleProp(name) {
  8078. name = camelCase(name);
  8079. return cssProps[name] || (cssProps[name] = getVendorProp(name));
  8080. }
  8081. function applyCss(element, prop, value) {
  8082. prop = getStyleProp(prop);
  8083. element.style[prop] = value;
  8084. }
  8085. return function(element, properties) {
  8086. var args = arguments,
  8087. prop,
  8088. value;
  8089. if (args.length == 2) {
  8090. for (prop in properties) {
  8091. value = properties[prop];
  8092. if (value !== undefined && properties.hasOwnProperty(prop)) applyCss(element, prop, value);
  8093. }
  8094. } else {
  8095. applyCss(element, args[1], args[2]);
  8096. }
  8097. }
  8098. })();
  8099. /**
  8100. * (Internal) Determines if an element or space separated list of class names contains a class name.
  8101. */
  8102. function hasClass(element, name) {
  8103. var list = typeof element == 'string' ? element : classList(element);
  8104. return list.indexOf(' ' + name + ' ') >= 0;
  8105. }
  8106. /**
  8107. * (Internal) Adds a class to an element.
  8108. */
  8109. function addClass(element, name) {
  8110. var oldList = classList(element),
  8111. newList = oldList + name;
  8112. if (hasClass(oldList, name)) return;
  8113. // Trim the opening space.
  8114. element.className = newList.substring(1);
  8115. }
  8116. /**
  8117. * (Internal) Removes a class from an element.
  8118. */
  8119. function removeClass(element, name) {
  8120. var oldList = classList(element),
  8121. newList;
  8122. if (!hasClass(element, name)) return;
  8123. // Replace the class name.
  8124. newList = oldList.replace(' ' + name + ' ', ' ');
  8125. // Trim the opening and closing spaces.
  8126. element.className = newList.substring(1, newList.length - 1);
  8127. }
  8128. /**
  8129. * (Internal) Gets a space separated list of the class names on the element.
  8130. * The list is wrapped with a single space on each end to facilitate finding
  8131. * matches within the list.
  8132. */
  8133. function classList(element) {
  8134. return (' ' + (element.className || '') + ' ').replace(/\s+/gi, ' ');
  8135. }
  8136. /**
  8137. * (Internal) Removes an element from the DOM.
  8138. */
  8139. function removeElement(element) {
  8140. element && element.parentNode && element.parentNode.removeChild(element);
  8141. }
  8142. return NProgress;
  8143. })();
  8144. module.exports = UI.progress = Progress;
  8145. /***/ },
  8146. /* 20 */
  8147. /***/ function(module, exports, __webpack_require__) {
  8148. 'use strict';
  8149. var $ = __webpack_require__(1);
  8150. var UI = __webpack_require__(2);
  8151. var PinchZoom = __webpack_require__(17);
  8152. var Hammer = __webpack_require__(3);
  8153. var animation = UI.support.animation;
  8154. var transition = UI.support.transition;
  8155. /**
  8156. * PureView
  8157. * @desc Image browser for Mobile
  8158. * @param element
  8159. * @param options
  8160. * @constructor
  8161. */
  8162. var PureView = function(element, options) {
  8163. this.$element = $(element);
  8164. this.$body = $(document.body);
  8165. this.options = $.extend({}, PureView.DEFAULTS, options);
  8166. this.$pureview = $(this.options.tpl).attr('id',
  8167. UI.utils.generateGUID('am-pureview'));
  8168. this.$slides = null;
  8169. this.transitioning = null;
  8170. this.scrollbarWidth = 0;
  8171. this.init();
  8172. };
  8173. PureView.DEFAULTS = {
  8174. tpl: '<div class="am-pureview am-pureview-bar-active">' +
  8175. '<ul class="am-pureview-slider"></ul>' +
  8176. '<ol class="am-pureview-nav"></ol>' +
  8177. '<div class="am-pureview-bar am-active">' +
  8178. '<span class="am-pureview-title"></span>' +
  8179. '<div class="am-pureview-counter"><span class="am-pureview-current"></span> / ' +
  8180. '<span class="am-pureview-total"></span></div></div>' +
  8181. '<div class="am-pureview-actions">' +
  8182. '<a href="javascript: void(0)" class="am-icon-chevron-left" ' +
  8183. 'data-am-close="pureview"></a></div>' +
  8184. '</div>',
  8185. className: {
  8186. prevSlide: 'am-pureview-slide-prev',
  8187. nextSlide: 'am-pureview-slide-next',
  8188. onlyOne: 'am-pureview-only',
  8189. active: 'am-active',
  8190. barActive: 'am-pureview-bar-active',
  8191. activeBody: 'am-pureview-active'
  8192. },
  8193. selector: {
  8194. slider: '.am-pureview-slider',
  8195. close: '[data-am-close="pureview"]',
  8196. total: '.am-pureview-total',
  8197. current: '.am-pureview-current',
  8198. title: '.am-pureview-title',
  8199. actions: '.am-pureview-actions',
  8200. bar: '.am-pureview-bar',
  8201. pinchZoom: '.am-pinch-zoom',
  8202. nav: '.am-pureview-nav'
  8203. },
  8204. shareBtn: false,
  8205. // press to toggle Toolbar
  8206. toggleToolbar: true,
  8207. // �Ӻδ���ȡͼƬ��img ����ʹ�� data-rel ָ����ͼ
  8208. target: 'img',
  8209. // ΢�� Webview �е���΢�ŵ�ͼƬ�����
  8210. // ʵ��ͼƬ���桢������ѡ��ղ�ͼƬ�ȹ���
  8211. weChatImagePreview: true
  8212. };
  8213. PureView.prototype.init = function() {
  8214. var _this = this;
  8215. var options = this.options;
  8216. var $element = this.$element;
  8217. var $pureview = this.$pureview;
  8218. this.refreshSlides();
  8219. $('body').append($pureview);
  8220. this.$title = $pureview.find(options.selector.title);
  8221. this.$current = $pureview.find(options.selector.current);
  8222. this.$bar = $pureview.find(options.selector.bar);
  8223. this.$actions = $pureview.find(options.selector.actions);
  8224. if (options.shareBtn) {
  8225. this.$actions.append('<a href="javascript: void(0)" ' +
  8226. 'class="am-icon-share-square-o" data-am-toggle="share"></a>');
  8227. }
  8228. this.$element.on('click.pureview.amui', options.target, function(e) {
  8229. e.preventDefault();
  8230. var clicked = _this.$images.index(this);
  8231. // Invoke WeChat ImagePreview in WeChat
  8232. // TODO: detect WeChat before init
  8233. if (options.weChatImagePreview && window.WeixinJSBridge) {
  8234. window.WeixinJSBridge.invoke('imagePreview', {
  8235. current: _this.imgUrls[clicked],
  8236. urls: _this.imgUrls
  8237. });
  8238. } else {
  8239. _this.open(clicked);
  8240. }
  8241. });
  8242. $pureview.find('.am-pureview-direction').
  8243. on('click.direction.pureview.amui', 'li', function(e) {
  8244. e.preventDefault();
  8245. if ($(this).is('.am-pureview-prev')) {
  8246. _this.prevSlide();
  8247. } else {
  8248. _this.nextSlide();
  8249. }
  8250. });
  8251. // Nav Contorl
  8252. $pureview.find(options.selector.nav).on('click.nav.pureview.amui', 'li',
  8253. function() {
  8254. var index = _this.$navItems.index($(this));
  8255. _this.activate(_this.$slides.eq(index));
  8256. });
  8257. // Close Icon
  8258. $pureview.find(options.selector.close).
  8259. on('click.close.pureview.amui', function(e) {
  8260. e.preventDefault();
  8261. _this.close();
  8262. });
  8263. this.$slider.hammer().on('swipeleft.pureview.amui', function(e) {
  8264. e.preventDefault();
  8265. _this.nextSlide();
  8266. }).on('swiperight.pureview.amui', function(e) {
  8267. e.preventDefault();
  8268. _this.prevSlide();
  8269. }).on('press.pureview.amui', function(e) {
  8270. e.preventDefault();
  8271. options.toggleToolbar && _this.toggleToolBar();
  8272. });
  8273. this.$slider.data('hammer').get('swipe').set({
  8274. direction: Hammer.DIRECTION_HORIZONTAL,
  8275. velocity: 0.35
  8276. });
  8277. // Observe DOM
  8278. $element.DOMObserve({
  8279. childList: true,
  8280. subtree: true
  8281. }, function(mutations, observer) {
  8282. // _this.refreshSlides();
  8283. // console.log('mutations[0].type);
  8284. });
  8285. // NOTE:
  8286. // trigger this event manually if MutationObserver not supported
  8287. // when new images appended, or call refreshSlides()
  8288. // if (!UI.support.mutationobserver) $element.trigger('changed.dom.amui')
  8289. $element.on('changed.dom.amui', function(e) {
  8290. e.stopPropagation();
  8291. _this.refreshSlides();
  8292. });
  8293. $(document).on('keydown.pureview.amui', $.proxy(function(e) {
  8294. var keyCode = e.keyCode;
  8295. if (keyCode == 37) {
  8296. this.prevSlide();
  8297. } else if (keyCode == 39) {
  8298. this.nextSlide();
  8299. } else if (keyCode == 27) {
  8300. this.close();
  8301. }
  8302. }, this));
  8303. };
  8304. PureView.prototype.refreshSlides = function() {
  8305. // update images collections
  8306. this.$images = this.$element.find(this.options.target);
  8307. var _this = this;
  8308. var options = this.options;
  8309. var $pureview = this.$pureview;
  8310. var $slides = $([]);
  8311. var $navItems = $([]);
  8312. var $images = this.$images;
  8313. var total = $images.length;
  8314. this.$slider = $pureview.find(options.selector.slider);
  8315. this.$nav = $pureview.find(options.selector.nav);
  8316. var viewedFlag = 'data-am-pureviewed';
  8317. // for WeChat Image Preview
  8318. this.imgUrls = this.imgUrls || [];
  8319. if (!total) {
  8320. return;
  8321. }
  8322. if (total === 1) {
  8323. $pureview.addClass(options.className.onlyOne);
  8324. }
  8325. $images.not('[' + viewedFlag + ']').each(function(i, item) {
  8326. var src;
  8327. var title;
  8328. // get image URI from link's href attribute
  8329. if (item.nodeName === 'A') {
  8330. src = item.href; // to absolute path
  8331. title = item.title || '';
  8332. } else {
  8333. // NOTE: `data-rel` should be a full URL, otherwise,
  8334. // WeChat images preview will not work
  8335. src = $(item).data('rel') || item.src; // <img src='' data-rel='' />
  8336. src = UI.utils.getAbsoluteUrl(src);
  8337. title = $(item).attr('alt') || '';
  8338. }
  8339. // add pureviewed flag
  8340. item.setAttribute(viewedFlag, '1');
  8341. // hide bar: wechat_webview_type=1
  8342. // http://tmt.io/wechat/ not working?
  8343. _this.imgUrls.push(src);
  8344. $slides = $slides.add($('<li data-src="' + src + '" data-title="' + title +
  8345. '"></li>'));
  8346. $navItems = $navItems.add($('<li>' + (i + 1) + '</li>'));
  8347. });
  8348. $pureview.find(options.selector.total).text(total);
  8349. this.$slider.append($slides);
  8350. this.$nav.append($navItems);
  8351. this.$navItems = this.$nav.find('li');
  8352. this.$slides = this.$slider.find('li');
  8353. };
  8354. PureView.prototype.loadImage = function($slide, callback) {
  8355. var appendedFlag = 'image-appended';
  8356. if (!$slide.data(appendedFlag)) {
  8357. var $img = $('<img>', {
  8358. src: $slide.data('src'),
  8359. alt: $slide.data('title')
  8360. });
  8361. $slide.html($img).wrapInner('<div class="am-pinch-zoom"></div>').redraw();
  8362. var $pinchWrapper = $slide.find(this.options.selector.pinchZoom);
  8363. $pinchWrapper.data('amui.pinchzoom', new PinchZoom($pinchWrapper[0], {}));
  8364. $slide.data('image-appended', true);
  8365. }
  8366. callback && callback.call(this);
  8367. };
  8368. PureView.prototype.activate = function($slide) {
  8369. var options = this.options;
  8370. var $slides = this.$slides;
  8371. var activeIndex = $slides.index($slide);
  8372. var title = $slide.data('title') || '';
  8373. var active = options.className.active;
  8374. if ($slides.find('.' + active).is($slide)) {
  8375. return;
  8376. }
  8377. if (this.transitioning) {
  8378. return;
  8379. }
  8380. this.loadImage($slide, function() {
  8381. UI.utils.imageLoader($slide.find('img'), function(image) {
  8382. $slide.find('.am-pinch-zoom').addClass('am-pureview-loaded');
  8383. $(image).addClass('am-img-loaded');
  8384. //图片放大效果
  8385. $(function () {
  8386. var rotate = 0;
  8387. $(".rotate_div").on("click", function () {
  8388. rotate += 90;
  8389. $(".am-active .am-pinch-zoom img").css("transform", "rotate(" + rotate + "deg)");
  8390. });
  8391. var scale = 1;
  8392. $('.rotate_jia').on('click', function () {
  8393. scale = scale + 0.1;
  8394. $('.am-active .am-pinch-zoom img').css('transform', 'rotate(' + rotate + 'deg)' + 'scale(' + scale + ',' + scale + ')');
  8395. });
  8396. $('.rotate_jian').on('click', function () {
  8397. if (scale > 1) {
  8398. scale = scale - 0.1;
  8399. $('.am-active .am-pinch-zoom img').css('transform', 'rotate(' + rotate + 'deg)' + 'scale(' + scale + ',' + scale + ')')
  8400. }
  8401. else {
  8402. return false;
  8403. }
  8404. })
  8405. var len = 0;
  8406. $('.up-img').click(function () {
  8407. len += -50;
  8408. $('.am-pinch-zoom').css('top', len + 'px')
  8409. });
  8410. $('.down-img').click(function () {
  8411. len += 50;
  8412. $('.am-pinch-zoom').css('top', len + 'px')
  8413. });
  8414. $('.left-img').click(function () {
  8415. len += -50;
  8416. $('.am-pinch-zoom').css('left', len + 'px')
  8417. });
  8418. $('.right-img').click(function () {
  8419. len += 50;
  8420. $('.am-pinch-zoom').css('left', len + 'px')
  8421. });
  8422. $('.middle-img').click(function () {
  8423. len += 50;
  8424. $('.am-pinch-zoom').css({'left': '0px', 'top': '0px'})
  8425. });
  8426. $('.am-icon-chevron-left').on('click', function () {
  8427. $(".am-img-loaded").css("transform", "rotate(360deg)");
  8428. $('.am-img-loaded').css('transform', 'scale(1,1)');
  8429. });
  8430. $(document).on("mousewheel DOMMouseScroll", function (e) {
  8431. var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || // chrome & ie
  8432. (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); // firefox
  8433. if (delta > 0) {
  8434. // 向上滚
  8435. scale = scale + 0.1;
  8436. console.log(scale);
  8437. $('.am-img-loaded').css('transform', 'rotate(' + rotate + 'deg)' + 'scale(' + scale + ',' + scale + ')');
  8438. } else if (delta < 0) {
  8439. // 向下滚
  8440. if (scale > 1) {
  8441. scale = scale - 0.1;
  8442. console.log(scale);
  8443. $('.am-img-loaded').css('transform', 'rotate(' + rotate + 'deg)' + 'scale(' + scale + ',' + scale + ')');
  8444. }
  8445. else {
  8446. $('.am-img-loaded').css('transform', 'rotate(' + rotate + 'deg)' + 'scale(1,1)');
  8447. }
  8448. }
  8449. });
  8450. $('.m_hxlist_con_main').click(function () {
  8451. $('.am-img-loaded').css('transform', 'scale(1,1)');
  8452. $('.am-pinch-zoom').css({'left': '0px', 'top': '0px'})
  8453. })
  8454. });
  8455. //图片放大效果
  8456. });
  8457. });
  8458. this.transitioning = 1;
  8459. this.$title.text(title);
  8460. this.$current.text(activeIndex + 1);
  8461. $slides.removeClass();
  8462. $slide.addClass(active);
  8463. $slides.eq(activeIndex - 1).addClass(options.className.prevSlide);
  8464. $slides.eq(activeIndex + 1).addClass(options.className.nextSlide);
  8465. this.$navItems.removeClass().
  8466. eq(activeIndex).addClass(options.className.active);
  8467. if (transition) {
  8468. $slide.one(transition.end, $.proxy(function() {
  8469. this.transitioning = 0;
  8470. }, this)).emulateTransitionEnd(300);
  8471. } else {
  8472. this.transitioning = 0;
  8473. }
  8474. // TODO: pre-load next image
  8475. };
  8476. PureView.prototype.nextSlide = function() {
  8477. if (this.$slides.length === 1) {
  8478. return;
  8479. }
  8480. var $slides = this.$slides;
  8481. var $active = $slides.filter('.am-active');
  8482. var activeIndex = $slides.index($active);
  8483. var rightSpring = 'am-animation-right-spring';
  8484. if (activeIndex + 1 >= $slides.length) { // last one
  8485. animation && $active.addClass(rightSpring).on(animation.end, function() {
  8486. $active.removeClass(rightSpring);
  8487. });
  8488. } else {
  8489. this.activate($slides.eq(activeIndex + 1));
  8490. }
  8491. };
  8492. PureView.prototype.prevSlide = function() {
  8493. if (this.$slides.length === 1) {
  8494. return;
  8495. }
  8496. var $slides = this.$slides;
  8497. var $active = $slides.filter('.am-active');
  8498. var activeIndex = this.$slides.index(($active));
  8499. var leftSpring = 'am-animation-left-spring';
  8500. if (activeIndex === 0) { // first one
  8501. animation && $active.addClass(leftSpring).on(animation.end, function() {
  8502. $active.removeClass(leftSpring);
  8503. });
  8504. } else {
  8505. this.activate($slides.eq(activeIndex - 1));
  8506. }
  8507. };
  8508. PureView.prototype.toggleToolBar = function() {
  8509. this.$pureview.toggleClass(this.options.className.barActive);
  8510. };
  8511. PureView.prototype.open = function(index) {
  8512. var active = index || 0;
  8513. this.checkScrollbar();
  8514. this.setScrollbar();
  8515. this.activate(this.$slides.eq(active));
  8516. this.$pureview.show().redraw().addClass(this.options.className.active);
  8517. this.$body.addClass(this.options.className.activeBody);
  8518. };
  8519. PureView.prototype.close = function() {
  8520. var options = this.options;
  8521. this.$pureview.removeClass(options.className.active);
  8522. //this.$slides.removeClass();
  8523. function resetBody() {
  8524. this.$pureview.hide();
  8525. this.$body.removeClass(options.className.activeBody);
  8526. this.resetScrollbar();
  8527. }
  8528. if (transition) {
  8529. this.$pureview.one(transition.end, $.proxy(resetBody, this)).
  8530. emulateTransitionEnd(300);
  8531. } else {
  8532. resetBody.call(this);
  8533. }
  8534. };
  8535. PureView.prototype.checkScrollbar = function() {
  8536. this.scrollbarWidth = UI.utils.measureScrollbar();
  8537. };
  8538. PureView.prototype.setScrollbar = function() {
  8539. var bodyPaddingRight = parseInt((this.$body.css('padding-right') || 0), 10);
  8540. if (this.scrollbarWidth) {
  8541. this.$body.css('padding-right', bodyPaddingRight + this.scrollbarWidth);
  8542. }
  8543. };
  8544. PureView.prototype.resetScrollbar = function() {
  8545. this.$body.css('padding-right', '');
  8546. };
  8547. UI.plugin('pureview', PureView);
  8548. // Init code
  8549. UI.ready(function(context) {
  8550. $('[data-am-pureview]', context).pureview();
  8551. });
  8552. module.exports = PureView;
  8553. // TODO: 1. �����Ľ�
  8554. // 2. �ı�ͼƬ��ʱ��ָ� Zoom
  8555. // 3. ѡ��
  8556. // 4. ͼƬ�߶����⣺���� PinchZoom ��ԭ�򣬹��ߵ�ͼƬ������ÿ��˹�������Ŵ��Ժ���ʾ��ȫ
  8557. /***/ },
  8558. /* 21 */
  8559. /***/ function(module, exports, __webpack_require__) {
  8560. 'use strict';
  8561. var $ = __webpack_require__(1);
  8562. var UI = __webpack_require__(2);
  8563. /**
  8564. * @via https://github.com/uikit/uikit/blob/master/src/js/scrollspy.js
  8565. * @license https://github.com/uikit/uikit/blob/master/LICENSE.md
  8566. */
  8567. var ScrollSpy = function(element, options) {
  8568. if (!UI.support.animation) {
  8569. return;
  8570. }
  8571. this.options = $.extend({}, ScrollSpy.DEFAULTS, options);
  8572. this.$element = $(element);
  8573. var checkViewRAF = function() {
  8574. UI.utils.rAF.call(window, $.proxy(this.checkView, this));
  8575. }.bind(this);
  8576. this.$window = $(window).on('scroll.scrollspy.amui', checkViewRAF)
  8577. .on('resize.scrollspy.amui orientationchange.scrollspy.amui',
  8578. UI.utils.debounce(checkViewRAF, 50));
  8579. this.timer = this.inViewState = this.initInView = null;
  8580. checkViewRAF();
  8581. };
  8582. ScrollSpy.DEFAULTS = {
  8583. animation: 'fade',
  8584. className: {
  8585. inView: 'am-scrollspy-inview',
  8586. init: 'am-scrollspy-init'
  8587. },
  8588. repeat: true,
  8589. delay: 0,
  8590. topOffset: 0,
  8591. leftOffset: 0
  8592. };
  8593. ScrollSpy.prototype.checkView = function() {
  8594. var $element = this.$element;
  8595. var options = this.options;
  8596. var inView = UI.utils.isInView($element, options);
  8597. var animation = options.animation ?
  8598. ' am-animation-' + options.animation : '';
  8599. if (inView && !this.inViewState) {
  8600. if (this.timer) {
  8601. clearTimeout(this.timer);
  8602. }
  8603. if (!this.initInView) {
  8604. $element.addClass(options.className.init);
  8605. this.offset = $element.offset();
  8606. this.initInView = true;
  8607. $element.trigger('init.scrollspy.amui');
  8608. }
  8609. this.timer = setTimeout(function() {
  8610. if (inView) {
  8611. $element.addClass(options.className.inView + animation).width();
  8612. }
  8613. }, options.delay);
  8614. this.inViewState = true;
  8615. $element.trigger('inview.scrollspy.amui');
  8616. }
  8617. if (!inView && this.inViewState && options.repeat) {
  8618. $element.removeClass(options.className.inView + animation);
  8619. this.inViewState = false;
  8620. $element.trigger('outview.scrollspy.amui');
  8621. }
  8622. };
  8623. ScrollSpy.prototype.check = function() {
  8624. UI.utils.rAF.call(window, $.proxy(this.checkView, this));
  8625. };
  8626. // Sticky Plugin
  8627. UI.plugin('scrollspy', ScrollSpy);
  8628. // Init code
  8629. UI.ready(function(context) {
  8630. $('[data-am-scrollspy]', context).scrollspy();
  8631. });
  8632. module.exports = ScrollSpy;
  8633. /***/ },
  8634. /* 22 */
  8635. /***/ function(module, exports, __webpack_require__) {
  8636. 'use strict';
  8637. var $ = __webpack_require__(1);
  8638. var UI = __webpack_require__(2);
  8639. __webpack_require__(23);
  8640. /**
  8641. * @via https://github.com/uikit/uikit/
  8642. * @license https://github.com/uikit/uikit/blob/master/LICENSE.md
  8643. */
  8644. // ScrollSpyNav Class
  8645. var ScrollSpyNav = function(element, options) {
  8646. this.options = $.extend({}, ScrollSpyNav.DEFAULTS, options);
  8647. this.$element = $(element);
  8648. this.anchors = [];
  8649. this.$links = this.$element.find('a[href^="#"]').each(function(i, link) {
  8650. this.anchors.push($(link).attr('href'));
  8651. }.bind(this));
  8652. this.$targets = $(this.anchors.join(', '));
  8653. var processRAF = function() {
  8654. UI.utils.rAF.call(window, $.proxy(this.process, this));
  8655. }.bind(this);
  8656. this.$window = $(window).on('scroll.scrollspynav.amui', processRAF)
  8657. .on('resize.scrollspynav.amui orientationchange.scrollspynav.amui',
  8658. UI.utils.debounce(processRAF, 50));
  8659. processRAF();
  8660. this.scrollProcess();
  8661. };
  8662. ScrollSpyNav.DEFAULTS = {
  8663. className: {
  8664. active: 'am-active'
  8665. },
  8666. closest: false,
  8667. smooth: true,
  8668. offsetTop: 0
  8669. };
  8670. ScrollSpyNav.prototype.process = function() {
  8671. var scrollTop = this.$window.scrollTop();
  8672. var options = this.options;
  8673. var inViews = [];
  8674. var $links = this.$links;
  8675. var $targets = this.$targets;
  8676. $targets.each(function(i, target) {
  8677. if (UI.utils.isInView(target, options)) {
  8678. inViews.push(target);
  8679. }
  8680. });
  8681. // console.log(inViews.length);
  8682. if (inViews.length) {
  8683. var $target;
  8684. $.each(inViews, function(i, item) {
  8685. if ($(item).offset().top >= scrollTop) {
  8686. $target = $(item);
  8687. return false; // break
  8688. }
  8689. });
  8690. if (!$target) {
  8691. return;
  8692. }
  8693. if (options.closest) {
  8694. $links.closest(options.closest).removeClass(options.className.active);
  8695. $links.filter('a[href="#' + $target.attr('id') + '"]').
  8696. closest(options.closest).addClass(options.className.active);
  8697. } else {
  8698. $links.removeClass(options.className.active).
  8699. filter('a[href="#' + $target.attr('id') + '"]').
  8700. addClass(options.className.active);
  8701. }
  8702. }
  8703. };
  8704. ScrollSpyNav.prototype.scrollProcess = function() {
  8705. var $links = this.$links;
  8706. var options = this.options;
  8707. // smoothScroll
  8708. if (options.smooth && $.fn.smoothScroll) {
  8709. $links.on('click', function(e) {
  8710. e.preventDefault();
  8711. var $this = $(this);
  8712. var $target = $($this.attr('href'));
  8713. if (!$target) {
  8714. return;
  8715. }
  8716. var offsetTop = options.offsetTop &&
  8717. !isNaN(parseInt(options.offsetTop)) && parseInt(options.offsetTop) || 0;
  8718. $(window).smoothScroll({position: $target.offset().top - offsetTop});
  8719. });
  8720. }
  8721. };
  8722. // ScrollSpyNav Plugin
  8723. UI.plugin('scrollspynav', ScrollSpyNav);
  8724. // Init code
  8725. UI.ready(function(context) {
  8726. $('[data-am-scrollspy-nav]', context).scrollspynav();
  8727. });
  8728. module.exports = ScrollSpyNav;
  8729. // TODO: 1. �㷨�Ľ�
  8730. // 2. �༶�˵�֧��
  8731. // 3. smooth scroll pushState
  8732. /***/ },
  8733. /* 23 */
  8734. /***/ function(module, exports, __webpack_require__) {
  8735. 'use strict';
  8736. var $ = __webpack_require__(1);
  8737. var UI = __webpack_require__(2);
  8738. var rAF = UI.utils.rAF;
  8739. var cAF = UI.utils.cancelAF;
  8740. /**
  8741. * Smooth Scroll
  8742. * @param position
  8743. * @via http://mir.aculo.us/2014/01/19/scrolling-dom-elements-to-the-top-a-zepto-plugin/
  8744. */
  8745. // Usage: $(window).smoothScroll([options])
  8746. // only allow one scroll to top operation to be in progress at a time,
  8747. // which is probably what you want
  8748. var smoothScrollInProgress = false;
  8749. var SmoothScroll = function(element, options) {
  8750. options = options || {};
  8751. var $this = $(element);
  8752. var targetY = parseInt(options.position) || SmoothScroll.DEFAULTS.position;
  8753. var initialY = $this.scrollTop();
  8754. var lastY = initialY;
  8755. var delta = targetY - initialY;
  8756. // duration in ms, make it a bit shorter for short distances
  8757. // this is not scientific and you might want to adjust this for
  8758. // your preferences
  8759. var speed = options.speed ||
  8760. Math.min(750, Math.min(1500, Math.abs(initialY - targetY)));
  8761. // temp variables (t will be a position between 0 and 1, y is the calculated scrollTop)
  8762. var start;
  8763. var t;
  8764. var y;
  8765. var cancelScroll = function() {
  8766. abort();
  8767. };
  8768. // abort if already in progress or nothing to scroll
  8769. if (smoothScrollInProgress) {
  8770. return;
  8771. }
  8772. if (delta === 0) {
  8773. return;
  8774. }
  8775. // quint ease-in-out smoothing, from
  8776. // https://github.com/madrobby/scripty2/blob/master/src/effects/transitions/penner.js#L127-L136
  8777. function smooth(pos) {
  8778. if ((pos /= 0.5) < 1) {
  8779. return 0.5 * Math.pow(pos, 5);
  8780. }
  8781. return 0.5 * (Math.pow((pos - 2), 5) + 2);
  8782. }
  8783. function abort() {
  8784. $this.off('touchstart.smoothscroll.amui', cancelScroll);
  8785. smoothScrollInProgress = false;
  8786. }
  8787. // when there's a touch detected while scrolling is in progress, abort
  8788. // the scrolling (emulates native scrolling behavior)
  8789. $this.on('touchstart.smoothscroll.amui', cancelScroll);
  8790. smoothScrollInProgress = true;
  8791. // start rendering away! note the function given to frame
  8792. // is named "render" so we can reference it again further down
  8793. function render(now) {
  8794. if (!smoothScrollInProgress) {
  8795. return;
  8796. }
  8797. if (!start) {
  8798. start = now;
  8799. }
  8800. // calculate t, position of animation in [0..1]
  8801. t = Math.min(1, Math.max((now - start) / speed, 0));
  8802. // calculate the new scrollTop position (don't forget to smooth)
  8803. y = Math.round(initialY + delta * smooth(t));
  8804. // bracket scrollTop so we're never over-scrolling
  8805. if (delta > 0 && y > targetY) {
  8806. y = targetY;
  8807. }
  8808. if (delta < 0 && y < targetY) {
  8809. y = targetY;
  8810. }
  8811. // only actually set scrollTop if there was a change fromt he last frame
  8812. if (lastY != y) {
  8813. $this.scrollTop(y);
  8814. }
  8815. lastY = y;
  8816. // if we're not done yet, queue up an other frame to render,
  8817. // or clean up
  8818. if (y !== targetY) {
  8819. cAF(scrollRAF);
  8820. scrollRAF = rAF(render);
  8821. } else {
  8822. cAF(scrollRAF);
  8823. abort();
  8824. }
  8825. }
  8826. var scrollRAF = rAF(render);
  8827. };
  8828. SmoothScroll.DEFAULTS = {
  8829. position: 0
  8830. };
  8831. $.fn.smoothScroll = function(option) {
  8832. return this.each(function() {
  8833. new SmoothScroll(this, option);
  8834. });
  8835. };
  8836. // Init code
  8837. $(document).on('click.smoothScroll.amui.data-api', '[data-am-smooth-scroll]',
  8838. function(e) {
  8839. e.preventDefault();
  8840. var options = UI.utils.parseOptions($(this).data('amSmoothScroll'));
  8841. $(window).smoothScroll(options);
  8842. });
  8843. module.exports = SmoothScroll;
  8844. /***/ },
  8845. /* 24 */
  8846. /***/ function(module, exports, __webpack_require__) {
  8847. 'use strict';
  8848. var $ = __webpack_require__(1);
  8849. var UI = __webpack_require__(2);
  8850. // require('./ui.dropdown');
  8851. // Make jQuery :contains Case-Insensitive
  8852. $.expr[':'].containsNC = function(elem, i, match, array) {
  8853. return (elem.textContent || elem.innerText || '').toLowerCase().
  8854. indexOf((match[3] || '').toLowerCase()) >= 0;
  8855. };
  8856. /**
  8857. * Selected
  8858. * @desc HTML select replacer
  8859. * @via https://github.com/silviomoreto/bootstrap-select
  8860. * @license https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE
  8861. * @param element
  8862. * @param options
  8863. * @constructor
  8864. */
  8865. var Selected = function(element, options) {
  8866. this.$element = $(element);
  8867. this.options = $.extend({}, Selected.DEFAULTS, {
  8868. placeholder: element.getAttribute('placeholder') ||
  8869. Selected.DEFAULTS.placeholder
  8870. }, options);
  8871. this.$originalOptions = this.$element.find('option');
  8872. this.multiple = element.multiple;
  8873. this.$selector = null;
  8874. this.initialized = false;
  8875. this.init();
  8876. };
  8877. Selected.DEFAULTS = {
  8878. btnWidth: null,
  8879. btnSize: null,
  8880. btnStyle: 'default',
  8881. dropUp: 0,
  8882. maxHeight: null,
  8883. maxChecked: null,
  8884. placeholder: '���ѡ��...',
  8885. selectedClass: 'am-checked',
  8886. disabledClass: 'am-disabled',
  8887. searchBox: false,
  8888. tpl: '<div class="am-selected am-dropdown ' +
  8889. '<%= dropUp ? \'am-dropdown-up\': \'\' %>" id="<%= id %>" data-am-dropdown>' +
  8890. ' <button type="button" class="am-selected-btn am-btn am-dropdown-toggle">' +
  8891. ' <span class="am-selected-status am-fl"></span>' +
  8892. ' <i class="am-selected-icon am-icon-caret-' +
  8893. '<%= dropUp ? \'up\' : \'down\' %>"></i>' +
  8894. ' </button>' +
  8895. ' <div class="am-selected-content am-dropdown-content">' +
  8896. ' <h2 class="am-selected-header">' +
  8897. '<span class="am-icon-chevron-left">����</span></h2>' +
  8898. ' <% if (searchBox) { %>' +
  8899. ' <div class="am-selected-search">' +
  8900. ' <input autocomplete="off" class="am-form-field am-input-sm" />' +
  8901. ' </div>' +
  8902. ' <% } %>' +
  8903. ' <ul class="am-selected-list">' +
  8904. ' <% for (var i = 0; i < options.length; i++) { %>' +
  8905. ' <% var option = options[i] %>' +
  8906. ' <% if (option.header) { %>' +
  8907. ' <li data-group="<%= option.group %>" class="am-selected-list-header">' +
  8908. ' <%= option.text %></li>' +
  8909. ' <% } else { %>' +
  8910. ' <li class="<%= option.classNames%>" ' +
  8911. ' data-index="<%= option.index %>" ' +
  8912. ' data-group="<%= option.group || 0 %>" ' +
  8913. ' data-value="<%= option.value %>" >' +
  8914. ' <span class="am-selected-text"><%= option.text %></span>' +
  8915. ' <i class="am-icon-check"></i></li>' +
  8916. ' <% } %>' +
  8917. ' <% } %>' +
  8918. ' </ul>' +
  8919. ' <div class="am-selected-hint"></div>' +
  8920. ' </div>' +
  8921. '</div>',
  8922. listTpl: '<% for (var i = 0; i < options.length; i++) { %>' +
  8923. ' <% var option = options[i] %>' +
  8924. ' <% if (option.header) { %>' +
  8925. ' <li data-group="<%= option.group %>" class="am-selected-list-header">' +
  8926. ' <%= option.text %></li>' +
  8927. ' <% } else { %>' +
  8928. ' <li class="<%= option.classNames %>" ' +
  8929. ' data-index="<%= option.index %>" ' +
  8930. ' data-group="<%= option.group || 0 %>" ' +
  8931. ' data-value="<%= option.value %>" >' +
  8932. ' <span class="am-selected-text"><%= option.text %></span>' +
  8933. ' <i class="am-icon-check"></i></li>' +
  8934. ' <% } %>' +
  8935. ' <% } %>'
  8936. };
  8937. Selected.prototype.init = function() {
  8938. var _this = this;
  8939. var $element = this.$element;
  8940. var options = this.options;
  8941. $element.hide();
  8942. var data = {
  8943. id: UI.utils.generateGUID('am-selected'),
  8944. multiple: this.multiple,
  8945. options: [],
  8946. searchBox: options.searchBox,
  8947. dropUp: options.dropUp,
  8948. placeholder: options.placeholder
  8949. };
  8950. this.$selector = $(UI.template(this.options.tpl, data));
  8951. // set select button styles
  8952. this.$selector.css({width: this.options.btnWidth});
  8953. if (this.$element[0].disabled) {
  8954. this.$selector.addClass(options.disabledClass);
  8955. }
  8956. this.$list = this.$selector.find('.am-selected-list');
  8957. this.$searchField = this.$selector.find('.am-selected-search input');
  8958. this.$hint = this.$selector.find('.am-selected-hint');
  8959. var $selectorBtn = this.$selector.find('.am-selected-btn');
  8960. var btnClassNames = [];
  8961. options.btnSize && btnClassNames.push('am-btn-' + options.btnSize);
  8962. options.btnStyle && btnClassNames.push('am-btn-' + options.btnStyle);
  8963. $selectorBtn.addClass(btnClassNames.join(' '));
  8964. this.$selector.dropdown({
  8965. justify: $selectorBtn
  8966. });
  8967. // set list height
  8968. if (options.maxHeight) {
  8969. this.$selector.find('.am-selected-list').css({
  8970. 'max-height': options.maxHeight,
  8971. 'overflow-y': 'scroll'
  8972. });
  8973. }
  8974. // set hint text
  8975. var hint = [];
  8976. var min = $element.attr('minchecked');
  8977. var max = $element.attr('maxchecked') || options.maxChecked;
  8978. this.maxChecked = max || Infinity;
  8979. if ($element[0].required) {
  8980. hint.push('��ѡ');
  8981. }
  8982. if (min || max) {
  8983. min && hint.push('����ѡ�� ' + min + ' ��');
  8984. max && hint.push('����ѡ�� ' + max + ' ��');
  8985. }
  8986. this.$hint.text(hint.join('��'));
  8987. // render dropdown list
  8988. this.renderOptions();
  8989. // append $selector after <select>
  8990. this.$element.after(this.$selector);
  8991. this.dropdown = this.$selector.data('amui.dropdown');
  8992. this.$status = this.$selector.find('.am-selected-status');
  8993. // #try to fixes #476
  8994. setTimeout(function() {
  8995. _this.syncData();
  8996. _this.initialized = true;
  8997. }, 0);
  8998. this.bindEvents();
  8999. };
  9000. Selected.prototype.renderOptions = function() {
  9001. var $element = this.$element;
  9002. var options = this.options;
  9003. var optionItems = [];
  9004. var $optgroup = $element.find('optgroup');
  9005. this.$originalOptions = this.$element.find('option');
  9006. // ��ѡ��ʹ�� JS �����Ѿ�ѡ��� option �Ժ�
  9007. // �����������ѡ����һ�� option������һ���ӳ٣���ʹ JS ��ȡ value ʱ���� null
  9008. if (!this.multiple && ($element.val() === null)) {
  9009. this.$originalOptions.length &&
  9010. (this.$originalOptions.get(0).selected = true);
  9011. }
  9012. function pushOption(index, item, group) {
  9013. if (item.value === '') {
  9014. // skip to next iteration
  9015. // @see http://stackoverflow.com/questions/481601/how-to-skip-to-next-iteration-in-jquery-each-util
  9016. return true;
  9017. }
  9018. var classNames = '';
  9019. item.disabled && (classNames += options.disabledClass);
  9020. !item.disabled && item.selected && (classNames += options.selectedClass);
  9021. optionItems.push({
  9022. group: group,
  9023. index: index,
  9024. classNames: classNames,
  9025. text: item.text,
  9026. value: item.value
  9027. });
  9028. }
  9029. // select with option groups
  9030. if ($optgroup.length) {
  9031. $optgroup.each(function(i) {
  9032. // push group name
  9033. optionItems.push({
  9034. header: true,
  9035. group: i + 1,
  9036. text: this.label
  9037. });
  9038. $optgroup.eq(i).find('option').each(function(index, item) {
  9039. pushOption(index, item, i);
  9040. });
  9041. });
  9042. } else {
  9043. // without option groups
  9044. this.$originalOptions.each(function(index, item) {
  9045. pushOption(index, item, null);
  9046. });
  9047. }
  9048. this.$list.html(UI.template(options.listTpl, {options: optionItems}));
  9049. this.$shadowOptions = this.$list.find('> li').
  9050. not('.am-selected-list-header');
  9051. };
  9052. Selected.prototype.setChecked = function(item) {
  9053. var options = this.options;
  9054. var $item = $(item);
  9055. var isChecked = $item.hasClass(options.selectedClass);
  9056. if (this.multiple) {
  9057. // multiple
  9058. var checkedLength = this.$list.find('.' + options.selectedClass).length;
  9059. if (!isChecked && this.maxChecked <= checkedLength) {
  9060. this.$element.trigger('checkedOverflow.selected.amui', {
  9061. selected: this
  9062. });
  9063. return false;
  9064. }
  9065. } else {
  9066. if (isChecked) {
  9067. return false;
  9068. }
  9069. this.dropdown.close();
  9070. this.$shadowOptions.not($item).removeClass(options.selectedClass);
  9071. }
  9072. $item.toggleClass(options.selectedClass);
  9073. this.syncData(item);
  9074. };
  9075. /**
  9076. * syncData
  9077. * @desc if `item` set, only sync `item` related option
  9078. * @param {Object} item
  9079. */
  9080. Selected.prototype.syncData = function(item) {
  9081. var _this = this;
  9082. var options = this.options;
  9083. var status = [];
  9084. var $checked = $([]);
  9085. this.$shadowOptions.filter('.' + options.selectedClass).each(function() {
  9086. var $this = $(this);
  9087. status.push($this.find('.am-selected-text').text());
  9088. if (!item) {
  9089. $checked = $checked.add(_this.$originalOptions
  9090. .filter('[value="' + $this.data('value') + '"]')
  9091. .prop('selected', true));
  9092. }
  9093. });
  9094. if (item) {
  9095. var $item = $(item);
  9096. this.$originalOptions
  9097. .filter('[value="' + $item.data('value') + '"]')
  9098. .prop('selected', $item.hasClass(options.selectedClass));
  9099. } else {
  9100. this.$originalOptions.not($checked).prop('selected', false);
  9101. }
  9102. // nothing selected
  9103. if (!this.$element.val()) {
  9104. status = [options.placeholder];
  9105. }
  9106. this.$status.text(status.join(', '));
  9107. // Do not trigger change event on initializing
  9108. this.initialized && this.$element.trigger('change');
  9109. };
  9110. Selected.prototype.bindEvents = function() {
  9111. var _this = this;
  9112. var header = 'am-selected-list-header';
  9113. var handleKeyup = UI.utils.debounce(function(e) {
  9114. _this.$shadowOptions.not('.' + header).hide().
  9115. filter(':containsNC("' + e.target.value + '")').show();
  9116. }, 100);
  9117. this.$list.on('click', '> li', function(e) {
  9118. var $this = $(this);
  9119. !$this.hasClass(_this.options.disabledClass) &&
  9120. !$this.hasClass(header) && _this.setChecked(this);
  9121. });
  9122. // simple search with jQuery :contains
  9123. this.$searchField.on('keyup.selected.amui', handleKeyup);
  9124. // empty search keywords
  9125. this.$selector.on('closed.dropdown.amui', function() {
  9126. _this.$searchField.val('');
  9127. _this.$shadowOptions.css({display: ''});
  9128. });
  9129. // work with Validator
  9130. // @since 2.5
  9131. this.$element.on('validated.field.validator.amui', function(e) {
  9132. if (e.validity) {
  9133. var valid = e.validity.valid;
  9134. var errorClassName = 'am-invalid';
  9135. _this.$selector[(!valid ? 'add' : 'remove') + 'Class'](errorClassName);
  9136. }
  9137. });
  9138. // observe DOM
  9139. if (UI.support.mutationobserver) {
  9140. this.observer = new UI.support.mutationobserver(function() {
  9141. _this.$element.trigger('changed.selected.amui');
  9142. });
  9143. this.observer.observe(this.$element[0], {
  9144. childList: true,
  9145. attributes: true,
  9146. subtree: true,
  9147. characterData: true
  9148. });
  9149. }
  9150. // custom event
  9151. this.$element.on('changed.selected.amui', function() {
  9152. _this.renderOptions();
  9153. _this.syncData();
  9154. });
  9155. };
  9156. // @since: 2.5
  9157. Selected.prototype.select = function(item) {
  9158. var $item;
  9159. if (typeof item === 'number') {
  9160. $item = this.$list.find('> li').not('.am-selected-list-header').eq(item);
  9161. } else if (typeof item === 'string') {
  9162. $item = this.$list.find(item);
  9163. } else {
  9164. $item = $(item);
  9165. }
  9166. $item.trigger('click');
  9167. },
  9168. // @since: 2.5
  9169. Selected.prototype.enable = function() {
  9170. this.$element.prop('disable', false);
  9171. this.$selector.dropdown('enable');
  9172. },
  9173. // @since: 2.5
  9174. Selected.prototype.disable = function() {
  9175. this.$element.prop('disable', true);
  9176. this.$selector.dropdown('disable');
  9177. },
  9178. Selected.prototype.destroy = function() {
  9179. this.$element.removeData('amui.selected').show();
  9180. this.$selector.remove();
  9181. };
  9182. UI.plugin('selected', Selected);
  9183. // Conflict with jQuery form
  9184. // https://github.com/malsup/form/blob/6bf24a5f6d8be65f4e5491863180c09356d9dadd/jquery.form.js#L1240-L1258
  9185. // https://github.com/allmobilize/amazeui/issues/379
  9186. // @deprecated: $.fn.selected = $.fn.selectIt = Plugin;
  9187. // New way to resolve conflict:
  9188. // @see https://github.com/amazeui/amazeui/issues/781#issuecomment-158873541
  9189. UI.ready(function(context) {
  9190. $('[data-am-selected]', context).selected();
  9191. });
  9192. module.exports = Selected;
  9193. /***/ },
  9194. /* 25 */
  9195. /***/ function(module, exports, __webpack_require__) {
  9196. 'use strict';
  9197. __webpack_require__(15);
  9198. var $ = __webpack_require__(1);
  9199. var UI = __webpack_require__(2);
  9200. var QRCode = __webpack_require__(26);
  9201. var doc = document;
  9202. var $doc = $(doc);
  9203. var Share = function(options) {
  9204. this.options = $.extend({}, Share.DEFAULTS, options || {});
  9205. this.$element = null;
  9206. this.$wechatQr = null;
  9207. this.pics = null;
  9208. this.inited = false;
  9209. this.active = false;
  9210. // this.init();
  9211. };
  9212. Share.DEFAULTS = {
  9213. sns: ['weibo', 'qq', 'qzone', 'tqq', 'wechat', 'renren'],
  9214. title: '����',
  9215. cancel: 'ȡ��',
  9216. closeOnShare: true,
  9217. id: UI.utils.generateGUID('am-share'),
  9218. desc: 'Hi����ҹ�����󣬷���һ�����������������һ���� ;-)',
  9219. via: 'Amaze UI',
  9220. tpl: '<div class="am-share am-modal-actions" id="<%= id %>">' +
  9221. '<h3 class="am-share-title"><%= title %></h3>' +
  9222. '<ul class="am-share-sns am-avg-sm-3">' +
  9223. '<% for(var i = 0; i < sns.length; i++) {%>' +
  9224. '<li>' +
  9225. '<a href="<%= sns[i].shareUrl %>" ' +
  9226. 'data-am-share-to="<%= sns[i].id %>" >' +
  9227. '<i class="am-icon-<%= sns[i].icon %>"></i>' +
  9228. '<span><%= sns[i].title %></span>' +
  9229. '</a></li>' +
  9230. '<% } %></ul>' +
  9231. '<div class="am-share-footer">' +
  9232. '<button class="am-btn am-btn-default am-btn-block" ' +
  9233. 'data-am-share-close><%= cancel %></button></div>' +
  9234. '</div>'
  9235. };
  9236. Share.SNS = {
  9237. weibo: {
  9238. title: '����΢��',
  9239. url: 'http://service.weibo.com/share/share.php',
  9240. width: 620,
  9241. height: 450,
  9242. icon: 'weibo'
  9243. },
  9244. // url ���ӵ�ַ
  9245. // title:��, �������������(��ѡ��Ĭ��Ϊ����ҳ���title)
  9246. // appkey:��, �������Ӧ��appkey,��ʾ������Դ(��ѡ)
  9247. // pic:��, ����ͼƬ��·��(��ѡ)
  9248. // ralateUid:��, �����û���UID������΢����@���û�(��ѡ)
  9249. // NOTE: ���Զ�ץȡͼƬ������ָ�� pic
  9250. qq: {
  9251. title: 'QQ ����',
  9252. url: 'http://connect.qq.com/widget/shareqq/index.html',
  9253. icon: 'qq'
  9254. },
  9255. // url:,
  9256. // title:'', �������(��ѡ)
  9257. // pics:'', ����ͼƬ��·��(��ѡ)
  9258. // summary:'', ����ժҪ(��ѡ)
  9259. // site:'', ������Դ �磺��Ѷ��(��ѡ)
  9260. // desc: '' ���͸��û�����Ϣ
  9261. // NOTE: �������ԣ����շ����û���ֻ�� url �� desc
  9262. qzone: {
  9263. title: 'QQ �ռ�',
  9264. url: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey',
  9265. icon: 'star'
  9266. },
  9267. // http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=xxx&title=xxx&desc=&summary=&site=
  9268. // url:,
  9269. // title:'', �������(��ѡ)
  9270. // desc:'', Ĭ�Ϸ�������(��ѡ)
  9271. // summary:'', ����ժҪ(��ѡ)
  9272. // site:'', ������Դ �磺��Ѷ��(��ѡ)
  9273. // pics:'', ����ͼƬ��·��(��ѡ)�������Զ�ץȡ�����ͼƬ��|�ָ�
  9274. tqq: {
  9275. title: '��Ѷ΢��',
  9276. url: 'http://v.t.qq.com/share/share.php',
  9277. icon: 'tencent-weibo'
  9278. },
  9279. // url=xx&title=&appkey=801cf76d3cfc44ada52ec13114e84a96
  9280. // url
  9281. // title
  9282. // pic ���ͼƬ�� | �ָ�
  9283. // appkey
  9284. // NOTE: �����Զ�ץȡͼƬ
  9285. wechat: {
  9286. title: '΢��',
  9287. url: '[qrcode]',
  9288. icon: 'wechat'
  9289. },
  9290. // ����һ����ά�� ���û�ɨ��
  9291. // ��ؽӿ� https://github.com/zxlie/WeixinApi
  9292. renren: {
  9293. title: '������',
  9294. url: 'http://widget.renren.com/dialog/share',
  9295. icon: 'renren'
  9296. },
  9297. // http://widget.renren.com/dialog/share?resourceUrl=www&srcUrl=www&title=ww&description=xxx
  9298. // 550 * 400
  9299. // resourceUrl : '', // �������ԴUrl
  9300. // srcUrl : '', // �������Դ��ԴUrl,
  9301. // // Ĭ��Ϊheader�е�Referer,�������ʧ�ܿ��Ե�����ֵΪresourceUrl����
  9302. // pic : '', // ���������ͼƬ�����Զ�ץȡ
  9303. // title : '', // ����ı���
  9304. // description : '' // �������ϸ����
  9305. // NOTE: �������ԣ�ֱ��ʹ�� url ��������
  9306. douban: {
  9307. title: '����',
  9308. url: 'http://www.douban.com/recommend/',
  9309. icon: 'share-alt'
  9310. },
  9311. // http://www.douban.com/service/sharebutton
  9312. // 450 * 330
  9313. // http://www.douban.com/share/service?bm=1&image=&href=xxx&updated=&name=
  9314. // href ����
  9315. // name ����
  9316. /* void (function() {
  9317. var d = document, e = encodeURIComponent,
  9318. s1 = window.getSelection, s2 = d.getSelection,
  9319. s3 = d.selection, s = s1 ? s1()
  9320. : s2 ? s2() : s3 ? s3.createRange().text : '',
  9321. r = 'http://www.douban.com/recommend/?url=&title=&sel=&v=1&r=1'
  9322. })();
  9323. */
  9324. // tsohu: '',
  9325. // http://t.sohu.com/third/post.jsp?url=&title=&content=utf-8&pic=
  9326. // print: '',
  9327. mail: {
  9328. title: '�ʼ�����',
  9329. url: 'mailto:',
  9330. icon: 'envelope-o'
  9331. },
  9332. sms: {
  9333. title: '���ŷ���',
  9334. url: 'sms:',
  9335. icon: 'comment'
  9336. }
  9337. };
  9338. Share.prototype.render = function() {
  9339. var options = this.options;
  9340. var snsData = [];
  9341. var title = encodeURIComponent(doc.title);
  9342. var link = encodeURIComponent(doc.location);
  9343. var msgBody = '?body=' + title + link;
  9344. options.sns.forEach(function(item, i) {
  9345. if (Share.SNS[item]) {
  9346. var tmp = Share.SNS[item];
  9347. var shareUrl;
  9348. tmp.id = item;
  9349. if (item === 'mail') {
  9350. shareUrl = msgBody + '&subject=' + options.desc;
  9351. } else if (item === 'sms') {
  9352. shareUrl = msgBody;
  9353. } else {
  9354. shareUrl = '?url=' + link + '&title=' + title;
  9355. }
  9356. tmp.shareUrl = tmp.url + shareUrl;
  9357. snsData.push(tmp);
  9358. }
  9359. });
  9360. return UI.template(options.tpl, $.extend({}, options, {sns: snsData}));
  9361. };
  9362. Share.prototype.init = function() {
  9363. if (this.inited) {
  9364. return;
  9365. }
  9366. var me = this;
  9367. var shareItem = '[data-am-share-to]';
  9368. $doc.ready($.proxy(function() {
  9369. $('body').append(this.render()); // append share DOM to body
  9370. this.$element = $('#' + this.options.id);
  9371. this.$element.find('[data-am-share-close]').
  9372. on('click.share.amui', function() {
  9373. me.close();
  9374. });
  9375. }, this));
  9376. $doc.on('click.share.amui', shareItem, $.proxy(function(e) {
  9377. var $clicked = $(e.target);
  9378. var $target = $clicked.is(shareItem) && $clicked ||
  9379. $clicked.parent(shareItem);
  9380. var sns = $target.attr('data-am-share-to');
  9381. if (!(sns === 'mail' || sns === 'sms')) {
  9382. e.preventDefault();
  9383. this.shareTo(sns, this.setData(sns));
  9384. }
  9385. this.close();
  9386. }, this));
  9387. this.inited = true;
  9388. };
  9389. Share.prototype.open = function() {
  9390. !this.inited && this.init();
  9391. this.$element && this.$element.modal('open');
  9392. this.$element.trigger('open.share.amui');
  9393. this.active = true;
  9394. };
  9395. Share.prototype.close = function() {
  9396. this.$element && this.$element.modal('close');
  9397. this.$element.trigger('close.share.amui');
  9398. this.active = false;
  9399. };
  9400. Share.prototype.toggle = function() {
  9401. this.active ? this.close() : this.open();
  9402. };
  9403. Share.prototype.setData = function(sns) {
  9404. if (!sns) {
  9405. return;
  9406. }
  9407. var shareData = {
  9408. url: doc.location,
  9409. title: doc.title
  9410. };
  9411. var desc = this.options.desc;
  9412. var imgSrc = this.pics || [];
  9413. var qqReg = /^(qzone|qq|tqq)$/;
  9414. if (qqReg.test(sns) && !imgSrc.length) {
  9415. var allImages = doc.images;
  9416. for (var i = 0; i < allImages.length && i < 10; i++) {
  9417. !!allImages[i].src && imgSrc.push(encodeURIComponent(allImages[i].src));
  9418. }
  9419. this.pics = imgSrc; // ����ͼƬ
  9420. }
  9421. switch (sns) {
  9422. case 'qzone':
  9423. shareData.desc = desc;
  9424. shareData.site = this.options.via;
  9425. shareData.pics = imgSrc.join('|');
  9426. // TODO: ץȡͼƬ����
  9427. break;
  9428. case 'qq':
  9429. shareData.desc = desc;
  9430. shareData.site = this.options.via;
  9431. shareData.pics = imgSrc[0];
  9432. // ץȡһ��ͼƬ
  9433. break;
  9434. case 'tqq':
  9435. // ץȡͼƬ����
  9436. shareData.pic = imgSrc.join('|');
  9437. break;
  9438. }
  9439. return shareData;
  9440. };
  9441. Share.prototype.shareTo = function(sns, data) {
  9442. var snsInfo = Share.SNS[sns];
  9443. if (!snsInfo) {
  9444. return;
  9445. }
  9446. if (sns === 'wechat' || sns === 'weixin') {
  9447. return this.wechatQr();
  9448. }
  9449. var query = [];
  9450. for (var key in data) {
  9451. if (data[key]) {
  9452. // ���� encode ͼƬ�ָ��� |
  9453. query.push(key.toString() + '=' + ((key === 'pic' || key === 'pics') ?
  9454. data[key] : encodeURIComponent(data[key])));
  9455. }
  9456. }
  9457. window.open(snsInfo.url + '?' + query.join('&'));
  9458. };
  9459. Share.prototype.wechatQr = function() {
  9460. if (!this.$wechatQr) {
  9461. var qrId = UI.utils.generateGUID('am-share-wechat');
  9462. var $qr = $('<div class="am-modal am-modal-no-btn am-share-wechat-qr">' +
  9463. '<div class="am-modal-dialog"><div class="am-modal-hd">����΢�� ' +
  9464. '<a href="" class="am-close am-close-spin" ' +
  9465. 'data-am-modal-close>&times;</a> </div>' +
  9466. '<div class="am-modal-bd">' +
  9467. '<div class="am-share-wx-qr"></div>' +
  9468. '<div class="am-share-wechat-tip">' +
  9469. '��΢�ţ�����ײ���<em>����</em>��<br/> ' +
  9470. 'ʹ��<em>ɨһɨ</em>����ҳ����������Ȧ</div></div></div></div>');
  9471. $qr.attr('id', qrId);
  9472. var qrNode = new QRCode({
  9473. render: 'canvas',
  9474. correctLevel: 0,
  9475. text: doc.location.href,
  9476. width: 180,
  9477. height: 180,
  9478. background: '#fff',
  9479. foreground: '#000'
  9480. });
  9481. $qr.find('.am-share-wx-qr').html(qrNode);
  9482. $qr.appendTo($('body'));
  9483. this.$wechatQr = $('#' + qrId);
  9484. }
  9485. this.$wechatQr.modal('open');
  9486. };
  9487. var share = new Share();
  9488. $doc.on('click.share.amui.data-api', '[data-am-toggle="share"]', function(e) {
  9489. e.preventDefault();
  9490. share.toggle();
  9491. });
  9492. module.exports = UI.share = share;
  9493. /***/ },
  9494. /* 26 */
  9495. /***/ function(module, exports, __webpack_require__) {
  9496. var $ = __webpack_require__(1);
  9497. var UI = __webpack_require__(2);
  9498. /**
  9499. * @ver 1.1.0
  9500. * @via https://github.com/aralejs/qrcode/blob/master/src/qrcode.js
  9501. * @license http://aralejs.org/
  9502. */
  9503. var qrcodeAlgObjCache = [];
  9504. /**
  9505. * ��ά�빹�캯������Ҫ���ڻ���
  9506. * @param {Object} opt ���ݲ���
  9507. * @return {String} qrcode
  9508. * @constructor
  9509. */
  9510. var QRCode = function(opt) {
  9511. if (typeof opt === 'string') { // ֻ����ASCII�ַ���
  9512. opt = {
  9513. text: opt
  9514. };
  9515. }
  9516. // ����Ĭ�ϲ���
  9517. this.options = $.extend({}, {
  9518. text: "",
  9519. render: "",
  9520. width: 256,
  9521. height: 256,
  9522. correctLevel: 3,
  9523. background: "#ffffff",
  9524. foreground: "#000000"
  9525. }, opt);
  9526. // ʹ��QRCodeAlg������ά��ṹ
  9527. var qrCodeAlg = null;
  9528. for (var i = 0, l = qrcodeAlgObjCache.length; i < l; i++) {
  9529. if (qrcodeAlgObjCache[i].text == this.options.text && qrcodeAlgObjCache[i].text.correctLevel == this.options.correctLevel) {
  9530. qrCodeAlg = qrcodeAlgObjCache[i].obj;
  9531. break;
  9532. }
  9533. }
  9534. if (i == l) {
  9535. qrCodeAlg = new QRCodeAlg(this.options.text, this.options.correctLevel);
  9536. qrcodeAlgObjCache.push({
  9537. text: this.options.text,
  9538. correctLevel: this.options.correctLevel,
  9539. obj: qrCodeAlg
  9540. });
  9541. }
  9542. if (this.options.render) {
  9543. switch (this.options.render) {
  9544. case "canvas":
  9545. return this.createCanvas(qrCodeAlg);
  9546. case "table":
  9547. return this.createTable(qrCodeAlg);
  9548. case "svg":
  9549. return this.createSVG(qrCodeAlg);
  9550. default:
  9551. return this.createDefault(qrCodeAlg);
  9552. }
  9553. }
  9554. return this.createDefault(qrCodeAlg);
  9555. };
  9556. /**
  9557. * ʹ��Canvas������ά��
  9558. * @return {}
  9559. */
  9560. QRCode.prototype.createDefault = function(qrCodeAlg) {
  9561. var canvas = document.createElement('canvas');
  9562. if (canvas.getContext)
  9563. return this.createCanvas(qrCodeAlg);
  9564. if (!!document.createElementNS && !!document.createElementNS(SVG_NS, 'svg').createSVGRect)
  9565. return this.createSVG(qrCodeAlg);
  9566. return this.createTable(qrCodeAlg);
  9567. };
  9568. QRCode.prototype.createCanvas = function(qrCodeAlg) {
  9569. //����canvas�ڵ�
  9570. var canvas = document.createElement('canvas');
  9571. canvas.width = this.options.width;
  9572. canvas.height = this.options.height;
  9573. var ctx = canvas.getContext('2d');
  9574. //����ÿ����ij���
  9575. var tileW = (this.options.width / qrCodeAlg.getModuleCount()).toPrecision(4);
  9576. var tileH = this.options.height / qrCodeAlg.getModuleCount().toPrecision(4);
  9577. //����
  9578. for (var row = 0; row < qrCodeAlg.getModuleCount(); row++) {
  9579. for (var col = 0; col < qrCodeAlg.getModuleCount(); col++) {
  9580. ctx.fillStyle = qrCodeAlg.modules[row][col] ? this.options.foreground : this.options.background;
  9581. var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
  9582. var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW));
  9583. ctx.fillRect(Math.round(col * tileW), Math.round(row * tileH), w, h);
  9584. }
  9585. }
  9586. //���ػ��ƵĽڵ�
  9587. return canvas;
  9588. };
  9589. /**
  9590. * ʹ��table�����ƶ�ά��
  9591. * @return {}
  9592. */
  9593. QRCode.prototype.createTable = function(qrCodeAlg) {
  9594. //����table�ڵ�
  9595. var s = [];
  9596. s.push('<table style="border:0px; margin:0px; padding:0px; border-collapse:collapse; background-color: ' +
  9597. this.options.background +
  9598. ';">');
  9599. // ����ÿ���ڵ�ij���ȡ������ֹ��֮����ַ���
  9600. var tileW = -1, tileH = -1, caculateW = -1, caculateH = -1;
  9601. tileW = caculateW = Math.floor(this.options.width / qrCodeAlg.getModuleCount());
  9602. tileH = caculateH = Math.floor(this.options.height / qrCodeAlg.getModuleCount());
  9603. if (caculateW <= 0) {
  9604. if (qrCodeAlg.getModuleCount() < 80) {
  9605. tileW = 2;
  9606. } else {
  9607. tileW = 1;
  9608. }
  9609. }
  9610. if (caculateH <= 0) {
  9611. if (qrCodeAlg.getModuleCount() < 80) {
  9612. tileH = 2;
  9613. } else {
  9614. tileH = 1;
  9615. }
  9616. }
  9617. // ���ƶ�ά��
  9618. foreTd = '<td style="border:0px; margin:0px; padding:0px; width:' + tileW + 'px; background-color: ' + this.options.foreground + '"></td>',
  9619. backTd = '<td style="border:0px; margin:0px; padding:0px; width:' + tileW + 'px; background-color: ' + this.options.background + '"></td>',
  9620. l = qrCodeAlg.getModuleCount();
  9621. for (var row = 0; row < l; row++) {
  9622. s.push('<tr style="border:0px; margin:0px; padding:0px; height: ' + tileH + 'px">');
  9623. for (var col = 0; col < l; col++) {
  9624. s.push(qrCodeAlg.modules[row][col] ? foreTd : backTd);
  9625. }
  9626. s.push('</tr>');
  9627. }
  9628. s.push('</table>');
  9629. var span = document.createElement("span");
  9630. span.innerHTML = s.join('');
  9631. return span.firstChild;
  9632. };
  9633. /**
  9634. * ʹ��SVG�����ƶ�ά��
  9635. * @return {}
  9636. */
  9637. QRCode.prototype.createSVG = function(qrCodeAlg) {
  9638. var x, dx, y, dy,
  9639. moduleCount = qrCodeAlg.getModuleCount(),
  9640. scale = this.options.height / this.options.width,
  9641. svg = '<svg xmlns="http://www.w3.org/2000/svg" '
  9642. + 'width="' + this.options.width + 'px" height="' + this.options.height + 'px" '
  9643. + 'viewbox="0 0 ' + moduleCount * 10 + ' ' + moduleCount * 10 * scale + '">',
  9644. rectHead = '<path ',
  9645. foreRect = ' style="stroke-width:0.5;stroke:' + this.options.foreground
  9646. + ';fill:' + this.options.foreground + ';"></path>',
  9647. backRect = ' style="stroke-width:0.5;stroke:' + this.options.background
  9648. + ';fill:' + this.options.background + ';"></path>';
  9649. // draw in the svg
  9650. for (var row = 0; row < moduleCount; row++) {
  9651. for (var col = 0; col < moduleCount; col++) {
  9652. x = col * 10;
  9653. y = row * 10 * scale;
  9654. dx = (col + 1) * 10;
  9655. dy = (row + 1) * 10 * scale;
  9656. svg += rectHead + 'd="M ' + x + ',' + y
  9657. + ' L ' + dx + ',' + y
  9658. + ' L ' + dx + ',' + dy
  9659. + ' L ' + x + ',' + dy
  9660. + ' Z"';
  9661. svg += qrCodeAlg.modules[row][col] ? foreRect : backRect;
  9662. }
  9663. }
  9664. svg += '</svg>';
  9665. // return just built svg
  9666. return $(svg)[0];
  9667. };
  9668. /**
  9669. * ��ȡ�����ַ���utf8����
  9670. * unicode BMPƽ��Լ65535���ַ�
  9671. * @param {num} code
  9672. * return {array}
  9673. */
  9674. function unicodeFormat8(code) {
  9675. // 1 byte
  9676. if (code < 128) {
  9677. return [code];
  9678. // 2 bytes
  9679. } else if (code < 2048) {
  9680. c0 = 192 + (code >> 6);
  9681. c1 = 128 + (code & 63);
  9682. return [c0, c1];
  9683. // 3 bytes
  9684. } else {
  9685. c0 = 224 + (code >> 12);
  9686. c1 = 128 + (code >> 6 & 63);
  9687. c2 = 128 + (code & 63);
  9688. return [c0, c1, c2];
  9689. }
  9690. }
  9691. /**
  9692. * ��ȡ�ַ�����utf8�����ֽڴ�
  9693. * @param {string} string
  9694. * @return {array}
  9695. */
  9696. function getUTF8Bytes(string) {
  9697. var utf8codes = [];
  9698. for (var i = 0; i < string.length; i++) {
  9699. var code = string.charCodeAt(i);
  9700. var utf8 = unicodeFormat8(code);
  9701. for (var j = 0; j < utf8.length; j++) {
  9702. utf8codes.push(utf8[j]);
  9703. }
  9704. }
  9705. return utf8codes;
  9706. }
  9707. /**
  9708. * ��ά���㷨ʵ��
  9709. * @param {string} data Ҫ�������Ϣ�ַ���
  9710. * @param {num} errorCorrectLevel ����ȼ�
  9711. */
  9712. function QRCodeAlg(data, errorCorrectLevel) {
  9713. this.typeNumber = -1; // �汾
  9714. this.errorCorrectLevel = errorCorrectLevel;
  9715. this.modules = null; // ��ά���󣬴�����ս��
  9716. this.moduleCount = 0; // �����С
  9717. this.dataCache = null; // ���ݻ���
  9718. this.rsBlocks = null; // �汾������Ϣ
  9719. this.totalDataCount = -1; // ��ʹ�õ�������
  9720. this.data = data;
  9721. this.utf8bytes = getUTF8Bytes(data);
  9722. this.make();
  9723. }
  9724. QRCodeAlg.prototype = {
  9725. constructor: QRCodeAlg,
  9726. /**
  9727. * ��ȡ��ά������С
  9728. * @return {num} �����С
  9729. */
  9730. getModuleCount: function() {
  9731. return this.moduleCount;
  9732. },
  9733. /**
  9734. * ����
  9735. */
  9736. make: function() {
  9737. this.getRightType();
  9738. this.dataCache = this.createData();
  9739. this.createQrcode();
  9740. },
  9741. /**
  9742. * ���ö�λ������ͼ��
  9743. * @param {bool} test ��ʾ�Ƿ���Ѱ�������Ĥ�׶�
  9744. * @param {num} maskPattern ��Ĥ�İ汾
  9745. */
  9746. makeImpl: function(maskPattern) {
  9747. this.moduleCount = this.typeNumber * 4 + 17;
  9748. this.modules = new Array(this.moduleCount);
  9749. for (var row = 0; row < this.moduleCount; row++) {
  9750. this.modules[row] = new Array(this.moduleCount);
  9751. }
  9752. this.setupPositionProbePattern(0, 0);
  9753. this.setupPositionProbePattern(this.moduleCount - 7, 0);
  9754. this.setupPositionProbePattern(0, this.moduleCount - 7);
  9755. this.setupPositionAdjustPattern();
  9756. this.setupTimingPattern();
  9757. this.setupTypeInfo(true, maskPattern);
  9758. if (this.typeNumber >= 7) {
  9759. this.setupTypeNumber(true);
  9760. }
  9761. this.mapData(this.dataCache, maskPattern);
  9762. },
  9763. /**
  9764. * ���ö�ά���λ��̽��ͼ��
  9765. * @param {num} row ̽��ͼ�ε����ĺ�����
  9766. * @param {num} col ̽��ͼ�ε�����������
  9767. */
  9768. setupPositionProbePattern: function(row, col) {
  9769. for (var r = -1; r <= 7; r++) {
  9770. if (row + r <= -1 || this.moduleCount <= row + r) continue;
  9771. for (var c = -1; c <= 7; c++) {
  9772. if (col + c <= -1 || this.moduleCount <= col + c) continue;
  9773. if ((0 <= r && r <= 6 && (c == 0 || c == 6)) || (0 <= c && c <= 6 && (r == 0 || r == 6)) || (2 <= r && r <= 4 && 2 <= c && c <= 4)) {
  9774. this.modules[row + r][col + c] = true;
  9775. } else {
  9776. this.modules[row + r][col + c] = false;
  9777. }
  9778. }
  9779. }
  9780. },
  9781. /**
  9782. * ��������
  9783. * @return {[type]} [description]
  9784. */
  9785. createQrcode: function() {
  9786. var minLostPoint = 0;
  9787. var pattern = 0;
  9788. var bestModules = null;
  9789. for (var i = 0; i < 8; i++) {
  9790. this.makeImpl(i);
  9791. var lostPoint = QRUtil.getLostPoint(this);
  9792. if (i == 0 || minLostPoint > lostPoint) {
  9793. minLostPoint = lostPoint;
  9794. pattern = i;
  9795. bestModules = this.modules;
  9796. }
  9797. }
  9798. this.modules = bestModules;
  9799. this.setupTypeInfo(false, pattern);
  9800. if (this.typeNumber >= 7) {
  9801. this.setupTypeNumber(false);
  9802. }
  9803. },
  9804. /**
  9805. * ���ö�λͼ��
  9806. * @return {[type]} [description]
  9807. */
  9808. setupTimingPattern: function() {
  9809. for (var r = 8; r < this.moduleCount - 8; r++) {
  9810. if (this.modules[r][6] != null) {
  9811. continue;
  9812. }
  9813. this.modules[r][6] = (r % 2 == 0);
  9814. if (this.modules[6][r] != null) {
  9815. continue;
  9816. }
  9817. this.modules[6][r] = (r % 2 == 0);
  9818. }
  9819. },
  9820. /**
  9821. * ���ý���ͼ��
  9822. * @return {[type]} [description]
  9823. */
  9824. setupPositionAdjustPattern: function() {
  9825. var pos = QRUtil.getPatternPosition(this.typeNumber);
  9826. for (var i = 0; i < pos.length; i++) {
  9827. for (var j = 0; j < pos.length; j++) {
  9828. var row = pos[i];
  9829. var col = pos[j];
  9830. if (this.modules[row][col] != null) {
  9831. continue;
  9832. }
  9833. for (var r = -2; r <= 2; r++) {
  9834. for (var c = -2; c <= 2; c++) {
  9835. if (r == -2 || r == 2 || c == -2 || c == 2 || (r == 0 && c == 0)) {
  9836. this.modules[row + r][col + c] = true;
  9837. } else {
  9838. this.modules[row + r][col + c] = false;
  9839. }
  9840. }
  9841. }
  9842. }
  9843. }
  9844. },
  9845. /**
  9846. * ���ð汾��Ϣ��7���ϰ汾���У�
  9847. * @param {bool} test �Ƿ����ж������Ĥ�׶�
  9848. * @return {[type]} [description]
  9849. */
  9850. setupTypeNumber: function(test) {
  9851. var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
  9852. for (var i = 0; i < 18; i++) {
  9853. var mod = (!test && ((bits >> i) & 1) == 1);
  9854. this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
  9855. this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
  9856. }
  9857. },
  9858. /**
  9859. * ���ø�ʽ��Ϣ������ȼ�����Ĥ�汾��
  9860. * @param {bool} test
  9861. * @param {num} maskPattern ��Ĥ�汾
  9862. * @return {}
  9863. */
  9864. setupTypeInfo: function(test, maskPattern) {
  9865. var data = (QRErrorCorrectLevel[this.errorCorrectLevel] << 3) | maskPattern;
  9866. var bits = QRUtil.getBCHTypeInfo(data);
  9867. // vertical
  9868. for (var i = 0; i < 15; i++) {
  9869. var mod = (!test && ((bits >> i) & 1) == 1);
  9870. if (i < 6) {
  9871. this.modules[i][8] = mod;
  9872. } else if (i < 8) {
  9873. this.modules[i + 1][8] = mod;
  9874. } else {
  9875. this.modules[this.moduleCount - 15 + i][8] = mod;
  9876. }
  9877. // horizontal
  9878. var mod = (!test && ((bits >> i) & 1) == 1);
  9879. if (i < 8) {
  9880. this.modules[8][this.moduleCount - i - 1] = mod;
  9881. } else if (i < 9) {
  9882. this.modules[8][15 - i - 1 + 1] = mod;
  9883. } else {
  9884. this.modules[8][15 - i - 1] = mod;
  9885. }
  9886. }
  9887. // fixed module
  9888. this.modules[this.moduleCount - 8][8] = (!test);
  9889. },
  9890. /**
  9891. * ���ݱ���
  9892. * @return {[type]} [description]
  9893. */
  9894. createData: function() {
  9895. var buffer = new QRBitBuffer();
  9896. var lengthBits = this.typeNumber > 9 ? 16 : 8;
  9897. buffer.put(4, 4); //���ģʽ
  9898. buffer.put(this.utf8bytes.length, lengthBits);
  9899. for (var i = 0, l = this.utf8bytes.length; i < l; i++) {
  9900. buffer.put(this.utf8bytes[i], 8);
  9901. }
  9902. if (buffer.length + 4 <= this.totalDataCount * 8) {
  9903. buffer.put(0, 4);
  9904. }
  9905. // padding
  9906. while (buffer.length % 8 != 0) {
  9907. buffer.putBit(false);
  9908. }
  9909. // padding
  9910. while (true) {
  9911. if (buffer.length >= this.totalDataCount * 8) {
  9912. break;
  9913. }
  9914. buffer.put(QRCodeAlg.PAD0, 8);
  9915. if (buffer.length >= this.totalDataCount * 8) {
  9916. break;
  9917. }
  9918. buffer.put(QRCodeAlg.PAD1, 8);
  9919. }
  9920. return this.createBytes(buffer);
  9921. },
  9922. /**
  9923. * ���������
  9924. * @param {buffer} buffer ���ݱ���
  9925. * @return {[type]}
  9926. */
  9927. createBytes: function(buffer) {
  9928. var offset = 0;
  9929. var maxDcCount = 0;
  9930. var maxEcCount = 0;
  9931. var length = this.rsBlock.length / 3;
  9932. var rsBlocks = new Array();
  9933. for (var i = 0; i < length; i++) {
  9934. var count = this.rsBlock[i * 3 + 0];
  9935. var totalCount = this.rsBlock[i * 3 + 1];
  9936. var dataCount = this.rsBlock[i * 3 + 2];
  9937. for (var j = 0; j < count; j++) {
  9938. rsBlocks.push([dataCount, totalCount]);
  9939. }
  9940. }
  9941. var dcdata = new Array(rsBlocks.length);
  9942. var ecdata = new Array(rsBlocks.length);
  9943. for (var r = 0; r < rsBlocks.length; r++) {
  9944. var dcCount = rsBlocks[r][0];
  9945. var ecCount = rsBlocks[r][1] - dcCount;
  9946. maxDcCount = Math.max(maxDcCount, dcCount);
  9947. maxEcCount = Math.max(maxEcCount, ecCount);
  9948. dcdata[r] = new Array(dcCount);
  9949. for (var i = 0; i < dcdata[r].length; i++) {
  9950. dcdata[r][i] = 0xff & buffer.buffer[i + offset];
  9951. }
  9952. offset += dcCount;
  9953. var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
  9954. var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
  9955. var modPoly = rawPoly.mod(rsPoly);
  9956. ecdata[r] = new Array(rsPoly.getLength() - 1);
  9957. for (var i = 0; i < ecdata[r].length; i++) {
  9958. var modIndex = i + modPoly.getLength() - ecdata[r].length;
  9959. ecdata[r][i] = (modIndex >= 0) ? modPoly.get(modIndex) : 0;
  9960. }
  9961. }
  9962. var data = new Array(this.totalDataCount);
  9963. var index = 0;
  9964. for (var i = 0; i < maxDcCount; i++) {
  9965. for (var r = 0; r < rsBlocks.length; r++) {
  9966. if (i < dcdata[r].length) {
  9967. data[index++] = dcdata[r][i];
  9968. }
  9969. }
  9970. }
  9971. for (var i = 0; i < maxEcCount; i++) {
  9972. for (var r = 0; r < rsBlocks.length; r++) {
  9973. if (i < ecdata[r].length) {
  9974. data[index++] = ecdata[r][i];
  9975. }
  9976. }
  9977. }
  9978. return data;
  9979. },
  9980. /**
  9981. * ����ģ�飬����������Ϣ
  9982. * @param {} data
  9983. * @param {} maskPattern
  9984. * @return {}
  9985. */
  9986. mapData: function(data, maskPattern) {
  9987. var inc = -1;
  9988. var row = this.moduleCount - 1;
  9989. var bitIndex = 7;
  9990. var byteIndex = 0;
  9991. for (var col = this.moduleCount - 1; col > 0; col -= 2) {
  9992. if (col == 6) col--;
  9993. while (true) {
  9994. for (var c = 0; c < 2; c++) {
  9995. if (this.modules[row][col - c] == null) {
  9996. var dark = false;
  9997. if (byteIndex < data.length) {
  9998. dark = (((data[byteIndex] >>> bitIndex) & 1) == 1);
  9999. }
  10000. var mask = QRUtil.getMask(maskPattern, row, col - c);
  10001. if (mask) {
  10002. dark = !dark;
  10003. }
  10004. this.modules[row][col - c] = dark;
  10005. bitIndex--;
  10006. if (bitIndex == -1) {
  10007. byteIndex++;
  10008. bitIndex = 7;
  10009. }
  10010. }
  10011. }
  10012. row += inc;
  10013. if (row < 0 || this.moduleCount <= row) {
  10014. row -= inc;
  10015. inc = -inc;
  10016. break;
  10017. }
  10018. }
  10019. }
  10020. }
  10021. };
  10022. /**
  10023. * ����ֶ�
  10024. */
  10025. QRCodeAlg.PAD0 = 0xEC;
  10026. QRCodeAlg.PAD1 = 0x11;
  10027. //---------------------------------------------------------------------
  10028. // ����ȼ���Ӧ�ı���
  10029. //---------------------------------------------------------------------
  10030. var QRErrorCorrectLevel = [1, 0, 3, 2];
  10031. //---------------------------------------------------------------------
  10032. // ��Ĥ�汾
  10033. //---------------------------------------------------------------------
  10034. var QRMaskPattern = {
  10035. PATTERN000: 0,
  10036. PATTERN001: 1,
  10037. PATTERN010: 2,
  10038. PATTERN011: 3,
  10039. PATTERN100: 4,
  10040. PATTERN101: 5,
  10041. PATTERN110: 6,
  10042. PATTERN111: 7
  10043. };
  10044. //---------------------------------------------------------------------
  10045. // ������
  10046. //---------------------------------------------------------------------
  10047. var QRUtil = {
  10048. /*
  10049. ÿ���汾����ͼ�ε�λ��
  10050. */
  10051. PATTERN_POSITION_TABLE: [
  10052. [],
  10053. [6, 18],
  10054. [6, 22],
  10055. [6, 26],
  10056. [6, 30],
  10057. [6, 34],
  10058. [6, 22, 38],
  10059. [6, 24, 42],
  10060. [6, 26, 46],
  10061. [6, 28, 50],
  10062. [6, 30, 54],
  10063. [6, 32, 58],
  10064. [6, 34, 62],
  10065. [6, 26, 46, 66],
  10066. [6, 26, 48, 70],
  10067. [6, 26, 50, 74],
  10068. [6, 30, 54, 78],
  10069. [6, 30, 56, 82],
  10070. [6, 30, 58, 86],
  10071. [6, 34, 62, 90],
  10072. [6, 28, 50, 72, 94],
  10073. [6, 26, 50, 74, 98],
  10074. [6, 30, 54, 78, 102],
  10075. [6, 28, 54, 80, 106],
  10076. [6, 32, 58, 84, 110],
  10077. [6, 30, 58, 86, 114],
  10078. [6, 34, 62, 90, 118],
  10079. [6, 26, 50, 74, 98, 122],
  10080. [6, 30, 54, 78, 102, 126],
  10081. [6, 26, 52, 78, 104, 130],
  10082. [6, 30, 56, 82, 108, 134],
  10083. [6, 34, 60, 86, 112, 138],
  10084. [6, 30, 58, 86, 114, 142],
  10085. [6, 34, 62, 90, 118, 146],
  10086. [6, 30, 54, 78, 102, 126, 150],
  10087. [6, 24, 50, 76, 102, 128, 154],
  10088. [6, 28, 54, 80, 106, 132, 158],
  10089. [6, 32, 58, 84, 110, 136, 162],
  10090. [6, 26, 54, 82, 110, 138, 166],
  10091. [6, 30, 58, 86, 114, 142, 170]
  10092. ],
  10093. G15: (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0),
  10094. G18: (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0),
  10095. G15_MASK: (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
  10096. /*
  10097. BCH�����ʽ��Ϣ
  10098. */
  10099. getBCHTypeInfo: function(data) {
  10100. var d = data << 10;
  10101. while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
  10102. d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15)));
  10103. }
  10104. return ((data << 10) | d) ^ QRUtil.G15_MASK;
  10105. },
  10106. /*
  10107. BCH����汾��Ϣ
  10108. */
  10109. getBCHTypeNumber: function(data) {
  10110. var d = data << 12;
  10111. while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
  10112. d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18)));
  10113. }
  10114. return (data << 12) | d;
  10115. },
  10116. /*
  10117. ��ȡBCHλ��Ϣ
  10118. */
  10119. getBCHDigit: function(data) {
  10120. var digit = 0;
  10121. while (data != 0) {
  10122. digit++;
  10123. data >>>= 1;
  10124. }
  10125. return digit;
  10126. },
  10127. /*
  10128. ��ȡ�汾��Ӧ�Ľ���ͼ��λ��
  10129. */
  10130. getPatternPosition: function(typeNumber) {
  10131. return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
  10132. },
  10133. /*
  10134. ��Ĥ�㷨
  10135. */
  10136. getMask: function(maskPattern, i, j) {
  10137. switch (maskPattern) {
  10138. case QRMaskPattern.PATTERN000:
  10139. return (i + j) % 2 == 0;
  10140. case QRMaskPattern.PATTERN001:
  10141. return i % 2 == 0;
  10142. case QRMaskPattern.PATTERN010:
  10143. return j % 3 == 0;
  10144. case QRMaskPattern.PATTERN011:
  10145. return (i + j) % 3 == 0;
  10146. case QRMaskPattern.PATTERN100:
  10147. return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
  10148. case QRMaskPattern.PATTERN101:
  10149. return (i * j) % 2 + (i * j) % 3 == 0;
  10150. case QRMaskPattern.PATTERN110:
  10151. return ((i * j) % 2 + (i * j) % 3) % 2 == 0;
  10152. case QRMaskPattern.PATTERN111:
  10153. return ((i * j) % 3 + (i + j) % 2) % 2 == 0;
  10154. default:
  10155. throw new Error("bad maskPattern:" + maskPattern);
  10156. }
  10157. },
  10158. /*
  10159. ��ȡRS�ľ������ʽ
  10160. */
  10161. getErrorCorrectPolynomial: function(errorCorrectLength) {
  10162. var a = new QRPolynomial([1], 0);
  10163. for (var i = 0; i < errorCorrectLength; i++) {
  10164. a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
  10165. }
  10166. return a;
  10167. },
  10168. /*
  10169. ��ȡ����
  10170. */
  10171. getLostPoint: function(qrCode) {
  10172. var moduleCount = qrCode.getModuleCount(),
  10173. lostPoint = 0,
  10174. darkCount = 0;
  10175. for (var row = 0; row < moduleCount; row++) {
  10176. var sameCount = 0;
  10177. var head = qrCode.modules[row][0];
  10178. for (var col = 0; col < moduleCount; col++) {
  10179. var current = qrCode.modules[row][col];
  10180. //level 3 ����
  10181. if (col < moduleCount - 6) {
  10182. if (current && !qrCode.modules[row][col + 1] && qrCode.modules[row][col + 2] && qrCode.modules[row][col + 3] && qrCode.modules[row][col + 4] && !qrCode.modules[row][col + 5] && qrCode.modules[row][col + 6]) {
  10183. if (col < moduleCount - 10) {
  10184. if (qrCode.modules[row][col + 7] && qrCode.modules[row][col + 8] && qrCode.modules[row][col + 9] && qrCode.modules[row][col + 10]) {
  10185. lostPoint += 40;
  10186. }
  10187. } else if (col > 3) {
  10188. if (qrCode.modules[row][col - 1] && qrCode.modules[row][col - 2] && qrCode.modules[row][col - 3] && qrCode.modules[row][col - 4]) {
  10189. lostPoint += 40;
  10190. }
  10191. }
  10192. }
  10193. }
  10194. //level 2 ����
  10195. if ((row < moduleCount - 1) && (col < moduleCount - 1)) {
  10196. var count = 0;
  10197. if (current) count++;
  10198. if (qrCode.modules[row + 1][col]) count++;
  10199. if (qrCode.modules[row][col + 1]) count++;
  10200. if (qrCode.modules[row + 1][col + 1]) count++;
  10201. if (count == 0 || count == 4) {
  10202. lostPoint += 3;
  10203. }
  10204. }
  10205. //level 1 ����
  10206. if (head ^ current) {
  10207. sameCount++;
  10208. } else {
  10209. head = current;
  10210. if (sameCount >= 5) {
  10211. lostPoint += (3 + sameCount - 5);
  10212. }
  10213. sameCount = 1;
  10214. }
  10215. //level 4 ����
  10216. if (current) {
  10217. darkCount++;
  10218. }
  10219. }
  10220. }
  10221. for (var col = 0; col < moduleCount; col++) {
  10222. var sameCount = 0;
  10223. var head = qrCode.modules[0][col];
  10224. for (var row = 0; row < moduleCount; row++) {
  10225. var current = qrCode.modules[row][col];
  10226. //level 3 ����
  10227. if (row < moduleCount - 6) {
  10228. if (current && !qrCode.modules[row + 1][col] && qrCode.modules[row + 2][col] && qrCode.modules[row + 3][col] && qrCode.modules[row + 4][col] && !qrCode.modules[row + 5][col] && qrCode.modules[row + 6][col]) {
  10229. if (row < moduleCount - 10) {
  10230. if (qrCode.modules[row + 7][col] && qrCode.modules[row + 8][col] && qrCode.modules[row + 9][col] && qrCode.modules[row + 10][col]) {
  10231. lostPoint += 40;
  10232. }
  10233. } else if (row > 3) {
  10234. if (qrCode.modules[row - 1][col] && qrCode.modules[row - 2][col] && qrCode.modules[row - 3][col] && qrCode.modules[row - 4][col]) {
  10235. lostPoint += 40;
  10236. }
  10237. }
  10238. }
  10239. }
  10240. //level 1 ����
  10241. if (head ^ current) {
  10242. sameCount++;
  10243. } else {
  10244. head = current;
  10245. if (sameCount >= 5) {
  10246. lostPoint += (3 + sameCount - 5);
  10247. }
  10248. sameCount = 1;
  10249. }
  10250. }
  10251. }
  10252. // LEVEL4
  10253. var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
  10254. lostPoint += ratio * 10;
  10255. return lostPoint;
  10256. }
  10257. };
  10258. //---------------------------------------------------------------------
  10259. // QRMathʹ�õ���ѧ����
  10260. //---------------------------------------------------------------------
  10261. var QRMath = {
  10262. /*
  10263. ��nת��Ϊa^m
  10264. */
  10265. glog: function(n) {
  10266. if (n < 1) {
  10267. throw new Error("glog(" + n + ")");
  10268. }
  10269. return QRMath.LOG_TABLE[n];
  10270. },
  10271. /*
  10272. ��a^mת��Ϊn
  10273. */
  10274. gexp: function(n) {
  10275. while (n < 0) {
  10276. n += 255;
  10277. }
  10278. while (n >= 256) {
  10279. n -= 255;
  10280. }
  10281. return QRMath.EXP_TABLE[n];
  10282. },
  10283. EXP_TABLE: new Array(256),
  10284. LOG_TABLE: new Array(256)
  10285. };
  10286. for (var i = 0; i < 8; i++) {
  10287. QRMath.EXP_TABLE[i] = 1 << i;
  10288. }
  10289. for (var i = 8; i < 256; i++) {
  10290. QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
  10291. }
  10292. for (var i = 0; i < 255; i++) {
  10293. QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
  10294. }
  10295. //---------------------------------------------------------------------
  10296. // QRPolynomial ����ʽ
  10297. //---------------------------------------------------------------------
  10298. /**
  10299. * ����ʽ��
  10300. * @param {Array} num ϵ��
  10301. * @param {num} shift a^shift
  10302. */
  10303. function QRPolynomial(num, shift) {
  10304. if (num.length == undefined) {
  10305. throw new Error(num.length + "/" + shift);
  10306. }
  10307. var offset = 0;
  10308. while (offset < num.length && num[offset] == 0) {
  10309. offset++;
  10310. }
  10311. this.num = new Array(num.length - offset + shift);
  10312. for (var i = 0; i < num.length - offset; i++) {
  10313. this.num[i] = num[i + offset];
  10314. }
  10315. }
  10316. QRPolynomial.prototype = {
  10317. get: function(index) {
  10318. return this.num[index];
  10319. },
  10320. getLength: function() {
  10321. return this.num.length;
  10322. },
  10323. /**
  10324. * ����ʽ�˷�
  10325. * @param {QRPolynomial} e ���˶���ʽ
  10326. * @return {[type]} [description]
  10327. */
  10328. multiply: function(e) {
  10329. var num = new Array(this.getLength() + e.getLength() - 1);
  10330. for (var i = 0; i < this.getLength(); i++) {
  10331. for (var j = 0; j < e.getLength(); j++) {
  10332. num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
  10333. }
  10334. }
  10335. return new QRPolynomial(num, 0);
  10336. },
  10337. /**
  10338. * ����ʽģ����
  10339. * @param {QRPolynomial} e ģ����ʽ
  10340. * @return {}
  10341. */
  10342. mod: function(e) {
  10343. var tl = this.getLength(),
  10344. el = e.getLength();
  10345. if (tl - el < 0) {
  10346. return this;
  10347. }
  10348. var num = new Array(tl);
  10349. for (var i = 0; i < tl; i++) {
  10350. num[i] = this.get(i);
  10351. }
  10352. while (num.length >= el) {
  10353. var ratio = QRMath.glog(num[0]) - QRMath.glog(e.get(0));
  10354. for (var i = 0; i < e.getLength(); i++) {
  10355. num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio);
  10356. }
  10357. while (num[0] == 0) {
  10358. num.shift();
  10359. }
  10360. }
  10361. return new QRPolynomial(num, 0);
  10362. }
  10363. };
  10364. //---------------------------------------------------------------------
  10365. // RS_BLOCK_TABLE
  10366. //---------------------------------------------------------------------
  10367. /*
  10368. ��ά������汾��Ϣ[����, ÿ���е����ݿ���, ÿ���е���Ϣ����]
  10369. */
  10370. var RS_BLOCK_TABLE = [
  10371. // L
  10372. // M
  10373. // Q
  10374. // H
  10375. // 1
  10376. [1, 26, 19],
  10377. [1, 26, 16],
  10378. [1, 26, 13],
  10379. [1, 26, 9],
  10380. // 2
  10381. [1, 44, 34],
  10382. [1, 44, 28],
  10383. [1, 44, 22],
  10384. [1, 44, 16],
  10385. // 3
  10386. [1, 70, 55],
  10387. [1, 70, 44],
  10388. [2, 35, 17],
  10389. [2, 35, 13],
  10390. // 4
  10391. [1, 100, 80],
  10392. [2, 50, 32],
  10393. [2, 50, 24],
  10394. [4, 25, 9],
  10395. // 5
  10396. [1, 134, 108],
  10397. [2, 67, 43],
  10398. [2, 33, 15, 2, 34, 16],
  10399. [2, 33, 11, 2, 34, 12],
  10400. // 6
  10401. [2, 86, 68],
  10402. [4, 43, 27],
  10403. [4, 43, 19],
  10404. [4, 43, 15],
  10405. // 7
  10406. [2, 98, 78],
  10407. [4, 49, 31],
  10408. [2, 32, 14, 4, 33, 15],
  10409. [4, 39, 13, 1, 40, 14],
  10410. // 8
  10411. [2, 121, 97],
  10412. [2, 60, 38, 2, 61, 39],
  10413. [4, 40, 18, 2, 41, 19],
  10414. [4, 40, 14, 2, 41, 15],
  10415. // 9
  10416. [2, 146, 116],
  10417. [3, 58, 36, 2, 59, 37],
  10418. [4, 36, 16, 4, 37, 17],
  10419. [4, 36, 12, 4, 37, 13],
  10420. // 10
  10421. [2, 86, 68, 2, 87, 69],
  10422. [4, 69, 43, 1, 70, 44],
  10423. [6, 43, 19, 2, 44, 20],
  10424. [6, 43, 15, 2, 44, 16],
  10425. // 11
  10426. [4, 101, 81],
  10427. [1, 80, 50, 4, 81, 51],
  10428. [4, 50, 22, 4, 51, 23],
  10429. [3, 36, 12, 8, 37, 13],
  10430. // 12
  10431. [2, 116, 92, 2, 117, 93],
  10432. [6, 58, 36, 2, 59, 37],
  10433. [4, 46, 20, 6, 47, 21],
  10434. [7, 42, 14, 4, 43, 15],
  10435. // 13
  10436. [4, 133, 107],
  10437. [8, 59, 37, 1, 60, 38],
  10438. [8, 44, 20, 4, 45, 21],
  10439. [12, 33, 11, 4, 34, 12],
  10440. // 14
  10441. [3, 145, 115, 1, 146, 116],
  10442. [4, 64, 40, 5, 65, 41],
  10443. [11, 36, 16, 5, 37, 17],
  10444. [11, 36, 12, 5, 37, 13],
  10445. // 15
  10446. [5, 109, 87, 1, 110, 88],
  10447. [5, 65, 41, 5, 66, 42],
  10448. [5, 54, 24, 7, 55, 25],
  10449. [11, 36, 12],
  10450. // 16
  10451. [5, 122, 98, 1, 123, 99],
  10452. [7, 73, 45, 3, 74, 46],
  10453. [15, 43, 19, 2, 44, 20],
  10454. [3, 45, 15, 13, 46, 16],
  10455. // 17
  10456. [1, 135, 107, 5, 136, 108],
  10457. [10, 74, 46, 1, 75, 47],
  10458. [1, 50, 22, 15, 51, 23],
  10459. [2, 42, 14, 17, 43, 15],
  10460. // 18
  10461. [5, 150, 120, 1, 151, 121],
  10462. [9, 69, 43, 4, 70, 44],
  10463. [17, 50, 22, 1, 51, 23],
  10464. [2, 42, 14, 19, 43, 15],
  10465. // 19
  10466. [3, 141, 113, 4, 142, 114],
  10467. [3, 70, 44, 11, 71, 45],
  10468. [17, 47, 21, 4, 48, 22],
  10469. [9, 39, 13, 16, 40, 14],
  10470. // 20
  10471. [3, 135, 107, 5, 136, 108],
  10472. [3, 67, 41, 13, 68, 42],
  10473. [15, 54, 24, 5, 55, 25],
  10474. [15, 43, 15, 10, 44, 16],
  10475. // 21
  10476. [4, 144, 116, 4, 145, 117],
  10477. [17, 68, 42],
  10478. [17, 50, 22, 6, 51, 23],
  10479. [19, 46, 16, 6, 47, 17],
  10480. // 22
  10481. [2, 139, 111, 7, 140, 112],
  10482. [17, 74, 46],
  10483. [7, 54, 24, 16, 55, 25],
  10484. [34, 37, 13],
  10485. // 23
  10486. [4, 151, 121, 5, 152, 122],
  10487. [4, 75, 47, 14, 76, 48],
  10488. [11, 54, 24, 14, 55, 25],
  10489. [16, 45, 15, 14, 46, 16],
  10490. // 24
  10491. [6, 147, 117, 4, 148, 118],
  10492. [6, 73, 45, 14, 74, 46],
  10493. [11, 54, 24, 16, 55, 25],
  10494. [30, 46, 16, 2, 47, 17],
  10495. // 25
  10496. [8, 132, 106, 4, 133, 107],
  10497. [8, 75, 47, 13, 76, 48],
  10498. [7, 54, 24, 22, 55, 25],
  10499. [22, 45, 15, 13, 46, 16],
  10500. // 26
  10501. [10, 142, 114, 2, 143, 115],
  10502. [19, 74, 46, 4, 75, 47],
  10503. [28, 50, 22, 6, 51, 23],
  10504. [33, 46, 16, 4, 47, 17],
  10505. // 27
  10506. [8, 152, 122, 4, 153, 123],
  10507. [22, 73, 45, 3, 74, 46],
  10508. [8, 53, 23, 26, 54, 24],
  10509. [12, 45, 15, 28, 46, 16],
  10510. // 28
  10511. [3, 147, 117, 10, 148, 118],
  10512. [3, 73, 45, 23, 74, 46],
  10513. [4, 54, 24, 31, 55, 25],
  10514. [11, 45, 15, 31, 46, 16],
  10515. // 29
  10516. [7, 146, 116, 7, 147, 117],
  10517. [21, 73, 45, 7, 74, 46],
  10518. [1, 53, 23, 37, 54, 24],
  10519. [19, 45, 15, 26, 46, 16],
  10520. // 30
  10521. [5, 145, 115, 10, 146, 116],
  10522. [19, 75, 47, 10, 76, 48],
  10523. [15, 54, 24, 25, 55, 25],
  10524. [23, 45, 15, 25, 46, 16],
  10525. // 31
  10526. [13, 145, 115, 3, 146, 116],
  10527. [2, 74, 46, 29, 75, 47],
  10528. [42, 54, 24, 1, 55, 25],
  10529. [23, 45, 15, 28, 46, 16],
  10530. // 32
  10531. [17, 145, 115],
  10532. [10, 74, 46, 23, 75, 47],
  10533. [10, 54, 24, 35, 55, 25],
  10534. [19, 45, 15, 35, 46, 16],
  10535. // 33
  10536. [17, 145, 115, 1, 146, 116],
  10537. [14, 74, 46, 21, 75, 47],
  10538. [29, 54, 24, 19, 55, 25],
  10539. [11, 45, 15, 46, 46, 16],
  10540. // 34
  10541. [13, 145, 115, 6, 146, 116],
  10542. [14, 74, 46, 23, 75, 47],
  10543. [44, 54, 24, 7, 55, 25],
  10544. [59, 46, 16, 1, 47, 17],
  10545. // 35
  10546. [12, 151, 121, 7, 152, 122],
  10547. [12, 75, 47, 26, 76, 48],
  10548. [39, 54, 24, 14, 55, 25],
  10549. [22, 45, 15, 41, 46, 16],
  10550. // 36
  10551. [6, 151, 121, 14, 152, 122],
  10552. [6, 75, 47, 34, 76, 48],
  10553. [46, 54, 24, 10, 55, 25],
  10554. [2, 45, 15, 64, 46, 16],
  10555. // 37
  10556. [17, 152, 122, 4, 153, 123],
  10557. [29, 74, 46, 14, 75, 47],
  10558. [49, 54, 24, 10, 55, 25],
  10559. [24, 45, 15, 46, 46, 16],
  10560. // 38
  10561. [4, 152, 122, 18, 153, 123],
  10562. [13, 74, 46, 32, 75, 47],
  10563. [48, 54, 24, 14, 55, 25],
  10564. [42, 45, 15, 32, 46, 16],
  10565. // 39
  10566. [20, 147, 117, 4, 148, 118],
  10567. [40, 75, 47, 7, 76, 48],
  10568. [43, 54, 24, 22, 55, 25],
  10569. [10, 45, 15, 67, 46, 16],
  10570. // 40
  10571. [19, 148, 118, 6, 149, 119],
  10572. [18, 75, 47, 31, 76, 48],
  10573. [34, 54, 24, 34, 55, 25],
  10574. [20, 45, 15, 61, 46, 16]
  10575. ];
  10576. /**
  10577. * �������ݻ�ȡ��Ӧ�汾
  10578. * @return {[type]} [description]
  10579. */
  10580. QRCodeAlg.prototype.getRightType = function() {
  10581. for (var typeNumber = 1; typeNumber < 41; typeNumber++) {
  10582. var rsBlock = RS_BLOCK_TABLE[(typeNumber - 1) * 4 + this.errorCorrectLevel];
  10583. if (rsBlock == undefined) {
  10584. throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + this.errorCorrectLevel);
  10585. }
  10586. var length = rsBlock.length / 3;
  10587. var totalDataCount = 0;
  10588. for (var i = 0; i < length; i++) {
  10589. var count = rsBlock[i * 3 + 0];
  10590. var dataCount = rsBlock[i * 3 + 2];
  10591. totalDataCount += dataCount * count;
  10592. }
  10593. var lengthBytes = typeNumber > 9 ? 2 : 1;
  10594. if (this.utf8bytes.length + lengthBytes < totalDataCount || typeNumber == 40) {
  10595. this.typeNumber = typeNumber;
  10596. this.rsBlock = rsBlock;
  10597. this.totalDataCount = totalDataCount;
  10598. break;
  10599. }
  10600. }
  10601. };
  10602. //---------------------------------------------------------------------
  10603. // QRBitBuffer
  10604. //---------------------------------------------------------------------
  10605. function QRBitBuffer() {
  10606. this.buffer = new Array();
  10607. this.length = 0;
  10608. }
  10609. QRBitBuffer.prototype = {
  10610. get: function(index) {
  10611. var bufIndex = Math.floor(index / 8);
  10612. return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1);
  10613. },
  10614. put: function(num, length) {
  10615. for (var i = 0; i < length; i++) {
  10616. this.putBit(((num >>> (length - i - 1)) & 1));
  10617. }
  10618. },
  10619. putBit: function(bit) {
  10620. var bufIndex = Math.floor(this.length / 8);
  10621. if (this.buffer.length <= bufIndex) {
  10622. this.buffer.push(0);
  10623. }
  10624. if (bit) {
  10625. this.buffer[bufIndex] |= (0x80 >>> (this.length % 8));
  10626. }
  10627. this.length++;
  10628. }
  10629. };
  10630. /**
  10631. * ��ȡ�����ַ���utf8����
  10632. * unicode BMPƽ��Լ65535���ַ�
  10633. * @param {num} code
  10634. * return {array}
  10635. */
  10636. function unicodeFormat8(code) {
  10637. // 1 byte
  10638. if (code < 128) {
  10639. return [code];
  10640. // 2 bytes
  10641. } else if (code < 2048) {
  10642. c0 = 192 + (code >> 6);
  10643. c1 = 128 + (code & 63);
  10644. return [c0, c1];
  10645. // 3 bytes
  10646. } else {
  10647. c0 = 224 + (code >> 12);
  10648. c1 = 128 + (code >> 6 & 63);
  10649. c2 = 128 + (code & 63);
  10650. return [c0, c1, c2];
  10651. }
  10652. }
  10653. /**
  10654. * ��ȡ�ַ�����utf8�����ֽڴ�
  10655. * @param {string} string
  10656. * @return {array}
  10657. */
  10658. function getUTF8Bytes(string) {
  10659. var utf8codes = [];
  10660. for (var i = 0; i < string.length; i++) {
  10661. var code = string.charCodeAt(i);
  10662. var utf8 = unicodeFormat8(code);
  10663. for (var j = 0; j < utf8.length; j++) {
  10664. utf8codes.push(utf8[j]);
  10665. }
  10666. }
  10667. return utf8codes;
  10668. }
  10669. /**
  10670. * ��ά���㷨ʵ��
  10671. * @param {string} data Ҫ�������Ϣ�ַ���
  10672. * @param {num} errorCorrectLevel ����ȼ�
  10673. */
  10674. function QRCodeAlg(data, errorCorrectLevel) {
  10675. this.typeNumber = -1; //�汾
  10676. this.errorCorrectLevel = errorCorrectLevel;
  10677. this.modules = null; //��ά���󣬴�����ս��
  10678. this.moduleCount = 0; //�����С
  10679. this.dataCache = null; //���ݻ���
  10680. this.rsBlocks = null; //�汾������Ϣ
  10681. this.totalDataCount = -1; //��ʹ�õ�������
  10682. this.data = data;
  10683. this.utf8bytes = getUTF8Bytes(data);
  10684. this.make();
  10685. }
  10686. QRCodeAlg.prototype = {
  10687. constructor: QRCodeAlg,
  10688. /**
  10689. * ��ȡ��ά������С
  10690. * @return {num} �����С
  10691. */
  10692. getModuleCount: function() {
  10693. return this.moduleCount;
  10694. },
  10695. /**
  10696. * ����
  10697. */
  10698. make: function() {
  10699. this.getRightType();
  10700. this.dataCache = this.createData();
  10701. this.createQrcode();
  10702. },
  10703. /**
  10704. * ���ö�λ������ͼ��
  10705. * @param {bool} test ��ʾ�Ƿ���Ѱ�������Ĥ�׶�
  10706. * @param {num} maskPattern ��Ĥ�İ汾
  10707. */
  10708. makeImpl: function(maskPattern) {
  10709. this.moduleCount = this.typeNumber * 4 + 17;
  10710. this.modules = new Array(this.moduleCount);
  10711. for (var row = 0; row < this.moduleCount; row++) {
  10712. this.modules[row] = new Array(this.moduleCount);
  10713. }
  10714. this.setupPositionProbePattern(0, 0);
  10715. this.setupPositionProbePattern(this.moduleCount - 7, 0);
  10716. this.setupPositionProbePattern(0, this.moduleCount - 7);
  10717. this.setupPositionAdjustPattern();
  10718. this.setupTimingPattern();
  10719. this.setupTypeInfo(true, maskPattern);
  10720. if (this.typeNumber >= 7) {
  10721. this.setupTypeNumber(true);
  10722. }
  10723. this.mapData(this.dataCache, maskPattern);
  10724. },
  10725. /**
  10726. * ���ö�ά���λ��̽��ͼ��
  10727. * @param {num} row ̽��ͼ�ε����ĺ�����
  10728. * @param {num} col ̽��ͼ�ε�����������
  10729. */
  10730. setupPositionProbePattern: function(row, col) {
  10731. for (var r = -1; r <= 7; r++) {
  10732. if (row + r <= -1 || this.moduleCount <= row + r) continue;
  10733. for (var c = -1; c <= 7; c++) {
  10734. if (col + c <= -1 || this.moduleCount <= col + c) continue;
  10735. if ((0 <= r && r <= 6 && (c == 0 || c == 6)) || (0 <= c && c <= 6 && (r == 0 || r == 6)) || (2 <= r && r <= 4 && 2 <= c && c <= 4)) {
  10736. this.modules[row + r][col + c] = true;
  10737. } else {
  10738. this.modules[row + r][col + c] = false;
  10739. }
  10740. }
  10741. }
  10742. },
  10743. /**
  10744. * ��������
  10745. * @return {[type]} [description]
  10746. */
  10747. createQrcode: function() {
  10748. var minLostPoint = 0;
  10749. var pattern = 0;
  10750. var bestModules = null;
  10751. for (var i = 0; i < 8; i++) {
  10752. this.makeImpl(i);
  10753. var lostPoint = QRUtil.getLostPoint(this);
  10754. if (i == 0 || minLostPoint > lostPoint) {
  10755. minLostPoint = lostPoint;
  10756. pattern = i;
  10757. bestModules = this.modules;
  10758. }
  10759. }
  10760. this.modules = bestModules;
  10761. this.setupTypeInfo(false, pattern);
  10762. if (this.typeNumber >= 7) {
  10763. this.setupTypeNumber(false);
  10764. }
  10765. },
  10766. /**
  10767. * ���ö�λͼ��
  10768. * @return {[type]} [description]
  10769. */
  10770. setupTimingPattern: function() {
  10771. for (var r = 8; r < this.moduleCount - 8; r++) {
  10772. if (this.modules[r][6] != null) {
  10773. continue;
  10774. }
  10775. this.modules[r][6] = (r % 2 == 0);
  10776. if (this.modules[6][r] != null) {
  10777. continue;
  10778. }
  10779. this.modules[6][r] = (r % 2 == 0);
  10780. }
  10781. },
  10782. /**
  10783. * ���ý���ͼ��
  10784. * @return {[type]} [description]
  10785. */
  10786. setupPositionAdjustPattern: function() {
  10787. var pos = QRUtil.getPatternPosition(this.typeNumber);
  10788. for (var i = 0; i < pos.length; i++) {
  10789. for (var j = 0; j < pos.length; j++) {
  10790. var row = pos[i];
  10791. var col = pos[j];
  10792. if (this.modules[row][col] != null) {
  10793. continue;
  10794. }
  10795. for (var r = -2; r <= 2; r++) {
  10796. for (var c = -2; c <= 2; c++) {
  10797. if (r == -2 || r == 2 || c == -2 || c == 2 || (r == 0 && c == 0)) {
  10798. this.modules[row + r][col + c] = true;
  10799. } else {
  10800. this.modules[row + r][col + c] = false;
  10801. }
  10802. }
  10803. }
  10804. }
  10805. }
  10806. },
  10807. /**
  10808. * ���ð汾��Ϣ��7���ϰ汾���У�
  10809. * @param {bool} test �Ƿ����ж������Ĥ�׶�
  10810. * @return {[type]} [description]
  10811. */
  10812. setupTypeNumber: function(test) {
  10813. var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
  10814. for (var i = 0; i < 18; i++) {
  10815. var mod = (!test && ((bits >> i) & 1) == 1);
  10816. this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
  10817. this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
  10818. }
  10819. },
  10820. /**
  10821. * ���ø�ʽ��Ϣ������ȼ�����Ĥ�汾��
  10822. * @param {bool} test
  10823. * @param {num} maskPattern ��Ĥ�汾
  10824. * @return {}
  10825. */
  10826. setupTypeInfo: function(test, maskPattern) {
  10827. var data = (QRErrorCorrectLevel[this.errorCorrectLevel] << 3) | maskPattern;
  10828. var bits = QRUtil.getBCHTypeInfo(data);
  10829. // vertical
  10830. for (var i = 0; i < 15; i++) {
  10831. var mod = (!test && ((bits >> i) & 1) == 1);
  10832. if (i < 6) {
  10833. this.modules[i][8] = mod;
  10834. } else if (i < 8) {
  10835. this.modules[i + 1][8] = mod;
  10836. } else {
  10837. this.modules[this.moduleCount - 15 + i][8] = mod;
  10838. }
  10839. // horizontal
  10840. var mod = (!test && ((bits >> i) & 1) == 1);
  10841. if (i < 8) {
  10842. this.modules[8][this.moduleCount - i - 1] = mod;
  10843. } else if (i < 9) {
  10844. this.modules[8][15 - i - 1 + 1] = mod;
  10845. } else {
  10846. this.modules[8][15 - i - 1] = mod;
  10847. }
  10848. }
  10849. // fixed module
  10850. this.modules[this.moduleCount - 8][8] = (!test);
  10851. },
  10852. /**
  10853. * ���ݱ���
  10854. * @return {[type]} [description]
  10855. */
  10856. createData: function() {
  10857. var buffer = new QRBitBuffer();
  10858. var lengthBits = this.typeNumber > 9 ? 16 : 8;
  10859. buffer.put(4, 4); //���ģʽ
  10860. buffer.put(this.utf8bytes.length, lengthBits);
  10861. for (var i = 0, l = this.utf8bytes.length; i < l; i++) {
  10862. buffer.put(this.utf8bytes[i], 8);
  10863. }
  10864. if (buffer.length + 4 <= this.totalDataCount * 8) {
  10865. buffer.put(0, 4);
  10866. }
  10867. // padding
  10868. while (buffer.length % 8 != 0) {
  10869. buffer.putBit(false);
  10870. }
  10871. // padding
  10872. while (true) {
  10873. if (buffer.length >= this.totalDataCount * 8) {
  10874. break;
  10875. }
  10876. buffer.put(QRCodeAlg.PAD0, 8);
  10877. if (buffer.length >= this.totalDataCount * 8) {
  10878. break;
  10879. }
  10880. buffer.put(QRCodeAlg.PAD1, 8);
  10881. }
  10882. return this.createBytes(buffer);
  10883. },
  10884. /**
  10885. * ���������
  10886. * @param {buffer} buffer ���ݱ���
  10887. * @return {[type]}
  10888. */
  10889. createBytes: function(buffer) {
  10890. var offset = 0;
  10891. var maxDcCount = 0;
  10892. var maxEcCount = 0;
  10893. var length = this.rsBlock.length / 3;
  10894. var rsBlocks = new Array();
  10895. for (var i = 0; i < length; i++) {
  10896. var count = this.rsBlock[i * 3 + 0];
  10897. var totalCount = this.rsBlock[i * 3 + 1];
  10898. var dataCount = this.rsBlock[i * 3 + 2];
  10899. for (var j = 0; j < count; j++) {
  10900. rsBlocks.push([dataCount, totalCount]);
  10901. }
  10902. }
  10903. var dcdata = new Array(rsBlocks.length);
  10904. var ecdata = new Array(rsBlocks.length);
  10905. for (var r = 0; r < rsBlocks.length; r++) {
  10906. var dcCount = rsBlocks[r][0];
  10907. var ecCount = rsBlocks[r][1] - dcCount;
  10908. maxDcCount = Math.max(maxDcCount, dcCount);
  10909. maxEcCount = Math.max(maxEcCount, ecCount);
  10910. dcdata[r] = new Array(dcCount);
  10911. for (var i = 0; i < dcdata[r].length; i++) {
  10912. dcdata[r][i] = 0xff & buffer.buffer[i + offset];
  10913. }
  10914. offset += dcCount;
  10915. var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
  10916. var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
  10917. var modPoly = rawPoly.mod(rsPoly);
  10918. ecdata[r] = new Array(rsPoly.getLength() - 1);
  10919. for (var i = 0; i < ecdata[r].length; i++) {
  10920. var modIndex = i + modPoly.getLength() - ecdata[r].length;
  10921. ecdata[r][i] = (modIndex >= 0) ? modPoly.get(modIndex) : 0;
  10922. }
  10923. }
  10924. var data = new Array(this.totalDataCount);
  10925. var index = 0;
  10926. for (var i = 0; i < maxDcCount; i++) {
  10927. for (var r = 0; r < rsBlocks.length; r++) {
  10928. if (i < dcdata[r].length) {
  10929. data[index++] = dcdata[r][i];
  10930. }
  10931. }
  10932. }
  10933. for (var i = 0; i < maxEcCount; i++) {
  10934. for (var r = 0; r < rsBlocks.length; r++) {
  10935. if (i < ecdata[r].length) {
  10936. data[index++] = ecdata[r][i];
  10937. }
  10938. }
  10939. }
  10940. return data;
  10941. },
  10942. /**
  10943. * ����ģ�飬����������Ϣ
  10944. * @param {} data
  10945. * @param {} maskPattern
  10946. * @return {}
  10947. */
  10948. mapData: function(data, maskPattern) {
  10949. var inc = -1;
  10950. var row = this.moduleCount - 1;
  10951. var bitIndex = 7;
  10952. var byteIndex = 0;
  10953. for (var col = this.moduleCount - 1; col > 0; col -= 2) {
  10954. if (col == 6) col--;
  10955. while (true) {
  10956. for (var c = 0; c < 2; c++) {
  10957. if (this.modules[row][col - c] == null) {
  10958. var dark = false;
  10959. if (byteIndex < data.length) {
  10960. dark = (((data[byteIndex] >>> bitIndex) & 1) == 1);
  10961. }
  10962. var mask = QRUtil.getMask(maskPattern, row, col - c);
  10963. if (mask) {
  10964. dark = !dark;
  10965. }
  10966. this.modules[row][col - c] = dark;
  10967. bitIndex--;
  10968. if (bitIndex == -1) {
  10969. byteIndex++;
  10970. bitIndex = 7;
  10971. }
  10972. }
  10973. }
  10974. row += inc;
  10975. if (row < 0 || this.moduleCount <= row) {
  10976. row -= inc;
  10977. inc = -inc;
  10978. break;
  10979. }
  10980. }
  10981. }
  10982. }
  10983. };
  10984. /**
  10985. * ����ֶ�
  10986. */
  10987. QRCodeAlg.PAD0 = 0xEC;
  10988. QRCodeAlg.PAD1 = 0x11;
  10989. //---------------------------------------------------------------------
  10990. // ����ȼ���Ӧ�ı���
  10991. //---------------------------------------------------------------------
  10992. var QRErrorCorrectLevel = [1, 0, 3, 2];
  10993. //---------------------------------------------------------------------
  10994. // ��Ĥ�汾
  10995. //---------------------------------------------------------------------
  10996. var QRMaskPattern = {
  10997. PATTERN000: 0,
  10998. PATTERN001: 1,
  10999. PATTERN010: 2,
  11000. PATTERN011: 3,
  11001. PATTERN100: 4,
  11002. PATTERN101: 5,
  11003. PATTERN110: 6,
  11004. PATTERN111: 7
  11005. };
  11006. //---------------------------------------------------------------------
  11007. // ������
  11008. //---------------------------------------------------------------------
  11009. var QRUtil = {
  11010. /*
  11011. ÿ���汾����ͼ�ε�λ��
  11012. */
  11013. PATTERN_POSITION_TABLE: [
  11014. [],
  11015. [6, 18],
  11016. [6, 22],
  11017. [6, 26],
  11018. [6, 30],
  11019. [6, 34],
  11020. [6, 22, 38],
  11021. [6, 24, 42],
  11022. [6, 26, 46],
  11023. [6, 28, 50],
  11024. [6, 30, 54],
  11025. [6, 32, 58],
  11026. [6, 34, 62],
  11027. [6, 26, 46, 66],
  11028. [6, 26, 48, 70],
  11029. [6, 26, 50, 74],
  11030. [6, 30, 54, 78],
  11031. [6, 30, 56, 82],
  11032. [6, 30, 58, 86],
  11033. [6, 34, 62, 90],
  11034. [6, 28, 50, 72, 94],
  11035. [6, 26, 50, 74, 98],
  11036. [6, 30, 54, 78, 102],
  11037. [6, 28, 54, 80, 106],
  11038. [6, 32, 58, 84, 110],
  11039. [6, 30, 58, 86, 114],
  11040. [6, 34, 62, 90, 118],
  11041. [6, 26, 50, 74, 98, 122],
  11042. [6, 30, 54, 78, 102, 126],
  11043. [6, 26, 52, 78, 104, 130],
  11044. [6, 30, 56, 82, 108, 134],
  11045. [6, 34, 60, 86, 112, 138],
  11046. [6, 30, 58, 86, 114, 142],
  11047. [6, 34, 62, 90, 118, 146],
  11048. [6, 30, 54, 78, 102, 126, 150],
  11049. [6, 24, 50, 76, 102, 128, 154],
  11050. [6, 28, 54, 80, 106, 132, 158],
  11051. [6, 32, 58, 84, 110, 136, 162],
  11052. [6, 26, 54, 82, 110, 138, 166],
  11053. [6, 30, 58, 86, 114, 142, 170]
  11054. ],
  11055. G15: (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0),
  11056. G18: (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0),
  11057. G15_MASK: (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
  11058. /*
  11059. BCH�����ʽ��Ϣ
  11060. */
  11061. getBCHTypeInfo: function(data) {
  11062. var d = data << 10;
  11063. while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
  11064. d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15)));
  11065. }
  11066. return ((data << 10) | d) ^ QRUtil.G15_MASK;
  11067. },
  11068. /*
  11069. BCH����汾��Ϣ
  11070. */
  11071. getBCHTypeNumber: function(data) {
  11072. var d = data << 12;
  11073. while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
  11074. d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18)));
  11075. }
  11076. return (data << 12) | d;
  11077. },
  11078. /*
  11079. ��ȡBCHλ��Ϣ
  11080. */
  11081. getBCHDigit: function(data) {
  11082. var digit = 0;
  11083. while (data != 0) {
  11084. digit++;
  11085. data >>>= 1;
  11086. }
  11087. return digit;
  11088. },
  11089. /*
  11090. ��ȡ�汾��Ӧ�Ľ���ͼ��λ��
  11091. */
  11092. getPatternPosition: function(typeNumber) {
  11093. return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
  11094. },
  11095. /*
  11096. ��Ĥ�㷨
  11097. */
  11098. getMask: function(maskPattern, i, j) {
  11099. switch (maskPattern) {
  11100. case QRMaskPattern.PATTERN000:
  11101. return (i + j) % 2 == 0;
  11102. case QRMaskPattern.PATTERN001:
  11103. return i % 2 == 0;
  11104. case QRMaskPattern.PATTERN010:
  11105. return j % 3 == 0;
  11106. case QRMaskPattern.PATTERN011:
  11107. return (i + j) % 3 == 0;
  11108. case QRMaskPattern.PATTERN100:
  11109. return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
  11110. case QRMaskPattern.PATTERN101:
  11111. return (i * j) % 2 + (i * j) % 3 == 0;
  11112. case QRMaskPattern.PATTERN110:
  11113. return ((i * j) % 2 + (i * j) % 3) % 2 == 0;
  11114. case QRMaskPattern.PATTERN111:
  11115. return ((i * j) % 3 + (i + j) % 2) % 2 == 0;
  11116. default:
  11117. throw new Error("bad maskPattern:" + maskPattern);
  11118. }
  11119. },
  11120. /*
  11121. ��ȡRS�ľ������ʽ
  11122. */
  11123. getErrorCorrectPolynomial: function(errorCorrectLength) {
  11124. var a = new QRPolynomial([1], 0);
  11125. for (var i = 0; i < errorCorrectLength; i++) {
  11126. a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
  11127. }
  11128. return a;
  11129. },
  11130. /*
  11131. ��ȡ����
  11132. */
  11133. getLostPoint: function(qrCode) {
  11134. var moduleCount = qrCode.getModuleCount(),
  11135. lostPoint = 0,
  11136. darkCount = 0;
  11137. for (var row = 0; row < moduleCount; row++) {
  11138. var sameCount = 0;
  11139. var head = qrCode.modules[row][0];
  11140. for (var col = 0; col < moduleCount; col++) {
  11141. var current = qrCode.modules[row][col];
  11142. //level 3 ����
  11143. if (col < moduleCount - 6) {
  11144. if (current && !qrCode.modules[row][col + 1] && qrCode.modules[row][col + 2] && qrCode.modules[row][col + 3] && qrCode.modules[row][col + 4] && !qrCode.modules[row][col + 5] && qrCode.modules[row][col + 6]) {
  11145. if (col < moduleCount - 10) {
  11146. if (qrCode.modules[row][col + 7] && qrCode.modules[row][col + 8] && qrCode.modules[row][col + 9] && qrCode.modules[row][col + 10]) {
  11147. lostPoint += 40;
  11148. }
  11149. } else if (col > 3) {
  11150. if (qrCode.modules[row][col - 1] && qrCode.modules[row][col - 2] && qrCode.modules[row][col - 3] && qrCode.modules[row][col - 4]) {
  11151. lostPoint += 40;
  11152. }
  11153. }
  11154. }
  11155. }
  11156. //level 2 ����
  11157. if ((row < moduleCount - 1) && (col < moduleCount - 1)) {
  11158. var count = 0;
  11159. if (current) count++;
  11160. if (qrCode.modules[row + 1][col]) count++;
  11161. if (qrCode.modules[row][col + 1]) count++;
  11162. if (qrCode.modules[row + 1][col + 1]) count++;
  11163. if (count == 0 || count == 4) {
  11164. lostPoint += 3;
  11165. }
  11166. }
  11167. //level 1 ����
  11168. if (head ^ current) {
  11169. sameCount++;
  11170. } else {
  11171. head = current;
  11172. if (sameCount >= 5) {
  11173. lostPoint += (3 + sameCount - 5);
  11174. }
  11175. sameCount = 1;
  11176. }
  11177. //level 4 ����
  11178. if (current) {
  11179. darkCount++;
  11180. }
  11181. }
  11182. }
  11183. for (var col = 0; col < moduleCount; col++) {
  11184. var sameCount = 0;
  11185. var head = qrCode.modules[0][col];
  11186. for (var row = 0; row < moduleCount; row++) {
  11187. var current = qrCode.modules[row][col];
  11188. //level 3 ����
  11189. if (row < moduleCount - 6) {
  11190. if (current && !qrCode.modules[row + 1][col] && qrCode.modules[row + 2][col] && qrCode.modules[row + 3][col] && qrCode.modules[row + 4][col] && !qrCode.modules[row + 5][col] && qrCode.modules[row + 6][col]) {
  11191. if (row < moduleCount - 10) {
  11192. if (qrCode.modules[row + 7][col] && qrCode.modules[row + 8][col] && qrCode.modules[row + 9][col] && qrCode.modules[row + 10][col]) {
  11193. lostPoint += 40;
  11194. }
  11195. } else if (row > 3) {
  11196. if (qrCode.modules[row - 1][col] && qrCode.modules[row - 2][col] && qrCode.modules[row - 3][col] && qrCode.modules[row - 4][col]) {
  11197. lostPoint += 40;
  11198. }
  11199. }
  11200. }
  11201. }
  11202. //level 1 ����
  11203. if (head ^ current) {
  11204. sameCount++;
  11205. } else {
  11206. head = current;
  11207. if (sameCount >= 5) {
  11208. lostPoint += (3 + sameCount - 5);
  11209. }
  11210. sameCount = 1;
  11211. }
  11212. }
  11213. }
  11214. // LEVEL4
  11215. var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
  11216. lostPoint += ratio * 10;
  11217. return lostPoint;
  11218. }
  11219. };
  11220. //---------------------------------------------------------------------
  11221. // QRMathʹ�õ���ѧ����
  11222. //---------------------------------------------------------------------
  11223. var QRMath = {
  11224. /*
  11225. ��nת��Ϊa^m
  11226. */
  11227. glog: function(n) {
  11228. if (n < 1) {
  11229. throw new Error("glog(" + n + ")");
  11230. }
  11231. return QRMath.LOG_TABLE[n];
  11232. },
  11233. /*
  11234. ��a^mת��Ϊn
  11235. */
  11236. gexp: function(n) {
  11237. while (n < 0) {
  11238. n += 255;
  11239. }
  11240. while (n >= 256) {
  11241. n -= 255;
  11242. }
  11243. return QRMath.EXP_TABLE[n];
  11244. },
  11245. EXP_TABLE: new Array(256),
  11246. LOG_TABLE: new Array(256)
  11247. };
  11248. for (var i = 0; i < 8; i++) {
  11249. QRMath.EXP_TABLE[i] = 1 << i;
  11250. }
  11251. for (var i = 8; i < 256; i++) {
  11252. QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
  11253. }
  11254. for (var i = 0; i < 255; i++) {
  11255. QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
  11256. }
  11257. //---------------------------------------------------------------------
  11258. // QRPolynomial ����ʽ
  11259. //---------------------------------------------------------------------
  11260. /**
  11261. * ����ʽ��
  11262. * @param {Array} num ϵ��
  11263. * @param {num} shift a^shift
  11264. */
  11265. function QRPolynomial(num, shift) {
  11266. if (num.length == undefined) {
  11267. throw new Error(num.length + "/" + shift);
  11268. }
  11269. var offset = 0;
  11270. while (offset < num.length && num[offset] == 0) {
  11271. offset++;
  11272. }
  11273. this.num = new Array(num.length - offset + shift);
  11274. for (var i = 0; i < num.length - offset; i++) {
  11275. this.num[i] = num[i + offset];
  11276. }
  11277. }
  11278. QRPolynomial.prototype = {
  11279. get: function(index) {
  11280. return this.num[index];
  11281. },
  11282. getLength: function() {
  11283. return this.num.length;
  11284. },
  11285. /**
  11286. * ����ʽ�˷�
  11287. * @param {QRPolynomial} e ���˶���ʽ
  11288. * @return {[type]} [description]
  11289. */
  11290. multiply: function(e) {
  11291. var num = new Array(this.getLength() + e.getLength() - 1);
  11292. for (var i = 0; i < this.getLength(); i++) {
  11293. for (var j = 0; j < e.getLength(); j++) {
  11294. num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
  11295. }
  11296. }
  11297. return new QRPolynomial(num, 0);
  11298. },
  11299. /**
  11300. * ����ʽģ����
  11301. * @param {QRPolynomial} e ģ����ʽ
  11302. * @return {}
  11303. */
  11304. mod: function(e) {
  11305. var tl = this.getLength(),
  11306. el = e.getLength();
  11307. if (tl - el < 0) {
  11308. return this;
  11309. }
  11310. var num = new Array(tl);
  11311. for (var i = 0; i < tl; i++) {
  11312. num[i] = this.get(i);
  11313. }
  11314. while (num.length >= el) {
  11315. var ratio = QRMath.glog(num[0]) - QRMath.glog(e.get(0));
  11316. for (var i = 0; i < e.getLength(); i++) {
  11317. num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio);
  11318. }
  11319. while (num[0] == 0) {
  11320. num.shift();
  11321. }
  11322. }
  11323. return new QRPolynomial(num, 0);
  11324. }
  11325. };
  11326. //---------------------------------------------------------------------
  11327. // RS_BLOCK_TABLE
  11328. //---------------------------------------------------------------------
  11329. /*
  11330. ��ά������汾��Ϣ[����, ÿ���е����ݿ���, ÿ���е���Ϣ����]
  11331. */
  11332. RS_BLOCK_TABLE = [
  11333. // L
  11334. // M
  11335. // Q
  11336. // H
  11337. // 1
  11338. [1, 26, 19],
  11339. [1, 26, 16],
  11340. [1, 26, 13],
  11341. [1, 26, 9],
  11342. // 2
  11343. [1, 44, 34],
  11344. [1, 44, 28],
  11345. [1, 44, 22],
  11346. [1, 44, 16],
  11347. // 3
  11348. [1, 70, 55],
  11349. [1, 70, 44],
  11350. [2, 35, 17],
  11351. [2, 35, 13],
  11352. // 4
  11353. [1, 100, 80],
  11354. [2, 50, 32],
  11355. [2, 50, 24],
  11356. [4, 25, 9],
  11357. // 5
  11358. [1, 134, 108],
  11359. [2, 67, 43],
  11360. [2, 33, 15, 2, 34, 16],
  11361. [2, 33, 11, 2, 34, 12],
  11362. // 6
  11363. [2, 86, 68],
  11364. [4, 43, 27],
  11365. [4, 43, 19],
  11366. [4, 43, 15],
  11367. // 7
  11368. [2, 98, 78],
  11369. [4, 49, 31],
  11370. [2, 32, 14, 4, 33, 15],
  11371. [4, 39, 13, 1, 40, 14],
  11372. // 8
  11373. [2, 121, 97],
  11374. [2, 60, 38, 2, 61, 39],
  11375. [4, 40, 18, 2, 41, 19],
  11376. [4, 40, 14, 2, 41, 15],
  11377. // 9
  11378. [2, 146, 116],
  11379. [3, 58, 36, 2, 59, 37],
  11380. [4, 36, 16, 4, 37, 17],
  11381. [4, 36, 12, 4, 37, 13],
  11382. // 10
  11383. [2, 86, 68, 2, 87, 69],
  11384. [4, 69, 43, 1, 70, 44],
  11385. [6, 43, 19, 2, 44, 20],
  11386. [6, 43, 15, 2, 44, 16],
  11387. // 11
  11388. [4, 101, 81],
  11389. [1, 80, 50, 4, 81, 51],
  11390. [4, 50, 22, 4, 51, 23],
  11391. [3, 36, 12, 8, 37, 13],
  11392. // 12
  11393. [2, 116, 92, 2, 117, 93],
  11394. [6, 58, 36, 2, 59, 37],
  11395. [4, 46, 20, 6, 47, 21],
  11396. [7, 42, 14, 4, 43, 15],
  11397. // 13
  11398. [4, 133, 107],
  11399. [8, 59, 37, 1, 60, 38],
  11400. [8, 44, 20, 4, 45, 21],
  11401. [12, 33, 11, 4, 34, 12],
  11402. // 14
  11403. [3, 145, 115, 1, 146, 116],
  11404. [4, 64, 40, 5, 65, 41],
  11405. [11, 36, 16, 5, 37, 17],
  11406. [11, 36, 12, 5, 37, 13],
  11407. // 15
  11408. [5, 109, 87, 1, 110, 88],
  11409. [5, 65, 41, 5, 66, 42],
  11410. [5, 54, 24, 7, 55, 25],
  11411. [11, 36, 12],
  11412. // 16
  11413. [5, 122, 98, 1, 123, 99],
  11414. [7, 73, 45, 3, 74, 46],
  11415. [15, 43, 19, 2, 44, 20],
  11416. [3, 45, 15, 13, 46, 16],
  11417. // 17
  11418. [1, 135, 107, 5, 136, 108],
  11419. [10, 74, 46, 1, 75, 47],
  11420. [1, 50, 22, 15, 51, 23],
  11421. [2, 42, 14, 17, 43, 15],
  11422. // 18
  11423. [5, 150, 120, 1, 151, 121],
  11424. [9, 69, 43, 4, 70, 44],
  11425. [17, 50, 22, 1, 51, 23],
  11426. [2, 42, 14, 19, 43, 15],
  11427. // 19
  11428. [3, 141, 113, 4, 142, 114],
  11429. [3, 70, 44, 11, 71, 45],
  11430. [17, 47, 21, 4, 48, 22],
  11431. [9, 39, 13, 16, 40, 14],
  11432. // 20
  11433. [3, 135, 107, 5, 136, 108],
  11434. [3, 67, 41, 13, 68, 42],
  11435. [15, 54, 24, 5, 55, 25],
  11436. [15, 43, 15, 10, 44, 16],
  11437. // 21
  11438. [4, 144, 116, 4, 145, 117],
  11439. [17, 68, 42],
  11440. [17, 50, 22, 6, 51, 23],
  11441. [19, 46, 16, 6, 47, 17],
  11442. // 22
  11443. [2, 139, 111, 7, 140, 112],
  11444. [17, 74, 46],
  11445. [7, 54, 24, 16, 55, 25],
  11446. [34, 37, 13],
  11447. // 23
  11448. [4, 151, 121, 5, 152, 122],
  11449. [4, 75, 47, 14, 76, 48],
  11450. [11, 54, 24, 14, 55, 25],
  11451. [16, 45, 15, 14, 46, 16],
  11452. // 24
  11453. [6, 147, 117, 4, 148, 118],
  11454. [6, 73, 45, 14, 74, 46],
  11455. [11, 54, 24, 16, 55, 25],
  11456. [30, 46, 16, 2, 47, 17],
  11457. // 25
  11458. [8, 132, 106, 4, 133, 107],
  11459. [8, 75, 47, 13, 76, 48],
  11460. [7, 54, 24, 22, 55, 25],
  11461. [22, 45, 15, 13, 46, 16],
  11462. // 26
  11463. [10, 142, 114, 2, 143, 115],
  11464. [19, 74, 46, 4, 75, 47],
  11465. [28, 50, 22, 6, 51, 23],
  11466. [33, 46, 16, 4, 47, 17],
  11467. // 27
  11468. [8, 152, 122, 4, 153, 123],
  11469. [22, 73, 45, 3, 74, 46],
  11470. [8, 53, 23, 26, 54, 24],
  11471. [12, 45, 15, 28, 46, 16],
  11472. // 28
  11473. [3, 147, 117, 10, 148, 118],
  11474. [3, 73, 45, 23, 74, 46],
  11475. [4, 54, 24, 31, 55, 25],
  11476. [11, 45, 15, 31, 46, 16],
  11477. // 29
  11478. [7, 146, 116, 7, 147, 117],
  11479. [21, 73, 45, 7, 74, 46],
  11480. [1, 53, 23, 37, 54, 24],
  11481. [19, 45, 15, 26, 46, 16],
  11482. // 30
  11483. [5, 145, 115, 10, 146, 116],
  11484. [19, 75, 47, 10, 76, 48],
  11485. [15, 54, 24, 25, 55, 25],
  11486. [23, 45, 15, 25, 46, 16],
  11487. // 31
  11488. [13, 145, 115, 3, 146, 116],
  11489. [2, 74, 46, 29, 75, 47],
  11490. [42, 54, 24, 1, 55, 25],
  11491. [23, 45, 15, 28, 46, 16],
  11492. // 32
  11493. [17, 145, 115],
  11494. [10, 74, 46, 23, 75, 47],
  11495. [10, 54, 24, 35, 55, 25],
  11496. [19, 45, 15, 35, 46, 16],
  11497. // 33
  11498. [17, 145, 115, 1, 146, 116],
  11499. [14, 74, 46, 21, 75, 47],
  11500. [29, 54, 24, 19, 55, 25],
  11501. [11, 45, 15, 46, 46, 16],
  11502. // 34
  11503. [13, 145, 115, 6, 146, 116],
  11504. [14, 74, 46, 23, 75, 47],
  11505. [44, 54, 24, 7, 55, 25],
  11506. [59, 46, 16, 1, 47, 17],
  11507. // 35
  11508. [12, 151, 121, 7, 152, 122],
  11509. [12, 75, 47, 26, 76, 48],
  11510. [39, 54, 24, 14, 55, 25],
  11511. [22, 45, 15, 41, 46, 16],
  11512. // 36
  11513. [6, 151, 121, 14, 152, 122],
  11514. [6, 75, 47, 34, 76, 48],
  11515. [46, 54, 24, 10, 55, 25],
  11516. [2, 45, 15, 64, 46, 16],
  11517. // 37
  11518. [17, 152, 122, 4, 153, 123],
  11519. [29, 74, 46, 14, 75, 47],
  11520. [49, 54, 24, 10, 55, 25],
  11521. [24, 45, 15, 46, 46, 16],
  11522. // 38
  11523. [4, 152, 122, 18, 153, 123],
  11524. [13, 74, 46, 32, 75, 47],
  11525. [48, 54, 24, 14, 55, 25],
  11526. [42, 45, 15, 32, 46, 16],
  11527. // 39
  11528. [20, 147, 117, 4, 148, 118],
  11529. [40, 75, 47, 7, 76, 48],
  11530. [43, 54, 24, 22, 55, 25],
  11531. [10, 45, 15, 67, 46, 16],
  11532. // 40
  11533. [19, 148, 118, 6, 149, 119],
  11534. [18, 75, 47, 31, 76, 48],
  11535. [34, 54, 24, 34, 55, 25],
  11536. [20, 45, 15, 61, 46, 16]
  11537. ];
  11538. /**
  11539. * �������ݻ�ȡ��Ӧ�汾
  11540. * @return {[type]} [description]
  11541. */
  11542. QRCodeAlg.prototype.getRightType = function() {
  11543. for (var typeNumber = 1; typeNumber < 41; typeNumber++) {
  11544. var rsBlock = RS_BLOCK_TABLE[(typeNumber - 1) * 4 + this.errorCorrectLevel];
  11545. if (rsBlock == undefined) {
  11546. throw new Error('bad rs block @ typeNumber:' + typeNumber + '/errorCorrectLevel:' + this.errorCorrectLevel);
  11547. }
  11548. var length = rsBlock.length / 3;
  11549. var totalDataCount = 0;
  11550. for (var i = 0; i < length; i++) {
  11551. var count = rsBlock[i * 3 + 0];
  11552. var dataCount = rsBlock[i * 3 + 2];
  11553. totalDataCount += dataCount * count;
  11554. }
  11555. var lengthBytes = typeNumber > 9 ? 2 : 1;
  11556. if (this.utf8bytes.length + lengthBytes < totalDataCount || typeNumber == 40) {
  11557. this.typeNumber = typeNumber;
  11558. this.rsBlock = rsBlock;
  11559. this.totalDataCount = totalDataCount;
  11560. break;
  11561. }
  11562. }
  11563. };
  11564. // ---------------------------------------------------------------------
  11565. // QRBitBuffer
  11566. // ---------------------------------------------------------------------
  11567. function QRBitBuffer() {
  11568. this.buffer = new Array();
  11569. this.length = 0;
  11570. }
  11571. QRBitBuffer.prototype = {
  11572. get: function(index) {
  11573. var bufIndex = Math.floor(index / 8);
  11574. return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1);
  11575. },
  11576. put: function(num, length) {
  11577. for (var i = 0; i < length; i++) {
  11578. this.putBit(((num >>> (length - i - 1)) & 1));
  11579. }
  11580. },
  11581. putBit: function(bit) {
  11582. var bufIndex = Math.floor(this.length / 8);
  11583. if (this.buffer.length <= bufIndex) {
  11584. this.buffer.push(0);
  11585. }
  11586. if (bit) {
  11587. this.buffer[bufIndex] |= (0x80 >>> (this.length % 8));
  11588. }
  11589. this.length++;
  11590. }
  11591. };
  11592. $.fn.qrcode = function QRCodePlugin(option) {
  11593. return this.each(function() {
  11594. $(this).append(new QRCode(option));
  11595. });
  11596. };
  11597. module.exports = UI.qrcode = QRCode;
  11598. /***/ },
  11599. /* 27 */
  11600. /***/ function(module, exports, __webpack_require__) {
  11601. 'use strict';
  11602. var $ = __webpack_require__(1);
  11603. var UI = __webpack_require__(2);
  11604. /**
  11605. * @via https://github.com/uikit/uikit/blob/master/src/js/addons/sticky.js
  11606. * @license https://github.com/uikit/uikit/blob/master/LICENSE.md
  11607. */
  11608. // Sticky Class
  11609. var Sticky = function(element, options) {
  11610. var _this = this;
  11611. this.options = $.extend({}, Sticky.DEFAULTS, options);
  11612. this.$element = $(element);
  11613. this.sticked = null;
  11614. this.inited = null;
  11615. this.$holder = undefined;
  11616. this.$window = $(window).
  11617. on('scroll.sticky.amui',
  11618. UI.utils.debounce($.proxy(this.checkPosition, this), 10)).
  11619. on('resize.sticky.amui orientationchange.sticky.amui',
  11620. UI.utils.debounce(function() {
  11621. _this.reset(true, function() {
  11622. _this.checkPosition();
  11623. });
  11624. }, 50)).
  11625. on('load.sticky.amui', $.proxy(this.checkPosition, this));
  11626. // the `.offset()` is diff between jQuery & Zepto.js
  11627. // jQuery: return `top` and `left`
  11628. // Zepto.js: return `top`, `left`, `width`, `height`
  11629. this.offset = this.$element.offset();
  11630. this.init();
  11631. };
  11632. Sticky.DEFAULTS = {
  11633. top: 0,
  11634. bottom: 0,
  11635. animation: '',
  11636. className: {
  11637. sticky: 'am-sticky',
  11638. resetting: 'am-sticky-resetting',
  11639. stickyBtm: 'am-sticky-bottom',
  11640. animationRev: 'am-animation-reverse'
  11641. }
  11642. };
  11643. Sticky.prototype.init = function() {
  11644. var result = this.check();
  11645. if (!result) {
  11646. return false;
  11647. }
  11648. var $element = this.$element;
  11649. var $elementMargin = '';
  11650. $.each($element.css(
  11651. ['marginTop', 'marginRight', 'marginBottom', 'marginLeft']),
  11652. function(name, value) {
  11653. return $elementMargin += ' ' + value;
  11654. });
  11655. var $holder = $('<div class="am-sticky-placeholder"></div>').css({
  11656. height: $element.css('position') !== 'absolute' ?
  11657. $element.outerHeight() : '',
  11658. float: $element.css('float') != 'none' ? $element.css('float') : '',
  11659. margin: $elementMargin
  11660. });
  11661. this.$holder = $element.css('margin', 0).wrap($holder).parent();
  11662. this.inited = 1;
  11663. return true;
  11664. };
  11665. Sticky.prototype.reset = function(force, cb) {
  11666. var options = this.options;
  11667. var $element = this.$element;
  11668. var animation = (options.animation) ?
  11669. ' am-animation-' + options.animation : '';
  11670. var complete = function() {
  11671. $element.css({position: '', top: '', width: '', left: '', margin: 0});
  11672. $element.removeClass([
  11673. animation,
  11674. options.className.animationRev,
  11675. options.className.sticky,
  11676. options.className.resetting
  11677. ].join(' '));
  11678. this.animating = false;
  11679. this.sticked = false;
  11680. this.offset = $element.offset();
  11681. cb && cb();
  11682. }.bind(this);
  11683. $element.addClass(options.className.resetting);
  11684. if (!force && options.animation && UI.support.animation) {
  11685. this.animating = true;
  11686. $element.removeClass(animation).one(UI.support.animation.end, function() {
  11687. complete();
  11688. }).width(); // force redraw
  11689. $element.addClass(animation + ' ' + options.className.animationRev);
  11690. } else {
  11691. complete();
  11692. }
  11693. };
  11694. Sticky.prototype.check = function() {
  11695. if (!this.$element.is(':visible')) {
  11696. return false;
  11697. }
  11698. var media = this.options.media;
  11699. if (media) {
  11700. switch (typeof(media)) {
  11701. case 'number':
  11702. if (window.innerWidth < media) {
  11703. return false;
  11704. }
  11705. break;
  11706. case 'string':
  11707. if (window.matchMedia && !window.matchMedia(media).matches) {
  11708. return false;
  11709. }
  11710. break;
  11711. }
  11712. }
  11713. return true;
  11714. };
  11715. Sticky.prototype.checkPosition = function() {
  11716. if (!this.inited) {
  11717. var initialized = this.init();
  11718. if (!initialized) {
  11719. return;
  11720. }
  11721. }
  11722. var options = this.options;
  11723. var scrollTop = this.$window.scrollTop();
  11724. var offsetTop = options.top;
  11725. var offsetBottom = options.bottom;
  11726. var $element = this.$element;
  11727. var animation = (options.animation) ?
  11728. ' am-animation-' + options.animation : '';
  11729. var className = [options.className.sticky, animation].join(' ');
  11730. if (typeof offsetBottom == 'function') {
  11731. offsetBottom = offsetBottom(this.$element);
  11732. }
  11733. var checkResult = (scrollTop > this.$holder.offset().top);
  11734. if (!this.sticked && checkResult) {
  11735. $element.addClass(className);
  11736. } else if (this.sticked && !checkResult) {
  11737. this.reset();
  11738. }
  11739. this.$holder.css({
  11740. height: $element.is(':visible') && $element.css('position') !== 'absolute' ?
  11741. $element.outerHeight() : ''
  11742. });
  11743. if (checkResult) {
  11744. $element.css({
  11745. top: offsetTop,
  11746. left: this.$holder.offset().left,
  11747. width: this.$holder.width()
  11748. });
  11749. /*
  11750. if (offsetBottom) {
  11751. // ���ײ��߾� + Ԫ�ظ߶� > ���ڸ߶ȣ� ʱ��λ���ײ�
  11752. if ((offsetBottom + this.offset.height > $(window).height()) &&
  11753. (scrollTop + $(window).height() >= scrollHeight - offsetBottom)) {
  11754. $element.addClass(options.className.stickyBtm).
  11755. css({top: $(window).height() - offsetBottom - this.offset.height});
  11756. } else {
  11757. $element.removeClass(options.className.stickyBtm).css({top: offsetTop});
  11758. }
  11759. }
  11760. */
  11761. }
  11762. this.sticked = checkResult;
  11763. };
  11764. // Sticky Plugin
  11765. UI.plugin('sticky', Sticky);
  11766. // Init code
  11767. $(window).on('load', function() {
  11768. $('[data-am-sticky]').sticky();
  11769. });
  11770. module.exports = Sticky;
  11771. /***/ },
  11772. /* 28 */
  11773. /***/ function(module, exports, __webpack_require__) {
  11774. 'use strict';
  11775. var $ = __webpack_require__(1);
  11776. var UI = __webpack_require__(2);
  11777. var Hammer = __webpack_require__(3);
  11778. var supportTransition = UI.support.transition;
  11779. var animation = UI.support.animation;
  11780. /**
  11781. * @via https://github.com/twbs/bootstrap/blob/master/js/tab.js
  11782. * @copyright 2011-2014 Twitter, Inc.
  11783. * @license MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  11784. */
  11785. /**
  11786. * Tabs
  11787. * @param {HTMLElement} element
  11788. * @param {Object} options
  11789. * @constructor
  11790. */
  11791. var Tabs = function(element, options) {
  11792. this.$element = $(element);
  11793. this.options = $.extend({}, Tabs.DEFAULTS, options || {});
  11794. this.transitioning = this.activeIndex = null;
  11795. this.refresh();
  11796. this.init();
  11797. };
  11798. Tabs.DEFAULTS = {
  11799. selector: {
  11800. nav: '> .am-tabs-nav',
  11801. content: '> .am-tabs-bd',
  11802. panel: '> .am-tab-panel'
  11803. },
  11804. activeClass: 'am-active'
  11805. };
  11806. Tabs.prototype.refresh = function() {
  11807. var selector = this.options.selector;
  11808. this.$tabNav = this.$element.find(selector.nav);
  11809. this.$navs = this.$tabNav.find('a');
  11810. this.$content = this.$element.find(selector.content);
  11811. this.$tabPanels = this.$content.find(selector.panel);
  11812. var $active = this.$tabNav.find('> .' + this.options.activeClass);
  11813. // Activate the first Tab when no active Tab or multiple active Tabs
  11814. if ($active.length !== 1) {
  11815. this.open(0);
  11816. } else {
  11817. this.activeIndex = this.$navs.index($active.children('a'));
  11818. }
  11819. };
  11820. Tabs.prototype.init = function() {
  11821. var _this = this;
  11822. var options = this.options;
  11823. this.$element.on('click.tabs.amui', options.selector.nav + ' a', function(e) {
  11824. e.preventDefault();
  11825. _this.open($(this));
  11826. });
  11827. // TODO: nested Tabs touch events
  11828. if (!options.noSwipe) {
  11829. if (!this.$content.length) {
  11830. return this;
  11831. }
  11832. var hammer = new Hammer.Manager(this.$content[0]);
  11833. var swipe = new Hammer.Swipe({
  11834. direction: Hammer.DIRECTION_HORIZONTAL
  11835. // threshold: 40
  11836. });
  11837. hammer.add(swipe);
  11838. hammer.on('swipeleft', UI.utils.debounce(function(e) {
  11839. e.preventDefault();
  11840. _this.goTo('next');
  11841. }, 100));
  11842. hammer.on('swiperight', UI.utils.debounce(function(e) {
  11843. e.preventDefault();
  11844. _this.goTo('prev');
  11845. }, 100));
  11846. this._hammer = hammer;
  11847. }
  11848. };
  11849. /**
  11850. * Open $nav tab
  11851. * @param {jQuery|HTMLElement|Number} $nav
  11852. * @returns {Tabs}
  11853. */
  11854. Tabs.prototype.open = function($nav) {
  11855. var activeClass = this.options.activeClass;
  11856. var activeIndex = typeof $nav === 'number' ? $nav : this.$navs.index($($nav));
  11857. $nav = typeof $nav === 'number' ? this.$navs.eq(activeIndex) : $($nav);
  11858. if (!$nav ||
  11859. !$nav.length ||
  11860. this.transitioning ||
  11861. $nav.parent('li').hasClass(activeClass)) {
  11862. return;
  11863. }
  11864. var $tabNav = this.$tabNav;
  11865. var href = $nav.attr('href');
  11866. var regexHash = /^#.+$/;
  11867. var $target = regexHash.test(href) && this.$content.find(href) ||
  11868. this.$tabPanels.eq(activeIndex);
  11869. var previous = $tabNav.find('.' + activeClass + ' a')[0];
  11870. var e = $.Event('open.tabs.amui', {
  11871. relatedTarget: previous
  11872. });
  11873. $nav.trigger(e);
  11874. if (e.isDefaultPrevented()) {
  11875. return;
  11876. }
  11877. // activate Tab nav
  11878. this.activate($nav.closest('li'), $tabNav);
  11879. // activate Tab content
  11880. this.activate($target, this.$content, function() {
  11881. $nav.trigger({
  11882. type: 'opened.tabs.amui',
  11883. relatedTarget: previous
  11884. });
  11885. });
  11886. this.activeIndex = activeIndex;
  11887. };
  11888. Tabs.prototype.activate = function($element, $container, callback) {
  11889. this.transitioning = true;
  11890. var activeClass = this.options.activeClass;
  11891. var $active = $container.find('> .' + activeClass);
  11892. var transition = callback && supportTransition && !!$active.length;
  11893. $active.removeClass(activeClass + ' am-in');
  11894. $element.addClass(activeClass);
  11895. if (transition) {
  11896. $element.redraw(); // reflow for transition
  11897. $element.addClass('am-in');
  11898. } else {
  11899. $element.removeClass('am-fade');
  11900. }
  11901. var complete = $.proxy(function complete() {
  11902. callback && callback();
  11903. this.transitioning = false;
  11904. }, this);
  11905. transition ? $active.one(supportTransition.end, complete) : complete();
  11906. };
  11907. /**
  11908. * Go to `next` or `prev` tab
  11909. * @param {String} direction - `next` or `prev`
  11910. */
  11911. Tabs.prototype.goTo = function(direction) {
  11912. var navIndex = this.activeIndex;
  11913. var isNext = direction === 'next';
  11914. var spring = isNext ? 'am-animation-right-spring' :
  11915. 'am-animation-left-spring';
  11916. if ((isNext && navIndex + 1 >= this.$navs.length) || // last one
  11917. (!isNext && navIndex === 0)) { // first one
  11918. var $panel = this.$tabPanels.eq(navIndex);
  11919. animation && $panel.addClass(spring).on(animation.end, function() {
  11920. $panel.removeClass(spring);
  11921. });
  11922. } else {
  11923. this.open(isNext ? navIndex + 1 : navIndex - 1);
  11924. }
  11925. };
  11926. Tabs.prototype.destroy = function() {
  11927. this.$element.off('.tabs.amui');
  11928. Hammer.off(this.$content[0], 'swipeleft swiperight');
  11929. this._hammer && this._hammer.destroy();
  11930. $.removeData(this.$element, 'amui.tabs');
  11931. };
  11932. // Plugin
  11933. function Plugin(option) {
  11934. var args = Array.prototype.slice.call(arguments, 1);
  11935. var methodReturn;
  11936. this.each(function() {
  11937. var $this = $(this);
  11938. var $tabs = $this.is('.am-tabs') && $this || $this.closest('.am-tabs');
  11939. var data = $tabs.data('amui.tabs');
  11940. var options = $.extend({}, UI.utils.parseOptions($this.data('amTabs')),
  11941. $.isPlainObject(option) && option);
  11942. if (!data) {
  11943. $tabs.data('amui.tabs', (data = new Tabs($tabs[0], options)));
  11944. }
  11945. if (typeof option === 'string') {
  11946. if (option === 'open' && $this.is('.am-tabs-nav a')) {
  11947. data.open($this);
  11948. } else {
  11949. methodReturn = typeof data[option] === 'function' ?
  11950. data[option].apply(data, args) : data[option];
  11951. }
  11952. }
  11953. });
  11954. return methodReturn === undefined ? this : methodReturn;
  11955. }
  11956. $.fn.tabs = Plugin;
  11957. // Init code
  11958. UI.ready(function(context) {
  11959. $('[data-am-tabs]', context).tabs();
  11960. });
  11961. $(document).on('click.tabs.amui.data-api', '[data-am-tabs] .am-tabs-nav a',
  11962. function(e) {
  11963. e.preventDefault();
  11964. Plugin.call($(this), 'open');
  11965. });
  11966. module.exports = UI.tabs = Tabs;
  11967. // TODO: 1. Ajax ֧��
  11968. // 2. touch �¼������߼��Ż�
  11969. /***/ },
  11970. /* 29 */
  11971. /***/ function(module, exports, __webpack_require__) {
  11972. 'use strict';
  11973. var $ = __webpack_require__(1);
  11974. var UI = __webpack_require__(2);
  11975. /**
  11976. * UCheck
  11977. * @via https://github.com/designmodo/Flat-UI/blob/8ef98df23ba7f5033e596a9bd05b53b535a9fe99/js/radiocheck.js
  11978. * @license CC BY 3.0 & MIT
  11979. * @param {HTMLElement} element
  11980. * @param {object} options
  11981. * @constructor
  11982. */
  11983. var UCheck = function(element, options) {
  11984. this.options = $.extend({}, UCheck.DEFAULTS, options);
  11985. // this.options = $.extend({}, UCheck.DEFAULTS, this.$element.data(), options);
  11986. this.$element = $(element);
  11987. this.init();
  11988. };
  11989. UCheck.DEFAULTS = {
  11990. checkboxClass: 'am-ucheck-checkbox',
  11991. radioClass: 'am-ucheck-radio',
  11992. checkboxTpl: '<span class="am-ucheck-icons">' +
  11993. '<i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span>',
  11994. radioTpl: '<span class="am-ucheck-icons">' +
  11995. '<i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span>'
  11996. };
  11997. UCheck.prototype.init = function() {
  11998. var $element = this.$element;
  11999. var element = $element[0];
  12000. var options = this.options;
  12001. if (element.type === 'checkbox') {
  12002. $element.addClass(options.checkboxClass)
  12003. .after(options.checkboxTpl);
  12004. } else if (element.type === 'radio') {
  12005. $element.addClass(options.radioClass)
  12006. .after(options.radioTpl);
  12007. }
  12008. };
  12009. UCheck.prototype.check = function() {
  12010. this.$element
  12011. .prop('checked', true)
  12012. .trigger('change.ucheck.amui')
  12013. .trigger('checked.ucheck.amui');
  12014. },
  12015. UCheck.prototype.uncheck = function() {
  12016. this.$element
  12017. .prop('checked', false)
  12018. .trigger('change.ucheck.amui')
  12019. .trigger('unchecked.ucheck.amui');
  12020. },
  12021. UCheck.prototype.toggle = function() {
  12022. this.$element.
  12023. prop('checked', function(i, value) {
  12024. return !value;
  12025. })
  12026. .trigger('change.ucheck.amui')
  12027. .trigger('toggled.ucheck.amui');
  12028. },
  12029. UCheck.prototype.disable = function() {
  12030. this.$element
  12031. .prop('disabled', true)
  12032. .trigger('change.ucheck.amui')
  12033. .trigger('disabled.ucheck.amui');
  12034. },
  12035. UCheck.prototype.enable = function() {
  12036. this.$element.prop('disabled', false);
  12037. this.$element.trigger('change.ucheck.amui').trigger('enabled.ucheck.amui');
  12038. },
  12039. UCheck.prototype.destroy = function() {
  12040. this.$element
  12041. .removeData('amui.ucheck')
  12042. .removeClass(this.options.checkboxClass + ' ' + this.options.radioClass)
  12043. .next('.am-ucheck-icons')
  12044. .remove()
  12045. .end()
  12046. .trigger('destroyed.ucheck.amui');
  12047. };
  12048. UI.plugin('uCheck', UCheck, {
  12049. after: function() {
  12050. // Adding 'am-nohover' class for touch devices
  12051. if (UI.support.touch) {
  12052. this.parent().hover(function() {
  12053. $(this).addClass('am-nohover');
  12054. }, function() {
  12055. $(this).removeClass('am-nohover');
  12056. });
  12057. }
  12058. }
  12059. });
  12060. UI.ready(function(context) {
  12061. $('[data-am-ucheck]', context).uCheck();
  12062. });
  12063. module.exports = UCheck;
  12064. // TODO: �����֤���ʹ�õ����
  12065. /***/ },
  12066. /* 30 */
  12067. /***/ function(module, exports, __webpack_require__) {
  12068. 'use strict';
  12069. var $ = __webpack_require__(1);
  12070. var UI = __webpack_require__(2);
  12071. var Validator = function(element, options) {
  12072. this.options = $.extend({}, Validator.DEFAULTS, options);
  12073. this.options.patterns = $.extend({}, Validator.patterns,
  12074. this.options.patterns);
  12075. var locales = this.options.locales;
  12076. !Validator.validationMessages[locales] && (this.options.locales = 'zh_CN');
  12077. this.$element = $(element);
  12078. this.init();
  12079. };
  12080. Validator.DEFAULTS = {
  12081. debug: false,
  12082. locales: 'zh_CN',
  12083. H5validation: false,
  12084. H5inputType: ['email', 'url', 'number'],
  12085. patterns: {},
  12086. patternClassPrefix: 'js-pattern-',
  12087. activeClass: 'am-active',
  12088. inValidClass: 'am-field-error',
  12089. validClass: 'am-field-valid',
  12090. validateOnSubmit: true,
  12091. alwaysRevalidate: false,
  12092. // Elements to validate with allValid (only validating visible elements)
  12093. // :input: selects all input, textarea, select and button elements.
  12094. // @since 2.5: move `:visible` to `ignore` option (became to `:hidden`)
  12095. allFields: ':input:not(:submit, :button, :disabled, .am-novalidate)',
  12096. // ignored elements
  12097. // @since 2.5
  12098. ignore: ':hidden:not([data-am-selected], .am-validate)',
  12099. // Custom events
  12100. customEvents: 'validate',
  12101. // Keyboard events
  12102. keyboardFields: ':input:not(:submit, :button, :disabled, .am-novalidate)',
  12103. keyboardEvents: 'focusout, change', // keyup, focusin
  12104. // bind `keyup` event to active field
  12105. activeKeyup: false,
  12106. textareaMaxlenthKeyup: true,
  12107. // Mouse events
  12108. pointerFields: 'input[type="range"]:not(:disabled, .am-novalidate), ' +
  12109. 'input[type="radio"]:not(:disabled, .am-novalidate), ' +
  12110. 'input[type="checkbox"]:not(:disabled, .am-novalidate), ' +
  12111. 'select:not(:disabled, .am-novalidate), ' +
  12112. 'option:not(:disabled, .am-novalidate)',
  12113. pointerEvents: 'click',
  12114. onValid: function(validity) {
  12115. },
  12116. onInValid: function(validity) {
  12117. },
  12118. markValid: function(validity) {
  12119. // this is Validator instance
  12120. var options = this.options;
  12121. var $field = $(validity.field);
  12122. var $parent = $field.closest('.am-form-group');
  12123. $field.addClass(options.validClass).removeClass(options.inValidClass);
  12124. $parent.addClass('am-form-success').removeClass('am-form-error');
  12125. options.onValid.call(this, validity);
  12126. },
  12127. markInValid: function(validity) {
  12128. var options = this.options;
  12129. var $field = $(validity.field);
  12130. var $parent = $field.closest('.am-form-group');
  12131. $field.addClass(options.inValidClass + ' ' + options.activeClass).
  12132. removeClass(options.validClass);
  12133. $parent.addClass('am-form-error').removeClass('am-form-success');
  12134. options.onInValid.call(this, validity);
  12135. },
  12136. validate: function(validity) {
  12137. // return validity;
  12138. },
  12139. submit: null
  12140. };
  12141. Validator.VERSION = '2.5.1';
  12142. /* jshint -W101 */
  12143. Validator.patterns = {
  12144. email: /^((([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/,
  12145. url: /^(https?|ftp):\/\/(((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/,
  12146. // Number, including positive, negative, and floating decimal
  12147. number: /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,
  12148. dateISO: /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/,
  12149. integer: /^-?\d+$/
  12150. };
  12151. /* jshint +W101 */
  12152. Validator.validationMessages = {
  12153. zh_CN: {
  12154. valueMissing: '����д��ѡ�񣩴��ֶ�',
  12155. customError: {
  12156. tooShort: '������д %s ���ַ�',
  12157. checkedOverflow: '����ѡ�� %s ��',
  12158. checkedUnderflow: '����ѡ�� %s ��'
  12159. },
  12160. patternMismatch: '�밴��Ҫ��ĸ�ʽ��д',
  12161. rangeOverflow: '����дС�ڵ��� %s ��ֵ',
  12162. rangeUnderflow: '����д���ڵ��� %s ��ֵ',
  12163. stepMismatch: '',
  12164. tooLong: '������д %s ���ַ�',
  12165. typeMismatch: '�밴��Ҫ���������д'
  12166. }
  12167. };
  12168. Validator.ERROR_MAP = {
  12169. tooShort: 'minlength',
  12170. checkedOverflow: 'maxchecked',
  12171. checkedUnderflow: 'minchecked',
  12172. rangeOverflow: 'max',
  12173. rangeUnderflow: 'min',
  12174. tooLong: 'maxlength'
  12175. };
  12176. // TODO: ���DZ�Ԫ�ز��� form ��Ԫ�ص�����
  12177. // TODO: change/click/focusout ͬʱ����ʱ�����ظ�
  12178. // TODO: ��ʾ��ʾ��Ϣ
  12179. Validator.prototype.init = function() {
  12180. var _this = this;
  12181. var $element = this.$element;
  12182. var options = this.options;
  12183. // using H5 form validation if option set and supported
  12184. if (options.H5validation && UI.support.formValidation) {
  12185. return false;
  12186. }
  12187. // disable HTML5 form validation
  12188. $element.attr('novalidate', 'novalidate');
  12189. function regexToPattern(regex) {
  12190. var pattern = regex.toString();
  12191. return pattern.substring(1, pattern.length - 1);
  12192. }
  12193. // add pattern to H5 input type
  12194. $.each(options.H5inputType, function(i, type) {
  12195. var $field = $element.find('input[type=' + type + ']');
  12196. if (!$field.attr('pattern') &&
  12197. !$field.is('[class*=' + options.patternClassPrefix + ']')) {
  12198. $field.attr('pattern', regexToPattern(options.patterns[type]));
  12199. }
  12200. });
  12201. // add pattern to .js-pattern-xx
  12202. $.each(options.patterns, function(key, value) {
  12203. var $field = $element.find('.' + options.patternClassPrefix + key);
  12204. !$field.attr('pattern') && $field.attr('pattern', regexToPattern(value));
  12205. });
  12206. $element.on('submit.validator.amui', function(e) {
  12207. // user custom submit handler
  12208. if (typeof options.submit === 'function') {
  12209. return options.submit.call(_this, e);
  12210. }
  12211. if (options.validateOnSubmit) {
  12212. var formValidity = _this.isFormValid();
  12213. // sync validate, return result
  12214. if ($.type(formValidity) === 'boolean') {
  12215. return formValidity;
  12216. }
  12217. if ($element.data('amui.checked')) {
  12218. return true;
  12219. } else {
  12220. $.when(formValidity).then(function() {
  12221. // done, submit form
  12222. $element.data('amui.checked', true).submit();
  12223. }, function() {
  12224. // fail
  12225. $element.data('amui.checked', false).
  12226. find('.' + options.inValidClass).eq(0).focus();
  12227. });
  12228. return false;
  12229. }
  12230. }
  12231. });
  12232. function bindEvents(fields, eventFlags, debounce) {
  12233. var events = eventFlags.split(',');
  12234. var validate = function(e) {
  12235. // console.log(e.type);
  12236. _this.validate(this);
  12237. };
  12238. if (debounce) {
  12239. validate = UI.utils.debounce(validate, debounce);
  12240. }
  12241. $.each(events, function(i, event) {
  12242. $element.on(event + '.validator.amui', fields, validate);
  12243. });
  12244. }
  12245. bindEvents(':input', options.customEvents);
  12246. bindEvents(options.keyboardFields, options.keyboardEvents);
  12247. bindEvents(options.pointerFields, options.pointerEvents);
  12248. if (options.textareaMaxlenthKeyup) {
  12249. bindEvents('textarea[maxlength]', 'keyup', 50);
  12250. }
  12251. if (options.activeKeyup) {
  12252. bindEvents('.am-active', 'keyup', 50);
  12253. }
  12254. /*if (options.errorMessage === 'tooltip') {
  12255. this.$tooltip = $('<div></div>', {
  12256. 'class': 'am-validator-message',
  12257. id: UI.utils.generateGUID('am-validator-message')
  12258. });
  12259. $(document.body).append(this.$tooltip);
  12260. }*/
  12261. };
  12262. Validator.prototype.isValid = function(field) {
  12263. var $field = $(field);
  12264. var options = this.options;
  12265. // valid field not has been validated
  12266. if ($field.data('validity') === undefined || options.alwaysRevalidate) {
  12267. this.validate(field);
  12268. }
  12269. return $field.data('validity') && $field.data('validity').valid;
  12270. };
  12271. Validator.prototype.validate = function(field) {
  12272. var _this = this;
  12273. var $element = this.$element;
  12274. var options = this.options;
  12275. var $field = $(field);
  12276. // Validate equal, e.g. confirm password
  12277. var equalTo = $field.data('equalTo');
  12278. if (equalTo) {
  12279. $field.attr('pattern', '^' + $element.find(equalTo).val() + '$');
  12280. }
  12281. var pattern = $field.attr('pattern') || false;
  12282. var re = new RegExp(pattern);
  12283. var $radioGroup = null;
  12284. var $checkboxGroup = null;
  12285. // if checkbox, return `:chcked` length
  12286. // NOTE: checkbox and radio should have name attribute
  12287. var value = ($field.is('[type=checkbox]')) ?
  12288. ($checkboxGroup = $element.find('input[name="' + field.name + '"]')).
  12289. filter(':checked').length : ($field.is('[type=radio]') ?
  12290. ($radioGroup = this.$element.find('input[name="' + field.name + '"]')).
  12291. filter(':checked').length > 0 : $field.val());
  12292. // if checkbox, valid the first input of checkbox group
  12293. $field = ($checkboxGroup && $checkboxGroup.length) ?
  12294. $checkboxGroup.first() : $field;
  12295. var required = ($field.attr('required') !== undefined) &&
  12296. ($field.attr('required') !== 'false');
  12297. var maxLength = parseInt($field.attr('maxlength'), 10);
  12298. var minLength = parseInt($field.attr('minlength'), 10);
  12299. var min = Number($field.attr('min'));
  12300. var max = Number($field.attr('max'));
  12301. var validity = this.createValidity({field: $field[0], valid: true});
  12302. // Debug
  12303. if (options.debug && window.console) {
  12304. console.log('Validate: value -> [' + value + ', regex -> [' + re +
  12305. '], required -> ' + required);
  12306. console.log('Regex test: ' + re.test(value) + ', Pattern: ' + pattern);
  12307. }
  12308. // check value length
  12309. if (!isNaN(maxLength) && value.length > maxLength) {
  12310. validity.valid = false;
  12311. validity.tooLong = true;
  12312. }
  12313. if (!isNaN(minLength) && value.length < minLength) {
  12314. validity.valid = false;
  12315. validity.customError = 'tooShort';
  12316. }
  12317. // check minimum and maximum
  12318. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input
  12319. // TODO: ������֤��Сֵ�����ֵ min/max
  12320. if (!isNaN(min) && Number(value) < min) {
  12321. validity.valid = false;
  12322. validity.rangeUnderflow = true;
  12323. }
  12324. if (!isNaN(max) && Number(value) > max) {
  12325. validity.valid = false;
  12326. validity.rangeOverflow = true;
  12327. }
  12328. // check required
  12329. if (required && !value) {
  12330. validity.valid = false;
  12331. validity.valueMissing = true;
  12332. } else if (($checkboxGroup || $field.is('select[multiple="multiple"]')) &&
  12333. value) {
  12334. // check checkboxes / multiple select with `minchecked`/`maxchecked` attr
  12335. // var $multipleField = $checkboxGroup ? $checkboxGroup.first() : $field;
  12336. // if is select[multiple="multiple"], return selected length
  12337. value = $checkboxGroup ? value : value.length;
  12338. // at least checked
  12339. var minChecked = parseInt($field.attr('minchecked'), 10);
  12340. // at most checked
  12341. var maxChecked = parseInt($field.attr('maxchecked'), 10);
  12342. if (!isNaN(minChecked) && value < minChecked) {
  12343. // console.log('At least [%d] items checked��', maxChecked);
  12344. validity.valid = false;
  12345. validity.customError = 'checkedUnderflow';
  12346. }
  12347. if (!isNaN(maxChecked) && value > maxChecked) {
  12348. // console.log('At most [%d] items checked��', maxChecked);
  12349. validity.valid = false;
  12350. validity.customError = 'checkedOverflow';
  12351. }
  12352. } else if (pattern && !re.test(value) && value) { // check pattern
  12353. validity.valid = false;
  12354. validity.patternMismatch = true;
  12355. }
  12356. var validateComplete = function(validity) {
  12357. this.markField(validity);
  12358. var event = $.Event('validated.field.validator.amui');
  12359. event.validity = validity;
  12360. $field.trigger(event).data('validity', validity);
  12361. // validate the radios/checkboxes with the same name
  12362. var $fields = $radioGroup || $checkboxGroup;
  12363. if ($fields) {
  12364. $fields.not($field).data('validity', validity).each(function() {
  12365. validity.field = this;
  12366. _this.markField(validity);
  12367. });
  12368. }
  12369. return validity;
  12370. };
  12371. // Run custom validate
  12372. // NOTE: async custom validate should return Deferred project
  12373. var customValidate;
  12374. (typeof options.validate === 'function') &&
  12375. (customValidate = options.validate.call(this, validity));
  12376. // Deferred
  12377. if (customValidate) {
  12378. var dfd = new $.Deferred();
  12379. $field.data('amui.dfdValidity', dfd.promise());
  12380. return $.when(customValidate).always(function(validity) {
  12381. dfd[validity.valid ? 'resolve' : 'reject'](validity);
  12382. validateComplete.call(_this, validity);
  12383. });
  12384. }
  12385. validateComplete.call(this, validity);
  12386. };
  12387. Validator.prototype.markField = function(validity) {
  12388. var options = this.options;
  12389. var flag = 'mark' + (validity.valid ? '' : 'In') + 'Valid';
  12390. options[flag] && options[flag].call(this, validity);
  12391. };
  12392. // check all fields in the form are valid
  12393. Validator.prototype.validateForm = function() {
  12394. var _this = this;
  12395. var $element = this.$element;
  12396. var options = this.options;
  12397. var $allFields = $element.find(options.allFields).not(options.ignore);
  12398. var radioNames = [];
  12399. var valid = true;
  12400. var formValidity = [];
  12401. var $inValidFields = $([]);
  12402. var promises = [];
  12403. // for async validate
  12404. var async = false;
  12405. $element.trigger('validate.form.validator.amui');
  12406. // Filter radio with the same name and keep only one,
  12407. // since they will be checked as a group by validate()
  12408. var $filteredFields = $allFields.filter(function(index) {
  12409. var name;
  12410. if (this.tagName === 'INPUT' && this.type === 'radio') {
  12411. name = this.name;
  12412. if (radioNames[name] === true) {
  12413. return false;
  12414. }
  12415. radioNames[name] = true;
  12416. }
  12417. return true;
  12418. });
  12419. $filteredFields.each(function() {
  12420. var $this = $(this);
  12421. var fieldValid = _this.isValid(this);
  12422. var fieldValidity = $this.data('validity');
  12423. valid = !!fieldValid && valid;
  12424. formValidity.push(fieldValidity);
  12425. if (!fieldValid) {
  12426. $inValidFields = $inValidFields.add($(this), $element);
  12427. }
  12428. // async validity
  12429. var promise = $this.data('amui.dfdValidity');
  12430. if (promise) {
  12431. promises.push(promise);
  12432. async = true;
  12433. } else {
  12434. // convert sync validity to Promise
  12435. var dfd = new $.Deferred();
  12436. promises.push(dfd.promise());
  12437. dfd[fieldValid ? 'resolve' : 'reject'](fieldValidity);
  12438. }
  12439. });
  12440. // NOTE: If there are async validity, the valid may be not exact result.
  12441. var validity = {
  12442. valid: valid,
  12443. $invalidFields: $inValidFields,
  12444. validity: formValidity,
  12445. promises: promises,
  12446. async: async
  12447. };
  12448. $element.trigger('validated.form.validator.amui', validity);
  12449. return validity;
  12450. };
  12451. Validator.prototype.isFormValid = function() {
  12452. var _this = this;
  12453. var formValidity = this.validateForm();
  12454. var triggerValid = function(type) {
  12455. _this.$element.trigger(type + '.validator.amui');
  12456. };
  12457. if (formValidity.async) {
  12458. var masterDfd = new $.Deferred();
  12459. $.when.apply(null, formValidity.promises).then(function() {
  12460. masterDfd.resolve();
  12461. triggerValid('valid');
  12462. }, function() {
  12463. masterDfd.reject();
  12464. triggerValid('invalid');
  12465. });
  12466. return masterDfd.promise();
  12467. } else {
  12468. if (!formValidity.valid) {
  12469. var $first = formValidity.$invalidFields.first();
  12470. // Selected plugin support
  12471. // @since 2.5
  12472. if ($first.is('[data-am-selected]')) {
  12473. $first = $first.next('.am-selected').find('.am-selected-btn');
  12474. }
  12475. $first.focus();
  12476. triggerValid('invalid');
  12477. return false;
  12478. }
  12479. triggerValid('valid');
  12480. return true;
  12481. }
  12482. };
  12483. // customErrors:
  12484. // 1. tooShort
  12485. // 2. checkedOverflow
  12486. // 3. checkedUnderflow
  12487. Validator.prototype.createValidity = function(validity) {
  12488. return $.extend({
  12489. customError: validity.customError || false,
  12490. patternMismatch: validity.patternMismatch || false,
  12491. rangeOverflow: validity.rangeOverflow || false, // higher than maximum
  12492. rangeUnderflow: validity.rangeUnderflow || false, // lower than minimum
  12493. stepMismatch: validity.stepMismatch || false,
  12494. tooLong: validity.tooLong || false,
  12495. // value is not in the correct syntax
  12496. typeMismatch: validity.typeMismatch || false,
  12497. valid: validity.valid || true,
  12498. // Returns true if the element has no value but is a required field
  12499. valueMissing: validity.valueMissing || false
  12500. }, validity);
  12501. };
  12502. Validator.prototype.getValidationMessage = function(validity) {
  12503. var messages = Validator.validationMessages[this.options.locales];
  12504. var error;
  12505. var message;
  12506. var placeholder = '%s';
  12507. var $field = $(validity.field);
  12508. if ($field.is('[type="checkbox"]') || $field.is('[type="radio"]')) {
  12509. $field = this.$element.find('[name=' + $field.attr('name') + ']').first();
  12510. }
  12511. // get error name
  12512. $.each(validity, function(key, val) {
  12513. // skip `field` and `valid`
  12514. if (key === 'field' || key === 'valid') {
  12515. return key;
  12516. }
  12517. // Amaze UI custom error type
  12518. if (key === 'customError' && val) {
  12519. error = val;
  12520. messages = messages.customError;
  12521. return false;
  12522. }
  12523. // W3C specs error type
  12524. if (val === true) {
  12525. error = key;
  12526. return false;
  12527. }
  12528. });
  12529. message = messages[error] || undefined;
  12530. if (message && Validator.ERROR_MAP[error]) {
  12531. message = message.replace(placeholder,
  12532. $field.attr(Validator.ERROR_MAP[error]) || '�涨��');
  12533. }
  12534. return message;
  12535. };
  12536. // remove valid mark
  12537. Validator.prototype.removeMark = function() {
  12538. this.$element
  12539. .find('.am-form-success, .am-form-error, .' + this.options.inValidClass +
  12540. ', .' + this.options.validClass)
  12541. .removeClass([
  12542. 'am-form-success',
  12543. 'am-form-error',
  12544. this.options.inValidClass,
  12545. this.options.validClass
  12546. ].join(' '));
  12547. };
  12548. // @since 2.5
  12549. Validator.prototype.destroy = function() {
  12550. this.removeMark();
  12551. // Remove data
  12552. // - Validator.prototype.init -> $element.data('amui.checked')
  12553. // - Validator.prototype.validateForm
  12554. // - Validator.prototype.isValid
  12555. this.$element.removeData('amui.validator amui.checked')
  12556. .off('.validator.amui')
  12557. .find(this.options.allFields).removeData('validity amui.dfdValidity');
  12558. };
  12559. UI.plugin('validator', Validator);
  12560. // init code
  12561. UI.ready(function(context) {
  12562. $('[data-am-validator]', context).validator();
  12563. });
  12564. module.exports = Validator;
  12565. /***/ },
  12566. /* 31 */
  12567. /***/ function(module, exports, __webpack_require__) {
  12568. 'use strict';
  12569. var UI = __webpack_require__(2);
  12570. var cookie = {
  12571. get: function(name) {
  12572. var cookieName = encodeURIComponent(name) + '=';
  12573. var cookieStart = document.cookie.indexOf(cookieName);
  12574. var cookieValue = null;
  12575. var cookieEnd;
  12576. if (cookieStart > -1) {
  12577. cookieEnd = document.cookie.indexOf(';', cookieStart);
  12578. if (cookieEnd == -1) {
  12579. cookieEnd = document.cookie.length;
  12580. }
  12581. cookieValue = decodeURIComponent(document.cookie.substring(cookieStart +
  12582. cookieName.length, cookieEnd));
  12583. }
  12584. return cookieValue;
  12585. },
  12586. set: function(name, value, expires, path, domain, secure) {
  12587. var cookieText = encodeURIComponent(name) + '=' +
  12588. encodeURIComponent(value);
  12589. if (expires instanceof Date) {
  12590. cookieText += '; expires=' + expires.toUTCString();
  12591. }
  12592. if (path) {
  12593. cookieText += '; path=' + path;
  12594. }
  12595. if (domain) {
  12596. cookieText += '; domain=' + domain;
  12597. }
  12598. if (secure) {
  12599. cookieText += '; secure';
  12600. }
  12601. document.cookie = cookieText;
  12602. },
  12603. unset: function(name, path, domain, secure) {
  12604. this.set(name, '', new Date(0), path, domain, secure);
  12605. }
  12606. };
  12607. UI.utils = UI.utils || {};
  12608. module.exports = UI.utils.cookie = cookie;
  12609. /***/ },
  12610. /* 32 */
  12611. /***/ function(module, exports, __webpack_require__) {
  12612. 'use strict';
  12613. var UI = __webpack_require__(2);
  12614. var screenfull = (function() {
  12615. var keyboardAllowed = typeof Element !== 'undefined' &&
  12616. 'ALLOW_KEYBOARD_INPUT' in Element;
  12617. var fn = (function() {
  12618. var val;
  12619. var valLength;
  12620. var fnMap = [
  12621. [
  12622. 'requestFullscreen',
  12623. 'exitFullscreen',
  12624. 'fullscreenElement',
  12625. 'fullscreenEnabled',
  12626. 'fullscreenchange',
  12627. 'fullscreenerror'
  12628. ],
  12629. // new WebKit
  12630. [
  12631. 'webkitRequestFullscreen',
  12632. 'webkitExitFullscreen',
  12633. 'webkitFullscreenElement',
  12634. 'webkitFullscreenEnabled',
  12635. 'webkitfullscreenchange',
  12636. 'webkitfullscreenerror'
  12637. ],
  12638. // old WebKit (Safari 5.1)
  12639. [
  12640. 'webkitRequestFullScreen',
  12641. 'webkitCancelFullScreen',
  12642. 'webkitCurrentFullScreenElement',
  12643. 'webkitCancelFullScreen',
  12644. 'webkitfullscreenchange',
  12645. 'webkitfullscreenerror'
  12646. ],
  12647. [
  12648. 'mozRequestFullScreen',
  12649. 'mozCancelFullScreen',
  12650. 'mozFullScreenElement',
  12651. 'mozFullScreenEnabled',
  12652. 'mozfullscreenchange',
  12653. 'mozfullscreenerror'
  12654. ],
  12655. [
  12656. 'msRequestFullscreen',
  12657. 'msExitFullscreen',
  12658. 'msFullscreenElement',
  12659. 'msFullscreenEnabled',
  12660. 'MSFullscreenChange',
  12661. 'MSFullscreenError'
  12662. ]
  12663. ];
  12664. var i = 0;
  12665. var l = fnMap.length;
  12666. var ret = {};
  12667. for (; i < l; i++) {
  12668. val = fnMap[i];
  12669. if (val && val[1] in document) {
  12670. for (i = 0, valLength = val.length; i < valLength; i++) {
  12671. ret[fnMap[0][i]] = val[i];
  12672. }
  12673. return ret;
  12674. }
  12675. }
  12676. return false;
  12677. })();
  12678. var screenfull = {
  12679. request: function(elem) {
  12680. var request = fn.requestFullscreen;
  12681. elem = elem || document.documentElement;
  12682. // Work around Safari 5.1 bug: reports support for
  12683. // keyboard in fullscreen even though it doesn't.
  12684. // Browser sniffing, since the alternative with
  12685. // setTimeout is even worse.
  12686. if (/5\.1[\.\d]* Safari/.test(navigator.userAgent)) {
  12687. elem[request]();
  12688. } else {
  12689. elem[request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT);
  12690. }
  12691. },
  12692. exit: function() {
  12693. document[fn.exitFullscreen]();
  12694. },
  12695. toggle: function(elem) {
  12696. if (this.isFullscreen) {
  12697. this.exit();
  12698. } else {
  12699. this.request(elem);
  12700. }
  12701. },
  12702. raw: fn
  12703. };
  12704. if (!fn) {
  12705. return false;
  12706. }
  12707. Object.defineProperties(screenfull, {
  12708. isFullscreen: {
  12709. get: function() {
  12710. return !!document[fn.fullscreenElement];
  12711. }
  12712. },
  12713. element: {
  12714. enumerable: true,
  12715. get: function() {
  12716. return document[fn.fullscreenElement];
  12717. }
  12718. },
  12719. enabled: {
  12720. enumerable: true,
  12721. get: function() {
  12722. // Coerce to boolean in case of old WebKit
  12723. return !!document[fn.fullscreenEnabled];
  12724. }
  12725. }
  12726. });
  12727. screenfull.VERSION = '2.0.0';
  12728. return screenfull;
  12729. })();
  12730. module.exports = UI.fullscreen = screenfull;
  12731. /***/ },
  12732. /* 33 */
  12733. /***/ function(module, exports, __webpack_require__) {
  12734. 'use strict';
  12735. var $ = __webpack_require__(1);
  12736. var UI = __webpack_require__(2);
  12737. UI.support.geolocation = window.navigator && window.navigator.geolocation;
  12738. var geo = UI.support.geolocation;
  12739. var Geolocation = function(options) {
  12740. this.options = options || {};
  12741. };
  12742. Geolocation.MESSAGES = {
  12743. unsupportedBrowser: 'Browser does not support location services',
  12744. permissionDenied: 'You have rejected access to your location',
  12745. positionUnavailable: 'Unable to determine your location',
  12746. timeout: 'Service timeout has been reached'
  12747. };
  12748. Geolocation.ERROR_CODE = {
  12749. 0: 'unsupportedBrowser',
  12750. 1: 'permissionDenied',
  12751. 2: 'positionUnavailable',
  12752. 3: 'timeout'
  12753. };
  12754. Geolocation.prototype.get = function(options) {
  12755. var _this = this;
  12756. options = $.extend({}, this.options, options);
  12757. var deferred = new $.Deferred();
  12758. if (geo) {
  12759. this.watchID = geo.getCurrentPosition(function(position) {
  12760. deferred.resolve.call(_this, position);
  12761. }, function(error) {
  12762. deferred.reject(Geolocation.MESSAGES[Geolocation.ERROR_CODE[error.code]]);
  12763. }, options);
  12764. } else {
  12765. deferred.reject(Geolocation.MESSAGES.unsupportedBrowser);
  12766. }
  12767. return deferred.promise();
  12768. };
  12769. Geolocation.prototype.watch = function(options) {
  12770. if (!geo) {
  12771. return;
  12772. }
  12773. options = $.extend({}, this.options, options);
  12774. if (!$.isFunction(options.done)) {
  12775. return;
  12776. }
  12777. this.clearWatch();
  12778. var fail = $.isFunction(options.fail) ? options.fail : null;
  12779. this.watchID = geo.watchPosition(options.done, fail, options);
  12780. return this.watchID;
  12781. };
  12782. Geolocation.prototype.clearWatch = function() {
  12783. if (!geo || !this.watchID) {
  12784. return;
  12785. }
  12786. geo.clearWatch(this.watchID);
  12787. this.watchID = null;
  12788. };
  12789. module.exports = UI.Geolocation = Geolocation;
  12790. /***/ },
  12791. /* 34 */
  12792. /***/ function(module, exports, __webpack_require__) {
  12793. 'use strict';
  12794. var UI = __webpack_require__(2);
  12795. /**
  12796. * store.js
  12797. * @via https://github.com/marcuswestin/store.js
  12798. * @license https://github.com/marcuswestin/store.js/blob/master/LICENSE
  12799. */
  12800. var store = {};
  12801. var win = window;
  12802. var localStorageName = 'localStorage';
  12803. var storage;
  12804. store.disabled = false;
  12805. store.version = '1.3.17';
  12806. store.set = function(key, value) {
  12807. };
  12808. store.get = function(key, defaultVal) {
  12809. };
  12810. store.has = function(key) {
  12811. return store.get(key) !== undefined;
  12812. };
  12813. store.remove = function(key) {
  12814. };
  12815. store.clear = function() {
  12816. };
  12817. store.transact = function(key, defaultVal, transactionFn) {
  12818. if (transactionFn == null) {
  12819. transactionFn = defaultVal;
  12820. defaultVal = null;
  12821. }
  12822. if (defaultVal == null) {
  12823. defaultVal = {};
  12824. }
  12825. var val = store.get(key, defaultVal);
  12826. transactionFn(val);
  12827. store.set(key, val);
  12828. };
  12829. store.getAll = function() {
  12830. };
  12831. store.forEach = function() {
  12832. };
  12833. store.serialize = function(value) {
  12834. return JSON.stringify(value);
  12835. };
  12836. store.deserialize = function(value) {
  12837. if (typeof value != 'string') {
  12838. return undefined;
  12839. }
  12840. try {
  12841. return JSON.parse(value);
  12842. } catch (e) {
  12843. return value || undefined;
  12844. }
  12845. };
  12846. // Functions to encapsulate questionable FireFox 3.6.13 behavior
  12847. // when about.config::dom.storage.enabled === false
  12848. // See https://github.com/marcuswestin/store.js/issues#issue/13
  12849. function isLocalStorageNameSupported() {
  12850. try {
  12851. return (localStorageName in win && win[localStorageName]);
  12852. }
  12853. catch (err) {
  12854. return false;
  12855. }
  12856. }
  12857. if (isLocalStorageNameSupported()) {
  12858. storage = win[localStorageName];
  12859. store.set = function(key, val) {
  12860. if (val === undefined) {
  12861. return store.remove(key);
  12862. }
  12863. storage.setItem(key, store.serialize(val));
  12864. return val;
  12865. };
  12866. store.get = function(key, defaultVal) {
  12867. var val = store.deserialize(storage.getItem(key));
  12868. return (val === undefined ? defaultVal : val);
  12869. };
  12870. store.remove = function(key) {
  12871. storage.removeItem(key);
  12872. };
  12873. store.clear = function() {
  12874. storage.clear();
  12875. };
  12876. store.getAll = function() {
  12877. var ret = {};
  12878. store.forEach(function(key, val) {
  12879. ret[key] = val;
  12880. });
  12881. return ret;
  12882. };
  12883. store.forEach = function(callback) {
  12884. for (var i = 0; i < storage.length; i++) {
  12885. var key = storage.key(i);
  12886. callback(key, store.get(key));
  12887. }
  12888. };
  12889. }
  12890. try {
  12891. var testKey = '__storeJs__';
  12892. store.set(testKey, testKey);
  12893. if (store.get(testKey) != testKey) {
  12894. store.disabled = true;
  12895. }
  12896. store.remove(testKey);
  12897. } catch (e) {
  12898. store.disabled = true;
  12899. }
  12900. store.enabled = !store.disabled;
  12901. module.exports = UI.store = store;
  12902. /***/ },
  12903. /* 35 */
  12904. /***/ function(module, exports, __webpack_require__) {
  12905. 'use strict';
  12906. var $ = __webpack_require__(1);
  12907. var UI = __webpack_require__(2);
  12908. __webpack_require__(7);
  12909. function accordionInit() {
  12910. var $accordion = $('[data-am-widget="accordion"]');
  12911. var selector = {
  12912. item: '.am-accordion-item',
  12913. title: '.am-accordion-title',
  12914. body: '.am-accordion-bd',
  12915. disabled: '.am-disabled'
  12916. };
  12917. $accordion.each(function(i, item) {
  12918. var options = UI.utils.parseOptions($(item).attr('data-am-accordion'));
  12919. var $title = $(item).find(selector.title);
  12920. $title.on('click.accordion.amui', function() {
  12921. var $collapse = $(this).next(selector.body);
  12922. var $parent = $(this).parent(selector.item);
  12923. var data = $collapse.data('amui.collapse');
  12924. if ($parent.is(selector.disabled)) {
  12925. return;
  12926. }
  12927. $parent.toggleClass('am-active');
  12928. if (!data) {
  12929. $collapse.collapse();
  12930. } else {
  12931. $collapse.collapse('toggle');
  12932. }
  12933. !options.multiple &&
  12934. $(item).children('.am-active').
  12935. not($parent).not(selector.disabled).removeClass('am-active').
  12936. find(selector.body + '.am-in').collapse('close');
  12937. });
  12938. });
  12939. }
  12940. // Init on DOM ready
  12941. $(accordionInit);
  12942. module.exports = UI.accordion = {
  12943. VERSION: '2.1.0',
  12944. init: accordionInit
  12945. };
  12946. /***/ },
  12947. /* 36 */
  12948. /***/ function(module, exports) {
  12949. 'use strict';
  12950. module.exports = {
  12951. VERSION: '2.0.1'
  12952. };
  12953. /***/ },
  12954. /* 37 */
  12955. /***/ function(module, exports, __webpack_require__) {
  12956. 'use strict';
  12957. var $ = __webpack_require__(1);
  12958. var UI = __webpack_require__(2);
  12959. function duoshuoInit() {
  12960. var $dsThread = $('.ds-thread');
  12961. var dsShortName = $dsThread.parent('[data-am-widget="duoshuo"]').
  12962. attr('data-ds-short-name');
  12963. var dsSrc = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
  12964. '//static.duoshuo.com/embed.js';
  12965. if (!$dsThread.length || !dsShortName) {
  12966. return;
  12967. }
  12968. window.duoshuoQuery = {
  12969. short_name: dsShortName
  12970. };
  12971. // �Ѿ��ж�˵�ű�
  12972. if ($('script[src="' + dsSrc + '"]').length) {
  12973. return;
  12974. }
  12975. var $dsJS = $('<script>', {
  12976. async: true,
  12977. type: 'text/javascript',
  12978. src: dsSrc,
  12979. charset: 'utf-8'
  12980. });
  12981. $('body').append($dsJS);
  12982. }
  12983. $(window).on('load', duoshuoInit);
  12984. module.exports = UI.duoshuo = {
  12985. VERSION: '2.0.1',
  12986. init: duoshuoInit
  12987. };
  12988. /***/ },
  12989. /* 38 */
  12990. /***/ function(module, exports, __webpack_require__) {
  12991. 'use strict';
  12992. var $ = __webpack_require__(1);
  12993. var UI = __webpack_require__(2);
  12994. __webpack_require__(20);
  12995. /**
  12996. * Is Images zoomable
  12997. * @return {Boolean}
  12998. */
  12999. $.isImgZoomAble = function(element) {
  13000. var t = new Image();
  13001. t.src = element.src;
  13002. var zoomAble = ($(element).width() < t.width);
  13003. if (zoomAble) {
  13004. $(element).closest('.am-figure').addClass('am-figure-zoomable');
  13005. }
  13006. return zoomAble;
  13007. };
  13008. function figureInit() {
  13009. $('.am-figure').each(function(i, item) {
  13010. var options = UI.utils.parseOptions($(item).attr('data-am-figure'));
  13011. var $item = $(item);
  13012. var data;
  13013. if (options.pureview) {
  13014. if (options.pureview === 'auto') {
  13015. var zoomAble = $.isImgZoomAble($item.find('img')[0]);
  13016. zoomAble && $item.pureview();
  13017. } else {
  13018. $item.addClass('am-figure-zoomable').pureview();
  13019. }
  13020. }
  13021. data = $item.data('amui.pureview');
  13022. if (data) {
  13023. $item.on('click', ':not(img)', function() {
  13024. data.open(0);
  13025. });
  13026. }
  13027. });
  13028. }
  13029. $(window).on('load', figureInit);
  13030. module.exports = UI.figure = {
  13031. VERSION: '2.0.3',
  13032. init: figureInit
  13033. };
  13034. /***/ },
  13035. /* 39 */
  13036. /***/ function(module, exports, __webpack_require__) {
  13037. 'use strict';
  13038. var $ = __webpack_require__(1);
  13039. var UI = __webpack_require__(2);
  13040. __webpack_require__(15);
  13041. var addToHS = __webpack_require__(4);
  13042. var cookie = __webpack_require__(31);
  13043. function footerInit() {
  13044. // modal mode
  13045. $('.am-footer-ysp').on('click', function() {
  13046. $('#am-footer-modal').modal();
  13047. });
  13048. var options = UI.utils.parseOptions($('.am-footer').data('amFooter'));
  13049. options.addToHS && addToHS();
  13050. // switch mode
  13051. // switch to desktop
  13052. $('[data-rel="desktop"]').on('click', function(e) {
  13053. e.preventDefault();
  13054. if (window.AMPlatform) { // front end
  13055. window.AMPlatform.util.goDesktop();
  13056. } else { // back end
  13057. cookie.set('allmobilize', 'desktop', '', '/');
  13058. window.location = window.location;
  13059. }
  13060. });
  13061. }
  13062. $(footerInit);
  13063. module.exports = UI.footer = {
  13064. VERSION: '3.1.2',
  13065. init: footerInit
  13066. };
  13067. /***/ },
  13068. /* 40 */
  13069. /***/ function(module, exports, __webpack_require__) {
  13070. 'use strict';
  13071. var $ = __webpack_require__(1);
  13072. var UI = __webpack_require__(2);
  13073. __webpack_require__(20);
  13074. function galleryInit() {
  13075. var $gallery = $('[data-am-widget="gallery"]');
  13076. $gallery.each(function() {
  13077. var options = UI.utils.parseOptions($(this).attr('data-am-gallery'));
  13078. if (options.pureview) {
  13079. (typeof options.pureview === 'object') ?
  13080. $(this).pureview(options.pureview) : $(this).pureview();
  13081. }
  13082. });
  13083. }
  13084. $(galleryInit);
  13085. module.exports = UI.gallery = {
  13086. VERSION: '3.0.0',
  13087. init: galleryInit
  13088. };
  13089. /***/ },
  13090. /* 41 */
  13091. /***/ function(module, exports, __webpack_require__) {
  13092. 'use strict';
  13093. var $ = __webpack_require__(1);
  13094. var UI = __webpack_require__(2);
  13095. __webpack_require__(23);
  13096. function goTopInit() {
  13097. var $goTop = $('[data-am-widget="gotop"]');
  13098. var $fixed = $goTop.filter('.am-gotop-fixed');
  13099. var $win = $(window);
  13100. if ($goTop.data('init')) {
  13101. return;
  13102. }
  13103. $goTop.find('a').on('click', function(e) {
  13104. e.preventDefault();
  13105. $win.smoothScroll();
  13106. });
  13107. function checkPosition() {
  13108. $fixed[($win.scrollTop() > 50 ? 'add' : 'remove') + 'Class']('am-active');
  13109. }
  13110. checkPosition();
  13111. $win.on('scroll.gotop.amui', UI.utils.debounce(checkPosition, 100));
  13112. $goTop.data('init', true);
  13113. }
  13114. $(goTopInit);
  13115. module.exports = UI.gotop = {
  13116. VERSION: '4.0.2',
  13117. init: goTopInit
  13118. };
  13119. /***/ },
  13120. /* 42 */
  13121. /***/ function(module, exports, __webpack_require__) {
  13122. 'use strict';
  13123. var $ = __webpack_require__(1);
  13124. var UI = __webpack_require__(2);
  13125. function headerInit() {
  13126. $('[data-am-widget="header"]').each(function() {
  13127. if ($(this).hasClass('am-header-fixed')) {
  13128. $('body').addClass('am-with-fixed-header');
  13129. return false;
  13130. }
  13131. });
  13132. }
  13133. $(headerInit);
  13134. module.exports = UI.header = {
  13135. VERSION: '2.0.0',
  13136. init: headerInit
  13137. };
  13138. /***/ },
  13139. /* 43 */
  13140. /***/ function(module, exports, __webpack_require__) {
  13141. 'use strict';
  13142. var UI = __webpack_require__(2);
  13143. module.exports = UI.intro = {
  13144. VERSION: '4.0.2',
  13145. init: function() {}
  13146. };
  13147. /***/ },
  13148. /* 44 */
  13149. /***/ function(module, exports, __webpack_require__) {
  13150. 'use strict';
  13151. var UI = __webpack_require__(2);
  13152. module.exports = UI.listNews = {
  13153. VERSION: '4.0.0',
  13154. init: function() {}
  13155. };
  13156. /***/ },
  13157. /* 45 */
  13158. /***/ function(module, exports, __webpack_require__) {
  13159. /* jshint strict: false, maxlen: 200 */
  13160. /* global BMap */
  13161. var $ = __webpack_require__(1);
  13162. var UI = __webpack_require__(2);
  13163. function addMapApi(callback) {
  13164. var $mapApi0 = $('<script />', {
  13165. id: 'am-map-api-0'
  13166. });
  13167. $('body').append($mapApi0);
  13168. $mapApi0.on('load', function() {
  13169. console.log('load');
  13170. var $mapApi1 = $('<script/>', {
  13171. id: 'am-map-api-1'
  13172. });
  13173. $('body').append($mapApi1);
  13174. $mapApi1.on('load', function() {
  13175. var script = document.createElement('script');
  13176. script.textContent = '(' + callback.toString() + ')();';
  13177. $('body')[0].appendChild(script);
  13178. }).attr('src', 'http://api.map.baidu.com/getscript' +
  13179. '?type=quick&file=feature' +
  13180. '&ak=WVAXZ05oyNRXS5egLImmentg&t=20140109092002');
  13181. }).attr('src', 'http://api.map.baidu.com/getscript' +
  13182. '?type=quick&file=api&ak=WVAXZ05oyNRXS5egLImmentg&t=20140109092002');
  13183. // jQuery �� `load` �¼����������⣬��̬���� src ���ԲŻᴥ�� `load` �¼�
  13184. // $mapApi0 = $('<script />', {src: 'xxx'}); ������д���� Zepto.js ����û������
  13185. }
  13186. function addBdMap() {
  13187. // ���ʹ�� $ ѡ�����minify �Ժ�ᱨ��: $ is undefined
  13188. // ��ʹ���� $ Ҳ��Ч����Ϊʹ��ԭ������
  13189. // ���������Ϊ callback ����뵽 body �Ժ��ִ�У�Ӧ���� $ ���ô�����
  13190. var content = document.querySelector('.am-map');
  13191. var defaultLng = 116.331398; // ����Ĭ��ֵ
  13192. var defaultLat = 39.897445; // γ��Ĭ��ֵ
  13193. var name = content.getAttribute('data-name');
  13194. var address = content.getAttribute('data-address');
  13195. var lng = content.getAttribute('data-longitude') || defaultLng;
  13196. var lat = content.getAttribute('data-latitude') || defaultLat;
  13197. var setZoom = content.getAttribute('data-setZoom') || 17;
  13198. var icon = content.getAttribute('data-icon');
  13199. var map = new BMap.Map('bd-map');
  13200. // ʵ����һ�����������
  13201. var point = new BMap.Point(lng, lat);
  13202. // ���ʼ����ͼ, options: 3-18
  13203. map.centerAndZoom(point, setZoom);
  13204. // ��ӵ�ͼ���ſؼ�
  13205. if (content.getAttribute('data-zoomControl')) {
  13206. map.addControl(new BMap.ZoomControl());
  13207. }
  13208. // ��ӱ����߿ؼ�
  13209. if (content.getAttribute('data-scaleControl')) {
  13210. map.addControl(new BMap.ScaleControl());
  13211. }
  13212. // ������׼���Զ��� icon
  13213. var marker = new BMap.Marker(point);
  13214. if (icon) {
  13215. marker.setIcon(new BMap.Icon(icon, new BMap.Size(40, 40)));
  13216. }
  13217. var opts = {
  13218. width: 200, // ��Ϣ���ڿ��
  13219. // height: 'auto', // ��Ϣ���ڸ߶�
  13220. title: name // ��Ϣ���ڱ���
  13221. };
  13222. // ������Ϣ���ڶ���
  13223. var infoWindow = new BMap.InfoWindow('��ַ��' + address, opts);
  13224. // ������ַ������ʵ��
  13225. var myGeo = new BMap.Geocoder();
  13226. // �ж���û��ʹ�þ�γ��
  13227. if (lng == defaultLng && lat == defaultLat) {
  13228. // ʹ�õ�ַ�����������õ�ͼ
  13229. // ����ַ���������ʾ�ڵ�ͼ��,��������ͼ��Ұ
  13230. myGeo.getPoint(address, function(point) {
  13231. if (point) {
  13232. map.centerAndZoom(point, setZoom);
  13233. marker.setPosition(point);
  13234. map.addOverlay(marker);
  13235. map.openInfoWindow(infoWindow, point); // ������Ϣ����
  13236. }
  13237. }, '');
  13238. } else {
  13239. // ʹ�þ�γ�������õ�ͼ
  13240. myGeo.getLocation(point, function(result) {
  13241. map.centerAndZoom(point, setZoom);
  13242. marker.setPosition(point);
  13243. map.addOverlay(marker);
  13244. if (address) {
  13245. map.openInfoWindow(infoWindow, point); // ������Ϣ����
  13246. } else {
  13247. map.openInfoWindow(new BMap.InfoWindow(address, opts), point); // ������Ϣ����
  13248. }
  13249. });
  13250. }
  13251. }
  13252. var mapInit = function() {
  13253. $('.am-map').length && addMapApi(addBdMap);
  13254. };
  13255. $(mapInit);
  13256. module.exports = UI.map = {
  13257. VERSION: '2.0.2',
  13258. init: mapInit
  13259. };
  13260. /***/ },
  13261. /* 46 */
  13262. /***/ function(module, exports, __webpack_require__) {
  13263. 'use strict';
  13264. var $ = __webpack_require__(1);
  13265. var UI = __webpack_require__(2);
  13266. function mechatInit() {
  13267. if (!$('#mechat').length) {
  13268. return;
  13269. }
  13270. var $mechat = $('[data-am-widget="mechat"]');
  13271. var unitid = $mechat.data('am-mechat-unitid');
  13272. var $mechatData = $('<script>', {
  13273. charset: 'utf-8',
  13274. src: 'http://mechatim.com/js/unit/button.js?id=' + unitid
  13275. });
  13276. $('body').append($mechatData);
  13277. }
  13278. // Lazy load
  13279. $(window).on('load', mechatInit);
  13280. module.exports = UI.mechat = {
  13281. VERSION: '2.0.1',
  13282. init: mechatInit
  13283. };
  13284. /***/ },
  13285. /* 47 */
  13286. /***/ function(module, exports, __webpack_require__) {
  13287. 'use strict';
  13288. var $ = __webpack_require__(1);
  13289. var UI = __webpack_require__(2);
  13290. var IScroll = __webpack_require__(14);
  13291. __webpack_require__(16);
  13292. __webpack_require__(7);
  13293. var menuInit = function() {
  13294. var $menus = $('[data-am-widget="menu"]');
  13295. $menus.find('.am-menu-nav .am-parent > a').on('click', function(e) {
  13296. e.preventDefault();
  13297. var $clicked = $(this);
  13298. var $parent = $clicked.parent();
  13299. var $subMenu = $clicked.next('.am-menu-sub');
  13300. $parent.toggleClass('am-open');
  13301. $subMenu.collapse('toggle');
  13302. $parent.siblings('.am-parent').removeClass('am-open')
  13303. .children('.am-menu-sub.am-in').collapse('close');
  13304. });
  13305. // Dropdown/slideDown menu
  13306. $menus.
  13307. filter('[data-am-menu-collapse]').
  13308. find('> .am-menu-toggle').
  13309. on('click', function(e) {
  13310. e.preventDefault();
  13311. var $this = $(this);
  13312. var $nav = $this.next('.am-menu-nav');
  13313. $this.toggleClass('am-active');
  13314. $nav.collapse('toggle');
  13315. });
  13316. // OffCanvas menu
  13317. $menus.
  13318. filter('[data-am-menu-offcanvas]').
  13319. find('> .am-menu-toggle').
  13320. on('click', function(e) {
  13321. e.preventDefault();
  13322. var $this = $(this);
  13323. var $nav = $this.next('.am-offcanvas');
  13324. $this.toggleClass('am-active');
  13325. $nav.offCanvas('open');
  13326. });
  13327. // Close offCanvas when link clicked
  13328. var autoCloseOffCanvas = '.am-offcanvas[data-dismiss-on="click"]';
  13329. var $autoCloseOffCanvas = $(autoCloseOffCanvas);
  13330. $autoCloseOffCanvas.find('a').not('.am-parent>a').on('click', function(e) {
  13331. $(this).parents(autoCloseOffCanvas).offCanvas('close');
  13332. });
  13333. // one theme
  13334. $menus.filter('.am-menu-one').each(function(index) {
  13335. var $this = $(this);
  13336. var $wrap = $('<div class="am-menu-nav-sub-wrap"></div>');
  13337. var allWidth = 0;
  13338. var $nav = $this.find('.am-menu-nav');
  13339. var $navTopItem = $nav.children('li');
  13340. var prevIndex;
  13341. $navTopItem.filter('.am-parent').each(function(index) {
  13342. $(this).attr('data-rel', '#am-menu-sub-' + index);
  13343. $(this).
  13344. find('.am-menu-sub').
  13345. attr('id', 'am-menu-sub-' + index).
  13346. appendTo($wrap);
  13347. });
  13348. $this.append($wrap);
  13349. $nav.wrap('<div class="am-menu-nav-wrap" id="am-menu-' + index + '">');
  13350. // $navTopItem.eq(0).addClass('am-active');
  13351. // ��������� li ���
  13352. $navTopItem.each(function(i) {
  13353. allWidth += parseFloat($(this).css('width'));
  13354. });
  13355. $nav.width(allWidth);
  13356. var menuScroll = new IScroll('#am-menu-' + index, {
  13357. eventPassthrough: true,
  13358. scrollX: true,
  13359. scrollY: false,
  13360. preventDefault: false
  13361. });
  13362. $navTopItem.on('click', function() {
  13363. var $clicked = $(this);
  13364. $clicked.addClass('am-active').siblings().removeClass('am-active');
  13365. $wrap.find('.am-menu-sub.am-in').collapse('close');
  13366. if ($clicked.is('.am-parent')) {
  13367. !$clicked.hasClass('.am-open') &&
  13368. $wrap.find($clicked.attr('data-rel')).collapse('open');
  13369. } else {
  13370. $clicked.siblings().removeClass('am-open');
  13371. }
  13372. // ��һ�ε��ã�û��prevIndex
  13373. if (prevIndex === undefined) {
  13374. prevIndex = $(this).index() ? 0 : 1;
  13375. }
  13376. // �жϷ���
  13377. var dir = $(this).index() > prevIndex;
  13378. var target = $(this)[dir ? 'next' : 'prev']();
  13379. // ����İ�ť����ʾһ��
  13380. var offset = target.offset() || $(this).offset();
  13381. var within = $this.offset();
  13382. // ������߾�
  13383. var listOffset;
  13384. var parentLeft = parseInt($this.css('padding-left'));
  13385. if (dir ? offset.left + offset.width > within.left + within.width :
  13386. offset.left < within.left) {
  13387. listOffset = $nav.offset();
  13388. menuScroll.scrollTo(dir ?
  13389. within.width - offset.left + listOffset.left -
  13390. offset.width - parentLeft :
  13391. listOffset.left - offset.left, 0, 400);
  13392. }
  13393. prevIndex = $(this).index();
  13394. });
  13395. $this.on('touchmove', function(event) {
  13396. event.preventDefault();
  13397. });
  13398. });
  13399. };
  13400. $(menuInit);
  13401. module.exports = UI.menu = {
  13402. VERSION: '4.0.3',
  13403. init: menuInit
  13404. };
  13405. /***/ },
  13406. /* 48 */
  13407. /***/ function(module, exports, __webpack_require__) {
  13408. 'use strict';
  13409. var $ = __webpack_require__(1);
  13410. var UI = __webpack_require__(2);
  13411. var share = __webpack_require__(25);
  13412. var QRCode = __webpack_require__(26);
  13413. __webpack_require__(15);
  13414. function navbarInit() {
  13415. var $navBar = $('[data-am-widget="navbar"]');
  13416. if (!$navBar.length) {
  13417. return;
  13418. }
  13419. var $win = $(window);
  13420. var $body = $('body');
  13421. var $navBarNav = $navBar.find('.am-navbar-nav');
  13422. var $navItems = $navBar.find('li');
  13423. var navItemsCounter = $navItems.length;
  13424. var configItems = $navBarNav.attr('class') &&
  13425. parseInt($navBarNav.attr('class').
  13426. match(/am-avg-sm-(\d+)/)[1]) || 3;
  13427. var navMinWidth = 60; // ÿ�� li ��С���
  13428. var offsetWidth = 16;
  13429. var $share = $navItems.filter('[data-am-navbar-share]');
  13430. var $qrcode = $navItems.filter('[data-am-navbar-qrcode]');
  13431. var activeStatus = 'am-active';
  13432. var $moreActions = $('<ul class="am-navbar-actions"></ul>', {
  13433. id: UI.utils.generateGUID('am-navbar-actions')
  13434. });
  13435. var $moreLink = $('<li class="am-navbar-labels am-navbar-more">' +
  13436. '<a href="javascript: void(0);">' +
  13437. '<span class="am-icon-angle-up"></span>' +
  13438. '<span class="am-navbar-label">����</span></a></li>');
  13439. // ����� Fix ������������ body �� padding-bottom
  13440. if ($navBar.css('position') == 'fixed') {
  13441. $body.addClass('am-with-fixed-navbar');
  13442. }
  13443. if ($qrcode.length) {
  13444. var qrId = 'am-navbar-qrcode';
  13445. $qrModal = $('#' + qrId);
  13446. if (!$qrModal.length) {
  13447. var qrImg = $qrcode.attr('data-am-navbar-qrcode');
  13448. var $qrModal = $('<div class="am-modal am-modal-no-btn" id="">' +
  13449. '<div class="am-modal-dialog">' +
  13450. '<div class="am-modal-bd"></div></div>' +
  13451. '</div>', {
  13452. id: qrId
  13453. });
  13454. var $qrContainer = $qrModal.find('.am-modal-bd');
  13455. // �ж��ϴ��Զ���Ķ�ά��û�У��������ɶ�ά��
  13456. if (qrImg) {
  13457. $qrContainer.html('<img src="' + qrImg + '"/>');
  13458. } else {
  13459. var qrnode = new QRCode({
  13460. render: 'canvas',
  13461. correctLevel: 0,
  13462. text: window.location.href,
  13463. width: 200,
  13464. height: 200,
  13465. background: '#fff',
  13466. foreground: '#000'
  13467. });
  13468. $qrContainer.html(qrnode);
  13469. }
  13470. $body.append($qrModal);
  13471. }
  13472. $qrcode.on('click', function(e) {
  13473. e.preventDefault();
  13474. $qrModal.modal();
  13475. });
  13476. }
  13477. if (navItemsCounter > configItems && navItemsCounter > calcSuiteItems()) {
  13478. initActions();
  13479. }
  13480. // console.log('NavItems: %d, config: %d, best: %d',
  13481. // navItemsCounter, configItems, calcSuiteItems());
  13482. function initActions() {
  13483. $navBarNav.append($moreLink);
  13484. $navBarNav.
  13485. find('li').
  13486. not('.am-navbar-more').
  13487. slice(calcSuiteItems() - 1).
  13488. appendTo($moreActions);
  13489. // Append more actions
  13490. $navBar.append($moreActions);
  13491. }
  13492. function checkNavBarItems() {
  13493. if (calcSuiteItems() >= navItemsCounter) {
  13494. // ��ʾ�������ӣ����� more
  13495. $moreLink.hide();
  13496. $moreActions.find('li').insertBefore($moreLink);
  13497. return;
  13498. }
  13499. !$navBar.find('.am-navbar-actions').length && initActions();
  13500. $moreLink.show();
  13501. if ($navBarNav.find('li').length < calcSuiteItems()) {
  13502. $moreActions.find('li').
  13503. slice(0, calcSuiteItems() - $navBarNav.find('li').length).
  13504. insertBefore($moreLink);
  13505. } else if ($navBarNav.find('li').length > calcSuiteItems()) {
  13506. if ($moreActions.find('li').length) {
  13507. $navBarNav.find('li').not($moreLink).slice(calcSuiteItems() - 1).
  13508. insertBefore($moreActions.find('li').first());
  13509. } else {
  13510. $navBarNav.find('li').not($moreLink).slice(calcSuiteItems() - 1).
  13511. appendTo($moreActions);
  13512. }
  13513. }
  13514. }
  13515. /**
  13516. * �������ʺ���ʾ����Ŀ����
  13517. * @returns {number}
  13518. */
  13519. function calcSuiteItems() {
  13520. return Math.floor(($win.width() - offsetWidth) / navMinWidth);
  13521. }
  13522. $navBar.on('click.navbar.amui', '.am-navbar-more', function(e) {
  13523. e.preventDefault();
  13524. $moreLink[$moreActions.hasClass(activeStatus) ?
  13525. 'removeClass' : 'addClass'](activeStatus);
  13526. $moreActions.toggleClass(activeStatus);
  13527. });
  13528. if ($share.length) {
  13529. $share.on('click.navbar.amui', function(e) {
  13530. e.preventDefault();
  13531. share.toggle();
  13532. });
  13533. }
  13534. $win.on('resize.navbar.amui orientationchange.navbar.amui',
  13535. UI.utils.debounce(checkNavBarItems, 150));
  13536. }
  13537. // DOMContent ready
  13538. $(navbarInit);
  13539. module.exports = UI.navbar = {
  13540. VERSION: '2.0.2',
  13541. init: navbarInit
  13542. };
  13543. /***/ },
  13544. /* 49 */
  13545. /***/ function(module, exports, __webpack_require__) {
  13546. 'use strict';
  13547. var UI = __webpack_require__(2);
  13548. module.exports = UI.pagination = {
  13549. VERSION: '3.0.1'
  13550. };
  13551. /***/ },
  13552. /* 50 */
  13553. /***/ function(module, exports, __webpack_require__) {
  13554. 'use strict';
  13555. var $ = __webpack_require__(1);
  13556. var UI = __webpack_require__(2);
  13557. var IScroll = __webpack_require__(14);
  13558. __webpack_require__(20);
  13559. /**
  13560. * ������
  13561. * @param {number} index ID ��ʶ����� paragraph ������ table
  13562. */
  13563. $.fn.scrollTable = function(index) {
  13564. var $this = $(this);
  13565. var $parent;
  13566. $this.wrap('<div class="am-paragraph-table-container" ' +
  13567. 'id="am-paragraph-table-' + index + '">' +
  13568. '<div class="am-paragraph-table-scroller"></div></div>');
  13569. $parent = $this.parent();
  13570. $parent.width($this.width());
  13571. $parent.height($this.height());
  13572. new IScroll('#am-paragraph-table-' + index, {
  13573. eventPassthrough: true,
  13574. scrollX: true,
  13575. scrollY: false,
  13576. preventDefault: false
  13577. });
  13578. };
  13579. function paragraphInit() {
  13580. var $paragraph = $('[data-am-widget="paragraph"]');
  13581. $paragraph.each(function(index) {
  13582. var $this = $(this);
  13583. var options = UI.utils.parseOptions($this.attr('data-am-paragraph'));
  13584. var $index = index;
  13585. if (options.pureview) {
  13586. $this.pureview();
  13587. }
  13588. if (options.tableScrollable) {
  13589. $this.find('table').each(function(index) {
  13590. if ($(this).width() > $(window).width()) {
  13591. $(this).scrollTable($index + '-' + index);
  13592. }
  13593. });
  13594. }
  13595. });
  13596. }
  13597. $(window).on('load', paragraphInit);
  13598. module.exports = UI.paragraph = {
  13599. VERSION: '2.0.1',
  13600. init: paragraphInit
  13601. };
  13602. /***/ },
  13603. /* 51 */
  13604. /***/ function(module, exports, __webpack_require__) {
  13605. 'use strict';
  13606. var $ = __webpack_require__(1);
  13607. var UI = __webpack_require__(2);
  13608. __webpack_require__(11);
  13609. function sliderInit() {
  13610. var $sliders = $('[data-am-widget="slider"]');
  13611. $sliders.not('.am-slider-manual').each(function(i, item) {
  13612. var options = UI.utils.parseOptions($(item).attr('data-am-slider'));
  13613. $(item).flexslider(options);
  13614. });
  13615. }
  13616. $(sliderInit);
  13617. module.exports = UI.slider = {
  13618. VERSION: '3.0.1',
  13619. init: sliderInit
  13620. };
  13621. /***/ },
  13622. /* 52 */
  13623. /***/ function(module, exports, __webpack_require__) {
  13624. 'use strict';
  13625. var $ = __webpack_require__(1);
  13626. var UI = __webpack_require__(2);
  13627. __webpack_require__(28);
  13628. function tabsInit() {
  13629. $('[data-am-widget="tabs"]').each(function() {
  13630. var options = $(this).data('amTabsNoswipe') ? {noSwipe: 1} : {};
  13631. $(this).tabs(options);
  13632. });
  13633. }
  13634. $(tabsInit);
  13635. module.exports = UI.tab = {
  13636. VERSION: '4.0.1',
  13637. init: tabsInit
  13638. };
  13639. /***/ },
  13640. /* 53 */
  13641. /***/ function(module, exports, __webpack_require__) {
  13642. 'use strict';
  13643. var UI = __webpack_require__(2);
  13644. module.exports = UI.titlebar = {
  13645. VERSION: '4.0.1'
  13646. };
  13647. /***/ },
  13648. /* 54 */
  13649. /***/ function(module, exports, __webpack_require__) {
  13650. 'use strict';
  13651. var $ = __webpack_require__(1);
  13652. var UI = __webpack_require__(2);
  13653. var isWeChat = window.navigator.userAgent.indexOf('MicroMessenger') > -1;
  13654. /* global wx,alert */
  13655. function appendWeChatSDK(callback) {
  13656. var $weChatSDK = $('<script/>', {
  13657. id: 'wechat-sdk'
  13658. });
  13659. $('body').append($weChatSDK);
  13660. $weChatSDK.on('load', function() {
  13661. callback && callback();
  13662. }).attr('src', 'http://res.wx.qq.com/open/js/jweixin-1.0.0.js');
  13663. }
  13664. function payHandler() {
  13665. var $paymentBtn = $('[data-am-widget="wechatpay"]');
  13666. if (!isWeChat) {
  13667. $paymentBtn.hide();
  13668. return false;
  13669. }
  13670. $paymentBtn.on('click', '.am-wechatpay-btn', function(e) {
  13671. e.preventDefault();
  13672. var options = UI.utils.parseOptions($(this).parent().data('wechatPay'));
  13673. // console.log(options);
  13674. // alert('pay button clicked');
  13675. if (!window.wx) {
  13676. alert('û��΢�� JS SDK');
  13677. return;
  13678. }
  13679. wx.checkJsApi({
  13680. jsApiList: ['chooseWXPay'],
  13681. success: function(res) {
  13682. if (res.checkResult.chooseWXPay) {
  13683. wx.chooseWXPay(options);
  13684. } else {
  13685. alert('΢�Ű汾��֧��֧���ӿڻ�û�п�����');
  13686. }
  13687. },
  13688. fail: function() {
  13689. alert('���� checkJsApi �ӿ�ʱ��������!');
  13690. }
  13691. });
  13692. });
  13693. }
  13694. var payInit = payHandler;
  13695. // Init on DOM ready
  13696. $(payInit);
  13697. module.exports = UI.pay = {
  13698. VERSION: '1.0.0',
  13699. init: payInit
  13700. };
  13701. /***/ }
  13702. /******/ ])
  13703. });
  13704. ;/**
  13705. * Created by Administrator on 2016/1/26.
  13706. */