a8a9b511f80fca176dafcaf4dc8baa2309e1a529.svn-base 433 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736
  1. /*!
  2. * jQuery Mobile 1.4.0
  3. * Git HEAD hash: f09aae0e035d6805e461a7be246d04a0dbc98f69 <> Date: Thu Dec 19 2013 17:34:22 UTC
  4. * http://jquerymobile.com
  5. *
  6. * Copyright 2010, 2013 jQuery Foundation, Inc. and other contributors
  7. * Released under the MIT license.
  8. * http://jquery.org/license
  9. *
  10. */
  11. (function ( root, doc, factory ) {
  12. if ( typeof define === "function" && define.amd ) {
  13. // AMD. Register as an anonymous module.
  14. define( [ "jquery" ], function ( $ ) {
  15. factory( $, root, doc );
  16. return $.mobile;
  17. });
  18. } else {
  19. // Browser globals
  20. factory( root.jQuery, root, doc );
  21. }
  22. }( this, document, function ( jQuery, window, document, undefined ) {
  23. (function( $ ) {
  24. $.mobile = {};
  25. }( jQuery ));
  26. (function( $, window, undefined ) {
  27. $.extend( $.mobile, {
  28. // Version of the jQuery Mobile Framework
  29. version: "1.4.0",
  30. // Deprecated and no longer used in 1.4 remove in 1.5
  31. // Define the url parameter used for referencing widget-generated sub-pages.
  32. // Translates to example.html&ui-page=subpageIdentifier
  33. // hash segment before &ui-page= is used to make Ajax request
  34. subPageUrlKey: "ui-page",
  35. hideUrlBar: true,
  36. // Keepnative Selector
  37. keepNative: ":jqmData(role='none'), :jqmData(role='nojs')",
  38. // Deprecated in 1.4 remove in 1.5
  39. // Class assigned to page currently in view, and during transitions
  40. activePageClass: "ui-page-active",
  41. // Deprecated in 1.4 remove in 1.5
  42. // Class used for "active" button state, from CSS framework
  43. activeBtnClass: "ui-btn-active",
  44. // Deprecated in 1.4 remove in 1.5
  45. // Class used for "focus" form element state, from CSS framework
  46. focusClass: "ui-focus",
  47. // Automatically handle clicks and form submissions through Ajax, when same-domain
  48. ajaxEnabled: true,
  49. // Automatically load and show pages based on location.hash
  50. hashListeningEnabled: true,
  51. // disable to prevent jquery from bothering with links
  52. linkBindingEnabled: true,
  53. // Set default page transition - 'none' for no transitions
  54. defaultPageTransition: "fade",
  55. // Set maximum window width for transitions to apply - 'false' for no limit
  56. maxTransitionWidth: false,
  57. // Minimum scroll distance that will be remembered when returning to a page
  58. // Deprecated remove in 1.5
  59. minScrollBack: 0,
  60. // Set default dialog transition - 'none' for no transitions
  61. defaultDialogTransition: "pop",
  62. // Error response message - appears when an Ajax page request fails
  63. pageLoadErrorMessage: "Error Loading Page",
  64. // For error messages, which theme does the box uses?
  65. pageLoadErrorMessageTheme: "a",
  66. // replace calls to window.history.back with phonegaps navigation helper
  67. // where it is provided on the window object
  68. phonegapNavigationEnabled: false,
  69. //automatically initialize the DOM when it's ready
  70. autoInitializePage: true,
  71. pushStateEnabled: true,
  72. // allows users to opt in to ignoring content by marking a parent element as
  73. // data-ignored
  74. ignoreContentEnabled: false,
  75. buttonMarkup: {
  76. hoverDelay: 200
  77. },
  78. // disable the alteration of the dynamic base tag or links in the case
  79. // that a dynamic base tag isn't supported
  80. dynamicBaseEnabled: true,
  81. // default the property to remove dependency on assignment in init module
  82. pageContainer: $(),
  83. //enable cross-domain page support
  84. allowCrossDomainPages: false,
  85. dialogHashKey: "&ui-state=dialog"
  86. });
  87. })( jQuery, this );
  88. (function( $, window, undefined ) {
  89. var nsNormalizeDict = {},
  90. oldFind = $.find,
  91. rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
  92. jqmDataRE = /:jqmData\(([^)]*)\)/g;
  93. $.extend( $.mobile, {
  94. // Namespace used framework-wide for data-attrs. Default is no namespace
  95. ns: "",
  96. // Retrieve an attribute from an element and perform some massaging of the value
  97. getAttribute: function( element, key ) {
  98. var data;
  99. element = element.jquery ? element[0] : element;
  100. if ( element && element.getAttribute ) {
  101. data = element.getAttribute( "data-" + $.mobile.ns + key );
  102. }
  103. // Copied from core's src/data.js:dataAttr()
  104. // Convert from a string to a proper data type
  105. try {
  106. data = data === "true" ? true :
  107. data === "false" ? false :
  108. data === "null" ? null :
  109. // Only convert to a number if it doesn't change the string
  110. +data + "" === data ? +data :
  111. rbrace.test( data ) ? JSON.parse( data ) :
  112. data;
  113. } catch( err ) {}
  114. return data;
  115. },
  116. // Expose our cache for testing purposes.
  117. nsNormalizeDict: nsNormalizeDict,
  118. // Take a data attribute property, prepend the namespace
  119. // and then camel case the attribute string. Add the result
  120. // to our nsNormalizeDict so we don't have to do this again.
  121. nsNormalize: function( prop ) {
  122. return nsNormalizeDict[ prop ] ||
  123. ( nsNormalizeDict[ prop ] = $.camelCase( $.mobile.ns + prop ) );
  124. },
  125. // Find the closest javascript page element to gather settings data jsperf test
  126. // http://jsperf.com/single-complex-selector-vs-many-complex-selectors/edit
  127. // possibly naive, but it shows that the parsing overhead for *just* the page selector vs
  128. // the page and dialog selector is negligable. This could probably be speed up by
  129. // doing a similar parent node traversal to the one found in the inherited theme code above
  130. closestPageData: function( $target ) {
  131. return $target
  132. .closest( ":jqmData(role='page'), :jqmData(role='dialog')" )
  133. .data( "mobile-page" );
  134. }
  135. });
  136. // Mobile version of data and removeData and hasData methods
  137. // ensures all data is set and retrieved using jQuery Mobile's data namespace
  138. $.fn.jqmData = function( prop, value ) {
  139. var result;
  140. if ( typeof prop !== "undefined" ) {
  141. if ( prop ) {
  142. prop = $.mobile.nsNormalize( prop );
  143. }
  144. // undefined is permitted as an explicit input for the second param
  145. // in this case it returns the value and does not set it to undefined
  146. if ( arguments.length < 2 || value === undefined ) {
  147. result = this.data( prop );
  148. } else {
  149. result = this.data( prop, value );
  150. }
  151. }
  152. return result;
  153. };
  154. $.jqmData = function( elem, prop, value ) {
  155. var result;
  156. if ( typeof prop !== "undefined" ) {
  157. result = $.data( elem, prop ? $.mobile.nsNormalize( prop ) : prop, value );
  158. }
  159. return result;
  160. };
  161. $.fn.jqmRemoveData = function( prop ) {
  162. return this.removeData( $.mobile.nsNormalize( prop ) );
  163. };
  164. $.jqmRemoveData = function( elem, prop ) {
  165. return $.removeData( elem, $.mobile.nsNormalize( prop ) );
  166. };
  167. $.find = function( selector, context, ret, extra ) {
  168. if ( selector.indexOf( ":jqmData" ) > -1 ) {
  169. selector = selector.replace( jqmDataRE, "[data-" + ( $.mobile.ns || "" ) + "$1]" );
  170. }
  171. return oldFind.call( this, selector, context, ret, extra );
  172. };
  173. $.extend( $.find, oldFind );
  174. })( jQuery, this );
  175. /*!
  176. * jQuery UI Core c0ab71056b936627e8a7821f03c044aec6280a40
  177. * http://jqueryui.com
  178. *
  179. * Copyright 2013 jQuery Foundation and other contributors
  180. * Released under the MIT license.
  181. * http://jquery.org/license
  182. *
  183. * http://api.jqueryui.com/category/ui-core/
  184. */
  185. (function( $, undefined ) {
  186. var uuid = 0,
  187. runiqueId = /^ui-id-\d+$/;
  188. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  189. $.ui = $.ui || {};
  190. $.extend( $.ui, {
  191. version: "c0ab71056b936627e8a7821f03c044aec6280a40",
  192. keyCode: {
  193. BACKSPACE: 8,
  194. COMMA: 188,
  195. DELETE: 46,
  196. DOWN: 40,
  197. END: 35,
  198. ENTER: 13,
  199. ESCAPE: 27,
  200. HOME: 36,
  201. LEFT: 37,
  202. PAGE_DOWN: 34,
  203. PAGE_UP: 33,
  204. PERIOD: 190,
  205. RIGHT: 39,
  206. SPACE: 32,
  207. TAB: 9,
  208. UP: 38
  209. }
  210. });
  211. // plugins
  212. $.fn.extend({
  213. focus: (function( orig ) {
  214. return function( delay, fn ) {
  215. return typeof delay === "number" ?
  216. this.each(function() {
  217. var elem = this;
  218. setTimeout(function() {
  219. $( elem ).focus();
  220. if ( fn ) {
  221. fn.call( elem );
  222. }
  223. }, delay );
  224. }) :
  225. orig.apply( this, arguments );
  226. };
  227. })( $.fn.focus ),
  228. scrollParent: function() {
  229. var scrollParent;
  230. if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  231. scrollParent = this.parents().filter(function() {
  232. return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  233. }).eq(0);
  234. } else {
  235. scrollParent = this.parents().filter(function() {
  236. return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  237. }).eq(0);
  238. }
  239. return ( /fixed/ ).test( this.css( "position") ) || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  240. },
  241. uniqueId: function() {
  242. return this.each(function() {
  243. if ( !this.id ) {
  244. this.id = "ui-id-" + (++uuid);
  245. }
  246. });
  247. },
  248. removeUniqueId: function() {
  249. return this.each(function() {
  250. if ( runiqueId.test( this.id ) ) {
  251. $( this ).removeAttr( "id" );
  252. }
  253. });
  254. }
  255. });
  256. // selectors
  257. function focusable( element, isTabIndexNotNaN ) {
  258. var map, mapName, img,
  259. nodeName = element.nodeName.toLowerCase();
  260. if ( "area" === nodeName ) {
  261. map = element.parentNode;
  262. mapName = map.name;
  263. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  264. return false;
  265. }
  266. img = $( "img[usemap=#" + mapName + "]" )[0];
  267. return !!img && visible( img );
  268. }
  269. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  270. !element.disabled :
  271. "a" === nodeName ?
  272. element.href || isTabIndexNotNaN :
  273. isTabIndexNotNaN) &&
  274. // the element and all of its ancestors must be visible
  275. visible( element );
  276. }
  277. function visible( element ) {
  278. return $.expr.filters.visible( element ) &&
  279. !$( element ).parents().addBack().filter(function() {
  280. return $.css( this, "visibility" ) === "hidden";
  281. }).length;
  282. }
  283. $.extend( $.expr[ ":" ], {
  284. data: $.expr.createPseudo ?
  285. $.expr.createPseudo(function( dataName ) {
  286. return function( elem ) {
  287. return !!$.data( elem, dataName );
  288. };
  289. }) :
  290. // support: jQuery <1.8
  291. function( elem, i, match ) {
  292. return !!$.data( elem, match[ 3 ] );
  293. },
  294. focusable: function( element ) {
  295. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  296. },
  297. tabbable: function( element ) {
  298. var tabIndex = $.attr( element, "tabindex" ),
  299. isTabIndexNaN = isNaN( tabIndex );
  300. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  301. }
  302. });
  303. // support: jQuery <1.8
  304. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  305. $.each( [ "Width", "Height" ], function( i, name ) {
  306. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  307. type = name.toLowerCase(),
  308. orig = {
  309. innerWidth: $.fn.innerWidth,
  310. innerHeight: $.fn.innerHeight,
  311. outerWidth: $.fn.outerWidth,
  312. outerHeight: $.fn.outerHeight
  313. };
  314. function reduce( elem, size, border, margin ) {
  315. $.each( side, function() {
  316. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  317. if ( border ) {
  318. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  319. }
  320. if ( margin ) {
  321. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  322. }
  323. });
  324. return size;
  325. }
  326. $.fn[ "inner" + name ] = function( size ) {
  327. if ( size === undefined ) {
  328. return orig[ "inner" + name ].call( this );
  329. }
  330. return this.each(function() {
  331. $( this ).css( type, reduce( this, size ) + "px" );
  332. });
  333. };
  334. $.fn[ "outer" + name] = function( size, margin ) {
  335. if ( typeof size !== "number" ) {
  336. return orig[ "outer" + name ].call( this, size );
  337. }
  338. return this.each(function() {
  339. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  340. });
  341. };
  342. });
  343. }
  344. // support: jQuery <1.8
  345. if ( !$.fn.addBack ) {
  346. $.fn.addBack = function( selector ) {
  347. return this.add( selector == null ?
  348. this.prevObject : this.prevObject.filter( selector )
  349. );
  350. };
  351. }
  352. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  353. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  354. $.fn.removeData = (function( removeData ) {
  355. return function( key ) {
  356. if ( arguments.length ) {
  357. return removeData.call( this, $.camelCase( key ) );
  358. } else {
  359. return removeData.call( this );
  360. }
  361. };
  362. })( $.fn.removeData );
  363. }
  364. // deprecated
  365. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  366. $.support.selectstart = "onselectstart" in document.createElement( "div" );
  367. $.fn.extend({
  368. disableSelection: function() {
  369. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  370. ".ui-disableSelection", function( event ) {
  371. event.preventDefault();
  372. });
  373. },
  374. enableSelection: function() {
  375. return this.unbind( ".ui-disableSelection" );
  376. },
  377. zIndex: function( zIndex ) {
  378. if ( zIndex !== undefined ) {
  379. return this.css( "zIndex", zIndex );
  380. }
  381. if ( this.length ) {
  382. var elem = $( this[ 0 ] ), position, value;
  383. while ( elem.length && elem[ 0 ] !== document ) {
  384. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  385. // This makes behavior of this function consistent across browsers
  386. // WebKit always returns auto if the element is positioned
  387. position = elem.css( "position" );
  388. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  389. // IE returns 0 when zIndex is not specified
  390. // other browsers return a string
  391. // we ignore the case of nested elements with an explicit value of 0
  392. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  393. value = parseInt( elem.css( "zIndex" ), 10 );
  394. if ( !isNaN( value ) && value !== 0 ) {
  395. return value;
  396. }
  397. }
  398. elem = elem.parent();
  399. }
  400. }
  401. return 0;
  402. }
  403. });
  404. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  405. $.ui.plugin = {
  406. add: function( module, option, set ) {
  407. var i,
  408. proto = $.ui[ module ].prototype;
  409. for ( i in set ) {
  410. proto.plugins[ i ] = proto.plugins[ i ] || [];
  411. proto.plugins[ i ].push( [ option, set[ i ] ] );
  412. }
  413. },
  414. call: function( instance, name, args, allowDisconnected ) {
  415. var i,
  416. set = instance.plugins[ name ];
  417. if ( !set ) {
  418. return;
  419. }
  420. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  421. return;
  422. }
  423. for ( i = 0; i < set.length; i++ ) {
  424. if ( instance.options[ set[ i ][ 0 ] ] ) {
  425. set[ i ][ 1 ].apply( instance.element, args );
  426. }
  427. }
  428. }
  429. };
  430. })( jQuery );
  431. (function( $, window, undefined ) {
  432. $.extend( $.mobile, {
  433. // define the window and the document objects
  434. window: $( window ),
  435. document: $( document ),
  436. // TODO: Remove and use $.ui.keyCode directly
  437. keyCode: $.ui.keyCode,
  438. // Place to store various widget extensions
  439. behaviors: {},
  440. // Scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value
  441. silentScroll: function( ypos ) {
  442. if ( $.type( ypos ) !== "number" ) {
  443. ypos = $.mobile.defaultHomeScroll;
  444. }
  445. // prevent scrollstart and scrollstop events
  446. $.event.special.scrollstart.enabled = false;
  447. setTimeout(function() {
  448. window.scrollTo( 0, ypos );
  449. $.mobile.document.trigger( "silentscroll", { x: 0, y: ypos });
  450. }, 20 );
  451. setTimeout(function() {
  452. $.event.special.scrollstart.enabled = true;
  453. }, 150 );
  454. },
  455. getClosestBaseUrl: function( ele ) {
  456. // Find the closest page and extract out its url.
  457. var url = $( ele ).closest( ".ui-page" ).jqmData( "url" ),
  458. base = $.mobile.path.documentBase.hrefNoHash;
  459. if ( !$.mobile.dynamicBaseEnabled || !url || !$.mobile.path.isPath( url ) ) {
  460. url = base;
  461. }
  462. return $.mobile.path.makeUrlAbsolute( url, base );
  463. },
  464. removeActiveLinkClass: function( forceRemoval ) {
  465. if ( !!$.mobile.activeClickedLink &&
  466. ( !$.mobile.activeClickedLink.closest( "." + $.mobile.activePageClass ).length ||
  467. forceRemoval ) ) {
  468. $.mobile.activeClickedLink.removeClass( $.mobile.activeBtnClass );
  469. }
  470. $.mobile.activeClickedLink = null;
  471. },
  472. // DEPRECATED in 1.4
  473. // Find the closest parent with a theme class on it. Note that
  474. // we are not using $.fn.closest() on purpose here because this
  475. // method gets called quite a bit and we need it to be as fast
  476. // as possible.
  477. getInheritedTheme: function( el, defaultTheme ) {
  478. var e = el[ 0 ],
  479. ltr = "",
  480. re = /ui-(bar|body|overlay)-([a-z])\b/,
  481. c, m;
  482. while ( e ) {
  483. c = e.className || "";
  484. if ( c && ( m = re.exec( c ) ) && ( ltr = m[ 2 ] ) ) {
  485. // We found a parent with a theme class
  486. // on it so bail from this loop.
  487. break;
  488. }
  489. e = e.parentNode;
  490. }
  491. // Return the theme letter we found, if none, return the
  492. // specified default.
  493. return ltr || defaultTheme || "a";
  494. },
  495. enhanceable: function( elements ) {
  496. return this.haveParents( elements, "enhance" );
  497. },
  498. hijackable: function( elements ) {
  499. return this.haveParents( elements, "ajax" );
  500. },
  501. haveParents: function( elements, attr ) {
  502. if ( !$.mobile.ignoreContentEnabled ) {
  503. return elements;
  504. }
  505. var count = elements.length,
  506. $newSet = $(),
  507. e, $element, excluded,
  508. i, c;
  509. for ( i = 0; i < count; i++ ) {
  510. $element = elements.eq( i );
  511. excluded = false;
  512. e = elements[ i ];
  513. while ( e ) {
  514. c = e.getAttribute ? e.getAttribute( "data-" + $.mobile.ns + attr ) : "";
  515. if ( c === "false" ) {
  516. excluded = true;
  517. break;
  518. }
  519. e = e.parentNode;
  520. }
  521. if ( !excluded ) {
  522. $newSet = $newSet.add( $element );
  523. }
  524. }
  525. return $newSet;
  526. },
  527. getScreenHeight: function() {
  528. // Native innerHeight returns more accurate value for this across platforms,
  529. // jQuery version is here as a normalized fallback for platforms like Symbian
  530. return window.innerHeight || $.mobile.window.height();
  531. },
  532. //simply set the active page's minimum height to screen height, depending on orientation
  533. resetActivePageHeight: function( height ) {
  534. var page = $( "." + $.mobile.activePageClass ),
  535. pageHeight = page.height(),
  536. pageOuterHeight = page.outerHeight( true );
  537. height = ( typeof height === "number" ) ? height : $.mobile.getScreenHeight();
  538. page.css( "min-height", height - ( pageOuterHeight - pageHeight ) );
  539. },
  540. loading: function() {
  541. // If this is the first call to this function, instantiate a loader widget
  542. var loader = this.loading._widget || $( $.mobile.loader.prototype.defaultHtml ).loader(),
  543. // Call the appropriate method on the loader
  544. returnValue = loader.loader.apply( loader, arguments );
  545. // Make sure the loader is retained for future calls to this function.
  546. this.loading._widget = loader;
  547. return returnValue;
  548. }
  549. });
  550. $.addDependents = function( elem, newDependents ) {
  551. var $elem = $( elem ),
  552. dependents = $elem.jqmData( "dependents" ) || $();
  553. $elem.jqmData( "dependents", $( dependents ).add( newDependents ) );
  554. };
  555. // plugins
  556. $.fn.extend({
  557. removeWithDependents: function() {
  558. $.removeWithDependents( this );
  559. },
  560. // Enhance child elements
  561. enhanceWithin: function() {
  562. var index,
  563. widgetElements = {},
  564. keepNative = $.mobile.page.prototype.keepNativeSelector(),
  565. that = this;
  566. // Add no js class to elements
  567. if ( $.mobile.nojs ) {
  568. $.mobile.nojs( this );
  569. }
  570. // Bind links for ajax nav
  571. if ( $.mobile.links ) {
  572. $.mobile.links( this );
  573. }
  574. // Degrade inputs for styleing
  575. if ( $.mobile.degradeInputsWithin ) {
  576. $.mobile.degradeInputsWithin( this );
  577. }
  578. // Run buttonmarkup
  579. if ( $.fn.buttonMarkup ) {
  580. this.find( $.fn.buttonMarkup.initSelector ).not( keepNative )
  581. .jqmEnhanceable().buttonMarkup();
  582. }
  583. // Add classes for fieldContain
  584. if ( $.fn.fieldcontain ) {
  585. this.find( ":jqmData(role='fieldcontain')" ).not( keepNative )
  586. .jqmEnhanceable().fieldcontain();
  587. }
  588. // Enhance widgets
  589. $.each( $.mobile.widgets, function( name, constructor ) {
  590. // If initSelector not false find elements
  591. if ( constructor.initSelector ) {
  592. // Filter elements that should not be enhanced based on parents
  593. var elements = $.mobile.enhanceable( that.find( constructor.initSelector ) );
  594. // If any matching elements remain filter ones with keepNativeSelector
  595. if ( elements.length > 0 ) {
  596. // $.mobile.page.prototype.keepNativeSelector is deprecated this is just for backcompat
  597. // Switch to $.mobile.keepNative in 1.5 which is just a value not a function
  598. elements = elements.not( keepNative );
  599. }
  600. // Enhance whatever is left
  601. if ( elements.length > 0 ) {
  602. widgetElements[ constructor.prototype.widgetName ] = elements;
  603. }
  604. }
  605. });
  606. for ( index in widgetElements ) {
  607. widgetElements[ index ][ index ]();
  608. }
  609. return this;
  610. },
  611. addDependents: function( newDependents ) {
  612. $.addDependents( this, newDependents );
  613. },
  614. // note that this helper doesn't attempt to handle the callback
  615. // or setting of an html element's text, its only purpose is
  616. // to return the html encoded version of the text in all cases. (thus the name)
  617. getEncodedText: function() {
  618. return $( "<a>" ).text( this.text() ).html();
  619. },
  620. // fluent helper function for the mobile namespaced equivalent
  621. jqmEnhanceable: function() {
  622. return $.mobile.enhanceable( this );
  623. },
  624. jqmHijackable: function() {
  625. return $.mobile.hijackable( this );
  626. }
  627. });
  628. $.removeWithDependents = function( nativeElement ) {
  629. var element = $( nativeElement );
  630. ( element.jqmData( "dependents" ) || $() ).remove();
  631. element.remove();
  632. };
  633. $.addDependents = function( nativeElement, newDependents ) {
  634. var element = $( nativeElement ),
  635. dependents = element.jqmData( "dependents" ) || $();
  636. element.jqmData( "dependents", $( dependents ).add( newDependents ) );
  637. };
  638. $.find.matches = function( expr, set ) {
  639. return $.find( expr, null, null, set );
  640. };
  641. $.find.matchesSelector = function( node, expr ) {
  642. return $.find( expr, null, null, [ node ] ).length > 0;
  643. };
  644. })( jQuery, this );
  645. /*!
  646. * jQuery UI Widget c0ab71056b936627e8a7821f03c044aec6280a40N
  647. * http://jqueryui.com
  648. *
  649. * Copyright 2013 jQuery Foundation and other contributors
  650. * Released under the MIT license.
  651. * http://jquery.org/license
  652. *
  653. * http://api.jqueryui.com/jQuery.widget/
  654. */
  655. (function( $, undefined ) {
  656. var uuid = 0,
  657. slice = Array.prototype.slice,
  658. _cleanData = $.cleanData;
  659. $.cleanData = function( elems ) {
  660. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  661. try {
  662. $( elem ).triggerHandler( "remove" );
  663. // http://bugs.jquery.com/ticket/8235
  664. } catch( e ) {}
  665. }
  666. _cleanData( elems );
  667. };
  668. $.widget = function( name, base, prototype ) {
  669. var fullName, existingConstructor, constructor, basePrototype,
  670. // proxiedPrototype allows the provided prototype to remain unmodified
  671. // so that it can be used as a mixin for multiple widgets (#8876)
  672. proxiedPrototype = {},
  673. namespace = name.split( "." )[ 0 ];
  674. name = name.split( "." )[ 1 ];
  675. fullName = namespace + "-" + name;
  676. if ( !prototype ) {
  677. prototype = base;
  678. base = $.Widget;
  679. }
  680. // create selector for plugin
  681. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  682. return !!$.data( elem, fullName );
  683. };
  684. $[ namespace ] = $[ namespace ] || {};
  685. existingConstructor = $[ namespace ][ name ];
  686. constructor = $[ namespace ][ name ] = function( options, element ) {
  687. // allow instantiation without "new" keyword
  688. if ( !this._createWidget ) {
  689. return new constructor( options, element );
  690. }
  691. // allow instantiation without initializing for simple inheritance
  692. // must use "new" keyword (the code above always passes args)
  693. if ( arguments.length ) {
  694. this._createWidget( options, element );
  695. }
  696. };
  697. // extend with the existing constructor to carry over any static properties
  698. $.extend( constructor, existingConstructor, {
  699. version: prototype.version,
  700. // copy the object used to create the prototype in case we need to
  701. // redefine the widget later
  702. _proto: $.extend( {}, prototype ),
  703. // track widgets that inherit from this widget in case this widget is
  704. // redefined after a widget inherits from it
  705. _childConstructors: []
  706. });
  707. basePrototype = new base();
  708. // we need to make the options hash a property directly on the new instance
  709. // otherwise we'll modify the options hash on the prototype that we're
  710. // inheriting from
  711. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  712. $.each( prototype, function( prop, value ) {
  713. if ( !$.isFunction( value ) ) {
  714. proxiedPrototype[ prop ] = value;
  715. return;
  716. }
  717. proxiedPrototype[ prop ] = (function() {
  718. var _super = function() {
  719. return base.prototype[ prop ].apply( this, arguments );
  720. },
  721. _superApply = function( args ) {
  722. return base.prototype[ prop ].apply( this, args );
  723. };
  724. return function() {
  725. var __super = this._super,
  726. __superApply = this._superApply,
  727. returnValue;
  728. this._super = _super;
  729. this._superApply = _superApply;
  730. returnValue = value.apply( this, arguments );
  731. this._super = __super;
  732. this._superApply = __superApply;
  733. return returnValue;
  734. };
  735. })();
  736. });
  737. constructor.prototype = $.widget.extend( basePrototype, {
  738. // TODO: remove support for widgetEventPrefix
  739. // always use the name + a colon as the prefix, e.g., draggable:start
  740. // don't prefix for widgets that aren't DOM-based
  741. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  742. }, proxiedPrototype, {
  743. constructor: constructor,
  744. namespace: namespace,
  745. widgetName: name,
  746. widgetFullName: fullName
  747. });
  748. // If this widget is being redefined then we need to find all widgets that
  749. // are inheriting from it and redefine all of them so that they inherit from
  750. // the new version of this widget. We're essentially trying to replace one
  751. // level in the prototype chain.
  752. if ( existingConstructor ) {
  753. $.each( existingConstructor._childConstructors, function( i, child ) {
  754. var childPrototype = child.prototype;
  755. // redefine the child widget using the same prototype that was
  756. // originally used, but inherit from the new version of the base
  757. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  758. });
  759. // remove the list of existing child constructors from the old constructor
  760. // so the old child constructors can be garbage collected
  761. delete existingConstructor._childConstructors;
  762. } else {
  763. base._childConstructors.push( constructor );
  764. }
  765. $.widget.bridge( name, constructor );
  766. return constructor;
  767. };
  768. $.widget.extend = function( target ) {
  769. var input = slice.call( arguments, 1 ),
  770. inputIndex = 0,
  771. inputLength = input.length,
  772. key,
  773. value;
  774. for ( ; inputIndex < inputLength; inputIndex++ ) {
  775. for ( key in input[ inputIndex ] ) {
  776. value = input[ inputIndex ][ key ];
  777. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  778. // Clone objects
  779. if ( $.isPlainObject( value ) ) {
  780. target[ key ] = $.isPlainObject( target[ key ] ) ?
  781. $.widget.extend( {}, target[ key ], value ) :
  782. // Don't extend strings, arrays, etc. with objects
  783. $.widget.extend( {}, value );
  784. // Copy everything else by reference
  785. } else {
  786. target[ key ] = value;
  787. }
  788. }
  789. }
  790. }
  791. return target;
  792. };
  793. $.widget.bridge = function( name, object ) {
  794. var fullName = object.prototype.widgetFullName || name;
  795. $.fn[ name ] = function( options ) {
  796. var isMethodCall = typeof options === "string",
  797. args = slice.call( arguments, 1 ),
  798. returnValue = this;
  799. // allow multiple hashes to be passed on init
  800. options = !isMethodCall && args.length ?
  801. $.widget.extend.apply( null, [ options ].concat(args) ) :
  802. options;
  803. if ( isMethodCall ) {
  804. this.each(function() {
  805. var methodValue,
  806. instance = $.data( this, fullName );
  807. if ( options === "instance" ) {
  808. returnValue = instance;
  809. return false;
  810. }
  811. if ( !instance ) {
  812. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  813. "attempted to call method '" + options + "'" );
  814. }
  815. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  816. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  817. }
  818. methodValue = instance[ options ].apply( instance, args );
  819. if ( methodValue !== instance && methodValue !== undefined ) {
  820. returnValue = methodValue && methodValue.jquery ?
  821. returnValue.pushStack( methodValue.get() ) :
  822. methodValue;
  823. return false;
  824. }
  825. });
  826. } else {
  827. this.each(function() {
  828. var instance = $.data( this, fullName );
  829. if ( instance ) {
  830. instance.option( options || {} )._init();
  831. } else {
  832. $.data( this, fullName, new object( options, this ) );
  833. }
  834. });
  835. }
  836. return returnValue;
  837. };
  838. };
  839. $.Widget = function( /* options, element */ ) {};
  840. $.Widget._childConstructors = [];
  841. $.Widget.prototype = {
  842. widgetName: "widget",
  843. widgetEventPrefix: "",
  844. defaultElement: "<div>",
  845. options: {
  846. disabled: false,
  847. // callbacks
  848. create: null
  849. },
  850. _createWidget: function( options, element ) {
  851. element = $( element || this.defaultElement || this )[ 0 ];
  852. this.element = $( element );
  853. this.uuid = uuid++;
  854. this.eventNamespace = "." + this.widgetName + this.uuid;
  855. this.options = $.widget.extend( {},
  856. this.options,
  857. this._getCreateOptions(),
  858. options );
  859. this.bindings = $();
  860. this.hoverable = $();
  861. this.focusable = $();
  862. if ( element !== this ) {
  863. $.data( element, this.widgetFullName, this );
  864. this._on( true, this.element, {
  865. remove: function( event ) {
  866. if ( event.target === element ) {
  867. this.destroy();
  868. }
  869. }
  870. });
  871. this.document = $( element.style ?
  872. // element within the document
  873. element.ownerDocument :
  874. // element is window or document
  875. element.document || element );
  876. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  877. }
  878. this._create();
  879. this._trigger( "create", null, this._getCreateEventData() );
  880. this._init();
  881. },
  882. _getCreateOptions: $.noop,
  883. _getCreateEventData: $.noop,
  884. _create: $.noop,
  885. _init: $.noop,
  886. destroy: function() {
  887. this._destroy();
  888. // we can probably remove the unbind calls in 2.0
  889. // all event bindings should go through this._on()
  890. this.element
  891. .unbind( this.eventNamespace )
  892. .removeData( this.widgetFullName )
  893. // support: jquery <1.6.3
  894. // http://bugs.jquery.com/ticket/9413
  895. .removeData( $.camelCase( this.widgetFullName ) );
  896. this.widget()
  897. .unbind( this.eventNamespace )
  898. .removeAttr( "aria-disabled" )
  899. .removeClass(
  900. this.widgetFullName + "-disabled " +
  901. "ui-state-disabled" );
  902. // clean up events and states
  903. this.bindings.unbind( this.eventNamespace );
  904. this.hoverable.removeClass( "ui-state-hover" );
  905. this.focusable.removeClass( "ui-state-focus" );
  906. },
  907. _destroy: $.noop,
  908. widget: function() {
  909. return this.element;
  910. },
  911. option: function( key, value ) {
  912. var options = key,
  913. parts,
  914. curOption,
  915. i;
  916. if ( arguments.length === 0 ) {
  917. // don't return a reference to the internal hash
  918. return $.widget.extend( {}, this.options );
  919. }
  920. if ( typeof key === "string" ) {
  921. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  922. options = {};
  923. parts = key.split( "." );
  924. key = parts.shift();
  925. if ( parts.length ) {
  926. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  927. for ( i = 0; i < parts.length - 1; i++ ) {
  928. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  929. curOption = curOption[ parts[ i ] ];
  930. }
  931. key = parts.pop();
  932. if ( value === undefined ) {
  933. return curOption[ key ] === undefined ? null : curOption[ key ];
  934. }
  935. curOption[ key ] = value;
  936. } else {
  937. if ( value === undefined ) {
  938. return this.options[ key ] === undefined ? null : this.options[ key ];
  939. }
  940. options[ key ] = value;
  941. }
  942. }
  943. this._setOptions( options );
  944. return this;
  945. },
  946. _setOptions: function( options ) {
  947. var key;
  948. for ( key in options ) {
  949. this._setOption( key, options[ key ] );
  950. }
  951. return this;
  952. },
  953. _setOption: function( key, value ) {
  954. this.options[ key ] = value;
  955. if ( key === "disabled" ) {
  956. this.widget()
  957. .toggleClass( this.widgetFullName + "-disabled", !!value );
  958. this.hoverable.removeClass( "ui-state-hover" );
  959. this.focusable.removeClass( "ui-state-focus" );
  960. }
  961. return this;
  962. },
  963. enable: function() {
  964. return this._setOptions({ disabled: false });
  965. },
  966. disable: function() {
  967. return this._setOptions({ disabled: true });
  968. },
  969. _on: function( suppressDisabledCheck, element, handlers ) {
  970. var delegateElement,
  971. instance = this;
  972. // no suppressDisabledCheck flag, shuffle arguments
  973. if ( typeof suppressDisabledCheck !== "boolean" ) {
  974. handlers = element;
  975. element = suppressDisabledCheck;
  976. suppressDisabledCheck = false;
  977. }
  978. // no element argument, shuffle and use this.element
  979. if ( !handlers ) {
  980. handlers = element;
  981. element = this.element;
  982. delegateElement = this.widget();
  983. } else {
  984. // accept selectors, DOM elements
  985. element = delegateElement = $( element );
  986. this.bindings = this.bindings.add( element );
  987. }
  988. $.each( handlers, function( event, handler ) {
  989. function handlerProxy() {
  990. // allow widgets to customize the disabled handling
  991. // - disabled as an array instead of boolean
  992. // - disabled class as method for disabling individual parts
  993. if ( !suppressDisabledCheck &&
  994. ( instance.options.disabled === true ||
  995. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  996. return;
  997. }
  998. return ( typeof handler === "string" ? instance[ handler ] : handler )
  999. .apply( instance, arguments );
  1000. }
  1001. // copy the guid so direct unbinding works
  1002. if ( typeof handler !== "string" ) {
  1003. handlerProxy.guid = handler.guid =
  1004. handler.guid || handlerProxy.guid || $.guid++;
  1005. }
  1006. var match = event.match( /^(\w+)\s*(.*)$/ ),
  1007. eventName = match[1] + instance.eventNamespace,
  1008. selector = match[2];
  1009. if ( selector ) {
  1010. delegateElement.delegate( selector, eventName, handlerProxy );
  1011. } else {
  1012. element.bind( eventName, handlerProxy );
  1013. }
  1014. });
  1015. },
  1016. _off: function( element, eventName ) {
  1017. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  1018. element.unbind( eventName ).undelegate( eventName );
  1019. },
  1020. _delay: function( handler, delay ) {
  1021. function handlerProxy() {
  1022. return ( typeof handler === "string" ? instance[ handler ] : handler )
  1023. .apply( instance, arguments );
  1024. }
  1025. var instance = this;
  1026. return setTimeout( handlerProxy, delay || 0 );
  1027. },
  1028. _hoverable: function( element ) {
  1029. this.hoverable = this.hoverable.add( element );
  1030. this._on( element, {
  1031. mouseenter: function( event ) {
  1032. $( event.currentTarget ).addClass( "ui-state-hover" );
  1033. },
  1034. mouseleave: function( event ) {
  1035. $( event.currentTarget ).removeClass( "ui-state-hover" );
  1036. }
  1037. });
  1038. },
  1039. _focusable: function( element ) {
  1040. this.focusable = this.focusable.add( element );
  1041. this._on( element, {
  1042. focusin: function( event ) {
  1043. $( event.currentTarget ).addClass( "ui-state-focus" );
  1044. },
  1045. focusout: function( event ) {
  1046. $( event.currentTarget ).removeClass( "ui-state-focus" );
  1047. }
  1048. });
  1049. },
  1050. _trigger: function( type, event, data ) {
  1051. var prop, orig,
  1052. callback = this.options[ type ];
  1053. data = data || {};
  1054. event = $.Event( event );
  1055. event.type = ( type === this.widgetEventPrefix ?
  1056. type :
  1057. this.widgetEventPrefix + type ).toLowerCase();
  1058. // the original event may come from any element
  1059. // so we need to reset the target on the new event
  1060. event.target = this.element[ 0 ];
  1061. // copy original event properties over to the new event
  1062. orig = event.originalEvent;
  1063. if ( orig ) {
  1064. for ( prop in orig ) {
  1065. if ( !( prop in event ) ) {
  1066. event[ prop ] = orig[ prop ];
  1067. }
  1068. }
  1069. }
  1070. this.element.trigger( event, data );
  1071. return !( $.isFunction( callback ) &&
  1072. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  1073. event.isDefaultPrevented() );
  1074. }
  1075. };
  1076. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  1077. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  1078. if ( typeof options === "string" ) {
  1079. options = { effect: options };
  1080. }
  1081. var hasOptions,
  1082. effectName = !options ?
  1083. method :
  1084. options === true || typeof options === "number" ?
  1085. defaultEffect :
  1086. options.effect || defaultEffect;
  1087. options = options || {};
  1088. if ( typeof options === "number" ) {
  1089. options = { duration: options };
  1090. }
  1091. hasOptions = !$.isEmptyObject( options );
  1092. options.complete = callback;
  1093. if ( options.delay ) {
  1094. element.delay( options.delay );
  1095. }
  1096. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  1097. element[ method ]( options );
  1098. } else if ( effectName !== method && element[ effectName ] ) {
  1099. element[ effectName ]( options.duration, options.easing, callback );
  1100. } else {
  1101. element.queue(function( next ) {
  1102. $( this )[ method ]();
  1103. if ( callback ) {
  1104. callback.call( element[ 0 ] );
  1105. }
  1106. next();
  1107. });
  1108. }
  1109. };
  1110. });
  1111. })( jQuery );
  1112. (function( $, undefined ) {
  1113. var rcapitals = /[A-Z]/g,
  1114. replaceFunction = function( c ) {
  1115. return "-" + c.toLowerCase();
  1116. };
  1117. $.extend( $.Widget.prototype, {
  1118. _getCreateOptions: function() {
  1119. var option, value,
  1120. elem = this.element[ 0 ],
  1121. options = {};
  1122. //
  1123. if ( !$.mobile.getAttribute( elem, "defaults" ) ) {
  1124. for ( option in this.options ) {
  1125. value = $.mobile.getAttribute( elem, option.replace( rcapitals, replaceFunction ) );
  1126. if ( value != null ) {
  1127. options[ option ] = value;
  1128. }
  1129. }
  1130. }
  1131. return options;
  1132. }
  1133. });
  1134. //TODO: Remove in 1.5 for backcompat only
  1135. $.mobile.widget = $.Widget;
  1136. })( jQuery );
  1137. (function( $ ) {
  1138. // TODO move loader class down into the widget settings
  1139. var loaderClass = "ui-loader", $html = $( "html" );
  1140. $.widget( "mobile.loader", {
  1141. // NOTE if the global config settings are defined they will override these
  1142. // options
  1143. options: {
  1144. // the theme for the loading message
  1145. theme: "a",
  1146. // whether the text in the loading message is shown
  1147. textVisible: false,
  1148. // custom html for the inner content of the loading message
  1149. html: "",
  1150. // the text to be displayed when the popup is shown
  1151. text: "loading"
  1152. },
  1153. defaultHtml: "<div class='" + loaderClass + "'>" +
  1154. "<span class='ui-icon-loading'></span>" +
  1155. "<h1></h1>" +
  1156. "</div>",
  1157. // For non-fixed supportin browsers. Position at y center (if scrollTop supported), above the activeBtn (if defined), or just 100px from top
  1158. fakeFixLoader: function() {
  1159. var activeBtn = $( "." + $.mobile.activeBtnClass ).first();
  1160. this.element
  1161. .css({
  1162. top: $.support.scrollTop && this.window.scrollTop() + this.window.height() / 2 ||
  1163. activeBtn.length && activeBtn.offset().top || 100
  1164. });
  1165. },
  1166. // check position of loader to see if it appears to be "fixed" to center
  1167. // if not, use abs positioning
  1168. checkLoaderPosition: function() {
  1169. var offset = this.element.offset(),
  1170. scrollTop = this.window.scrollTop(),
  1171. screenHeight = $.mobile.getScreenHeight();
  1172. if ( offset.top < scrollTop || ( offset.top - scrollTop ) > screenHeight ) {
  1173. this.element.addClass( "ui-loader-fakefix" );
  1174. this.fakeFixLoader();
  1175. this.window
  1176. .unbind( "scroll", this.checkLoaderPosition )
  1177. .bind( "scroll", $.proxy( this.fakeFixLoader, this ) );
  1178. }
  1179. },
  1180. resetHtml: function() {
  1181. this.element.html( $( this.defaultHtml ).html() );
  1182. },
  1183. // Turn on/off page loading message. Theme doubles as an object argument
  1184. // with the following shape: { theme: '', text: '', html: '', textVisible: '' }
  1185. // NOTE that the $.mobile.loading* settings and params past the first are deprecated
  1186. // TODO sweet jesus we need to break some of this out
  1187. show: function( theme, msgText, textonly ) {
  1188. var textVisible, message, loadSettings;
  1189. this.resetHtml();
  1190. // use the prototype options so that people can set them globally at
  1191. // mobile init. Consistency, it's what's for dinner
  1192. if ( $.type( theme ) === "object" ) {
  1193. loadSettings = $.extend( {}, this.options, theme );
  1194. theme = loadSettings.theme;
  1195. } else {
  1196. loadSettings = this.options;
  1197. // here we prefer the theme value passed as a string argument, then
  1198. // we prefer the global option because we can't use undefined default
  1199. // prototype options, then the prototype option
  1200. theme = theme || loadSettings.theme;
  1201. }
  1202. // set the message text, prefer the param, then the settings object
  1203. // then loading message
  1204. message = msgText || ( loadSettings.text === false ? "" : loadSettings.text );
  1205. // prepare the dom
  1206. $html.addClass( "ui-loading" );
  1207. textVisible = loadSettings.textVisible;
  1208. // add the proper css given the options (theme, text, etc)
  1209. // Force text visibility if the second argument was supplied, or
  1210. // if the text was explicitly set in the object args
  1211. this.element.attr("class", loaderClass +
  1212. " ui-corner-all ui-body-" + theme +
  1213. " ui-loader-" + ( textVisible || msgText || theme.text ? "verbose" : "default" ) +
  1214. ( loadSettings.textonly || textonly ? " ui-loader-textonly" : "" ) );
  1215. // TODO verify that jquery.fn.html is ok to use in both cases here
  1216. // this might be overly defensive in preventing unknowing xss
  1217. // if the html attribute is defined on the loading settings, use that
  1218. // otherwise use the fallbacks from above
  1219. if ( loadSettings.html ) {
  1220. this.element.html( loadSettings.html );
  1221. } else {
  1222. this.element.find( "h1" ).text( message );
  1223. }
  1224. // attach the loader to the DOM
  1225. this.element.appendTo( $.mobile.pageContainer );
  1226. // check that the loader is visible
  1227. this.checkLoaderPosition();
  1228. // on scroll check the loader position
  1229. this.window.bind( "scroll", $.proxy( this.checkLoaderPosition, this ) );
  1230. },
  1231. hide: function() {
  1232. $html.removeClass( "ui-loading" );
  1233. if ( this.options.text ) {
  1234. this.element.removeClass( "ui-loader-fakefix" );
  1235. }
  1236. $.mobile.window.unbind( "scroll", this.fakeFixLoader );
  1237. $.mobile.window.unbind( "scroll", this.checkLoaderPosition );
  1238. }
  1239. });
  1240. })(jQuery, this);
  1241. // Script: jQuery hashchange event
  1242. //
  1243. // *Version: 1.3, Last updated: 7/21/2010*
  1244. //
  1245. // Project Home - http://benalman.com/projects/jquery-hashchange-plugin/
  1246. // GitHub - http://github.com/cowboy/jquery-hashchange/
  1247. // Source - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.js
  1248. // (Minified) - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.min.js (0.8kb gzipped)
  1249. //
  1250. // About: License
  1251. //
  1252. // Copyright (c) 2010 "Cowboy" Ben Alman,
  1253. // Dual licensed under the MIT and GPL licenses.
  1254. // http://benalman.com/about/license/
  1255. //
  1256. // About: Examples
  1257. //
  1258. // These working examples, complete with fully commented code, illustrate a few
  1259. // ways in which this plugin can be used.
  1260. //
  1261. // hashchange event - http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/
  1262. // document.domain - http://benalman.com/code/projects/jquery-hashchange/examples/document_domain/
  1263. //
  1264. // About: Support and Testing
  1265. //
  1266. // Information about what version or versions of jQuery this plugin has been
  1267. // tested with, what browsers it has been tested in, and where the unit tests
  1268. // reside (so you can test it yourself).
  1269. //
  1270. // jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2
  1271. // Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5,
  1272. // Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5.
  1273. // Unit Tests - http://benalman.com/code/projects/jquery-hashchange/unit/
  1274. //
  1275. // About: Known issues
  1276. //
  1277. // While this jQuery hashchange event implementation is quite stable and
  1278. // robust, there are a few unfortunate browser bugs surrounding expected
  1279. // hashchange event-based behaviors, independent of any JavaScript
  1280. // window.onhashchange abstraction. See the following examples for more
  1281. // information:
  1282. //
  1283. // Chrome: Back Button - http://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/
  1284. // Firefox: Remote XMLHttpRequest - http://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/
  1285. // WebKit: Back Button in an Iframe - http://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/
  1286. // Safari: Back Button from a different domain - http://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/
  1287. //
  1288. // Also note that should a browser natively support the window.onhashchange
  1289. // event, but not report that it does, the fallback polling loop will be used.
  1290. //
  1291. // About: Release History
  1292. //
  1293. // 1.3 - (7/21/2010) Reorganized IE6/7 Iframe code to make it more
  1294. // "removable" for mobile-only development. Added IE6/7 document.title
  1295. // support. Attempted to make Iframe as hidden as possible by using
  1296. // techniques from http://www.paciellogroup.com/blog/?p=604. Added
  1297. // support for the "shortcut" format $(window).hashchange( fn ) and
  1298. // $(window).hashchange() like jQuery provides for built-in events.
  1299. // Renamed jQuery.hashchangeDelay to <jQuery.fn.hashchange.delay> and
  1300. // lowered its default value to 50. Added <jQuery.fn.hashchange.domain>
  1301. // and <jQuery.fn.hashchange.src> properties plus document-domain.html
  1302. // file to address access denied issues when setting document.domain in
  1303. // IE6/7.
  1304. // 1.2 - (2/11/2010) Fixed a bug where coming back to a page using this plugin
  1305. // from a page on another domain would cause an error in Safari 4. Also,
  1306. // IE6/7 Iframe is now inserted after the body (this actually works),
  1307. // which prevents the page from scrolling when the event is first bound.
  1308. // Event can also now be bound before DOM ready, but it won't be usable
  1309. // before then in IE6/7.
  1310. // 1.1 - (1/21/2010) Incorporated document.documentMode test to fix IE8 bug
  1311. // where browser version is incorrectly reported as 8.0, despite
  1312. // inclusion of the X-UA-Compatible IE=EmulateIE7 meta tag.
  1313. // 1.0 - (1/9/2010) Initial Release. Broke out the jQuery BBQ event.special
  1314. // window.onhashchange functionality into a separate plugin for users
  1315. // who want just the basic event & back button support, without all the
  1316. // extra awesomeness that BBQ provides. This plugin will be included as
  1317. // part of jQuery BBQ, but also be available separately.
  1318. (function( $, window, undefined ) {
  1319. // Reused string.
  1320. var str_hashchange = 'hashchange',
  1321. // Method / object references.
  1322. doc = document,
  1323. fake_onhashchange,
  1324. special = $.event.special,
  1325. // Does the browser support window.onhashchange? Note that IE8 running in
  1326. // IE7 compatibility mode reports true for 'onhashchange' in window, even
  1327. // though the event isn't supported, so also test document.documentMode.
  1328. doc_mode = doc.documentMode,
  1329. supports_onhashchange = 'on' + str_hashchange in window && ( doc_mode === undefined || doc_mode > 7 );
  1330. // Get location.hash (or what you'd expect location.hash to be) sans any
  1331. // leading #. Thanks for making this necessary, Firefox!
  1332. function get_fragment( url ) {
  1333. url = url || location.href;
  1334. return '#' + url.replace( /^[^#]*#?(.*)$/, '$1' );
  1335. };
  1336. // Method: jQuery.fn.hashchange
  1337. //
  1338. // Bind a handler to the window.onhashchange event or trigger all bound
  1339. // window.onhashchange event handlers. This behavior is consistent with
  1340. // jQuery's built-in event handlers.
  1341. //
  1342. // Usage:
  1343. //
  1344. // > jQuery(window).hashchange( [ handler ] );
  1345. //
  1346. // Arguments:
  1347. //
  1348. // handler - (Function) Optional handler to be bound to the hashchange
  1349. // event. This is a "shortcut" for the more verbose form:
  1350. // jQuery(window).bind( 'hashchange', handler ). If handler is omitted,
  1351. // all bound window.onhashchange event handlers will be triggered. This
  1352. // is a shortcut for the more verbose
  1353. // jQuery(window).trigger( 'hashchange' ). These forms are described in
  1354. // the <hashchange event> section.
  1355. //
  1356. // Returns:
  1357. //
  1358. // (jQuery) The initial jQuery collection of elements.
  1359. // Allow the "shortcut" format $(elem).hashchange( fn ) for binding and
  1360. // $(elem).hashchange() for triggering, like jQuery does for built-in events.
  1361. $.fn[ str_hashchange ] = function( fn ) {
  1362. return fn ? this.bind( str_hashchange, fn ) : this.trigger( str_hashchange );
  1363. };
  1364. // Property: jQuery.fn.hashchange.delay
  1365. //
  1366. // The numeric interval (in milliseconds) at which the <hashchange event>
  1367. // polling loop executes. Defaults to 50.
  1368. // Property: jQuery.fn.hashchange.domain
  1369. //
  1370. // If you're setting document.domain in your JavaScript, and you want hash
  1371. // history to work in IE6/7, not only must this property be set, but you must
  1372. // also set document.domain BEFORE jQuery is loaded into the page. This
  1373. // property is only applicable if you are supporting IE6/7 (or IE8 operating
  1374. // in "IE7 compatibility" mode).
  1375. //
  1376. // In addition, the <jQuery.fn.hashchange.src> property must be set to the
  1377. // path of the included "document-domain.html" file, which can be renamed or
  1378. // modified if necessary (note that the document.domain specified must be the
  1379. // same in both your main JavaScript as well as in this file).
  1380. //
  1381. // Usage:
  1382. //
  1383. // jQuery.fn.hashchange.domain = document.domain;
  1384. // Property: jQuery.fn.hashchange.src
  1385. //
  1386. // If, for some reason, you need to specify an Iframe src file (for example,
  1387. // when setting document.domain as in <jQuery.fn.hashchange.domain>), you can
  1388. // do so using this property. Note that when using this property, history
  1389. // won't be recorded in IE6/7 until the Iframe src file loads. This property
  1390. // is only applicable if you are supporting IE6/7 (or IE8 operating in "IE7
  1391. // compatibility" mode).
  1392. //
  1393. // Usage:
  1394. //
  1395. // jQuery.fn.hashchange.src = 'path/to/file.html';
  1396. $.fn[ str_hashchange ].delay = 50;
  1397. /*
  1398. $.fn[ str_hashchange ].domain = null;
  1399. $.fn[ str_hashchange ].src = null;
  1400. */
  1401. // Event: hashchange event
  1402. //
  1403. // Fired when location.hash changes. In browsers that support it, the native
  1404. // HTML5 window.onhashchange event is used, otherwise a polling loop is
  1405. // initialized, running every <jQuery.fn.hashchange.delay> milliseconds to
  1406. // see if the hash has changed. In IE6/7 (and IE8 operating in "IE7
  1407. // compatibility" mode), a hidden Iframe is created to allow the back button
  1408. // and hash-based history to work.
  1409. //
  1410. // Usage as described in <jQuery.fn.hashchange>:
  1411. //
  1412. // > // Bind an event handler.
  1413. // > jQuery(window).hashchange( function(e) {
  1414. // > var hash = location.hash;
  1415. // > ...
  1416. // > });
  1417. // >
  1418. // > // Manually trigger the event handler.
  1419. // > jQuery(window).hashchange();
  1420. //
  1421. // A more verbose usage that allows for event namespacing:
  1422. //
  1423. // > // Bind an event handler.
  1424. // > jQuery(window).bind( 'hashchange', function(e) {
  1425. // > var hash = location.hash;
  1426. // > ...
  1427. // > });
  1428. // >
  1429. // > // Manually trigger the event handler.
  1430. // > jQuery(window).trigger( 'hashchange' );
  1431. //
  1432. // Additional Notes:
  1433. //
  1434. // * The polling loop and Iframe are not created until at least one handler
  1435. // is actually bound to the 'hashchange' event.
  1436. // * If you need the bound handler(s) to execute immediately, in cases where
  1437. // a location.hash exists on page load, via bookmark or page refresh for
  1438. // example, use jQuery(window).hashchange() or the more verbose
  1439. // jQuery(window).trigger( 'hashchange' ).
  1440. // * The event can be bound before DOM ready, but since it won't be usable
  1441. // before then in IE6/7 (due to the necessary Iframe), recommended usage is
  1442. // to bind it inside a DOM ready handler.
  1443. // Override existing $.event.special.hashchange methods (allowing this plugin
  1444. // to be defined after jQuery BBQ in BBQ's source code).
  1445. special[ str_hashchange ] = $.extend( special[ str_hashchange ], {
  1446. // Called only when the first 'hashchange' event is bound to window.
  1447. setup: function() {
  1448. // If window.onhashchange is supported natively, there's nothing to do..
  1449. if ( supports_onhashchange ) { return false; }
  1450. // Otherwise, we need to create our own. And we don't want to call this
  1451. // until the user binds to the event, just in case they never do, since it
  1452. // will create a polling loop and possibly even a hidden Iframe.
  1453. $( fake_onhashchange.start );
  1454. },
  1455. // Called only when the last 'hashchange' event is unbound from window.
  1456. teardown: function() {
  1457. // If window.onhashchange is supported natively, there's nothing to do..
  1458. if ( supports_onhashchange ) { return false; }
  1459. // Otherwise, we need to stop ours (if possible).
  1460. $( fake_onhashchange.stop );
  1461. }
  1462. });
  1463. // fake_onhashchange does all the work of triggering the window.onhashchange
  1464. // event for browsers that don't natively support it, including creating a
  1465. // polling loop to watch for hash changes and in IE 6/7 creating a hidden
  1466. // Iframe to enable back and forward.
  1467. fake_onhashchange = (function() {
  1468. var self = {},
  1469. timeout_id,
  1470. // Remember the initial hash so it doesn't get triggered immediately.
  1471. last_hash = get_fragment(),
  1472. fn_retval = function( val ) { return val; },
  1473. history_set = fn_retval,
  1474. history_get = fn_retval;
  1475. // Start the polling loop.
  1476. self.start = function() {
  1477. timeout_id || poll();
  1478. };
  1479. // Stop the polling loop.
  1480. self.stop = function() {
  1481. timeout_id && clearTimeout( timeout_id );
  1482. timeout_id = undefined;
  1483. };
  1484. // This polling loop checks every $.fn.hashchange.delay milliseconds to see
  1485. // if location.hash has changed, and triggers the 'hashchange' event on
  1486. // window when necessary.
  1487. function poll() {
  1488. var hash = get_fragment(),
  1489. history_hash = history_get( last_hash );
  1490. if ( hash !== last_hash ) {
  1491. history_set( last_hash = hash, history_hash );
  1492. $(window).trigger( str_hashchange );
  1493. } else if ( history_hash !== last_hash ) {
  1494. location.href = location.href.replace( /#.*/, '' ) + history_hash;
  1495. }
  1496. timeout_id = setTimeout( poll, $.fn[ str_hashchange ].delay );
  1497. };
  1498. // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  1499. // vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv
  1500. // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  1501. window.attachEvent && !window.addEventListener && !supports_onhashchange && (function() {
  1502. // Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8
  1503. // when running in "IE7 compatibility" mode.
  1504. var iframe,
  1505. iframe_src;
  1506. // When the event is bound and polling starts in IE 6/7, create a hidden
  1507. // Iframe for history handling.
  1508. self.start = function() {
  1509. if ( !iframe ) {
  1510. iframe_src = $.fn[ str_hashchange ].src;
  1511. iframe_src = iframe_src && iframe_src + get_fragment();
  1512. // Create hidden Iframe. Attempt to make Iframe as hidden as possible
  1513. // by using techniques from http://www.paciellogroup.com/blog/?p=604.
  1514. iframe = $('<iframe tabindex="-1" title="empty"/>').hide()
  1515. // When Iframe has completely loaded, initialize the history and
  1516. // start polling.
  1517. .one( 'load', function() {
  1518. iframe_src || history_set( get_fragment() );
  1519. poll();
  1520. })
  1521. // Load Iframe src if specified, otherwise nothing.
  1522. .attr( 'src', iframe_src || 'javascript:0' )
  1523. // Append Iframe after the end of the body to prevent unnecessary
  1524. // initial page scrolling (yes, this works).
  1525. .insertAfter( 'body' )[0].contentWindow;
  1526. // Whenever `document.title` changes, update the Iframe's title to
  1527. // prettify the back/next history menu entries. Since IE sometimes
  1528. // errors with "Unspecified error" the very first time this is set
  1529. // (yes, very useful) wrap this with a try/catch block.
  1530. doc.onpropertychange = function() {
  1531. try {
  1532. if ( event.propertyName === 'title' ) {
  1533. iframe.document.title = doc.title;
  1534. }
  1535. } catch(e) {}
  1536. };
  1537. }
  1538. };
  1539. // Override the "stop" method since an IE6/7 Iframe was created. Even
  1540. // if there are no longer any bound event handlers, the polling loop
  1541. // is still necessary for back/next to work at all!
  1542. self.stop = fn_retval;
  1543. // Get history by looking at the hidden Iframe's location.hash.
  1544. history_get = function() {
  1545. return get_fragment( iframe.location.href );
  1546. };
  1547. // Set a new history item by opening and then closing the Iframe
  1548. // document, *then* setting its location.hash. If document.domain has
  1549. // been set, update that as well.
  1550. history_set = function( hash, history_hash ) {
  1551. var iframe_doc = iframe.document,
  1552. domain = $.fn[ str_hashchange ].domain;
  1553. if ( hash !== history_hash ) {
  1554. // Update Iframe with any initial `document.title` that might be set.
  1555. iframe_doc.title = doc.title;
  1556. // Opening the Iframe's document after it has been closed is what
  1557. // actually adds a history entry.
  1558. iframe_doc.open();
  1559. // Set document.domain for the Iframe document as well, if necessary.
  1560. domain && iframe_doc.write( '<script>document.domain="' + domain + '"<\/script>' );
  1561. iframe_doc.close();
  1562. // Update the Iframe's hash, for great justice.
  1563. iframe.location.hash = hash;
  1564. }
  1565. };
  1566. })();
  1567. // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1568. // ^^^^^^^^^^^^^^^^^^^ REMOVE IF NOT SUPPORTING IE6/7/8 ^^^^^^^^^^^^^^^^^^^
  1569. // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1570. return self;
  1571. })();
  1572. })(jQuery,this);
  1573. (function( $, undefined ) {
  1574. /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
  1575. window.matchMedia = window.matchMedia || (function( doc, undefined ) {
  1576. var bool,
  1577. docElem = doc.documentElement,
  1578. refNode = docElem.firstElementChild || docElem.firstChild,
  1579. // fakeBody required for <FF4 when executed in <head>
  1580. fakeBody = doc.createElement( "body" ),
  1581. div = doc.createElement( "div" );
  1582. div.id = "mq-test-1";
  1583. div.style.cssText = "position:absolute;top:-100em";
  1584. fakeBody.style.background = "none";
  1585. fakeBody.appendChild(div);
  1586. return function(q){
  1587. div.innerHTML = "&shy;<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
  1588. docElem.insertBefore( fakeBody, refNode );
  1589. bool = div.offsetWidth === 42;
  1590. docElem.removeChild( fakeBody );
  1591. return {
  1592. matches: bool,
  1593. media: q
  1594. };
  1595. };
  1596. }( document ));
  1597. // $.mobile.media uses matchMedia to return a boolean.
  1598. $.mobile.media = function( q ) {
  1599. return window.matchMedia( q ).matches;
  1600. };
  1601. })(jQuery);
  1602. (function( $, undefined ) {
  1603. var support = {
  1604. touch: "ontouchend" in document
  1605. };
  1606. $.mobile.support = $.mobile.support || {};
  1607. $.extend( $.support, support );
  1608. $.extend( $.mobile.support, support );
  1609. }( jQuery ));
  1610. (function( $, undefined ) {
  1611. $.extend( $.support, {
  1612. orientation: "orientation" in window && "onorientationchange" in window
  1613. });
  1614. }( jQuery ));
  1615. (function( $, undefined ) {
  1616. // thx Modernizr
  1617. function propExists( prop ) {
  1618. var uc_prop = prop.charAt( 0 ).toUpperCase() + prop.substr( 1 ),
  1619. props = ( prop + " " + vendors.join( uc_prop + " " ) + uc_prop ).split( " " ),
  1620. v;
  1621. for ( v in props ) {
  1622. if ( fbCSS[ props[ v ] ] !== undefined ) {
  1623. return true;
  1624. }
  1625. }
  1626. }
  1627. var fakeBody = $( "<body>" ).prependTo( "html" ),
  1628. fbCSS = fakeBody[ 0 ].style,
  1629. vendors = [ "Webkit", "Moz", "O" ],
  1630. webos = "palmGetResource" in window, //only used to rule out scrollTop
  1631. opera = window.opera,
  1632. operamini = window.operamini && ({}).toString.call( window.operamini ) === "[object OperaMini]",
  1633. bb = window.blackberry && !propExists( "-webkit-transform" ), //only used to rule out box shadow, as it's filled opaque on BB 5 and lower
  1634. nokiaLTE7_3;
  1635. function validStyle( prop, value, check_vend ) {
  1636. var div = document.createElement( "div" ),
  1637. uc = function( txt ) {
  1638. return txt.charAt( 0 ).toUpperCase() + txt.substr( 1 );
  1639. },
  1640. vend_pref = function( vend ) {
  1641. if ( vend === "" ) {
  1642. return "";
  1643. } else {
  1644. return "-" + vend.charAt( 0 ).toLowerCase() + vend.substr( 1 ) + "-";
  1645. }
  1646. },
  1647. check_style = function( vend ) {
  1648. var vend_prop = vend_pref( vend ) + prop + ": " + value + ";",
  1649. uc_vend = uc( vend ),
  1650. propStyle = uc_vend + ( uc_vend === "" ? prop : uc( prop ) );
  1651. div.setAttribute( "style", vend_prop );
  1652. if ( !!div.style[ propStyle ] ) {
  1653. ret = true;
  1654. }
  1655. },
  1656. check_vends = check_vend ? check_vend : vendors,
  1657. i, ret;
  1658. for( i = 0; i < check_vends.length; i++ ) {
  1659. check_style( check_vends[i] );
  1660. }
  1661. return !!ret;
  1662. }
  1663. // inline SVG support test
  1664. function inlineSVG() {
  1665. // Thanks Modernizr & Erik Dahlstrom
  1666. var w = window,
  1667. svg = !!w.document.createElementNS && !!w.document.createElementNS( "http://www.w3.org/2000/svg", "svg" ).createSVGRect && !( w.opera && navigator.userAgent.indexOf( "Chrome" ) === -1 ),
  1668. support = function( data ) {
  1669. if ( !( data && svg ) ) {
  1670. $( "html" ).addClass( "ui-nosvg" );
  1671. }
  1672. },
  1673. img = new w.Image();
  1674. img.onerror = function() {
  1675. support( false );
  1676. };
  1677. img.onload = function() {
  1678. support( img.width === 1 && img.height === 1 );
  1679. };
  1680. img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
  1681. }
  1682. function transform3dTest() {
  1683. var mqProp = "transform-3d",
  1684. // Because the `translate3d` test below throws false positives in Android:
  1685. ret = $.mobile.media( "(-" + vendors.join( "-" + mqProp + "),(-" ) + "-" + mqProp + "),(" + mqProp + ")" ),
  1686. el, transforms, t;
  1687. if ( ret ) {
  1688. return !!ret;
  1689. }
  1690. el = document.createElement( "div" );
  1691. transforms = {
  1692. // We’re omitting Opera for the time being; MS uses unprefixed.
  1693. "MozTransform": "-moz-transform",
  1694. "transform": "transform"
  1695. };
  1696. fakeBody.append( el );
  1697. for ( t in transforms ) {
  1698. if ( el.style[ t ] !== undefined ) {
  1699. el.style[ t ] = "translate3d( 100px, 1px, 1px )";
  1700. ret = window.getComputedStyle( el ).getPropertyValue( transforms[ t ] );
  1701. }
  1702. }
  1703. return ( !!ret && ret !== "none" );
  1704. }
  1705. // Test for dynamic-updating base tag support ( allows us to avoid href,src attr rewriting )
  1706. function baseTagTest() {
  1707. var fauxBase = location.protocol + "//" + location.host + location.pathname + "ui-dir/",
  1708. base = $( "head base" ),
  1709. fauxEle = null,
  1710. href = "",
  1711. link, rebase;
  1712. if ( !base.length ) {
  1713. base = fauxEle = $( "<base>", { "href": fauxBase }).appendTo( "head" );
  1714. } else {
  1715. href = base.attr( "href" );
  1716. }
  1717. link = $( "<a href='testurl' />" ).prependTo( fakeBody );
  1718. rebase = link[ 0 ].href;
  1719. base[ 0 ].href = href || location.pathname;
  1720. if ( fauxEle ) {
  1721. fauxEle.remove();
  1722. }
  1723. return rebase.indexOf( fauxBase ) === 0;
  1724. }
  1725. // Thanks Modernizr
  1726. function cssPointerEventsTest() {
  1727. var element = document.createElement( "x" ),
  1728. documentElement = document.documentElement,
  1729. getComputedStyle = window.getComputedStyle,
  1730. supports;
  1731. if ( !( "pointerEvents" in element.style ) ) {
  1732. return false;
  1733. }
  1734. element.style.pointerEvents = "auto";
  1735. element.style.pointerEvents = "x";
  1736. documentElement.appendChild( element );
  1737. supports = getComputedStyle &&
  1738. getComputedStyle( element, "" ).pointerEvents === "auto";
  1739. documentElement.removeChild( element );
  1740. return !!supports;
  1741. }
  1742. function boundingRect() {
  1743. var div = document.createElement( "div" );
  1744. return typeof div.getBoundingClientRect !== "undefined";
  1745. }
  1746. // non-UA-based IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
  1747. // allows for inclusion of IE 6+, including Windows Mobile 7
  1748. $.extend( $.mobile, { browser: {} } );
  1749. $.mobile.browser.oldIE = (function() {
  1750. var v = 3,
  1751. div = document.createElement( "div" ),
  1752. a = div.all || [];
  1753. do {
  1754. div.innerHTML = "<!--[if gt IE " + ( ++v ) + "]><br><![endif]-->";
  1755. } while( a[0] );
  1756. return v > 4 ? v : !v;
  1757. })();
  1758. function fixedPosition() {
  1759. var w = window,
  1760. ua = navigator.userAgent,
  1761. platform = navigator.platform,
  1762. // Rendering engine is Webkit, and capture major version
  1763. wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ),
  1764. wkversion = !!wkmatch && wkmatch[ 1 ],
  1765. ffmatch = ua.match( /Fennec\/([0-9]+)/ ),
  1766. ffversion = !!ffmatch && ffmatch[ 1 ],
  1767. operammobilematch = ua.match( /Opera Mobi\/([0-9]+)/ ),
  1768. omversion = !!operammobilematch && operammobilematch[ 1 ];
  1769. if (
  1770. // iOS 4.3 and older : Platform is iPhone/Pad/Touch and Webkit version is less than 534 (ios5)
  1771. ( ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1 || platform.indexOf( "iPod" ) > -1 ) && wkversion && wkversion < 534 ) ||
  1772. // Opera Mini
  1773. ( w.operamini && ({}).toString.call( w.operamini ) === "[object OperaMini]" ) ||
  1774. ( operammobilematch && omversion < 7458 ) ||
  1775. //Android lte 2.1: Platform is Android and Webkit version is less than 533 (Android 2.2)
  1776. ( ua.indexOf( "Android" ) > -1 && wkversion && wkversion < 533 ) ||
  1777. // Firefox Mobile before 6.0 -
  1778. ( ffversion && ffversion < 6 ) ||
  1779. // WebOS less than 3
  1780. ( "palmGetResource" in window && wkversion && wkversion < 534 ) ||
  1781. // MeeGo
  1782. ( ua.indexOf( "MeeGo" ) > -1 && ua.indexOf( "NokiaBrowser/8.5.0" ) > -1 ) ) {
  1783. return false;
  1784. }
  1785. return true;
  1786. }
  1787. $.extend( $.support, {
  1788. cssTransitions: "WebKitTransitionEvent" in window ||
  1789. validStyle( "transition", "height 100ms linear", [ "Webkit", "Moz", "" ] ) &&
  1790. !$.mobile.browser.oldIE && !opera,
  1791. // Note, Chrome for iOS has an extremely quirky implementation of popstate.
  1792. // We've chosen to take the shortest path to a bug fix here for issue #5426
  1793. // See the following link for information about the regex chosen
  1794. // https://developers.google.com/chrome/mobile/docs/user-agent#chrome_for_ios_user-agent
  1795. pushState: "pushState" in history &&
  1796. "replaceState" in history &&
  1797. // When running inside a FF iframe, calling replaceState causes an error
  1798. !( window.navigator.userAgent.indexOf( "Firefox" ) >= 0 && window.top !== window ) &&
  1799. ( window.navigator.userAgent.search(/CriOS/) === -1 ),
  1800. mediaquery: $.mobile.media( "only all" ),
  1801. cssPseudoElement: !!propExists( "content" ),
  1802. touchOverflow: !!propExists( "overflowScrolling" ),
  1803. cssTransform3d: transform3dTest(),
  1804. cssAnimations: !!propExists( "animationName" ),
  1805. boxShadow: !!propExists( "boxShadow" ) && !bb,
  1806. fixedPosition: fixedPosition(),
  1807. scrollTop: ("pageXOffset" in window ||
  1808. "scrollTop" in document.documentElement ||
  1809. "scrollTop" in fakeBody[ 0 ]) && !webos && !operamini,
  1810. dynamicBaseTag: baseTagTest(),
  1811. cssPointerEvents: cssPointerEventsTest(),
  1812. boundingRect: boundingRect(),
  1813. inlineSVG: inlineSVG
  1814. });
  1815. fakeBody.remove();
  1816. // $.mobile.ajaxBlacklist is used to override ajaxEnabled on platforms that have known conflicts with hash history updates (BB5, Symbian)
  1817. // or that generally work better browsing in regular http for full page refreshes (Opera Mini)
  1818. // Note: This detection below is used as a last resort.
  1819. // We recommend only using these detection methods when all other more reliable/forward-looking approaches are not possible
  1820. nokiaLTE7_3 = (function() {
  1821. var ua = window.navigator.userAgent;
  1822. //The following is an attempt to match Nokia browsers that are running Symbian/s60, with webkit, version 7.3 or older
  1823. return ua.indexOf( "Nokia" ) > -1 &&
  1824. ( ua.indexOf( "Symbian/3" ) > -1 || ua.indexOf( "Series60/5" ) > -1 ) &&
  1825. ua.indexOf( "AppleWebKit" ) > -1 &&
  1826. ua.match( /(BrowserNG|NokiaBrowser)\/7\.[0-3]/ );
  1827. })();
  1828. // Support conditions that must be met in order to proceed
  1829. // default enhanced qualifications are media query support OR IE 7+
  1830. $.mobile.gradeA = function() {
  1831. return ( ( $.support.mediaquery && $.support.cssPseudoElement ) || $.mobile.browser.oldIE && $.mobile.browser.oldIE >= 8 ) && ( $.support.boundingRect || $.fn.jquery.match(/1\.[0-7+]\.[0-9+]?/) !== null );
  1832. };
  1833. $.mobile.ajaxBlacklist =
  1834. // BlackBerry browsers, pre-webkit
  1835. window.blackberry && !window.WebKitPoint ||
  1836. // Opera Mini
  1837. operamini ||
  1838. // Symbian webkits pre 7.3
  1839. nokiaLTE7_3;
  1840. // Lastly, this workaround is the only way we've found so far to get pre 7.3 Symbian webkit devices
  1841. // to render the stylesheets when they're referenced before this script, as we'd recommend doing.
  1842. // This simply reappends the CSS in place, which for some reason makes it apply
  1843. if ( nokiaLTE7_3 ) {
  1844. $(function() {
  1845. $( "head link[rel='stylesheet']" ).attr( "rel", "alternate stylesheet" ).attr( "rel", "stylesheet" );
  1846. });
  1847. }
  1848. // For ruling out shadows via css
  1849. if ( !$.support.boxShadow ) {
  1850. $( "html" ).addClass( "ui-noboxshadow" );
  1851. }
  1852. })( jQuery );
  1853. (function( $, undefined ) {
  1854. var $win = $.mobile.window, self,
  1855. dummyFnToInitNavigate = function() {
  1856. };
  1857. $.event.special.beforenavigate = {
  1858. setup: function() {
  1859. $win.on( "navigate", dummyFnToInitNavigate );
  1860. },
  1861. teardown: function() {
  1862. $win.off( "navigate", dummyFnToInitNavigate );
  1863. }
  1864. };
  1865. $.event.special.navigate = self = {
  1866. bound: false,
  1867. pushStateEnabled: true,
  1868. originalEventName: undefined,
  1869. // If pushstate support is present and push state support is defined to
  1870. // be true on the mobile namespace.
  1871. isPushStateEnabled: function() {
  1872. return $.support.pushState &&
  1873. $.mobile.pushStateEnabled === true &&
  1874. this.isHashChangeEnabled();
  1875. },
  1876. // !! assumes mobile namespace is present
  1877. isHashChangeEnabled: function() {
  1878. return $.mobile.hashListeningEnabled === true;
  1879. },
  1880. // TODO a lot of duplication between popstate and hashchange
  1881. popstate: function( event ) {
  1882. var newEvent = new $.Event( "navigate" ),
  1883. beforeNavigate = new $.Event( "beforenavigate" ),
  1884. state = event.originalEvent.state || {};
  1885. beforeNavigate.originalEvent = event;
  1886. $win.trigger( beforeNavigate );
  1887. if ( beforeNavigate.isDefaultPrevented() ) {
  1888. return;
  1889. }
  1890. if ( event.historyState ) {
  1891. $.extend(state, event.historyState);
  1892. }
  1893. // Make sure the original event is tracked for the end
  1894. // user to inspect incase they want to do something special
  1895. newEvent.originalEvent = event;
  1896. // NOTE we let the current stack unwind because any assignment to
  1897. // location.hash will stop the world and run this event handler. By
  1898. // doing this we create a similar behavior to hashchange on hash
  1899. // assignment
  1900. setTimeout(function() {
  1901. $win.trigger( newEvent, {
  1902. state: state
  1903. });
  1904. }, 0);
  1905. },
  1906. hashchange: function( event /*, data */ ) {
  1907. var newEvent = new $.Event( "navigate" ),
  1908. beforeNavigate = new $.Event( "beforenavigate" );
  1909. beforeNavigate.originalEvent = event;
  1910. $win.trigger( beforeNavigate );
  1911. if ( beforeNavigate.isDefaultPrevented() ) {
  1912. return;
  1913. }
  1914. // Make sure the original event is tracked for the end
  1915. // user to inspect incase they want to do something special
  1916. newEvent.originalEvent = event;
  1917. // Trigger the hashchange with state provided by the user
  1918. // that altered the hash
  1919. $win.trigger( newEvent, {
  1920. // Users that want to fully normalize the two events
  1921. // will need to do history management down the stack and
  1922. // add the state to the event before this binding is fired
  1923. // TODO consider allowing for the explicit addition of callbacks
  1924. // to be fired before this value is set to avoid event timing issues
  1925. state: event.hashchangeState || {}
  1926. });
  1927. },
  1928. // TODO We really only want to set this up once
  1929. // but I'm not clear if there's a beter way to achieve
  1930. // this with the jQuery special event structure
  1931. setup: function( /* data, namespaces */ ) {
  1932. if ( self.bound ) {
  1933. return;
  1934. }
  1935. self.bound = true;
  1936. if ( self.isPushStateEnabled() ) {
  1937. self.originalEventName = "popstate";
  1938. $win.bind( "popstate.navigate", self.popstate );
  1939. } else if ( self.isHashChangeEnabled() ) {
  1940. self.originalEventName = "hashchange";
  1941. $win.bind( "hashchange.navigate", self.hashchange );
  1942. }
  1943. }
  1944. };
  1945. })( jQuery );
  1946. (function( $, undefined ) {
  1947. var path, $base, dialogHashKey = "&ui-state=dialog";
  1948. $.mobile.path = path = {
  1949. uiStateKey: "&ui-state",
  1950. // This scary looking regular expression parses an absolute URL or its relative
  1951. // variants (protocol, site, document, query, and hash), into the various
  1952. // components (protocol, host, path, query, fragment, etc that make up the
  1953. // URL as well as some other commonly used sub-parts. When used with RegExp.exec()
  1954. // or String.match, it parses the URL into a results array that looks like this:
  1955. //
  1956. // [0]: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content
  1957. // [1]: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread
  1958. // [2]: http://jblas:password@mycompany.com:8080/mail/inbox
  1959. // [3]: http://jblas:password@mycompany.com:8080
  1960. // [4]: http:
  1961. // [5]: //
  1962. // [6]: jblas:password@mycompany.com:8080
  1963. // [7]: jblas:password
  1964. // [8]: jblas
  1965. // [9]: password
  1966. // [10]: mycompany.com:8080
  1967. // [11]: mycompany.com
  1968. // [12]: 8080
  1969. // [13]: /mail/inbox
  1970. // [14]: /mail/
  1971. // [15]: inbox
  1972. // [16]: ?msg=1234&type=unread
  1973. // [17]: #msg-content
  1974. //
  1975. urlParseRE: /^\s*(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,
  1976. // Abstraction to address xss (Issue #4787) by removing the authority in
  1977. // browsers that auto decode it. All references to location.href should be
  1978. // replaced with a call to this method so that it can be dealt with properly here
  1979. getLocation: function( url ) {
  1980. var uri = url ? this.parseUrl( url ) : location,
  1981. hash = this.parseUrl( url || location.href ).hash;
  1982. // mimic the browser with an empty string when the hash is empty
  1983. hash = hash === "#" ? "" : hash;
  1984. // Make sure to parse the url or the location object for the hash because using location.hash
  1985. // is autodecoded in firefox, the rest of the url should be from the object (location unless
  1986. // we're testing) to avoid the inclusion of the authority
  1987. return uri.protocol + "//" + uri.host + uri.pathname + uri.search + hash;
  1988. },
  1989. //return the original document url
  1990. getDocumentUrl: function( asParsedObject ) {
  1991. return asParsedObject ? $.extend( {}, path.documentUrl ) : path.documentUrl.href;
  1992. },
  1993. parseLocation: function() {
  1994. return this.parseUrl( this.getLocation() );
  1995. },
  1996. //Parse a URL into a structure that allows easy access to
  1997. //all of the URL components by name.
  1998. parseUrl: function( url ) {
  1999. // If we're passed an object, we'll assume that it is
  2000. // a parsed url object and just return it back to the caller.
  2001. if ( $.type( url ) === "object" ) {
  2002. return url;
  2003. }
  2004. var matches = path.urlParseRE.exec( url || "" ) || [];
  2005. // Create an object that allows the caller to access the sub-matches
  2006. // by name. Note that IE returns an empty string instead of undefined,
  2007. // like all other browsers do, so we normalize everything so its consistent
  2008. // no matter what browser we're running on.
  2009. return {
  2010. href: matches[ 0 ] || "",
  2011. hrefNoHash: matches[ 1 ] || "",
  2012. hrefNoSearch: matches[ 2 ] || "",
  2013. domain: matches[ 3 ] || "",
  2014. protocol: matches[ 4 ] || "",
  2015. doubleSlash: matches[ 5 ] || "",
  2016. authority: matches[ 6 ] || "",
  2017. username: matches[ 8 ] || "",
  2018. password: matches[ 9 ] || "",
  2019. host: matches[ 10 ] || "",
  2020. hostname: matches[ 11 ] || "",
  2021. port: matches[ 12 ] || "",
  2022. pathname: matches[ 13 ] || "",
  2023. directory: matches[ 14 ] || "",
  2024. filename: matches[ 15 ] || "",
  2025. search: matches[ 16 ] || "",
  2026. hash: matches[ 17 ] || ""
  2027. };
  2028. },
  2029. //Turn relPath into an asbolute path. absPath is
  2030. //an optional absolute path which describes what
  2031. //relPath is relative to.
  2032. makePathAbsolute: function( relPath, absPath ) {
  2033. var absStack,
  2034. relStack,
  2035. i, d;
  2036. if ( relPath && relPath.charAt( 0 ) === "/" ) {
  2037. return relPath;
  2038. }
  2039. relPath = relPath || "";
  2040. absPath = absPath ? absPath.replace( /^\/|(\/[^\/]*|[^\/]+)$/g, "" ) : "";
  2041. absStack = absPath ? absPath.split( "/" ) : [];
  2042. relStack = relPath.split( "/" );
  2043. for ( i = 0; i < relStack.length; i++ ) {
  2044. d = relStack[ i ];
  2045. switch ( d ) {
  2046. case ".":
  2047. break;
  2048. case "..":
  2049. if ( absStack.length ) {
  2050. absStack.pop();
  2051. }
  2052. break;
  2053. default:
  2054. absStack.push( d );
  2055. break;
  2056. }
  2057. }
  2058. return "/" + absStack.join( "/" );
  2059. },
  2060. //Returns true if both urls have the same domain.
  2061. isSameDomain: function( absUrl1, absUrl2 ) {
  2062. return path.parseUrl( absUrl1 ).domain === path.parseUrl( absUrl2 ).domain;
  2063. },
  2064. //Returns true for any relative variant.
  2065. isRelativeUrl: function( url ) {
  2066. // All relative Url variants have one thing in common, no protocol.
  2067. return path.parseUrl( url ).protocol === "";
  2068. },
  2069. //Returns true for an absolute url.
  2070. isAbsoluteUrl: function( url ) {
  2071. return path.parseUrl( url ).protocol !== "";
  2072. },
  2073. //Turn the specified realtive URL into an absolute one. This function
  2074. //can handle all relative variants (protocol, site, document, query, fragment).
  2075. makeUrlAbsolute: function( relUrl, absUrl ) {
  2076. if ( !path.isRelativeUrl( relUrl ) ) {
  2077. return relUrl;
  2078. }
  2079. if ( absUrl === undefined ) {
  2080. absUrl = this.documentBase;
  2081. }
  2082. var relObj = path.parseUrl( relUrl ),
  2083. absObj = path.parseUrl( absUrl ),
  2084. protocol = relObj.protocol || absObj.protocol,
  2085. doubleSlash = relObj.protocol ? relObj.doubleSlash : ( relObj.doubleSlash || absObj.doubleSlash ),
  2086. authority = relObj.authority || absObj.authority,
  2087. hasPath = relObj.pathname !== "",
  2088. pathname = path.makePathAbsolute( relObj.pathname || absObj.filename, absObj.pathname ),
  2089. search = relObj.search || ( !hasPath && absObj.search ) || "",
  2090. hash = relObj.hash;
  2091. return protocol + doubleSlash + authority + pathname + search + hash;
  2092. },
  2093. //Add search (aka query) params to the specified url.
  2094. addSearchParams: function( url, params ) {
  2095. var u = path.parseUrl( url ),
  2096. p = ( typeof params === "object" ) ? $.param( params ) : params,
  2097. s = u.search || "?";
  2098. return u.hrefNoSearch + s + ( s.charAt( s.length - 1 ) !== "?" ? "&" : "" ) + p + ( u.hash || "" );
  2099. },
  2100. convertUrlToDataUrl: function( absUrl ) {
  2101. var u = path.parseUrl( absUrl );
  2102. if ( path.isEmbeddedPage( u ) ) {
  2103. // For embedded pages, remove the dialog hash key as in getFilePath(),
  2104. // and remove otherwise the Data Url won't match the id of the embedded Page.
  2105. return u.hash
  2106. .split( dialogHashKey )[0]
  2107. .replace( /^#/, "" )
  2108. .replace( /\?.*$/, "" );
  2109. } else if ( path.isSameDomain( u, this.documentBase ) ) {
  2110. return u.hrefNoHash.replace( this.documentBase.domain, "" ).split( dialogHashKey )[0];
  2111. }
  2112. return window.decodeURIComponent(absUrl);
  2113. },
  2114. //get path from current hash, or from a file path
  2115. get: function( newPath ) {
  2116. if ( newPath === undefined ) {
  2117. newPath = path.parseLocation().hash;
  2118. }
  2119. return path.stripHash( newPath ).replace( /[^\/]*\.[^\/*]+$/, "" );
  2120. },
  2121. //set location hash to path
  2122. set: function( path ) {
  2123. location.hash = path;
  2124. },
  2125. //test if a given url (string) is a path
  2126. //NOTE might be exceptionally naive
  2127. isPath: function( url ) {
  2128. return ( /\// ).test( url );
  2129. },
  2130. //return a url path with the window's location protocol/hostname/pathname removed
  2131. clean: function( url ) {
  2132. return url.replace( this.documentBase.domain, "" );
  2133. },
  2134. //just return the url without an initial #
  2135. stripHash: function( url ) {
  2136. return url.replace( /^#/, "" );
  2137. },
  2138. stripQueryParams: function( url ) {
  2139. return url.replace( /\?.*$/, "" );
  2140. },
  2141. //remove the preceding hash, any query params, and dialog notations
  2142. cleanHash: function( hash ) {
  2143. return path.stripHash( hash.replace( /\?.*$/, "" ).replace( dialogHashKey, "" ) );
  2144. },
  2145. isHashValid: function( hash ) {
  2146. return ( /^#[^#]+$/ ).test( hash );
  2147. },
  2148. //check whether a url is referencing the same domain, or an external domain or different protocol
  2149. //could be mailto, etc
  2150. isExternal: function( url ) {
  2151. var u = path.parseUrl( url );
  2152. return u.protocol && u.domain !== this.documentUrl.domain ? true : false;
  2153. },
  2154. hasProtocol: function( url ) {
  2155. return ( /^(:?\w+:)/ ).test( url );
  2156. },
  2157. isEmbeddedPage: function( url ) {
  2158. var u = path.parseUrl( url );
  2159. //if the path is absolute, then we need to compare the url against
  2160. //both the this.documentUrl and the documentBase. The main reason for this
  2161. //is that links embedded within external documents will refer to the
  2162. //application document, whereas links embedded within the application
  2163. //document will be resolved against the document base.
  2164. if ( u.protocol !== "" ) {
  2165. return ( !this.isPath(u.hash) && u.hash && ( u.hrefNoHash === this.documentUrl.hrefNoHash || ( this.documentBaseDiffers && u.hrefNoHash === this.documentBase.hrefNoHash ) ) );
  2166. }
  2167. return ( /^#/ ).test( u.href );
  2168. },
  2169. squash: function( url, resolutionUrl ) {
  2170. var href, cleanedUrl, search, stateIndex,
  2171. isPath = this.isPath( url ),
  2172. uri = this.parseUrl( url ),
  2173. preservedHash = uri.hash,
  2174. uiState = "";
  2175. // produce a url against which we can resole the provided path
  2176. resolutionUrl = resolutionUrl || (path.isPath(url) ? path.getLocation() : path.getDocumentUrl());
  2177. // If the url is anything but a simple string, remove any preceding hash
  2178. // eg #foo/bar -> foo/bar
  2179. // #foo -> #foo
  2180. cleanedUrl = isPath ? path.stripHash( url ) : url;
  2181. // If the url is a full url with a hash check if the parsed hash is a path
  2182. // if it is, strip the #, and use it otherwise continue without change
  2183. cleanedUrl = path.isPath( uri.hash ) ? path.stripHash( uri.hash ) : cleanedUrl;
  2184. // Split the UI State keys off the href
  2185. stateIndex = cleanedUrl.indexOf( this.uiStateKey );
  2186. // store the ui state keys for use
  2187. if ( stateIndex > -1 ) {
  2188. uiState = cleanedUrl.slice( stateIndex );
  2189. cleanedUrl = cleanedUrl.slice( 0, stateIndex );
  2190. }
  2191. // make the cleanedUrl absolute relative to the resolution url
  2192. href = path.makeUrlAbsolute( cleanedUrl, resolutionUrl );
  2193. // grab the search from the resolved url since parsing from
  2194. // the passed url may not yield the correct result
  2195. search = this.parseUrl( href ).search;
  2196. // TODO all this crap is terrible, clean it up
  2197. if ( isPath ) {
  2198. // reject the hash if it's a path or it's just a dialog key
  2199. if ( path.isPath( preservedHash ) || preservedHash.replace("#", "").indexOf( this.uiStateKey ) === 0) {
  2200. preservedHash = "";
  2201. }
  2202. // Append the UI State keys where it exists and it's been removed
  2203. // from the url
  2204. if ( uiState && preservedHash.indexOf( this.uiStateKey ) === -1) {
  2205. preservedHash += uiState;
  2206. }
  2207. // make sure that pound is on the front of the hash
  2208. if ( preservedHash.indexOf( "#" ) === -1 && preservedHash !== "" ) {
  2209. preservedHash = "#" + preservedHash;
  2210. }
  2211. // reconstruct each of the pieces with the new search string and hash
  2212. href = path.parseUrl( href );
  2213. href = href.protocol + "//" + href.host + href.pathname + search + preservedHash;
  2214. } else {
  2215. href += href.indexOf( "#" ) > -1 ? uiState : "#" + uiState;
  2216. }
  2217. return href;
  2218. },
  2219. isPreservableHash: function( hash ) {
  2220. return hash.replace( "#", "" ).indexOf( this.uiStateKey ) === 0;
  2221. },
  2222. // Escape weird characters in the hash if it is to be used as a selector
  2223. hashToSelector: function( hash ) {
  2224. var hasHash = ( hash.substring( 0, 1 ) === "#" );
  2225. if ( hasHash ) {
  2226. hash = hash.substring( 1 );
  2227. }
  2228. return ( hasHash ? "#" : "" ) + hash.replace( /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g, "\\$1" );
  2229. },
  2230. // return the substring of a filepath before the sub-page key, for making
  2231. // a server request
  2232. getFilePath: function( path ) {
  2233. var splitkey = "&" + $.mobile.subPageUrlKey;
  2234. return path && path.split( splitkey )[0].split( dialogHashKey )[0];
  2235. },
  2236. // check if the specified url refers to the first page in the main
  2237. // application document.
  2238. isFirstPageUrl: function( url ) {
  2239. // We only deal with absolute paths.
  2240. var u = path.parseUrl( path.makeUrlAbsolute( url, this.documentBase ) ),
  2241. // Does the url have the same path as the document?
  2242. samePath = u.hrefNoHash === this.documentUrl.hrefNoHash ||
  2243. ( this.documentBaseDiffers &&
  2244. u.hrefNoHash === this.documentBase.hrefNoHash ),
  2245. // Get the first page element.
  2246. fp = $.mobile.firstPage,
  2247. // Get the id of the first page element if it has one.
  2248. fpId = fp && fp[0] ? fp[0].id : undefined;
  2249. // The url refers to the first page if the path matches the document and
  2250. // it either has no hash value, or the hash is exactly equal to the id
  2251. // of the first page element.
  2252. return samePath &&
  2253. ( !u.hash ||
  2254. u.hash === "#" ||
  2255. ( fpId && u.hash.replace( /^#/, "" ) === fpId ) );
  2256. },
  2257. // Some embedded browsers, like the web view in Phone Gap, allow
  2258. // cross-domain XHR requests if the document doing the request was loaded
  2259. // via the file:// protocol. This is usually to allow the application to
  2260. // "phone home" and fetch app specific data. We normally let the browser
  2261. // handle external/cross-domain urls, but if the allowCrossDomainPages
  2262. // option is true, we will allow cross-domain http/https requests to go
  2263. // through our page loading logic.
  2264. isPermittedCrossDomainRequest: function( docUrl, reqUrl ) {
  2265. return $.mobile.allowCrossDomainPages &&
  2266. (docUrl.protocol === "file:" || docUrl.protocol === "content:") &&
  2267. reqUrl.search( /^https?:/ ) !== -1;
  2268. }
  2269. };
  2270. path.documentUrl = path.parseLocation();
  2271. $base = $( "head" ).find( "base" );
  2272. path.documentBase = $base.length ?
  2273. path.parseUrl( path.makeUrlAbsolute( $base.attr( "href" ), path.documentUrl.href ) ) :
  2274. path.documentUrl;
  2275. path.documentBaseDiffers = (path.documentUrl.hrefNoHash !== path.documentBase.hrefNoHash);
  2276. //return the original document base url
  2277. path.getDocumentBase = function( asParsedObject ) {
  2278. return asParsedObject ? $.extend( {}, path.documentBase ) : path.documentBase.href;
  2279. };
  2280. // DEPRECATED as of 1.4.0 - remove in 1.5.0
  2281. $.extend( $.mobile, {
  2282. //return the original document url
  2283. getDocumentUrl: path.getDocumentUrl,
  2284. //return the original document base url
  2285. getDocumentBase: path.getDocumentBase
  2286. });
  2287. })( jQuery );
  2288. (function( $, undefined ) {
  2289. $.mobile.History = function( stack, index ) {
  2290. this.stack = stack || [];
  2291. this.activeIndex = index || 0;
  2292. };
  2293. $.extend($.mobile.History.prototype, {
  2294. getActive: function() {
  2295. return this.stack[ this.activeIndex ];
  2296. },
  2297. getLast: function() {
  2298. return this.stack[ this.previousIndex ];
  2299. },
  2300. getNext: function() {
  2301. return this.stack[ this.activeIndex + 1 ];
  2302. },
  2303. getPrev: function() {
  2304. return this.stack[ this.activeIndex - 1 ];
  2305. },
  2306. // addNew is used whenever a new page is added
  2307. add: function( url, data ) {
  2308. data = data || {};
  2309. //if there's forward history, wipe it
  2310. if ( this.getNext() ) {
  2311. this.clearForward();
  2312. }
  2313. // if the hash is included in the data make sure the shape
  2314. // is consistent for comparison
  2315. if ( data.hash && data.hash.indexOf( "#" ) === -1) {
  2316. data.hash = "#" + data.hash;
  2317. }
  2318. data.url = url;
  2319. this.stack.push( data );
  2320. this.activeIndex = this.stack.length - 1;
  2321. },
  2322. //wipe urls ahead of active index
  2323. clearForward: function() {
  2324. this.stack = this.stack.slice( 0, this.activeIndex + 1 );
  2325. },
  2326. find: function( url, stack, earlyReturn ) {
  2327. stack = stack || this.stack;
  2328. var entry, i, length = stack.length, index;
  2329. for ( i = 0; i < length; i++ ) {
  2330. entry = stack[i];
  2331. if ( decodeURIComponent(url) === decodeURIComponent(entry.url) ||
  2332. decodeURIComponent(url) === decodeURIComponent(entry.hash) ) {
  2333. index = i;
  2334. if ( earlyReturn ) {
  2335. return index;
  2336. }
  2337. }
  2338. }
  2339. return index;
  2340. },
  2341. closest: function( url ) {
  2342. var closest, a = this.activeIndex;
  2343. // First, take the slice of the history stack before the current index and search
  2344. // for a url match. If one is found, we'll avoid avoid looking through forward history
  2345. // NOTE the preference for backward history movement is driven by the fact that
  2346. // most mobile browsers only have a dedicated back button, and users rarely use
  2347. // the forward button in desktop browser anyhow
  2348. closest = this.find( url, this.stack.slice(0, a) );
  2349. // If nothing was found in backward history check forward. The `true`
  2350. // value passed as the third parameter causes the find method to break
  2351. // on the first match in the forward history slice. The starting index
  2352. // of the slice must then be added to the result to get the element index
  2353. // in the original history stack :( :(
  2354. //
  2355. // TODO this is hyper confusing and should be cleaned up (ugh so bad)
  2356. if ( closest === undefined ) {
  2357. closest = this.find( url, this.stack.slice(a), true );
  2358. closest = closest === undefined ? closest : closest + a;
  2359. }
  2360. return closest;
  2361. },
  2362. direct: function( opts ) {
  2363. var newActiveIndex = this.closest( opts.url ), a = this.activeIndex;
  2364. // save new page index, null check to prevent falsey 0 result
  2365. // record the previous index for reference
  2366. if ( newActiveIndex !== undefined ) {
  2367. this.activeIndex = newActiveIndex;
  2368. this.previousIndex = a;
  2369. }
  2370. // invoke callbacks where appropriate
  2371. //
  2372. // TODO this is also convoluted and confusing
  2373. if ( newActiveIndex < a ) {
  2374. ( opts.present || opts.back || $.noop )( this.getActive(), "back" );
  2375. } else if ( newActiveIndex > a ) {
  2376. ( opts.present || opts.forward || $.noop )( this.getActive(), "forward" );
  2377. } else if ( newActiveIndex === undefined && opts.missing ) {
  2378. opts.missing( this.getActive() );
  2379. }
  2380. }
  2381. });
  2382. })( jQuery );
  2383. (function( $, undefined ) {
  2384. var path = $.mobile.path,
  2385. initialHref = location.href;
  2386. $.mobile.Navigator = function( history ) {
  2387. this.history = history;
  2388. this.ignoreInitialHashChange = true;
  2389. $.mobile.window.bind({
  2390. "popstate.history": $.proxy( this.popstate, this ),
  2391. "hashchange.history": $.proxy( this.hashchange, this )
  2392. });
  2393. };
  2394. $.extend($.mobile.Navigator.prototype, {
  2395. squash: function( url, data ) {
  2396. var state, href, hash = path.isPath(url) ? path.stripHash(url) : url;
  2397. href = path.squash( url );
  2398. // make sure to provide this information when it isn't explicitly set in the
  2399. // data object that was passed to the squash method
  2400. state = $.extend({
  2401. hash: hash,
  2402. url: href
  2403. }, data);
  2404. // replace the current url with the new href and store the state
  2405. // Note that in some cases we might be replacing an url with the
  2406. // same url. We do this anyways because we need to make sure that
  2407. // all of our history entries have a state object associated with
  2408. // them. This allows us to work around the case where $.mobile.back()
  2409. // is called to transition from an external page to an embedded page.
  2410. // In that particular case, a hashchange event is *NOT* generated by the browser.
  2411. // Ensuring each history entry has a state object means that onPopState()
  2412. // will always trigger our hashchange callback even when a hashchange event
  2413. // is not fired.
  2414. window.history.replaceState( state, state.title || document.title, href );
  2415. return state;
  2416. },
  2417. hash: function( url, href ) {
  2418. var parsed, loc, hash, resolved;
  2419. // Grab the hash for recording. If the passed url is a path
  2420. // we used the parsed version of the squashed url to reconstruct,
  2421. // otherwise we assume it's a hash and store it directly
  2422. parsed = path.parseUrl( url );
  2423. loc = path.parseLocation();
  2424. if ( loc.pathname + loc.search === parsed.pathname + parsed.search ) {
  2425. // If the pathname and search of the passed url is identical to the current loc
  2426. // then we must use the hash. Otherwise there will be no event
  2427. // eg, url = "/foo/bar?baz#bang", location.href = "http://example.com/foo/bar?baz"
  2428. hash = parsed.hash ? parsed.hash : parsed.pathname + parsed.search;
  2429. } else if ( path.isPath(url) ) {
  2430. resolved = path.parseUrl( href );
  2431. // If the passed url is a path, make it domain relative and remove any trailing hash
  2432. hash = resolved.pathname + resolved.search + (path.isPreservableHash( resolved.hash )? resolved.hash.replace( "#", "" ) : "");
  2433. } else {
  2434. hash = url;
  2435. }
  2436. return hash;
  2437. },
  2438. // TODO reconsider name
  2439. go: function( url, data, noEvents ) {
  2440. var state, href, hash, popstateEvent,
  2441. isPopStateEvent = $.event.special.navigate.isPushStateEnabled();
  2442. // Get the url as it would look squashed on to the current resolution url
  2443. href = path.squash( url );
  2444. // sort out what the hash sould be from the url
  2445. hash = this.hash( url, href );
  2446. // Here we prevent the next hash change or popstate event from doing any
  2447. // history management. In the case of hashchange we don't swallow it
  2448. // if there will be no hashchange fired (since that won't reset the value)
  2449. // and will swallow the following hashchange
  2450. if ( noEvents && hash !== path.stripHash(path.parseLocation().hash) ) {
  2451. this.preventNextHashChange = noEvents;
  2452. }
  2453. // IMPORTANT in the case where popstate is supported the event will be triggered
  2454. // directly, stopping further execution - ie, interupting the flow of this
  2455. // method call to fire bindings at this expression. Below the navigate method
  2456. // there is a binding to catch this event and stop its propagation.
  2457. //
  2458. // We then trigger a new popstate event on the window with a null state
  2459. // so that the navigate events can conclude their work properly
  2460. //
  2461. // if the url is a path we want to preserve the query params that are available on
  2462. // the current url.
  2463. this.preventHashAssignPopState = true;
  2464. window.location.hash = hash;
  2465. // If popstate is enabled and the browser triggers `popstate` events when the hash
  2466. // is set (this often happens immediately in browsers like Chrome), then the
  2467. // this flag will be set to false already. If it's a browser that does not trigger
  2468. // a `popstate` on hash assignement or `replaceState` then we need avoid the branch
  2469. // that swallows the event created by the popstate generated by the hash assignment
  2470. // At the time of this writing this happens with Opera 12 and some version of IE
  2471. this.preventHashAssignPopState = false;
  2472. state = $.extend({
  2473. url: href,
  2474. hash: hash,
  2475. title: document.title
  2476. }, data);
  2477. if ( isPopStateEvent ) {
  2478. popstateEvent = new $.Event( "popstate" );
  2479. popstateEvent.originalEvent = {
  2480. type: "popstate",
  2481. state: null
  2482. };
  2483. this.squash( url, state );
  2484. // Trigger a new faux popstate event to replace the one that we
  2485. // caught that was triggered by the hash setting above.
  2486. if ( !noEvents ) {
  2487. this.ignorePopState = true;
  2488. $.mobile.window.trigger( popstateEvent );
  2489. }
  2490. }
  2491. // record the history entry so that the information can be included
  2492. // in hashchange event driven navigate events in a similar fashion to
  2493. // the state that's provided by popstate
  2494. this.history.add( state.url, state );
  2495. },
  2496. // This binding is intended to catch the popstate events that are fired
  2497. // when execution of the `$.navigate` method stops at window.location.hash = url;
  2498. // and completely prevent them from propagating. The popstate event will then be
  2499. // retriggered after execution resumes
  2500. //
  2501. // TODO grab the original event here and use it for the synthetic event in the
  2502. // second half of the navigate execution that will follow this binding
  2503. popstate: function( event ) {
  2504. var hash, state;
  2505. // Partly to support our test suite which manually alters the support
  2506. // value to test hashchange. Partly to prevent all around weirdness
  2507. if ( !$.event.special.navigate.isPushStateEnabled() ) {
  2508. return;
  2509. }
  2510. // If this is the popstate triggered by the actual alteration of the hash
  2511. // prevent it completely. History is tracked manually
  2512. if ( this.preventHashAssignPopState ) {
  2513. this.preventHashAssignPopState = false;
  2514. event.stopImmediatePropagation();
  2515. return;
  2516. }
  2517. // if this is the popstate triggered after the `replaceState` call in the go
  2518. // method, then simply ignore it. The history entry has already been captured
  2519. if ( this.ignorePopState ) {
  2520. this.ignorePopState = false;
  2521. return;
  2522. }
  2523. // If there is no state, and the history stack length is one were
  2524. // probably getting the page load popstate fired by browsers like chrome
  2525. // avoid it and set the one time flag to false.
  2526. // TODO: Do we really need all these conditions? Comparing location hrefs
  2527. // should be sufficient.
  2528. if ( !event.originalEvent.state &&
  2529. this.history.stack.length === 1 &&
  2530. this.ignoreInitialHashChange ) {
  2531. this.ignoreInitialHashChange = false;
  2532. if ( location.href === initialHref ) {
  2533. event.preventDefault();
  2534. return;
  2535. }
  2536. }
  2537. // account for direct manipulation of the hash. That is, we will receive a popstate
  2538. // when the hash is changed by assignment, and it won't have a state associated. We
  2539. // then need to squash the hash. See below for handling of hash assignment that
  2540. // matches an existing history entry
  2541. // TODO it might be better to only add to the history stack
  2542. // when the hash is adjacent to the active history entry
  2543. hash = path.parseLocation().hash;
  2544. if ( !event.originalEvent.state && hash ) {
  2545. // squash the hash that's been assigned on the URL with replaceState
  2546. // also grab the resulting state object for storage
  2547. state = this.squash( hash );
  2548. // record the new hash as an additional history entry
  2549. // to match the browser's treatment of hash assignment
  2550. this.history.add( state.url, state );
  2551. // pass the newly created state information
  2552. // along with the event
  2553. event.historyState = state;
  2554. // do not alter history, we've added a new history entry
  2555. // so we know where we are
  2556. return;
  2557. }
  2558. // If all else fails this is a popstate that comes from the back or forward buttons
  2559. // make sure to set the state of our history stack properly, and record the directionality
  2560. this.history.direct({
  2561. url: (event.originalEvent.state || {}).url || hash,
  2562. // When the url is either forward or backward in history include the entry
  2563. // as data on the event object for merging as data in the navigate event
  2564. present: function( historyEntry, direction ) {
  2565. // make sure to create a new object to pass down as the navigate event data
  2566. event.historyState = $.extend({}, historyEntry);
  2567. event.historyState.direction = direction;
  2568. }
  2569. });
  2570. },
  2571. // NOTE must bind before `navigate` special event hashchange binding otherwise the
  2572. // navigation data won't be attached to the hashchange event in time for those
  2573. // bindings to attach it to the `navigate` special event
  2574. // TODO add a check here that `hashchange.navigate` is bound already otherwise it's
  2575. // broken (exception?)
  2576. hashchange: function( event ) {
  2577. var history, hash;
  2578. // If hashchange listening is explicitly disabled or pushstate is supported
  2579. // avoid making use of the hashchange handler.
  2580. if (!$.event.special.navigate.isHashChangeEnabled() ||
  2581. $.event.special.navigate.isPushStateEnabled() ) {
  2582. return;
  2583. }
  2584. // On occasion explicitly want to prevent the next hash from propogating because we only
  2585. // with to alter the url to represent the new state do so here
  2586. if ( this.preventNextHashChange ) {
  2587. this.preventNextHashChange = false;
  2588. event.stopImmediatePropagation();
  2589. return;
  2590. }
  2591. history = this.history;
  2592. hash = path.parseLocation().hash;
  2593. // If this is a hashchange caused by the back or forward button
  2594. // make sure to set the state of our history stack properly
  2595. this.history.direct({
  2596. url: hash,
  2597. // When the url is either forward or backward in history include the entry
  2598. // as data on the event object for merging as data in the navigate event
  2599. present: function( historyEntry, direction ) {
  2600. // make sure to create a new object to pass down as the navigate event data
  2601. event.hashchangeState = $.extend({}, historyEntry);
  2602. event.hashchangeState.direction = direction;
  2603. },
  2604. // When we don't find a hash in our history clearly we're aiming to go there
  2605. // record the entry as new for future traversal
  2606. //
  2607. // NOTE it's not entirely clear that this is the right thing to do given that we
  2608. // can't know the users intention. It might be better to explicitly _not_
  2609. // support location.hash assignment in preference to $.navigate calls
  2610. // TODO first arg to add should be the href, but it causes issues in identifying
  2611. // embeded pages
  2612. missing: function() {
  2613. history.add( hash, {
  2614. hash: hash,
  2615. title: document.title
  2616. });
  2617. }
  2618. });
  2619. }
  2620. });
  2621. })( jQuery );
  2622. (function( $, undefined ) {
  2623. // TODO consider queueing navigation activity until previous activities have completed
  2624. // so that end users don't have to think about it. Punting for now
  2625. // TODO !! move the event bindings into callbacks on the navigate event
  2626. $.mobile.navigate = function( url, data, noEvents ) {
  2627. $.mobile.navigate.navigator.go( url, data, noEvents );
  2628. };
  2629. // expose the history on the navigate method in anticipation of full integration with
  2630. // existing navigation functionalty that is tightly coupled to the history information
  2631. $.mobile.navigate.history = new $.mobile.History();
  2632. // instantiate an instance of the navigator for use within the $.navigate method
  2633. $.mobile.navigate.navigator = new $.mobile.Navigator( $.mobile.navigate.history );
  2634. var loc = $.mobile.path.parseLocation();
  2635. $.mobile.navigate.history.add( loc.href, {hash: loc.hash} );
  2636. })( jQuery );
  2637. // This plugin is an experiment for abstracting away the touch and mouse
  2638. // events so that developers don't have to worry about which method of input
  2639. // the device their document is loaded on supports.
  2640. //
  2641. // The idea here is to allow the developer to register listeners for the
  2642. // basic mouse events, such as mousedown, mousemove, mouseup, and click,
  2643. // and the plugin will take care of registering the correct listeners
  2644. // behind the scenes to invoke the listener at the fastest possible time
  2645. // for that device, while still retaining the order of event firing in
  2646. // the traditional mouse environment, should multiple handlers be registered
  2647. // on the same element for different events.
  2648. //
  2649. // The current version exposes the following virtual events to jQuery bind methods:
  2650. // "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel"
  2651. (function( $, window, document, undefined ) {
  2652. var dataPropertyName = "virtualMouseBindings",
  2653. touchTargetPropertyName = "virtualTouchID",
  2654. virtualEventNames = "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split( " " ),
  2655. touchEventProps = "clientX clientY pageX pageY screenX screenY".split( " " ),
  2656. mouseHookProps = $.event.mouseHooks ? $.event.mouseHooks.props : [],
  2657. mouseEventProps = $.event.props.concat( mouseHookProps ),
  2658. activeDocHandlers = {},
  2659. resetTimerID = 0,
  2660. startX = 0,
  2661. startY = 0,
  2662. didScroll = false,
  2663. clickBlockList = [],
  2664. blockMouseTriggers = false,
  2665. blockTouchTriggers = false,
  2666. eventCaptureSupported = "addEventListener" in document,
  2667. $document = $( document ),
  2668. nextTouchID = 1,
  2669. lastTouchID = 0, threshold,
  2670. i;
  2671. $.vmouse = {
  2672. moveDistanceThreshold: 10,
  2673. clickDistanceThreshold: 10,
  2674. resetTimerDuration: 1500
  2675. };
  2676. function getNativeEvent( event ) {
  2677. while ( event && typeof event.originalEvent !== "undefined" ) {
  2678. event = event.originalEvent;
  2679. }
  2680. return event;
  2681. }
  2682. function createVirtualEvent( event, eventType ) {
  2683. var t = event.type,
  2684. oe, props, ne, prop, ct, touch, i, j, len;
  2685. event = $.Event( event );
  2686. event.type = eventType;
  2687. oe = event.originalEvent;
  2688. props = $.event.props;
  2689. // addresses separation of $.event.props in to $.event.mouseHook.props and Issue 3280
  2690. // https://github.com/jquery/jquery-mobile/issues/3280
  2691. if ( t.search( /^(mouse|click)/ ) > -1 ) {
  2692. props = mouseEventProps;
  2693. }
  2694. // copy original event properties over to the new event
  2695. // this would happen if we could call $.event.fix instead of $.Event
  2696. // but we don't have a way to force an event to be fixed multiple times
  2697. if ( oe ) {
  2698. for ( i = props.length, prop; i; ) {
  2699. prop = props[ --i ];
  2700. event[ prop ] = oe[ prop ];
  2701. }
  2702. }
  2703. // make sure that if the mouse and click virtual events are generated
  2704. // without a .which one is defined
  2705. if ( t.search(/mouse(down|up)|click/) > -1 && !event.which ) {
  2706. event.which = 1;
  2707. }
  2708. if ( t.search(/^touch/) !== -1 ) {
  2709. ne = getNativeEvent( oe );
  2710. t = ne.touches;
  2711. ct = ne.changedTouches;
  2712. touch = ( t && t.length ) ? t[0] : ( ( ct && ct.length ) ? ct[ 0 ] : undefined );
  2713. if ( touch ) {
  2714. for ( j = 0, len = touchEventProps.length; j < len; j++) {
  2715. prop = touchEventProps[ j ];
  2716. event[ prop ] = touch[ prop ];
  2717. }
  2718. }
  2719. }
  2720. return event;
  2721. }
  2722. function getVirtualBindingFlags( element ) {
  2723. var flags = {},
  2724. b, k;
  2725. while ( element ) {
  2726. b = $.data( element, dataPropertyName );
  2727. for ( k in b ) {
  2728. if ( b[ k ] ) {
  2729. flags[ k ] = flags.hasVirtualBinding = true;
  2730. }
  2731. }
  2732. element = element.parentNode;
  2733. }
  2734. return flags;
  2735. }
  2736. function getClosestElementWithVirtualBinding( element, eventType ) {
  2737. var b;
  2738. while ( element ) {
  2739. b = $.data( element, dataPropertyName );
  2740. if ( b && ( !eventType || b[ eventType ] ) ) {
  2741. return element;
  2742. }
  2743. element = element.parentNode;
  2744. }
  2745. return null;
  2746. }
  2747. function enableTouchBindings() {
  2748. blockTouchTriggers = false;
  2749. }
  2750. function disableTouchBindings() {
  2751. blockTouchTriggers = true;
  2752. }
  2753. function enableMouseBindings() {
  2754. lastTouchID = 0;
  2755. clickBlockList.length = 0;
  2756. blockMouseTriggers = false;
  2757. // When mouse bindings are enabled, our
  2758. // touch bindings are disabled.
  2759. disableTouchBindings();
  2760. }
  2761. function disableMouseBindings() {
  2762. // When mouse bindings are disabled, our
  2763. // touch bindings are enabled.
  2764. enableTouchBindings();
  2765. }
  2766. function startResetTimer() {
  2767. clearResetTimer();
  2768. resetTimerID = setTimeout( function() {
  2769. resetTimerID = 0;
  2770. enableMouseBindings();
  2771. }, $.vmouse.resetTimerDuration );
  2772. }
  2773. function clearResetTimer() {
  2774. if ( resetTimerID ) {
  2775. clearTimeout( resetTimerID );
  2776. resetTimerID = 0;
  2777. }
  2778. }
  2779. function triggerVirtualEvent( eventType, event, flags ) {
  2780. var ve;
  2781. if ( ( flags && flags[ eventType ] ) ||
  2782. ( !flags && getClosestElementWithVirtualBinding( event.target, eventType ) ) ) {
  2783. ve = createVirtualEvent( event, eventType );
  2784. $( event.target).trigger( ve );
  2785. }
  2786. return ve;
  2787. }
  2788. function mouseEventCallback( event ) {
  2789. var touchID = $.data( event.target, touchTargetPropertyName ),
  2790. ve;
  2791. if ( !blockMouseTriggers && ( !lastTouchID || lastTouchID !== touchID ) ) {
  2792. ve = triggerVirtualEvent( "v" + event.type, event );
  2793. if ( ve ) {
  2794. if ( ve.isDefaultPrevented() ) {
  2795. event.preventDefault();
  2796. }
  2797. if ( ve.isPropagationStopped() ) {
  2798. event.stopPropagation();
  2799. }
  2800. if ( ve.isImmediatePropagationStopped() ) {
  2801. event.stopImmediatePropagation();
  2802. }
  2803. }
  2804. }
  2805. }
  2806. function handleTouchStart( event ) {
  2807. var touches = getNativeEvent( event ).touches,
  2808. target, flags, t;
  2809. if ( touches && touches.length === 1 ) {
  2810. target = event.target;
  2811. flags = getVirtualBindingFlags( target );
  2812. if ( flags.hasVirtualBinding ) {
  2813. lastTouchID = nextTouchID++;
  2814. $.data( target, touchTargetPropertyName, lastTouchID );
  2815. clearResetTimer();
  2816. disableMouseBindings();
  2817. didScroll = false;
  2818. t = getNativeEvent( event ).touches[ 0 ];
  2819. startX = t.pageX;
  2820. startY = t.pageY;
  2821. triggerVirtualEvent( "vmouseover", event, flags );
  2822. triggerVirtualEvent( "vmousedown", event, flags );
  2823. }
  2824. }
  2825. }
  2826. function handleScroll( event ) {
  2827. if ( blockTouchTriggers ) {
  2828. return;
  2829. }
  2830. if ( !didScroll ) {
  2831. triggerVirtualEvent( "vmousecancel", event, getVirtualBindingFlags( event.target ) );
  2832. }
  2833. didScroll = true;
  2834. startResetTimer();
  2835. }
  2836. function handleTouchMove( event ) {
  2837. if ( blockTouchTriggers ) {
  2838. return;
  2839. }
  2840. var t = getNativeEvent( event ).touches[ 0 ],
  2841. didCancel = didScroll,
  2842. moveThreshold = $.vmouse.moveDistanceThreshold,
  2843. flags = getVirtualBindingFlags( event.target );
  2844. didScroll = didScroll ||
  2845. ( Math.abs( t.pageX - startX ) > moveThreshold ||
  2846. Math.abs( t.pageY - startY ) > moveThreshold );
  2847. if ( didScroll && !didCancel ) {
  2848. triggerVirtualEvent( "vmousecancel", event, flags );
  2849. }
  2850. triggerVirtualEvent( "vmousemove", event, flags );
  2851. startResetTimer();
  2852. }
  2853. function handleTouchEnd( event ) {
  2854. if ( blockTouchTriggers ) {
  2855. return;
  2856. }
  2857. disableTouchBindings();
  2858. var flags = getVirtualBindingFlags( event.target ),
  2859. ve, t;
  2860. triggerVirtualEvent( "vmouseup", event, flags );
  2861. if ( !didScroll ) {
  2862. ve = triggerVirtualEvent( "vclick", event, flags );
  2863. if ( ve && ve.isDefaultPrevented() ) {
  2864. // The target of the mouse events that follow the touchend
  2865. // event don't necessarily match the target used during the
  2866. // touch. This means we need to rely on coordinates for blocking
  2867. // any click that is generated.
  2868. t = getNativeEvent( event ).changedTouches[ 0 ];
  2869. clickBlockList.push({
  2870. touchID: lastTouchID,
  2871. x: t.clientX,
  2872. y: t.clientY
  2873. });
  2874. // Prevent any mouse events that follow from triggering
  2875. // virtual event notifications.
  2876. blockMouseTriggers = true;
  2877. }
  2878. }
  2879. triggerVirtualEvent( "vmouseout", event, flags);
  2880. didScroll = false;
  2881. startResetTimer();
  2882. }
  2883. function hasVirtualBindings( ele ) {
  2884. var bindings = $.data( ele, dataPropertyName ),
  2885. k;
  2886. if ( bindings ) {
  2887. for ( k in bindings ) {
  2888. if ( bindings[ k ] ) {
  2889. return true;
  2890. }
  2891. }
  2892. }
  2893. return false;
  2894. }
  2895. function dummyMouseHandler() {}
  2896. function getSpecialEventObject( eventType ) {
  2897. var realType = eventType.substr( 1 );
  2898. return {
  2899. setup: function(/* data, namespace */) {
  2900. // If this is the first virtual mouse binding for this element,
  2901. // add a bindings object to its data.
  2902. if ( !hasVirtualBindings( this ) ) {
  2903. $.data( this, dataPropertyName, {} );
  2904. }
  2905. // If setup is called, we know it is the first binding for this
  2906. // eventType, so initialize the count for the eventType to zero.
  2907. var bindings = $.data( this, dataPropertyName );
  2908. bindings[ eventType ] = true;
  2909. // If this is the first virtual mouse event for this type,
  2910. // register a global handler on the document.
  2911. activeDocHandlers[ eventType ] = ( activeDocHandlers[ eventType ] || 0 ) + 1;
  2912. if ( activeDocHandlers[ eventType ] === 1 ) {
  2913. $document.bind( realType, mouseEventCallback );
  2914. }
  2915. // Some browsers, like Opera Mini, won't dispatch mouse/click events
  2916. // for elements unless they actually have handlers registered on them.
  2917. // To get around this, we register dummy handlers on the elements.
  2918. $( this ).bind( realType, dummyMouseHandler );
  2919. // For now, if event capture is not supported, we rely on mouse handlers.
  2920. if ( eventCaptureSupported ) {
  2921. // If this is the first virtual mouse binding for the document,
  2922. // register our touchstart handler on the document.
  2923. activeDocHandlers[ "touchstart" ] = ( activeDocHandlers[ "touchstart" ] || 0) + 1;
  2924. if ( activeDocHandlers[ "touchstart" ] === 1 ) {
  2925. $document.bind( "touchstart", handleTouchStart )
  2926. .bind( "touchend", handleTouchEnd )
  2927. // On touch platforms, touching the screen and then dragging your finger
  2928. // causes the window content to scroll after some distance threshold is
  2929. // exceeded. On these platforms, a scroll prevents a click event from being
  2930. // dispatched, and on some platforms, even the touchend is suppressed. To
  2931. // mimic the suppression of the click event, we need to watch for a scroll
  2932. // event. Unfortunately, some platforms like iOS don't dispatch scroll
  2933. // events until *AFTER* the user lifts their finger (touchend). This means
  2934. // we need to watch both scroll and touchmove events to figure out whether
  2935. // or not a scroll happenens before the touchend event is fired.
  2936. .bind( "touchmove", handleTouchMove )
  2937. .bind( "scroll", handleScroll );
  2938. }
  2939. }
  2940. },
  2941. teardown: function(/* data, namespace */) {
  2942. // If this is the last virtual binding for this eventType,
  2943. // remove its global handler from the document.
  2944. --activeDocHandlers[ eventType ];
  2945. if ( !activeDocHandlers[ eventType ] ) {
  2946. $document.unbind( realType, mouseEventCallback );
  2947. }
  2948. if ( eventCaptureSupported ) {
  2949. // If this is the last virtual mouse binding in existence,
  2950. // remove our document touchstart listener.
  2951. --activeDocHandlers[ "touchstart" ];
  2952. if ( !activeDocHandlers[ "touchstart" ] ) {
  2953. $document.unbind( "touchstart", handleTouchStart )
  2954. .unbind( "touchmove", handleTouchMove )
  2955. .unbind( "touchend", handleTouchEnd )
  2956. .unbind( "scroll", handleScroll );
  2957. }
  2958. }
  2959. var $this = $( this ),
  2960. bindings = $.data( this, dataPropertyName );
  2961. // teardown may be called when an element was
  2962. // removed from the DOM. If this is the case,
  2963. // jQuery core may have already stripped the element
  2964. // of any data bindings so we need to check it before
  2965. // using it.
  2966. if ( bindings ) {
  2967. bindings[ eventType ] = false;
  2968. }
  2969. // Unregister the dummy event handler.
  2970. $this.unbind( realType, dummyMouseHandler );
  2971. // If this is the last virtual mouse binding on the
  2972. // element, remove the binding data from the element.
  2973. if ( !hasVirtualBindings( this ) ) {
  2974. $this.removeData( dataPropertyName );
  2975. }
  2976. }
  2977. };
  2978. }
  2979. // Expose our custom events to the jQuery bind/unbind mechanism.
  2980. for ( i = 0; i < virtualEventNames.length; i++ ) {
  2981. $.event.special[ virtualEventNames[ i ] ] = getSpecialEventObject( virtualEventNames[ i ] );
  2982. }
  2983. // Add a capture click handler to block clicks.
  2984. // Note that we require event capture support for this so if the device
  2985. // doesn't support it, we punt for now and rely solely on mouse events.
  2986. if ( eventCaptureSupported ) {
  2987. document.addEventListener( "click", function( e ) {
  2988. var cnt = clickBlockList.length,
  2989. target = e.target,
  2990. x, y, ele, i, o, touchID;
  2991. if ( cnt ) {
  2992. x = e.clientX;
  2993. y = e.clientY;
  2994. threshold = $.vmouse.clickDistanceThreshold;
  2995. // The idea here is to run through the clickBlockList to see if
  2996. // the current click event is in the proximity of one of our
  2997. // vclick events that had preventDefault() called on it. If we find
  2998. // one, then we block the click.
  2999. //
  3000. // Why do we have to rely on proximity?
  3001. //
  3002. // Because the target of the touch event that triggered the vclick
  3003. // can be different from the target of the click event synthesized
  3004. // by the browser. The target of a mouse/click event that is synthesized
  3005. // from a touch event seems to be implementation specific. For example,
  3006. // some browsers will fire mouse/click events for a link that is near
  3007. // a touch event, even though the target of the touchstart/touchend event
  3008. // says the user touched outside the link. Also, it seems that with most
  3009. // browsers, the target of the mouse/click event is not calculated until the
  3010. // time it is dispatched, so if you replace an element that you touched
  3011. // with another element, the target of the mouse/click will be the new
  3012. // element underneath that point.
  3013. //
  3014. // Aside from proximity, we also check to see if the target and any
  3015. // of its ancestors were the ones that blocked a click. This is necessary
  3016. // because of the strange mouse/click target calculation done in the
  3017. // Android 2.1 browser, where if you click on an element, and there is a
  3018. // mouse/click handler on one of its ancestors, the target will be the
  3019. // innermost child of the touched element, even if that child is no where
  3020. // near the point of touch.
  3021. ele = target;
  3022. while ( ele ) {
  3023. for ( i = 0; i < cnt; i++ ) {
  3024. o = clickBlockList[ i ];
  3025. touchID = 0;
  3026. if ( ( ele === target && Math.abs( o.x - x ) < threshold && Math.abs( o.y - y ) < threshold ) ||
  3027. $.data( ele, touchTargetPropertyName ) === o.touchID ) {
  3028. // XXX: We may want to consider removing matches from the block list
  3029. // instead of waiting for the reset timer to fire.
  3030. e.preventDefault();
  3031. e.stopPropagation();
  3032. return;
  3033. }
  3034. }
  3035. ele = ele.parentNode;
  3036. }
  3037. }
  3038. }, true);
  3039. }
  3040. })( jQuery, window, document );
  3041. (function( $, window, undefined ) {
  3042. var $document = $( document ),
  3043. supportTouch = $.mobile.support.touch,
  3044. scrollEvent = "touchmove scroll",
  3045. touchStartEvent = supportTouch ? "touchstart" : "mousedown",
  3046. touchStopEvent = supportTouch ? "touchend" : "mouseup",
  3047. touchMoveEvent = supportTouch ? "touchmove" : "mousemove";
  3048. // setup new event shortcuts
  3049. $.each( ( "touchstart touchmove touchend " +
  3050. "tap taphold " +
  3051. "swipe swipeleft swiperight " +
  3052. "scrollstart scrollstop" ).split( " " ), function( i, name ) {
  3053. $.fn[ name ] = function( fn ) {
  3054. return fn ? this.bind( name, fn ) : this.trigger( name );
  3055. };
  3056. // jQuery < 1.8
  3057. if ( $.attrFn ) {
  3058. $.attrFn[ name ] = true;
  3059. }
  3060. });
  3061. function triggerCustomEvent( obj, eventType, event ) {
  3062. var originalType = event.type;
  3063. event.type = eventType;
  3064. $.event.dispatch.call( obj, event );
  3065. event.type = originalType;
  3066. }
  3067. // also handles scrollstop
  3068. $.event.special.scrollstart = {
  3069. enabled: true,
  3070. setup: function() {
  3071. var thisObject = this,
  3072. $this = $( thisObject ),
  3073. scrolling,
  3074. timer;
  3075. function trigger( event, state ) {
  3076. scrolling = state;
  3077. triggerCustomEvent( thisObject, scrolling ? "scrollstart" : "scrollstop", event );
  3078. }
  3079. // iPhone triggers scroll after a small delay; use touchmove instead
  3080. $this.bind( scrollEvent, function( event ) {
  3081. if ( !$.event.special.scrollstart.enabled ) {
  3082. return;
  3083. }
  3084. if ( !scrolling ) {
  3085. trigger( event, true );
  3086. }
  3087. clearTimeout( timer );
  3088. timer = setTimeout( function() {
  3089. trigger( event, false );
  3090. }, 50 );
  3091. });
  3092. },
  3093. teardown: function() {
  3094. $( this ).unbind( scrollEvent );
  3095. }
  3096. };
  3097. // also handles taphold
  3098. $.event.special.tap = {
  3099. tapholdThreshold: 750,
  3100. emitTapOnTaphold: true,
  3101. setup: function() {
  3102. var thisObject = this,
  3103. $this = $( thisObject ),
  3104. isTaphold = false;
  3105. $this.bind( "vmousedown", function( event ) {
  3106. isTaphold = false;
  3107. if ( event.which && event.which !== 1 ) {
  3108. return false;
  3109. }
  3110. var origTarget = event.target,
  3111. timer;
  3112. function clearTapTimer() {
  3113. clearTimeout( timer );
  3114. }
  3115. function clearTapHandlers() {
  3116. clearTapTimer();
  3117. $this.unbind( "vclick", clickHandler )
  3118. .unbind( "vmouseup", clearTapTimer );
  3119. $document.unbind( "vmousecancel", clearTapHandlers );
  3120. }
  3121. function clickHandler( event ) {
  3122. clearTapHandlers();
  3123. // ONLY trigger a 'tap' event if the start target is
  3124. // the same as the stop target.
  3125. if ( !isTaphold && origTarget === event.target ) {
  3126. triggerCustomEvent( thisObject, "tap", event );
  3127. } else if ( isTaphold ) {
  3128. event.stopPropagation();
  3129. }
  3130. }
  3131. $this.bind( "vmouseup", clearTapTimer )
  3132. .bind( "vclick", clickHandler );
  3133. $document.bind( "vmousecancel", clearTapHandlers );
  3134. timer = setTimeout( function() {
  3135. if ( !$.event.special.tap.emitTapOnTaphold ) {
  3136. isTaphold = true;
  3137. }
  3138. triggerCustomEvent( thisObject, "taphold", $.Event( "taphold", { target: origTarget } ) );
  3139. }, $.event.special.tap.tapholdThreshold );
  3140. });
  3141. },
  3142. teardown: function() {
  3143. $( this ).unbind( "vmousedown" ).unbind( "vclick" ).unbind( "vmouseup" );
  3144. $document.unbind( "vmousecancel" );
  3145. }
  3146. };
  3147. // also handles swipeleft, swiperight
  3148. $.event.special.swipe = {
  3149. scrollSupressionThreshold: 30, // More than this horizontal displacement, and we will suppress scrolling.
  3150. durationThreshold: 1000, // More time than this, and it isn't a swipe.
  3151. horizontalDistanceThreshold: 30, // Swipe horizontal displacement must be more than this.
  3152. verticalDistanceThreshold: 75, // Swipe vertical displacement must be less than this.
  3153. start: function( event ) {
  3154. var data = event.originalEvent.touches ?
  3155. event.originalEvent.touches[ 0 ] : event;
  3156. return {
  3157. time: ( new Date() ).getTime(),
  3158. coords: [ data.pageX, data.pageY ],
  3159. origin: $( event.target )
  3160. };
  3161. },
  3162. stop: function( event ) {
  3163. var data = event.originalEvent.touches ?
  3164. event.originalEvent.touches[ 0 ] : event;
  3165. return {
  3166. time: ( new Date() ).getTime(),
  3167. coords: [ data.pageX, data.pageY ]
  3168. };
  3169. },
  3170. handleSwipe: function( start, stop, thisObject, origTarget ) {
  3171. if ( stop.time - start.time < $.event.special.swipe.durationThreshold &&
  3172. Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold &&
  3173. Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) {
  3174. var direction = start.coords[0] > stop.coords[ 0 ] ? "swipeleft" : "swiperight";
  3175. triggerCustomEvent( thisObject, "swipe", $.Event( "swipe", { target: origTarget, swipestart: start, swipestop: stop }) );
  3176. triggerCustomEvent( thisObject, direction,$.Event( direction, { target: origTarget, swipestart: start, swipestop: stop } ) );
  3177. return true;
  3178. }
  3179. return false;
  3180. },
  3181. setup: function() {
  3182. var thisObject = this,
  3183. $this = $( thisObject );
  3184. $this.bind( touchStartEvent, function( event ) {
  3185. var stop,
  3186. start = $.event.special.swipe.start( event ),
  3187. origTarget = event.target,
  3188. emitted = false;
  3189. function moveHandler( event ) {
  3190. if ( !start ) {
  3191. return;
  3192. }
  3193. stop = $.event.special.swipe.stop( event );
  3194. if ( !emitted ) {
  3195. emitted = $.event.special.swipe.handleSwipe( start, stop, thisObject, origTarget );
  3196. }
  3197. // prevent scrolling
  3198. if ( Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.scrollSupressionThreshold ) {
  3199. event.preventDefault();
  3200. }
  3201. }
  3202. $this.bind( touchMoveEvent, moveHandler )
  3203. .one( touchStopEvent, function() {
  3204. emitted = true;
  3205. $this.unbind( touchMoveEvent, moveHandler );
  3206. });
  3207. });
  3208. },
  3209. teardown: function() {
  3210. $( this ).unbind( touchStartEvent ).unbind( touchMoveEvent ).unbind( touchStopEvent );
  3211. }
  3212. };
  3213. $.each({
  3214. scrollstop: "scrollstart",
  3215. taphold: "tap",
  3216. swipeleft: "swipe",
  3217. swiperight: "swipe"
  3218. }, function( event, sourceEvent ) {
  3219. $.event.special[ event ] = {
  3220. setup: function() {
  3221. $( this ).bind( sourceEvent, $.noop );
  3222. },
  3223. teardown: function() {
  3224. $( this ).unbind( sourceEvent );
  3225. }
  3226. };
  3227. });
  3228. })( jQuery, this );
  3229. // throttled resize event
  3230. (function( $ ) {
  3231. $.event.special.throttledresize = {
  3232. setup: function() {
  3233. $( this ).bind( "resize", handler );
  3234. },
  3235. teardown: function() {
  3236. $( this ).unbind( "resize", handler );
  3237. }
  3238. };
  3239. var throttle = 250,
  3240. handler = function() {
  3241. curr = ( new Date() ).getTime();
  3242. diff = curr - lastCall;
  3243. if ( diff >= throttle ) {
  3244. lastCall = curr;
  3245. $( this ).trigger( "throttledresize" );
  3246. } else {
  3247. if ( heldCall ) {
  3248. clearTimeout( heldCall );
  3249. }
  3250. // Promise a held call will still execute
  3251. heldCall = setTimeout( handler, throttle - diff );
  3252. }
  3253. },
  3254. lastCall = 0,
  3255. heldCall,
  3256. curr,
  3257. diff;
  3258. })( jQuery );
  3259. (function( $, window ) {
  3260. var win = $( window ),
  3261. event_name = "orientationchange",
  3262. get_orientation,
  3263. last_orientation,
  3264. initial_orientation_is_landscape,
  3265. initial_orientation_is_default,
  3266. portrait_map = { "0": true, "180": true },
  3267. ww, wh, landscape_threshold;
  3268. // It seems that some device/browser vendors use window.orientation values 0 and 180 to
  3269. // denote the "default" orientation. For iOS devices, and most other smart-phones tested,
  3270. // the default orientation is always "portrait", but in some Android and RIM based tablets,
  3271. // the default orientation is "landscape". The following code attempts to use the window
  3272. // dimensions to figure out what the current orientation is, and then makes adjustments
  3273. // to the to the portrait_map if necessary, so that we can properly decode the
  3274. // window.orientation value whenever get_orientation() is called.
  3275. //
  3276. // Note that we used to use a media query to figure out what the orientation the browser
  3277. // thinks it is in:
  3278. //
  3279. // initial_orientation_is_landscape = $.mobile.media("all and (orientation: landscape)");
  3280. //
  3281. // but there was an iPhone/iPod Touch bug beginning with iOS 4.2, up through iOS 5.1,
  3282. // where the browser *ALWAYS* applied the landscape media query. This bug does not
  3283. // happen on iPad.
  3284. if ( $.support.orientation ) {
  3285. // Check the window width and height to figure out what the current orientation
  3286. // of the device is at this moment. Note that we've initialized the portrait map
  3287. // values to 0 and 180, *AND* we purposely check for landscape so that if we guess
  3288. // wrong, , we default to the assumption that portrait is the default orientation.
  3289. // We use a threshold check below because on some platforms like iOS, the iPhone
  3290. // form-factor can report a larger width than height if the user turns on the
  3291. // developer console. The actual threshold value is somewhat arbitrary, we just
  3292. // need to make sure it is large enough to exclude the developer console case.
  3293. ww = window.innerWidth || win.width();
  3294. wh = window.innerHeight || win.height();
  3295. landscape_threshold = 50;
  3296. initial_orientation_is_landscape = ww > wh && ( ww - wh ) > landscape_threshold;
  3297. // Now check to see if the current window.orientation is 0 or 180.
  3298. initial_orientation_is_default = portrait_map[ window.orientation ];
  3299. // If the initial orientation is landscape, but window.orientation reports 0 or 180, *OR*
  3300. // if the initial orientation is portrait, but window.orientation reports 90 or -90, we
  3301. // need to flip our portrait_map values because landscape is the default orientation for
  3302. // this device/browser.
  3303. if ( ( initial_orientation_is_landscape && initial_orientation_is_default ) || ( !initial_orientation_is_landscape && !initial_orientation_is_default ) ) {
  3304. portrait_map = { "-90": true, "90": true };
  3305. }
  3306. }
  3307. $.event.special.orientationchange = $.extend( {}, $.event.special.orientationchange, {
  3308. setup: function() {
  3309. // If the event is supported natively, return false so that jQuery
  3310. // will bind to the event using DOM methods.
  3311. if ( $.support.orientation && !$.event.special.orientationchange.disabled ) {
  3312. return false;
  3313. }
  3314. // Get the current orientation to avoid initial double-triggering.
  3315. last_orientation = get_orientation();
  3316. // Because the orientationchange event doesn't exist, simulate the
  3317. // event by testing window dimensions on resize.
  3318. win.bind( "throttledresize", handler );
  3319. },
  3320. teardown: function() {
  3321. // If the event is not supported natively, return false so that
  3322. // jQuery will unbind the event using DOM methods.
  3323. if ( $.support.orientation && !$.event.special.orientationchange.disabled ) {
  3324. return false;
  3325. }
  3326. // Because the orientationchange event doesn't exist, unbind the
  3327. // resize event handler.
  3328. win.unbind( "throttledresize", handler );
  3329. },
  3330. add: function( handleObj ) {
  3331. // Save a reference to the bound event handler.
  3332. var old_handler = handleObj.handler;
  3333. handleObj.handler = function( event ) {
  3334. // Modify event object, adding the .orientation property.
  3335. event.orientation = get_orientation();
  3336. // Call the originally-bound event handler and return its result.
  3337. return old_handler.apply( this, arguments );
  3338. };
  3339. }
  3340. });
  3341. // If the event is not supported natively, this handler will be bound to
  3342. // the window resize event to simulate the orientationchange event.
  3343. function handler() {
  3344. // Get the current orientation.
  3345. var orientation = get_orientation();
  3346. if ( orientation !== last_orientation ) {
  3347. // The orientation has changed, so trigger the orientationchange event.
  3348. last_orientation = orientation;
  3349. win.trigger( event_name );
  3350. }
  3351. }
  3352. // Get the current page orientation. This method is exposed publicly, should it
  3353. // be needed, as jQuery.event.special.orientationchange.orientation()
  3354. $.event.special.orientationchange.orientation = get_orientation = function() {
  3355. var isPortrait = true, elem = document.documentElement;
  3356. // prefer window orientation to the calculation based on screensize as
  3357. // the actual screen resize takes place before or after the orientation change event
  3358. // has been fired depending on implementation (eg android 2.3 is before, iphone after).
  3359. // More testing is required to determine if a more reliable method of determining the new screensize
  3360. // is possible when orientationchange is fired. (eg, use media queries + element + opacity)
  3361. if ( $.support.orientation ) {
  3362. // if the window orientation registers as 0 or 180 degrees report
  3363. // portrait, otherwise landscape
  3364. isPortrait = portrait_map[ window.orientation ];
  3365. } else {
  3366. isPortrait = elem && elem.clientWidth / elem.clientHeight < 1.1;
  3367. }
  3368. return isPortrait ? "portrait" : "landscape";
  3369. };
  3370. $.fn[ event_name ] = function( fn ) {
  3371. return fn ? this.bind( event_name, fn ) : this.trigger( event_name );
  3372. };
  3373. // jQuery < 1.8
  3374. if ( $.attrFn ) {
  3375. $.attrFn[ event_name ] = true;
  3376. }
  3377. }( jQuery, this ));
  3378. (function( $, undefined ) {
  3379. // existing base tag?
  3380. var baseElement = $( "head" ).children( "base" ),
  3381. // base element management, defined depending on dynamic base tag support
  3382. // TODO move to external widget
  3383. base = {
  3384. // define base element, for use in routing asset urls that are referenced
  3385. // in Ajax-requested markup
  3386. element: ( baseElement.length ? baseElement :
  3387. $( "<base>", { href: $.mobile.path.documentBase.hrefNoHash } ).prependTo( $( "head" ) ) ),
  3388. linkSelector: "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]",
  3389. // set the generated BASE element's href to a new page's base path
  3390. set: function( href ) {
  3391. // we should do nothing if the user wants to manage their url base
  3392. // manually
  3393. if ( !$.mobile.dynamicBaseEnabled ) {
  3394. return;
  3395. }
  3396. // we should use the base tag if we can manipulate it dynamically
  3397. if ( $.support.dynamicBaseTag ) {
  3398. base.element.attr( "href",
  3399. $.mobile.path.makeUrlAbsolute( href, $.mobile.path.documentBase ) );
  3400. }
  3401. },
  3402. rewrite: function( href, page ) {
  3403. var newPath = $.mobile.path.get( href );
  3404. page.find( base.linkSelector ).each(function( i, link ) {
  3405. var thisAttr = $( link ).is( "[href]" ) ? "href" :
  3406. $( link ).is( "[src]" ) ? "src" : "action",
  3407. thisUrl = $( link ).attr( thisAttr );
  3408. // XXX_jblas: We need to fix this so that it removes the document
  3409. // base URL, and then prepends with the new page URL.
  3410. // if full path exists and is same, chop it - helps IE out
  3411. thisUrl = thisUrl.replace( location.protocol + "//" +
  3412. location.host + location.pathname, "" );
  3413. if ( !/^(\w+:|#|\/)/.test( thisUrl ) ) {
  3414. $( link ).attr( thisAttr, newPath + thisUrl );
  3415. }
  3416. });
  3417. },
  3418. // set the generated BASE element's href to a new page's base path
  3419. reset: function(/* href */) {
  3420. base.element.attr( "href", $.mobile.path.documentBase.hrefNoSearch );
  3421. }
  3422. };
  3423. $.mobile.base = base;
  3424. })( jQuery );
  3425. (function( $, undefined ) {
  3426. $.mobile.widgets = {};
  3427. var originalWidget = $.widget,
  3428. // Record the original, non-mobileinit-modified version of $.mobile.keepNative
  3429. // so we can later determine whether someone has modified $.mobile.keepNative
  3430. keepNativeFactoryDefault = $.mobile.keepNative;
  3431. $.widget = (function( orig ) {
  3432. return function() {
  3433. var constructor = orig.apply( this, arguments ),
  3434. name = constructor.prototype.widgetName;
  3435. constructor.initSelector = ( ( constructor.prototype.initSelector !== undefined ) ?
  3436. constructor.prototype.initSelector : ":jqmData(role='" + name + "')" );
  3437. $.mobile.widgets[ name ] = constructor;
  3438. return constructor;
  3439. };
  3440. })( $.widget );
  3441. // Make sure $.widget still has bridge and extend methods
  3442. $.extend( $.widget, originalWidget );
  3443. // For backcompat remove in 1.5
  3444. $.mobile.document.on( "create", function( event ) {
  3445. $( event.target ).enhanceWithin();
  3446. });
  3447. $.widget( "mobile.page", {
  3448. options: {
  3449. theme: "a",
  3450. domCache: false,
  3451. // Deprecated in 1.4 remove in 1.5
  3452. keepNativeDefault: $.mobile.keepNative,
  3453. // Deprecated in 1.4 remove in 1.5
  3454. contentTheme: null,
  3455. enhanced: false
  3456. },
  3457. // DEPRECATED for > 1.4
  3458. // TODO remove at 1.5
  3459. _createWidget: function() {
  3460. $.Widget.prototype._createWidget.apply( this, arguments );
  3461. this._trigger( "init" );
  3462. },
  3463. _create: function() {
  3464. // If false is returned by the callbacks do not create the page
  3465. if ( this._trigger( "beforecreate" ) === false ) {
  3466. return false;
  3467. }
  3468. if ( !this.options.enhanced ) {
  3469. this._enhance();
  3470. }
  3471. this._on( this.element, {
  3472. pagebeforehide: "removeContainerBackground",
  3473. pagebeforeshow: "_handlePageBeforeShow"
  3474. });
  3475. this.element.enhanceWithin();
  3476. // Dialog widget is deprecated in 1.4 remove this in 1.5
  3477. if ( $.mobile.getAttribute( this.element[0], "role" ) === "dialog" && $.mobile.dialog ) {
  3478. this.element.dialog();
  3479. }
  3480. },
  3481. _enhance: function () {
  3482. var attrPrefix = "data-" + $.mobile.ns,
  3483. self = this;
  3484. if ( this.options.role ) {
  3485. this.element.attr( "data-" + $.mobile.ns + "role", this.options.role );
  3486. }
  3487. this.element
  3488. .attr( "tabindex", "0" )
  3489. .addClass( "ui-page ui-page-theme-" + this.options.theme );
  3490. // Manipulation of content os Deprecated as of 1.4 remove in 1.5
  3491. this.element.find( "[" + attrPrefix + "role='content']" ).each( function() {
  3492. var $this = $( this ),
  3493. theme = this.getAttribute( attrPrefix + "theme" ) || undefined;
  3494. self.options.contentTheme = theme || self.options.contentTheme || ( self.options.dialog && self.options.theme ) || ( self.element.jqmData("role") === "dialog" && self.options.theme );
  3495. $this.addClass( "ui-content" );
  3496. if ( self.options.contentTheme ) {
  3497. $this.addClass( "ui-body-" + ( self.options.contentTheme ) );
  3498. }
  3499. // Add ARIA role
  3500. $this.attr( "role", "main" ).addClass( "ui-content" );
  3501. });
  3502. },
  3503. bindRemove: function( callback ) {
  3504. var page = this.element;
  3505. // when dom caching is not enabled or the page is embedded bind to remove the page on hide
  3506. if ( !page.data( "mobile-page" ).options.domCache &&
  3507. page.is( ":jqmData(external-page='true')" ) ) {
  3508. // TODO use _on - that is, sort out why it doesn't work in this case
  3509. page.bind( "pagehide.remove", callback || function( e, data ) {
  3510. //check if this is a same page transition and if so don't remove the page
  3511. if( !data.samePage ){
  3512. var $this = $( this ),
  3513. prEvent = new $.Event( "pageremove" );
  3514. $this.trigger( prEvent );
  3515. if ( !prEvent.isDefaultPrevented() ) {
  3516. $this.removeWithDependents();
  3517. }
  3518. }
  3519. });
  3520. }
  3521. },
  3522. _setOptions: function( o ) {
  3523. if ( o.theme !== undefined ) {
  3524. this.element.removeClass( "ui-body-" + this.options.theme ).addClass( "ui-body-" + o.theme );
  3525. }
  3526. if ( o.contentTheme !== undefined ) {
  3527. this.element.find( "[data-" + $.mobile.ns + "='content']" ).removeClass( "ui-body-" + this.options.contentTheme )
  3528. .addClass( "ui-body-" + o.contentTheme );
  3529. }
  3530. },
  3531. _handlePageBeforeShow: function(/* e */) {
  3532. this.setContainerBackground();
  3533. },
  3534. // Deprecated in 1.4 remove in 1.5
  3535. removeContainerBackground: function() {
  3536. this.element.closest( ":mobile-pagecontainer" ).pagecontainer({ "theme": "none" });
  3537. },
  3538. // Deprecated in 1.4 remove in 1.5
  3539. // set the page container background to the page theme
  3540. setContainerBackground: function( theme ) {
  3541. this.element.parent().pagecontainer( { "theme": theme || this.options.theme } );
  3542. },
  3543. // Deprecated in 1.4 remove in 1.5
  3544. keepNativeSelector: function() {
  3545. var options = this.options,
  3546. keepNative = $.trim( options.keepNative || "" ),
  3547. globalValue = $.trim( $.mobile.keepNative ),
  3548. optionValue = $.trim( options.keepNativeDefault ),
  3549. // Check if $.mobile.keepNative has changed from the factory default
  3550. newDefault = ( keepNativeFactoryDefault === globalValue ?
  3551. "" : globalValue ),
  3552. // If $.mobile.keepNative has not changed, use options.keepNativeDefault
  3553. oldDefault = ( newDefault === "" ? optionValue : "" );
  3554. // Concatenate keepNative selectors from all sources where the value has
  3555. // changed or, if nothing has changed, return the default
  3556. return ( ( keepNative ? [ keepNative ] : [] )
  3557. .concat( newDefault ? [ newDefault ] : [] )
  3558. .concat( oldDefault ? [ oldDefault ] : [] )
  3559. .join( ", " ) );
  3560. }
  3561. });
  3562. })( jQuery );
  3563. (function( $, undefined ) {
  3564. $.widget( "mobile.pagecontainer", {
  3565. options: {
  3566. theme: "a"
  3567. },
  3568. initSelector: false,
  3569. _create: function() {
  3570. this.setLastScrollEnabled = true;
  3571. // TODO consider moving the navigation handler OUT of widget into
  3572. // some other object as glue between the navigate event and the
  3573. // content widget load and change methods
  3574. this._on( this.window, { navigate: "_filterNavigateEvents" });
  3575. this._on( this.window, {
  3576. // disable an scroll setting when a hashchange has been fired,
  3577. // this only works because the recording of the scroll position
  3578. // is delayed for 100ms after the browser might have changed the
  3579. // position because of the hashchange
  3580. navigate: "_disableRecordScroll",
  3581. // bind to scrollstop for the first page, "pagechange" won't be
  3582. // fired in that case
  3583. scrollstop: "_delayedRecordScroll"
  3584. });
  3585. // TODO move from page* events to content* events
  3586. this._on({ pagechange: "_afterContentChange" });
  3587. // handle initial hashchange from chrome :(
  3588. this.window.one( "navigate", $.proxy(function() {
  3589. this.setLastScrollEnabled = true;
  3590. }, this));
  3591. },
  3592. _setOptions: function( options ) {
  3593. if ( options.theme !== undefined && options.theme !== "none" ) {
  3594. this.element.removeClass( "ui-overlay-" + this.options.theme )
  3595. .addClass( "ui-overlay-" + options.theme );
  3596. } else if ( options.theme !== undefined ) {
  3597. this.element.removeClass( "ui-overlay-" + this.options.theme );
  3598. }
  3599. this._super( options );
  3600. },
  3601. _disableRecordScroll: function() {
  3602. this.setLastScrollEnabled = false;
  3603. },
  3604. _enableRecordScroll: function() {
  3605. this.setLastScrollEnabled = true;
  3606. },
  3607. // TODO consider the name here, since it's purpose specific
  3608. _afterContentChange: function() {
  3609. // once the page has changed, re-enable the scroll recording
  3610. this.setLastScrollEnabled = true;
  3611. // remove any binding that previously existed on the get scroll
  3612. // which may or may not be different than the scroll element
  3613. // determined for this page previously
  3614. this._off( this.window, "scrollstop" );
  3615. // determine and bind to the current scoll element which may be the
  3616. // window or in the case of touch overflow the element touch overflow
  3617. this._on( this.window, { scrollstop: "_delayedRecordScroll" });
  3618. },
  3619. _recordScroll: function() {
  3620. // this barrier prevents setting the scroll value based on
  3621. // the browser scrolling the window based on a hashchange
  3622. if ( !this.setLastScrollEnabled ) {
  3623. return;
  3624. }
  3625. var active = this._getActiveHistory(),
  3626. currentScroll, minScroll, defaultScroll;
  3627. if ( active ) {
  3628. currentScroll = this._getScroll();
  3629. minScroll = this._getMinScroll();
  3630. defaultScroll = this._getDefaultScroll();
  3631. // Set active page's lastScroll prop. If the location we're
  3632. // scrolling to is less than minScrollBack, let it go.
  3633. active.lastScroll = currentScroll < minScroll ? defaultScroll : currentScroll;
  3634. }
  3635. },
  3636. _delayedRecordScroll: function() {
  3637. setTimeout( $.proxy(this, "_recordScroll"), 100 );
  3638. },
  3639. _getScroll: function() {
  3640. return this.window.scrollTop();
  3641. },
  3642. _getMinScroll: function() {
  3643. return $.mobile.minScrollBack;
  3644. },
  3645. _getDefaultScroll: function() {
  3646. return $.mobile.defaultHomeScroll;
  3647. },
  3648. _filterNavigateEvents: function( e, data ) {
  3649. var url;
  3650. if ( e.originalEvent && e.originalEvent.isDefaultPrevented() ) {
  3651. return;
  3652. }
  3653. url = e.originalEvent.type.indexOf( "hashchange" ) > -1 ? data.state.hash : data.state.url;
  3654. if ( !url ) {
  3655. url = this._getHash();
  3656. }
  3657. if ( !url || url === "#" || url.indexOf( "#" + $.mobile.path.uiStateKey ) === 0 ) {
  3658. url = location.href;
  3659. }
  3660. this._handleNavigate( url, data.state );
  3661. },
  3662. _getHash: function() {
  3663. return $.mobile.path.parseLocation().hash;
  3664. },
  3665. // TODO active page should be managed by the container (ie, it should be a property)
  3666. getActivePage: function() {
  3667. return this.activePage;
  3668. },
  3669. // TODO the first page should be a property set during _create using the logic
  3670. // that currently resides in init
  3671. _getInitialContent: function() {
  3672. return $.mobile.firstPage;
  3673. },
  3674. // TODO each content container should have a history object
  3675. _getHistory: function() {
  3676. return $.mobile.navigate.history;
  3677. },
  3678. // TODO use _getHistory
  3679. _getActiveHistory: function() {
  3680. return $.mobile.navigate.history.getActive();
  3681. },
  3682. // TODO the document base should be determined at creation
  3683. _getDocumentBase: function() {
  3684. return $.mobile.path.documentBase;
  3685. },
  3686. back: function() {
  3687. this.go( -1 );
  3688. },
  3689. forward: function() {
  3690. this.go( 1 );
  3691. },
  3692. go: function( steps ) {
  3693. //if hashlistening is enabled use native history method
  3694. if ( $.mobile.hashListeningEnabled ) {
  3695. window.history.go( steps );
  3696. } else {
  3697. //we are not listening to the hash so handle history internally
  3698. var activeIndex = $.mobile.navigate.history.activeIndex,
  3699. index = activeIndex + parseInt( steps, 10 ),
  3700. url = $.mobile.navigate.history.stack[ index ].url,
  3701. direction = ( steps >= 1 )? "forward" : "back";
  3702. //update the history object
  3703. $.mobile.navigate.history.activeIndex = index;
  3704. $.mobile.navigate.history.previousIndex = activeIndex;
  3705. //change to the new page
  3706. this.change( url, { direction: direction, changeHash: false, fromHashChange: true } );
  3707. }
  3708. },
  3709. // TODO rename _handleDestination
  3710. _handleDestination: function( to ) {
  3711. var history;
  3712. // clean the hash for comparison if it's a url
  3713. if ( $.type(to) === "string" ) {
  3714. to = $.mobile.path.stripHash( to );
  3715. }
  3716. if ( to ) {
  3717. history = this._getHistory();
  3718. // At this point, 'to' can be one of 3 things, a cached page
  3719. // element from a history stack entry, an id, or site-relative /
  3720. // absolute URL. If 'to' is an id, we need to resolve it against
  3721. // the documentBase, not the location.href, since the hashchange
  3722. // could've been the result of a forward/backward navigation
  3723. // that crosses from an external page/dialog to an internal
  3724. // page/dialog.
  3725. //
  3726. // TODO move check to history object or path object?
  3727. to = !$.mobile.path.isPath( to ) ? ( $.mobile.path.makeUrlAbsolute( "#" + to, this._getDocumentBase() ) ) : to;
  3728. // If we're about to go to an initial URL that contains a
  3729. // reference to a non-existent internal page, go to the first
  3730. // page instead. We know that the initial hash refers to a
  3731. // non-existent page, because the initial hash did not end
  3732. // up in the initial history entry
  3733. // TODO move check to history object?
  3734. if ( to === $.mobile.path.makeUrlAbsolute( "#" + history.initialDst, this._getDocumentBase() ) &&
  3735. history.stack.length &&
  3736. history.stack[0].url !== history.initialDst.replace( $.mobile.dialogHashKey, "" ) ) {
  3737. to = this._getInitialContent();
  3738. }
  3739. }
  3740. return to || this._getInitialContent();
  3741. },
  3742. _handleDialog: function( changePageOptions, data ) {
  3743. var to, active, activeContent = this.getActivePage();
  3744. // If current active page is not a dialog skip the dialog and continue
  3745. // in the same direction
  3746. if ( activeContent && !activeContent.hasClass( "ui-dialog" ) ) {
  3747. // determine if we're heading forward or backward and continue
  3748. // accordingly past the current dialog
  3749. if ( data.direction === "back" ) {
  3750. this.back();
  3751. } else {
  3752. this.forward();
  3753. }
  3754. // prevent changePage call
  3755. return false;
  3756. } else {
  3757. // if the current active page is a dialog and we're navigating
  3758. // to a dialog use the dialog objected saved in the stack
  3759. to = data.pageUrl;
  3760. active = this._getActiveHistory();
  3761. // make sure to set the role, transition and reversal
  3762. // as most of this is lost by the domCache cleaning
  3763. $.extend( changePageOptions, {
  3764. role: active.role,
  3765. transition: active.transition,
  3766. reverse: data.direction === "back"
  3767. });
  3768. }
  3769. return to;
  3770. },
  3771. _handleNavigate: function( url, data ) {
  3772. //find first page via hash
  3773. // TODO stripping the hash twice with handleUrl
  3774. var to = $.mobile.path.stripHash( url ), history = this._getHistory(),
  3775. // transition is false if it's the first page, undefined
  3776. // otherwise (and may be overridden by default)
  3777. transition = history.stack.length === 0 ? "none" : undefined,
  3778. // default options for the changPage calls made after examining
  3779. // the current state of the page and the hash, NOTE that the
  3780. // transition is derived from the previous history entry
  3781. changePageOptions = {
  3782. changeHash: false,
  3783. fromHashChange: true,
  3784. reverse: data.direction === "back"
  3785. };
  3786. $.extend( changePageOptions, data, {
  3787. transition: ( history.getLast() || {} ).transition || transition
  3788. });
  3789. // TODO move to _handleDestination ?
  3790. // If this isn't the first page, if the current url is a dialog hash
  3791. // key, and the initial destination isn't equal to the current target
  3792. // page, use the special dialog handling
  3793. if ( history.activeIndex > 0 &&
  3794. to.indexOf( $.mobile.dialogHashKey ) > -1 &&
  3795. history.initialDst !== to ) {
  3796. to = this._handleDialog( changePageOptions, data );
  3797. if ( to === false ) {
  3798. return;
  3799. }
  3800. }
  3801. this._changeContent( this._handleDestination( to ), changePageOptions );
  3802. },
  3803. _changeContent: function( to, opts ) {
  3804. $.mobile.changePage( to, opts );
  3805. },
  3806. _getBase: function() {
  3807. return $.mobile.base;
  3808. },
  3809. _getNs: function() {
  3810. return $.mobile.ns;
  3811. },
  3812. _enhance: function( content, role ) {
  3813. // TODO consider supporting a custom callback, and passing in
  3814. // the settings which includes the role
  3815. return content.page({ role: role });
  3816. },
  3817. _include: function( page, settings ) {
  3818. // append to page and enhance
  3819. page.appendTo( this.element );
  3820. // use the page widget to enhance
  3821. this._enhance( page, settings.role );
  3822. // remove page on hide
  3823. page.page( "bindRemove" );
  3824. },
  3825. _find: function( absUrl ) {
  3826. // TODO consider supporting a custom callback
  3827. var fileUrl = this._createFileUrl( absUrl ),
  3828. dataUrl = this._createDataUrl( absUrl ),
  3829. page, initialContent = this._getInitialContent();
  3830. // Check to see if the page already exists in the DOM.
  3831. // NOTE do _not_ use the :jqmData pseudo selector because parenthesis
  3832. // are a valid url char and it breaks on the first occurence
  3833. page = this.element
  3834. .children( "[data-" + this._getNs() +"url='" + dataUrl + "']" );
  3835. // If we failed to find the page, check to see if the url is a
  3836. // reference to an embedded page. If so, it may have been dynamically
  3837. // injected by a developer, in which case it would be lacking a
  3838. // data-url attribute and in need of enhancement.
  3839. if ( page.length === 0 && dataUrl && !$.mobile.path.isPath( dataUrl ) ) {
  3840. page = this.element.children( $.mobile.path.hashToSelector("#" + dataUrl) )
  3841. .attr( "data-" + this._getNs() + "url", dataUrl )
  3842. .jqmData( "url", dataUrl );
  3843. }
  3844. // If we failed to find a page in the DOM, check the URL to see if it
  3845. // refers to the first page in the application. Also check to make sure
  3846. // our cached-first-page is actually in the DOM. Some user deployed
  3847. // apps are pruning the first page from the DOM for various reasons.
  3848. // We check for this case here because we don't want a first-page with
  3849. // an id falling through to the non-existent embedded page error case.
  3850. if ( page.length === 0 &&
  3851. $.mobile.path.isFirstPageUrl( fileUrl ) &&
  3852. initialContent &&
  3853. initialContent.parent().length ) {
  3854. page = $( initialContent );
  3855. }
  3856. return page;
  3857. },
  3858. _getLoader: function() {
  3859. return $.mobile.loading();
  3860. },
  3861. _showLoading: function( delay, theme, msg, textonly ) {
  3862. // This configurable timeout allows cached pages a brief
  3863. // delay to load without showing a message
  3864. if ( this._loadMsg ) {
  3865. return;
  3866. }
  3867. this._loadMsg = setTimeout($.proxy(function() {
  3868. this._getLoader().loader( "show", theme, msg, textonly );
  3869. this._loadMsg = 0;
  3870. }, this), delay );
  3871. },
  3872. _hideLoading: function() {
  3873. // Stop message show timer
  3874. clearTimeout( this._loadMsg );
  3875. this._loadMsg = 0;
  3876. // Hide loading message
  3877. this._getLoader().loader( "hide" );
  3878. },
  3879. _showError: function() {
  3880. // make sure to remove the current loading message
  3881. this._hideLoading();
  3882. // show the error message
  3883. this._showLoading( 0, $.mobile.pageLoadErrorMessageTheme, $.mobile.pageLoadErrorMessage, true );
  3884. // hide the error message after a delay
  3885. // TODO configuration
  3886. setTimeout( $.proxy(this, "_hideLoading"), 1500 );
  3887. },
  3888. _parse: function( html, fileUrl ) {
  3889. // TODO consider allowing customization of this method. It's very JQM specific
  3890. var page, all = $( "<div></div>" );
  3891. //workaround to allow scripts to execute when included in page divs
  3892. all.get( 0 ).innerHTML = html;
  3893. page = all.find( ":jqmData(role='page'), :jqmData(role='dialog')" ).first();
  3894. //if page elem couldn't be found, create one and insert the body element's contents
  3895. if ( !page.length ) {
  3896. page = $( "<div data-" + this._getNs() + "role='page'>" +
  3897. ( html.split( /<\/?body[^>]*>/gmi )[1] || "" ) +
  3898. "</div>" );
  3899. }
  3900. // TODO tagging a page with external to make sure that embedded pages aren't
  3901. // removed by the various page handling code is bad. Having page handling code
  3902. // in many places is bad. Solutions post 1.0
  3903. page.attr( "data-" + this._getNs() + "url", $.mobile.path.convertUrlToDataUrl(fileUrl) )
  3904. .attr( "data-" + this._getNs() + "external-page", true );
  3905. return page;
  3906. },
  3907. _setLoadedTitle: function( page, html ) {
  3908. //page title regexp
  3909. var newPageTitle = html.match( /<title[^>]*>([^<]*)/ ) && RegExp.$1;
  3910. if ( newPageTitle && !page.jqmData("title") ) {
  3911. newPageTitle = $( "<div>" + newPageTitle + "</div>" ).text();
  3912. page.jqmData( "title", newPageTitle );
  3913. }
  3914. },
  3915. _isRewritableBaseTag: function() {
  3916. return $.mobile.dynamicBaseEnabled && !$.support.dynamicBaseTag;
  3917. },
  3918. _createDataUrl: function( absoluteUrl ) {
  3919. return $.mobile.path.convertUrlToDataUrl( absoluteUrl );
  3920. },
  3921. _createFileUrl: function( absoluteUrl ) {
  3922. return $.mobile.path.getFilePath( absoluteUrl );
  3923. },
  3924. _triggerWithDeprecated: function( name, data, page ) {
  3925. var deprecatedEvent = $.Event( "page" + name ),
  3926. newEvent = $.Event( this.widgetName + name );
  3927. // DEPRECATED
  3928. // trigger the old deprecated event on the page if it's provided
  3929. ( page || this.element ).trigger( deprecatedEvent, data );
  3930. // use the widget trigger method for the new content* event
  3931. this.element.trigger( newEvent, data );
  3932. return {
  3933. deprecatedEvent: deprecatedEvent,
  3934. event: newEvent
  3935. };
  3936. },
  3937. // TODO it would be nice to split this up more but everything appears to be "one off"
  3938. // or require ordering such that other bits are sprinkled in between parts that
  3939. // could be abstracted out as a group
  3940. _loadSuccess: function( absUrl, triggerData, settings, deferred ) {
  3941. var fileUrl = this._createFileUrl( absUrl ),
  3942. dataUrl = this._createDataUrl( absUrl );
  3943. return $.proxy(function( html, textStatus, xhr ) {
  3944. //pre-parse html to check for a data-url,
  3945. //use it as the new fileUrl, base path, etc
  3946. var content,
  3947. // TODO handle dialogs again
  3948. pageElemRegex = new RegExp( "(<[^>]+\\bdata-" + this._getNs() + "role=[\"']?page[\"']?[^>]*>)" ),
  3949. dataUrlRegex = new RegExp( "\\bdata-" + this._getNs() + "url=[\"']?([^\"'>]*)[\"']?" );
  3950. // data-url must be provided for the base tag so resource requests
  3951. // can be directed to the correct url. loading into a temprorary
  3952. // element makes these requests immediately
  3953. if ( pageElemRegex.test( html ) &&
  3954. RegExp.$1 &&
  3955. dataUrlRegex.test( RegExp.$1 ) &&
  3956. RegExp.$1 ) {
  3957. fileUrl = $.mobile.path.getFilePath( $("<div>" + RegExp.$1 + "</div>").text() );
  3958. }
  3959. //dont update the base tag if we are prefetching
  3960. if ( settings.prefetch === undefined ) {
  3961. this._getBase().set( fileUrl );
  3962. }
  3963. content = this._parse( html, fileUrl );
  3964. this._setLoadedTitle( content, html );
  3965. // Add the content reference and xhr to our triggerData.
  3966. triggerData.xhr = xhr;
  3967. triggerData.textStatus = textStatus;
  3968. // DEPRECATED
  3969. triggerData.page = content;
  3970. triggerData.content = content;
  3971. // If the default behavior is prevented, stop here!
  3972. // Note that it is the responsibility of the listener/handler
  3973. // that called preventDefault(), to resolve/reject the
  3974. // deferred object within the triggerData.
  3975. if ( !this._trigger( "load", undefined, triggerData ) ) {
  3976. return;
  3977. }
  3978. // rewrite src and href attrs to use a base url if the base tag won't work
  3979. if ( this._isRewritableBaseTag() && content ) {
  3980. this._getBase().rewrite( fileUrl, content );
  3981. }
  3982. this._include( content, settings );
  3983. // Enhancing the content may result in new dialogs/sub content being inserted
  3984. // into the DOM. If the original absUrl refers to a sub-content, that is the
  3985. // real content we are interested in.
  3986. if ( absUrl.indexOf( "&" + $.mobile.subPageUrlKey ) > -1 ) {
  3987. content = this.element.children( "[data-" + this._getNs() +"url='" + dataUrl + "']" );
  3988. }
  3989. // Remove loading message.
  3990. if ( settings.showLoadMsg ) {
  3991. this._hideLoading();
  3992. }
  3993. // BEGIN DEPRECATED ---------------------------------------------------
  3994. // Let listeners know the content loaded successfully.
  3995. this.element.trigger( "pageload" );
  3996. // END DEPRECATED -----------------------------------------------------
  3997. deferred.resolve( absUrl, settings, content );
  3998. }, this);
  3999. },
  4000. _loadDefaults: {
  4001. type: "get",
  4002. data: undefined,
  4003. // DEPRECATED
  4004. reloadPage: false,
  4005. reload: false,
  4006. // By default we rely on the role defined by the @data-role attribute.
  4007. role: undefined,
  4008. showLoadMsg: false,
  4009. // This delay allows loads that pull from browser cache to
  4010. // occur without showing the loading message.
  4011. loadMsgDelay: 50
  4012. },
  4013. load: function( url, options ) {
  4014. // This function uses deferred notifications to let callers
  4015. // know when the content is done loading, or if an error has occurred.
  4016. var deferred = ( options && options.deferred ) || $.Deferred(),
  4017. // The default load options with overrides specified by the caller.
  4018. settings = $.extend( {}, this._loadDefaults, options ),
  4019. // The DOM element for the content after it has been loaded.
  4020. content = null,
  4021. // The absolute version of the URL passed into the function. This
  4022. // version of the URL may contain dialog/subcontent params in it.
  4023. absUrl = $.mobile.path.makeUrlAbsolute( url, this._findBaseWithDefault() ),
  4024. fileUrl, dataUrl, pblEvent, triggerData;
  4025. // DEPRECATED reloadPage
  4026. settings.reload = settings.reloadPage;
  4027. // If the caller provided data, and we're using "get" request,
  4028. // append the data to the URL.
  4029. if ( settings.data && settings.type === "get" ) {
  4030. absUrl = $.mobile.path.addSearchParams( absUrl, settings.data );
  4031. settings.data = undefined;
  4032. }
  4033. // If the caller is using a "post" request, reload must be true
  4034. if ( settings.data && settings.type === "post" ) {
  4035. settings.reload = true;
  4036. }
  4037. // The absolute version of the URL minus any dialog/subcontent params.
  4038. // In otherwords the real URL of the content to be loaded.
  4039. fileUrl = this._createFileUrl( absUrl );
  4040. // The version of the Url actually stored in the data-url attribute of
  4041. // the content. For embedded content, it is just the id of the page. For
  4042. // content within the same domain as the document base, it is the site
  4043. // relative path. For cross-domain content (Phone Gap only) the entire
  4044. // absolute Url is used to load the content.
  4045. dataUrl = this._createDataUrl( absUrl );
  4046. content = this._find( absUrl );
  4047. // If it isn't a reference to the first content and refers to missing
  4048. // embedded content reject the deferred and return
  4049. if ( content.length === 0 &&
  4050. $.mobile.path.isEmbeddedPage(fileUrl) &&
  4051. !$.mobile.path.isFirstPageUrl(fileUrl) ) {
  4052. deferred.reject( absUrl, settings );
  4053. return;
  4054. }
  4055. // Reset base to the default document base
  4056. // TODO figure out why we doe this
  4057. this._getBase().reset();
  4058. // If the content we are interested in is already in the DOM,
  4059. // and the caller did not indicate that we should force a
  4060. // reload of the file, we are done. Resolve the deferrred so that
  4061. // users can bind to .done on the promise
  4062. if ( content.length && !settings.reload ) {
  4063. this._enhance( content, settings.role );
  4064. deferred.resolve( absUrl, settings, content );
  4065. //if we are reloading the content make sure we update
  4066. // the base if its not a prefetch
  4067. if ( !settings.prefetch ) {
  4068. this._getBase().set(url);
  4069. }
  4070. return;
  4071. }
  4072. triggerData = {
  4073. url: url,
  4074. absUrl: absUrl,
  4075. dataUrl: dataUrl,
  4076. deferred: deferred,
  4077. options: settings
  4078. };
  4079. // Let listeners know we're about to load content.
  4080. pblEvent = this._triggerWithDeprecated( "beforeload", triggerData );
  4081. // If the default behavior is prevented, stop here!
  4082. if ( pblEvent.deprecatedEvent.isDefaultPrevented() ||
  4083. pblEvent.event.isDefaultPrevented() ) {
  4084. return;
  4085. }
  4086. if ( settings.showLoadMsg ) {
  4087. this._showLoading( settings.loadMsgDelay );
  4088. }
  4089. // Reset base to the default document base.
  4090. // only reset if we are not prefetching
  4091. if ( settings.prefetch === undefined ) {
  4092. this._getBase().reset();
  4093. }
  4094. if ( !( $.mobile.allowCrossDomainPages ||
  4095. $.mobile.path.isSameDomain($.mobile.path.documentUrl, absUrl ) ) ) {
  4096. deferred.reject( absUrl, settings );
  4097. return;
  4098. }
  4099. // Load the new content.
  4100. $.ajax({
  4101. url: fileUrl,
  4102. type: settings.type,
  4103. data: settings.data,
  4104. contentType: settings.contentType,
  4105. dataType: "html",
  4106. success: this._loadSuccess( absUrl, triggerData, settings, deferred ),
  4107. error: this._loadError( absUrl, triggerData, settings, deferred )
  4108. });
  4109. },
  4110. _loadError: function( absUrl, triggerData, settings, deferred ) {
  4111. return $.proxy(function( xhr, textStatus, errorThrown ) {
  4112. //set base back to current path
  4113. this._getBase().set( $.mobile.path.get() );
  4114. // Add error info to our triggerData.
  4115. triggerData.xhr = xhr;
  4116. triggerData.textStatus = textStatus;
  4117. triggerData.errorThrown = errorThrown;
  4118. // Let listeners know the page load failed.
  4119. var plfEvent = this._triggerWithDeprecated( "loadfailed", triggerData );
  4120. // If the default behavior is prevented, stop here!
  4121. // Note that it is the responsibility of the listener/handler
  4122. // that called preventDefault(), to resolve/reject the
  4123. // deferred object within the triggerData.
  4124. if ( plfEvent.deprecatedEvent.isDefaultPrevented() ||
  4125. plfEvent.event.isDefaultPrevented() ) {
  4126. return;
  4127. }
  4128. // Remove loading message.
  4129. if ( settings.showLoadMsg ) {
  4130. this._showError();
  4131. }
  4132. deferred.reject( absUrl, settings );
  4133. }, this);
  4134. },
  4135. _getTransitionHandler: function( transition ) {
  4136. transition = $.mobile._maybeDegradeTransition( transition );
  4137. //find the transition handler for the specified transition. If there
  4138. //isn't one in our transitionHandlers dictionary, use the default one.
  4139. //call the handler immediately to kick-off the transition.
  4140. return $.mobile.transitionHandlers[ transition ] || $.mobile.defaultTransitionHandler;
  4141. },
  4142. // TODO move into transition handlers?
  4143. _triggerCssTransitionEvents: function( to, from, prefix ) {
  4144. var samePage = false;
  4145. prefix = prefix || "";
  4146. // TODO decide if these events should in fact be triggered on the container
  4147. if ( from ) {
  4148. //Check if this is a same page transition and tell the handler in page
  4149. if( to[0] === from[0] ){
  4150. samePage = true;
  4151. }
  4152. //trigger before show/hide events
  4153. // TODO deprecate nextPage in favor of next
  4154. this._triggerWithDeprecated( prefix + "hide", { nextPage: to, samePage: samePage }, from );
  4155. }
  4156. // TODO deprecate prevPage in favor of previous
  4157. this._triggerWithDeprecated( prefix + "show", { prevPage: from || $( "" ) }, to );
  4158. },
  4159. // TODO make private once change has been defined in the widget
  4160. _cssTransition: function( to, from, options ) {
  4161. var transition = options.transition,
  4162. reverse = options.reverse,
  4163. deferred = options.deferred,
  4164. TransitionHandler,
  4165. promise;
  4166. this._triggerCssTransitionEvents( to, from, "before" );
  4167. // TODO put this in a binding to events *outside* the widget
  4168. this._hideLoading();
  4169. TransitionHandler = this._getTransitionHandler( transition );
  4170. promise = ( new TransitionHandler( transition, reverse, to, from ) ).transition();
  4171. // TODO temporary accomodation of argument deferred
  4172. promise.done(function() {
  4173. deferred.resolve.apply( deferred, arguments );
  4174. });
  4175. promise.done($.proxy(function() {
  4176. this._triggerCssTransitionEvents( to, from );
  4177. }, this));
  4178. },
  4179. _releaseTransitionLock: function() {
  4180. //release transition lock so navigation is free again
  4181. isPageTransitioning = false;
  4182. if ( pageTransitionQueue.length > 0 ) {
  4183. $.mobile.changePage.apply( null, pageTransitionQueue.pop() );
  4184. }
  4185. },
  4186. _removeActiveLinkClass: function( force ) {
  4187. //clear out the active button state
  4188. $.mobile.removeActiveLinkClass( force );
  4189. },
  4190. _loadUrl: function( to, triggerData, settings ) {
  4191. // preserve the original target as the dataUrl value will be
  4192. // simplified eg, removing ui-state, and removing query params
  4193. // from the hash this is so that users who want to use query
  4194. // params have access to them in the event bindings for the page
  4195. // life cycle See issue #5085
  4196. settings.target = to;
  4197. settings.deferred = $.Deferred();
  4198. this.load( to, settings );
  4199. settings.deferred.done($.proxy(function( url, options, content ) {
  4200. isPageTransitioning = false;
  4201. // store the original absolute url so that it can be provided
  4202. // to events in the triggerData of the subsequent changePage call
  4203. options.absUrl = triggerData.absUrl;
  4204. this.transition( content, triggerData, options );
  4205. }, this));
  4206. settings.deferred.fail($.proxy(function(/* url, options */) {
  4207. this._removeActiveLinkClass( true );
  4208. this._releaseTransitionLock();
  4209. this._triggerWithDeprecated( "changefailed", triggerData );
  4210. }, this));
  4211. },
  4212. _triggerPageBeforeChange: function( to, triggerData, settings ) {
  4213. var pbcEvent = new $.Event( "pagebeforechange" );
  4214. $.extend(triggerData, { toPage: to, options: settings });
  4215. // NOTE: preserve the original target as the dataUrl value will be
  4216. // simplified eg, removing ui-state, and removing query params from
  4217. // the hash this is so that users who want to use query params have
  4218. // access to them in the event bindings for the page life cycle
  4219. // See issue #5085
  4220. if ( $.type(to) === "string" ) {
  4221. // if the toPage is a string simply convert it
  4222. triggerData.absUrl = $.mobile.path.makeUrlAbsolute( to, this._findBaseWithDefault() );
  4223. } else {
  4224. // if the toPage is a jQuery object grab the absolute url stored
  4225. // in the loadPage callback where it exists
  4226. triggerData.absUrl = settings.absUrl;
  4227. }
  4228. // Let listeners know we're about to change the current page.
  4229. this.element.trigger( pbcEvent, triggerData );
  4230. // If the default behavior is prevented, stop here!
  4231. if ( pbcEvent.isDefaultPrevented() ) {
  4232. return false;
  4233. }
  4234. return true;
  4235. },
  4236. change: function( to, options ) {
  4237. // If we are in the midst of a transition, queue the current request.
  4238. // We'll call changePage() once we're done with the current transition
  4239. // to service the request.
  4240. if ( isPageTransitioning ) {
  4241. pageTransitionQueue.unshift( arguments );
  4242. return;
  4243. }
  4244. var settings = $.extend( {}, $.mobile.changePage.defaults, options ),
  4245. triggerData = {};
  4246. // Make sure we have a fromPage.
  4247. settings.fromPage = settings.fromPage || this.activePage;
  4248. // if the page beforechange default is prevented return early
  4249. if ( !this._triggerPageBeforeChange(to, triggerData, settings) ) {
  4250. return;
  4251. }
  4252. // We allow "pagebeforechange" observers to modify the to in
  4253. // the trigger data to allow for redirects. Make sure our to is
  4254. // updated. We also need to re-evaluate whether it is a string,
  4255. // because an object can also be replaced by a string
  4256. to = triggerData.toPage;
  4257. // If the caller passed us a url, call loadPage()
  4258. // to make sure it is loaded into the DOM. We'll listen
  4259. // to the promise object it returns so we know when
  4260. // it is done loading or if an error ocurred.
  4261. if ( $.type(to) === "string" ) {
  4262. // Set the isPageTransitioning flag to prevent any requests from
  4263. // entering this method while we are in the midst of loading a page
  4264. // or transitioning.
  4265. isPageTransitioning = true;
  4266. this._loadUrl( to, triggerData, settings );
  4267. } else {
  4268. this.transition( to, triggerData, settings );
  4269. }
  4270. },
  4271. transition: function( toPage, triggerData, settings ) {
  4272. var fromPage, url, pageUrl, fileUrl,
  4273. active, activeIsInitialPage,
  4274. historyDir, pageTitle, isDialog,
  4275. alreadyThere, newPageTitle,
  4276. params, cssTransitionDeferred,
  4277. beforeTransition;
  4278. // If we are in the midst of a transition, queue the current request.
  4279. // We'll call changePage() once we're done with the current transition
  4280. // to service the request.
  4281. if ( isPageTransitioning ) {
  4282. // make sure to only queue the to and settings values so the arguments
  4283. // work with a call to the change method
  4284. pageTransitionQueue.unshift( [toPage, settings] );
  4285. return;
  4286. }
  4287. // DEPRECATED - this call only, in favor of the before transition
  4288. // if the page beforechange default is prevented return early
  4289. if ( !this._triggerPageBeforeChange(toPage, triggerData, settings) ) {
  4290. return;
  4291. }
  4292. // if the (content|page)beforetransition default is prevented return early
  4293. // Note, we have to check for both the deprecated and new events
  4294. beforeTransition = this._triggerWithDeprecated( "beforetransition", triggerData );
  4295. if (beforeTransition.deprecatedEvent.isDefaultPrevented() ||
  4296. beforeTransition.event.isDefaultPrevented() ) {
  4297. return;
  4298. }
  4299. // Set the isPageTransitioning flag to prevent any requests from
  4300. // entering this method while we are in the midst of loading a page
  4301. // or transitioning.
  4302. isPageTransitioning = true;
  4303. // If we are going to the first-page of the application, we need to make
  4304. // sure settings.dataUrl is set to the application document url. This allows
  4305. // us to avoid generating a document url with an id hash in the case where the
  4306. // first-page of the document has an id attribute specified.
  4307. if ( toPage[ 0 ] === $.mobile.firstPage[ 0 ] && !settings.dataUrl ) {
  4308. settings.dataUrl = $.mobile.path.documentUrl.hrefNoHash;
  4309. }
  4310. // The caller passed us a real page DOM element. Update our
  4311. // internal state and then trigger a transition to the page.
  4312. fromPage = settings.fromPage;
  4313. url = ( settings.dataUrl && $.mobile.path.convertUrlToDataUrl(settings.dataUrl) ) ||
  4314. toPage.jqmData( "url" );
  4315. // The pageUrl var is usually the same as url, except when url is obscured
  4316. // as a dialog url. pageUrl always contains the file path
  4317. pageUrl = url;
  4318. fileUrl = $.mobile.path.getFilePath( url );
  4319. active = $.mobile.navigate.history.getActive();
  4320. activeIsInitialPage = $.mobile.navigate.history.activeIndex === 0;
  4321. historyDir = 0;
  4322. pageTitle = document.title;
  4323. isDialog = ( settings.role === "dialog" ||
  4324. toPage.jqmData( "role" ) === "dialog" ) &&
  4325. toPage.jqmData( "dialog" ) !== true;
  4326. // By default, we prevent changePage requests when the fromPage and toPage
  4327. // are the same element, but folks that generate content
  4328. // manually/dynamically and reuse pages want to be able to transition to
  4329. // the same page. To allow this, they will need to change the default
  4330. // value of allowSamePageTransition to true, *OR*, pass it in as an
  4331. // option when they manually call changePage(). It should be noted that
  4332. // our default transition animations assume that the formPage and toPage
  4333. // are different elements, so they may behave unexpectedly. It is up to
  4334. // the developer that turns on the allowSamePageTransitiona option to
  4335. // either turn off transition animations, or make sure that an appropriate
  4336. // animation transition is used.
  4337. if ( fromPage && fromPage[0] === toPage[0] &&
  4338. !settings.allowSamePageTransition ) {
  4339. isPageTransitioning = false;
  4340. this._triggerWithDeprecated( "transition", triggerData );
  4341. this.element.trigger( "pagechange", triggerData );
  4342. // Even if there is no page change to be done, we should keep the
  4343. // urlHistory in sync with the hash changes
  4344. if ( settings.fromHashChange ) {
  4345. $.mobile.navigate.history.direct({ url: url });
  4346. }
  4347. return;
  4348. }
  4349. // We need to make sure the page we are given has already been enhanced.
  4350. toPage.page({ role: settings.role });
  4351. // If the changePage request was sent from a hashChange event, check to
  4352. // see if the page is already within the urlHistory stack. If so, we'll
  4353. // assume the user hit the forward/back button and will try to match the
  4354. // transition accordingly.
  4355. if ( settings.fromHashChange ) {
  4356. historyDir = settings.direction === "back" ? -1 : 1;
  4357. }
  4358. // Kill the keyboard.
  4359. // XXX_jblas: We need to stop crawling the entire document to kill focus.
  4360. // Instead, we should be tracking focus with a delegate()
  4361. // handler so we already have the element in hand at this
  4362. // point.
  4363. // Wrap this in a try/catch block since IE9 throw "Unspecified error" if
  4364. // document.activeElement is undefined when we are in an IFrame.
  4365. try {
  4366. if ( document.activeElement &&
  4367. document.activeElement.nodeName.toLowerCase() !== "body" ) {
  4368. $( document.activeElement ).blur();
  4369. } else {
  4370. $( "input:focus, textarea:focus, select:focus" ).blur();
  4371. }
  4372. } catch( e ) {}
  4373. // Record whether we are at a place in history where a dialog used to be -
  4374. // if so, do not add a new history entry and do not change the hash either
  4375. alreadyThere = false;
  4376. // If we're displaying the page as a dialog, we don't want the url
  4377. // for the dialog content to be used in the hash. Instead, we want
  4378. // to append the dialogHashKey to the url of the current page.
  4379. if ( isDialog && active ) {
  4380. // on the initial page load active.url is undefined and in that case
  4381. // should be an empty string. Moving the undefined -> empty string back
  4382. // into urlHistory.addNew seemed imprudent given undefined better
  4383. // represents the url state
  4384. // If we are at a place in history that once belonged to a dialog, reuse
  4385. // this state without adding to urlHistory and without modifying the
  4386. // hash. However, if a dialog is already displayed at this point, and
  4387. // we're about to display another dialog, then we must add another hash
  4388. // and history entry on top so that one may navigate back to the
  4389. // original dialog
  4390. if ( active.url &&
  4391. active.url.indexOf( $.mobile.dialogHashKey ) > -1 &&
  4392. this.activePage &&
  4393. !this.activePage.hasClass( "ui-dialog" ) &&
  4394. $.mobile.navigate.history.activeIndex > 0 ) {
  4395. settings.changeHash = false;
  4396. alreadyThere = true;
  4397. }
  4398. // Normally, we tack on a dialog hash key, but if this is the location
  4399. // of a stale dialog, we reuse the URL from the entry
  4400. url = ( active.url || "" );
  4401. // account for absolute urls instead of just relative urls use as hashes
  4402. if ( !alreadyThere && url.indexOf("#") > -1 ) {
  4403. url += $.mobile.dialogHashKey;
  4404. } else {
  4405. url += "#" + $.mobile.dialogHashKey;
  4406. }
  4407. // tack on another dialogHashKey if this is the same as the initial hash
  4408. // this makes sure that a history entry is created for this dialog
  4409. if ( $.mobile.navigate.history.activeIndex === 0 && url === $.mobile.navigate.history.initialDst ) {
  4410. url += $.mobile.dialogHashKey;
  4411. }
  4412. }
  4413. // if title element wasn't found, try the page div data attr too
  4414. // If this is a deep-link or a reload ( active === undefined ) then just
  4415. // use pageTitle
  4416. newPageTitle = ( !active ) ? pageTitle : toPage.jqmData( "title" ) ||
  4417. toPage.children( ":jqmData(role='header')" ).find( ".ui-title" ).text();
  4418. if ( !!newPageTitle && pageTitle === document.title ) {
  4419. pageTitle = newPageTitle;
  4420. }
  4421. if ( !toPage.jqmData( "title" ) ) {
  4422. toPage.jqmData( "title", pageTitle );
  4423. }
  4424. // Make sure we have a transition defined.
  4425. settings.transition = settings.transition ||
  4426. ( ( historyDir && !activeIsInitialPage ) ? active.transition : undefined ) ||
  4427. ( isDialog ? $.mobile.defaultDialogTransition : $.mobile.defaultPageTransition );
  4428. //add page to history stack if it's not back or forward
  4429. if ( !historyDir && alreadyThere ) {
  4430. $.mobile.navigate.history.getActive().pageUrl = pageUrl;
  4431. }
  4432. // Set the location hash.
  4433. if ( url && !settings.fromHashChange ) {
  4434. // rebuilding the hash here since we loose it earlier on
  4435. // TODO preserve the originally passed in path
  4436. if ( !$.mobile.path.isPath( url ) && url.indexOf( "#" ) < 0 ) {
  4437. url = "#" + url;
  4438. }
  4439. // TODO the property names here are just silly
  4440. params = {
  4441. transition: settings.transition,
  4442. title: pageTitle,
  4443. pageUrl: pageUrl,
  4444. role: settings.role
  4445. };
  4446. if ( settings.changeHash !== false && $.mobile.hashListeningEnabled ) {
  4447. $.mobile.navigate( url, params, true);
  4448. } else if ( toPage[ 0 ] !== $.mobile.firstPage[ 0 ] ) {
  4449. $.mobile.navigate.history.add( url, params );
  4450. }
  4451. }
  4452. //set page title
  4453. document.title = pageTitle;
  4454. //set "toPage" as activePage deprecated in 1.4 remove in 1.5
  4455. $.mobile.activePage = toPage;
  4456. //new way to handle activePage
  4457. this.activePage = toPage;
  4458. // If we're navigating back in the URL history, set reverse accordingly.
  4459. settings.reverse = settings.reverse || historyDir < 0;
  4460. cssTransitionDeferred = $.Deferred();
  4461. this._cssTransition(toPage, fromPage, {
  4462. transition: settings.transition,
  4463. reverse: settings.reverse,
  4464. deferred: cssTransitionDeferred
  4465. });
  4466. cssTransitionDeferred.done($.proxy(function( name, reverse, $to, $from, alreadyFocused ) {
  4467. $.mobile.removeActiveLinkClass();
  4468. //if there's a duplicateCachedPage, remove it from the DOM now that it's hidden
  4469. if ( settings.duplicateCachedPage ) {
  4470. settings.duplicateCachedPage.remove();
  4471. }
  4472. // despite visibility: hidden addresses issue #2965
  4473. // https://github.com/jquery/jquery-mobile/issues/2965
  4474. if ( !alreadyFocused ) {
  4475. $.mobile.focusPage( toPage );
  4476. }
  4477. this._releaseTransitionLock();
  4478. this.element.trigger( "pagechange", triggerData );
  4479. this._triggerWithDeprecated( "transition", triggerData );
  4480. }, this));
  4481. },
  4482. // determine the current base url
  4483. _findBaseWithDefault: function() {
  4484. var closestBase = ( this.activePage &&
  4485. $.mobile.getClosestBaseUrl( this.activePage ) );
  4486. return closestBase || $.mobile.path.documentBase.hrefNoHash;
  4487. }
  4488. });
  4489. // The following handlers should be bound after mobileinit has been triggered
  4490. // the following deferred is resolved in the init file
  4491. $.mobile.navreadyDeferred = $.Deferred();
  4492. //these variables make all page containers use the same queue and only navigate one at a time
  4493. // queue to hold simultanious page transitions
  4494. var pageTransitionQueue = [],
  4495. // indicates whether or not page is in process of transitioning
  4496. isPageTransitioning = false;
  4497. })( jQuery );
  4498. (function( $, undefined ) {
  4499. // resolved on domready
  4500. var domreadyDeferred = $.Deferred(),
  4501. documentUrl = $.mobile.path.documentUrl,
  4502. // used to track last vclicked element to make sure its value is added to form data
  4503. $lastVClicked = null;
  4504. /* Event Bindings - hashchange, submit, and click */
  4505. function findClosestLink( ele ) {
  4506. while ( ele ) {
  4507. // Look for the closest element with a nodeName of "a".
  4508. // Note that we are checking if we have a valid nodeName
  4509. // before attempting to access it. This is because the
  4510. // node we get called with could have originated from within
  4511. // an embedded SVG document where some symbol instance elements
  4512. // don't have nodeName defined on them, or strings are of type
  4513. // SVGAnimatedString.
  4514. if ( ( typeof ele.nodeName === "string" ) && ele.nodeName.toLowerCase() === "a" ) {
  4515. break;
  4516. }
  4517. ele = ele.parentNode;
  4518. }
  4519. return ele;
  4520. }
  4521. $.mobile.loadPage = function( url, opts ) {
  4522. var container;
  4523. opts = opts || {};
  4524. container = ( opts.pageContainer || $.mobile.pageContainer );
  4525. // create the deferred that will be supplied to loadPage callers
  4526. // and resolved by the content widget's load method
  4527. opts.deferred = $.Deferred();
  4528. // Preferring to allow exceptions for uninitialized opts.pageContainer
  4529. // widgets so we know if we need to force init here for users
  4530. container.pagecontainer( "load", url, opts );
  4531. // provide the deferred
  4532. return opts.deferred.promise();
  4533. };
  4534. //define vars for interal use
  4535. /* internal utility functions */
  4536. // NOTE Issue #4950 Android phonegap doesn't navigate back properly
  4537. // when a full page refresh has taken place. It appears that hashchange
  4538. // and replacestate history alterations work fine but we need to support
  4539. // both forms of history traversal in our code that uses backward history
  4540. // movement
  4541. $.mobile.back = function() {
  4542. var nav = window.navigator;
  4543. // if the setting is on and the navigator object is
  4544. // available use the phonegap navigation capability
  4545. if ( this.phonegapNavigationEnabled &&
  4546. nav &&
  4547. nav.app &&
  4548. nav.app.backHistory ) {
  4549. nav.app.backHistory();
  4550. } else {
  4551. $.mobile.pageContainer.pagecontainer( "back" );
  4552. }
  4553. };
  4554. //direct focus to the page title, or otherwise first focusable element
  4555. $.mobile.focusPage = function ( page ) {
  4556. var autofocus = page.find( "[autofocus]" ),
  4557. pageTitle = page.find( ".ui-title:eq(0)" );
  4558. if ( autofocus.length ) {
  4559. autofocus.focus();
  4560. return;
  4561. }
  4562. if ( pageTitle.length ) {
  4563. pageTitle.focus();
  4564. } else{
  4565. page.focus();
  4566. }
  4567. };
  4568. // No-op implementation of transition degradation
  4569. $.mobile._maybeDegradeTransition = $.mobile._maybeDegradeTransition || function( transition ) {
  4570. return transition;
  4571. };
  4572. /* exposed $.mobile methods */
  4573. //animation complete callback
  4574. $.fn.animationComplete = function( callback ) {
  4575. if ( $.support.cssTransitions ) {
  4576. return $( this ).one( "webkitAnimationEnd animationend", callback );
  4577. }
  4578. else{
  4579. // defer execution for consistency between webkit/non webkit
  4580. setTimeout( callback, 0 );
  4581. return $( this );
  4582. }
  4583. };
  4584. $.mobile.changePage = function( to, options ) {
  4585. $.mobile.pageContainer.pagecontainer( "change", to, options );
  4586. };
  4587. $.mobile.changePage.defaults = {
  4588. transition: undefined,
  4589. reverse: false,
  4590. changeHash: true,
  4591. fromHashChange: false,
  4592. role: undefined, // By default we rely on the role defined by the @data-role attribute.
  4593. duplicateCachedPage: undefined,
  4594. pageContainer: undefined,
  4595. showLoadMsg: true, //loading message shows by default when pages are being fetched during changePage
  4596. dataUrl: undefined,
  4597. fromPage: undefined,
  4598. allowSamePageTransition: false
  4599. };
  4600. $.mobile._registerInternalEvents = function() {
  4601. var getAjaxFormData = function( $form, calculateOnly ) {
  4602. var url, ret = true, formData, vclickedName, method;
  4603. if ( !$.mobile.ajaxEnabled ||
  4604. // test that the form is, itself, ajax false
  4605. $form.is( ":jqmData(ajax='false')" ) ||
  4606. // test that $.mobile.ignoreContentEnabled is set and
  4607. // the form or one of it's parents is ajax=false
  4608. !$form.jqmHijackable().length ||
  4609. $form.attr( "target" ) ) {
  4610. return false;
  4611. }
  4612. url = ( $lastVClicked && $lastVClicked.attr( "formaction" ) ) ||
  4613. $form.attr( "action" );
  4614. method = ( $form.attr( "method" ) || "get" ).toLowerCase();
  4615. // If no action is specified, browsers default to using the
  4616. // URL of the document containing the form. Since we dynamically
  4617. // pull in pages from external documents, the form should submit
  4618. // to the URL for the source document of the page containing
  4619. // the form.
  4620. if ( !url ) {
  4621. // Get the @data-url for the page containing the form.
  4622. url = $.mobile.getClosestBaseUrl( $form );
  4623. // NOTE: If the method is "get", we need to strip off the query string
  4624. // because it will get replaced with the new form data. See issue #5710.
  4625. if ( method === "get" ) {
  4626. url = $.mobile.path.parseUrl( url ).hrefNoSearch;
  4627. }
  4628. if ( url === $.mobile.path.documentBase.hrefNoHash ) {
  4629. // The url we got back matches the document base,
  4630. // which means the page must be an internal/embedded page,
  4631. // so default to using the actual document url as a browser
  4632. // would.
  4633. url = documentUrl.hrefNoSearch;
  4634. }
  4635. }
  4636. url = $.mobile.path.makeUrlAbsolute( url, $.mobile.getClosestBaseUrl( $form ) );
  4637. if ( ( $.mobile.path.isExternal( url ) && !$.mobile.path.isPermittedCrossDomainRequest( documentUrl, url ) ) ) {
  4638. return false;
  4639. }
  4640. if ( !calculateOnly ) {
  4641. formData = $form.serializeArray();
  4642. if ( $lastVClicked && $lastVClicked[ 0 ].form === $form[ 0 ] ) {
  4643. vclickedName = $lastVClicked.attr( "name" );
  4644. if ( vclickedName ) {
  4645. // Make sure the last clicked element is included in the form
  4646. $.each( formData, function( key, value ) {
  4647. if ( value.name === vclickedName ) {
  4648. // Unset vclickedName - we've found it in the serialized data already
  4649. vclickedName = "";
  4650. return false;
  4651. }
  4652. });
  4653. if ( vclickedName ) {
  4654. formData.push( { name: vclickedName, value: $lastVClicked.attr( "value" ) } );
  4655. }
  4656. }
  4657. }
  4658. ret = {
  4659. url: url,
  4660. options: {
  4661. type: method,
  4662. data: $.param( formData ),
  4663. transition: $form.jqmData( "transition" ),
  4664. reverse: $form.jqmData( "direction" ) === "reverse",
  4665. reloadPage: true
  4666. }
  4667. };
  4668. }
  4669. return ret;
  4670. };
  4671. //bind to form submit events, handle with Ajax
  4672. $.mobile.document.delegate( "form", "submit", function( event ) {
  4673. var formData;
  4674. if ( !event.isDefaultPrevented() ) {
  4675. formData = getAjaxFormData( $( this ) );
  4676. if ( formData ) {
  4677. $.mobile.changePage( formData.url, formData.options );
  4678. event.preventDefault();
  4679. }
  4680. }
  4681. });
  4682. //add active state on vclick
  4683. $.mobile.document.bind( "vclick", function( event ) {
  4684. var $btn, btnEls, target = event.target, needClosest = false;
  4685. // if this isn't a left click we don't care. Its important to note
  4686. // that when the virtual event is generated it will create the which attr
  4687. if ( event.which > 1 || !$.mobile.linkBindingEnabled ) {
  4688. return;
  4689. }
  4690. // Record that this element was clicked, in case we need it for correct
  4691. // form submission during the "submit" handler above
  4692. $lastVClicked = $( target );
  4693. // Try to find a target element to which the active class will be applied
  4694. if ( $.data( target, "mobile-button" ) ) {
  4695. // If the form will not be submitted via AJAX, do not add active class
  4696. if ( !getAjaxFormData( $( target ).closest( "form" ), true ) ) {
  4697. return;
  4698. }
  4699. // We will apply the active state to this button widget - the parent
  4700. // of the input that was clicked will have the associated data
  4701. if ( target.parentNode ) {
  4702. target = target.parentNode;
  4703. }
  4704. } else {
  4705. target = findClosestLink( target );
  4706. if ( !( target && $.mobile.path.parseUrl( target.getAttribute( "href" ) || "#" ).hash !== "#" ) ) {
  4707. return;
  4708. }
  4709. // TODO teach $.mobile.hijackable to operate on raw dom elements so the
  4710. // link wrapping can be avoided
  4711. if ( !$( target ).jqmHijackable().length ) {
  4712. return;
  4713. }
  4714. }
  4715. // Avoid calling .closest by using the data set during .buttonMarkup()
  4716. // List items have the button data in the parent of the element clicked
  4717. if ( !!~target.className.indexOf( "ui-link-inherit" ) ) {
  4718. if ( target.parentNode ) {
  4719. btnEls = $.data( target.parentNode, "buttonElements" );
  4720. }
  4721. // Otherwise, look for the data on the target itself
  4722. } else {
  4723. btnEls = $.data( target, "buttonElements" );
  4724. }
  4725. // If found, grab the button's outer element
  4726. if ( btnEls ) {
  4727. target = btnEls.outer;
  4728. } else {
  4729. needClosest = true;
  4730. }
  4731. $btn = $( target );
  4732. // If the outer element wasn't found by the our heuristics, use .closest()
  4733. if ( needClosest ) {
  4734. $btn = $btn.closest( ".ui-btn" );
  4735. }
  4736. if ( $btn.length > 0 &&
  4737. !( $btn.hasClass( "ui-state-disabled" ||
  4738. // DEPRECATED as of 1.4.0 - remove after 1.4.0 release
  4739. // only ui-state-disabled should be present thereafter
  4740. $btn.hasClass( "ui-disabled" ) ) ) ) {
  4741. $.mobile.removeActiveLinkClass( true );
  4742. $.mobile.activeClickedLink = $btn;
  4743. $.mobile.activeClickedLink.addClass( $.mobile.activeBtnClass );
  4744. }
  4745. });
  4746. // click routing - direct to HTTP or Ajax, accordingly
  4747. $.mobile.document.bind( "click", function( event ) {
  4748. if ( !$.mobile.linkBindingEnabled || event.isDefaultPrevented() ) {
  4749. return;
  4750. }
  4751. var link = findClosestLink( event.target ),
  4752. $link = $( link ),
  4753. //remove active link class if external (then it won't be there if you come back)
  4754. httpCleanup = function() {
  4755. window.setTimeout(function() { $.mobile.removeActiveLinkClass( true ); }, 200 );
  4756. },
  4757. baseUrl, href,
  4758. useDefaultUrlHandling, isExternal,
  4759. transition, reverse, role;
  4760. // If a button was clicked, clean up the active class added by vclick above
  4761. if ( $.mobile.activeClickedLink &&
  4762. $.mobile.activeClickedLink[ 0 ] === event.target.parentNode ) {
  4763. httpCleanup();
  4764. }
  4765. // If there is no link associated with the click or its not a left
  4766. // click we want to ignore the click
  4767. // TODO teach $.mobile.hijackable to operate on raw dom elements so the link wrapping
  4768. // can be avoided
  4769. if ( !link || event.which > 1 || !$link.jqmHijackable().length ) {
  4770. return;
  4771. }
  4772. //if there's a data-rel=back attr, go back in history
  4773. if ( $link.is( ":jqmData(rel='back')" ) ) {
  4774. $.mobile.back();
  4775. return false;
  4776. }
  4777. baseUrl = $.mobile.getClosestBaseUrl( $link );
  4778. //get href, if defined, otherwise default to empty hash
  4779. href = $.mobile.path.makeUrlAbsolute( $link.attr( "href" ) || "#", baseUrl );
  4780. //if ajax is disabled, exit early
  4781. if ( !$.mobile.ajaxEnabled && !$.mobile.path.isEmbeddedPage( href ) ) {
  4782. httpCleanup();
  4783. //use default click handling
  4784. return;
  4785. }
  4786. // XXX_jblas: Ideally links to application pages should be specified as
  4787. // an url to the application document with a hash that is either
  4788. // the site relative path or id to the page. But some of the
  4789. // internal code that dynamically generates sub-pages for nested
  4790. // lists and select dialogs, just write a hash in the link they
  4791. // create. This means the actual URL path is based on whatever
  4792. // the current value of the base tag is at the time this code
  4793. // is called. For now we are just assuming that any url with a
  4794. // hash in it is an application page reference.
  4795. if ( href.search( "#" ) !== -1 ) {
  4796. href = href.replace( /[^#]*#/, "" );
  4797. if ( !href ) {
  4798. //link was an empty hash meant purely
  4799. //for interaction, so we ignore it.
  4800. event.preventDefault();
  4801. return;
  4802. } else if ( $.mobile.path.isPath( href ) ) {
  4803. //we have apath so make it the href we want to load.
  4804. href = $.mobile.path.makeUrlAbsolute( href, baseUrl );
  4805. } else {
  4806. //we have a simple id so use the documentUrl as its base.
  4807. href = $.mobile.path.makeUrlAbsolute( "#" + href, documentUrl.hrefNoHash );
  4808. }
  4809. }
  4810. // Should we handle this link, or let the browser deal with it?
  4811. useDefaultUrlHandling = $link.is( "[rel='external']" ) || $link.is( ":jqmData(ajax='false')" ) || $link.is( "[target]" );
  4812. // Some embedded browsers, like the web view in Phone Gap, allow cross-domain XHR
  4813. // requests if the document doing the request was loaded via the file:// protocol.
  4814. // This is usually to allow the application to "phone home" and fetch app specific
  4815. // data. We normally let the browser handle external/cross-domain urls, but if the
  4816. // allowCrossDomainPages option is true, we will allow cross-domain http/https
  4817. // requests to go through our page loading logic.
  4818. //check for protocol or rel and its not an embedded page
  4819. //TODO overlap in logic from isExternal, rel=external check should be
  4820. // moved into more comprehensive isExternalLink
  4821. isExternal = useDefaultUrlHandling || ( $.mobile.path.isExternal( href ) && !$.mobile.path.isPermittedCrossDomainRequest( documentUrl, href ) );
  4822. if ( isExternal ) {
  4823. httpCleanup();
  4824. //use default click handling
  4825. return;
  4826. }
  4827. //use ajax
  4828. transition = $link.jqmData( "transition" );
  4829. reverse = $link.jqmData( "direction" ) === "reverse" ||
  4830. // deprecated - remove by 1.0
  4831. $link.jqmData( "back" );
  4832. //this may need to be more specific as we use data-rel more
  4833. role = $link.attr( "data-" + $.mobile.ns + "rel" ) || undefined;
  4834. $.mobile.changePage( href, { transition: transition, reverse: reverse, role: role, link: $link } );
  4835. event.preventDefault();
  4836. });
  4837. //prefetch pages when anchors with data-prefetch are encountered
  4838. $.mobile.document.delegate( ".ui-page", "pageshow.prefetch", function() {
  4839. var urls = [];
  4840. $( this ).find( "a:jqmData(prefetch)" ).each(function() {
  4841. var $link = $( this ),
  4842. url = $link.attr( "href" );
  4843. if ( url && $.inArray( url, urls ) === -1 ) {
  4844. urls.push( url );
  4845. $.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ),prefetch: true } );
  4846. }
  4847. });
  4848. });
  4849. // TODO ensure that the navigate binding in the content widget happens at the right time
  4850. $.mobile.pageContainer.pagecontainer();
  4851. //set page min-heights to be device specific
  4852. $.mobile.document.bind( "pageshow", $.mobile.resetActivePageHeight );
  4853. $.mobile.window.bind( "throttledresize", $.mobile.resetActivePageHeight );
  4854. };//navreadyDeferred done callback
  4855. $( function() { domreadyDeferred.resolve(); } );
  4856. $.when( domreadyDeferred, $.mobile.navreadyDeferred ).done( function() { $.mobile._registerInternalEvents(); } );
  4857. })( jQuery );
  4858. (function( $, window, undefined ) {
  4859. // TODO remove direct references to $.mobile and properties, we should
  4860. // favor injection with params to the constructor
  4861. $.mobile.Transition = function() {
  4862. this.init.apply( this, arguments );
  4863. };
  4864. $.extend($.mobile.Transition.prototype, {
  4865. toPreClass: " ui-page-pre-in",
  4866. init: function( name, reverse, $to, $from ) {
  4867. $.extend(this, {
  4868. name: name,
  4869. reverse: reverse,
  4870. $to: $to,
  4871. $from: $from,
  4872. deferred: new $.Deferred()
  4873. });
  4874. },
  4875. cleanFrom: function() {
  4876. this.$from
  4877. .removeClass( $.mobile.activePageClass + " out in reverse " + this.name )
  4878. .height( "" );
  4879. },
  4880. // NOTE overridden by child object prototypes, noop'd here as defaults
  4881. beforeDoneIn: function() {},
  4882. beforeDoneOut: function() {},
  4883. beforeStartOut: function() {},
  4884. doneIn: function() {
  4885. this.beforeDoneIn();
  4886. this.$to.removeClass( "out in reverse " + this.name ).height( "" );
  4887. this.toggleViewportClass();
  4888. // In some browsers (iOS5), 3D transitions block the ability to scroll to the desired location during transition
  4889. // This ensures we jump to that spot after the fact, if we aren't there already.
  4890. if ( $.mobile.window.scrollTop() !== this.toScroll ) {
  4891. this.scrollPage();
  4892. }
  4893. if ( !this.sequential ) {
  4894. this.$to.addClass( $.mobile.activePageClass );
  4895. }
  4896. this.deferred.resolve( this.name, this.reverse, this.$to, this.$from, true );
  4897. },
  4898. doneOut: function( screenHeight, reverseClass, none, preventFocus ) {
  4899. this.beforeDoneOut();
  4900. this.startIn( screenHeight, reverseClass, none, preventFocus );
  4901. },
  4902. hideIn: function( callback ) {
  4903. // Prevent flickering in phonegap container: see comments at #4024 regarding iOS
  4904. this.$to.css( "z-index", -10 );
  4905. callback.call( this );
  4906. this.$to.css( "z-index", "" );
  4907. },
  4908. scrollPage: function() {
  4909. // By using scrollTo instead of silentScroll, we can keep things better in order
  4910. // Just to be precautios, disable scrollstart listening like silentScroll would
  4911. $.event.special.scrollstart.enabled = false;
  4912. //if we are hiding the url bar or the page was previously scrolled scroll to hide or return to position
  4913. if ( $.mobile.hideUrlBar || this.toScroll !== $.mobile.defaultHomeScroll ) {
  4914. window.scrollTo( 0, this.toScroll );
  4915. }
  4916. // reenable scrollstart listening like silentScroll would
  4917. setTimeout( function() {
  4918. $.event.special.scrollstart.enabled = true;
  4919. }, 150 );
  4920. },
  4921. startIn: function( screenHeight, reverseClass, none, preventFocus ) {
  4922. this.hideIn(function() {
  4923. this.$to.addClass( $.mobile.activePageClass + this.toPreClass );
  4924. // Send focus to page as it is now display: block
  4925. if ( !preventFocus ) {
  4926. $.mobile.focusPage( this.$to );
  4927. }
  4928. // Set to page height
  4929. this.$to.height( screenHeight + this.toScroll );
  4930. if ( !none ) {
  4931. this.scrollPage();
  4932. }
  4933. });
  4934. if ( !none ) {
  4935. this.$to.animationComplete( $.proxy(function() {
  4936. this.doneIn();
  4937. }, this ));
  4938. }
  4939. this.$to
  4940. .removeClass( this.toPreClass )
  4941. .addClass( this.name + " in " + reverseClass );
  4942. if ( none ) {
  4943. this.doneIn();
  4944. }
  4945. },
  4946. startOut: function( screenHeight, reverseClass, none ) {
  4947. this.beforeStartOut( screenHeight, reverseClass, none );
  4948. // Set the from page's height and start it transitioning out
  4949. // Note: setting an explicit height helps eliminate tiling in the transitions
  4950. this.$from
  4951. .height( screenHeight + $.mobile.window.scrollTop() )
  4952. .addClass( this.name + " out" + reverseClass );
  4953. },
  4954. toggleViewportClass: function() {
  4955. $.mobile.pageContainer.toggleClass( "ui-mobile-viewport-transitioning viewport-" + this.name );
  4956. },
  4957. transition: function() {
  4958. // NOTE many of these could be calculated/recorded in the constructor, it's my
  4959. // opinion that binding them as late as possible has value with regards to
  4960. // better transitions with fewer bugs. Ie, it's not guaranteed that the
  4961. // object will be created and transition will be run immediately after as
  4962. // it is today. So we wait until transition is invoked to gather the following
  4963. var reverseClass = this.reverse ? " reverse" : "",
  4964. screenHeight = $.mobile.getScreenHeight(),
  4965. maxTransitionOverride = $.mobile.maxTransitionWidth !== false && $.mobile.window.width() > $.mobile.maxTransitionWidth,
  4966. none = !$.support.cssTransitions || !$.support.cssAnimations || maxTransitionOverride || !this.name || this.name === "none" || Math.max( $.mobile.window.scrollTop(), this.toScroll ) > $.mobile.getMaxScrollForTransition();
  4967. this.toScroll = $.mobile.navigate.history.getActive().lastScroll || $.mobile.defaultHomeScroll;
  4968. this.toggleViewportClass();
  4969. if ( this.$from && !none ) {
  4970. this.startOut( screenHeight, reverseClass, none );
  4971. } else {
  4972. this.doneOut( screenHeight, reverseClass, none, true );
  4973. }
  4974. return this.deferred.promise();
  4975. }
  4976. });
  4977. })( jQuery, this );
  4978. (function( $ ) {
  4979. $.mobile.SerialTransition = function() {
  4980. this.init.apply(this, arguments);
  4981. };
  4982. $.extend($.mobile.SerialTransition.prototype, $.mobile.Transition.prototype, {
  4983. sequential: true,
  4984. beforeDoneOut: function() {
  4985. if ( this.$from ) {
  4986. this.cleanFrom();
  4987. }
  4988. },
  4989. beforeStartOut: function( screenHeight, reverseClass, none ) {
  4990. this.$from.animationComplete($.proxy(function() {
  4991. this.doneOut( screenHeight, reverseClass, none );
  4992. }, this ));
  4993. }
  4994. });
  4995. })( jQuery );
  4996. (function( $ ) {
  4997. $.mobile.ConcurrentTransition = function() {
  4998. this.init.apply(this, arguments);
  4999. };
  5000. $.extend($.mobile.ConcurrentTransition.prototype, $.mobile.Transition.prototype, {
  5001. sequential: false,
  5002. beforeDoneIn: function() {
  5003. if ( this.$from ) {
  5004. this.cleanFrom();
  5005. }
  5006. },
  5007. beforeStartOut: function( screenHeight, reverseClass, none ) {
  5008. this.doneOut( screenHeight, reverseClass, none );
  5009. }
  5010. });
  5011. })( jQuery );
  5012. (function( $ ) {
  5013. // generate the handlers from the above
  5014. var defaultGetMaxScrollForTransition = function() {
  5015. return $.mobile.getScreenHeight() * 3;
  5016. };
  5017. //transition handler dictionary for 3rd party transitions
  5018. $.mobile.transitionHandlers = {
  5019. "sequential": $.mobile.SerialTransition,
  5020. "simultaneous": $.mobile.ConcurrentTransition
  5021. };
  5022. // Make our transition handler the public default.
  5023. $.mobile.defaultTransitionHandler = $.mobile.transitionHandlers.sequential;
  5024. $.mobile.transitionFallbacks = {};
  5025. // If transition is defined, check if css 3D transforms are supported, and if not, if a fallback is specified
  5026. $.mobile._maybeDegradeTransition = function( transition ) {
  5027. if ( transition && !$.support.cssTransform3d && $.mobile.transitionFallbacks[ transition ] ) {
  5028. transition = $.mobile.transitionFallbacks[ transition ];
  5029. }
  5030. return transition;
  5031. };
  5032. // Set the getMaxScrollForTransition to default if no implementation was set by user
  5033. $.mobile.getMaxScrollForTransition = $.mobile.getMaxScrollForTransition || defaultGetMaxScrollForTransition;
  5034. })( jQuery );
  5035. /*
  5036. * fallback transition for flip in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5037. */
  5038. (function( $, window, undefined ) {
  5039. $.mobile.transitionFallbacks.flip = "fade";
  5040. })( jQuery, this );
  5041. /*
  5042. * fallback transition for flow in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5043. */
  5044. (function( $, window, undefined ) {
  5045. $.mobile.transitionFallbacks.flow = "fade";
  5046. })( jQuery, this );
  5047. /*
  5048. * fallback transition for pop in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5049. */
  5050. (function( $, window, undefined ) {
  5051. $.mobile.transitionFallbacks.pop = "fade";
  5052. })( jQuery, this );
  5053. /*
  5054. * fallback transition for slide in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5055. */
  5056. (function( $, window, undefined ) {
  5057. // Use the simultaneous transitions handler for slide transitions
  5058. $.mobile.transitionHandlers.slide = $.mobile.transitionHandlers.simultaneous;
  5059. // Set the slide transitions's fallback to "fade"
  5060. $.mobile.transitionFallbacks.slide = "fade";
  5061. })( jQuery, this );
  5062. /*
  5063. * fallback transition for slidedown in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5064. */
  5065. (function( $, window, undefined ) {
  5066. $.mobile.transitionFallbacks.slidedown = "fade";
  5067. })( jQuery, this );
  5068. /*
  5069. * fallback transition for slidefade in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5070. */
  5071. (function( $, window, undefined ) {
  5072. // Set the slide transitions's fallback to "fade"
  5073. $.mobile.transitionFallbacks.slidefade = "fade";
  5074. })( jQuery, this );
  5075. /*
  5076. * fallback transition for slideup in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5077. */
  5078. (function( $, window, undefined ) {
  5079. $.mobile.transitionFallbacks.slideup = "fade";
  5080. })( jQuery, this );
  5081. /*
  5082. * fallback transition for turn in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5083. */
  5084. (function( $, window, undefined ) {
  5085. $.mobile.transitionFallbacks.turn = "fade";
  5086. })( jQuery, this );
  5087. (function( $, undefined ) {
  5088. $.mobile.degradeInputs = {
  5089. color: false,
  5090. date: false,
  5091. datetime: false,
  5092. "datetime-local": false,
  5093. email: false,
  5094. month: false,
  5095. number: false,
  5096. range: "number",
  5097. search: "text",
  5098. tel: false,
  5099. time: false,
  5100. url: false,
  5101. week: false
  5102. };
  5103. // Backcompat remove in 1.5
  5104. $.mobile.page.prototype.options.degradeInputs = $.mobile.degradeInputs;
  5105. // Auto self-init widgets
  5106. $.mobile.degradeInputsWithin = function( target ) {
  5107. target = $( target );
  5108. // Degrade inputs to avoid poorly implemented native functionality
  5109. target.find( "input" ).not( $.mobile.page.prototype.keepNativeSelector() ).each(function() {
  5110. var element = $( this ),
  5111. type = this.getAttribute( "type" ),
  5112. optType = $.mobile.degradeInputs[ type ] || "text",
  5113. html, hasType, findstr, repstr;
  5114. if ( $.mobile.degradeInputs[ type ] ) {
  5115. html = $( "<div>" ).html( element.clone() ).html();
  5116. // In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead
  5117. hasType = html.indexOf( " type=" ) > -1;
  5118. findstr = hasType ? /\s+type=["']?\w+['"]?/ : /\/?>/;
  5119. repstr = " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\"" + ( hasType ? "" : ">" );
  5120. element.replaceWith( html.replace( findstr, repstr ) );
  5121. }
  5122. });
  5123. };
  5124. })( jQuery );
  5125. (function( $, window, undefined ) {
  5126. $.widget( "mobile.page", $.mobile.page, {
  5127. options: {
  5128. // Accepts left, right and none
  5129. closeBtn: "left",
  5130. closeBtnText: "Close",
  5131. overlayTheme: "a",
  5132. corners: true,
  5133. dialog: false
  5134. },
  5135. _create: function() {
  5136. this._super();
  5137. if ( this.options.dialog ) {
  5138. $.extend( this, {
  5139. _inner: this.element.children(),
  5140. _headerCloseButton: null
  5141. });
  5142. if ( !this.options.enhanced ) {
  5143. this._setCloseBtn( this.options.closeBtn );
  5144. }
  5145. }
  5146. },
  5147. _enhance: function() {
  5148. this._super();
  5149. // Class the markup for dialog styling and wrap interior
  5150. if ( this.options.dialog ) {
  5151. this.element.addClass( "ui-dialog" )
  5152. .wrapInner( $( "<div/>", {
  5153. // ARIA role
  5154. "role" : "dialog",
  5155. "class" : "ui-dialog-contain ui-overlay-shadow" +
  5156. ( this.options.corners ? " ui-corner-all" : "" )
  5157. }));
  5158. }
  5159. },
  5160. _setOptions: function( options ) {
  5161. var closeButtonLocation, closeButtonText,
  5162. currentOpts = this.options;
  5163. if ( options.corners !== undefined ) {
  5164. this._inner.toggleClass( "ui-corner-all", !!options.corners );
  5165. }
  5166. if ( options.overlayTheme !== undefined ) {
  5167. if ( $.mobile.activePage[ 0 ] === this.element[ 0 ] ) {
  5168. currentOpts.overlayTheme = options.overlayTheme;
  5169. this._handlePageBeforeShow();
  5170. }
  5171. }
  5172. if ( options.closeBtnText !== undefined ) {
  5173. closeButtonLocation = currentOpts.closeBtn;
  5174. closeButtonText = options.closeBtnText;
  5175. }
  5176. if ( options.closeBtn !== undefined ) {
  5177. closeButtonLocation = options.closeBtn;
  5178. }
  5179. if ( closeButtonLocation ) {
  5180. this._setCloseBtn( closeButtonLocation, closeButtonText );
  5181. }
  5182. this._super( options );
  5183. },
  5184. _handlePageBeforeShow: function () {
  5185. if ( this.options.overlayTheme && this.options.dialog ) {
  5186. this.removeContainerBackground();
  5187. this.setContainerBackground( this.options.overlayTheme );
  5188. } else {
  5189. this._super();
  5190. }
  5191. },
  5192. _setCloseBtn: function( location, text ) {
  5193. var dst,
  5194. btn = this._headerCloseButton;
  5195. // Sanitize value
  5196. location = "left" === location ? "left" : "right" === location ? "right" : "none";
  5197. if ( "none" === location ) {
  5198. if ( btn ) {
  5199. btn.remove();
  5200. btn = null;
  5201. }
  5202. } else if ( btn ) {
  5203. btn.removeClass( "ui-btn-left ui-btn-right" ).addClass( "ui-btn-" + location );
  5204. if ( text ) {
  5205. btn.text( text );
  5206. }
  5207. } else {
  5208. dst = this._inner.find( ":jqmData(role='header')" ).first();
  5209. btn = $( "<a></a>", {
  5210. "href": "#",
  5211. "class": "ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-" + location
  5212. })
  5213. .attr( "data-" + $.mobile.ns + "rel", "back" )
  5214. .text( text || this.options.closeBtnText || "" )
  5215. .prependTo( dst );
  5216. this._on( btn, { click: "close" } );
  5217. }
  5218. this._headerCloseButton = btn;
  5219. }
  5220. });
  5221. })( jQuery, this );
  5222. (function( $, window, undefined ) {
  5223. $.widget( "mobile.dialog", {
  5224. options: {
  5225. // Accepts left, right and none
  5226. closeBtn: "left",
  5227. closeBtnText: "Close",
  5228. overlayTheme: "a",
  5229. corners: true
  5230. },
  5231. // Override the theme set by the page plugin on pageshow
  5232. _handlePageBeforeShow: function() {
  5233. this._isCloseable = true;
  5234. if ( this.options.overlayTheme ) {
  5235. this.element
  5236. .page( "removeContainerBackground" )
  5237. .page( "setContainerBackground", this.options.overlayTheme );
  5238. }
  5239. },
  5240. _handlePageBeforeHide: function() {
  5241. this._isCloseable = false;
  5242. },
  5243. // click and submit events:
  5244. // - clicks and submits should use the closing transition that the dialog
  5245. // opened with unless a data-transition is specified on the link/form
  5246. // - if the click was on the close button, or the link has a data-rel="back"
  5247. // it'll go back in history naturally
  5248. _handleVClickSubmit: function( event ) {
  5249. var attrs,
  5250. $target = $( event.target ).closest( event.type === "vclick" ? "a" : "form" );
  5251. if ( $target.length && !$target.jqmData( "transition" ) ) {
  5252. attrs = {};
  5253. attrs[ "data-" + $.mobile.ns + "transition" ] =
  5254. ( $.mobile.navigate.history.getActive() || {} )[ "transition" ] ||
  5255. $.mobile.defaultDialogTransition;
  5256. attrs[ "data-" + $.mobile.ns + "direction" ] = "reverse";
  5257. $target.attr( attrs );
  5258. }
  5259. },
  5260. _create: function() {
  5261. var elem = this.element,
  5262. opts = this.options;
  5263. // Class the markup for dialog styling and wrap interior
  5264. elem.addClass( "ui-dialog" )
  5265. .wrapInner( $( "<div/>", {
  5266. // ARIA role
  5267. "role" : "dialog",
  5268. "class" : "ui-dialog-contain ui-overlay-shadow" +
  5269. ( !!opts.corners ? " ui-corner-all" : "" )
  5270. }));
  5271. $.extend( this, {
  5272. _isCloseable: false,
  5273. _inner: elem.children(),
  5274. _headerCloseButton: null
  5275. });
  5276. this._on( elem, {
  5277. vclick: "_handleVClickSubmit",
  5278. submit: "_handleVClickSubmit",
  5279. pagebeforeshow: "_handlePageBeforeShow",
  5280. pagebeforehide: "_handlePageBeforeHide"
  5281. });
  5282. this._setCloseBtn( opts.closeBtn );
  5283. },
  5284. _setOptions: function( options ) {
  5285. var closeButtonLocation, closeButtonText,
  5286. currentOpts = this.options;
  5287. if ( options.corners !== undefined ) {
  5288. this._inner.toggleClass( "ui-corner-all", !!options.corners );
  5289. }
  5290. if ( options.overlayTheme !== undefined ) {
  5291. if ( $.mobile.activePage[ 0 ] === this.element[ 0 ] ) {
  5292. currentOpts.overlayTheme = options.overlayTheme;
  5293. this._handlePageBeforeShow();
  5294. }
  5295. }
  5296. if ( options.closeBtnText !== undefined ) {
  5297. closeButtonLocation = currentOpts.closeBtn;
  5298. closeButtonText = options.closeBtnText;
  5299. }
  5300. if ( options.closeBtn !== undefined ) {
  5301. closeButtonLocation = options.closeBtn;
  5302. }
  5303. if ( closeButtonLocation ) {
  5304. this._setCloseBtn( closeButtonLocation, closeButtonText );
  5305. }
  5306. this._super( options );
  5307. },
  5308. _setCloseBtn: function( location, text ) {
  5309. var dst,
  5310. btn = this._headerCloseButton;
  5311. // Sanitize value
  5312. location = "left" === location ? "left" : "right" === location ? "right" : "none";
  5313. if ( "none" === location ) {
  5314. if ( btn ) {
  5315. btn.remove();
  5316. btn = null;
  5317. }
  5318. } else if ( btn ) {
  5319. btn.removeClass( "ui-btn-left ui-btn-right" ).addClass( "ui-btn-" + location );
  5320. if ( text ) {
  5321. btn.text( text );
  5322. }
  5323. } else {
  5324. dst = this._inner.find( ":jqmData(role='header')" ).first();
  5325. btn = $( "<a></a>", {
  5326. "role": "button",
  5327. "href": "#",
  5328. "class": "ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-" + location
  5329. })
  5330. .text( text || this.options.closeBtnText || "" )
  5331. .prependTo( dst );
  5332. this._on( btn, { click: "close" } );
  5333. }
  5334. this._headerCloseButton = btn;
  5335. },
  5336. // Close method goes back in history
  5337. close: function() {
  5338. var hist = $.mobile.navigate.history;
  5339. if ( this._isCloseable ) {
  5340. this._isCloseable = false;
  5341. // If the hash listening is enabled and there is at least one preceding history
  5342. // entry it's ok to go back. Initial pages with the dialog hash state are an example
  5343. // where the stack check is necessary
  5344. if ( $.mobile.hashListeningEnabled && hist.activeIndex > 0 ) {
  5345. $.mobile.back();
  5346. } else {
  5347. $.mobile.pageContainer.pagecontainer( "back" );
  5348. }
  5349. }
  5350. }
  5351. });
  5352. })( jQuery, this );
  5353. (function( $, undefined ) {
  5354. var rInitialLetter = /([A-Z])/g;
  5355. $.widget( "mobile.collapsible", {
  5356. options: {
  5357. enhanced: false,
  5358. expandCueText: null,
  5359. collapseCueText: null,
  5360. collapsed: true,
  5361. heading: "h1,h2,h3,h4,h5,h6,legend",
  5362. collapsedIcon: null,
  5363. expandedIcon: null,
  5364. iconpos: null,
  5365. theme: null,
  5366. contentTheme: null,
  5367. inset: null,
  5368. corners: null,
  5369. mini: null
  5370. },
  5371. _create: function() {
  5372. var elem = this.element,
  5373. ui = {
  5374. accordion: elem
  5375. .closest( ":jqmData(role='collapsible-set')" +
  5376. ( $.mobile.collapsibleset ? ", :mobile-collapsibleset" : "" ) )
  5377. .addClass( "ui-collapsible-set" )
  5378. };
  5379. $.extend( this, {
  5380. _ui: ui
  5381. });
  5382. if ( this.options.enhanced ) {
  5383. ui.heading = $( ".ui-collapsible-heading", this.element[ 0 ] );
  5384. ui.content = ui.heading.next();
  5385. ui.anchor = $( "a", ui.heading[ 0 ] ).first();
  5386. ui.status = ui.anchor.children( ".ui-collapsible-heading-status" );
  5387. } else {
  5388. this._enhance( elem, ui );
  5389. }
  5390. this._on( ui.heading, {
  5391. "tap": function() {
  5392. ui.heading.find( "a" ).first().addClass( $.mobile.activeBtnClass );
  5393. },
  5394. "click": function( event ) {
  5395. this._handleExpandCollapse( !ui.heading.hasClass( "ui-collapsible-heading-collapsed" ) );
  5396. event.preventDefault();
  5397. event.stopPropagation();
  5398. }
  5399. });
  5400. },
  5401. // Adjust the keys inside options for inherited values
  5402. _getOptions: function( options ) {
  5403. var key,
  5404. accordion = this._ui.accordion,
  5405. accordionWidget = this._ui.accordionWidget;
  5406. // Copy options
  5407. options = $.extend( {}, options );
  5408. if ( accordion.length && !accordionWidget ) {
  5409. this._ui.accordionWidget =
  5410. accordionWidget = accordion.data( "mobile-collapsibleset" );
  5411. }
  5412. for ( key in options ) {
  5413. // Retrieve the option value first from the options object passed in and, if
  5414. // null, from the parent accordion or, if that's null too, or if there's no
  5415. // parent accordion, then from the defaults.
  5416. options[ key ] =
  5417. ( options[ key ] != null ) ? options[ key ] :
  5418. ( accordionWidget ) ? accordionWidget.options[ key ] :
  5419. accordion.length ? $.mobile.getAttribute( accordion[ 0 ],
  5420. key.replace( rInitialLetter, "-$1" ).toLowerCase() ):
  5421. null;
  5422. if ( null == options[ key ] ) {
  5423. options[ key ] = $.mobile.collapsible.defaults[ key ];
  5424. }
  5425. }
  5426. return options;
  5427. },
  5428. _themeClassFromOption: function( prefix, value ) {
  5429. return ( value ? ( value === "none" ? "" : prefix + value ) : "" );
  5430. },
  5431. _enhance: function( elem, ui ) {
  5432. var iconclass,
  5433. opts = this._getOptions( this.options ),
  5434. contentThemeClass = this._themeClassFromOption( "ui-body-", opts.contentTheme );
  5435. elem.addClass( "ui-collapsible " +
  5436. ( opts.inset ? "ui-collapsible-inset " : "" ) +
  5437. ( opts.inset && opts.corners ? "ui-corner-all " : "" ) +
  5438. ( contentThemeClass ? "ui-collapsible-themed-content " : "" ) );
  5439. ui.originalHeading = elem.children( this.options.heading ).first(),
  5440. ui.content = elem
  5441. .wrapInner( "<div " +
  5442. "class='ui-collapsible-content " +
  5443. contentThemeClass + "'></div>" )
  5444. .children( ".ui-collapsible-content" ),
  5445. ui.heading = ui.originalHeading;
  5446. // Replace collapsibleHeading if it's a legend
  5447. if ( ui.heading.is( "legend" ) ) {
  5448. ui.heading = $( "<div role='heading'>"+ ui.heading.html() +"</div>" );
  5449. ui.placeholder = $( "<div><!-- placeholder for legend --></div>" ).insertBefore( ui.originalHeading );
  5450. ui.originalHeading.remove();
  5451. }
  5452. iconclass = ( opts.collapsed ? ( opts.collapsedIcon ? "ui-icon-" + opts.collapsedIcon : "" ):
  5453. ( opts.expandedIcon ? "ui-icon-" + opts.expandedIcon : "" ) );
  5454. ui.status = $( "<span class='ui-collapsible-heading-status'></span>" );
  5455. ui.anchor = ui.heading
  5456. .detach()
  5457. //modify markup & attributes
  5458. .addClass( "ui-collapsible-heading" )
  5459. .append( ui.status )
  5460. .wrapInner( "<a href='#' class='ui-collapsible-heading-toggle'></a>" )
  5461. .find( "a" )
  5462. .first()
  5463. .addClass( "ui-btn " +
  5464. ( iconclass ? iconclass + " " : "" ) +
  5465. ( iconclass ? ( "ui-btn-icon-" +
  5466. ( opts.iconpos === "right" ? "right" : "left" ) ) +
  5467. " " : "" ) +
  5468. this._themeClassFromOption( "ui-btn-", opts.theme ) + " " +
  5469. ( opts.mini ? "ui-mini " : "" ) );
  5470. //drop heading in before content
  5471. ui.heading.insertBefore( ui.content );
  5472. this._handleExpandCollapse( this.options.collapsed );
  5473. return ui;
  5474. },
  5475. refresh: function() {
  5476. var key, options = {};
  5477. for ( key in $.mobile.collapsible.defaults ) {
  5478. options[ key ] = this.options[ key ];
  5479. }
  5480. this._setOptions( options );
  5481. },
  5482. _setOptions: function( options ) {
  5483. var isCollapsed, newTheme, oldTheme, hasCorners,
  5484. elem = this.element,
  5485. currentOpts = this._getOptions( this.options ),
  5486. ui = this._ui,
  5487. anchor = ui.anchor,
  5488. status = ui.status,
  5489. opts = this._getOptions( options );
  5490. // First and foremost we need to make sure the collapsible is in the proper
  5491. // state, in case somebody decided to change the collapsed option at the
  5492. // same time as another option
  5493. if ( options.collapsed !== undefined ) {
  5494. this._handleExpandCollapse( options.collapsed );
  5495. }
  5496. isCollapsed = elem.hasClass( "ui-collapsible-collapsed" );
  5497. // Only options referring to the current state need to be applied right away
  5498. // It is enough to store options covering the alternate in this.options.
  5499. if ( isCollapsed ) {
  5500. if ( opts.expandCueText !== undefined ) {
  5501. status.text( opts.expandCueText );
  5502. }
  5503. if ( opts.collapsedIcon !== undefined ) {
  5504. if ( currentOpts.collapsedIcon ) {
  5505. anchor.removeClass( "ui-icon-" + currentOpts.collapsedIcon );
  5506. }
  5507. if ( opts.collapsedIcon ) {
  5508. anchor.addClass( "ui-icon-" + opts.collapsedIcon );
  5509. }
  5510. }
  5511. } else {
  5512. if ( opts.collapseCueText !== undefined ) {
  5513. status.text( opts.collapseCueText );
  5514. }
  5515. if ( opts.expandedIcon !== undefined ) {
  5516. if ( currentOpts.expandedIcon ) {
  5517. anchor.removeClass( "ui-icon-" + currentOpts.expandedIcon );
  5518. }
  5519. if ( opts.expandedIcon ) {
  5520. anchor.addClass( "ui-icon-" + opts.expandedIcon );
  5521. }
  5522. }
  5523. }
  5524. if ( opts.iconpos !== undefined ) {
  5525. anchor.removeClass( "ui-btn-icon-" + ( currentOpts.iconPos === "right" ? "right" : "left" ) );
  5526. anchor.addClass( "ui-btn-icon-" + ( opts.iconPos === "right" ? "right" : "left" ) );
  5527. }
  5528. if ( opts.theme !== undefined ) {
  5529. oldTheme = this._themeClassFromOption( "ui-btn-", currentOpts.theme );
  5530. newTheme = this._themeClassFromOption( "ui-btn-", opts.theme );
  5531. anchor.removeClass( oldTheme ).addClass( newTheme );
  5532. }
  5533. if ( opts.contentTheme !== undefined ) {
  5534. oldTheme = this._themeClassFromOption( "ui-body-", currentOpts.theme );
  5535. newTheme = this._themeClassFromOption( "ui-body-", opts.theme );
  5536. ui.content.removeClass( oldTheme ).addClass( newTheme );
  5537. }
  5538. if ( opts.inset !== undefined ) {
  5539. elem.toggleClass( "ui-collapsible-inset", opts.inset );
  5540. hasCorners = !!( opts.inset && ( opts.corners || currentOpts.corners ) );
  5541. }
  5542. if ( opts.corners !== undefined ) {
  5543. hasCorners = !!( opts.corners && ( opts.inset || currentOpts.inset ) );
  5544. }
  5545. if ( hasCorners !== undefined ) {
  5546. elem.toggleClass( "ui-corner-all", hasCorners );
  5547. }
  5548. if ( opts.mini !== undefined ) {
  5549. anchor.toggleClass( "ui-mini", opts.mini );
  5550. }
  5551. this._super( options );
  5552. },
  5553. _handleExpandCollapse: function( isCollapse ) {
  5554. var opts = this._getOptions( this.options ),
  5555. ui = this._ui;
  5556. ui.status.text( isCollapse ? opts.expandCueText : opts.collapseCueText );
  5557. ui.heading
  5558. .toggleClass( "ui-collapsible-heading-collapsed", isCollapse )
  5559. .find( "a" ).first()
  5560. .toggleClass( "ui-icon-" + opts.expandedIcon, !isCollapse )
  5561. // logic or cause same icon for expanded/collapsed state would remove the ui-icon-class
  5562. .toggleClass( "ui-icon-" + opts.collapsedIcon, ( isCollapse || opts.expandedIcon === opts.collapsedIcon ) )
  5563. .removeClass( $.mobile.activeBtnClass );
  5564. this.element.toggleClass( "ui-collapsible-collapsed", isCollapse );
  5565. ui.content
  5566. .toggleClass( "ui-collapsible-content-collapsed", isCollapse )
  5567. .attr( "aria-hidden", isCollapse )
  5568. .trigger( "updatelayout" );
  5569. this.options.collapsed = isCollapse;
  5570. this._trigger( isCollapse ? "collapse" : "expand" );
  5571. },
  5572. expand: function() {
  5573. this._handleExpandCollapse( false );
  5574. },
  5575. collapse: function() {
  5576. this._handleExpandCollapse( true );
  5577. },
  5578. _destroy: function() {
  5579. var ui = this._ui,
  5580. opts = this.options;
  5581. if ( opts.enhanced ) {
  5582. return;
  5583. }
  5584. if ( ui.placeholder ) {
  5585. ui.originalHeading.insertBefore( ui.placeholder );
  5586. ui.placeholder.remove();
  5587. ui.heading.remove();
  5588. } else {
  5589. ui.status.remove();
  5590. ui.heading
  5591. .removeClass( "ui-collapsible-heading ui-collapsible-heading-collapsed" )
  5592. .children()
  5593. .contents()
  5594. .unwrap();
  5595. }
  5596. ui.anchor.contents().unwrap();
  5597. ui.content.contents().unwrap();
  5598. this.element
  5599. .removeClass( "ui-collapsible ui-collapsible-collapsed " +
  5600. "ui-collapsible-themed-content ui-collapsible-inset ui-corner-all" );
  5601. }
  5602. });
  5603. // Defaults to be used by all instances of collapsible if per-instance values
  5604. // are unset or if nothing is specified by way of inheritance from an accordion.
  5605. // Note that this hash does not contain options "collapsed" or "heading",
  5606. // because those are not inheritable.
  5607. $.mobile.collapsible.defaults = {
  5608. expandCueText: " click to expand contents",
  5609. collapseCueText: " click to collapse contents",
  5610. collapsedIcon: "plus",
  5611. contentTheme: "inherit",
  5612. expandedIcon: "minus",
  5613. iconpos: "left",
  5614. inset: true,
  5615. corners: true,
  5616. theme: "inherit",
  5617. mini: false
  5618. };
  5619. })( jQuery );
  5620. (function( $, undefined ) {
  5621. $.mobile.behaviors.addFirstLastClasses = {
  5622. _getVisibles: function( $els, create ) {
  5623. var visibles;
  5624. if ( create ) {
  5625. visibles = $els.not( ".ui-screen-hidden" );
  5626. } else {
  5627. visibles = $els.filter( ":visible" );
  5628. if ( visibles.length === 0 ) {
  5629. visibles = $els.not( ".ui-screen-hidden" );
  5630. }
  5631. }
  5632. return visibles;
  5633. },
  5634. _addFirstLastClasses: function( $els, $visibles, create ) {
  5635. $els.removeClass( "ui-first-child ui-last-child" );
  5636. $visibles.eq( 0 ).addClass( "ui-first-child" ).end().last().addClass( "ui-last-child" );
  5637. if ( !create ) {
  5638. this.element.trigger( "updatelayout" );
  5639. }
  5640. },
  5641. _removeFirstLastClasses: function( $els ) {
  5642. $els.removeClass( "ui-first-child ui-last-child" );
  5643. }
  5644. };
  5645. })( jQuery );
  5646. (function( $, undefined ) {
  5647. var childCollapsiblesSelector = ":mobile-collapsible, " + $.mobile.collapsible.initSelector;
  5648. $.widget( "mobile.collapsibleset", $.extend( {
  5649. // The initSelector is deprecated as of 1.4.0. In 1.5.0 we will use
  5650. // :jqmData(role='collapsibleset') which will allow us to get rid of the line
  5651. // below altogether, because the autoinit will generate such an initSelector
  5652. initSelector: ":jqmData(role='collapsible-set'),:jqmData(role='collapsibleset')",
  5653. options: $.extend( {
  5654. enhanced: false
  5655. }, $.mobile.collapsible.defaults ),
  5656. _handleCollapsibleExpand: function( event ) {
  5657. var closestCollapsible = $( event.target ).closest( ".ui-collapsible" );
  5658. if ( closestCollapsible.parent().is( ":mobile-collapsibleset, :jqmData(role='collapsible-set')" ) ) {
  5659. closestCollapsible
  5660. .siblings( ".ui-collapsible:not(.ui-collapsible-collapsed)" )
  5661. .collapsible( "collapse" );
  5662. }
  5663. },
  5664. _create: function() {
  5665. var elem = this.element,
  5666. opts = this.options;
  5667. $.extend( this, {
  5668. _classes: ""
  5669. });
  5670. if ( !opts.enhanced ) {
  5671. elem.addClass( "ui-collapsible-set " +
  5672. this._themeClassFromOption( "ui-group-theme-", opts.theme ) + " " +
  5673. ( opts.corners && opts.inset ? "ui-corner-all " : "" ) );
  5674. this.element.find( $.mobile.collapsible.initSelector ).collapsible();
  5675. }
  5676. this._on( elem, { collapsibleexpand: "_handleCollapsibleExpand" } );
  5677. },
  5678. _themeClassFromOption: function( prefix, value ) {
  5679. return ( value ? ( value === "none" ? "" : prefix + value ) : "" );
  5680. },
  5681. _init: function() {
  5682. this._refresh( true );
  5683. // Because the corners are handled by the collapsible itself and the default state is collapsed
  5684. // That was causing https://github.com/jquery/jquery-mobile/issues/4116
  5685. this.element
  5686. .children( childCollapsiblesSelector )
  5687. .filter( ":jqmData(collapsed='false')" )
  5688. .collapsible( "expand" );
  5689. },
  5690. _setOptions: function( options ) {
  5691. var ret, hasCorners,
  5692. elem = this.element,
  5693. themeClass = this._themeClassFromOption( "ui-group-theme-", options.theme );
  5694. if ( themeClass ) {
  5695. elem
  5696. .removeClass( this._themeClassFromOption( "ui-group-theme-", this.options.theme ) )
  5697. .addClass( themeClass );
  5698. }
  5699. if ( options.inset !== undefined ) {
  5700. hasCorners = !!( options.inset && ( options.corners || this.options.corners ) );
  5701. }
  5702. if ( options.corners !== undefined ) {
  5703. hasCorners = !!( options.corners && ( options.inset || this.options.inset ) );
  5704. }
  5705. if ( hasCorners !== undefined ) {
  5706. elem.toggleClass( "ui-corner-all", hasCorners );
  5707. }
  5708. ret = this._super( options );
  5709. this.element.children( ":mobile-collapsible" ).collapsible( "refresh" );
  5710. return ret;
  5711. },
  5712. _destroy: function() {
  5713. var el = this.element;
  5714. this._removeFirstLastClasses( el.children( childCollapsiblesSelector ) );
  5715. el
  5716. .removeClass( "ui-collapsible-set ui-corner-all " +
  5717. this._themeClassFromOption( "ui-group-theme-", this.options.theme ) )
  5718. .children( ":mobile-collapsible" )
  5719. .collapsible( "destroy" );
  5720. },
  5721. _refresh: function( create ) {
  5722. var collapsiblesInSet = this.element.children( childCollapsiblesSelector );
  5723. this.element.find( $.mobile.collapsible.initSelector ).not( ".ui-collapsible" ).collapsible();
  5724. this._addFirstLastClasses( collapsiblesInSet, this._getVisibles( collapsiblesInSet, create ), create );
  5725. },
  5726. refresh: function() {
  5727. this._refresh( false );
  5728. }
  5729. }, $.mobile.behaviors.addFirstLastClasses ) );
  5730. })( jQuery );
  5731. (function( $, undefined ) {
  5732. // Deprecated in 1.4
  5733. $.fn.fieldcontain = function(/* options */) {
  5734. return this.addClass( "ui-field-contain" );
  5735. };
  5736. })( jQuery );
  5737. (function( $, undefined ) {
  5738. $.fn.grid = function( options ) {
  5739. return this.each(function() {
  5740. var $this = $( this ),
  5741. o = $.extend({
  5742. grid: null
  5743. }, options ),
  5744. $kids = $this.children(),
  5745. gridCols = { solo:1, a:2, b:3, c:4, d:5 },
  5746. grid = o.grid,
  5747. iterator,
  5748. letter;
  5749. if ( !grid ) {
  5750. if ( $kids.length <= 5 ) {
  5751. for ( letter in gridCols ) {
  5752. if ( gridCols[ letter ] === $kids.length ) {
  5753. grid = letter;
  5754. }
  5755. }
  5756. } else {
  5757. grid = "a";
  5758. $this.addClass( "ui-grid-duo" );
  5759. }
  5760. }
  5761. iterator = gridCols[grid];
  5762. $this.addClass( "ui-grid-" + grid );
  5763. $kids.filter( ":nth-child(" + iterator + "n+1)" ).addClass( "ui-block-a" );
  5764. if ( iterator > 1 ) {
  5765. $kids.filter( ":nth-child(" + iterator + "n+2)" ).addClass( "ui-block-b" );
  5766. }
  5767. if ( iterator > 2 ) {
  5768. $kids.filter( ":nth-child(" + iterator + "n+3)" ).addClass( "ui-block-c" );
  5769. }
  5770. if ( iterator > 3 ) {
  5771. $kids.filter( ":nth-child(" + iterator + "n+4)" ).addClass( "ui-block-d" );
  5772. }
  5773. if ( iterator > 4 ) {
  5774. $kids.filter( ":nth-child(" + iterator + "n+5)" ).addClass( "ui-block-e" );
  5775. }
  5776. });
  5777. };
  5778. })( jQuery );
  5779. (function( $, undefined ) {
  5780. $.widget( "mobile.navbar", {
  5781. options: {
  5782. iconpos: "top",
  5783. grid: null
  5784. },
  5785. _create: function() {
  5786. var $navbar = this.element,
  5787. $navbtns = $navbar.find( "a" ),
  5788. iconpos = $navbtns.filter( ":jqmData(icon)" ).length ? this.options.iconpos : undefined;
  5789. $navbar.addClass( "ui-navbar" )
  5790. .attr( "role", "navigation" )
  5791. .find( "ul" )
  5792. .jqmEnhanceable()
  5793. .grid({ grid: this.options.grid });
  5794. $navbtns
  5795. .each( function() {
  5796. var icon = $.mobile.getAttribute( this, "icon" ),
  5797. theme = $.mobile.getAttribute( this, "theme" ),
  5798. classes = "ui-btn";
  5799. if ( theme ) {
  5800. classes += " ui-btn-" + theme;
  5801. }
  5802. if ( icon ) {
  5803. classes += " ui-icon-" + icon + " ui-btn-icon-" + iconpos;
  5804. }
  5805. $( this ).addClass( classes );
  5806. });
  5807. $navbar.delegate( "a", "vclick", function( /* event */ ) {
  5808. var activeBtn = $( this );
  5809. if ( !( activeBtn.hasClass( "ui-state-disabled" ) ||
  5810. // DEPRECATED as of 1.4.0 - remove after 1.4.0 release
  5811. // only ui-state-disabled should be present thereafter
  5812. activeBtn.hasClass( "ui-disabled" ) ||
  5813. activeBtn.hasClass( $.mobile.activeBtnClass ) ) ) {
  5814. $navbtns.removeClass( $.mobile.activeBtnClass );
  5815. activeBtn.addClass( $.mobile.activeBtnClass );
  5816. // The code below is a workaround to fix #1181
  5817. $( document ).one( "pagehide", function() {
  5818. activeBtn.removeClass( $.mobile.activeBtnClass );
  5819. });
  5820. }
  5821. });
  5822. // Buttons in the navbar with ui-state-persist class should regain their active state before page show
  5823. $navbar.closest( ".ui-page" ).bind( "pagebeforeshow", function() {
  5824. $navbtns.filter( ".ui-state-persist" ).addClass( $.mobile.activeBtnClass );
  5825. });
  5826. }
  5827. });
  5828. })( jQuery );
  5829. (function( $, undefined ) {
  5830. var getAttr = $.mobile.getAttribute;
  5831. $.widget( "mobile.listview", $.extend( {
  5832. options: {
  5833. theme: null,
  5834. countTheme: null, /* Deprecated in 1.4 */
  5835. dividerTheme: null,
  5836. icon: "carat-r",
  5837. splitIcon: "carat-r",
  5838. splitTheme: null,
  5839. corners: true,
  5840. shadow: true,
  5841. inset: false
  5842. },
  5843. _create: function() {
  5844. var t = this,
  5845. listviewClasses = "";
  5846. listviewClasses += t.options.inset ? " ui-listview-inset" : "";
  5847. if ( !!t.options.inset ) {
  5848. listviewClasses += t.options.corners ? " ui-corner-all" : "";
  5849. listviewClasses += t.options.shadow ? " ui-shadow" : "";
  5850. }
  5851. // create listview markup
  5852. t.element.addClass( " ui-listview" + listviewClasses );
  5853. t.refresh( true );
  5854. },
  5855. // TODO: Remove in 1.5
  5856. _findFirstElementByTagName: function( ele, nextProp, lcName, ucName ) {
  5857. var dict = {};
  5858. dict[ lcName ] = dict[ ucName ] = true;
  5859. while ( ele ) {
  5860. if ( dict[ ele.nodeName ] ) {
  5861. return ele;
  5862. }
  5863. ele = ele[ nextProp ];
  5864. }
  5865. return null;
  5866. },
  5867. // TODO: Remove in 1.5
  5868. _addThumbClasses: function( containers ) {
  5869. var i, img, len = containers.length;
  5870. for ( i = 0; i < len; i++ ) {
  5871. img = $( this._findFirstElementByTagName( containers[ i ].firstChild, "nextSibling", "img", "IMG" ) );
  5872. if ( img.length ) {
  5873. $( this._findFirstElementByTagName( img[ 0 ].parentNode, "parentNode", "li", "LI" ) ).addClass( img.hasClass( "ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" );
  5874. }
  5875. }
  5876. },
  5877. _getChildrenByTagName: function( ele, lcName, ucName ) {
  5878. var results = [],
  5879. dict = {};
  5880. dict[ lcName ] = dict[ ucName ] = true;
  5881. ele = ele.firstChild;
  5882. while ( ele ) {
  5883. if ( dict[ ele.nodeName ] ) {
  5884. results.push( ele );
  5885. }
  5886. ele = ele.nextSibling;
  5887. }
  5888. return $( results );
  5889. },
  5890. _beforeListviewRefresh: $.noop,
  5891. _afterListviewRefresh: $.noop,
  5892. refresh: function( create ) {
  5893. var buttonClass, pos, numli, item, itemClass, itemTheme, itemIcon, icon, a,
  5894. isDivider, startCount, newStartCount, value, last, splittheme, splitThemeClass, spliticon,
  5895. altButtonClass, dividerTheme, li,
  5896. o = this.options,
  5897. $list = this.element,
  5898. ol = !!$.nodeName( $list[ 0 ], "ol" ),
  5899. start = $list.attr( "start" ),
  5900. itemClassDict = {},
  5901. countBubbles = $list.find( ".ui-li-count" ),
  5902. countTheme = getAttr( $list[ 0 ], "counttheme" ) || this.options.countTheme,
  5903. countThemeClass = countTheme ? "ui-body-" + countTheme : "ui-body-inherit";
  5904. if ( o.theme ) {
  5905. $list.addClass( "ui-group-theme-" + o.theme );
  5906. }
  5907. // Check if a start attribute has been set while taking a value of 0 into account
  5908. if ( ol && ( start || start === 0 ) ) {
  5909. startCount = parseInt( start, 10 ) - 1;
  5910. $list.css( "counter-reset", "listnumbering " + startCount );
  5911. }
  5912. this._beforeListviewRefresh();
  5913. li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" );
  5914. for ( pos = 0, numli = li.length; pos < numli; pos++ ) {
  5915. item = li.eq( pos );
  5916. itemClass = "";
  5917. if ( create || item[ 0 ].className.search( /\bui-li-static\b|\bui-li-divider\b/ ) < 0 ) {
  5918. a = this._getChildrenByTagName( item[ 0 ], "a", "A" );
  5919. isDivider = ( getAttr( item[ 0 ], "role" ) === "list-divider" );
  5920. value = item.attr( "value" );
  5921. itemTheme = getAttr( item[ 0 ], "theme" );
  5922. if ( a.length && a[ 0 ].className.search( /\bui-btn\b/ ) < 0 && !isDivider ) {
  5923. itemIcon = getAttr( item[ 0 ], "icon" );
  5924. icon = ( itemIcon === false ) ? false : ( itemIcon || o.icon );
  5925. // TODO: Remove in 1.5 together with links.js (links.js / .ui-link deprecated in 1.4)
  5926. a.removeClass( "ui-link" );
  5927. buttonClass = "ui-btn";
  5928. if ( itemTheme ) {
  5929. buttonClass += " ui-btn-" + itemTheme;
  5930. }
  5931. if ( a.length > 1 ) {
  5932. itemClass = "ui-li-has-alt";
  5933. last = a.last();
  5934. splittheme = getAttr( last[ 0 ], "theme" ) || o.splitTheme || getAttr( item[ 0 ], "theme", true );
  5935. splitThemeClass = splittheme ? " ui-btn-" + splittheme : "";
  5936. spliticon = getAttr( last[ 0 ], "icon" ) || getAttr( item[ 0 ], "icon" ) || o.splitIcon;
  5937. altButtonClass = "ui-btn ui-btn-icon-notext ui-icon-" + spliticon + splitThemeClass;
  5938. last
  5939. .attr( "title", $.trim( last.getEncodedText() ) )
  5940. .addClass( altButtonClass )
  5941. .empty();
  5942. } else if ( icon ) {
  5943. buttonClass += " ui-btn-icon-right ui-icon-" + icon;
  5944. }
  5945. a.first().addClass( buttonClass );
  5946. } else if ( isDivider ) {
  5947. dividerTheme = ( getAttr( item[ 0 ], "theme" ) || o.dividerTheme || o.theme );
  5948. itemClass = "ui-li-divider ui-bar-" + ( dividerTheme ? dividerTheme : "inherit" );
  5949. item.attr( "role", "heading" );
  5950. } else if ( a.length <= 0 ) {
  5951. itemClass = "ui-li-static ui-body-" + ( itemTheme ? itemTheme : "inherit" );
  5952. }
  5953. if ( ol && value ) {
  5954. newStartCount = parseInt( value , 10 ) - 1;
  5955. item.css( "counter-reset", "listnumbering " + newStartCount );
  5956. }
  5957. }
  5958. // Instead of setting item class directly on the list item
  5959. // at this point in time, push the item into a dictionary
  5960. // that tells us what class to set on it so we can do this after this
  5961. // processing loop is finished.
  5962. if ( !itemClassDict[ itemClass ] ) {
  5963. itemClassDict[ itemClass ] = [];
  5964. }
  5965. itemClassDict[ itemClass ].push( item[ 0 ] );
  5966. }
  5967. // Set the appropriate listview item classes on each list item.
  5968. // The main reason we didn't do this
  5969. // in the for-loop above is because we can eliminate per-item function overhead
  5970. // by calling addClass() and children() once or twice afterwards. This
  5971. // can give us a significant boost on platforms like WP7.5.
  5972. for ( itemClass in itemClassDict ) {
  5973. $( itemClassDict[ itemClass ] ).addClass( itemClass );
  5974. }
  5975. countBubbles.each( function() {
  5976. $( this ).closest( "li" ).addClass( "ui-li-has-count" );
  5977. });
  5978. if ( countThemeClass ) {
  5979. countBubbles.addClass( countThemeClass );
  5980. }
  5981. // Deprecated in 1.4. From 1.5 you have to add class ui-li-has-thumb or ui-li-has-icon to the LI.
  5982. this._addThumbClasses( li );
  5983. this._addThumbClasses( li.find( ".ui-btn" ) );
  5984. this._afterListviewRefresh();
  5985. this._addFirstLastClasses( li, this._getVisibles( li, create ), create );
  5986. }
  5987. }, $.mobile.behaviors.addFirstLastClasses ) );
  5988. })( jQuery );
  5989. (function( $, undefined ) {
  5990. function defaultAutodividersSelector( elt ) {
  5991. // look for the text in the given element
  5992. var text = $.trim( elt.text() ) || null;
  5993. if ( !text ) {
  5994. return null;
  5995. }
  5996. // create the text for the divider (first uppercased letter)
  5997. text = text.slice( 0, 1 ).toUpperCase();
  5998. return text;
  5999. }
  6000. $.widget( "mobile.listview", $.mobile.listview, {
  6001. options: {
  6002. autodividers: false,
  6003. autodividersSelector: defaultAutodividersSelector
  6004. },
  6005. _beforeListviewRefresh: function() {
  6006. if ( this.options.autodividers ) {
  6007. this._replaceDividers();
  6008. this._superApply( arguments );
  6009. }
  6010. },
  6011. _replaceDividers: function() {
  6012. var i, lis, li, dividerText,
  6013. lastDividerText = null,
  6014. list = this.element,
  6015. divider;
  6016. list.children( "li:jqmData(role='list-divider')" ).remove();
  6017. lis = list.children( "li" );
  6018. for ( i = 0; i < lis.length ; i++ ) {
  6019. li = lis[ i ];
  6020. dividerText = this.options.autodividersSelector( $( li ) );
  6021. if ( dividerText && lastDividerText !== dividerText ) {
  6022. divider = document.createElement( "li" );
  6023. divider.appendChild( document.createTextNode( dividerText ) );
  6024. divider.setAttribute( "data-" + $.mobile.ns + "role", "list-divider" );
  6025. li.parentNode.insertBefore( divider, li );
  6026. }
  6027. lastDividerText = dividerText;
  6028. }
  6029. }
  6030. });
  6031. })( jQuery );
  6032. (function( $, undefined ) {
  6033. var rdivider = /(^|\s)ui-li-divider($|\s)/,
  6034. rhidden = /(^|\s)ui-screen-hidden($|\s)/;
  6035. $.widget( "mobile.listview", $.mobile.listview, {
  6036. options: {
  6037. hideDividers: false
  6038. },
  6039. _afterListviewRefresh: function() {
  6040. var items, idx, item, hideDivider = true;
  6041. this._superApply( arguments );
  6042. if ( this.options.hideDividers ) {
  6043. items = this._getChildrenByTagName( this.element[ 0 ], "li", "LI" );
  6044. for ( idx = items.length - 1 ; idx > -1 ; idx-- ) {
  6045. item = items[ idx ];
  6046. if ( item.className.match( rdivider ) ) {
  6047. if ( hideDivider ) {
  6048. item.className = item.className + " ui-screen-hidden";
  6049. }
  6050. hideDivider = true;
  6051. } else {
  6052. if ( !item.className.match( rhidden ) ) {
  6053. hideDivider = false;
  6054. }
  6055. }
  6056. }
  6057. }
  6058. }
  6059. });
  6060. })( jQuery );
  6061. (function( $, undefined ) {
  6062. $.mobile.nojs = function( target ) {
  6063. $( ":jqmData(role='nojs')", target ).addClass( "ui-nojs" );
  6064. };
  6065. })( jQuery );
  6066. (function( $, undefined ) {
  6067. $.mobile.behaviors.formReset = {
  6068. _handleFormReset: function() {
  6069. this._on( this.element.closest( "form" ), {
  6070. reset: function() {
  6071. this._delay( "_reset" );
  6072. }
  6073. });
  6074. }
  6075. };
  6076. })( jQuery );
  6077. /*
  6078. * "checkboxradio" plugin
  6079. */
  6080. (function( $, undefined ) {
  6081. $.widget( "mobile.checkboxradio", $.extend( {
  6082. initSelector: "input:not( :jqmData(role='flipswitch' ) )[type='checkbox'],input[type='radio']:not( :jqmData(role='flipswitch' ))",
  6083. options: {
  6084. theme: "inherit",
  6085. mini: false,
  6086. wrapperClass: null,
  6087. enhanced: false,
  6088. iconpos: "left"
  6089. },
  6090. _create: function() {
  6091. var input = this.element,
  6092. o = this.options,
  6093. inheritAttr = function( input, dataAttr ) {
  6094. return input.jqmData( dataAttr ) ||
  6095. input.closest( "form, fieldset" ).jqmData( dataAttr );
  6096. },
  6097. // NOTE: Windows Phone could not find the label through a selector
  6098. // filter works though.
  6099. parentLabel = input.closest( "label" ),
  6100. label = parentLabel.length ? parentLabel :
  6101. input
  6102. .closest( "form, fieldset, :jqmData(role='page'), :jqmData(role='dialog')" )
  6103. .find( "label" )
  6104. .filter( "[for='" + $.mobile.path.hashToSelector( input[0].id ) + "']" )
  6105. .first(),
  6106. inputtype = input[0].type,
  6107. checkedClass = "ui-" + inputtype + "-on",
  6108. uncheckedClass = "ui-" + inputtype + "-off";
  6109. if ( inputtype !== "checkbox" && inputtype !== "radio" ) {
  6110. return;
  6111. }
  6112. if ( this.element[0].disabled ) {
  6113. this.options.disabled = true;
  6114. }
  6115. o.iconpos = inheritAttr( input, "iconpos" ) || label.attr( "data-" + $.mobile.ns + "iconpos" ) || o.iconpos,
  6116. // Establish options
  6117. o.mini = inheritAttr( input, "mini" ) || o.mini;
  6118. // Expose for other methods
  6119. $.extend( this, {
  6120. input: input,
  6121. label: label,
  6122. parentLabel: parentLabel,
  6123. inputtype: inputtype,
  6124. checkedClass: checkedClass,
  6125. uncheckedClass: uncheckedClass
  6126. });
  6127. if ( !this.options.enhanced ) {
  6128. this._enhance();
  6129. }
  6130. this._on( label, {
  6131. vmouseover: "_handleLabelVMouseOver",
  6132. vclick: "_handleLabelVClick"
  6133. });
  6134. this._on( input, {
  6135. vmousedown: "_cacheVals",
  6136. vclick: "_handleInputVClick",
  6137. focus: "_handleInputFocus",
  6138. blur: "_handleInputBlur"
  6139. });
  6140. this._handleFormReset();
  6141. this.refresh();
  6142. },
  6143. _enhance: function() {
  6144. this.label.addClass( "ui-btn ui-corner-all");
  6145. if ( this.parentLabel.length > 0 ) {
  6146. this.input.add( this.label ).wrapAll( this._wrapper() );
  6147. } else {
  6148. //this.element.replaceWith( this.input.add( this.label ).wrapAll( this._wrapper() ) );
  6149. this.element.wrap( this._wrapper() );
  6150. this.element.parent().prepend( this.label );
  6151. }
  6152. // Wrap the input + label in a div
  6153. this._setOptions({
  6154. "theme": this.options.theme,
  6155. "iconpos": this.options.iconpos,
  6156. "mini": this.options.mini
  6157. });
  6158. },
  6159. _wrapper: function() {
  6160. return $( "<div class='" +
  6161. ( this.options.wrapperClass ? this.options.wrapperClass : "" ) +
  6162. " ui-" + this.inputtype +
  6163. ( this.options.disabled ? " ui-state-disabled" : "" ) + "' >" );
  6164. },
  6165. _handleInputFocus: function() {
  6166. this.label.addClass( $.mobile.focusClass );
  6167. },
  6168. _handleInputBlur: function() {
  6169. this.label.removeClass( $.mobile.focusClass );
  6170. },
  6171. _handleInputVClick: function() {
  6172. var $this = this.element;
  6173. // Adds checked attribute to checked input when keyboard is used
  6174. if ( $this.is( ":checked" ) ) {
  6175. $this.prop( "checked", true);
  6176. this._getInputSet().not( $this ).prop( "checked", false );
  6177. } else {
  6178. $this.prop( "checked", false );
  6179. }
  6180. this._updateAll();
  6181. },
  6182. _handleLabelVMouseOver: function( event ) {
  6183. if ( this.label.parent().hasClass( "ui-state-disabled" ) ) {
  6184. event.stopPropagation();
  6185. }
  6186. },
  6187. _handleLabelVClick: function( event ) {
  6188. var input = this.element;
  6189. if ( input.is( ":disabled" ) ) {
  6190. event.preventDefault();
  6191. return;
  6192. }
  6193. this._cacheVals();
  6194. input.prop( "checked", this.inputtype === "radio" && true || !input.prop( "checked" ) );
  6195. // trigger click handler's bound directly to the input as a substitute for
  6196. // how label clicks behave normally in the browsers
  6197. // TODO: it would be nice to let the browser's handle the clicks and pass them
  6198. // through to the associate input. we can swallow that click at the parent
  6199. // wrapper element level
  6200. input.triggerHandler( "click" );
  6201. // Input set for common radio buttons will contain all the radio
  6202. // buttons, but will not for checkboxes. clearing the checked status
  6203. // of other radios ensures the active button state is applied properly
  6204. this._getInputSet().not( input ).prop( "checked", false );
  6205. this._updateAll();
  6206. return false;
  6207. },
  6208. _cacheVals: function() {
  6209. this._getInputSet().each( function() {
  6210. $( this ).attr("data-" + $.mobile.ns + "cacheVal", this.checked );
  6211. });
  6212. },
  6213. //returns either a set of radios with the same name attribute, or a single checkbox
  6214. _getInputSet: function() {
  6215. if ( this.inputtype === "checkbox" ) {
  6216. return this.element;
  6217. }
  6218. return this.element.closest( "form, :jqmData(role='page'), :jqmData(role='dialog')" )
  6219. .find( "input[name='" + this.element[ 0 ].name + "'][type='" + this.inputtype + "']" );
  6220. },
  6221. _updateAll: function() {
  6222. var self = this;
  6223. this._getInputSet().each( function() {
  6224. var $this = $( this );
  6225. if ( this.checked || self.inputtype === "checkbox" ) {
  6226. $this.trigger( "change" );
  6227. }
  6228. })
  6229. .checkboxradio( "refresh" );
  6230. },
  6231. _reset: function() {
  6232. this.refresh();
  6233. },
  6234. // Is the widget supposed to display an icon?
  6235. _hasIcon: function() {
  6236. var controlgroup, controlgroupWidget,
  6237. controlgroupConstructor = $.mobile.controlgroup;
  6238. // If the controlgroup widget is defined ...
  6239. if ( controlgroupConstructor ) {
  6240. controlgroup = this.element.closest(
  6241. ":mobile-controlgroup," +
  6242. controlgroupConstructor.prototype.initSelector );
  6243. // ... and the checkbox is in a controlgroup ...
  6244. if ( controlgroup.length > 0 ) {
  6245. // ... look for a controlgroup widget instance, and ...
  6246. controlgroupWidget = $.data( controlgroup[ 0 ], "mobile-controlgroup" );
  6247. // ... if found, decide based on the option value, ...
  6248. return ( ( controlgroupWidget ? controlgroupWidget.options.type :
  6249. // ... otherwise decide based on the "type" data attribute.
  6250. controlgroup.attr( "data-" + $.mobile.ns + "type" ) ) !== "horizontal" );
  6251. }
  6252. }
  6253. // Normally, the widget displays an icon.
  6254. return true;
  6255. },
  6256. refresh: function() {
  6257. var hasIcon = this._hasIcon(),
  6258. isChecked = this.element[ 0 ].checked,
  6259. active = $.mobile.activeBtnClass,
  6260. iconposClass = "ui-btn-icon-" + this.options.iconpos,
  6261. addClasses = [],
  6262. removeClasses = [];
  6263. if ( hasIcon ) {
  6264. removeClasses.push( active );
  6265. addClasses.push( iconposClass );
  6266. } else {
  6267. removeClasses.push( iconposClass );
  6268. ( isChecked ? addClasses : removeClasses ).push( active );
  6269. }
  6270. if ( isChecked ) {
  6271. addClasses.push( this.checkedClass );
  6272. removeClasses.push( this.uncheckedClass );
  6273. } else {
  6274. addClasses.push( this.uncheckedClass );
  6275. removeClasses.push( this.checkedClass );
  6276. }
  6277. this.label
  6278. .addClass( addClasses.join( " " ) )
  6279. .removeClass( removeClasses.join( " " ) );
  6280. },
  6281. widget: function() {
  6282. return this.label.parent();
  6283. },
  6284. _setOptions: function( options ) {
  6285. var label = this.label,
  6286. currentOptions = this.options,
  6287. outer = this.widget(),
  6288. hasIcon = this._hasIcon();
  6289. if ( options.disabled !== undefined ) {
  6290. this.input.prop( "disabled", !!options.disabled );
  6291. outer.toggleClass( "ui-state-disabled", !!options.disabled );
  6292. }
  6293. if ( options.mini !== undefined ) {
  6294. outer.toggleClass( "ui-mini", !!options.mini );
  6295. }
  6296. if ( options.theme !== undefined ) {
  6297. label
  6298. .removeClass( "ui-btn-" + currentOptions.theme )
  6299. .addClass( "ui-btn-" + options.theme );
  6300. }
  6301. if ( options.wrapperClass !== undefined ) {
  6302. outer
  6303. .removeClass( currentOptions.wrapperClass )
  6304. .addClass( options.wrapperClass );
  6305. }
  6306. if ( options.iconpos !== undefined && hasIcon ) {
  6307. label.removeClass( "ui-btn-icon-" + currentOptions.iconpos ).addClass( "ui-btn-icon-" + options.iconpos );
  6308. } else if ( !hasIcon ) {
  6309. label.removeClass( "ui-btn-icon-" + currentOptions.iconpos );
  6310. }
  6311. this._super( options );
  6312. }
  6313. }, $.mobile.behaviors.formReset ) );
  6314. })( jQuery );
  6315. (function( $, undefined ) {
  6316. $.widget( "mobile.button", {
  6317. initSelector: "input[type='button'], input[type='submit'], input[type='reset']",
  6318. options: {
  6319. theme: null,
  6320. icon: null,
  6321. iconpos: "left",
  6322. iconshadow: false, /* TODO: Deprecated in 1.4, remove in 1.5. */
  6323. corners: true,
  6324. shadow: true,
  6325. inline: null,
  6326. mini: null,
  6327. wrapperClass: null,
  6328. enhanced: false
  6329. },
  6330. _create: function() {
  6331. if ( this.element.is( ":disabled" ) ) {
  6332. this.options.disabled = true;
  6333. }
  6334. if ( !this.options.enhanced ) {
  6335. this._enhance();
  6336. }
  6337. $.extend( this, {
  6338. wrapper: this.element.parent()
  6339. });
  6340. this._on( {
  6341. focus: function() {
  6342. this.widget().addClass( $.mobile.focusClass );
  6343. },
  6344. blur: function() {
  6345. this.widget().removeClass( $.mobile.focusClass );
  6346. }
  6347. });
  6348. this.refresh( true );
  6349. },
  6350. _enhance: function() {
  6351. this.element.wrap( this._button() );
  6352. },
  6353. _button: function() {
  6354. var options = this.options,
  6355. iconClasses = this._getIconClasses( this.options );
  6356. return $("<div class='ui-btn ui-input-btn" +
  6357. ( options.wrapperClass ? " " + options.wrapperClass : "" ) +
  6358. ( options.theme ? " ui-btn-" + options.theme : "" ) +
  6359. ( options.corners ? " ui-corner-all" : "" ) +
  6360. ( options.shadow ? " ui-shadow" : "" ) +
  6361. ( options.inline ? " ui-btn-inline" : "" ) +
  6362. ( options.mini ? " ui-mini" : "" ) +
  6363. ( options.disabled ? " ui-state-disabled" : "" ) +
  6364. ( iconClasses ? ( " " + iconClasses ) : "" ) +
  6365. "' >" + this.element.val() + "</div>" );
  6366. },
  6367. widget: function() {
  6368. return this.wrapper;
  6369. },
  6370. _destroy: function() {
  6371. this.element.insertBefore( this.button );
  6372. this.button.remove();
  6373. },
  6374. _getIconClasses: function( options ) {
  6375. return ( options.icon ? ( "ui-icon-" + options.icon +
  6376. ( options.iconshadow ? " ui-shadow-icon" : "" ) + /* TODO: Deprecated in 1.4, remove in 1.5. */
  6377. " ui-btn-icon-" + options.iconpos ) : "" );
  6378. },
  6379. _setOptions: function( options ) {
  6380. var outer = this.widget();
  6381. if ( options.theme !== undefined ) {
  6382. outer
  6383. .removeClass( this.options.theme )
  6384. .addClass( "ui-btn-" + options.theme );
  6385. }
  6386. if ( options.corners !== undefined ) {
  6387. outer.toggleClass( "ui-corner-all", options.corners );
  6388. }
  6389. if ( options.shadow !== undefined ) {
  6390. outer.toggleClass( "ui-shadow", options.shadow );
  6391. }
  6392. if ( options.inline !== undefined ) {
  6393. outer.toggleClass( "ui-btn-inline", options.inline );
  6394. }
  6395. if ( options.mini !== undefined ) {
  6396. outer.toggleClass( "ui-mini", options.mini );
  6397. }
  6398. if ( options.disabled !== undefined ) {
  6399. this.element.prop( "disabled", options.disabled );
  6400. outer.toggleClass( "ui-state-disabled", options.disabled );
  6401. }
  6402. if ( options.icon !== undefined ||
  6403. options.iconshadow !== undefined || /* TODO: Deprecated in 1.4, remove in 1.5. */
  6404. options.iconpos !== undefined ) {
  6405. outer
  6406. .removeClass( this._getIconClasses( this.options ) )
  6407. .addClass( this._getIconClasses(
  6408. $.extend( {}, this.options, options ) ) );
  6409. }
  6410. this._super( options );
  6411. },
  6412. refresh: function( create ) {
  6413. if ( this.options.icon && this.options.iconpos === "notext" && this.element.attr( "title" ) ) {
  6414. this.element.attr( "title", this.element.val() );
  6415. }
  6416. if ( !create ) {
  6417. var originalElement = this.element.detach();
  6418. $( this.wrapper ).text( this.element.val() ).append( originalElement );
  6419. }
  6420. }
  6421. });
  6422. })( jQuery );
  6423. (function( $ ) {
  6424. var meta = $( "meta[name=viewport]" ),
  6425. initialContent = meta.attr( "content" ),
  6426. disabledZoom = initialContent + ",maximum-scale=1, user-scalable=no",
  6427. enabledZoom = initialContent + ",maximum-scale=10, user-scalable=yes",
  6428. disabledInitially = /(user-scalable[\s]*=[\s]*no)|(maximum-scale[\s]*=[\s]*1)[$,\s]/.test( initialContent );
  6429. $.mobile.zoom = $.extend( {}, {
  6430. enabled: !disabledInitially,
  6431. locked: false,
  6432. disable: function( lock ) {
  6433. if ( !disabledInitially && !$.mobile.zoom.locked ) {
  6434. meta.attr( "content", disabledZoom );
  6435. $.mobile.zoom.enabled = false;
  6436. $.mobile.zoom.locked = lock || false;
  6437. }
  6438. },
  6439. enable: function( unlock ) {
  6440. if ( !disabledInitially && ( !$.mobile.zoom.locked || unlock === true ) ) {
  6441. meta.attr( "content", enabledZoom );
  6442. $.mobile.zoom.enabled = true;
  6443. $.mobile.zoom.locked = false;
  6444. }
  6445. },
  6446. restore: function() {
  6447. if ( !disabledInitially ) {
  6448. meta.attr( "content", initialContent );
  6449. $.mobile.zoom.enabled = true;
  6450. }
  6451. }
  6452. });
  6453. }( jQuery ));
  6454. (function( $, undefined ) {
  6455. $.widget( "mobile.textinput", {
  6456. initSelector: "input[type='text']," +
  6457. "input[type='search']," +
  6458. ":jqmData(type='search')," +
  6459. "input[type='number']," +
  6460. ":jqmData(type='number')," +
  6461. "input[type='password']," +
  6462. "input[type='email']," +
  6463. "input[type='url']," +
  6464. "input[type='tel']," +
  6465. "textarea," +
  6466. "input[type='time']," +
  6467. "input[type='date']," +
  6468. "input[type='month']," +
  6469. "input[type='week']," +
  6470. "input[type='datetime']," +
  6471. "input[type='datetime-local']," +
  6472. "input[type='color']," +
  6473. "input:not([type])," +
  6474. "input[type='file']",
  6475. options: {
  6476. theme: null,
  6477. corners: true,
  6478. mini: false,
  6479. // This option defaults to true on iOS devices.
  6480. preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
  6481. wrapperClass: "",
  6482. enhanced: false
  6483. },
  6484. _create: function() {
  6485. var options = this.options,
  6486. isSearch = this.element.is( "[type='search'], :jqmData(type='search')" ),
  6487. isTextarea = this.element[ 0 ].tagName === "TEXTAREA",
  6488. isRange = this.element.is( "[data-" + ( $.mobile.ns || "" ) + "type='range']" ),
  6489. inputNeedsWrap = ( (this.element.is( "input" ) ||
  6490. this.element.is( "[data-" + ( $.mobile.ns || "" ) + "type='search']" ) ) &&
  6491. !isRange );
  6492. if ( this.element.prop( "disabled" ) ) {
  6493. options.disabled = true;
  6494. }
  6495. $.extend( this, {
  6496. classes: this._classesFromOptions(),
  6497. isSearch: isSearch,
  6498. isTextarea: isTextarea,
  6499. isRange: isRange,
  6500. inputNeedsWrap: inputNeedsWrap
  6501. });
  6502. this._autoCorrect();
  6503. if ( !options.enhanced ) {
  6504. this._enhance();
  6505. }
  6506. this._on( {
  6507. "focus": "_handleFocus",
  6508. "blur": "_handleBlur"
  6509. });
  6510. },
  6511. refresh: function() {
  6512. this.setOptions({
  6513. "disabled" : this.element.is( ":disabled" )
  6514. });
  6515. },
  6516. _enhance: function() {
  6517. var elementClasses = [];
  6518. if ( this.isTextarea ) {
  6519. elementClasses.push( "ui-input-text" );
  6520. }
  6521. if ( this.isTextarea || this.isRange ) {
  6522. elementClasses.push( "ui-shadow-inset" );
  6523. }
  6524. //"search" and "text" input widgets
  6525. if ( this.inputNeedsWrap ) {
  6526. this.element.wrap( this._wrap() );
  6527. } else {
  6528. elementClasses = elementClasses.concat( this.classes );
  6529. }
  6530. this.element.addClass( elementClasses.join( " " ) );
  6531. },
  6532. widget: function() {
  6533. return ( this.inputNeedsWrap ) ? this.element.parent() : this.element;
  6534. },
  6535. _classesFromOptions: function() {
  6536. var options = this.options,
  6537. classes = [];
  6538. classes.push( "ui-body-" + ( ( options.theme === null ) ? "inherit" : options.theme ) );
  6539. if ( options.corners ) {
  6540. classes.push( "ui-corner-all" );
  6541. }
  6542. if ( options.mini ) {
  6543. classes.push( "ui-mini" );
  6544. }
  6545. if ( options.disabled ) {
  6546. classes.push( "ui-state-disabled" );
  6547. }
  6548. if ( options.wrapperClass ) {
  6549. classes.push( options.wrapperClass );
  6550. }
  6551. return classes;
  6552. },
  6553. _wrap: function() {
  6554. return $( "<div class='" +
  6555. ( this.isSearch ? "ui-input-search " : "ui-input-text " ) +
  6556. this.classes.join( " " ) + " " +
  6557. "ui-shadow-inset'></div>" );
  6558. },
  6559. _autoCorrect: function() {
  6560. // XXX: Temporary workaround for issue 785 (Apple bug 8910589).
  6561. // Turn off autocorrect and autocomplete on non-iOS 5 devices
  6562. // since the popup they use can't be dismissed by the user. Note
  6563. // that we test for the presence of the feature by looking for
  6564. // the autocorrect property on the input element. We currently
  6565. // have no test for iOS 5 or newer so we're temporarily using
  6566. // the touchOverflow support flag for jQM 1.0. Yes, I feel dirty.
  6567. // - jblas
  6568. if ( typeof this.element[0].autocorrect !== "undefined" &&
  6569. !$.support.touchOverflow ) {
  6570. // Set the attribute instead of the property just in case there
  6571. // is code that attempts to make modifications via HTML.
  6572. this.element[0].setAttribute( "autocorrect", "off" );
  6573. this.element[0].setAttribute( "autocomplete", "off" );
  6574. }
  6575. },
  6576. _handleBlur: function() {
  6577. this.widget().removeClass( $.mobile.focusClass );
  6578. if ( this.options.preventFocusZoom ) {
  6579. $.mobile.zoom.enable( true );
  6580. }
  6581. },
  6582. _handleFocus: function() {
  6583. // In many situations, iOS will zoom into the input upon tap, this
  6584. // prevents that from happening
  6585. if ( this.options.preventFocusZoom ) {
  6586. $.mobile.zoom.disable( true );
  6587. }
  6588. this.widget().addClass( $.mobile.focusClass );
  6589. },
  6590. _setOptions: function ( options ) {
  6591. var outer = this.widget();
  6592. this._super( options );
  6593. if ( !( options.disabled === undefined &&
  6594. options.mini === undefined &&
  6595. options.corners === undefined &&
  6596. options.theme === undefined &&
  6597. options.wrapperClass === undefined ) ) {
  6598. outer.removeClass( this.classes.join( " " ) );
  6599. this.classes = this._classesFromOptions();
  6600. outer.addClass( this.classes.join( " " ) );
  6601. }
  6602. if ( options.disabled !== undefined ) {
  6603. this.element.prop( "disabled", !!options.disabled );
  6604. }
  6605. },
  6606. _destroy: function() {
  6607. if ( this.options.enhanced ) {
  6608. return;
  6609. }
  6610. if ( this.inputNeedsWrap ) {
  6611. this.element.unwrap();
  6612. }
  6613. this.element.removeClass( "ui-input-text " + this.classes.join( " " ) );
  6614. }
  6615. });
  6616. })( jQuery );
  6617. (function( $, undefined ) {
  6618. $.widget( "mobile.slider", $.extend( {
  6619. initSelector: "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')",
  6620. widgetEventPrefix: "slide",
  6621. options: {
  6622. theme: null,
  6623. trackTheme: null,
  6624. corners: true,
  6625. mini: false,
  6626. highlight: false
  6627. },
  6628. _create: function() {
  6629. // TODO: Each of these should have comments explain what they're for
  6630. var self = this,
  6631. control = this.element,
  6632. trackTheme = this.options.trackTheme || $.mobile.getAttribute( control[ 0 ], "theme" ),
  6633. trackThemeClass = trackTheme ? " ui-bar-" + trackTheme : " ui-bar-inherit",
  6634. cornerClass = ( this.options.corners || control.jqmData( "corners" ) ) ? " ui-corner-all" : "",
  6635. miniClass = ( this.options.mini || control.jqmData( "mini" ) ) ? " ui-mini" : "",
  6636. cType = control[ 0 ].nodeName.toLowerCase(),
  6637. isToggleSwitch = ( cType === "select" ),
  6638. isRangeslider = control.parent().is( ":jqmData(role='rangeslider')" ),
  6639. selectClass = ( isToggleSwitch ) ? "ui-slider-switch" : "",
  6640. controlID = control.attr( "id" ),
  6641. $label = $( "[for='" + controlID + "']" ),
  6642. labelID = $label.attr( "id" ) || controlID + "-label",
  6643. min = !isToggleSwitch ? parseFloat( control.attr( "min" ) ) : 0,
  6644. max = !isToggleSwitch ? parseFloat( control.attr( "max" ) ) : control.find( "option" ).length-1,
  6645. step = window.parseFloat( control.attr( "step" ) || 1 ),
  6646. domHandle = document.createElement( "a" ),
  6647. handle = $( domHandle ),
  6648. domSlider = document.createElement( "div" ),
  6649. slider = $( domSlider ),
  6650. valuebg = this.options.highlight && !isToggleSwitch ? (function() {
  6651. var bg = document.createElement( "div" );
  6652. bg.className = "ui-slider-bg " + $.mobile.activeBtnClass;
  6653. return $( bg ).prependTo( slider );
  6654. })() : false,
  6655. options,
  6656. wrapper,
  6657. j, length,
  6658. i, optionsCount, origTabIndex,
  6659. side, activeClass, sliderImg;
  6660. $label.attr( "id", labelID );
  6661. this.isToggleSwitch = isToggleSwitch;
  6662. domHandle.setAttribute( "href", "#" );
  6663. domSlider.setAttribute( "role", "application" );
  6664. domSlider.className = [ this.isToggleSwitch ? "ui-slider ui-slider-track ui-shadow-inset " : "ui-slider-track ui-shadow-inset ", selectClass, trackThemeClass, cornerClass, miniClass ].join( "" );
  6665. domHandle.className = "ui-slider-handle";
  6666. domSlider.appendChild( domHandle );
  6667. handle.attr({
  6668. "role": "slider",
  6669. "aria-valuemin": min,
  6670. "aria-valuemax": max,
  6671. "aria-valuenow": this._value(),
  6672. "aria-valuetext": this._value(),
  6673. "title": this._value(),
  6674. "aria-labelledby": labelID
  6675. });
  6676. $.extend( this, {
  6677. slider: slider,
  6678. handle: handle,
  6679. control: control,
  6680. type: cType,
  6681. step: step,
  6682. max: max,
  6683. min: min,
  6684. valuebg: valuebg,
  6685. isRangeslider: isRangeslider,
  6686. dragging: false,
  6687. beforeStart: null,
  6688. userModified: false,
  6689. mouseMoved: false
  6690. });
  6691. if ( isToggleSwitch ) {
  6692. // TODO: restore original tabindex (if any) in a destroy method
  6693. origTabIndex = control.attr( "tabindex" );
  6694. if ( origTabIndex ) {
  6695. handle.attr( "tabindex", origTabIndex );
  6696. }
  6697. control.attr( "tabindex", "-1" ).focus(function() {
  6698. $( this ).blur();
  6699. handle.focus();
  6700. });
  6701. wrapper = document.createElement( "div" );
  6702. wrapper.className = "ui-slider-inneroffset";
  6703. for ( j = 0, length = domSlider.childNodes.length; j < length; j++ ) {
  6704. wrapper.appendChild( domSlider.childNodes[j] );
  6705. }
  6706. domSlider.appendChild( wrapper );
  6707. // slider.wrapInner( "<div class='ui-slider-inneroffset'></div>" );
  6708. // make the handle move with a smooth transition
  6709. handle.addClass( "ui-slider-handle-snapping" );
  6710. options = control.find( "option" );
  6711. for ( i = 0, optionsCount = options.length; i < optionsCount; i++ ) {
  6712. side = !i ? "b" : "a";
  6713. activeClass = !i ? "" : " " + $.mobile.activeBtnClass;
  6714. sliderImg = document.createElement( "span" );
  6715. sliderImg.className = [ "ui-slider-label ui-slider-label-", side, activeClass ].join( "" );
  6716. sliderImg.setAttribute( "role", "img" );
  6717. sliderImg.appendChild( document.createTextNode( options[i].innerHTML ) );
  6718. $( sliderImg ).prependTo( slider );
  6719. }
  6720. self._labels = $( ".ui-slider-label", slider );
  6721. }
  6722. // monitor the input for updated values
  6723. control.addClass( isToggleSwitch ? "ui-slider-switch" : "ui-slider-input" );
  6724. this._on( control, {
  6725. "change": "_controlChange",
  6726. "keyup": "_controlKeyup",
  6727. "blur": "_controlBlur",
  6728. "vmouseup": "_controlVMouseUp"
  6729. });
  6730. slider.bind( "vmousedown", $.proxy( this._sliderVMouseDown, this ) )
  6731. .bind( "vclick", false );
  6732. // We have to instantiate a new function object for the unbind to work properly
  6733. // since the method itself is defined in the prototype (causing it to unbind everything)
  6734. this._on( document, { "vmousemove": "_preventDocumentDrag" });
  6735. this._on( slider.add( document ), { "vmouseup": "_sliderVMouseUp" });
  6736. slider.insertAfter( control );
  6737. // wrap in a div for styling purposes
  6738. if ( !isToggleSwitch && !isRangeslider ) {
  6739. wrapper = this.options.mini ? "<div class='ui-slider ui-mini'>" : "<div class='ui-slider'>";
  6740. control.add( slider ).wrapAll( wrapper );
  6741. }
  6742. // bind the handle event callbacks and set the context to the widget instance
  6743. this._on( this.handle, {
  6744. "vmousedown": "_handleVMouseDown",
  6745. "keydown": "_handleKeydown",
  6746. "keyup": "_handleKeyup"
  6747. });
  6748. this.handle.bind( "vclick", false );
  6749. this._handleFormReset();
  6750. this.refresh( undefined, undefined, true );
  6751. },
  6752. _setOptions: function( options ) {
  6753. if ( options.theme !== undefined ) {
  6754. this._setTheme( options.theme );
  6755. }
  6756. if ( options.trackTheme !== undefined ) {
  6757. this._setTrackTheme( options.trackTheme );
  6758. }
  6759. if ( options.corners !== undefined ) {
  6760. this._setCorners( options.corners );
  6761. }
  6762. if ( options.mini !== undefined ) {
  6763. this._setMini( options.mini );
  6764. }
  6765. if ( options.highlight !== undefined ) {
  6766. this._setHighlight( options.highlight );
  6767. }
  6768. if ( options.disabled !== undefined ) {
  6769. this._setDisabled( options.disabled );
  6770. }
  6771. this._super( options );
  6772. },
  6773. _controlChange: function( event ) {
  6774. // if the user dragged the handle, the "change" event was triggered from inside refresh(); don't call refresh() again
  6775. if ( this._trigger( "controlchange", event ) === false ) {
  6776. return false;
  6777. }
  6778. if ( !this.mouseMoved ) {
  6779. this.refresh( this._value(), true );
  6780. }
  6781. },
  6782. _controlKeyup: function(/* event */) { // necessary?
  6783. this.refresh( this._value(), true, true );
  6784. },
  6785. _controlBlur: function(/* event */) {
  6786. this.refresh( this._value(), true );
  6787. },
  6788. // it appears the clicking the up and down buttons in chrome on
  6789. // range/number inputs doesn't trigger a change until the field is
  6790. // blurred. Here we check thif the value has changed and refresh
  6791. _controlVMouseUp: function(/* event */) {
  6792. this._checkedRefresh();
  6793. },
  6794. // NOTE force focus on handle
  6795. _handleVMouseDown: function(/* event */) {
  6796. this.handle.focus();
  6797. },
  6798. _handleKeydown: function( event ) {
  6799. var index = this._value();
  6800. if ( this.options.disabled ) {
  6801. return;
  6802. }
  6803. // In all cases prevent the default and mark the handle as active
  6804. switch ( event.keyCode ) {
  6805. case $.mobile.keyCode.HOME:
  6806. case $.mobile.keyCode.END:
  6807. case $.mobile.keyCode.PAGE_UP:
  6808. case $.mobile.keyCode.PAGE_DOWN:
  6809. case $.mobile.keyCode.UP:
  6810. case $.mobile.keyCode.RIGHT:
  6811. case $.mobile.keyCode.DOWN:
  6812. case $.mobile.keyCode.LEFT:
  6813. event.preventDefault();
  6814. if ( !this._keySliding ) {
  6815. this._keySliding = true;
  6816. this.handle.addClass( "ui-state-active" ); /* TODO: We don't use this class for styling. Do we need to add it? */
  6817. }
  6818. break;
  6819. }
  6820. // move the slider according to the keypress
  6821. switch ( event.keyCode ) {
  6822. case $.mobile.keyCode.HOME:
  6823. this.refresh( this.min );
  6824. break;
  6825. case $.mobile.keyCode.END:
  6826. this.refresh( this.max );
  6827. break;
  6828. case $.mobile.keyCode.PAGE_UP:
  6829. case $.mobile.keyCode.UP:
  6830. case $.mobile.keyCode.RIGHT:
  6831. this.refresh( index + this.step );
  6832. break;
  6833. case $.mobile.keyCode.PAGE_DOWN:
  6834. case $.mobile.keyCode.DOWN:
  6835. case $.mobile.keyCode.LEFT:
  6836. this.refresh( index - this.step );
  6837. break;
  6838. }
  6839. }, // remove active mark
  6840. _handleKeyup: function(/* event */) {
  6841. if ( this._keySliding ) {
  6842. this._keySliding = false;
  6843. this.handle.removeClass( "ui-state-active" ); /* See comment above. */
  6844. }
  6845. },
  6846. _sliderVMouseDown: function( event ) {
  6847. // NOTE: we don't do this in refresh because we still want to
  6848. // support programmatic alteration of disabled inputs
  6849. if ( this.options.disabled || !( event.which === 1 || event.which === 0 || event.which === undefined ) ) {
  6850. return false;
  6851. }
  6852. if ( this._trigger( "beforestart", event ) === false ) {
  6853. return false;
  6854. }
  6855. this.dragging = true;
  6856. this.userModified = false;
  6857. this.mouseMoved = false;
  6858. if ( this.isToggleSwitch ) {
  6859. this.beforeStart = this.element[0].selectedIndex;
  6860. }
  6861. this.refresh( event );
  6862. this._trigger( "start" );
  6863. return false;
  6864. },
  6865. _sliderVMouseUp: function() {
  6866. if ( this.dragging ) {
  6867. this.dragging = false;
  6868. if ( this.isToggleSwitch ) {
  6869. // make the handle move with a smooth transition
  6870. this.handle.addClass( "ui-slider-handle-snapping" );
  6871. if ( this.mouseMoved ) {
  6872. // this is a drag, change the value only if user dragged enough
  6873. if ( this.userModified ) {
  6874. this.refresh( this.beforeStart === 0 ? 1 : 0 );
  6875. } else {
  6876. this.refresh( this.beforeStart );
  6877. }
  6878. } else {
  6879. // this is just a click, change the value
  6880. this.refresh( this.beforeStart === 0 ? 1 : 0 );
  6881. }
  6882. }
  6883. this.mouseMoved = false;
  6884. this._trigger( "stop" );
  6885. return false;
  6886. }
  6887. },
  6888. _preventDocumentDrag: function( event ) {
  6889. // NOTE: we don't do this in refresh because we still want to
  6890. // support programmatic alteration of disabled inputs
  6891. if ( this._trigger( "drag", event ) === false) {
  6892. return false;
  6893. }
  6894. if ( this.dragging && !this.options.disabled ) {
  6895. // this.mouseMoved must be updated before refresh() because it will be used in the control "change" event
  6896. this.mouseMoved = true;
  6897. if ( this.isToggleSwitch ) {
  6898. // make the handle move in sync with the mouse
  6899. this.handle.removeClass( "ui-slider-handle-snapping" );
  6900. }
  6901. this.refresh( event );
  6902. // only after refresh() you can calculate this.userModified
  6903. this.userModified = this.beforeStart !== this.element[0].selectedIndex;
  6904. return false;
  6905. }
  6906. },
  6907. _checkedRefresh: function() {
  6908. if ( this.value !== this._value() ) {
  6909. this.refresh( this._value() );
  6910. }
  6911. },
  6912. _value: function() {
  6913. return this.isToggleSwitch ? this.element[0].selectedIndex : parseFloat( this.element.val() ) ;
  6914. },
  6915. _reset: function() {
  6916. this.refresh( undefined, false, true );
  6917. },
  6918. refresh: function( val, isfromControl, preventInputUpdate ) {
  6919. // NOTE: we don't return here because we want to support programmatic
  6920. // alteration of the input value, which should still update the slider
  6921. var self = this,
  6922. parentTheme = $.mobile.getAttribute( this.element[ 0 ], "theme" ),
  6923. theme = this.options.theme || parentTheme,
  6924. themeClass = theme ? " ui-btn-" + theme : "",
  6925. trackTheme = this.options.trackTheme || parentTheme,
  6926. trackThemeClass = trackTheme ? " ui-bar-" + trackTheme : " ui-bar-inherit",
  6927. cornerClass = this.options.corners ? " ui-corner-all" : "",
  6928. miniClass = this.options.mini ? " ui-mini" : "",
  6929. left, width, data, tol,
  6930. pxStep, percent,
  6931. control, isInput, optionElements, min, max, step,
  6932. newval, valModStep, alignValue, percentPerStep,
  6933. handlePercent, aPercent, bPercent,
  6934. valueChanged;
  6935. self.slider[0].className = [ this.isToggleSwitch ? "ui-slider ui-slider-switch ui-slider-track ui-shadow-inset" : "ui-slider-track ui-shadow-inset", trackThemeClass, cornerClass, miniClass ].join( "" );
  6936. if ( this.options.disabled || this.element.prop( "disabled" ) ) {
  6937. this.disable();
  6938. }
  6939. // set the stored value for comparison later
  6940. this.value = this._value();
  6941. if ( this.options.highlight && !this.isToggleSwitch && this.slider.find( ".ui-slider-bg" ).length === 0 ) {
  6942. this.valuebg = (function() {
  6943. var bg = document.createElement( "div" );
  6944. bg.className = "ui-slider-bg " + $.mobile.activeBtnClass;
  6945. return $( bg ).prependTo( self.slider );
  6946. })();
  6947. }
  6948. this.handle.addClass( "ui-btn" + themeClass + " ui-shadow" );
  6949. control = this.element;
  6950. isInput = !this.isToggleSwitch;
  6951. optionElements = isInput ? [] : control.find( "option" );
  6952. min = isInput ? parseFloat( control.attr( "min" ) ) : 0;
  6953. max = isInput ? parseFloat( control.attr( "max" ) ) : optionElements.length - 1;
  6954. step = ( isInput && parseFloat( control.attr( "step" ) ) > 0 ) ? parseFloat( control.attr( "step" ) ) : 1;
  6955. if ( typeof val === "object" ) {
  6956. data = val;
  6957. // a slight tolerance helped get to the ends of the slider
  6958. tol = 8;
  6959. left = this.slider.offset().left;
  6960. width = this.slider.width();
  6961. pxStep = width/((max-min)/step);
  6962. if ( !this.dragging ||
  6963. data.pageX < left - tol ||
  6964. data.pageX > left + width + tol ) {
  6965. return;
  6966. }
  6967. if ( pxStep > 1 ) {
  6968. percent = ( ( data.pageX - left ) / width ) * 100;
  6969. } else {
  6970. percent = Math.round( ( ( data.pageX - left ) / width ) * 100 );
  6971. }
  6972. } else {
  6973. if ( val == null ) {
  6974. val = isInput ? parseFloat( control.val() || 0 ) : control[0].selectedIndex;
  6975. }
  6976. percent = ( parseFloat( val ) - min ) / ( max - min ) * 100;
  6977. }
  6978. if ( isNaN( percent ) ) {
  6979. return;
  6980. }
  6981. newval = ( percent / 100 ) * ( max - min ) + min;
  6982. //from jQuery UI slider, the following source will round to the nearest step
  6983. valModStep = ( newval - min ) % step;
  6984. alignValue = newval - valModStep;
  6985. if ( Math.abs( valModStep ) * 2 >= step ) {
  6986. alignValue += ( valModStep > 0 ) ? step : ( -step );
  6987. }
  6988. percentPerStep = 100/((max-min)/step);
  6989. // Since JavaScript has problems with large floats, round
  6990. // the final value to 5 digits after the decimal point (see jQueryUI: #4124)
  6991. newval = parseFloat( alignValue.toFixed(5) );
  6992. if ( typeof pxStep === "undefined" ) {
  6993. pxStep = width / ( (max-min) / step );
  6994. }
  6995. if ( pxStep > 1 && isInput ) {
  6996. percent = ( newval - min ) * percentPerStep * ( 1 / step );
  6997. }
  6998. if ( percent < 0 ) {
  6999. percent = 0;
  7000. }
  7001. if ( percent > 100 ) {
  7002. percent = 100;
  7003. }
  7004. if ( newval < min ) {
  7005. newval = min;
  7006. }
  7007. if ( newval > max ) {
  7008. newval = max;
  7009. }
  7010. this.handle.css( "left", percent + "%" );
  7011. this.handle[0].setAttribute( "aria-valuenow", isInput ? newval : optionElements.eq( newval ).attr( "value" ) );
  7012. this.handle[0].setAttribute( "aria-valuetext", isInput ? newval : optionElements.eq( newval ).getEncodedText() );
  7013. this.handle[0].setAttribute( "title", isInput ? newval : optionElements.eq( newval ).getEncodedText() );
  7014. if ( this.valuebg ) {
  7015. this.valuebg.css( "width", percent + "%" );
  7016. }
  7017. // drag the label widths
  7018. if ( this._labels ) {
  7019. handlePercent = this.handle.width() / this.slider.width() * 100;
  7020. aPercent = percent && handlePercent + ( 100 - handlePercent ) * percent / 100;
  7021. bPercent = percent === 100 ? 0 : Math.min( handlePercent + 100 - aPercent, 100 );
  7022. this._labels.each(function() {
  7023. var ab = $( this ).hasClass( "ui-slider-label-a" );
  7024. $( this ).width( ( ab ? aPercent : bPercent ) + "%" );
  7025. });
  7026. }
  7027. if ( !preventInputUpdate ) {
  7028. valueChanged = false;
  7029. // update control"s value
  7030. if ( isInput ) {
  7031. valueChanged = control.val() !== newval;
  7032. control.val( newval );
  7033. } else {
  7034. valueChanged = control[ 0 ].selectedIndex !== newval;
  7035. control[ 0 ].selectedIndex = newval;
  7036. }
  7037. if ( this._trigger( "beforechange", val ) === false) {
  7038. return false;
  7039. }
  7040. if ( !isfromControl && valueChanged ) {
  7041. control.trigger( "change" );
  7042. }
  7043. }
  7044. },
  7045. _setHighlight: function( value ) {
  7046. value = !!value;
  7047. if ( value ) {
  7048. this.options.highlight = !!value;
  7049. this.refresh();
  7050. } else if ( this.valuebg ) {
  7051. this.valuebg.remove();
  7052. this.valuebg = false;
  7053. }
  7054. },
  7055. _setTheme: function( value ) {
  7056. this.handle
  7057. .removeClass( "ui-btn-" + this.options.theme )
  7058. .addClass( "ui-btn-" + value );
  7059. var currentTheme = this.options.theme ? this.options.theme : "inherit",
  7060. newTheme = value ? value : "inherit";
  7061. this.control
  7062. .removeClass( "ui-body-" + currentTheme )
  7063. .addClass( "ui-body-" + newTheme );
  7064. },
  7065. _setTrackTheme: function( value ) {
  7066. var currentTrackTheme = this.options.trackTheme ? this.options.trackTheme : "inherit",
  7067. newTrackTheme = value ? value : "inherit";
  7068. this.slider
  7069. .removeClass( "ui-body-" + currentTrackTheme )
  7070. .addClass( "ui-body-" + newTrackTheme );
  7071. },
  7072. _setMini: function( value ) {
  7073. value = !!value;
  7074. if ( !this.isToggleSwitch && !this.isRangeslider ) {
  7075. this.slider.parent().toggleClass( "ui-mini", value );
  7076. this.element.toggleClass( "ui-mini", value );
  7077. }
  7078. this.slider.toggleClass( "ui-mini", value );
  7079. },
  7080. _setCorners: function( value ) {
  7081. this.slider.toggleClass( "ui-corner-all", value );
  7082. if ( !this.isToggleSwitch ) {
  7083. this.control.toggleClass( "ui-corner-all", value );
  7084. }
  7085. },
  7086. _setDisabled: function( value ) {
  7087. value = !!value;
  7088. this.element.prop( "disabled", value );
  7089. this.slider.toggleClass( "ui-state-disabled" ).attr( "aria-disabled", value );
  7090. }
  7091. }, $.mobile.behaviors.formReset ) );
  7092. })( jQuery );
  7093. (function( $, undefined ) {
  7094. var popup;
  7095. function getPopup() {
  7096. if ( !popup ) {
  7097. popup = $( "<div></div>", {
  7098. "class": "ui-slider-popup ui-shadow ui-corner-all"
  7099. });
  7100. }
  7101. return popup.clone();
  7102. }
  7103. $.widget( "mobile.slider", $.mobile.slider, {
  7104. options: {
  7105. popupEnabled: false,
  7106. showValue: false
  7107. },
  7108. _create: function() {
  7109. this._super();
  7110. $.extend( this, {
  7111. _currentValue: null,
  7112. _popup: null,
  7113. _popupVisible: false
  7114. });
  7115. this._setOption( "popupEnabled", this.options.popupEnabled );
  7116. this._on( this.handle, { "vmousedown" : "_showPopup" } );
  7117. this._on( this.slider.add( this.document ), { "vmouseup" : "_hidePopup" } );
  7118. this._refresh();
  7119. },
  7120. // position the popup centered 5px above the handle
  7121. _positionPopup: function() {
  7122. var dstOffset = this.handle.offset();
  7123. this._popup.offset( {
  7124. left: dstOffset.left + ( this.handle.width() - this._popup.width() ) / 2,
  7125. top: dstOffset.top - this._popup.outerHeight() - 5
  7126. });
  7127. },
  7128. _setOption: function( key, value ) {
  7129. this._super( key, value );
  7130. if ( key === "showValue" ) {
  7131. this.handle.html( value && !this.options.mini ? this._value() : "" );
  7132. } else if ( key === "popupEnabled" ) {
  7133. if ( value && !this._popup ) {
  7134. this._popup = getPopup()
  7135. .addClass( "ui-body-" + ( this.options.theme || "a" ) )
  7136. .insertBefore( this.element );
  7137. }
  7138. }
  7139. },
  7140. // show value on the handle and in popup
  7141. refresh: function() {
  7142. this._super.apply( this, arguments );
  7143. this._refresh();
  7144. },
  7145. _refresh: function() {
  7146. var o = this.options, newValue;
  7147. if ( o.popupEnabled ) {
  7148. // remove the title attribute from the handle (which is
  7149. // responsible for the annoying tooltip); NB we have
  7150. // to do it here as the jqm slider sets it every time
  7151. // the slider's value changes :(
  7152. this.handle.removeAttr( "title" );
  7153. }
  7154. newValue = this._value();
  7155. if ( newValue === this._currentValue ) {
  7156. return;
  7157. }
  7158. this._currentValue = newValue;
  7159. if ( o.popupEnabled && this._popup ) {
  7160. this._positionPopup();
  7161. this._popup.html( newValue );
  7162. } else if ( o.showValue && !this.options.mini ) {
  7163. this.handle.html( newValue );
  7164. }
  7165. },
  7166. _showPopup: function() {
  7167. if ( this.options.popupEnabled && !this._popupVisible ) {
  7168. this.handle.html( "" );
  7169. this._popup.show();
  7170. this._positionPopup();
  7171. this._popupVisible = true;
  7172. }
  7173. },
  7174. _hidePopup: function() {
  7175. var o = this.options;
  7176. if ( o.popupEnabled && this._popupVisible ) {
  7177. if ( o.showValue && !o.mini ) {
  7178. this.handle.html( this._value() );
  7179. }
  7180. this._popup.hide();
  7181. this._popupVisible = false;
  7182. }
  7183. }
  7184. });
  7185. })( jQuery );
  7186. (function( $, undefined ) {
  7187. $.widget( "mobile.flipswitch", $.extend({
  7188. options: {
  7189. onText: "On",
  7190. offText: "Off",
  7191. theme: null,
  7192. enhanced: false,
  7193. wrapperClass: null,
  7194. corners: true,
  7195. mini: false
  7196. },
  7197. _create: function() {
  7198. if ( !this.options.enhanced ) {
  7199. this._enhance();
  7200. } else {
  7201. $.extend( this, {
  7202. flipswitch: this.element.parent(),
  7203. on: this.element.find( ".ui-flipswitch-on" ).eq( 0 ),
  7204. off: this.element.find( ".ui-flipswitch-off" ).eq(0),
  7205. type: this.element.get( 0 ).tagName
  7206. });
  7207. }
  7208. this._handleFormReset();
  7209. if ( this.element.is( ":disabled" ) ) {
  7210. this._setOptions({
  7211. "disabled": true
  7212. });
  7213. }
  7214. this._on( this.flipswitch, {
  7215. "click": "_toggle",
  7216. "swipeleft": "_left",
  7217. "swiperight": "_right"
  7218. });
  7219. this._on( this.on, {
  7220. "keydown": "_keydown"
  7221. });
  7222. this._on( {
  7223. "change": "refresh"
  7224. });
  7225. },
  7226. widget: function() {
  7227. return this.flipswitch;
  7228. },
  7229. _left: function() {
  7230. this.flipswitch.removeClass( "ui-flipswitch-active" );
  7231. if ( this.type === "SELECT" ) {
  7232. this.element.get( 0 ).selectedIndex = 0;
  7233. } else {
  7234. this.element.prop( "checked", false );
  7235. }
  7236. this.element.trigger( "change" );
  7237. },
  7238. _right: function() {
  7239. this.flipswitch.addClass( "ui-flipswitch-active" );
  7240. if ( this.type === "SELECT" ) {
  7241. this.element.get( 0 ).selectedIndex = 1;
  7242. } else {
  7243. this.element.prop( "checked", true );
  7244. }
  7245. this.element.trigger( "change" );
  7246. },
  7247. _enhance: function() {
  7248. var flipswitch = $( "<div>" ),
  7249. options = this.options,
  7250. element = this.element,
  7251. theme = options.theme ? options.theme : "inherit",
  7252. on = $( "<span></span>", { tabindex: 1 } ),
  7253. off = $( "<span></span>" ),
  7254. type = element.get( 0 ).tagName,
  7255. onText = ( type === "INPUT" ) ?
  7256. options.onText : element.find( "option" ).eq( 1 ).text(),
  7257. offText = ( type === "INPUT" ) ?
  7258. options.offText : element.find( "option" ).eq( 0 ).text();
  7259. on
  7260. .addClass( "ui-flipswitch-on ui-btn ui-shadow ui-btn-inherit" )
  7261. .text( onText );
  7262. off
  7263. .addClass( "ui-flipswitch-off" )
  7264. .text( offText );
  7265. flipswitch
  7266. .addClass( "ui-flipswitch ui-shadow-inset " +
  7267. "ui-bar-" + theme + " " +
  7268. ( options.wrapperClass ? options.wrapperClass : "" ) + " " +
  7269. ( ( element.is( ":checked" ) ||
  7270. element
  7271. .find( "option" )
  7272. .eq( 1 )
  7273. .is( ":selected" ) ) ? "ui-flipswitch-active" : "" ) +
  7274. ( element.is(":disabled") ? " ui-state-disabled": "") +
  7275. ( options.corners ? " ui-corner-all": "" ) +
  7276. ( options.mini ? " ui-mini": "" ) )
  7277. .append( on, off );
  7278. element
  7279. .addClass( "ui-flipswitch-input" )
  7280. .after( flipswitch )
  7281. .appendTo( flipswitch );
  7282. $.extend( this, {
  7283. flipswitch: flipswitch,
  7284. on: on,
  7285. off: off,
  7286. type: type
  7287. });
  7288. },
  7289. _reset: function() {
  7290. this.refresh();
  7291. },
  7292. refresh: function() {
  7293. var direction,
  7294. existingDirection = this.flipswitch.hasClass( "ui-flipswitch-active" ) ? "_right" : "_left";
  7295. if ( this.type === "SELECT" ) {
  7296. direction = ( this.element.get( 0 ).selectedIndex > 0 ) ? "_right": "_left";
  7297. } else {
  7298. direction = this.element.prop( "checked" ) ? "_right": "_left";
  7299. }
  7300. if ( direction !== existingDirection ) {
  7301. this[ direction ]();
  7302. }
  7303. },
  7304. _toggle: function() {
  7305. var direction = this.flipswitch.hasClass( "ui-flipswitch-active" ) ? "_left" : "_right";
  7306. this[ direction ]();
  7307. },
  7308. _keydown: function( e ) {
  7309. if ( e.which === $.mobile.keyCode.LEFT ) {
  7310. this._left();
  7311. } else if ( e.which === $.mobile.keyCode.RIGHT ) {
  7312. this._right();
  7313. } else if ( e.which === $.mobile.keyCode.SPACE ) {
  7314. this._toggle();
  7315. e.preventDefault();
  7316. }
  7317. },
  7318. _setOptions: function( options ) {
  7319. if ( options.theme !== undefined ) {
  7320. var currentTheme = options.theme ? options.theme : "inherit",
  7321. newTheme = options.theme ? options.theme : "inherit";
  7322. this.widget()
  7323. .removeClass( "ui-bar-" + currentTheme )
  7324. .addClass( "ui-bar-" + newTheme );
  7325. }
  7326. if ( options.onText !== undefined ) {
  7327. this.on.text( options.onText );
  7328. }
  7329. if ( options.offText !== undefined ) {
  7330. this.off.text( options.offText );
  7331. }
  7332. if ( options.disabled !== undefined ) {
  7333. this.widget().toggleClass( "ui-state-disabled", options.disabled );
  7334. }
  7335. if ( options.mini !== undefined ) {
  7336. this.widget().toggleClass( "ui-mini", options.mini );
  7337. }
  7338. if ( options.corners !== undefined ) {
  7339. this.widget().toggleClass( "ui-corner-all", options.corners );
  7340. }
  7341. this._super( options );
  7342. },
  7343. _destroy: function() {
  7344. if ( this.options.enhanced ) {
  7345. return;
  7346. }
  7347. this.on.remove();
  7348. this.off.remove();
  7349. this.element.unwrap();
  7350. this.flipswitch.remove();
  7351. this.removeClass( "ui-flipswitch-input" );
  7352. }
  7353. }, $.mobile.behaviors.formReset ) );
  7354. })( jQuery );
  7355. (function( $, undefined ) {
  7356. $.widget( "mobile.rangeslider", $.extend( {
  7357. options: {
  7358. theme: null,
  7359. trackTheme: null,
  7360. corners: true,
  7361. mini: false,
  7362. highlight: true
  7363. },
  7364. _create: function() {
  7365. var $el = this.element,
  7366. elClass = this.options.mini ? "ui-rangeslider ui-mini" : "ui-rangeslider",
  7367. _inputFirst = $el.find( "input" ).first(),
  7368. _inputLast = $el.find( "input" ).last(),
  7369. _label = $el.find( "label" ).first(),
  7370. _sliderWidgetFirst = $.data( _inputFirst.get( 0 ), "mobile-slider" ) ||
  7371. $.data( _inputFirst.slider().get( 0 ), "mobile-slider" ),
  7372. _sliderWidgetLast = $.data( _inputLast.get(0), "mobile-slider" ) ||
  7373. $.data( _inputLast.slider().get( 0 ), "mobile-slider" ),
  7374. _sliderFirst = _sliderWidgetFirst.slider,
  7375. _sliderLast = _sliderWidgetLast.slider,
  7376. firstHandle = _sliderWidgetFirst.handle,
  7377. _sliders = $( "<div class='ui-rangeslider-sliders' />" ).appendTo( $el );
  7378. _inputFirst.addClass( "ui-rangeslider-first" );
  7379. _inputLast.addClass( "ui-rangeslider-last" );
  7380. $el.addClass( elClass );
  7381. _sliderFirst.appendTo( _sliders );
  7382. _sliderLast.appendTo( _sliders );
  7383. _label.insertBefore( $el );
  7384. firstHandle.prependTo( _sliderLast );
  7385. $.extend( this, {
  7386. _inputFirst: _inputFirst,
  7387. _inputLast: _inputLast,
  7388. _sliderFirst: _sliderFirst,
  7389. _sliderLast: _sliderLast,
  7390. _label: _label,
  7391. _targetVal: null,
  7392. _sliderTarget: false,
  7393. _sliders: _sliders,
  7394. _proxy: false
  7395. });
  7396. this.refresh();
  7397. this._on( this.element.find( "input.ui-slider-input" ), {
  7398. "slidebeforestart": "_slidebeforestart",
  7399. "slidestop": "_slidestop",
  7400. "slidedrag": "_slidedrag",
  7401. "slidebeforechange": "_change",
  7402. "blur": "_change",
  7403. "keyup": "_change"
  7404. });
  7405. this._on({
  7406. "mousedown":"_change"
  7407. });
  7408. this._on( this.element.closest( "form" ), {
  7409. "reset":"_handleReset"
  7410. });
  7411. this._on( firstHandle, {
  7412. "vmousedown": "_dragFirstHandle"
  7413. });
  7414. },
  7415. _handleReset: function() {
  7416. var self = this;
  7417. //we must wait for the stack to unwind before updateing other wise sliders will not have updated yet
  7418. setTimeout( function() {
  7419. self._updateHighlight();
  7420. },0);
  7421. },
  7422. _dragFirstHandle: function( event ) {
  7423. //if the first handle is dragged send the event to the first slider
  7424. $.data( this._inputFirst.get(0), "mobile-slider" ).dragging = true;
  7425. $.data( this._inputFirst.get(0), "mobile-slider" ).refresh( event );
  7426. return false;
  7427. },
  7428. _slidedrag: function( event ) {
  7429. var first = $( event.target ).is( this._inputFirst ),
  7430. otherSlider = ( first ) ? this._inputLast : this._inputFirst;
  7431. this._sliderTarget = false;
  7432. //if the drag was initiated on an extreme and the other handle is focused send the events to
  7433. //the closest handle
  7434. if ( ( this._proxy === "first" && first ) || ( this._proxy === "last" && !first ) ) {
  7435. $.data( otherSlider.get(0), "mobile-slider" ).dragging = true;
  7436. $.data( otherSlider.get(0), "mobile-slider" ).refresh( event );
  7437. return false;
  7438. }
  7439. },
  7440. _slidestop: function( event ) {
  7441. var first = $( event.target ).is( this._inputFirst );
  7442. this._proxy = false;
  7443. //this stops dragging of the handle and brings the active track to the front
  7444. //this makes clicks on the track go the the last handle used
  7445. this.element.find( "input" ).trigger( "vmouseup" );
  7446. this._sliderFirst.css( "z-index", first ? 1 : "" );
  7447. },
  7448. _slidebeforestart: function( event ) {
  7449. this._sliderTarget = false;
  7450. //if the track is the target remember this and the original value
  7451. if ( $( event.originalEvent.target ).hasClass( "ui-slider-track" ) ) {
  7452. this._sliderTarget = true;
  7453. this._targetVal = $( event.target ).val();
  7454. }
  7455. },
  7456. _setOptions: function( options ) {
  7457. if ( options.theme !== undefined ) {
  7458. this._setTheme( options.theme );
  7459. }
  7460. if ( options.trackTheme !== undefined ) {
  7461. this._setTrackTheme( options.trackTheme );
  7462. }
  7463. if ( options.mini !== undefined ) {
  7464. this._setMini( options.mini );
  7465. }
  7466. if ( options.highlight !== undefined ) {
  7467. this._setHighlight( options.highlight );
  7468. }
  7469. this._super( options );
  7470. this.refresh();
  7471. },
  7472. refresh: function() {
  7473. var $el = this.element,
  7474. o = this.options;
  7475. if ( this._inputFirst.is( ":disabled" ) || this._inputLast.is( ":disabled" ) ) {
  7476. this.options.disabled = true;
  7477. }
  7478. $el.find( "input" ).slider({
  7479. theme: o.theme,
  7480. trackTheme: o.trackTheme,
  7481. disabled: o.disabled,
  7482. corners: o.corners,
  7483. mini: o.mini,
  7484. highlight: o.highlight
  7485. }).slider( "refresh" );
  7486. this._updateHighlight();
  7487. },
  7488. _change: function( event ) {
  7489. if ( event.type === "keyup" ) {
  7490. this._updateHighlight();
  7491. return false;
  7492. }
  7493. var self = this,
  7494. min = parseFloat( this._inputFirst.val(), 10 ),
  7495. max = parseFloat( this._inputLast.val(), 10 ),
  7496. first = $( event.target ).hasClass( "ui-rangeslider-first" ),
  7497. thisSlider = first ? this._inputFirst : this._inputLast,
  7498. otherSlider = first ? this._inputLast : this._inputFirst;
  7499. if ( ( this._inputFirst.val() > this._inputLast.val() && event.type === "mousedown" && !$(event.target).hasClass("ui-slider-handle")) ) {
  7500. thisSlider.blur();
  7501. } else if ( event.type === "mousedown" ) {
  7502. return;
  7503. }
  7504. if ( min > max && !this._sliderTarget ) {
  7505. //this prevents min from being greater then max
  7506. thisSlider.val( first ? max: min ).slider( "refresh" );
  7507. this._trigger( "normalize" );
  7508. } else if ( min > max ) {
  7509. //this makes it so clicks on the target on either extreme go to the closest handle
  7510. thisSlider.val( this._targetVal ).slider( "refresh" );
  7511. //You must wait for the stack to unwind so first slider is updated before updating second
  7512. setTimeout( function() {
  7513. otherSlider.val( first ? min: max ).slider( "refresh" );
  7514. $.data( otherSlider.get(0), "mobile-slider" ).handle.focus();
  7515. self._sliderFirst.css( "z-index", first ? "" : 1 );
  7516. self._trigger( "normalize" );
  7517. }, 0 );
  7518. this._proxy = ( first ) ? "first" : "last";
  7519. }
  7520. //fixes issue where when both _sliders are at min they cannot be adjusted
  7521. if ( min === max ) {
  7522. $.data( thisSlider.get(0), "mobile-slider" ).handle.css( "z-index", 1 );
  7523. $.data( otherSlider.get(0), "mobile-slider" ).handle.css( "z-index", 0 );
  7524. } else {
  7525. $.data( otherSlider.get(0), "mobile-slider" ).handle.css( "z-index", "" );
  7526. $.data( thisSlider.get(0), "mobile-slider" ).handle.css( "z-index", "" );
  7527. }
  7528. this._updateHighlight();
  7529. if ( min >= max ) {
  7530. return false;
  7531. }
  7532. },
  7533. _updateHighlight: function() {
  7534. var min = parseInt( $.data( this._inputFirst.get(0), "mobile-slider" ).handle.get(0).style.left, 10 ),
  7535. max = parseInt( $.data( this._inputLast.get(0), "mobile-slider" ).handle.get(0).style.left, 10 ),
  7536. width = (max - min);
  7537. this.element.find( ".ui-slider-bg" ).css({
  7538. "margin-left": min + "%",
  7539. "width": width + "%"
  7540. });
  7541. },
  7542. _setTheme: function( value ) {
  7543. this._inputFirst.slider( "option", "theme", value );
  7544. this._inputLast.slider( "option", "theme", value );
  7545. },
  7546. _setTrackTheme: function( value ) {
  7547. this._inputFirst.slider( "option", "trackTheme", value );
  7548. this._inputLast.slider( "option", "trackTheme", value );
  7549. },
  7550. _setMini: function( value ) {
  7551. this._inputFirst.slider( "option", "mini", value );
  7552. this._inputLast.slider( "option", "mini", value );
  7553. this.element.toggleClass( "ui-mini", !!value );
  7554. },
  7555. _setHighlight: function( value ) {
  7556. this._inputFirst.slider( "option", "highlight", value );
  7557. this._inputLast.slider( "option", "highlight", value );
  7558. },
  7559. _destroy: function() {
  7560. this._label.prependTo( this.element );
  7561. this.element.removeClass( "ui-rangeslider ui-mini" );
  7562. this._inputFirst.after( this._sliderFirst );
  7563. this._inputLast.after( this._sliderLast );
  7564. this._sliders.remove();
  7565. this.element.find( "input" ).removeClass( "ui-rangeslider-first ui-rangeslider-last" ).slider( "destroy" );
  7566. }
  7567. }, $.mobile.behaviors.formReset ) );
  7568. })( jQuery );
  7569. (function( $, undefined ) {
  7570. $.widget( "mobile.textinput", $.mobile.textinput, {
  7571. options: {
  7572. clearBtn: false,
  7573. clearBtnText: "Clear text"
  7574. },
  7575. _create: function() {
  7576. this._super();
  7577. if ( !!this.options.clearBtn || this.isSearch ) {
  7578. this._addClearBtn();
  7579. }
  7580. },
  7581. clearButton: function() {
  7582. return $( "<a href='#' class='ui-input-clear ui-btn ui-icon-delete ui-btn-icon-notext ui-corner-all" +
  7583. "' title='" + this.options.clearBtnText + "'>" + this.options.clearBtnText + "</a>" );
  7584. },
  7585. _clearBtnClick: function( event ) {
  7586. this.element.val( "" )
  7587. .focus()
  7588. .trigger( "change" );
  7589. this._clearBtn.addClass( "ui-input-clear-hidden" );
  7590. event.preventDefault();
  7591. },
  7592. _addClearBtn: function() {
  7593. if ( !this.options.enhanced ) {
  7594. this._enhanceClear();
  7595. }
  7596. $.extend( this, {
  7597. _clearBtn: this.widget().find("a.ui-input-clear")
  7598. });
  7599. this._bindClearEvents();
  7600. this._toggleClear();
  7601. },
  7602. _enhanceClear: function() {
  7603. this.clearButton().appendTo( this.widget() );
  7604. this.widget().addClass( "ui-input-has-clear" );
  7605. },
  7606. _bindClearEvents: function() {
  7607. this._on( this._clearBtn, {
  7608. "click": "_clearBtnClick"
  7609. });
  7610. this._on({
  7611. "keyup": "_toggleClear",
  7612. "change": "_toggleClear",
  7613. "input": "_toggleClear",
  7614. "focus": "_toggleClear",
  7615. "blur": "_toggleClear",
  7616. "cut": "_toggleClear",
  7617. "paste": "_toggleClear"
  7618. });
  7619. },
  7620. _unbindClear: function() {
  7621. this._off( this._clearBtn, "click");
  7622. this._off( this.element, "keyup change input focus blur cut paste" );
  7623. },
  7624. _setOptions: function( options ) {
  7625. this._super( options );
  7626. if ( options.clearbtn !== undefined && !this.element.is( "textarea, :jqmData(type='range')" ) ) {
  7627. if ( options.clearBtn ) {
  7628. this._addClearBtn();
  7629. } else {
  7630. this._destroyClear();
  7631. }
  7632. }
  7633. if ( options.clearBtnText !== undefined && this._clearBtn !== undefined ) {
  7634. this._clearBtn.text( options.clearBtnText );
  7635. }
  7636. },
  7637. _toggleClear: function() {
  7638. this._delay( "_toggleClearClass", 0 );
  7639. },
  7640. _toggleClearClass: function() {
  7641. this._clearBtn.toggleClass( "ui-input-clear-hidden", !this.element.val() );
  7642. },
  7643. _destroyClear: function() {
  7644. this.element.removeClass( "ui-input-has-clear" );
  7645. this._unbindClear()._clearBtn.remove();
  7646. },
  7647. _destroy: function() {
  7648. this._super();
  7649. this._destroyClear();
  7650. }
  7651. });
  7652. })( jQuery );
  7653. (function( $, undefined ) {
  7654. $.widget( "mobile.textinput", $.mobile.textinput, {
  7655. options: {
  7656. autogrow:true,
  7657. keyupTimeoutBuffer: 100
  7658. },
  7659. _create: function() {
  7660. this._super();
  7661. if ( this.options.autogrow && this.isTextarea ) {
  7662. this._autogrow();
  7663. }
  7664. },
  7665. _autogrow: function() {
  7666. this._on({
  7667. "keyup": "_timeout",
  7668. "change": "_timeout",
  7669. "input": "_timeout",
  7670. "paste": "_timeout",
  7671. });
  7672. // Attach to the various you-have-become-visible notifications that the
  7673. // various framework elements emit.
  7674. // TODO: Remove all but the updatelayout handler once #6426 is fixed.
  7675. this._on( true, this.document, {
  7676. // TODO: Move to non-deprecated event
  7677. "pageshow": "_handleShow",
  7678. "popupbeforeposition": "_handleShow",
  7679. "updatelayout": "_handleShow",
  7680. "panelopen": "_handleShow"
  7681. });
  7682. },
  7683. // Synchronously fix the widget height if this widget's parents are such
  7684. // that they show/hide content at runtime. We still need to check whether
  7685. // the widget is actually visible in case it is contained inside multiple
  7686. // such containers. For example: panel contains collapsible contains
  7687. // autogrow textinput. The panel may emit "panelopen" indicating that its
  7688. // content has become visible, but the collapsible is still collapsed, so
  7689. // the autogrow textarea is still not visible.
  7690. _handleShow: function( event ) {
  7691. if ( $.contains( event.target, this.element[ 0 ] ) &&
  7692. this.element.is( ":visible" ) ) {
  7693. if ( event.type !== "popupbeforeposition" ) {
  7694. this.element
  7695. .addClass( "ui-textinput-autogrow-resize" )
  7696. .one( "transitionend webkitTransitionEnd oTransitionEnd",
  7697. $.proxy( function() {
  7698. this.element.removeClass( "ui-textinput-autogrow-resize" );
  7699. }, this ) );
  7700. }
  7701. this._prepareHeightUpdate();
  7702. }
  7703. },
  7704. _unbindAutogrow: function() {
  7705. this._off( this.element, "keyup change input paste" );
  7706. this._off( this.document,
  7707. "pageshow popupbeforeposition updatelayout panelopen" );
  7708. },
  7709. keyupTimeout: null,
  7710. _prepareHeightUpdate: function( delay ) {
  7711. if ( this.keyupTimeout ) {
  7712. clearTimeout( this.keyupTimeout );
  7713. }
  7714. if ( delay === undefined ) {
  7715. this._updateHeight();
  7716. } else {
  7717. this.keyupTimeout = this._delay( "_updateHeight", delay );
  7718. }
  7719. },
  7720. _timeout: function() {
  7721. this._prepareHeightUpdate( this.options.keyupTimeoutBuffer );
  7722. },
  7723. _updateHeight: function() {
  7724. this.keyupTimeout = 0;
  7725. this.element.css({
  7726. "height": 0,
  7727. "min-height": 0,
  7728. "max-height": 0
  7729. });
  7730. var paddingTop, paddingBottom, paddingHeight,
  7731. scrollHeight = this.element[ 0 ].scrollHeight,
  7732. clientHeight = this.element[ 0 ].clientHeight,
  7733. borderTop = parseFloat( this.element.css( "border-top-width" ) ),
  7734. borderBottom = parseFloat( this.element.css( "border-bottom-width" ) ),
  7735. borderHeight = borderTop + borderBottom,
  7736. height = scrollHeight + borderHeight + 15;
  7737. // Issue 6179: Padding is not included in scrollHeight and
  7738. // clientHeight by Firefox if no scrollbar is visible. Because
  7739. // textareas use the border-box box-sizing model, padding should be
  7740. // included in the new (assigned) height. Because the height is set
  7741. // to 0, clientHeight == 0 in Firefox. Therefore, we can use this to
  7742. // check if padding must be added.
  7743. if ( clientHeight === 0 ) {
  7744. paddingTop = parseFloat( this.element.css( "padding-top" ) );
  7745. paddingBottom = parseFloat( this.element.css( "padding-bottom" ) );
  7746. paddingHeight = paddingTop + paddingBottom;
  7747. height += paddingHeight;
  7748. }
  7749. this.element.css({
  7750. "height": height,
  7751. "min-height": "",
  7752. "max-height": ""
  7753. });
  7754. },
  7755. refresh: function() {
  7756. if ( this.options.autogrow && this.isTextarea ) {
  7757. this._updateHeight();
  7758. }
  7759. },
  7760. _setOptions: function( options ) {
  7761. this._super( options );
  7762. if ( options.autogrow !== undefined && this.isTextarea ) {
  7763. if ( options.autogrow ) {
  7764. this._autogrow();
  7765. } else {
  7766. this._unbindAutogrow();
  7767. }
  7768. }
  7769. }
  7770. });
  7771. })( jQuery );
  7772. (function( $, undefined ) {
  7773. $.widget( "mobile.selectmenu", $.extend( {
  7774. initSelector: "select:not( :jqmData(role='slider')):not( :jqmData(role='flipswitch') )",
  7775. options: {
  7776. theme: null,
  7777. icon: "carat-d",
  7778. iconpos: "right",
  7779. inline: false,
  7780. corners: true,
  7781. shadow: true,
  7782. iconshadow: false, /* TODO: Deprecated in 1.4, remove in 1.5. */
  7783. overlayTheme: null,
  7784. dividerTheme: null,
  7785. hidePlaceholderMenuItems: true,
  7786. closeText: "Close",
  7787. nativeMenu: true,
  7788. // This option defaults to true on iOS devices.
  7789. preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
  7790. mini: false
  7791. },
  7792. _button: function() {
  7793. return $( "<div/>" );
  7794. },
  7795. _setDisabled: function( value ) {
  7796. this.element.attr( "disabled", value );
  7797. this.button.attr( "aria-disabled", value );
  7798. return this._setOption( "disabled", value );
  7799. },
  7800. _focusButton : function() {
  7801. var self = this;
  7802. setTimeout( function() {
  7803. self.button.focus();
  7804. }, 40);
  7805. },
  7806. _selectOptions: function() {
  7807. return this.select.find( "option" );
  7808. },
  7809. // setup items that are generally necessary for select menu extension
  7810. _preExtension: function() {
  7811. var inline = this.options.inline || this.element.jqmData( "inline" ),
  7812. mini = this.options.mini || this.element.jqmData( "mini" ),
  7813. classes = "";
  7814. // TODO: Post 1.1--once we have time to test thoroughly--any classes manually applied to the original element should be carried over to the enhanced element, with an `-enhanced` suffix. See https://github.com/jquery/jquery-mobile/issues/3577
  7815. /* if ( $el[0].className.length ) {
  7816. classes = $el[0].className;
  7817. } */
  7818. if ( !!~this.element[0].className.indexOf( "ui-btn-left" ) ) {
  7819. classes = " ui-btn-left";
  7820. }
  7821. if ( !!~this.element[0].className.indexOf( "ui-btn-right" ) ) {
  7822. classes = " ui-btn-right";
  7823. }
  7824. if ( inline ) {
  7825. classes += " ui-btn-inline";
  7826. }
  7827. if ( mini ) {
  7828. classes += " ui-mini";
  7829. }
  7830. this.select = this.element.removeClass( "ui-btn-left ui-btn-right" ).wrap( "<div class='ui-select" + classes + "'>" );
  7831. this.selectId = this.select.attr( "id" ) || ( "select-" + this.uuid );
  7832. this.buttonId = this.selectId + "-button";
  7833. this.label = $( "label[for='"+ this.selectId +"']" );
  7834. this.isMultiple = this.select[ 0 ].multiple;
  7835. },
  7836. _destroy: function() {
  7837. var wrapper = this.element.parents( ".ui-select" );
  7838. if ( wrapper.length > 0 ) {
  7839. if ( wrapper.is( ".ui-btn-left, .ui-btn-right" ) ) {
  7840. this.element.addClass( wrapper.hasClass( "ui-btn-left" ) ? "ui-btn-left" : "ui-btn-right" );
  7841. }
  7842. this.element.insertAfter( wrapper );
  7843. wrapper.remove();
  7844. }
  7845. },
  7846. _create: function() {
  7847. this._preExtension();
  7848. this.button = this._button();
  7849. var self = this,
  7850. options = this.options,
  7851. iconpos = options.icon ? ( options.iconpos || this.select.jqmData( "iconpos" ) ) : false,
  7852. button = this.button
  7853. .insertBefore( this.select )
  7854. .attr( "id", this.buttonId )
  7855. .addClass( "ui-btn" +
  7856. ( options.icon ? ( " ui-icon-" + options.icon + " ui-btn-icon-" + iconpos +
  7857. ( options.iconshadow ? " ui-shadow-icon" : "" ) ) : "" ) + /* TODO: Remove in 1.5. */
  7858. ( options.theme ? " ui-btn-" + options.theme : "" ) +
  7859. ( options.corners ? " ui-corner-all" : "" ) +
  7860. ( options.shadow ? " ui-shadow" : "" ) );
  7861. this.setButtonText();
  7862. // Opera does not properly support opacity on select elements
  7863. // In Mini, it hides the element, but not its text
  7864. // On the desktop,it seems to do the opposite
  7865. // for these reasons, using the nativeMenu option results in a full native select in Opera
  7866. if ( options.nativeMenu && window.opera && window.opera.version ) {
  7867. button.addClass( "ui-select-nativeonly" );
  7868. }
  7869. // Add counter for multi selects
  7870. if ( this.isMultiple ) {
  7871. this.buttonCount = $( "<span>" )
  7872. .addClass( "ui-li-count ui-body-inherit" )
  7873. .hide()
  7874. .appendTo( button.addClass( "ui-li-has-count" ) );
  7875. }
  7876. // Disable if specified
  7877. if ( options.disabled || this.element.attr( "disabled" )) {
  7878. this.disable();
  7879. }
  7880. // Events on native select
  7881. this.select.change(function() {
  7882. self.refresh();
  7883. if ( !!options.nativeMenu ) {
  7884. this.blur();
  7885. }
  7886. });
  7887. this._handleFormReset();
  7888. this._on( this.button, {
  7889. keydown: "_handleKeydown"
  7890. });
  7891. this.build();
  7892. },
  7893. build: function() {
  7894. var self = this;
  7895. this.select
  7896. .appendTo( self.button )
  7897. .bind( "vmousedown", function() {
  7898. // Add active class to button
  7899. self.button.addClass( $.mobile.activeBtnClass );
  7900. })
  7901. .bind( "focus", function() {
  7902. self.button.addClass( $.mobile.focusClass );
  7903. })
  7904. .bind( "blur", function() {
  7905. self.button.removeClass( $.mobile.focusClass );
  7906. })
  7907. .bind( "focus vmouseover", function() {
  7908. self.button.trigger( "vmouseover" );
  7909. })
  7910. .bind( "vmousemove", function() {
  7911. // Remove active class on scroll/touchmove
  7912. self.button.removeClass( $.mobile.activeBtnClass );
  7913. })
  7914. .bind( "change blur vmouseout", function() {
  7915. self.button.trigger( "vmouseout" )
  7916. .removeClass( $.mobile.activeBtnClass );
  7917. });
  7918. // In many situations, iOS will zoom into the select upon tap, this prevents that from happening
  7919. self.button.bind( "vmousedown", function() {
  7920. if ( self.options.preventFocusZoom ) {
  7921. $.mobile.zoom.disable( true );
  7922. }
  7923. });
  7924. self.label.bind( "click focus", function() {
  7925. if ( self.options.preventFocusZoom ) {
  7926. $.mobile.zoom.disable( true );
  7927. }
  7928. });
  7929. self.select.bind( "focus", function() {
  7930. if ( self.options.preventFocusZoom ) {
  7931. $.mobile.zoom.disable( true );
  7932. }
  7933. });
  7934. self.button.bind( "mouseup", function() {
  7935. if ( self.options.preventFocusZoom ) {
  7936. setTimeout(function() {
  7937. $.mobile.zoom.enable( true );
  7938. }, 0 );
  7939. }
  7940. });
  7941. self.select.bind( "blur", function() {
  7942. if ( self.options.preventFocusZoom ) {
  7943. $.mobile.zoom.enable( true );
  7944. }
  7945. });
  7946. },
  7947. selected: function() {
  7948. return this._selectOptions().filter( ":selected" );
  7949. },
  7950. selectedIndices: function() {
  7951. var self = this;
  7952. return this.selected().map(function() {
  7953. return self._selectOptions().index( this );
  7954. }).get();
  7955. },
  7956. setButtonText: function() {
  7957. var self = this,
  7958. selected = this.selected(),
  7959. text = this.placeholder,
  7960. span = $( document.createElement( "span" ) );
  7961. this.button.children( "span" ).not( ".ui-li-count" ).remove().end().end().prepend( (function() {
  7962. if ( selected.length ) {
  7963. text = selected.map(function() {
  7964. return $( this ).text();
  7965. }).get().join( ", " );
  7966. } else {
  7967. text = self.placeholder;
  7968. }
  7969. if ( text ) {
  7970. span.text( text );
  7971. } else {
  7972. span.html( "&nbsp;" );
  7973. }
  7974. // TODO possibly aggregate multiple select option classes
  7975. return span
  7976. .addClass( self.select.attr( "class" ) )
  7977. .addClass( selected.attr( "class" ) )
  7978. .removeClass( "ui-screen-hidden" );
  7979. })());
  7980. },
  7981. setButtonCount: function() {
  7982. var selected = this.selected();
  7983. // multiple count inside button
  7984. if ( this.isMultiple ) {
  7985. this.buttonCount[ selected.length > 1 ? "show" : "hide" ]().text( selected.length );
  7986. }
  7987. },
  7988. _handleKeydown: function( /* event */ ) {
  7989. this._delay( "_refreshButton" );
  7990. },
  7991. _reset: function() {
  7992. this.refresh();
  7993. },
  7994. _refreshButton: function() {
  7995. this.setButtonText();
  7996. this.setButtonCount();
  7997. },
  7998. refresh: function() {
  7999. this._refreshButton();
  8000. },
  8001. // open and close preserved in native selects
  8002. // to simplify users code when looping over selects
  8003. open: $.noop,
  8004. close: $.noop,
  8005. disable: function() {
  8006. this._setDisabled( true );
  8007. this.button.addClass( "ui-state-disabled" );
  8008. },
  8009. enable: function() {
  8010. this._setDisabled( false );
  8011. this.button.removeClass( "ui-state-disabled" );
  8012. }
  8013. }, $.mobile.behaviors.formReset ) );
  8014. })( jQuery );
  8015. (function( $, undefined ) {
  8016. $.mobile.links = function( target ) {
  8017. //links within content areas, tests included with page
  8018. $( target )
  8019. .find( "a" )
  8020. .jqmEnhanceable()
  8021. .filter( ":jqmData(rel='popup')[href][href!='']" )
  8022. .each( function() {
  8023. // Accessibility info for popups
  8024. var element = this,
  8025. idref = element.getAttribute( "href" ).substring( 1 );
  8026. if ( idref ) {
  8027. element.setAttribute( "aria-haspopup", true );
  8028. element.setAttribute( "aria-owns", idref );
  8029. element.setAttribute( "aria-expanded", false );
  8030. }
  8031. })
  8032. .end()
  8033. .not( ".ui-btn, :jqmData(role='none'), :jqmData(role='nojs')" )
  8034. .addClass( "ui-link" );
  8035. };
  8036. })( jQuery );
  8037. (function( $, undefined ) {
  8038. function fitSegmentInsideSegment( windowSize, segmentSize, offset, desired ) {
  8039. var returnValue = desired;
  8040. if ( windowSize < segmentSize ) {
  8041. // Center segment if it's bigger than the window
  8042. returnValue = offset + ( windowSize - segmentSize ) / 2;
  8043. } else {
  8044. // Otherwise center it at the desired coordinate while keeping it completely inside the window
  8045. returnValue = Math.min( Math.max( offset, desired - segmentSize / 2 ), offset + windowSize - segmentSize );
  8046. }
  8047. return returnValue;
  8048. }
  8049. function getWindowCoordinates( theWindow ) {
  8050. return {
  8051. x: theWindow.scrollLeft(),
  8052. y: theWindow.scrollTop(),
  8053. cx: ( theWindow[ 0 ].innerWidth || theWindow.width() ),
  8054. cy: ( theWindow[ 0 ].innerHeight || theWindow.height() )
  8055. };
  8056. }
  8057. $.widget( "mobile.popup", {
  8058. options: {
  8059. wrapperClass: null,
  8060. theme: null,
  8061. overlayTheme: null,
  8062. shadow: true,
  8063. corners: true,
  8064. transition: "none",
  8065. positionTo: "origin",
  8066. tolerance: null,
  8067. closeLinkSelector: "a:jqmData(rel='back')",
  8068. closeLinkEvents: "click.popup",
  8069. navigateEvents: "navigate.popup",
  8070. closeEvents: "navigate.popup pagebeforechange.popup",
  8071. dismissible: true,
  8072. enhanced: false,
  8073. // NOTE Windows Phone 7 has a scroll position caching issue that
  8074. // requires us to disable popup history management by default
  8075. // https://github.com/jquery/jquery-mobile/issues/4784
  8076. //
  8077. // NOTE this option is modified in _create!
  8078. history: !$.mobile.browser.oldIE
  8079. },
  8080. _create: function() {
  8081. var theElement = this.element,
  8082. myId = theElement.attr( "id" ),
  8083. currentOptions = this.options;
  8084. // We need to adjust the history option to be false if there's no AJAX nav.
  8085. // We can't do it in the option declarations because those are run before
  8086. // it is determined whether there shall be AJAX nav.
  8087. currentOptions.history = currentOptions.history && $.mobile.ajaxEnabled && $.mobile.hashListeningEnabled;
  8088. // Define instance variables
  8089. $.extend( this, {
  8090. _scrollTop: 0,
  8091. _page: theElement.closest( ".ui-page" ),
  8092. _ui: null,
  8093. _fallbackTransition: "",
  8094. _currentTransition: false,
  8095. _prerequisites: null,
  8096. _isOpen: false,
  8097. _tolerance: null,
  8098. _resizeData: null,
  8099. _ignoreResizeTo: 0,
  8100. _orientationchangeInProgress: false
  8101. });
  8102. if ( this._page.length === 0 ) {
  8103. this._page = $( "body" );
  8104. }
  8105. if ( currentOptions.enhanced ) {
  8106. this._ui = {
  8107. container: theElement.parent(),
  8108. screen: theElement.parent().prev(),
  8109. placeholder: $( this.document[ 0 ].getElementById( myId + "-placeholder" ) )
  8110. };
  8111. } else {
  8112. this._ui = this._enhance( theElement, myId );
  8113. this._applyTransition( currentOptions.transition );
  8114. }
  8115. this
  8116. ._setTolerance( currentOptions.tolerance )
  8117. ._ui.focusElement = this._ui.container;
  8118. // Event handlers
  8119. this._on( this._ui.screen, { "vclick": "_eatEventAndClose" } );
  8120. this._on( this.window, {
  8121. orientationchange: $.proxy( this, "_handleWindowOrientationchange" ),
  8122. resize: $.proxy( this, "_handleWindowResize" ),
  8123. keyup: $.proxy( this, "_handleWindowKeyUp" )
  8124. });
  8125. this._on( this.document, { "focusin": "_handleDocumentFocusIn" } );
  8126. },
  8127. _enhance: function( theElement, myId ) {
  8128. var currentOptions = this.options,
  8129. wrapperClass = currentOptions.wrapperClass,
  8130. ui = {
  8131. screen: $( "<div class='ui-screen-hidden ui-popup-screen " +
  8132. this._themeClassFromOption( "ui-overlay-", currentOptions.overlayTheme ) + "'></div>" ),
  8133. placeholder: $( "<div style='display: none;'><!-- placeholder --></div>" ),
  8134. container: $( "<div class='ui-popup-container ui-popup-hidden ui-popup-truncate" +
  8135. ( wrapperClass ? ( " " + wrapperClass ) : "" ) + "'></div>" )
  8136. },
  8137. fragment = this.document[ 0 ].createDocumentFragment();
  8138. fragment.appendChild( ui.screen[ 0 ] );
  8139. fragment.appendChild( ui.container[ 0 ] );
  8140. if ( myId ) {
  8141. ui.screen.attr( "id", myId + "-screen" );
  8142. ui.container.attr( "id", myId + "-popup" );
  8143. ui.placeholder
  8144. .attr( "id", myId + "-placeholder" )
  8145. .html( "<!-- placeholder for " + myId + " -->" );
  8146. }
  8147. // Apply the proto
  8148. this._page[ 0 ].appendChild( fragment );
  8149. // Leave a placeholder where the element used to be
  8150. ui.placeholder.insertAfter( theElement );
  8151. theElement
  8152. .detach()
  8153. .addClass( "ui-popup " +
  8154. this._themeClassFromOption( "ui-body-", currentOptions.theme ) + " " +
  8155. ( currentOptions.shadow ? "ui-overlay-shadow " : "" ) +
  8156. ( currentOptions.corners ? "ui-corner-all " : "" ) )
  8157. .appendTo( ui.container );
  8158. return ui;
  8159. },
  8160. _eatEventAndClose: function( theEvent ) {
  8161. theEvent.preventDefault();
  8162. theEvent.stopImmediatePropagation();
  8163. if ( this.options.dismissible ) {
  8164. this.close();
  8165. }
  8166. return false;
  8167. },
  8168. // Make sure the screen covers the entire document - CSS is sometimes not
  8169. // enough to accomplish this.
  8170. _resizeScreen: function() {
  8171. var screen = this._ui.screen,
  8172. popupHeight = this._ui.container.outerHeight( true ),
  8173. screenHeight = screen.removeAttr( "style" ).height(),
  8174. // Subtracting 1 here is necessary for an obscure Andrdoid 4.0 bug where
  8175. // the browser hangs if the screen covers the entire document :/
  8176. documentHeight = this.document.height() - 1;
  8177. if ( screenHeight < documentHeight ) {
  8178. screen.height( documentHeight );
  8179. } else if ( popupHeight > screenHeight ) {
  8180. screen.height( popupHeight );
  8181. }
  8182. },
  8183. _handleWindowKeyUp: function( theEvent ) {
  8184. if ( this._isOpen && theEvent.keyCode === $.mobile.keyCode.ESCAPE ) {
  8185. return this._eatEventAndClose( theEvent );
  8186. }
  8187. },
  8188. _expectResizeEvent: function() {
  8189. var windowCoordinates = getWindowCoordinates( this.window );
  8190. if ( this._resizeData ) {
  8191. if ( windowCoordinates.x === this._resizeData.windowCoordinates.x &&
  8192. windowCoordinates.y === this._resizeData.windowCoordinates.y &&
  8193. windowCoordinates.cx === this._resizeData.windowCoordinates.cx &&
  8194. windowCoordinates.cy === this._resizeData.windowCoordinates.cy ) {
  8195. // timeout not refreshed
  8196. return false;
  8197. } else {
  8198. // clear existing timeout - it will be refreshed below
  8199. clearTimeout( this._resizeData.timeoutId );
  8200. }
  8201. }
  8202. this._resizeData = {
  8203. timeoutId: this._delay( "_resizeTimeout", 200 ),
  8204. windowCoordinates: windowCoordinates
  8205. };
  8206. return true;
  8207. },
  8208. _resizeTimeout: function() {
  8209. if ( this._isOpen ) {
  8210. if ( !this._expectResizeEvent() ) {
  8211. if ( this._ui.container.hasClass( "ui-popup-hidden" ) ) {
  8212. // effectively rapid-open the popup while leaving the screen intact
  8213. this._ui.container.removeClass( "ui-popup-hidden ui-popup-truncate" );
  8214. this.reposition( { positionTo: "window" } );
  8215. this._ignoreResizeEvents();
  8216. }
  8217. this._resizeScreen();
  8218. this._resizeData = null;
  8219. this._orientationchangeInProgress = false;
  8220. }
  8221. } else {
  8222. this._resizeData = null;
  8223. this._orientationchangeInProgress = false;
  8224. }
  8225. },
  8226. _stopIgnoringResizeEvents: function() {
  8227. this._ignoreResizeTo = 0;
  8228. },
  8229. _ignoreResizeEvents: function() {
  8230. if ( this._ignoreResizeTo ) {
  8231. clearTimeout( this._ignoreResizeTo );
  8232. }
  8233. this._ignoreResizeTo = this._delay( "_stopIgnoringResizeEvents", 1000 );
  8234. },
  8235. _handleWindowResize: function(/* theEvent */) {
  8236. if ( this._isOpen && this._ignoreResizeTo === 0 ) {
  8237. if ( ( this._expectResizeEvent() || this._orientationchangeInProgress ) &&
  8238. !this._ui.container.hasClass( "ui-popup-hidden" ) ) {
  8239. // effectively rapid-close the popup while leaving the screen intact
  8240. this._ui.container
  8241. .addClass( "ui-popup-hidden ui-popup-truncate" )
  8242. .removeAttr( "style" );
  8243. }
  8244. }
  8245. },
  8246. _handleWindowOrientationchange: function(/* theEvent */) {
  8247. if ( !this._orientationchangeInProgress && this._isOpen && this._ignoreResizeTo === 0 ) {
  8248. this._expectResizeEvent();
  8249. this._orientationchangeInProgress = true;
  8250. }
  8251. },
  8252. // When the popup is open, attempting to focus on an element that is not a
  8253. // child of the popup will redirect focus to the popup
  8254. _handleDocumentFocusIn: function( theEvent ) {
  8255. var target,
  8256. targetElement = theEvent.target,
  8257. ui = this._ui;
  8258. if ( !this._isOpen ) {
  8259. return;
  8260. }
  8261. if ( targetElement !== ui.container[ 0 ] ) {
  8262. target = $( targetElement );
  8263. if ( 0 === target.parents().filter( ui.container[ 0 ] ).length ) {
  8264. $( this.document[ 0 ].activeElement ).one( "focus", function(/* theEvent */) {
  8265. target.blur();
  8266. });
  8267. ui.focusElement.focus();
  8268. theEvent.preventDefault();
  8269. theEvent.stopImmediatePropagation();
  8270. return false;
  8271. } else if ( ui.focusElement[ 0 ] === ui.container[ 0 ] ) {
  8272. ui.focusElement = target;
  8273. }
  8274. }
  8275. this._ignoreResizeEvents();
  8276. },
  8277. _themeClassFromOption: function( prefix, value ) {
  8278. return ( value ? ( value === "none" ? "" : ( prefix + value ) ) : ( prefix + "inherit" ) );
  8279. },
  8280. _applyTransition: function( value ) {
  8281. if ( value ) {
  8282. this._ui.container.removeClass( this._fallbackTransition );
  8283. if ( value !== "none" ) {
  8284. this._fallbackTransition = $.mobile._maybeDegradeTransition( value );
  8285. if ( this._fallbackTransition === "none" ) {
  8286. this._fallbackTransition = "";
  8287. }
  8288. this._ui.container.addClass( this._fallbackTransition );
  8289. }
  8290. }
  8291. return this;
  8292. },
  8293. _setOptions: function( newOptions ) {
  8294. var currentOptions = this.options,
  8295. theElement = this.element,
  8296. screen = this._ui.screen;
  8297. if ( newOptions.wrapperClass !== undefined ) {
  8298. this._ui.container
  8299. .removeClass( currentOptions.wrapperClass )
  8300. .addClass( newOptions.wrapperClass );
  8301. }
  8302. if ( newOptions.theme !== undefined ) {
  8303. theElement
  8304. .removeClass( this._themeClassFromOption( "ui-body-", currentOptions.theme ) )
  8305. .addClass( this._themeClassFromOption( "ui-body-", newOptions.theme ) );
  8306. }
  8307. if ( newOptions.overlayTheme !== undefined ) {
  8308. screen
  8309. .removeClass( this._themeClassFromOption( "ui-overlay-", currentOptions.overlayTheme ) )
  8310. .addClass( this._themeClassFromOption( "ui-overlay-", newOptions.overlayTheme ) );
  8311. if ( this._isOpen ) {
  8312. screen.addClass( "in" );
  8313. }
  8314. }
  8315. if ( newOptions.shadow !== undefined ) {
  8316. theElement.toggleClass( "ui-overlay-shadow", newOptions.shadow );
  8317. }
  8318. if ( newOptions.corners !== undefined ) {
  8319. theElement.toggleClass( "ui-corner-all", newOptions.corners );
  8320. }
  8321. if ( newOptions.transition !== undefined ) {
  8322. if ( !this._currentTransition ) {
  8323. this._applyTransition( newOptions.transition );
  8324. }
  8325. }
  8326. if ( newOptions.tolerance !== undefined ) {
  8327. this._setTolerance( newOptions.tolerance );
  8328. }
  8329. if ( newOptions.disabled !== undefined ) {
  8330. if ( newOptions.disabled ) {
  8331. this.close();
  8332. }
  8333. }
  8334. return this._super( newOptions );
  8335. },
  8336. _setTolerance: function( value ) {
  8337. var tol = { t: 30, r: 15, b: 30, l: 15 },
  8338. ar;
  8339. if ( value !== undefined ) {
  8340. ar = String( value ).split( "," );
  8341. $.each( ar, function( idx, val ) { ar[ idx ] = parseInt( val, 10 ); } );
  8342. switch( ar.length ) {
  8343. // All values are to be the same
  8344. case 1:
  8345. if ( !isNaN( ar[ 0 ] ) ) {
  8346. tol.t = tol.r = tol.b = tol.l = ar[ 0 ];
  8347. }
  8348. break;
  8349. // The first value denotes top/bottom tolerance, and the second value denotes left/right tolerance
  8350. case 2:
  8351. if ( !isNaN( ar[ 0 ] ) ) {
  8352. tol.t = tol.b = ar[ 0 ];
  8353. }
  8354. if ( !isNaN( ar[ 1 ] ) ) {
  8355. tol.l = tol.r = ar[ 1 ];
  8356. }
  8357. break;
  8358. // The array contains values in the order top, right, bottom, left
  8359. case 4:
  8360. if ( !isNaN( ar[ 0 ] ) ) {
  8361. tol.t = ar[ 0 ];
  8362. }
  8363. if ( !isNaN( ar[ 1 ] ) ) {
  8364. tol.r = ar[ 1 ];
  8365. }
  8366. if ( !isNaN( ar[ 2 ] ) ) {
  8367. tol.b = ar[ 2 ];
  8368. }
  8369. if ( !isNaN( ar[ 3 ] ) ) {
  8370. tol.l = ar[ 3 ];
  8371. }
  8372. break;
  8373. default:
  8374. break;
  8375. }
  8376. }
  8377. this._tolerance = tol;
  8378. return this;
  8379. },
  8380. _clampPopupWidth: function( infoOnly ) {
  8381. var menuSize,
  8382. windowCoordinates = getWindowCoordinates( this.window ),
  8383. // rectangle within which the popup must fit
  8384. rectangle = {
  8385. x: this._tolerance.l,
  8386. y: windowCoordinates.y + this._tolerance.t,
  8387. cx: windowCoordinates.cx - this._tolerance.l - this._tolerance.r,
  8388. cy: windowCoordinates.cy - this._tolerance.t - this._tolerance.b
  8389. };
  8390. if ( !infoOnly ) {
  8391. // Clamp the width of the menu before grabbing its size
  8392. this._ui.container.css( "max-width", rectangle.cx );
  8393. }
  8394. menuSize = {
  8395. cx: this._ui.container.outerWidth( true ),
  8396. cy: this._ui.container.outerHeight( true )
  8397. };
  8398. return { rc: rectangle, menuSize: menuSize };
  8399. },
  8400. _calculateFinalLocation: function( desired, clampInfo ) {
  8401. var returnValue,
  8402. rectangle = clampInfo.rc,
  8403. menuSize = clampInfo.menuSize;
  8404. // Center the menu over the desired coordinates, while not going outside
  8405. // the window tolerances. This will center wrt. the window if the popup is
  8406. // too large.
  8407. returnValue = {
  8408. left: fitSegmentInsideSegment( rectangle.cx, menuSize.cx, rectangle.x, desired.x ),
  8409. top: fitSegmentInsideSegment( rectangle.cy, menuSize.cy, rectangle.y, desired.y )
  8410. };
  8411. // Make sure the top of the menu is visible
  8412. returnValue.top = Math.max( 0, returnValue.top );
  8413. // If the height of the menu is smaller than the height of the document
  8414. // align the bottom with the bottom of the document
  8415. returnValue.top -= Math.min( returnValue.top,
  8416. Math.max( 0, returnValue.top + menuSize.cy - this.document.height() ) );
  8417. return returnValue;
  8418. },
  8419. // Try and center the overlay over the given coordinates
  8420. _placementCoords: function( desired ) {
  8421. return this._calculateFinalLocation( desired, this._clampPopupWidth() );
  8422. },
  8423. _createPrerequisites: function( screenPrerequisite, containerPrerequisite, whenDone ) {
  8424. var prerequisites,
  8425. self = this;
  8426. // It is important to maintain both the local variable prerequisites and
  8427. // self._prerequisites. The local variable remains in the closure of the
  8428. // functions which call the callbacks passed in. The comparison between the
  8429. // local variable and self._prerequisites is necessary, because once a
  8430. // function has been passed to .animationComplete() it will be called next
  8431. // time an animation completes, even if that's not the animation whose end
  8432. // the function was supposed to catch (for example, if an abort happens
  8433. // during the opening animation, the .animationComplete handler is not
  8434. // called for that animation anymore, but the handler remains attached, so
  8435. // it is called the next time the popup is opened - making it stale.
  8436. // Comparing the local variable prerequisites to the widget-level variable
  8437. // self._prerequisites ensures that callbacks triggered by a stale
  8438. // .animationComplete will be ignored.
  8439. prerequisites = {
  8440. screen: $.Deferred(),
  8441. container: $.Deferred()
  8442. };
  8443. prerequisites.screen.then( function() {
  8444. if ( prerequisites === self._prerequisites ) {
  8445. screenPrerequisite();
  8446. }
  8447. });
  8448. prerequisites.container.then( function() {
  8449. if ( prerequisites === self._prerequisites ) {
  8450. containerPrerequisite();
  8451. }
  8452. });
  8453. $.when( prerequisites.screen, prerequisites.container ).done( function() {
  8454. if ( prerequisites === self._prerequisites ) {
  8455. self._prerequisites = null;
  8456. whenDone();
  8457. }
  8458. });
  8459. self._prerequisites = prerequisites;
  8460. },
  8461. _animate: function( args ) {
  8462. // NOTE before removing the default animation of the screen
  8463. // this had an animate callback that would resolve the deferred
  8464. // now the deferred is resolved immediately
  8465. // TODO remove the dependency on the screen deferred
  8466. this._ui.screen
  8467. .removeClass( args.classToRemove )
  8468. .addClass( args.screenClassToAdd );
  8469. args.prerequisites.screen.resolve();
  8470. if ( args.transition && args.transition !== "none" ) {
  8471. if ( args.applyTransition ) {
  8472. this._applyTransition( args.transition );
  8473. }
  8474. if ( this._fallbackTransition ) {
  8475. this._ui.container
  8476. .animationComplete( $.proxy( args.prerequisites.container, "resolve" ) )
  8477. .addClass( args.containerClassToAdd )
  8478. .removeClass( args.classToRemove );
  8479. return;
  8480. }
  8481. }
  8482. this._ui.container.removeClass( args.classToRemove );
  8483. args.prerequisites.container.resolve();
  8484. },
  8485. // The desired coordinates passed in will be returned untouched if no reference element can be identified via
  8486. // desiredPosition.positionTo. Nevertheless, this function ensures that its return value always contains valid
  8487. // x and y coordinates by specifying the center middle of the window if the coordinates are absent.
  8488. // options: { x: coordinate, y: coordinate, positionTo: string: "origin", "window", or jQuery selector
  8489. _desiredCoords: function( openOptions ) {
  8490. var offset,
  8491. dst = null,
  8492. windowCoordinates = getWindowCoordinates( this.window ),
  8493. x = openOptions.x,
  8494. y = openOptions.y,
  8495. pTo = openOptions.positionTo;
  8496. // Establish which element will serve as the reference
  8497. if ( pTo && pTo !== "origin" ) {
  8498. if ( pTo === "window" ) {
  8499. x = windowCoordinates.cx / 2 + windowCoordinates.x;
  8500. y = windowCoordinates.cy / 2 + windowCoordinates.y;
  8501. } else {
  8502. try {
  8503. dst = $( pTo );
  8504. } catch( err ) {
  8505. dst = null;
  8506. }
  8507. if ( dst ) {
  8508. dst.filter( ":visible" );
  8509. if ( dst.length === 0 ) {
  8510. dst = null;
  8511. }
  8512. }
  8513. }
  8514. }
  8515. // If an element was found, center over it
  8516. if ( dst ) {
  8517. offset = dst.offset();
  8518. x = offset.left + dst.outerWidth() / 2;
  8519. y = offset.top + dst.outerHeight() / 2;
  8520. }
  8521. // Make sure x and y are valid numbers - center over the window
  8522. if ( $.type( x ) !== "number" || isNaN( x ) ) {
  8523. x = windowCoordinates.cx / 2 + windowCoordinates.x;
  8524. }
  8525. if ( $.type( y ) !== "number" || isNaN( y ) ) {
  8526. y = windowCoordinates.cy / 2 + windowCoordinates.y;
  8527. }
  8528. return { x: x, y: y };
  8529. },
  8530. _reposition: function( openOptions ) {
  8531. // We only care about position-related parameters for repositioning
  8532. openOptions = {
  8533. x: openOptions.x,
  8534. y: openOptions.y,
  8535. positionTo: openOptions.positionTo
  8536. };
  8537. this._trigger( "beforeposition", undefined, openOptions );
  8538. this._ui.container.offset( this._placementCoords( this._desiredCoords( openOptions ) ) );
  8539. },
  8540. reposition: function( openOptions ) {
  8541. if ( this._isOpen ) {
  8542. this._reposition( openOptions );
  8543. }
  8544. },
  8545. _openPrerequisitesComplete: function() {
  8546. var id = this.element.attr( "id" );
  8547. this._ui.container.addClass( "ui-popup-active" );
  8548. this._isOpen = true;
  8549. this._resizeScreen();
  8550. this._ui.container.attr( "tabindex", "0" ).focus();
  8551. this._ignoreResizeEvents();
  8552. if ( id ) {
  8553. this.document.find( "[aria-haspopup='true'][aria-owns='" + id + "']" ).attr( "aria-expanded", true );
  8554. }
  8555. this._trigger( "afteropen" );
  8556. },
  8557. _open: function( options ) {
  8558. var openOptions = $.extend( {}, this.options, options ),
  8559. // TODO move blacklist to private method
  8560. androidBlacklist = ( function() {
  8561. var ua = navigator.userAgent,
  8562. // Rendering engine is Webkit, and capture major version
  8563. wkmatch = ua.match( /AppleWebKit\/([0-9\.]+)/ ),
  8564. wkversion = !!wkmatch && wkmatch[ 1 ],
  8565. androidmatch = ua.match( /Android (\d+(?:\.\d+))/ ),
  8566. andversion = !!androidmatch && androidmatch[ 1 ],
  8567. chromematch = ua.indexOf( "Chrome" ) > -1;
  8568. // Platform is Android, WebKit version is greater than 534.13 ( Android 3.2.1 ) and not Chrome.
  8569. if ( androidmatch !== null && andversion === "4.0" && wkversion && wkversion > 534.13 && !chromematch ) {
  8570. return true;
  8571. }
  8572. return false;
  8573. }());
  8574. // Count down to triggering "popupafteropen" - we have two prerequisites:
  8575. // 1. The popup window animation completes (container())
  8576. // 2. The screen opacity animation completes (screen())
  8577. this._createPrerequisites(
  8578. $.noop,
  8579. $.noop,
  8580. $.proxy( this, "_openPrerequisitesComplete" ) );
  8581. this._currentTransition = openOptions.transition;
  8582. this._applyTransition( openOptions.transition );
  8583. this._ui.screen.removeClass( "ui-screen-hidden" );
  8584. this._ui.container.removeClass( "ui-popup-truncate" );
  8585. // Give applications a chance to modify the contents of the container before it appears
  8586. this._reposition( openOptions );
  8587. this._ui.container.removeClass( "ui-popup-hidden" );
  8588. if ( this.options.overlayTheme && androidBlacklist ) {
  8589. /* TODO: The native browser on Android 4.0.X ("Ice Cream Sandwich") suffers from an issue where the popup overlay appears to be z-indexed above the popup itself when certain other styles exist on the same page -- namely, any element set to `position: fixed` and certain types of input. These issues are reminiscent of previously uncovered bugs in older versions of Android's native browser: https://github.com/scottjehl/Device-Bugs/issues/3
  8590. This fix closes the following bugs ( I use "closes" with reluctance, and stress that this issue should be revisited as soon as possible ):
  8591. https://github.com/jquery/jquery-mobile/issues/4816
  8592. https://github.com/jquery/jquery-mobile/issues/4844
  8593. https://github.com/jquery/jquery-mobile/issues/4874
  8594. */
  8595. // TODO sort out why this._page isn't working
  8596. this.element.closest( ".ui-page" ).addClass( "ui-popup-open" );
  8597. }
  8598. this._animate({
  8599. additionalCondition: true,
  8600. transition: openOptions.transition,
  8601. classToRemove: "",
  8602. screenClassToAdd: "in",
  8603. containerClassToAdd: "in",
  8604. applyTransition: false,
  8605. prerequisites: this._prerequisites
  8606. });
  8607. },
  8608. _closePrerequisiteScreen: function() {
  8609. this._ui.screen
  8610. .removeClass( "out" )
  8611. .addClass( "ui-screen-hidden" );
  8612. },
  8613. _closePrerequisiteContainer: function() {
  8614. this._ui.container
  8615. .removeClass( "reverse out" )
  8616. .addClass( "ui-popup-hidden ui-popup-truncate" )
  8617. .removeAttr( "style" );
  8618. },
  8619. _closePrerequisitesDone: function() {
  8620. var container = this._ui.container,
  8621. id = this.element.attr( "id" );
  8622. container.removeAttr( "tabindex" );
  8623. // remove the global mutex for popups
  8624. $.mobile.popup.active = undefined;
  8625. // Blur elements inside the container, including the container
  8626. $( ":focus", container[ 0 ] ).add( container[ 0 ] ).blur();
  8627. if ( id ) {
  8628. this.document.find( "[aria-haspopup='true'][aria-owns='" + id + "']" ).attr( "aria-expanded", false );
  8629. }
  8630. // alert users that the popup is closed
  8631. this._trigger( "afterclose" );
  8632. },
  8633. _close: function( immediate ) {
  8634. this._ui.container.removeClass( "ui-popup-active" );
  8635. this._page.removeClass( "ui-popup-open" );
  8636. this._isOpen = false;
  8637. // Count down to triggering "popupafterclose" - we have two prerequisites:
  8638. // 1. The popup window reverse animation completes (container())
  8639. // 2. The screen opacity animation completes (screen())
  8640. this._createPrerequisites(
  8641. $.proxy( this, "_closePrerequisiteScreen" ),
  8642. $.proxy( this, "_closePrerequisiteContainer" ),
  8643. $.proxy( this, "_closePrerequisitesDone" ) );
  8644. this._animate( {
  8645. additionalCondition: this._ui.screen.hasClass( "in" ),
  8646. transition: ( immediate ? "none" : ( this._currentTransition ) ),
  8647. classToRemove: "in",
  8648. screenClassToAdd: "out",
  8649. containerClassToAdd: "reverse out",
  8650. applyTransition: true,
  8651. prerequisites: this._prerequisites
  8652. });
  8653. },
  8654. _unenhance: function() {
  8655. if ( this.options.enhanced ) {
  8656. return;
  8657. }
  8658. // Put the element back to where the placeholder was and remove the "ui-popup" class
  8659. this._setOptions( { theme: $.mobile.popup.prototype.options.theme } );
  8660. this.element
  8661. // Cannot directly insertAfter() - we need to detach() first, because
  8662. // insertAfter() will do nothing if the payload div was not attached
  8663. // to the DOM at the time the widget was created, and so the payload
  8664. // will remain inside the container even after we call insertAfter().
  8665. // If that happens and we remove the container a few lines below, we
  8666. // will cause an infinite recursion - #5244
  8667. .detach()
  8668. .insertAfter( this._ui.placeholder )
  8669. .removeClass( "ui-popup ui-overlay-shadow ui-corner-all ui-body-inherit" );
  8670. this._ui.screen.remove();
  8671. this._ui.container.remove();
  8672. this._ui.placeholder.remove();
  8673. },
  8674. _destroy: function() {
  8675. if ( $.mobile.popup.active === this ) {
  8676. this.element.one( "popupafterclose", $.proxy( this, "_unenhance" ) );
  8677. this.close();
  8678. } else {
  8679. this._unenhance();
  8680. }
  8681. return this;
  8682. },
  8683. _closePopup: function( theEvent, data ) {
  8684. var parsedDst, toUrl,
  8685. currentOptions = this.options,
  8686. immediate = false;
  8687. if ( ( theEvent && theEvent.isDefaultPrevented() ) || $.mobile.popup.active !== this ) {
  8688. return;
  8689. }
  8690. // restore location on screen
  8691. window.scrollTo( 0, this._scrollTop );
  8692. if ( theEvent && theEvent.type === "pagebeforechange" && data ) {
  8693. // Determine whether we need to rapid-close the popup, or whether we can
  8694. // take the time to run the closing transition
  8695. if ( typeof data.toPage === "string" ) {
  8696. parsedDst = data.toPage;
  8697. } else {
  8698. parsedDst = data.toPage.jqmData( "url" );
  8699. }
  8700. parsedDst = $.mobile.path.parseUrl( parsedDst );
  8701. toUrl = parsedDst.pathname + parsedDst.search + parsedDst.hash;
  8702. if ( this._myUrl !== $.mobile.path.makeUrlAbsolute( toUrl ) ) {
  8703. // Going to a different page - close immediately
  8704. immediate = true;
  8705. } else {
  8706. theEvent.preventDefault();
  8707. }
  8708. }
  8709. // remove nav bindings
  8710. this.window.off( currentOptions.closeEvents );
  8711. // unbind click handlers added when history is disabled
  8712. this.element.undelegate( currentOptions.closeLinkSelector, currentOptions.closeLinkEvents );
  8713. this._close( immediate );
  8714. },
  8715. // any navigation event after a popup is opened should close the popup
  8716. // NOTE the pagebeforechange is bound to catch navigation events that don't
  8717. // alter the url (eg, dialogs from popups)
  8718. _bindContainerClose: function() {
  8719. this.window
  8720. .on( this.options.closeEvents, $.proxy( this, "_closePopup" ) );
  8721. },
  8722. widget: function() {
  8723. return this._ui.container;
  8724. },
  8725. // TODO no clear deliniation of what should be here and
  8726. // what should be in _open. Seems to be "visual" vs "history" for now
  8727. open: function( options ) {
  8728. var url, hashkey, activePage, currentIsDialog, hasHash, urlHistory,
  8729. self = this,
  8730. currentOptions = this.options;
  8731. // make sure open is idempotent
  8732. if ( $.mobile.popup.active || currentOptions.disabled ) {
  8733. return this;
  8734. }
  8735. // set the global popup mutex
  8736. $.mobile.popup.active = this;
  8737. this._scrollTop = this.window.scrollTop();
  8738. // if history alteration is disabled close on navigate events
  8739. // and leave the url as is
  8740. if ( !( currentOptions.history ) ) {
  8741. self._open( options );
  8742. self._bindContainerClose();
  8743. // When histoy is disabled we have to grab the data-rel
  8744. // back link clicks so we can close the popup instead of
  8745. // relying on history to do it for us
  8746. self.element
  8747. .delegate( currentOptions.closeLinkSelector, currentOptions.closeLinkEvents, function( theEvent ) {
  8748. self.close();
  8749. theEvent.preventDefault();
  8750. });
  8751. return this;
  8752. }
  8753. // cache some values for min/readability
  8754. urlHistory = $.mobile.navigate.history;
  8755. hashkey = $.mobile.dialogHashKey;
  8756. activePage = $.mobile.activePage;
  8757. currentIsDialog = ( activePage ? activePage.hasClass( "ui-dialog" ) : false );
  8758. this._myUrl = url = urlHistory.getActive().url;
  8759. hasHash = ( url.indexOf( hashkey ) > -1 ) && !currentIsDialog && ( urlHistory.activeIndex > 0 );
  8760. if ( hasHash ) {
  8761. self._open( options );
  8762. self._bindContainerClose();
  8763. return this;
  8764. }
  8765. // if the current url has no dialog hash key proceed as normal
  8766. // otherwise, if the page is a dialog simply tack on the hash key
  8767. if ( url.indexOf( hashkey ) === -1 && !currentIsDialog ) {
  8768. url = url + (url.indexOf( "#" ) > -1 ? hashkey : "#" + hashkey);
  8769. } else {
  8770. url = $.mobile.path.parseLocation().hash + hashkey;
  8771. }
  8772. // Tack on an extra hashkey if this is the first page and we've just reconstructed the initial hash
  8773. if ( urlHistory.activeIndex === 0 && url === urlHistory.initialDst ) {
  8774. url += hashkey;
  8775. }
  8776. // swallow the the initial navigation event, and bind for the next
  8777. this.window.one( "beforenavigate", function( theEvent ) {
  8778. theEvent.preventDefault();
  8779. self._open( options );
  8780. self._bindContainerClose();
  8781. });
  8782. this.urlAltered = true;
  8783. $.mobile.navigate( url, { role: "dialog" } );
  8784. return this;
  8785. },
  8786. close: function() {
  8787. // make sure close is idempotent
  8788. if ( $.mobile.popup.active !== this ) {
  8789. return this;
  8790. }
  8791. this._scrollTop = this.window.scrollTop();
  8792. if ( this.options.history && this.urlAltered ) {
  8793. $.mobile.back();
  8794. this.urlAltered = false;
  8795. } else {
  8796. // simulate the nav bindings having fired
  8797. this._closePopup();
  8798. }
  8799. return this;
  8800. }
  8801. });
  8802. // TODO this can be moved inside the widget
  8803. $.mobile.popup.handleLink = function( $link ) {
  8804. var offset,
  8805. path = $.mobile.path,
  8806. // NOTE make sure to get only the hash from the href because ie7 (wp7)
  8807. // returns the absolute href in this case ruining the element selection
  8808. popup = $( path.hashToSelector( path.parseUrl( $link.attr( "href" ) ).hash ) ).first();
  8809. if ( popup.length > 0 && popup.data( "mobile-popup" ) ) {
  8810. offset = $link.offset();
  8811. popup.popup( "open", {
  8812. x: offset.left + $link.outerWidth() / 2,
  8813. y: offset.top + $link.outerHeight() / 2,
  8814. transition: $link.jqmData( "transition" ),
  8815. positionTo: $link.jqmData( "position-to" )
  8816. });
  8817. }
  8818. //remove after delay
  8819. setTimeout( function() {
  8820. $link.removeClass( $.mobile.activeBtnClass );
  8821. }, 300 );
  8822. };
  8823. // TODO move inside _create
  8824. $.mobile.document.on( "pagebeforechange", function( theEvent, data ) {
  8825. if ( data.options.role === "popup" ) {
  8826. $.mobile.popup.handleLink( data.options.link );
  8827. theEvent.preventDefault();
  8828. }
  8829. });
  8830. })( jQuery );
  8831. /*
  8832. * custom "selectmenu" plugin
  8833. */
  8834. (function( $, undefined ) {
  8835. var unfocusableItemSelector = ".ui-disabled,.ui-state-disabled,.ui-li-divider,.ui-screen-hidden,:jqmData(role='placeholder')",
  8836. goToAdjacentItem = function( item, target, direction ) {
  8837. var adjacent = item[ direction + "All" ]()
  8838. .not( unfocusableItemSelector )
  8839. .first();
  8840. // if there's a previous option, focus it
  8841. if ( adjacent.length ) {
  8842. target
  8843. .blur()
  8844. .attr( "tabindex", "-1" );
  8845. adjacent.find( "a" ).first().focus();
  8846. }
  8847. };
  8848. $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
  8849. _create: function() {
  8850. var o = this.options;
  8851. // Custom selects cannot exist inside popups, so revert the "nativeMenu"
  8852. // option to true if a parent is a popup
  8853. o.nativeMenu = o.nativeMenu || ( this.element.parents( ":jqmData(role='popup'),:mobile-popup" ).length > 0 );
  8854. return this._super();
  8855. },
  8856. _handleSelectFocus: function() {
  8857. this.element.blur();
  8858. this.button.focus();
  8859. },
  8860. _handleKeydown: function( event ) {
  8861. this._super( event );
  8862. this._handleButtonVclickKeydown( event );
  8863. },
  8864. _handleButtonVclickKeydown: function( event ) {
  8865. if ( this.options.disabled || this.isOpen ) {
  8866. return;
  8867. }
  8868. if (event.type === "vclick" ||
  8869. event.keyCode && (event.keyCode === $.mobile.keyCode.ENTER || event.keyCode === $.mobile.keyCode.SPACE)) {
  8870. this._decideFormat();
  8871. if ( this.menuType === "overlay" ) {
  8872. this.button.attr( "href", "#" + this.popupId ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "popup" );
  8873. } else {
  8874. this.button.attr( "href", "#" + this.dialogId ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "dialog" );
  8875. }
  8876. this.isOpen = true;
  8877. // Do not prevent default, so the navigation may have a chance to actually open the chosen format
  8878. }
  8879. },
  8880. _handleListFocus: function( e ) {
  8881. var params = ( e.type === "focusin" ) ?
  8882. { tabindex: "0", event: "vmouseover" }:
  8883. { tabindex: "-1", event: "vmouseout" };
  8884. $( e.target )
  8885. .attr( "tabindex", params.tabindex )
  8886. .trigger( params.event );
  8887. },
  8888. _handleListKeydown: function( event ) {
  8889. var target = $( event.target ),
  8890. li = target.closest( "li" );
  8891. // switch logic based on which key was pressed
  8892. switch ( event.keyCode ) {
  8893. // up or left arrow keys
  8894. case 38:
  8895. goToAdjacentItem( li, target, "prev" );
  8896. return false;
  8897. // down or right arrow keys
  8898. case 40:
  8899. goToAdjacentItem( li, target, "next" );
  8900. return false;
  8901. // If enter or space is pressed, trigger click
  8902. case 13:
  8903. case 32:
  8904. target.trigger( "click" );
  8905. return false;
  8906. }
  8907. },
  8908. _handleMenuPageHide: function() {
  8909. // TODO centralize page removal binding / handling in the page plugin.
  8910. // Suggestion from @jblas to do refcounting
  8911. //
  8912. // TODO extremely confusing dependency on the open method where the pagehide.remove
  8913. // bindings are stripped to prevent the parent page from disappearing. The way
  8914. // we're keeping pages in the DOM right now sucks
  8915. //
  8916. // rebind the page remove that was unbound in the open function
  8917. // to allow for the parent page removal from actions other than the use
  8918. // of a dialog sized custom select
  8919. //
  8920. // doing this here provides for the back button on the custom select dialog
  8921. this.thisPage.page( "bindRemove" );
  8922. },
  8923. _handleHeaderCloseClick: function() {
  8924. if ( this.menuType === "overlay" ) {
  8925. this.close();
  8926. return false;
  8927. }
  8928. },
  8929. build: function() {
  8930. var selectId, popupId, dialogId, label, thisPage, isMultiple, menuId, themeAttr, overlayThemeAttr,
  8931. dividerThemeAttr, menuPage, listbox, list, header, headerTitle, menuPageContent, menuPageClose, headerClose, self,
  8932. o = this.options;
  8933. if ( o.nativeMenu ) {
  8934. return this._super();
  8935. }
  8936. self = this;
  8937. selectId = this.selectId;
  8938. popupId = selectId + "-listbox";
  8939. dialogId = selectId + "-dialog";
  8940. label = this.label;
  8941. thisPage = this.element.closest( ".ui-page" );
  8942. isMultiple = this.element[ 0 ].multiple;
  8943. menuId = selectId + "-menu";
  8944. themeAttr = o.theme ? ( " data-" + $.mobile.ns + "theme='" + o.theme + "'" ) : "";
  8945. overlayThemeAttr = o.overlayTheme ? ( " data-" + $.mobile.ns + "theme='" + o.overlayTheme + "'" ) : "";
  8946. dividerThemeAttr = ( o.dividerTheme && isMultiple ) ? ( " data-" + $.mobile.ns + "divider-theme='" + o.dividerTheme + "'" ) : "";
  8947. menuPage = $( "<div data-" + $.mobile.ns + "role='dialog' class='ui-selectmenu' id='" + dialogId + "'" + themeAttr + overlayThemeAttr + ">" +
  8948. "<div data-" + $.mobile.ns + "role='header'>" +
  8949. "<div class='ui-title'>" + label.getEncodedText() + "</div>"+
  8950. "</div>"+
  8951. "<div data-" + $.mobile.ns + "role='content'></div>"+
  8952. "</div>" );
  8953. listbox = $( "<div id='" + popupId + "' class='ui-selectmenu'>" ).insertAfter( this.select ).popup({ theme: o.overlayTheme });
  8954. list = $( "<ul class='ui-selectmenu-list' id='" + menuId + "' role='listbox' aria-labelledby='" + this.buttonId + "'" + themeAttr + dividerThemeAttr + ">" ).appendTo( listbox );
  8955. header = $( "<div class='ui-header ui-bar-" + ( o.theme ? o.theme : "inherit" ) + "'>" ).prependTo( listbox );
  8956. headerTitle = $( "<h1 class='ui-title'>" ).appendTo( header );
  8957. if ( this.isMultiple ) {
  8958. headerClose = $( "<a>", {
  8959. "role": "button",
  8960. "text": o.closeText,
  8961. "href": "#",
  8962. "class": "ui-btn ui-corner-all ui-btn-left ui-btn-icon-notext ui-icon-delete"
  8963. }).appendTo( header );
  8964. }
  8965. $.extend( this, {
  8966. selectId: selectId,
  8967. menuId: menuId,
  8968. popupId: popupId,
  8969. dialogId: dialogId,
  8970. thisPage: thisPage,
  8971. menuPage: menuPage,
  8972. label: label,
  8973. isMultiple: isMultiple,
  8974. theme: o.theme,
  8975. listbox: listbox,
  8976. list: list,
  8977. header: header,
  8978. headerTitle: headerTitle,
  8979. headerClose: headerClose,
  8980. menuPageContent: menuPageContent,
  8981. menuPageClose: menuPageClose,
  8982. placeholder: ""
  8983. });
  8984. // Create list from select, update state
  8985. this.refresh();
  8986. if ( this._origTabIndex === undefined ) {
  8987. // Map undefined to false, because this._origTabIndex === undefined
  8988. // indicates that we have not yet checked whether the select has
  8989. // originally had a tabindex attribute, whereas false indicates that
  8990. // we have checked the select for such an attribute, and have found
  8991. // none present.
  8992. this._origTabIndex = ( this.select[ 0 ].getAttribute( "tabindex" ) === null ) ? false : this.select.attr( "tabindex" );
  8993. }
  8994. this.select.attr( "tabindex", "-1" );
  8995. this._on( this.select, { focus : "_handleSelectFocus" } );
  8996. // Button events
  8997. this._on( this.button, {
  8998. vclick: "_handleButtonVclickKeydown"
  8999. });
  9000. // Events for list items
  9001. this.list.attr( "role", "listbox" );
  9002. this._on( this.list, {
  9003. focusin : "_handleListFocus",
  9004. focusout : "_handleListFocus",
  9005. keydown: "_handleListKeydown"
  9006. });
  9007. this.list
  9008. .delegate( "li:not(.ui-disabled,.ui-state-disabled,.ui-li-divider)", "click", function( event ) {
  9009. // index of option tag to be selected
  9010. var oldIndex = self.select[ 0 ].selectedIndex,
  9011. newIndex = $.mobile.getAttribute( this, "option-index" ),
  9012. option = self._selectOptions().eq( newIndex )[ 0 ];
  9013. // toggle selected status on the tag for multi selects
  9014. option.selected = self.isMultiple ? !option.selected : true;
  9015. // toggle checkbox class for multiple selects
  9016. if ( self.isMultiple ) {
  9017. $( this ).find( "a" )
  9018. .toggleClass( "ui-checkbox-on", option.selected )
  9019. .toggleClass( "ui-checkbox-off", !option.selected );
  9020. }
  9021. // trigger change if value changed
  9022. if ( self.isMultiple || oldIndex !== newIndex ) {
  9023. self.select.trigger( "change" );
  9024. }
  9025. // hide custom select for single selects only - otherwise focus clicked item
  9026. // We need to grab the clicked item the hard way, because the list may have been rebuilt
  9027. if ( self.isMultiple ) {
  9028. self.list.find( "li:not(.ui-li-divider)" ).eq( newIndex )
  9029. .find( "a" ).first().focus();
  9030. }
  9031. else {
  9032. self.close();
  9033. }
  9034. event.preventDefault();
  9035. });
  9036. // button refocus ensures proper height calculation
  9037. // by removing the inline style and ensuring page inclusion
  9038. this._on( this.menuPage, { pagehide: "_handleMenuPageHide" } );
  9039. // Events on the popup
  9040. this._on( this.listbox, { popupafterclose: "close" } );
  9041. // Close button on small overlays
  9042. if ( this.isMultiple ) {
  9043. this._on( this.headerClose, { click: "_handleHeaderCloseClick" } );
  9044. }
  9045. return this;
  9046. },
  9047. _isRebuildRequired: function() {
  9048. var list = this.list.find( "li" ),
  9049. options = this._selectOptions().not( ".ui-screen-hidden" );
  9050. // TODO exceedingly naive method to determine difference
  9051. // ignores value changes etc in favor of a forcedRebuild
  9052. // from the user in the refresh method
  9053. return options.text() !== list.text();
  9054. },
  9055. selected: function() {
  9056. return this._selectOptions().filter( ":selected:not( :jqmData(placeholder='true') )" );
  9057. },
  9058. refresh: function( force ) {
  9059. var self, indices;
  9060. if ( this.options.nativeMenu ) {
  9061. return this._super( force );
  9062. }
  9063. self = this;
  9064. if ( force || this._isRebuildRequired() ) {
  9065. self._buildList();
  9066. }
  9067. indices = this.selectedIndices();
  9068. self.setButtonText();
  9069. self.setButtonCount();
  9070. self.list.find( "li:not(.ui-li-divider)" )
  9071. .find( "a" ).removeClass( $.mobile.activeBtnClass ).end()
  9072. .attr( "aria-selected", false )
  9073. .each(function( i ) {
  9074. if ( $.inArray( i, indices ) > -1 ) {
  9075. var item = $( this );
  9076. // Aria selected attr
  9077. item.attr( "aria-selected", true );
  9078. // Multiple selects: add the "on" checkbox state to the icon
  9079. if ( self.isMultiple ) {
  9080. item.find( "a" ).removeClass( "ui-checkbox-off" ).addClass( "ui-checkbox-on" );
  9081. } else {
  9082. if ( item.hasClass( "ui-screen-hidden" ) ) {
  9083. item.next().find( "a" ).addClass( $.mobile.activeBtnClass );
  9084. } else {
  9085. item.find( "a" ).addClass( $.mobile.activeBtnClass );
  9086. }
  9087. }
  9088. }
  9089. });
  9090. },
  9091. close: function() {
  9092. if ( this.options.disabled || !this.isOpen ) {
  9093. return;
  9094. }
  9095. var self = this;
  9096. if ( self.menuType === "page" ) {
  9097. self.menuPage.dialog( "close" );
  9098. self.list.appendTo( self.listbox );
  9099. } else {
  9100. self.listbox.popup( "close" );
  9101. }
  9102. self._focusButton();
  9103. // allow the dialog to be closed again
  9104. self.isOpen = false;
  9105. },
  9106. open: function() {
  9107. this.button.click();
  9108. },
  9109. _focusMenuItem: function() {
  9110. var selector = this.list.find( "a." + $.mobile.activeBtnClass );
  9111. if ( selector.length === 0 ) {
  9112. selector = this.list.find( "li:not(" + unfocusableItemSelector + ") a.ui-btn" );
  9113. }
  9114. selector.first().focus();
  9115. },
  9116. _decideFormat: function() {
  9117. var self = this,
  9118. $window = this.window,
  9119. selfListParent = self.list.parent(),
  9120. menuHeight = selfListParent.outerHeight(),
  9121. scrollTop = $window.scrollTop(),
  9122. btnOffset = self.button.offset().top,
  9123. screenHeight = $window.height();
  9124. if ( menuHeight > screenHeight - 80 || !$.support.scrollTop ) {
  9125. self.menuPage.appendTo( $.mobile.pageContainer ).page();
  9126. self.menuPageContent = self.menuPage.find( ".ui-content" );
  9127. self.menuPageClose = self.menuPage.find( ".ui-header a" );
  9128. // prevent the parent page from being removed from the DOM,
  9129. // otherwise the results of selecting a list item in the dialog
  9130. // fall into a black hole
  9131. self.thisPage.unbind( "pagehide.remove" );
  9132. //for WebOS/Opera Mini (set lastscroll using button offset)
  9133. if ( scrollTop === 0 && btnOffset > screenHeight ) {
  9134. self.thisPage.one( "pagehide", function() {
  9135. $( this ).jqmData( "lastScroll", btnOffset );
  9136. });
  9137. }
  9138. self.menuPage.one( {
  9139. pageshow: $.proxy( this, "_focusMenuItem" ),
  9140. pagehide: $.proxy( this, "close" )
  9141. });
  9142. self.menuType = "page";
  9143. self.menuPageContent.append( self.list );
  9144. self.menuPage.find( "div .ui-title" ).text( self.label.text() );
  9145. } else {
  9146. self.menuType = "overlay";
  9147. self.listbox.one( { popupafteropen: $.proxy( this, "_focusMenuItem" ) } );
  9148. }
  9149. },
  9150. _buildList: function() {
  9151. var self = this,
  9152. o = this.options,
  9153. placeholder = this.placeholder,
  9154. needPlaceholder = true,
  9155. dataIcon = "false",
  9156. $options, numOptions, select,
  9157. dataPrefix = "data-" + $.mobile.ns,
  9158. dataIndexAttr = dataPrefix + "option-index",
  9159. dataIconAttr = dataPrefix + "icon",
  9160. dataRoleAttr = dataPrefix + "role",
  9161. dataPlaceholderAttr = dataPrefix + "placeholder",
  9162. fragment = document.createDocumentFragment(),
  9163. isPlaceholderItem = false,
  9164. optGroup,
  9165. i,
  9166. option, $option, parent, text, anchor, classes,
  9167. optLabel, divider, item;
  9168. self.list.empty().filter( ".ui-listview" ).listview( "destroy" );
  9169. $options = this._selectOptions();
  9170. numOptions = $options.length;
  9171. select = this.select[ 0 ];
  9172. for ( i = 0; i < numOptions;i++, isPlaceholderItem = false) {
  9173. option = $options[i];
  9174. $option = $( option );
  9175. // Do not create options based on ui-screen-hidden select options
  9176. if ( $option.hasClass( "ui-screen-hidden" ) ) {
  9177. continue;
  9178. }
  9179. parent = option.parentNode;
  9180. text = $option.text();
  9181. anchor = document.createElement( "a" );
  9182. classes = [];
  9183. anchor.setAttribute( "href", "#" );
  9184. anchor.appendChild( document.createTextNode( text ) );
  9185. // Are we inside an optgroup?
  9186. if ( parent !== select && parent.nodeName.toLowerCase() === "optgroup" ) {
  9187. optLabel = parent.getAttribute( "label" );
  9188. if ( optLabel !== optGroup ) {
  9189. divider = document.createElement( "li" );
  9190. divider.setAttribute( dataRoleAttr, "list-divider" );
  9191. divider.setAttribute( "role", "option" );
  9192. divider.setAttribute( "tabindex", "-1" );
  9193. divider.appendChild( document.createTextNode( optLabel ) );
  9194. fragment.appendChild( divider );
  9195. optGroup = optLabel;
  9196. }
  9197. }
  9198. if ( needPlaceholder && ( !option.getAttribute( "value" ) || text.length === 0 || $option.jqmData( "placeholder" ) ) ) {
  9199. needPlaceholder = false;
  9200. isPlaceholderItem = true;
  9201. // If we have identified a placeholder, record the fact that it was
  9202. // us who have added the placeholder to the option and mark it
  9203. // retroactively in the select as well
  9204. if ( null === option.getAttribute( dataPlaceholderAttr ) ) {
  9205. this._removePlaceholderAttr = true;
  9206. }
  9207. option.setAttribute( dataPlaceholderAttr, true );
  9208. if ( o.hidePlaceholderMenuItems ) {
  9209. classes.push( "ui-screen-hidden" );
  9210. }
  9211. if ( placeholder !== text ) {
  9212. placeholder = self.placeholder = text;
  9213. }
  9214. }
  9215. item = document.createElement( "li" );
  9216. if ( option.disabled ) {
  9217. classes.push( "ui-state-disabled" );
  9218. item.setAttribute( "aria-disabled", true );
  9219. }
  9220. item.setAttribute( dataIndexAttr, i );
  9221. item.setAttribute( dataIconAttr, dataIcon );
  9222. if ( isPlaceholderItem ) {
  9223. item.setAttribute( dataPlaceholderAttr, true );
  9224. }
  9225. item.className = classes.join( " " );
  9226. item.setAttribute( "role", "option" );
  9227. anchor.setAttribute( "tabindex", "-1" );
  9228. if ( this.isMultiple ) {
  9229. $( anchor ).addClass( "ui-btn ui-checkbox-off ui-btn-icon-right" );
  9230. }
  9231. item.appendChild( anchor );
  9232. fragment.appendChild( item );
  9233. }
  9234. self.list[0].appendChild( fragment );
  9235. // Hide header if it's not a multiselect and there's no placeholder
  9236. if ( !this.isMultiple && !placeholder.length ) {
  9237. this.header.addClass( "ui-screen-hidden" );
  9238. } else {
  9239. this.headerTitle.text( this.placeholder );
  9240. }
  9241. // Now populated, create listview
  9242. self.list.listview();
  9243. },
  9244. _button: function() {
  9245. return this.options.nativeMenu ?
  9246. this._super() :
  9247. $( "<a>", {
  9248. "href": "#",
  9249. "role": "button",
  9250. // TODO value is undefined at creation
  9251. "id": this.buttonId,
  9252. "aria-haspopup": "true",
  9253. // TODO value is undefined at creation
  9254. "aria-owns": this.menuId
  9255. });
  9256. },
  9257. _destroy: function() {
  9258. if ( !this.options.nativeMenu ) {
  9259. this.close();
  9260. // Restore the tabindex attribute to its original value
  9261. if ( this._origTabIndex !== undefined ) {
  9262. if ( this._origTabIndex !== false ) {
  9263. this.select.attr( "tabindex", this._origTabIndex );
  9264. } else {
  9265. this.select.removeAttr( "tabindex" );
  9266. }
  9267. }
  9268. // Remove the placeholder attribute if we were the ones to add it
  9269. if ( this._removePlaceholderAttr ) {
  9270. this._selectOptions().removeAttr( "data-" + $.mobile.ns + "placeholder" );
  9271. }
  9272. // Remove the popup
  9273. this.listbox.remove();
  9274. // Remove the dialog
  9275. this.menuPage.remove();
  9276. }
  9277. // Chain up
  9278. this._super();
  9279. }
  9280. });
  9281. })( jQuery );
  9282. // buttonMarkup is deprecated as of 1.4.0 and will be removed in 1.5.0.
  9283. (function( $, undefined ) {
  9284. // General policy: Do not access data-* attributes except during enhancement.
  9285. // In all other cases we determine the state of the button exclusively from its
  9286. // className. That's why optionsToClasses expects a full complement of options,
  9287. // and the jQuery plugin completes the set of options from the default values.
  9288. // Map classes to buttonMarkup boolean options - used in classNameToOptions()
  9289. var reverseBoolOptionMap = {
  9290. "ui-shadow" : "shadow",
  9291. "ui-corner-all" : "corners",
  9292. "ui-btn-inline" : "inline",
  9293. "ui-shadow-icon" : "iconshadow", /* TODO: Remove in 1.5 */
  9294. "ui-mini" : "mini"
  9295. },
  9296. getAttrFixed = function() {
  9297. var ret = $.mobile.getAttribute.apply( this, arguments );
  9298. return ( ret == null ? undefined : ret );
  9299. },
  9300. capitalLettersRE = /[A-Z]/g;
  9301. // optionsToClasses:
  9302. // @options: A complete set of options to convert to class names.
  9303. // @existingClasses: extra classes to add to the result
  9304. //
  9305. // Converts @options to buttonMarkup classes and returns the result as an array
  9306. // that can be converted to an element's className with .join( " " ). All
  9307. // possible options must be set inside @options. Use $.fn.buttonMarkup.defaults
  9308. // to get a complete set and use $.extend to override your choice of options
  9309. // from that set.
  9310. function optionsToClasses( options, existingClasses ) {
  9311. var classes = existingClasses ? existingClasses : [];
  9312. // Add classes to the array - first ui-btn
  9313. classes.push( "ui-btn" );
  9314. // If there is a theme
  9315. if ( options.theme ) {
  9316. classes.push( "ui-btn-" + options.theme );
  9317. }
  9318. // If there's an icon, add the icon-related classes
  9319. if ( options.icon ) {
  9320. classes = classes.concat([
  9321. "ui-icon-" + options.icon,
  9322. "ui-btn-icon-" + options.iconpos
  9323. ]);
  9324. if ( options.iconshadow ) {
  9325. classes.push( "ui-shadow-icon" ); /* TODO: Remove in 1.5 */
  9326. }
  9327. }
  9328. // Add the appropriate class for each boolean option
  9329. if ( options.inline ) {
  9330. classes.push( "ui-btn-inline" );
  9331. }
  9332. if ( options.shadow ) {
  9333. classes.push( "ui-shadow" );
  9334. }
  9335. if ( options.corners ) {
  9336. classes.push( "ui-corner-all" );
  9337. }
  9338. if ( options.mini ) {
  9339. classes.push( "ui-mini" );
  9340. }
  9341. // Create a string from the array and return it
  9342. return classes;
  9343. }
  9344. // classNameToOptions:
  9345. // @classes: A string containing a .className-style space-separated class list
  9346. //
  9347. // Loops over @classes and calculates an options object based on the
  9348. // buttonMarkup-related classes it finds. It records unrecognized classes in an
  9349. // array.
  9350. //
  9351. // Returns: An object containing the following items:
  9352. //
  9353. // "options": buttonMarkup options found to be present because of the
  9354. // presence/absence of corresponding classes
  9355. //
  9356. // "unknownClasses": a string containing all the non-buttonMarkup-related
  9357. // classes found in @classes
  9358. //
  9359. // "alreadyEnhanced": A boolean indicating whether the ui-btn class was among
  9360. // those found to be present
  9361. function classNameToOptions( classes ) {
  9362. var idx, map, unknownClass,
  9363. alreadyEnhanced = false,
  9364. noIcon = true,
  9365. o = {
  9366. icon: "",
  9367. inline: false,
  9368. shadow: false,
  9369. corners: false,
  9370. iconshadow: false,
  9371. mini: false
  9372. },
  9373. unknownClasses = [];
  9374. classes = classes.split( " " );
  9375. // Loop over the classes
  9376. for ( idx = 0 ; idx < classes.length ; idx++ ) {
  9377. // Assume it's an unrecognized class
  9378. unknownClass = true;
  9379. // Recognize boolean options from the presence of classes
  9380. map = reverseBoolOptionMap[ classes[ idx ] ];
  9381. if ( map !== undefined ) {
  9382. unknownClass = false;
  9383. o[ map ] = true;
  9384. // Recognize the presence of an icon and establish the icon position
  9385. } else if ( classes[ idx ].indexOf( "ui-btn-icon-" ) === 0 ) {
  9386. unknownClass = false;
  9387. noIcon = false;
  9388. o.iconpos = classes[ idx ].substring( 12 );
  9389. // Establish which icon is present
  9390. } else if ( classes[ idx ].indexOf( "ui-icon-" ) === 0 ) {
  9391. unknownClass = false;
  9392. o.icon = classes[ idx ].substring( 8 );
  9393. // Establish the theme - this recognizes one-letter theme swatch names
  9394. } else if ( classes[ idx ].indexOf( "ui-btn-" ) === 0 && classes[ idx ].length === 8 ) {
  9395. unknownClass = false;
  9396. o.theme = classes[ idx ].substring( 7 );
  9397. // Recognize that this element has already been buttonMarkup-enhanced
  9398. } else if ( classes[ idx ] === "ui-btn" ) {
  9399. unknownClass = false;
  9400. alreadyEnhanced = true;
  9401. }
  9402. // If this class has not been recognized, add it to the list
  9403. if ( unknownClass ) {
  9404. unknownClasses.push( classes[ idx ] );
  9405. }
  9406. }
  9407. // If a "ui-btn-icon-*" icon position class is absent there cannot be an icon
  9408. if ( noIcon ) {
  9409. o.icon = "";
  9410. }
  9411. return {
  9412. options: o,
  9413. unknownClasses: unknownClasses,
  9414. alreadyEnhanced: alreadyEnhanced
  9415. };
  9416. }
  9417. function camelCase2Hyphenated( c ) {
  9418. return "-" + c.toLowerCase();
  9419. }
  9420. // $.fn.buttonMarkup:
  9421. // DOM: gets/sets .className
  9422. //
  9423. // @options: options to apply to the elements in the jQuery object
  9424. // @overwriteClasses: boolean indicating whether to honour existing classes
  9425. //
  9426. // Calculates the classes to apply to the elements in the jQuery object based on
  9427. // the options passed in. If @overwriteClasses is true, it sets the className
  9428. // property of each element in the jQuery object to the buttonMarkup classes
  9429. // it calculates based on the options passed in.
  9430. //
  9431. // If you wish to preserve any classes that are already present on the elements
  9432. // inside the jQuery object, including buttonMarkup-related classes that were
  9433. // added by a previous call to $.fn.buttonMarkup() or during page enhancement
  9434. // then you should omit @overwriteClasses or set it to false.
  9435. $.fn.buttonMarkup = function( options, overwriteClasses ) {
  9436. var idx, data, el, retrievedOptions, optionKey,
  9437. defaults = $.fn.buttonMarkup.defaults;
  9438. for ( idx = 0 ; idx < this.length ; idx++ ) {
  9439. el = this[ idx ];
  9440. data = overwriteClasses ?
  9441. // Assume this element is not enhanced and ignore its classes
  9442. { alreadyEnhanced: false, unknownClasses: [] } :
  9443. // Otherwise analyze existing classes to establish existing options and
  9444. // classes
  9445. classNameToOptions( el.className );
  9446. retrievedOptions = $.extend( {},
  9447. // If the element already has the class ui-btn, then we assume that
  9448. // it has passed through buttonMarkup before - otherwise, the options
  9449. // returned by classNameToOptions do not correctly reflect the state of
  9450. // the element
  9451. ( data.alreadyEnhanced ? data.options : {} ),
  9452. // Finally, apply the options passed in
  9453. options );
  9454. // If this is the first call on this element, retrieve remaining options
  9455. // from the data-attributes
  9456. if ( !data.alreadyEnhanced ) {
  9457. for ( optionKey in defaults ) {
  9458. if ( retrievedOptions[ optionKey ] === undefined ) {
  9459. retrievedOptions[ optionKey ] = getAttrFixed( el,
  9460. optionKey.replace( capitalLettersRE, camelCase2Hyphenated )
  9461. );
  9462. }
  9463. }
  9464. }
  9465. el.className = optionsToClasses(
  9466. // Merge all the options and apply them as classes
  9467. $.extend( {},
  9468. // The defaults form the basis
  9469. defaults,
  9470. // Add the computed options
  9471. retrievedOptions
  9472. ),
  9473. // ... and re-apply any unrecognized classes that were found
  9474. data.unknownClasses ).join( " " );
  9475. if ( el.tagName.toLowerCase() !== "button" ) {
  9476. el.setAttribute( "role", "button" );
  9477. }
  9478. }
  9479. return this;
  9480. };
  9481. // buttonMarkup defaults. This must be a complete set, i.e., a value must be
  9482. // given here for all recognized options
  9483. $.fn.buttonMarkup.defaults = {
  9484. icon: "",
  9485. iconpos: "left",
  9486. theme: null,
  9487. inline: false,
  9488. shadow: true,
  9489. corners: true,
  9490. iconshadow: false, /* TODO: Remove in 1.5. Option deprecated in 1.4. */
  9491. mini: false
  9492. };
  9493. $.extend( $.fn.buttonMarkup, {
  9494. initSelector: "a:jqmData(role='button'), .ui-bar > a, .ui-bar > :jqmData(role='controlgroup') > a, button"
  9495. });
  9496. })( jQuery );
  9497. (function( $, undefined ) {
  9498. $.widget( "mobile.controlgroup", $.extend( {
  9499. options: {
  9500. enhanced: false,
  9501. theme: null,
  9502. shadow: false,
  9503. corners: true,
  9504. excludeInvisible: true,
  9505. type: "vertical",
  9506. mini: false
  9507. },
  9508. _create: function() {
  9509. var elem = this.element,
  9510. opts = this.options;
  9511. // Run buttonmarkup
  9512. if ( $.fn.buttonMarkup ) {
  9513. this.element.find( $.fn.buttonMarkup.initSelector ).buttonMarkup();
  9514. }
  9515. // Enhance child widgets
  9516. $.each( this._childWidgets, $.proxy( function( number, widgetName ) {
  9517. if ( $.mobile[ widgetName ] ) {
  9518. this.element.find( $.mobile[ widgetName ].initSelector ).not( $.mobile.page.prototype.keepNativeSelector() )[ widgetName ]();
  9519. }
  9520. }, this ));
  9521. $.extend( this, {
  9522. _ui: null,
  9523. _initialRefresh: true
  9524. });
  9525. if ( opts.enhanced ) {
  9526. this._ui = {
  9527. groupLegend: elem.children( ".ui-controlgroup-label" ).children(),
  9528. childWrapper: elem.children( ".ui-controlgroup-controls" )
  9529. };
  9530. } else {
  9531. this._ui = this._enhance();
  9532. }
  9533. },
  9534. _childWidgets: [ "checkboxradio", "selectmenu", "button" ],
  9535. _themeClassFromOption: function( value ) {
  9536. return ( value ? ( value === "none" ? "" : "ui-group-theme-" + value ) : "" );
  9537. },
  9538. _enhance: function() {
  9539. var elem = this.element,
  9540. opts = this.options,
  9541. ui = {
  9542. groupLegend: elem.children( "legend" ),
  9543. childWrapper: elem
  9544. .addClass( "ui-controlgroup " +
  9545. "ui-controlgroup-" +
  9546. ( opts.type === "horizontal" ? "horizontal" : "vertical" ) + " " +
  9547. this._themeClassFromOption( opts.theme ) + " " +
  9548. ( opts.corners ? "ui-corner-all " : "" ) +
  9549. ( opts.mini ? "ui-mini " : "" ) )
  9550. .wrapInner( "<div " +
  9551. "class='ui-controlgroup-controls " +
  9552. ( opts.shadow === true ? "ui-shadow" : "" ) + "'></div>" )
  9553. .children()
  9554. };
  9555. if ( ui.groupLegend.length > 0 ) {
  9556. $( "<div role='heading' class='ui-controlgroup-label'></div>" )
  9557. .append( ui.groupLegend )
  9558. .prependTo( elem );
  9559. }
  9560. return ui;
  9561. },
  9562. _init: function() {
  9563. this.refresh();
  9564. },
  9565. _setOptions: function( options ) {
  9566. var callRefresh, returnValue,
  9567. elem = this.element;
  9568. // Must have one of horizontal or vertical
  9569. if ( options.type !== undefined ) {
  9570. elem
  9571. .removeClass( "ui-controlgroup-horizontal ui-controlgroup-vertical" )
  9572. .addClass( "ui-controlgroup-" + ( options.type === "horizontal" ? "horizontal" : "vertical" ) );
  9573. callRefresh = true;
  9574. }
  9575. if ( options.theme !== undefined ) {
  9576. elem
  9577. .removeClass( this._themeClassFromOption( this.options.theme ) )
  9578. .addClass( this._themeClassFromOption( options.theme ) );
  9579. }
  9580. if ( options.corners !== undefined ) {
  9581. elem.toggleClass( "ui-corner-all", options.corners );
  9582. }
  9583. if ( options.mini !== undefined ) {
  9584. elem.toggleClass( "ui-mini", options.mini );
  9585. }
  9586. if ( options.shadow !== undefined ) {
  9587. this._ui.childWrapper.toggleClass( "ui-shadow", options.shadow );
  9588. }
  9589. if ( options.excludeInvisible !== undefined ) {
  9590. this.options.excludeInvisible = options.excludeInvisible;
  9591. callRefresh = true;
  9592. }
  9593. returnValue = this._super( options );
  9594. if ( callRefresh ) {
  9595. this.refresh();
  9596. }
  9597. return returnValue;
  9598. },
  9599. container: function() {
  9600. return this._ui.childWrapper;
  9601. },
  9602. refresh: function() {
  9603. var $el = this.container(),
  9604. els = $el.find( ".ui-btn" ).not( ".ui-slider-handle" ),
  9605. create = this._initialRefresh;
  9606. if ( $.mobile.checkboxradio ) {
  9607. $el.find( ":mobile-checkboxradio" ).checkboxradio( "refresh" );
  9608. }
  9609. this._addFirstLastClasses( els,
  9610. this.options.excludeInvisible ? this._getVisibles( els, create ) : els,
  9611. create );
  9612. this._initialRefresh = false;
  9613. },
  9614. // Caveat: If the legend is not the first child of the controlgroup at enhance
  9615. // time, it will be after _destroy().
  9616. _destroy: function() {
  9617. var ui, buttons,
  9618. opts = this.options;
  9619. if ( opts.enhanced ) {
  9620. return this;
  9621. }
  9622. ui = this._ui;
  9623. buttons = this.element
  9624. .removeClass( "ui-controlgroup " +
  9625. "ui-controlgroup-horizontal ui-controlgroup-vertical ui-corner-all ui-mini " +
  9626. this._themeClassFromOption( opts.theme ) )
  9627. .find( ".ui-btn" )
  9628. .not( ".ui-slider-handle" );
  9629. this._removeFirstLastClasses( buttons );
  9630. ui.groupLegend.unwrap();
  9631. ui.childWrapper.children().unwrap();
  9632. }
  9633. }, $.mobile.behaviors.addFirstLastClasses ) );
  9634. })(jQuery);
  9635. (function( $, undefined ) {
  9636. $.widget( "mobile.toolbar", {
  9637. initSelector: ":jqmData(role='footer'), :jqmData(role='header')",
  9638. options: {
  9639. theme: null,
  9640. addBackBtn: false,
  9641. backBtnTheme: null,
  9642. backBtnText: "Back"
  9643. },
  9644. _create: function() {
  9645. var leftbtn, rightbtn,
  9646. role = this.element.is( ":jqmData(role='header')" ) ? "header" : "footer",
  9647. page = this.element.closest( ".ui-page" );
  9648. if ( page.length === 0 ) {
  9649. page = false;
  9650. this._on( this.document, {
  9651. "pageshow": "refresh"
  9652. });
  9653. }
  9654. $.extend( this, {
  9655. role: role,
  9656. page: page,
  9657. leftbtn: leftbtn,
  9658. rightbtn: rightbtn,
  9659. backBtn: null
  9660. });
  9661. this.element.attr( "role", role === "header" ? "banner" : "contentinfo" ).addClass( "ui-" + role );
  9662. this.refresh();
  9663. this._setOptions( this.options );
  9664. },
  9665. _setOptions: function( o ) {
  9666. if ( o.addBackBtn !== undefined ) {
  9667. if ( this.options.addBackBtn &&
  9668. this.role === "header" &&
  9669. $( ".ui-page" ).length > 1 &&
  9670. this.page[ 0 ].getAttribute( "data-" + $.mobile.ns + "url" ) !== $.mobile.path.stripHash( location.hash ) &&
  9671. !this.leftbtn ) {
  9672. this._addBackButton();
  9673. } else {
  9674. this.element.find( ".ui-toolbar-back-btn" ).remove();
  9675. }
  9676. }
  9677. if ( o.backBtnTheme != null ) {
  9678. this.element
  9679. .find( ".ui-toolbar-back-btn" )
  9680. .addClass( "ui-btn ui-btn-" + o.backBtnTheme );
  9681. }
  9682. if ( o.backBtnText !== undefined ) {
  9683. this.element.find( ".ui-toolbar-back-btn .ui-btn-text" ).text( o.backBtnText );
  9684. }
  9685. if ( o.theme !== undefined ) {
  9686. var currentTheme = this.options.theme ? this.options.theme : "inherit",
  9687. newTheme = o.theme ? o.theme : "inherit";
  9688. this.element.removeClass( "ui-bar-" + currentTheme ).addClass( "ui-bar-" + newTheme );
  9689. }
  9690. this._super( o );
  9691. },
  9692. refresh: function() {
  9693. if ( this.role === "header" ) {
  9694. this._addHeaderButtonClasses();
  9695. }
  9696. if ( !this.page ) {
  9697. this._setRelative();
  9698. if ( this.role === "footer" ) {
  9699. this.element.appendTo( "body" );
  9700. }
  9701. }
  9702. this._addHeadingClasses();
  9703. this._btnMarkup();
  9704. },
  9705. //we only want this to run on non fixed toolbars so make it easy to override
  9706. _setRelative: function() {
  9707. $( "[data-"+ $.mobile.ns + "role='page']" ).css({ "position": "relative" });
  9708. },
  9709. // Deprecated in 1.4. As from 1.5 button classes have to be present in the markup.
  9710. _btnMarkup: function() {
  9711. this.element.children( "a" ).attr( "data-" + $.mobile.ns + "role", "button" );
  9712. this.element.trigger( "create" );
  9713. },
  9714. // Deprecated in 1.4. As from 1.5 ui-btn-left/right classes have to be present in the markup.
  9715. _addHeaderButtonClasses: function() {
  9716. var $headeranchors = this.element.children( "a, button" );
  9717. this.leftbtn = $headeranchors.hasClass( "ui-btn-left" );
  9718. this.rightbtn = $headeranchors.hasClass( "ui-btn-right" );
  9719. this.leftbtn = this.leftbtn || $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length;
  9720. this.rightbtn = this.rightbtn || $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length;
  9721. },
  9722. _addBackButton: function() {
  9723. var theme,
  9724. options = this.options;
  9725. if ( !this.backBtn ) {
  9726. theme = options.backBtnTheme || options.theme;
  9727. this.backBtn = $( "<a role='button' href='javascript:void(0);' " +
  9728. "class='ui-btn ui-corner-all ui-shadow ui-btn-left " +
  9729. ( theme ? "ui-btn-" + theme + " " : "" ) +
  9730. "ui-toolbar-back-btn ui-icon-carat-l ui-btn-icon-left' " +
  9731. "data-" + $.mobile.ns + "rel='back'>" + options.backBtnText + "</a>" )
  9732. .prependTo( this.element );
  9733. }
  9734. },
  9735. _addHeadingClasses: function() {
  9736. this.element.children( "h1, h2, h3, h4, h5, h6" )
  9737. .addClass( "ui-title" )
  9738. // Regardless of h element number in src, it becomes h1 for the enhanced page
  9739. .attr({
  9740. "role": "heading",
  9741. "aria-level": "1"
  9742. });
  9743. }
  9744. });
  9745. })( jQuery );
  9746. (function( $, undefined ) {
  9747. $.widget( "mobile.toolbar", $.mobile.toolbar, {
  9748. options: {
  9749. position:null,
  9750. visibleOnPageShow: true,
  9751. disablePageZoom: true,
  9752. transition: "slide", //can be none, fade, slide (slide maps to slideup or slidedown)
  9753. fullscreen: false,
  9754. tapToggle: true,
  9755. tapToggleBlacklist: "a, button, input, select, textarea, .ui-header-fixed, .ui-footer-fixed, .ui-flipswitch, .ui-popup, .ui-panel, .ui-panel-dismiss-open",
  9756. hideDuringFocus: "input, textarea, select",
  9757. updatePagePadding: true,
  9758. trackPersistentToolbars: true,
  9759. // Browser detection! Weeee, here we go...
  9760. // Unfortunately, position:fixed is costly, not to mention probably impossible, to feature-detect accurately.
  9761. // Some tests exist, but they currently return false results in critical devices and browsers, which could lead to a broken experience.
  9762. // Testing fixed positioning is also pretty obtrusive to page load, requiring injected elements and scrolling the window
  9763. // The following function serves to rule out some popular browsers with known fixed-positioning issues
  9764. // This is a plugin option like any other, so feel free to improve or overwrite it
  9765. supportBlacklist: function() {
  9766. return !$.support.fixedPosition;
  9767. }
  9768. },
  9769. _create: function() {
  9770. this._super();
  9771. if ( this.options.position === "fixed" && !this.options.supportBlacklist() ) {
  9772. this._makeFixed();
  9773. }
  9774. },
  9775. _makeFixed: function() {
  9776. this.element.addClass( "ui-"+ this.role +"-fixed" );
  9777. this.updatePagePadding();
  9778. this._addTransitionClass();
  9779. this._bindPageEvents();
  9780. this._bindToggleHandlers();
  9781. this._setOptions( this.options );
  9782. },
  9783. _setOptions: function( o ) {
  9784. if ( o.position === "fixed" && this.options.position !== "fixed" ) {
  9785. this._makeFixed();
  9786. }
  9787. if ( this.options.position === "fixed" && !this.options.supportBlacklist() ) {
  9788. var $page = ( !!this.page )? this.page: ( $(".ui-page-active").length > 0 )? $(".ui-page-active"): $(".ui-page").eq(0);
  9789. if ( o.fullscreen !== undefined) {
  9790. if ( o.fullscreen ) {
  9791. this.element.addClass( "ui-"+ this.role +"-fullscreen" );
  9792. $page.addClass( "ui-page-" + this.role + "-fullscreen" );
  9793. }
  9794. // If not fullscreen, add class to page to set top or bottom padding
  9795. else {
  9796. this.element.removeClass( "ui-"+ this.role +"-fullscreen" );
  9797. $page.removeClass( "ui-page-" + this.role + "-fullscreen" ).addClass( "ui-page-" + this.role+ "-fixed" );
  9798. }
  9799. }
  9800. }
  9801. this._super(o);
  9802. },
  9803. _addTransitionClass: function() {
  9804. var tclass = this.options.transition;
  9805. if ( tclass && tclass !== "none" ) {
  9806. // use appropriate slide for header or footer
  9807. if ( tclass === "slide" ) {
  9808. tclass = this.element.hasClass( "ui-header" ) ? "slidedown" : "slideup";
  9809. }
  9810. this.element.addClass( tclass );
  9811. }
  9812. },
  9813. _bindPageEvents: function() {
  9814. var page = ( !!this.page )? this.element.closest( ".ui-page" ): this.document;
  9815. //page event bindings
  9816. // Fixed toolbars require page zoom to be disabled, otherwise usability issues crop up
  9817. // This method is meant to disable zoom while a fixed-positioned toolbar page is visible
  9818. this._on( page , {
  9819. "pagebeforeshow": "_handlePageBeforeShow",
  9820. "webkitAnimationStart":"_handleAnimationStart",
  9821. "animationstart":"_handleAnimationStart",
  9822. "updatelayout": "_handleAnimationStart",
  9823. "pageshow": "_handlePageShow",
  9824. "pagebeforehide": "_handlePageBeforeHide"
  9825. });
  9826. },
  9827. _handlePageBeforeShow: function( ) {
  9828. var o = this.options;
  9829. if ( o.disablePageZoom ) {
  9830. $.mobile.zoom.disable( true );
  9831. }
  9832. if ( !o.visibleOnPageShow ) {
  9833. this.hide( true );
  9834. }
  9835. },
  9836. _handleAnimationStart: function() {
  9837. if ( this.options.updatePagePadding ) {
  9838. this.updatePagePadding( ( !!this.page )? this.page: ".ui-page-active" );
  9839. }
  9840. },
  9841. _handlePageShow: function() {
  9842. this.updatePagePadding( ( !!this.page )? this.page: ".ui-page-active" );
  9843. if ( this.options.updatePagePadding ) {
  9844. this._on( this.window, { "throttledresize": "updatePagePadding" } );
  9845. }
  9846. },
  9847. _handlePageBeforeHide: function( e, ui ) {
  9848. var o = this.options,
  9849. thisFooter, thisHeader, nextFooter, nextHeader;
  9850. if ( o.disablePageZoom ) {
  9851. $.mobile.zoom.enable( true );
  9852. }
  9853. if ( o.updatePagePadding ) {
  9854. this._off( this.window, "throttledresize" );
  9855. }
  9856. if ( o.trackPersistentToolbars ) {
  9857. thisFooter = $( ".ui-footer-fixed:jqmData(id)", this.page );
  9858. thisHeader = $( ".ui-header-fixed:jqmData(id)", this.page );
  9859. nextFooter = thisFooter.length && ui.nextPage && $( ".ui-footer-fixed:jqmData(id='" + thisFooter.jqmData( "id" ) + "')", ui.nextPage ) || $();
  9860. nextHeader = thisHeader.length && ui.nextPage && $( ".ui-header-fixed:jqmData(id='" + thisHeader.jqmData( "id" ) + "')", ui.nextPage ) || $();
  9861. if ( nextFooter.length || nextHeader.length ) {
  9862. nextFooter.add( nextHeader ).appendTo( $.mobile.pageContainer );
  9863. ui.nextPage.one( "pageshow", function() {
  9864. nextHeader.prependTo( this );
  9865. nextFooter.appendTo( this );
  9866. });
  9867. }
  9868. }
  9869. },
  9870. _visible: true,
  9871. // This will set the content element's top or bottom padding equal to the toolbar's height
  9872. updatePagePadding: function( tbPage ) {
  9873. var $el = this.element,
  9874. header = ( this.role ==="header" ),
  9875. pos = parseFloat( $el.css( header ? "top" : "bottom" ) );
  9876. // This behavior only applies to "fixed", not "fullscreen"
  9877. if ( this.options.fullscreen ) { return; }
  9878. // tbPage argument can be a Page object or an event, if coming from throttled resize.
  9879. tbPage = ( tbPage && tbPage.type === undefined && tbPage ) || this.page || $el.closest( ".ui-page" );
  9880. tbPage = ( !!this.page )? this.page: ".ui-page-active";
  9881. $( tbPage ).css( "padding-" + ( header ? "top" : "bottom" ), $el.outerHeight() + pos );
  9882. },
  9883. _useTransition: function( notransition ) {
  9884. var $win = this.window,
  9885. $el = this.element,
  9886. scroll = $win.scrollTop(),
  9887. elHeight = $el.height(),
  9888. pHeight = ( !!this.page )? $el.closest( ".ui-page" ).height():$(".ui-page-active").height(),
  9889. viewportHeight = $.mobile.getScreenHeight();
  9890. return !notransition &&
  9891. ( this.options.transition && this.options.transition !== "none" &&
  9892. (
  9893. ( this.role === "header" && !this.options.fullscreen && scroll > elHeight ) ||
  9894. ( this.role === "footer" && !this.options.fullscreen && scroll + viewportHeight < pHeight - elHeight )
  9895. ) || this.options.fullscreen
  9896. );
  9897. },
  9898. show: function( notransition ) {
  9899. var hideClass = "ui-fixed-hidden",
  9900. $el = this.element;
  9901. if ( this._useTransition( notransition ) ) {
  9902. $el
  9903. .removeClass( "out " + hideClass )
  9904. .addClass( "in" )
  9905. .animationComplete(function () {
  9906. $el.removeClass( "in" );
  9907. });
  9908. }
  9909. else {
  9910. $el.removeClass( hideClass );
  9911. }
  9912. this._visible = true;
  9913. },
  9914. hide: function( notransition ) {
  9915. var hideClass = "ui-fixed-hidden",
  9916. $el = this.element,
  9917. // if it's a slide transition, our new transitions need the reverse class as well to slide outward
  9918. outclass = "out" + ( this.options.transition === "slide" ? " reverse" : "" );
  9919. if ( this._useTransition( notransition ) ) {
  9920. $el
  9921. .addClass( outclass )
  9922. .removeClass( "in" )
  9923. .animationComplete(function() {
  9924. $el.addClass( hideClass ).removeClass( outclass );
  9925. });
  9926. }
  9927. else {
  9928. $el.addClass( hideClass ).removeClass( outclass );
  9929. }
  9930. this._visible = false;
  9931. },
  9932. toggle: function() {
  9933. this[ this._visible ? "hide" : "show" ]();
  9934. },
  9935. _bindToggleHandlers: function() {
  9936. var self = this,
  9937. o = self.options,
  9938. delayShow, delayHide,
  9939. isVisible = true,
  9940. page = ( !!this.page )? this.page: $(".ui-page");
  9941. // tap toggle
  9942. page
  9943. .bind( "vclick", function( e ) {
  9944. if ( o.tapToggle && !$( e.target ).closest( o.tapToggleBlacklist ).length ) {
  9945. self.toggle();
  9946. }
  9947. })
  9948. .bind( "focusin focusout", function( e ) {
  9949. //this hides the toolbars on a keyboard pop to give more screen room and prevent ios bug which
  9950. //positions fixed toolbars in the middle of the screen on pop if the input is near the top or
  9951. //bottom of the screen addresses issues #4410 Footer navbar moves up when clicking on a textbox in an Android environment
  9952. //and issue #4113 Header and footer change their position after keyboard popup - iOS
  9953. //and issue #4410 Footer navbar moves up when clicking on a textbox in an Android environment
  9954. if ( screen.width < 1025 && $( e.target ).is( o.hideDuringFocus ) && !$( e.target ).closest( ".ui-header-fixed, .ui-footer-fixed" ).length ) {
  9955. //Fix for issue #4724 Moving through form in Mobile Safari with "Next" and "Previous" system
  9956. //controls causes fixed position, tap-toggle false Header to reveal itself
  9957. // isVisible instead of self._visible because the focusin and focusout events fire twice at the same time
  9958. // Also use a delay for hiding the toolbars because on Android native browser focusin is direclty followed
  9959. // by a focusout when a native selects opens and the other way around when it closes.
  9960. if ( e.type === "focusout" && !isVisible ) {
  9961. isVisible = true;
  9962. //wait for the stack to unwind and see if we have jumped to another input
  9963. clearTimeout( delayHide );
  9964. delayShow = setTimeout( function() {
  9965. self.show();
  9966. }, 0 );
  9967. } else if ( e.type === "focusin" && !!isVisible ) {
  9968. //if we have jumped to another input clear the time out to cancel the show.
  9969. clearTimeout( delayShow );
  9970. isVisible = false;
  9971. delayHide = setTimeout( function() {
  9972. self.hide();
  9973. }, 0 );
  9974. }
  9975. }
  9976. });
  9977. },
  9978. _setRelative: function() {
  9979. if( this.options.position !== "fixed" ){
  9980. $( "[data-"+ $.mobile.ns + "role='page']" ).css({ "position": "relative" });
  9981. }
  9982. },
  9983. _destroy: function() {
  9984. var $el = this.element,
  9985. header = $el.hasClass( "ui-header" );
  9986. $el.closest( ".ui-page" ).css( "padding-" + ( header ? "top" : "bottom" ), "" );
  9987. $el.removeClass( "ui-header-fixed ui-footer-fixed ui-header-fullscreen ui-footer-fullscreen in out fade slidedown slideup ui-fixed-hidden" );
  9988. $el.closest( ".ui-page" ).removeClass( "ui-page-header-fixed ui-page-footer-fixed ui-page-header-fullscreen ui-page-footer-fullscreen" );
  9989. }
  9990. });
  9991. })( jQuery );
  9992. (function( $, undefined ) {
  9993. $.widget( "mobile.toolbar", $.mobile.toolbar, {
  9994. _makeFixed: function() {
  9995. this._super();
  9996. this._workarounds();
  9997. },
  9998. //check the browser and version and run needed workarounds
  9999. _workarounds: function() {
  10000. var ua = navigator.userAgent,
  10001. platform = navigator.platform,
  10002. // Rendering engine is Webkit, and capture major version
  10003. wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ),
  10004. wkversion = !!wkmatch && wkmatch[ 1 ],
  10005. os = null,
  10006. self = this;
  10007. //set the os we are working in if it dosent match one with workarounds return
  10008. if ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1 || platform.indexOf( "iPod" ) > -1 ) {
  10009. os = "ios";
  10010. } else if ( ua.indexOf( "Android" ) > -1 ) {
  10011. os = "android";
  10012. } else {
  10013. return;
  10014. }
  10015. //check os version if it dosent match one with workarounds return
  10016. if ( os === "ios" ) {
  10017. //iOS workarounds
  10018. self._bindScrollWorkaround();
  10019. } else if ( os === "android" && wkversion && wkversion < 534 ) {
  10020. //Android 2.3 run all Android 2.3 workaround
  10021. self._bindScrollWorkaround();
  10022. self._bindListThumbWorkaround();
  10023. } else {
  10024. return;
  10025. }
  10026. },
  10027. //Utility class for checking header and footer positions relative to viewport
  10028. _viewportOffset: function() {
  10029. var $el = this.element,
  10030. header = $el.hasClass( "ui-header" ),
  10031. offset = Math.abs( $el.offset().top - this.window.scrollTop() );
  10032. if ( !header ) {
  10033. offset = Math.round( offset - this.window.height() + $el.outerHeight() ) - 60;
  10034. }
  10035. return offset;
  10036. },
  10037. //bind events for _triggerRedraw() function
  10038. _bindScrollWorkaround: function() {
  10039. var self = this;
  10040. //bind to scrollstop and check if the toolbars are correctly positioned
  10041. this._on( this.window, { scrollstop: function() {
  10042. var viewportOffset = self._viewportOffset();
  10043. //check if the header is visible and if its in the right place
  10044. if ( viewportOffset > 2 && self._visible ) {
  10045. self._triggerRedraw();
  10046. }
  10047. }});
  10048. },
  10049. //this addresses issue #4250 Persistent footer instability in v1.1 with long select lists in Android 2.3.3
  10050. //and issue #3748 Android 2.x: Page transitions broken when fixed toolbars used
  10051. //the absolutely positioned thumbnail in a list view causes problems with fixed position buttons above in a nav bar
  10052. //setting the li's to -webkit-transform:translate3d(0,0,0); solves this problem to avoide potential issues in other
  10053. //platforms we scope this with the class ui-android-2x-fix
  10054. _bindListThumbWorkaround: function() {
  10055. this.element.closest( ".ui-page" ).addClass( "ui-android-2x-fixed" );
  10056. },
  10057. //this addresses issues #4337 Fixed header problem after scrolling content on iOS and Android
  10058. //and device bugs project issue #1 Form elements can lose click hit area in position: fixed containers.
  10059. //this also addresses not on fixed toolbars page in docs
  10060. //adding 1px of padding to the bottom then removing it causes a "redraw"
  10061. //which positions the toolbars correctly (they will always be visually correct)
  10062. _triggerRedraw: function() {
  10063. var paddingBottom = parseFloat( $( ".ui-page-active" ).css( "padding-bottom" ) );
  10064. //trigger page redraw to fix incorrectly positioned fixed elements
  10065. $( ".ui-page-active" ).css( "padding-bottom", ( paddingBottom + 1 ) + "px" );
  10066. //if the padding is reset with out a timeout the reposition will not occure.
  10067. //this is independant of JQM the browser seems to need the time to react.
  10068. setTimeout( function() {
  10069. $( ".ui-page-active" ).css( "padding-bottom", paddingBottom + "px" );
  10070. }, 0 );
  10071. },
  10072. destroy: function() {
  10073. this._super();
  10074. //Remove the class we added to the page previously in android 2.x
  10075. this.element.closest( ".ui-page-active" ).removeClass( "ui-android-2x-fix" );
  10076. }
  10077. });
  10078. })( jQuery );
  10079. ( function( $, undefined ) {
  10080. var ieHack = ( $.mobile.browser.oldIE && $.mobile.browser.oldIE <= 8 ),
  10081. uiTemplate = $(
  10082. "<div class='ui-popup-arrow-guide'></div>" +
  10083. "<div class='ui-popup-arrow-container" + ( ieHack ? " ie" : "" ) + "'>" +
  10084. "<div class='ui-popup-arrow'>" +
  10085. "<div class='ui-popup-arrow-background'></div>" +
  10086. "</div>" +
  10087. "</div>"
  10088. ),
  10089. // Needed for transforming coordinates from screen to arrow background
  10090. txFactor = Math.sqrt( 2 ) / 2;
  10091. function getArrow() {
  10092. var clone = uiTemplate.clone(),
  10093. gd = clone.eq( 0 ),
  10094. ct = clone.eq( 1 ),
  10095. ar = ct.children(),
  10096. bg = ar.children();
  10097. return { arEls: ct.add( gd ), gd: gd, ct: ct, ar: ar, bg: bg };
  10098. }
  10099. $.widget( "mobile.popup", $.mobile.popup, {
  10100. options: {
  10101. arrow: ""
  10102. },
  10103. _create: function() {
  10104. var ar,
  10105. ret = this._super();
  10106. if ( this.options.arrow ) {
  10107. this._ui.arrow = ar = this._addArrow();
  10108. }
  10109. return ret;
  10110. },
  10111. _addArrow: function() {
  10112. var theme,
  10113. opts = this.options,
  10114. ar = getArrow();
  10115. theme = this._themeClassFromOption( "ui-body-", opts.theme );
  10116. ar.ar.addClass( theme + ( opts.shadow ? " ui-overlay-shadow" : "" ) );
  10117. ar.bg.addClass( theme );
  10118. ar.arEls.hide().appendTo( this.element );
  10119. return ar;
  10120. },
  10121. _unenhance: function() {
  10122. var ar = this._ui.arrow;
  10123. if ( ar ) {
  10124. ar.arEls.remove();
  10125. }
  10126. return this._super();
  10127. },
  10128. // Pretend to show an arrow described by @p and @dir and calculate the
  10129. // distance from the desired point. If a best-distance is passed in, return
  10130. // the minimum of the one passed in and the one calculated.
  10131. _tryAnArrow: function( p, dir, desired, s, best ) {
  10132. var result, r, diff, desiredForArrow = {}, tip = {};
  10133. // If the arrow has no wiggle room along the edge of the popup, it cannot
  10134. // be displayed along the requested edge without it sticking out.
  10135. if ( s.arFull[ p.dimKey ] > s.guideDims[ p.dimKey ] ) {
  10136. return best;
  10137. }
  10138. desiredForArrow[ p.fst ] = desired[ p.fst ] +
  10139. ( s.arHalf[ p.oDimKey ] + s.menuHalf[ p.oDimKey ] ) * p.offsetFactor -
  10140. s.contentBox[ p.fst ] + ( s.clampInfo.menuSize[ p.oDimKey ] - s.contentBox[ p.oDimKey ] ) * p.arrowOffsetFactor;
  10141. desiredForArrow[ p.snd ] = desired[ p.snd ];
  10142. result = s.result || this._calculateFinalLocation( desiredForArrow, s.clampInfo );
  10143. r = { x: result.left, y: result.top };
  10144. tip[ p.fst ] = r[ p.fst ] + s.contentBox[ p.fst ] + p.tipOffset;
  10145. tip[ p.snd ] = Math.max( result[ p.prop ] + s.guideOffset[ p.prop ] + s.arHalf[ p.dimKey ],
  10146. Math.min( result[ p.prop ] + s.guideOffset[ p.prop ] + s.guideDims[ p.dimKey ] - s.arHalf[ p.dimKey ],
  10147. desired[ p.snd ] ) );
  10148. diff = Math.abs( desired.x - tip.x ) + Math.abs( desired.y - tip.y );
  10149. if ( !best || diff < best.diff ) {
  10150. // Convert tip offset to coordinates inside the popup
  10151. tip[ p.snd ] -= s.arHalf[ p.dimKey ] + result[ p.prop ] + s.contentBox[ p.snd ];
  10152. best = { dir: dir, diff: diff, result: result, posProp: p.prop, posVal: tip[ p.snd ] };
  10153. }
  10154. return best;
  10155. },
  10156. _getPlacementState: function( clamp ) {
  10157. var offset, gdOffset,
  10158. ar = this._ui.arrow,
  10159. state = {
  10160. clampInfo: this._clampPopupWidth( !clamp ),
  10161. arFull: { cx: ar.ct.width(), cy: ar.ct.height() },
  10162. guideDims: { cx: ar.gd.width(), cy: ar.gd.height() },
  10163. guideOffset: ar.gd.offset()
  10164. };
  10165. offset = this.element.offset();
  10166. ar.gd.css( { left: 0, top: 0, right: 0, bottom: 0 } );
  10167. gdOffset = ar.gd.offset();
  10168. state.contentBox = {
  10169. x: gdOffset.left - offset.left,
  10170. y: gdOffset.top - offset.top,
  10171. cx: ar.gd.width(),
  10172. cy: ar.gd.height()
  10173. };
  10174. ar.gd.removeAttr( "style" );
  10175. // The arrow box moves between guideOffset and guideOffset + guideDims - arFull
  10176. state.guideOffset = { left: state.guideOffset.left - offset.left, top: state.guideOffset.top - offset.top };
  10177. state.arHalf = { cx: state.arFull.cx / 2, cy: state.arFull.cy / 2 };
  10178. state.menuHalf = { cx: state.clampInfo.menuSize.cx / 2, cy: state.clampInfo.menuSize.cy / 2 };
  10179. return state;
  10180. },
  10181. _placementCoords: function( desired ) {
  10182. var state, best, params, bgOffset, elOffset, diff, bgRef,
  10183. optionValue = this.options.arrow,
  10184. ar = this._ui.arrow;
  10185. if ( !ar ) {
  10186. return this._super( desired );
  10187. }
  10188. ar.arEls.show();
  10189. bgRef = {};
  10190. state = this._getPlacementState( true );
  10191. params = {
  10192. "l": { fst: "x", snd: "y", prop: "top", dimKey: "cy", oDimKey: "cx", offsetFactor: 1, tipOffset: -state.arHalf.cx, arrowOffsetFactor: 0 },
  10193. "r": { fst: "x", snd: "y", prop: "top", dimKey: "cy", oDimKey: "cx", offsetFactor: -1, tipOffset: state.arHalf.cx + state.contentBox.cx, arrowOffsetFactor: 1 },
  10194. "b": { fst: "y", snd: "x", prop: "left", dimKey: "cx", oDimKey: "cy", offsetFactor: -1, tipOffset: state.arHalf.cy + state.contentBox.cy, arrowOffsetFactor: 1 },
  10195. "t": { fst: "y", snd: "x", prop: "left", dimKey: "cx", oDimKey: "cy", offsetFactor: 1, tipOffset: -state.arHalf.cy, arrowOffsetFactor: 0 }
  10196. };
  10197. // Try each side specified in the options to see on which one the arrow
  10198. // should be placed such that the distance between the tip of the arrow and
  10199. // the desired coordinates is the shortest.
  10200. $.each( ( optionValue === true ? "l,t,r,b" : optionValue ).split( "," ),
  10201. $.proxy( function( key, value ) {
  10202. best = this._tryAnArrow( params[ value ], value, desired, state, best );
  10203. }, this ) );
  10204. // Could not place the arrow along any of the edges - behave as if showing
  10205. // the arrow was turned off.
  10206. if ( !best ) {
  10207. ar.arEls.hide();
  10208. return this._super( desired );
  10209. }
  10210. // Move the arrow into place
  10211. ar.ct
  10212. .removeClass( "ui-popup-arrow-l ui-popup-arrow-t ui-popup-arrow-r ui-popup-arrow-b" )
  10213. .addClass( "ui-popup-arrow-" + best.dir )
  10214. .removeAttr( "style" ).css( best.posProp, best.posVal )
  10215. .show();
  10216. // Do not move/size the background div on IE, because we use the arrow div for background as well.
  10217. if ( !ieHack ) {
  10218. elOffset = this.element.offset();
  10219. bgRef[ params[ best.dir ].fst ] = ar.ct.offset();
  10220. bgRef[ params[ best.dir ].snd ] = {
  10221. left: elOffset.left + state.contentBox.x,
  10222. top: elOffset.top + state.contentBox.y
  10223. };
  10224. bgOffset = ar.bg
  10225. .removeAttr( "style" )
  10226. .css( ( "cx" === params[ best.dir ].dimKey ? "width" : "height" ), state.contentBox[ params[ best.dir ].dimKey ] )
  10227. .offset();
  10228. diff = { dx: bgRef.x.left - bgOffset.left, dy: bgRef.y.top - bgOffset.top };
  10229. ar.bg.css( { left: txFactor * diff.dy + txFactor * diff.dx, top: txFactor * diff.dy - txFactor * diff.dx } );
  10230. }
  10231. return best.result;
  10232. },
  10233. _setOptions: function( opts ) {
  10234. var newTheme,
  10235. oldTheme = this.options.theme,
  10236. ar = this._ui.arrow,
  10237. ret = this._super( opts );
  10238. if ( opts.arrow !== undefined ) {
  10239. if ( !ar && opts.arrow ) {
  10240. this._ui.arrow = this._addArrow();
  10241. // Important to return here so we don't set the same options all over
  10242. // again below.
  10243. return;
  10244. } else if ( ar && !opts.arrow ) {
  10245. ar.arEls.remove();
  10246. this._ui.arrow = null;
  10247. }
  10248. }
  10249. // Reassign with potentially new arrow
  10250. ar = this._ui.arrow;
  10251. if ( ar ) {
  10252. if ( opts.theme !== undefined ) {
  10253. oldTheme = this._themeClassFromOption( "ui-body-", oldTheme );
  10254. newTheme = this._themeClassFromOption( "ui-body-", opts.theme );
  10255. ar.ar.removeClass( oldTheme ).addClass( newTheme );
  10256. ar.bg.removeClass( oldTheme ).addClass( newTheme );
  10257. }
  10258. if ( opts.shadow !== undefined ) {
  10259. ar.ar.toggleClass( "ui-overlay-shadow", opts.shadow );
  10260. }
  10261. }
  10262. return ret;
  10263. },
  10264. _destroy: function() {
  10265. var ar = this._ui.arrow;
  10266. if ( ar ) {
  10267. ar.arEls.remove();
  10268. }
  10269. return this._super();
  10270. }
  10271. });
  10272. })( jQuery );
  10273. (function( $, undefined ) {
  10274. $.widget( "mobile.panel", {
  10275. options: {
  10276. classes: {
  10277. panel: "ui-panel",
  10278. panelOpen: "ui-panel-open",
  10279. panelClosed: "ui-panel-closed",
  10280. panelFixed: "ui-panel-fixed",
  10281. panelInner: "ui-panel-inner",
  10282. modal: "ui-panel-dismiss",
  10283. modalOpen: "ui-panel-dismiss-open",
  10284. pageContainer: "ui-panel-page-container",
  10285. pageWrapper: "ui-panel-wrapper",
  10286. pageFixedToolbar: "ui-panel-fixed-toolbar",
  10287. pageContentPrefix: "ui-panel-page-content", /* Used for wrapper and fixed toolbars position, display and open classes. */
  10288. animate: "ui-panel-animate"
  10289. },
  10290. animate: true,
  10291. theme: null,
  10292. position: "left",
  10293. dismissible: true,
  10294. display: "reveal", //accepts reveal, push, overlay
  10295. swipeClose: true,
  10296. positionFixed: false
  10297. },
  10298. _panelID: null,
  10299. _closeLink: null,
  10300. _parentPage: null,
  10301. _page: null,
  10302. _modal: null,
  10303. _panelInner: null,
  10304. _wrapper: null,
  10305. _fixedToolbars: null,
  10306. _create: function() {
  10307. var el = this.element,
  10308. parentPage = el.closest( ":jqmData(role='page')" );
  10309. // expose some private props to other methods
  10310. $.extend( this, {
  10311. _panelID: el.attr( "id" ),
  10312. _closeLink: el.find( ":jqmData(rel='close')" ),
  10313. _parentPage: ( parentPage.length > 0 ) ? parentPage : false,
  10314. _page: this._getPage,
  10315. _panelInner: this._getPanelInner(),
  10316. _wrapper: this._getWrapper,
  10317. _fixedToolbars: this._getFixedToolbars
  10318. });
  10319. this._addPanelClasses();
  10320. // if animating, add the class to do so
  10321. if ( $.support.cssTransform3d && !!this.options.animate ) {
  10322. this.element.addClass( this.options.classes.animate );
  10323. }
  10324. this._bindUpdateLayout();
  10325. this._bindCloseEvents();
  10326. this._bindLinkListeners();
  10327. this._bindPageEvents();
  10328. if ( !!this.options.dismissible ) {
  10329. this._createModal();
  10330. }
  10331. this._bindSwipeEvents();
  10332. },
  10333. _getPanelInner: function() {
  10334. var panelInner = this.element.find( "." + this.options.classes.panelInner );
  10335. if ( panelInner.length === 0 ) {
  10336. panelInner = this.element.children().wrapAll( "<div class='" + this.options.classes.panelInner + "' />" ).parent();
  10337. }
  10338. return panelInner;
  10339. },
  10340. _createModal: function() {
  10341. var self = this,
  10342. target = self._parentPage ? self._parentPage.parent() : self.element.parent();
  10343. self._modal = $( "<div class='" + self.options.classes.modal + "' data-panelid='" + self._panelID + "'></div>" )
  10344. .on( "mousedown", function() {
  10345. self.close();
  10346. })
  10347. .appendTo( target );
  10348. },
  10349. _getPage: function() {
  10350. var page = this._parentPage ? this._parentPage : $( "." + $.mobile.activePageClass );
  10351. return page;
  10352. },
  10353. _getWrapper: function() {
  10354. var wrapper = this._page().find( "." + this.options.classes.pageWrapper );
  10355. if ( wrapper.length === 0 ) {
  10356. wrapper = this._page().children( ".ui-header:not(.ui-header-fixed), .ui-content:not(.ui-popup), .ui-footer:not(.ui-footer-fixed)" )
  10357. .wrapAll( "<div class='" + this.options.classes.pageWrapper + "'></div>" )
  10358. .parent();
  10359. }
  10360. return wrapper;
  10361. },
  10362. _getFixedToolbars: function() {
  10363. var extFixedToolbars = $( "body" ).children( ".ui-header-fixed, .ui-footer-fixed" ),
  10364. intFixedToolbars = this._page().find( ".ui-header-fixed, .ui-footer-fixed" ),
  10365. fixedToolbars = extFixedToolbars.add( intFixedToolbars ).addClass( this.options.classes.pageFixedToolbar );
  10366. return fixedToolbars;
  10367. },
  10368. _getPosDisplayClasses: function( prefix ) {
  10369. return prefix + "-position-" + this.options.position + " " + prefix + "-display-" + this.options.display;
  10370. },
  10371. _getPanelClasses: function() {
  10372. var panelClasses = this.options.classes.panel +
  10373. " " + this._getPosDisplayClasses( this.options.classes.panel ) +
  10374. " " + this.options.classes.panelClosed +
  10375. " " + "ui-body-" + ( this.options.theme ? this.options.theme : "inherit" );
  10376. if ( !!this.options.positionFixed ) {
  10377. panelClasses += " " + this.options.classes.panelFixed;
  10378. }
  10379. return panelClasses;
  10380. },
  10381. _addPanelClasses: function() {
  10382. this.element.addClass( this._getPanelClasses() );
  10383. },
  10384. _bindCloseEvents: function() {
  10385. var self = this;
  10386. self._closeLink.on( "click.panel" , function( e ) {
  10387. e.preventDefault();
  10388. self.close();
  10389. return false;
  10390. });
  10391. self.element.on( "click.panel" , "a:jqmData(ajax='false')", function(/* e */) {
  10392. self.close();
  10393. });
  10394. },
  10395. _positionPanel: function() {
  10396. var self = this,
  10397. panelInnerHeight = self._panelInner.outerHeight(),
  10398. expand = panelInnerHeight > $.mobile.getScreenHeight();
  10399. if ( expand || !self.options.positionFixed ) {
  10400. if ( expand ) {
  10401. self._unfixPanel();
  10402. $.mobile.resetActivePageHeight( panelInnerHeight );
  10403. }
  10404. window.scrollTo( 0, $.mobile.defaultHomeScroll );
  10405. } else {
  10406. self._fixPanel();
  10407. }
  10408. },
  10409. _bindFixListener: function() {
  10410. this._on( $( window ), { "throttledresize": "_positionPanel" });
  10411. },
  10412. _unbindFixListener: function() {
  10413. this._off( $( window ), "throttledresize" );
  10414. },
  10415. _unfixPanel: function() {
  10416. if ( !!this.options.positionFixed && $.support.fixedPosition ) {
  10417. this.element.removeClass( this.options.classes.panelFixed );
  10418. }
  10419. },
  10420. _fixPanel: function() {
  10421. if ( !!this.options.positionFixed && $.support.fixedPosition ) {
  10422. this.element.addClass( this.options.classes.panelFixed );
  10423. }
  10424. },
  10425. _bindUpdateLayout: function() {
  10426. var self = this;
  10427. self.element.on( "updatelayout", function(/* e */) {
  10428. if ( self._open ) {
  10429. self._positionPanel();
  10430. }
  10431. });
  10432. },
  10433. _bindLinkListeners: function() {
  10434. this._on( "body", {
  10435. "click a": "_handleClick"
  10436. });
  10437. },
  10438. _handleClick: function( e ) {
  10439. if ( e.currentTarget.href.split( "#" )[ 1 ] === this._panelID && this._panelID !== undefined ) {
  10440. e.preventDefault();
  10441. var link = $( e.target );
  10442. if ( link.hasClass( "ui-btn" ) ) {
  10443. link.addClass( $.mobile.activeBtnClass );
  10444. this.element.one( "panelopen panelclose", function() {
  10445. link.removeClass( $.mobile.activeBtnClass );
  10446. });
  10447. }
  10448. this.toggle();
  10449. return false;
  10450. }
  10451. },
  10452. _bindSwipeEvents: function() {
  10453. var self = this,
  10454. area = self._modal ? self.element.add( self._modal ) : self.element;
  10455. // on swipe, close the panel
  10456. if ( !!self.options.swipeClose ) {
  10457. if ( self.options.position === "left" ) {
  10458. area.on( "swipeleft.panel", function(/* e */) {
  10459. self.close();
  10460. });
  10461. } else {
  10462. area.on( "swiperight.panel", function(/* e */) {
  10463. self.close();
  10464. });
  10465. }
  10466. }
  10467. },
  10468. _bindPageEvents: function() {
  10469. var self = this;
  10470. this.document
  10471. // Close the panel if another panel on the page opens
  10472. .on( "panelbeforeopen", function( e ) {
  10473. if ( self._open && e.target !== self.element[ 0 ] ) {
  10474. self.close();
  10475. }
  10476. })
  10477. // On escape, close? might need to have a target check too...
  10478. .on( "keyup.panel", function( e ) {
  10479. if ( e.keyCode === 27 && self._open ) {
  10480. self.close();
  10481. }
  10482. });
  10483. // Clean up open panels after page hide
  10484. if ( self._parentPage ) {
  10485. this.document.on( "pagehide", ":jqmData(role='page')", function() {
  10486. if ( self._open ) {
  10487. self.close( true );
  10488. }
  10489. });
  10490. } else {
  10491. this.document.on( "pagebeforehide", function() {
  10492. if ( self._open ) {
  10493. self.close( true );
  10494. }
  10495. });
  10496. }
  10497. },
  10498. // state storage of open or closed
  10499. _open: false,
  10500. _pageContentOpenClasses: null,
  10501. _modalOpenClasses: null,
  10502. open: function( immediate ) {
  10503. if ( !this._open ) {
  10504. var self = this,
  10505. o = self.options,
  10506. _openPanel = function() {
  10507. self.document.off( "panelclose" );
  10508. self._page().jqmData( "panel", "open" );
  10509. if ( $.support.cssTransform3d && !!o.animate && o.display !== "overlay" ) {
  10510. self._wrapper().addClass( o.classes.animate );
  10511. self._fixedToolbars().addClass( o.classes.animate );
  10512. }
  10513. if ( !immediate && $.support.cssTransform3d && !!o.animate ) {
  10514. self.document.on( self._transitionEndEvents, complete );
  10515. } else {
  10516. setTimeout( complete, 0 );
  10517. }
  10518. if ( o.theme && o.display !== "overlay" ) {
  10519. self._page().parent()
  10520. .addClass( o.classes.pageContainer + "-themed " + o.classes.pageContainer + "-" + o.theme );
  10521. }
  10522. self.element
  10523. .removeClass( o.classes.panelClosed )
  10524. .addClass( o.classes.panelOpen );
  10525. self._positionPanel();
  10526. self._pageContentOpenClasses = self._getPosDisplayClasses( o.classes.pageContentPrefix );
  10527. if ( o.display !== "overlay" ) {
  10528. self._page().parent().addClass( o.classes.pageContainer );
  10529. self._wrapper().addClass( self._pageContentOpenClasses );
  10530. self._fixedToolbars().addClass( self._pageContentOpenClasses );
  10531. }
  10532. self._modalOpenClasses = self._getPosDisplayClasses( o.classes.modal ) + " " + o.classes.modalOpen;
  10533. if ( self._modal ) {
  10534. self._modal
  10535. .addClass( self._modalOpenClasses )
  10536. .height( Math.max( self._modal.height(), self.document.height() ) );
  10537. }
  10538. },
  10539. complete = function() {
  10540. self.document.off( self._transitionEndEvents, complete );
  10541. if ( o.display !== "overlay" ) {
  10542. self._wrapper().addClass( o.classes.pageContentPrefix + "-open" );
  10543. self._fixedToolbars().addClass( o.classes.pageContentPrefix + "-open" );
  10544. }
  10545. self._bindFixListener();
  10546. self._trigger( "open" );
  10547. };
  10548. self._trigger( "beforeopen" );
  10549. if ( self._page().jqmData( "panel" ) === "open" ) {
  10550. self.document.on( "panelclose", function() {
  10551. _openPanel();
  10552. });
  10553. } else {
  10554. _openPanel();
  10555. }
  10556. self._open = true;
  10557. }
  10558. },
  10559. close: function( immediate ) {
  10560. if ( this._open ) {
  10561. var self = this,
  10562. o = this.options,
  10563. _closePanel = function() {
  10564. if ( !immediate && $.support.cssTransform3d && !!o.animate ) {
  10565. self.document.on( self._transitionEndEvents, complete );
  10566. } else {
  10567. setTimeout( complete, 0 );
  10568. }
  10569. self.element.removeClass( o.classes.panelOpen );
  10570. if ( o.display !== "overlay" ) {
  10571. self._wrapper().removeClass( self._pageContentOpenClasses );
  10572. self._fixedToolbars().removeClass( self._pageContentOpenClasses );
  10573. }
  10574. if ( self._modal ) {
  10575. self._modal.removeClass( self._modalOpenClasses );
  10576. }
  10577. },
  10578. complete = function() {
  10579. self.document.off( self._transitionEndEvents, complete );
  10580. if ( o.theme && o.display !== "overlay" ) {
  10581. self._page().parent().removeClass( o.classes.pageContainer + "-themed " + o.classes.pageContainer + "-" + o.theme );
  10582. }
  10583. self.element.addClass( o.classes.panelClosed );
  10584. if ( o.display !== "overlay" ) {
  10585. self._page().parent().removeClass( o.classes.pageContainer );
  10586. self._wrapper().removeClass( o.classes.pageContentPrefix + "-open" );
  10587. self._fixedToolbars().removeClass( o.classes.pageContentPrefix + "-open" );
  10588. }
  10589. if ( $.support.cssTransform3d && !!o.animate && o.display !== "overlay" ) {
  10590. self._wrapper().removeClass( o.classes.animate );
  10591. self._fixedToolbars().removeClass( o.classes.animate );
  10592. }
  10593. self._fixPanel();
  10594. self._unbindFixListener();
  10595. $.mobile.resetActivePageHeight();
  10596. self._page().jqmRemoveData( "panel" );
  10597. self._trigger( "close" );
  10598. };
  10599. self._trigger( "beforeclose" );
  10600. _closePanel();
  10601. self._open = false;
  10602. }
  10603. },
  10604. toggle: function() {
  10605. this[ this._open ? "close" : "open" ]();
  10606. },
  10607. _transitionEndEvents: "webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",
  10608. _destroy: function() {
  10609. var otherPanels,
  10610. o = this.options,
  10611. multiplePanels = ( $( "body > :mobile-panel" ).length + $.mobile.activePage.find( ":mobile-panel" ).length ) > 1;
  10612. if ( o.display !== "overlay" ) {
  10613. // remove the wrapper if not in use by another panel
  10614. otherPanels = $( "body > :mobile-panel" ).add( $.mobile.activePage.find( ":mobile-panel" ) );
  10615. if ( otherPanels.not( ".ui-panel-display-overlay" ).not( this.element ).length === 0 ) {
  10616. this._wrapper().children().unwrap();
  10617. }
  10618. if ( this._open ) {
  10619. this._fixedToolbars().removeClass( o.classes.pageContentPrefix + "-open" );
  10620. if ( $.support.cssTransform3d && !!o.animate ) {
  10621. this._fixedToolbars().removeClass( o.classes.animate );
  10622. }
  10623. this._page().parent().removeClass( o.classes.pageContainer );
  10624. if ( o.theme ) {
  10625. this._page().parent().removeClass( o.classes.pageContainer + "-themed " + o.classes.pageContainer + "-" + o.theme );
  10626. }
  10627. }
  10628. }
  10629. if ( !multiplePanels ) {
  10630. this.document.off( "panelopen panelclose" );
  10631. if ( this._open ) {
  10632. this.document.off( this._transitionEndEvents );
  10633. $.mobile.resetActivePageHeight();
  10634. }
  10635. }
  10636. if ( this._open ) {
  10637. this._page().jqmRemoveData( "panel" );
  10638. }
  10639. this._panelInner.children().unwrap();
  10640. this.element
  10641. .removeClass( [ this._getPanelClasses(), o.classes.panelOpen, o.classes.animate ].join( " " ) )
  10642. .off( "swipeleft.panel swiperight.panel" )
  10643. .off( "panelbeforeopen" )
  10644. .off( "panelhide" )
  10645. .off( "keyup.panel" )
  10646. .off( "updatelayout" )
  10647. .off( this._transitionEndEvents );
  10648. this._closeLink.off( "click.panel" );
  10649. if ( this._modal ) {
  10650. this._modal.remove();
  10651. }
  10652. }
  10653. });
  10654. })( jQuery );
  10655. (function( $, undefined ) {
  10656. $.widget( "mobile.table", {
  10657. options: {
  10658. classes: {
  10659. table: "ui-table"
  10660. },
  10661. enhanced: false
  10662. },
  10663. _create: function() {
  10664. if ( !this.options.enhanced ) {
  10665. this.element.addClass( this.options.classes.table );
  10666. }
  10667. // extend here, assign on refresh > _setHeaders
  10668. $.extend( this, {
  10669. // Expose headers and allHeaders properties on the widget
  10670. // headers references the THs within the first TR in the table
  10671. headers: undefined,
  10672. // allHeaders references headers, plus all THs in the thead, which may
  10673. // include several rows, or not
  10674. allHeaders: undefined
  10675. });
  10676. this._refresh( true );
  10677. },
  10678. _setHeaders: function() {
  10679. var trs = this.element.find( "thead tr" );
  10680. this.headers = this.element.find( "tr:eq(0)" ).children();
  10681. this.allHeaders = this.headers.add( trs.children() );
  10682. },
  10683. refresh: function() {
  10684. this._refresh();
  10685. },
  10686. rebuild: $.noop,
  10687. _refresh: function( /* create */ ) {
  10688. var table = this.element,
  10689. trs = table.find( "thead tr" );
  10690. // updating headers on refresh (fixes #5880)
  10691. this._setHeaders();
  10692. // Iterate over the trs
  10693. trs.each( function() {
  10694. var columnCount = 0;
  10695. // Iterate over the children of the tr
  10696. $( this ).children().each( function() {
  10697. var span = parseInt( this.getAttribute( "colspan" ), 10 ),
  10698. selector = ":nth-child(" + ( columnCount + 1 ) + ")",
  10699. j;
  10700. this.setAttribute( "data-" + $.mobile.ns + "colstart", columnCount + 1 );
  10701. if ( span ) {
  10702. for( j = 0; j < span - 1; j++ ) {
  10703. columnCount++;
  10704. selector += ", :nth-child(" + ( columnCount + 1 ) + ")";
  10705. }
  10706. }
  10707. // Store "cells" data on header as a reference to all cells in the
  10708. // same column as this TH
  10709. $( this ).jqmData( "cells", table.find( "tr" ).not( trs.eq( 0 ) ).not( this ).children( selector ) );
  10710. columnCount++;
  10711. });
  10712. });
  10713. }
  10714. });
  10715. })( jQuery );
  10716. (function( $, undefined ) {
  10717. $.widget( "mobile.table", $.mobile.table, {
  10718. options: {
  10719. mode: "columntoggle",
  10720. columnBtnTheme: null,
  10721. columnPopupTheme: null,
  10722. columnBtnText: "Columns...",
  10723. classes: $.extend( $.mobile.table.prototype.options.classes, {
  10724. popup: "ui-table-columntoggle-popup",
  10725. columnBtn: "ui-table-columntoggle-btn",
  10726. priorityPrefix: "ui-table-priority-",
  10727. columnToggleTable: "ui-table-columntoggle"
  10728. })
  10729. },
  10730. _create: function() {
  10731. this._super();
  10732. if ( this.options.mode !== "columntoggle" ) {
  10733. return;
  10734. }
  10735. $.extend( this, {
  10736. _menu: null
  10737. });
  10738. if ( this.options.enhanced ) {
  10739. this._menu = $( this.document[ 0 ].getElementById( this._id() + "-popup" ) ).children().first();
  10740. this._addToggles( this._menu, true );
  10741. this._bindToggles( this._menu );
  10742. } else {
  10743. this._menu = this._enhanceColToggle();
  10744. this.element.addClass( this.options.classes.columnToggleTable );
  10745. }
  10746. this._setupEvents();
  10747. this._setToggleState();
  10748. },
  10749. _id: function() {
  10750. return ( this.element.attr( "id" ) || ( this.widgetName + this.uuid ) );
  10751. },
  10752. _setupEvents: function() {
  10753. //NOTE: inputs are bound in bindToggles,
  10754. // so it can be called on refresh, too
  10755. // update column toggles on resize
  10756. this._on( this.window, {
  10757. throttledresize: "_setToggleState"
  10758. });
  10759. },
  10760. _bindToggles: function( menu ) {
  10761. var inputs = menu.find( "input" );
  10762. this._on( inputs, {
  10763. change: "_menuInputChange"
  10764. });
  10765. },
  10766. _addToggles: function( menu, keep ) {
  10767. var inputs,
  10768. checkboxIndex = 0,
  10769. opts = this.options,
  10770. container = menu.controlgroup( "container" );
  10771. // allow update of menu on refresh (fixes #5880)
  10772. if ( keep ) {
  10773. inputs = menu.find( "input" );
  10774. } else {
  10775. container.empty();
  10776. }
  10777. // create the hide/show toggles
  10778. this.headers.not( "td" ).each( function() {
  10779. var header = $( this ),
  10780. priority = $.mobile.getAttribute( this, "priority" ),
  10781. cells = header.add( header.jqmData( "cells" ) );
  10782. if ( priority ) {
  10783. cells.addClass( opts.classes.priorityPrefix + priority );
  10784. ( keep ? inputs.eq( checkboxIndex++ ) :
  10785. $("<label><input type='checkbox' checked />" +
  10786. ( header.children( "abbr" ).first().attr( "title" ) ||
  10787. header.text() ) +
  10788. "</label>" )
  10789. .appendTo( container )
  10790. .children( 0 )
  10791. .checkboxradio( {
  10792. theme: opts.columnPopupTheme
  10793. }) )
  10794. .jqmData( "cells", cells );
  10795. }
  10796. });
  10797. // set bindings here
  10798. if ( !keep ) {
  10799. menu.controlgroup( "refresh" );
  10800. this._bindToggles( menu );
  10801. }
  10802. },
  10803. _menuInputChange: function( evt ) {
  10804. var input = $( evt.target ),
  10805. checked = input[ 0 ].checked;
  10806. input.jqmData( "cells" )
  10807. .toggleClass( "ui-table-cell-hidden", !checked )
  10808. .toggleClass( "ui-table-cell-visible", checked );
  10809. if ( input[ 0 ].getAttribute( "locked" ) ) {
  10810. input.removeAttr( "locked" );
  10811. this._unlockCells( input.jqmData( "cells" ) );
  10812. } else {
  10813. input.attr( "locked", true );
  10814. }
  10815. },
  10816. _unlockCells: function( cells ) {
  10817. // allow hide/show via CSS only = remove all toggle-locks
  10818. cells.removeClass( "ui-table-cell-hidden ui-table-cell-visible");
  10819. },
  10820. _enhanceColToggle: function() {
  10821. var id , menuButton, popup, menu,
  10822. table = this.element,
  10823. opts = this.options,
  10824. ns = $.mobile.ns,
  10825. fragment = this.document[ 0 ].createDocumentFragment();
  10826. id = this._id() + "-popup";
  10827. menuButton = $( "<a href='#" + id + "' " +
  10828. "class='" + opts.classes.columnBtn + " ui-btn " +
  10829. "ui-btn-" + ( opts.columnBtnTheme || "a" ) +
  10830. " ui-corner-all ui-shadow ui-mini' " +
  10831. "data-" + ns + "rel='popup'>" + opts.columnBtnText + "</a>" );
  10832. popup = $( "<div class='" + opts.classes.popup + "' id='" + id + "'></div>" );
  10833. menu = $( "<fieldset></fieldset>" ).controlgroup();
  10834. // set extension here, send "false" to trigger build/rebuild
  10835. this._addToggles( menu, false );
  10836. menu.appendTo( popup );
  10837. fragment.appendChild( popup[ 0 ] );
  10838. fragment.appendChild( menuButton[ 0 ] );
  10839. table.before( fragment );
  10840. popup.popup();
  10841. return menu;
  10842. },
  10843. rebuild: function() {
  10844. this._super();
  10845. if ( this.options.mode === "columntoggle" ) {
  10846. // NOTE: rebuild passes "false", while refresh passes "undefined"
  10847. // both refresh the table, but inside addToggles, !false will be true,
  10848. // so a rebuild call can be indentified
  10849. this._refresh( false );
  10850. }
  10851. },
  10852. _refresh: function( create ) {
  10853. this._super( create );
  10854. if ( !create && this.options.mode === "columntoggle" ) {
  10855. // columns not being replaced must be cleared from input toggle-locks
  10856. this._unlockCells( this.allHeaders );
  10857. // update columntoggles and cells
  10858. this._addToggles( this._menu, create );
  10859. // check/uncheck
  10860. this._setToggleState();
  10861. }
  10862. },
  10863. _setToggleState: function() {
  10864. this._menu.find( "input" ).each( function() {
  10865. var checkbox = $( this );
  10866. this.checked = checkbox.jqmData( "cells" ).eq( 0 ).css( "display" ) === "table-cell";
  10867. checkbox.checkboxradio( "refresh" );
  10868. });
  10869. },
  10870. _destroy: function() {
  10871. this._super();
  10872. }
  10873. });
  10874. })( jQuery );
  10875. (function( $, undefined ) {
  10876. $.widget( "mobile.table", $.mobile.table, {
  10877. options: {
  10878. mode: "reflow",
  10879. classes: $.extend( $.mobile.table.prototype.options.classes, {
  10880. reflowTable: "ui-table-reflow",
  10881. cellLabels: "ui-table-cell-label"
  10882. })
  10883. },
  10884. _create: function() {
  10885. this._super();
  10886. // If it's not reflow mode, return here.
  10887. if ( this.options.mode !== "reflow" ) {
  10888. return;
  10889. }
  10890. if ( !this.options.enhanced ) {
  10891. this.element.addClass( this.options.classes.reflowTable );
  10892. this._updateReflow();
  10893. }
  10894. },
  10895. rebuild: function() {
  10896. this._super();
  10897. if ( this.options.mode === "reflow" ) {
  10898. this._refresh( false );
  10899. }
  10900. },
  10901. _refresh: function( create ) {
  10902. this._super( create );
  10903. if ( !create && this.options.mode === "reflow" ) {
  10904. this._updateReflow( );
  10905. }
  10906. },
  10907. _updateReflow: function() {
  10908. var table = this,
  10909. opts = this.options;
  10910. // get headers in reverse order so that top-level headers are appended last
  10911. $( table.allHeaders.get().reverse() ).each( function() {
  10912. var cells = $( this ).jqmData( "cells" ),
  10913. colstart = $.mobile.getAttribute( this, "colstart" ),
  10914. hierarchyClass = cells.not( this ).filter( "thead th" ).length && " ui-table-cell-label-top",
  10915. text = $( this ).text(),
  10916. iteration, filter;
  10917. if ( text !== "" ) {
  10918. if ( hierarchyClass ) {
  10919. iteration = parseInt( this.getAttribute( "colspan" ), 10 );
  10920. filter = "";
  10921. if ( iteration ) {
  10922. filter = "td:nth-child("+ iteration +"n + " + ( colstart ) +")";
  10923. }
  10924. table._addLabels( cells.filter( filter ), opts.classes.cellLabels + hierarchyClass, text );
  10925. } else {
  10926. table._addLabels( cells, opts.classes.cellLabels, text );
  10927. }
  10928. }
  10929. });
  10930. },
  10931. _addLabels: function( cells, label, text ) {
  10932. // .not fixes #6006
  10933. cells.not( ":has(b." + label + ")" ).prepend( "<b class='" + label + "'>" + text + "</b>" );
  10934. }
  10935. });
  10936. })( jQuery );
  10937. (function( $, undefined ) {
  10938. // TODO rename filterCallback/deprecate and default to the item itself as the first argument
  10939. var defaultFilterCallback = function( index, searchValue ) {
  10940. return ( ( "" + ( $.mobile.getAttribute( this, "filtertext" ) || $( this ).text() ) )
  10941. .toLowerCase().indexOf( searchValue ) === -1 );
  10942. };
  10943. $.widget( "mobile.filterable", {
  10944. initSelector: ":jqmData(filter='true')",
  10945. options: {
  10946. filterReveal: false,
  10947. filterCallback: defaultFilterCallback,
  10948. enhanced: false,
  10949. input: null,
  10950. children: "> li, > option, > optgroup option, > tbody tr, > .ui-controlgroup-controls > .ui-btn, > .ui-controlgroup-controls > .ui-checkbox, > .ui-controlgroup-controls > .ui-radio"
  10951. },
  10952. _create: function() {
  10953. var opts = this.options;
  10954. $.extend( this, {
  10955. _search: null,
  10956. _timer: 0
  10957. });
  10958. this._setInput( opts.input );
  10959. if ( !opts.enhanced ) {
  10960. this._filterItems( ( ( this._search && this._search.val() ) || "" ).toLowerCase() );
  10961. }
  10962. },
  10963. _onKeyUp: function() {
  10964. var val, lastval,
  10965. search = this._search;
  10966. if ( search ) {
  10967. val = search.val().toLowerCase(),
  10968. lastval = $.mobile.getAttribute( search[ 0 ], "lastval" ) + "";
  10969. if ( lastval && lastval === val ) {
  10970. // Execute the handler only once per value change
  10971. return;
  10972. }
  10973. if ( this._timer ) {
  10974. window.clearTimeout( this._timer );
  10975. this._timer = 0;
  10976. }
  10977. this._timer = this._delay( function() {
  10978. this._trigger( "beforefilter", "beforefilter", { input: search } );
  10979. // Change val as lastval for next execution
  10980. search[ 0 ].setAttribute( "data-" + $.mobile.ns + "lastval", val );
  10981. this._filterItems( val );
  10982. this._timer = 0;
  10983. }, 250 );
  10984. }
  10985. },
  10986. _getFilterableItems: function() {
  10987. var elem = this.element,
  10988. children = this.options.children,
  10989. items = !children ? { length: 0 }:
  10990. $.isFunction( children ) ? children():
  10991. children.nodeName ? $( children ):
  10992. children.jquery ? children:
  10993. this.element.find( children );
  10994. if ( items.length === 0 ) {
  10995. items = elem.children();
  10996. }
  10997. return items;
  10998. },
  10999. _filterItems: function( val ) {
  11000. var idx, callback, length, dst,
  11001. show = [],
  11002. hide = [],
  11003. opts = this.options,
  11004. filterItems = this._getFilterableItems();
  11005. if ( val != null ) {
  11006. callback = opts.filterCallback || defaultFilterCallback;
  11007. length = filterItems.length;
  11008. // Partition the items into those to be hidden and those to be shown
  11009. for ( idx = 0 ; idx < length ; idx++ ) {
  11010. dst = ( callback.call( filterItems[ idx ], idx, val ) ) ? hide : show;
  11011. dst.push( filterItems[ idx ] );
  11012. }
  11013. }
  11014. // If nothing is hidden, then the decision whether to hide or show the items
  11015. // is based on the "filterReveal" option.
  11016. if ( hide.length === 0 ) {
  11017. filterItems[ opts.filterReveal ? "addClass" : "removeClass" ]( "ui-screen-hidden" );
  11018. } else {
  11019. $( hide ).addClass( "ui-screen-hidden" );
  11020. $( show ).removeClass( "ui-screen-hidden" );
  11021. }
  11022. this._refreshChildWidget();
  11023. },
  11024. // The Default implementation of _refreshChildWidget attempts to call
  11025. // refresh on collapsibleset, controlgroup, selectmenu, or listview
  11026. _refreshChildWidget: function() {
  11027. var widget, idx,
  11028. recognizedWidgets = [ "collapsibleset", "selectmenu", "controlgroup", "listview" ];
  11029. for ( idx = recognizedWidgets.length - 1 ; idx > -1 ; idx-- ) {
  11030. widget = recognizedWidgets[ idx ];
  11031. if ( $.mobile[ widget ] ) {
  11032. widget = this.element.data( "mobile-" + widget );
  11033. if ( widget && $.isFunction( widget.refresh ) ) {
  11034. widget.refresh();
  11035. }
  11036. }
  11037. }
  11038. },
  11039. // TODO: When the input is not internal, do not even store it in this._search
  11040. _setInput: function ( selector ) {
  11041. var search = this._search;
  11042. // Stop a pending filter operation
  11043. if ( this._timer ) {
  11044. window.clearTimeout( this._timer );
  11045. this._timer = 0;
  11046. }
  11047. if ( search ) {
  11048. this._off( search, "keyup change input" );
  11049. search = null;
  11050. }
  11051. if ( selector ) {
  11052. search = selector.jquery ? selector:
  11053. selector.nodeName ? $( selector ):
  11054. this.document.find( selector );
  11055. this._on( search, {
  11056. keyup: "_onKeyUp",
  11057. change: "_onKeyUp",
  11058. input: "_onKeyUp"
  11059. });
  11060. }
  11061. this._search = search;
  11062. },
  11063. _setOptions: function( options ) {
  11064. var refilter = !( ( options.filterReveal === undefined ) &&
  11065. ( options.filterCallback === undefined ) &&
  11066. ( options.children === undefined ) );
  11067. this._super( options );
  11068. if ( options.input !== undefined ) {
  11069. this._setInput( options.input );
  11070. refilter = true;
  11071. }
  11072. if ( refilter ) {
  11073. this.refresh();
  11074. }
  11075. },
  11076. _destroy: function() {
  11077. var opts = this.options,
  11078. items = this._getFilterableItems();
  11079. if ( opts.enhanced ) {
  11080. items.toggleClass( "ui-screen-hidden", opts.filterReveal );
  11081. } else {
  11082. items.removeClass( "ui-screen-hidden" );
  11083. }
  11084. },
  11085. refresh: function() {
  11086. if ( this._timer ) {
  11087. window.clearTimeout( this._timer );
  11088. this._timer = 0;
  11089. }
  11090. this._filterItems( ( ( this._search && this._search.val() ) || "" ).toLowerCase() );
  11091. }
  11092. });
  11093. })( jQuery );
  11094. (function( $, undefined ) {
  11095. // Create a function that will replace the _setOptions function of a widget,
  11096. // and will pass the options on to the input of the filterable.
  11097. var replaceSetOptions = function( self, orig ) {
  11098. return function( options ) {
  11099. orig.call( this, options );
  11100. self._syncTextInputOptions( options );
  11101. };
  11102. },
  11103. rDividerListItem = /(^|\s)ui-li-divider(\s|$)/,
  11104. origDefaultFilterCallback = $.mobile.filterable.prototype.options.filterCallback;
  11105. // Override the default filter callback with one that does not hide list dividers
  11106. $.mobile.filterable.prototype.options.filterCallback = function( index, searchValue ) {
  11107. return !this.className.match( rDividerListItem ) &&
  11108. origDefaultFilterCallback.call( this, index, searchValue );
  11109. };
  11110. $.widget( "mobile.filterable", $.mobile.filterable, {
  11111. options: {
  11112. filterPlaceholder: "Filter items...",
  11113. filterTheme: null
  11114. },
  11115. _create: function() {
  11116. var idx, widgetName,
  11117. elem = this.element,
  11118. recognizedWidgets = [ "collapsibleset", "selectmenu", "controlgroup", "listview" ],
  11119. createHandlers = {};
  11120. this._super();
  11121. $.extend( this, {
  11122. _widget: null
  11123. });
  11124. for ( idx = recognizedWidgets.length - 1 ; idx > -1 ; idx-- ) {
  11125. widgetName = recognizedWidgets[ idx ];
  11126. if ( $.mobile[ widgetName ] ) {
  11127. if ( this._setWidget( elem.data( "mobile-" + widgetName ) ) ) {
  11128. break;
  11129. } else {
  11130. createHandlers[ widgetName + "create" ] = "_handleCreate";
  11131. }
  11132. }
  11133. }
  11134. if ( !this._widget ) {
  11135. this._on( elem, createHandlers );
  11136. }
  11137. },
  11138. _handleCreate: function( evt ) {
  11139. this._setWidget( this.element.data( "mobile-" + evt.type.substring( 0, evt.type.length - 6 ) ) );
  11140. },
  11141. _setWidget: function( widget ) {
  11142. if ( !this._widget && widget ) {
  11143. this._widget = widget;
  11144. this._widget._setOptions = replaceSetOptions( this, this._widget._setOptions );
  11145. }
  11146. if ( !!this._widget ) {
  11147. this._syncTextInputOptions( this._widget.options );
  11148. if ( this._widget.widgetName === "listview" ) {
  11149. this._widget.options.hidedividers = true;
  11150. this._widget.element.listview( "refresh" );
  11151. }
  11152. }
  11153. return !!this._widget;
  11154. },
  11155. _isSearchInternal: function() {
  11156. return ( this._search && this._search.jqmData( "ui-filterable-" + this.uuid + "-internal" ) );
  11157. },
  11158. _setInput: function( selector ) {
  11159. var opts = this.options,
  11160. updatePlaceholder = true,
  11161. textinputOpts = {};
  11162. if ( !selector ) {
  11163. if ( this._isSearchInternal() ) {
  11164. // Ignore the call to set a new input if the selector goes to falsy and
  11165. // the current textinput is already of the internally generated variety.
  11166. return;
  11167. } else {
  11168. // Generating a new textinput widget. No need to set the placeholder
  11169. // further down the function.
  11170. updatePlaceholder = false;
  11171. selector = $( "<input " +
  11172. "data-" + $.mobile.ns + "type='search' " +
  11173. "placeholder='" + opts.filterPlaceholder + "'></input>" )
  11174. .jqmData( "ui-filterable-" + this.uuid + "-internal", true );
  11175. $( "<form class='ui-filterable'></form>" )
  11176. .append( selector )
  11177. .submit( function( evt ) {
  11178. evt.preventDefault();
  11179. selector.blur();
  11180. })
  11181. .insertBefore( this.element );
  11182. if ( $.mobile.textinput ) {
  11183. if ( this.options.filterTheme != null ) {
  11184. textinputOpts[ "theme" ] = opts.filterTheme;
  11185. }
  11186. selector.textinput( textinputOpts );
  11187. }
  11188. }
  11189. }
  11190. this._super( selector );
  11191. if ( this._isSearchInternal() && updatePlaceholder ) {
  11192. this._search.attr( "placeholder", this.options.filterPlaceholder );
  11193. }
  11194. },
  11195. _setOptions: function( options ) {
  11196. var ret = this._super( options );
  11197. // Need to set the filterPlaceholder after having established the search input
  11198. if ( options.filterPlaceholder !== undefined ) {
  11199. if ( this._isSearchInternal() ) {
  11200. this._search.attr( "placeholder", options.filterPlaceholder );
  11201. }
  11202. }
  11203. if ( options.filterTheme !== undefined && this._search && $.mobile.textinput ) {
  11204. this._search.textinput( "option", "theme", options.filterTheme );
  11205. }
  11206. return ret;
  11207. },
  11208. _destroy: function() {
  11209. if ( this._isSearchInternal() ) {
  11210. this._search.remove();
  11211. }
  11212. this._super();
  11213. },
  11214. _syncTextInputOptions: function( options ) {
  11215. var idx,
  11216. textinputOptions = {};
  11217. // We only sync options if the filterable's textinput is of the internally
  11218. // generated variety, rather than one specified by the user.
  11219. if ( this._isSearchInternal() && $.mobile.textinput ) {
  11220. // Apply only the options understood by textinput
  11221. for ( idx in $.mobile.textinput.prototype.options ) {
  11222. if ( options[ idx ] !== undefined ) {
  11223. if ( idx === "theme" && this.options.filterTheme != null ) {
  11224. textinputOptions[ idx ] = this.options.filterTheme;
  11225. } else {
  11226. textinputOptions[ idx ] = options[ idx ];
  11227. }
  11228. }
  11229. }
  11230. this._search.textinput( "option", textinputOptions );
  11231. }
  11232. }
  11233. });
  11234. })( jQuery );
  11235. /*!
  11236. * jQuery UI Tabs fadf2b312a05040436451c64bbfaf4814bc62c56
  11237. * http://jqueryui.com
  11238. *
  11239. * Copyright 2013 jQuery Foundation and other contributors
  11240. * Released under the MIT license.
  11241. * http://jquery.org/license
  11242. *
  11243. * http://api.jqueryui.com/tabs/
  11244. *
  11245. * Depends:
  11246. * jquery.ui.core.js
  11247. * jquery.ui.widget.js
  11248. */
  11249. (function( $, undefined ) {
  11250. var tabId = 0,
  11251. rhash = /#.*$/;
  11252. function getNextTabId() {
  11253. return ++tabId;
  11254. }
  11255. function isLocal( anchor ) {
  11256. return anchor.hash.length > 1 &&
  11257. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  11258. decodeURIComponent( location.href.replace( rhash, "" ) );
  11259. }
  11260. $.widget( "ui.tabs", {
  11261. version: "fadf2b312a05040436451c64bbfaf4814bc62c56",
  11262. delay: 300,
  11263. options: {
  11264. active: null,
  11265. collapsible: false,
  11266. event: "click",
  11267. heightStyle: "content",
  11268. hide: null,
  11269. show: null,
  11270. // callbacks
  11271. activate: null,
  11272. beforeActivate: null,
  11273. beforeLoad: null,
  11274. load: null
  11275. },
  11276. _create: function() {
  11277. var that = this,
  11278. options = this.options;
  11279. this.running = false;
  11280. this.element
  11281. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11282. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11283. // Prevent users from focusing disabled tabs via click
  11284. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11285. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11286. event.preventDefault();
  11287. }
  11288. })
  11289. // support: IE <9
  11290. // Preventing the default action in mousedown doesn't prevent IE
  11291. // from focusing the element, so if the anchor gets focused, blur.
  11292. // We don't have to worry about focusing the previously focused
  11293. // element since clicking on a non-focusable element should focus
  11294. // the body anyway.
  11295. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11296. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11297. this.blur();
  11298. }
  11299. });
  11300. this._processTabs();
  11301. options.active = this._initialActive();
  11302. // Take disabling tabs via class attribute from HTML
  11303. // into account and update option properly.
  11304. if ( $.isArray( options.disabled ) ) {
  11305. options.disabled = $.unique( options.disabled.concat(
  11306. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11307. return that.tabs.index( li );
  11308. })
  11309. ) ).sort();
  11310. }
  11311. // check for length avoids error when initializing empty list
  11312. if ( this.options.active !== false && this.anchors.length ) {
  11313. this.active = this._findActive( options.active );
  11314. } else {
  11315. this.active = $();
  11316. }
  11317. this._refresh();
  11318. if ( this.active.length ) {
  11319. this.load( options.active );
  11320. }
  11321. },
  11322. _initialActive: function() {
  11323. var active = this.options.active,
  11324. collapsible = this.options.collapsible,
  11325. locationHash = location.hash.substring( 1 );
  11326. if ( active === null ) {
  11327. // check the fragment identifier in the URL
  11328. if ( locationHash ) {
  11329. this.tabs.each(function( i, tab ) {
  11330. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11331. active = i;
  11332. return false;
  11333. }
  11334. });
  11335. }
  11336. // check for a tab marked active via a class
  11337. if ( active === null ) {
  11338. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11339. }
  11340. // no active tab, set to false
  11341. if ( active === null || active === -1 ) {
  11342. active = this.tabs.length ? 0 : false;
  11343. }
  11344. }
  11345. // handle numbers: negative, out of range
  11346. if ( active !== false ) {
  11347. active = this.tabs.index( this.tabs.eq( active ) );
  11348. if ( active === -1 ) {
  11349. active = collapsible ? false : 0;
  11350. }
  11351. }
  11352. // don't allow collapsible: false and active: false
  11353. if ( !collapsible && active === false && this.anchors.length ) {
  11354. active = 0;
  11355. }
  11356. return active;
  11357. },
  11358. _getCreateEventData: function() {
  11359. return {
  11360. tab: this.active,
  11361. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11362. };
  11363. },
  11364. _tabKeydown: function( event ) {
  11365. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11366. selectedIndex = this.tabs.index( focusedTab ),
  11367. goingForward = true;
  11368. if ( this._handlePageNav( event ) ) {
  11369. return;
  11370. }
  11371. switch ( event.keyCode ) {
  11372. case $.ui.keyCode.RIGHT:
  11373. case $.ui.keyCode.DOWN:
  11374. selectedIndex++;
  11375. break;
  11376. case $.ui.keyCode.UP:
  11377. case $.ui.keyCode.LEFT:
  11378. goingForward = false;
  11379. selectedIndex--;
  11380. break;
  11381. case $.ui.keyCode.END:
  11382. selectedIndex = this.anchors.length - 1;
  11383. break;
  11384. case $.ui.keyCode.HOME:
  11385. selectedIndex = 0;
  11386. break;
  11387. case $.ui.keyCode.SPACE:
  11388. // Activate only, no collapsing
  11389. event.preventDefault();
  11390. clearTimeout( this.activating );
  11391. this._activate( selectedIndex );
  11392. return;
  11393. case $.ui.keyCode.ENTER:
  11394. // Toggle (cancel delayed activation, allow collapsing)
  11395. event.preventDefault();
  11396. clearTimeout( this.activating );
  11397. // Determine if we should collapse or activate
  11398. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11399. return;
  11400. default:
  11401. return;
  11402. }
  11403. // Focus the appropriate tab, based on which key was pressed
  11404. event.preventDefault();
  11405. clearTimeout( this.activating );
  11406. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11407. // Navigating with control key will prevent automatic activation
  11408. if ( !event.ctrlKey ) {
  11409. // Update aria-selected immediately so that AT think the tab is already selected.
  11410. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11411. // but the tab will already be activated by the time the announcement finishes.
  11412. focusedTab.attr( "aria-selected", "false" );
  11413. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11414. this.activating = this._delay(function() {
  11415. this.option( "active", selectedIndex );
  11416. }, this.delay );
  11417. }
  11418. },
  11419. _panelKeydown: function( event ) {
  11420. if ( this._handlePageNav( event ) ) {
  11421. return;
  11422. }
  11423. // Ctrl+up moves focus to the current tab
  11424. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  11425. event.preventDefault();
  11426. this.active.focus();
  11427. }
  11428. },
  11429. // Alt+page up/down moves focus to the previous/next tab (and activates)
  11430. _handlePageNav: function( event ) {
  11431. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  11432. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  11433. return true;
  11434. }
  11435. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  11436. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  11437. return true;
  11438. }
  11439. },
  11440. _findNextTab: function( index, goingForward ) {
  11441. var lastTabIndex = this.tabs.length - 1;
  11442. function constrain() {
  11443. if ( index > lastTabIndex ) {
  11444. index = 0;
  11445. }
  11446. if ( index < 0 ) {
  11447. index = lastTabIndex;
  11448. }
  11449. return index;
  11450. }
  11451. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  11452. index = goingForward ? index + 1 : index - 1;
  11453. }
  11454. return index;
  11455. },
  11456. _focusNextTab: function( index, goingForward ) {
  11457. index = this._findNextTab( index, goingForward );
  11458. this.tabs.eq( index ).focus();
  11459. return index;
  11460. },
  11461. _setOption: function( key, value ) {
  11462. if ( key === "active" ) {
  11463. // _activate() will handle invalid values and update this.options
  11464. this._activate( value );
  11465. return;
  11466. }
  11467. if ( key === "disabled" ) {
  11468. // don't use the widget factory's disabled handling
  11469. this._setupDisabled( value );
  11470. return;
  11471. }
  11472. this._super( key, value);
  11473. if ( key === "collapsible" ) {
  11474. this.element.toggleClass( "ui-tabs-collapsible", value );
  11475. // Setting collapsible: false while collapsed; open first panel
  11476. if ( !value && this.options.active === false ) {
  11477. this._activate( 0 );
  11478. }
  11479. }
  11480. if ( key === "event" ) {
  11481. this._setupEvents( value );
  11482. }
  11483. if ( key === "heightStyle" ) {
  11484. this._setupHeightStyle( value );
  11485. }
  11486. },
  11487. _tabId: function( tab ) {
  11488. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  11489. },
  11490. _sanitizeSelector: function( hash ) {
  11491. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  11492. },
  11493. refresh: function() {
  11494. var options = this.options,
  11495. lis = this.tablist.children( ":has(a[href])" );
  11496. // get disabled tabs from class attribute from HTML
  11497. // this will get converted to a boolean if needed in _refresh()
  11498. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  11499. return lis.index( tab );
  11500. });
  11501. this._processTabs();
  11502. // was collapsed or no tabs
  11503. if ( options.active === false || !this.anchors.length ) {
  11504. options.active = false;
  11505. this.active = $();
  11506. // was active, but active tab is gone
  11507. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  11508. // all remaining tabs are disabled
  11509. if ( this.tabs.length === options.disabled.length ) {
  11510. options.active = false;
  11511. this.active = $();
  11512. // activate previous tab
  11513. } else {
  11514. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  11515. }
  11516. // was active, active tab still exists
  11517. } else {
  11518. // make sure active index is correct
  11519. options.active = this.tabs.index( this.active );
  11520. }
  11521. this._refresh();
  11522. },
  11523. _refresh: function() {
  11524. this._setupDisabled( this.options.disabled );
  11525. this._setupEvents( this.options.event );
  11526. this._setupHeightStyle( this.options.heightStyle );
  11527. this.tabs.not( this.active ).attr({
  11528. "aria-selected": "false",
  11529. tabIndex: -1
  11530. });
  11531. this.panels.not( this._getPanelForTab( this.active ) )
  11532. .hide()
  11533. .attr({
  11534. "aria-expanded": "false",
  11535. "aria-hidden": "true"
  11536. });
  11537. // Make sure one tab is in the tab order
  11538. if ( !this.active.length ) {
  11539. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  11540. } else {
  11541. this.active
  11542. .addClass( "ui-tabs-active ui-state-active" )
  11543. .attr({
  11544. "aria-selected": "true",
  11545. tabIndex: 0
  11546. });
  11547. this._getPanelForTab( this.active )
  11548. .show()
  11549. .attr({
  11550. "aria-expanded": "true",
  11551. "aria-hidden": "false"
  11552. });
  11553. }
  11554. },
  11555. _processTabs: function() {
  11556. var that = this;
  11557. this.tablist = this._getList()
  11558. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11559. .attr( "role", "tablist" );
  11560. this.tabs = this.tablist.find( "> li:has(a[href])" )
  11561. .addClass( "ui-state-default ui-corner-top" )
  11562. .attr({
  11563. role: "tab",
  11564. tabIndex: -1
  11565. });
  11566. this.anchors = this.tabs.map(function() {
  11567. return $( "a", this )[ 0 ];
  11568. })
  11569. .addClass( "ui-tabs-anchor" )
  11570. .attr({
  11571. role: "presentation",
  11572. tabIndex: -1
  11573. });
  11574. this.panels = $();
  11575. this.anchors.each(function( i, anchor ) {
  11576. var selector, panel, panelId,
  11577. anchorId = $( anchor ).uniqueId().attr( "id" ),
  11578. tab = $( anchor ).closest( "li" ),
  11579. originalAriaControls = tab.attr( "aria-controls" );
  11580. // inline tab
  11581. if ( isLocal( anchor ) ) {
  11582. selector = anchor.hash;
  11583. panel = that.element.find( that._sanitizeSelector( selector ) );
  11584. // remote tab
  11585. } else {
  11586. panelId = that._tabId( tab );
  11587. selector = "#" + panelId;
  11588. panel = that.element.find( selector );
  11589. if ( !panel.length ) {
  11590. panel = that._createPanel( panelId );
  11591. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  11592. }
  11593. panel.attr( "aria-live", "polite" );
  11594. }
  11595. if ( panel.length) {
  11596. that.panels = that.panels.add( panel );
  11597. }
  11598. if ( originalAriaControls ) {
  11599. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  11600. }
  11601. tab.attr({
  11602. "aria-controls": selector.substring( 1 ),
  11603. "aria-labelledby": anchorId
  11604. });
  11605. panel.attr( "aria-labelledby", anchorId );
  11606. });
  11607. this.panels
  11608. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11609. .attr( "role", "tabpanel" );
  11610. },
  11611. // allow overriding how to find the list for rare usage scenarios (#7715)
  11612. _getList: function() {
  11613. return this.element.find( "ol,ul" ).eq( 0 );
  11614. },
  11615. _createPanel: function( id ) {
  11616. return $( "<div>" )
  11617. .attr( "id", id )
  11618. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11619. .data( "ui-tabs-destroy", true );
  11620. },
  11621. _setupDisabled: function( disabled ) {
  11622. if ( $.isArray( disabled ) ) {
  11623. if ( !disabled.length ) {
  11624. disabled = false;
  11625. } else if ( disabled.length === this.anchors.length ) {
  11626. disabled = true;
  11627. }
  11628. }
  11629. // disable tabs
  11630. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  11631. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  11632. $( li )
  11633. .addClass( "ui-state-disabled" )
  11634. .attr( "aria-disabled", "true" );
  11635. } else {
  11636. $( li )
  11637. .removeClass( "ui-state-disabled" )
  11638. .removeAttr( "aria-disabled" );
  11639. }
  11640. }
  11641. this.options.disabled = disabled;
  11642. },
  11643. _setupEvents: function( event ) {
  11644. var events = {
  11645. click: function( event ) {
  11646. event.preventDefault();
  11647. }
  11648. };
  11649. if ( event ) {
  11650. $.each( event.split(" "), function( index, eventName ) {
  11651. events[ eventName ] = "_eventHandler";
  11652. });
  11653. }
  11654. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  11655. this._on( this.anchors, events );
  11656. this._on( this.tabs, { keydown: "_tabKeydown" } );
  11657. this._on( this.panels, { keydown: "_panelKeydown" } );
  11658. this._focusable( this.tabs );
  11659. this._hoverable( this.tabs );
  11660. },
  11661. _setupHeightStyle: function( heightStyle ) {
  11662. var maxHeight,
  11663. parent = this.element.parent();
  11664. if ( heightStyle === "fill" ) {
  11665. maxHeight = parent.height();
  11666. maxHeight -= this.element.outerHeight() - this.element.height();
  11667. this.element.siblings( ":visible" ).each(function() {
  11668. var elem = $( this ),
  11669. position = elem.css( "position" );
  11670. if ( position === "absolute" || position === "fixed" ) {
  11671. return;
  11672. }
  11673. maxHeight -= elem.outerHeight( true );
  11674. });
  11675. this.element.children().not( this.panels ).each(function() {
  11676. maxHeight -= $( this ).outerHeight( true );
  11677. });
  11678. this.panels.each(function() {
  11679. $( this ).height( Math.max( 0, maxHeight -
  11680. $( this ).innerHeight() + $( this ).height() ) );
  11681. })
  11682. .css( "overflow", "auto" );
  11683. } else if ( heightStyle === "auto" ) {
  11684. maxHeight = 0;
  11685. this.panels.each(function() {
  11686. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  11687. }).height( maxHeight );
  11688. }
  11689. },
  11690. _eventHandler: function( event ) {
  11691. var options = this.options,
  11692. active = this.active,
  11693. anchor = $( event.currentTarget ),
  11694. tab = anchor.closest( "li" ),
  11695. clickedIsActive = tab[ 0 ] === active[ 0 ],
  11696. collapsing = clickedIsActive && options.collapsible,
  11697. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  11698. toHide = !active.length ? $() : this._getPanelForTab( active ),
  11699. eventData = {
  11700. oldTab: active,
  11701. oldPanel: toHide,
  11702. newTab: collapsing ? $() : tab,
  11703. newPanel: toShow
  11704. };
  11705. event.preventDefault();
  11706. if ( tab.hasClass( "ui-state-disabled" ) ||
  11707. // tab is already loading
  11708. tab.hasClass( "ui-tabs-loading" ) ||
  11709. // can't switch durning an animation
  11710. this.running ||
  11711. // click on active header, but not collapsible
  11712. ( clickedIsActive && !options.collapsible ) ||
  11713. // allow canceling activation
  11714. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  11715. return;
  11716. }
  11717. options.active = collapsing ? false : this.tabs.index( tab );
  11718. this.active = clickedIsActive ? $() : tab;
  11719. if ( this.xhr ) {
  11720. this.xhr.abort();
  11721. }
  11722. if ( !toHide.length && !toShow.length ) {
  11723. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  11724. }
  11725. if ( toShow.length ) {
  11726. this.load( this.tabs.index( tab ), event );
  11727. }
  11728. this._toggle( event, eventData );
  11729. },
  11730. // handles show/hide for selecting tabs
  11731. _toggle: function( event, eventData ) {
  11732. var that = this,
  11733. toShow = eventData.newPanel,
  11734. toHide = eventData.oldPanel;
  11735. this.running = true;
  11736. function complete() {
  11737. that.running = false;
  11738. that._trigger( "activate", event, eventData );
  11739. }
  11740. function show() {
  11741. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  11742. if ( toShow.length && that.options.show ) {
  11743. that._show( toShow, that.options.show, complete );
  11744. } else {
  11745. toShow.show();
  11746. complete();
  11747. }
  11748. }
  11749. // start out by hiding, then showing, then completing
  11750. if ( toHide.length && this.options.hide ) {
  11751. this._hide( toHide, this.options.hide, function() {
  11752. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11753. show();
  11754. });
  11755. } else {
  11756. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11757. toHide.hide();
  11758. show();
  11759. }
  11760. toHide.attr({
  11761. "aria-expanded": "false",
  11762. "aria-hidden": "true"
  11763. });
  11764. eventData.oldTab.attr( "aria-selected", "false" );
  11765. // If we're switching tabs, remove the old tab from the tab order.
  11766. // If we're opening from collapsed state, remove the previous tab from the tab order.
  11767. // If we're collapsing, then keep the collapsing tab in the tab order.
  11768. if ( toShow.length && toHide.length ) {
  11769. eventData.oldTab.attr( "tabIndex", -1 );
  11770. } else if ( toShow.length ) {
  11771. this.tabs.filter(function() {
  11772. return $( this ).attr( "tabIndex" ) === 0;
  11773. })
  11774. .attr( "tabIndex", -1 );
  11775. }
  11776. toShow.attr({
  11777. "aria-expanded": "true",
  11778. "aria-hidden": "false"
  11779. });
  11780. eventData.newTab.attr({
  11781. "aria-selected": "true",
  11782. tabIndex: 0
  11783. });
  11784. },
  11785. _activate: function( index ) {
  11786. var anchor,
  11787. active = this._findActive( index );
  11788. // trying to activate the already active panel
  11789. if ( active[ 0 ] === this.active[ 0 ] ) {
  11790. return;
  11791. }
  11792. // trying to collapse, simulate a click on the current active header
  11793. if ( !active.length ) {
  11794. active = this.active;
  11795. }
  11796. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  11797. this._eventHandler({
  11798. target: anchor,
  11799. currentTarget: anchor,
  11800. preventDefault: $.noop
  11801. });
  11802. },
  11803. _findActive: function( index ) {
  11804. return index === false ? $() : this.tabs.eq( index );
  11805. },
  11806. _getIndex: function( index ) {
  11807. // meta-function to give users option to provide a href string instead of a numerical index.
  11808. if ( typeof index === "string" ) {
  11809. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  11810. }
  11811. return index;
  11812. },
  11813. _destroy: function() {
  11814. if ( this.xhr ) {
  11815. this.xhr.abort();
  11816. }
  11817. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  11818. this.tablist
  11819. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11820. .removeAttr( "role" );
  11821. this.anchors
  11822. .removeClass( "ui-tabs-anchor" )
  11823. .removeAttr( "role" )
  11824. .removeAttr( "tabIndex" )
  11825. .removeUniqueId();
  11826. this.tabs.add( this.panels ).each(function() {
  11827. if ( $.data( this, "ui-tabs-destroy" ) ) {
  11828. $( this ).remove();
  11829. } else {
  11830. $( this )
  11831. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  11832. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  11833. .removeAttr( "tabIndex" )
  11834. .removeAttr( "aria-live" )
  11835. .removeAttr( "aria-busy" )
  11836. .removeAttr( "aria-selected" )
  11837. .removeAttr( "aria-labelledby" )
  11838. .removeAttr( "aria-hidden" )
  11839. .removeAttr( "aria-expanded" )
  11840. .removeAttr( "role" );
  11841. }
  11842. });
  11843. this.tabs.each(function() {
  11844. var li = $( this ),
  11845. prev = li.data( "ui-tabs-aria-controls" );
  11846. if ( prev ) {
  11847. li
  11848. .attr( "aria-controls", prev )
  11849. .removeData( "ui-tabs-aria-controls" );
  11850. } else {
  11851. li.removeAttr( "aria-controls" );
  11852. }
  11853. });
  11854. this.panels.show();
  11855. if ( this.options.heightStyle !== "content" ) {
  11856. this.panels.css( "height", "" );
  11857. }
  11858. },
  11859. enable: function( index ) {
  11860. var disabled = this.options.disabled;
  11861. if ( disabled === false ) {
  11862. return;
  11863. }
  11864. if ( index === undefined ) {
  11865. disabled = false;
  11866. } else {
  11867. index = this._getIndex( index );
  11868. if ( $.isArray( disabled ) ) {
  11869. disabled = $.map( disabled, function( num ) {
  11870. return num !== index ? num : null;
  11871. });
  11872. } else {
  11873. disabled = $.map( this.tabs, function( li, num ) {
  11874. return num !== index ? num : null;
  11875. });
  11876. }
  11877. }
  11878. this._setupDisabled( disabled );
  11879. },
  11880. disable: function( index ) {
  11881. var disabled = this.options.disabled;
  11882. if ( disabled === true ) {
  11883. return;
  11884. }
  11885. if ( index === undefined ) {
  11886. disabled = true;
  11887. } else {
  11888. index = this._getIndex( index );
  11889. if ( $.inArray( index, disabled ) !== -1 ) {
  11890. return;
  11891. }
  11892. if ( $.isArray( disabled ) ) {
  11893. disabled = $.merge( [ index ], disabled ).sort();
  11894. } else {
  11895. disabled = [ index ];
  11896. }
  11897. }
  11898. this._setupDisabled( disabled );
  11899. },
  11900. load: function( index, event ) {
  11901. index = this._getIndex( index );
  11902. var that = this,
  11903. tab = this.tabs.eq( index ),
  11904. anchor = tab.find( ".ui-tabs-anchor" ),
  11905. panel = this._getPanelForTab( tab ),
  11906. eventData = {
  11907. tab: tab,
  11908. panel: panel
  11909. };
  11910. // not remote
  11911. if ( isLocal( anchor[ 0 ] ) ) {
  11912. return;
  11913. }
  11914. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  11915. // support: jQuery <1.8
  11916. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  11917. // but as of 1.8, $.ajax() always returns a jqXHR object.
  11918. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  11919. tab.addClass( "ui-tabs-loading" );
  11920. panel.attr( "aria-busy", "true" );
  11921. this.xhr
  11922. .success(function( response ) {
  11923. // support: jQuery <1.8
  11924. // http://bugs.jquery.com/ticket/11778
  11925. setTimeout(function() {
  11926. panel.html( response );
  11927. that._trigger( "load", event, eventData );
  11928. }, 1 );
  11929. })
  11930. .complete(function( jqXHR, status ) {
  11931. // support: jQuery <1.8
  11932. // http://bugs.jquery.com/ticket/11778
  11933. setTimeout(function() {
  11934. if ( status === "abort" ) {
  11935. that.panels.stop( false, true );
  11936. }
  11937. tab.removeClass( "ui-tabs-loading" );
  11938. panel.removeAttr( "aria-busy" );
  11939. if ( jqXHR === that.xhr ) {
  11940. delete that.xhr;
  11941. }
  11942. }, 1 );
  11943. });
  11944. }
  11945. },
  11946. _ajaxSettings: function( anchor, event, eventData ) {
  11947. var that = this;
  11948. return {
  11949. url: anchor.attr( "href" ),
  11950. beforeSend: function( jqXHR, settings ) {
  11951. return that._trigger( "beforeLoad", event,
  11952. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  11953. }
  11954. };
  11955. },
  11956. _getPanelForTab: function( tab ) {
  11957. var id = $( tab ).attr( "aria-controls" );
  11958. return this.element.find( this._sanitizeSelector( "#" + id ) );
  11959. }
  11960. });
  11961. })( jQuery );
  11962. (function( $, undefined ) {
  11963. })( jQuery );
  11964. (function( $, window ) {
  11965. $.mobile.iosorientationfixEnabled = true;
  11966. // This fix addresses an iOS bug, so return early if the UA claims it's something else.
  11967. var ua = navigator.userAgent,
  11968. zoom,
  11969. evt, x, y, z, aig;
  11970. if ( !( /iPhone|iPad|iPod/.test( navigator.platform ) && /OS [1-5]_[0-9_]* like Mac OS X/i.test( ua ) && ua.indexOf( "AppleWebKit" ) > -1 ) ) {
  11971. $.mobile.iosorientationfixEnabled = false;
  11972. return;
  11973. }
  11974. zoom = $.mobile.zoom;
  11975. function checkTilt( e ) {
  11976. evt = e.originalEvent;
  11977. aig = evt.accelerationIncludingGravity;
  11978. x = Math.abs( aig.x );
  11979. y = Math.abs( aig.y );
  11980. z = Math.abs( aig.z );
  11981. // If portrait orientation and in one of the danger zones
  11982. if ( !window.orientation && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ) {
  11983. if ( zoom.enabled ) {
  11984. zoom.disable();
  11985. }
  11986. } else if ( !zoom.enabled ) {
  11987. zoom.enable();
  11988. }
  11989. }
  11990. $.mobile.document.on( "mobileinit", function() {
  11991. if ( $.mobile.iosorientationfixEnabled ) {
  11992. $.mobile.window
  11993. .bind( "orientationchange.iosorientationfix", zoom.enable )
  11994. .bind( "devicemotion.iosorientationfix", checkTilt );
  11995. }
  11996. });
  11997. }( jQuery, this ));
  11998. (function( $, window, undefined ) {
  11999. var $html = $( "html" ),
  12000. $window = $.mobile.window;
  12001. //remove initial build class (only present on first pageshow)
  12002. function hideRenderingClass() {
  12003. $html.removeClass( "ui-mobile-rendering" );
  12004. }
  12005. // trigger mobileinit event - useful hook for configuring $.mobile settings before they're used
  12006. $( window.document ).trigger( "mobileinit" );
  12007. // support conditions
  12008. // if device support condition(s) aren't met, leave things as they are -> a basic, usable experience,
  12009. // otherwise, proceed with the enhancements
  12010. if ( !$.mobile.gradeA() ) {
  12011. return;
  12012. }
  12013. // override ajaxEnabled on platforms that have known conflicts with hash history updates
  12014. // or generally work better browsing in regular http for full page refreshes (BB5, Opera Mini)
  12015. if ( $.mobile.ajaxBlacklist ) {
  12016. $.mobile.ajaxEnabled = false;
  12017. }
  12018. // Add mobile, initial load "rendering" classes to docEl
  12019. $html.addClass( "ui-mobile ui-mobile-rendering" );
  12020. // This is a fallback. If anything goes wrong (JS errors, etc), or events don't fire,
  12021. // this ensures the rendering class is removed after 5 seconds, so content is visible and accessible
  12022. setTimeout( hideRenderingClass, 5000 );
  12023. $.extend( $.mobile, {
  12024. // find and enhance the pages in the dom and transition to the first page.
  12025. initializePage: function() {
  12026. // find present pages
  12027. var path = $.mobile.path,
  12028. $pages = $( ":jqmData(role='page'), :jqmData(role='dialog')" ),
  12029. hash = path.stripHash( path.stripQueryParams(path.parseLocation().hash) ),
  12030. hashPage = document.getElementById( hash );
  12031. // if no pages are found, create one with body's inner html
  12032. if ( !$pages.length ) {
  12033. $pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 );
  12034. }
  12035. // add dialogs, set data-url attrs
  12036. $pages.each(function() {
  12037. var $this = $( this );
  12038. // unless the data url is already set set it to the pathname
  12039. if ( !$this[ 0 ].getAttribute( "data-" + $.mobile.ns + "url" ) ) {
  12040. $this.attr( "data-" + $.mobile.ns + "url", $this.attr( "id" ) || location.pathname + location.search );
  12041. }
  12042. });
  12043. // define first page in dom case one backs out to the directory root (not always the first page visited, but defined as fallback)
  12044. $.mobile.firstPage = $pages.first();
  12045. // define page container
  12046. $.mobile.pageContainer = $.mobile.firstPage
  12047. .parent()
  12048. .addClass( "ui-mobile-viewport" )
  12049. .pagecontainer();
  12050. // initialize navigation events now, after mobileinit has occurred and the page container
  12051. // has been created but before the rest of the library is alerted to that fact
  12052. $.mobile.navreadyDeferred.resolve();
  12053. // alert listeners that the pagecontainer has been determined for binding
  12054. // to events triggered on it
  12055. $window.trigger( "pagecontainercreate" );
  12056. // cue page loading message
  12057. $.mobile.loading( "show" );
  12058. //remove initial build class (only present on first pageshow)
  12059. hideRenderingClass();
  12060. // if hashchange listening is disabled, there's no hash deeplink,
  12061. // the hash is not valid (contains more than one # or does not start with #)
  12062. // or there is no page with that hash, change to the first page in the DOM
  12063. // Remember, however, that the hash can also be a path!
  12064. if ( ! ( $.mobile.hashListeningEnabled &&
  12065. $.mobile.path.isHashValid( location.hash ) &&
  12066. ( $( hashPage ).is( ":jqmData(role='page')" ) ||
  12067. $.mobile.path.isPath( hash ) ||
  12068. hash === $.mobile.dialogHashKey ) ) ) {
  12069. // Store the initial destination
  12070. if ( $.mobile.path.isHashValid( location.hash ) ) {
  12071. $.mobile.navigate.history.initialDst = hash.replace( "#", "" );
  12072. }
  12073. // make sure to set initial popstate state if it exists
  12074. // so that navigation back to the initial page works properly
  12075. if ( $.event.special.navigate.isPushStateEnabled() ) {
  12076. $.mobile.navigate.navigator.squash( path.parseLocation().href );
  12077. }
  12078. $.mobile.changePage( $.mobile.firstPage, {
  12079. transition: "none",
  12080. reverse: true,
  12081. changeHash: false,
  12082. fromHashChange: true
  12083. });
  12084. } else {
  12085. // trigger hashchange or navigate to squash and record the correct
  12086. // history entry for an initial hash path
  12087. if ( !$.event.special.navigate.isPushStateEnabled() ) {
  12088. $window.trigger( "hashchange", [true] );
  12089. } else {
  12090. // TODO figure out how to simplify this interaction with the initial history entry
  12091. // at the bottom js/navigate/navigate.js
  12092. $.mobile.navigate.history.stack = [];
  12093. $.mobile.navigate( $.mobile.path.isPath( location.hash ) ? location.hash : location.href );
  12094. }
  12095. }
  12096. }
  12097. });
  12098. $(function() {
  12099. //Run inlineSVG support test
  12100. $.support.inlineSVG();
  12101. // check which scrollTop value should be used by scrolling to 1 immediately at domready
  12102. // then check what the scroll top is. Android will report 0... others 1
  12103. // note that this initial scroll won't hide the address bar. It's just for the check.
  12104. // hide iOS browser chrome on load if hideUrlBar is true this is to try and do it as soon as possible
  12105. if ( $.mobile.hideUrlBar ) {
  12106. window.scrollTo( 0, 1 );
  12107. }
  12108. // if defaultHomeScroll hasn't been set yet, see if scrollTop is 1
  12109. // it should be 1 in most browsers, but android treats 1 as 0 (for hiding addr bar)
  12110. // so if it's 1, use 0 from now on
  12111. $.mobile.defaultHomeScroll = ( !$.support.scrollTop || $.mobile.window.scrollTop() === 1 ) ? 0 : 1;
  12112. //dom-ready inits
  12113. if ( $.mobile.autoInitializePage ) {
  12114. $.mobile.initializePage();
  12115. }
  12116. // window load event
  12117. // hide iOS browser chrome on load if hideUrlBar is true this is as fall back incase we were too early before
  12118. if ( $.mobile.hideUrlBar ) {
  12119. $window.load( $.mobile.silentScroll );
  12120. }
  12121. if ( !$.support.cssPointerEvents ) {
  12122. // IE and Opera don't support CSS pointer-events: none that we use to disable link-based buttons
  12123. // by adding the 'ui-disabled' class to them. Using a JavaScript workaround for those browser.
  12124. // https://github.com/jquery/jquery-mobile/issues/3558
  12125. // DEPRECATED as of 1.4.0 - remove ui-disabled after 1.4.0 release
  12126. // only ui-state-disabled should be present thereafter
  12127. $.mobile.document.delegate( ".ui-state-disabled,.ui-disabled", "vclick",
  12128. function( e ) {
  12129. e.preventDefault();
  12130. e.stopImmediatePropagation();
  12131. }
  12132. );
  12133. }
  12134. });
  12135. }( jQuery, this ));
  12136. }));