jquery.mobile-1.4.5.js 455 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454
  1. /*!
  2. * jQuery Mobile 1.4.5
  3. * Git HEAD hash: 68e55e78b292634d3991c795f06f5e37a512decc <> Date: Fri Oct 31 2014 17:33:30 UTC
  4. * http://jquerymobile.com
  5. *
  6. * Copyright 2010, 2014 jQuery Foundation, Inc. and othercontributors
  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. /*!
  27. * jQuery UI Core c0ab71056b936627e8a7821f03c044aec6280a40
  28. * http://jqueryui.com
  29. *
  30. * Copyright 2013 jQuery Foundation and other contributors
  31. * Released under the MIT license.
  32. * http://jquery.org/license
  33. *
  34. * http://api.jqueryui.com/category/ui-core/
  35. */
  36. (function( $, undefined ) {
  37. var uuid = 0,
  38. runiqueId = /^ui-id-\d+$/;
  39. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  40. $.ui = $.ui || {};
  41. $.extend( $.ui, {
  42. version: "c0ab71056b936627e8a7821f03c044aec6280a40",
  43. keyCode: {
  44. BACKSPACE: 8,
  45. COMMA: 188,
  46. DELETE: 46,
  47. DOWN: 40,
  48. END: 35,
  49. ENTER: 13,
  50. ESCAPE: 27,
  51. HOME: 36,
  52. LEFT: 37,
  53. PAGE_DOWN: 34,
  54. PAGE_UP: 33,
  55. PERIOD: 190,
  56. RIGHT: 39,
  57. SPACE: 32,
  58. TAB: 9,
  59. UP: 38
  60. }
  61. });
  62. // plugins
  63. $.fn.extend({
  64. focus: (function( orig ) {
  65. return function( delay, fn ) {
  66. return typeof delay === "number" ?
  67. this.each(function() {
  68. var elem = this;
  69. setTimeout(function() {
  70. $( elem ).focus();
  71. if ( fn ) {
  72. fn.call( elem );
  73. }
  74. }, delay );
  75. }) :
  76. orig.apply( this, arguments );
  77. };
  78. })( $.fn.focus ),
  79. scrollParent: function() {
  80. var scrollParent;
  81. if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  82. scrollParent = this.parents().filter(function() {
  83. return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  84. }).eq(0);
  85. } else {
  86. scrollParent = this.parents().filter(function() {
  87. return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  88. }).eq(0);
  89. }
  90. return ( /fixed/ ).test( this.css( "position") ) || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  91. },
  92. uniqueId: function() {
  93. return this.each(function() {
  94. if ( !this.id ) {
  95. this.id = "ui-id-" + (++uuid);
  96. }
  97. });
  98. },
  99. removeUniqueId: function() {
  100. return this.each(function() {
  101. if ( runiqueId.test( this.id ) ) {
  102. $( this ).removeAttr( "id" );
  103. }
  104. });
  105. }
  106. });
  107. // selectors
  108. function focusable( element, isTabIndexNotNaN ) {
  109. var map, mapName, img,
  110. nodeName = element.nodeName.toLowerCase();
  111. if ( "area" === nodeName ) {
  112. map = element.parentNode;
  113. mapName = map.name;
  114. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  115. return false;
  116. }
  117. img = $( "img[usemap=#" + mapName + "]" )[0];
  118. return !!img && visible( img );
  119. }
  120. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  121. !element.disabled :
  122. "a" === nodeName ?
  123. element.href || isTabIndexNotNaN :
  124. isTabIndexNotNaN) &&
  125. // the element and all of its ancestors must be visible
  126. visible( element );
  127. }
  128. function visible( element ) {
  129. return $.expr.filters.visible( element ) &&
  130. !$( element ).parents().addBack().filter(function() {
  131. return $.css( this, "visibility" ) === "hidden";
  132. }).length;
  133. }
  134. $.extend( $.expr[ ":" ], {
  135. data: $.expr.createPseudo ?
  136. $.expr.createPseudo(function( dataName ) {
  137. return function( elem ) {
  138. return !!$.data( elem, dataName );
  139. };
  140. }) :
  141. // support: jQuery <1.8
  142. function( elem, i, match ) {
  143. return !!$.data( elem, match[ 3 ] );
  144. },
  145. focusable: function( element ) {
  146. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  147. },
  148. tabbable: function( element ) {
  149. var tabIndex = $.attr( element, "tabindex" ),
  150. isTabIndexNaN = isNaN( tabIndex );
  151. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  152. }
  153. });
  154. // support: jQuery <1.8
  155. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  156. $.each( [ "Width", "Height" ], function( i, name ) {
  157. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  158. type = name.toLowerCase(),
  159. orig = {
  160. innerWidth: $.fn.innerWidth,
  161. innerHeight: $.fn.innerHeight,
  162. outerWidth: $.fn.outerWidth,
  163. outerHeight: $.fn.outerHeight
  164. };
  165. function reduce( elem, size, border, margin ) {
  166. $.each( side, function() {
  167. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  168. if ( border ) {
  169. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  170. }
  171. if ( margin ) {
  172. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  173. }
  174. });
  175. return size;
  176. }
  177. $.fn[ "inner" + name ] = function( size ) {
  178. if ( size === undefined ) {
  179. return orig[ "inner" + name ].call( this );
  180. }
  181. return this.each(function() {
  182. $( this ).css( type, reduce( this, size ) + "px" );
  183. });
  184. };
  185. $.fn[ "outer" + name] = function( size, margin ) {
  186. if ( typeof size !== "number" ) {
  187. return orig[ "outer" + name ].call( this, size );
  188. }
  189. return this.each(function() {
  190. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  191. });
  192. };
  193. });
  194. }
  195. // support: jQuery <1.8
  196. if ( !$.fn.addBack ) {
  197. $.fn.addBack = function( selector ) {
  198. return this.add( selector == null ?
  199. this.prevObject : this.prevObject.filter( selector )
  200. );
  201. };
  202. }
  203. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  204. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  205. $.fn.removeData = (function( removeData ) {
  206. return function( key ) {
  207. if ( arguments.length ) {
  208. return removeData.call( this, $.camelCase( key ) );
  209. } else {
  210. return removeData.call( this );
  211. }
  212. };
  213. })( $.fn.removeData );
  214. }
  215. // deprecated
  216. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  217. $.support.selectstart = "onselectstart" in document.createElement( "div" );
  218. $.fn.extend({
  219. disableSelection: function() {
  220. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  221. ".ui-disableSelection", function( event ) {
  222. event.preventDefault();
  223. });
  224. },
  225. enableSelection: function() {
  226. return this.unbind( ".ui-disableSelection" );
  227. },
  228. zIndex: function( zIndex ) {
  229. if ( zIndex !== undefined ) {
  230. return this.css( "zIndex", zIndex );
  231. }
  232. if ( this.length ) {
  233. var elem = $( this[ 0 ] ), position, value;
  234. while ( elem.length && elem[ 0 ] !== document ) {
  235. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  236. // This makes behavior of this function consistent across browsers
  237. // WebKit always returns auto if the element is positioned
  238. position = elem.css( "position" );
  239. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  240. // IE returns 0 when zIndex is not specified
  241. // other browsers return a string
  242. // we ignore the case of nested elements with an explicit value of 0
  243. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  244. value = parseInt( elem.css( "zIndex" ), 10 );
  245. if ( !isNaN( value ) && value !== 0 ) {
  246. return value;
  247. }
  248. }
  249. elem = elem.parent();
  250. }
  251. }
  252. return 0;
  253. }
  254. });
  255. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  256. $.ui.plugin = {
  257. add: function( module, option, set ) {
  258. var i,
  259. proto = $.ui[ module ].prototype;
  260. for ( i in set ) {
  261. proto.plugins[ i ] = proto.plugins[ i ] || [];
  262. proto.plugins[ i ].push( [ option, set[ i ] ] );
  263. }
  264. },
  265. call: function( instance, name, args, allowDisconnected ) {
  266. var i,
  267. set = instance.plugins[ name ];
  268. if ( !set ) {
  269. return;
  270. }
  271. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  272. return;
  273. }
  274. for ( i = 0; i < set.length; i++ ) {
  275. if ( instance.options[ set[ i ][ 0 ] ] ) {
  276. set[ i ][ 1 ].apply( instance.element, args );
  277. }
  278. }
  279. }
  280. };
  281. })( jQuery );
  282. (function( $, window, undefined ) {
  283. // Subtract the height of external toolbars from the page height, if the page does not have
  284. // internal toolbars of the same type. We take care to use the widget options if we find a
  285. // widget instance and the element's data-attributes otherwise.
  286. var compensateToolbars = function( page, desiredHeight ) {
  287. var pageParent = page.parent(),
  288. toolbarsAffectingHeight = [],
  289. // We use this function to filter fixed toolbars with option updatePagePadding set to
  290. // true (which is the default) from our height subtraction, because fixed toolbars with
  291. // option updatePagePadding set to true compensate for their presence by adding padding
  292. // to the active page. We want to avoid double-counting by also subtracting their
  293. // height from the desired page height.
  294. noPadders = function() {
  295. var theElement = $( this ),
  296. widgetOptions = $.mobile.toolbar && theElement.data( "mobile-toolbar" ) ?
  297. theElement.toolbar( "option" ) : {
  298. position: theElement.attr( "data-" + $.mobile.ns + "position" ),
  299. updatePagePadding: ( theElement.attr( "data-" + $.mobile.ns +
  300. "update-page-padding" ) !== false )
  301. };
  302. return !( widgetOptions.position === "fixed" &&
  303. widgetOptions.updatePagePadding === true );
  304. },
  305. externalHeaders = pageParent.children( ":jqmData(role='header')" ).filter( noPadders ),
  306. internalHeaders = page.children( ":jqmData(role='header')" ),
  307. externalFooters = pageParent.children( ":jqmData(role='footer')" ).filter( noPadders ),
  308. internalFooters = page.children( ":jqmData(role='footer')" );
  309. // If we have no internal headers, but we do have external headers, then their height
  310. // reduces the page height
  311. if ( internalHeaders.length === 0 && externalHeaders.length > 0 ) {
  312. toolbarsAffectingHeight = toolbarsAffectingHeight.concat( externalHeaders.toArray() );
  313. }
  314. // If we have no internal footers, but we do have external footers, then their height
  315. // reduces the page height
  316. if ( internalFooters.length === 0 && externalFooters.length > 0 ) {
  317. toolbarsAffectingHeight = toolbarsAffectingHeight.concat( externalFooters.toArray() );
  318. }
  319. $.each( toolbarsAffectingHeight, function( index, value ) {
  320. desiredHeight -= $( value ).outerHeight();
  321. });
  322. // Height must be at least zero
  323. return Math.max( 0, desiredHeight );
  324. };
  325. $.extend( $.mobile, {
  326. // define the window and the document objects
  327. window: $( window ),
  328. document: $( document ),
  329. // TODO: Remove and use $.ui.keyCode directly
  330. keyCode: $.ui.keyCode,
  331. // Place to store various widget extensions
  332. behaviors: {},
  333. // Scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value
  334. silentScroll: function( ypos ) {
  335. if ( $.type( ypos ) !== "number" ) {
  336. ypos = $.mobile.defaultHomeScroll;
  337. }
  338. // prevent scrollstart and scrollstop events
  339. $.event.special.scrollstart.enabled = false;
  340. setTimeout(function() {
  341. window.scrollTo( 0, ypos );
  342. $.mobile.document.trigger( "silentscroll", { x: 0, y: ypos });
  343. }, 20 );
  344. setTimeout(function() {
  345. $.event.special.scrollstart.enabled = true;
  346. }, 150 );
  347. },
  348. getClosestBaseUrl: function( ele ) {
  349. // Find the closest page and extract out its url.
  350. var url = $( ele ).closest( ".ui-page" ).jqmData( "url" ),
  351. base = $.mobile.path.documentBase.hrefNoHash;
  352. if ( !$.mobile.dynamicBaseEnabled || !url || !$.mobile.path.isPath( url ) ) {
  353. url = base;
  354. }
  355. return $.mobile.path.makeUrlAbsolute( url, base );
  356. },
  357. removeActiveLinkClass: function( forceRemoval ) {
  358. if ( !!$.mobile.activeClickedLink &&
  359. ( !$.mobile.activeClickedLink.closest( "." + $.mobile.activePageClass ).length ||
  360. forceRemoval ) ) {
  361. $.mobile.activeClickedLink.removeClass( $.mobile.activeBtnClass );
  362. }
  363. $.mobile.activeClickedLink = null;
  364. },
  365. // DEPRECATED in 1.4
  366. // Find the closest parent with a theme class on it. Note that
  367. // we are not using $.fn.closest() on purpose here because this
  368. // method gets called quite a bit and we need it to be as fast
  369. // as possible.
  370. getInheritedTheme: function( el, defaultTheme ) {
  371. var e = el[ 0 ],
  372. ltr = "",
  373. re = /ui-(bar|body|overlay)-([a-z])\b/,
  374. c, m;
  375. while ( e ) {
  376. c = e.className || "";
  377. if ( c && ( m = re.exec( c ) ) && ( ltr = m[ 2 ] ) ) {
  378. // We found a parent with a theme class
  379. // on it so bail from this loop.
  380. break;
  381. }
  382. e = e.parentNode;
  383. }
  384. // Return the theme letter we found, if none, return the
  385. // specified default.
  386. return ltr || defaultTheme || "a";
  387. },
  388. enhanceable: function( elements ) {
  389. return this.haveParents( elements, "enhance" );
  390. },
  391. hijackable: function( elements ) {
  392. return this.haveParents( elements, "ajax" );
  393. },
  394. haveParents: function( elements, attr ) {
  395. if ( !$.mobile.ignoreContentEnabled ) {
  396. return elements;
  397. }
  398. var count = elements.length,
  399. $newSet = $(),
  400. e, $element, excluded,
  401. i, c;
  402. for ( i = 0; i < count; i++ ) {
  403. $element = elements.eq( i );
  404. excluded = false;
  405. e = elements[ i ];
  406. while ( e ) {
  407. c = e.getAttribute ? e.getAttribute( "data-" + $.mobile.ns + attr ) : "";
  408. if ( c === "false" ) {
  409. excluded = true;
  410. break;
  411. }
  412. e = e.parentNode;
  413. }
  414. if ( !excluded ) {
  415. $newSet = $newSet.add( $element );
  416. }
  417. }
  418. return $newSet;
  419. },
  420. getScreenHeight: function() {
  421. // Native innerHeight returns more accurate value for this across platforms,
  422. // jQuery version is here as a normalized fallback for platforms like Symbian
  423. return window.innerHeight || $.mobile.window.height();
  424. },
  425. //simply set the active page's minimum height to screen height, depending on orientation
  426. resetActivePageHeight: function( height ) {
  427. var page = $( "." + $.mobile.activePageClass ),
  428. pageHeight = page.height(),
  429. pageOuterHeight = page.outerHeight( true );
  430. height = compensateToolbars( page,
  431. ( typeof height === "number" ) ? height : $.mobile.getScreenHeight() );
  432. // Remove any previous min-height setting
  433. page.css( "min-height", "" );
  434. // Set the minimum height only if the height as determined by CSS is insufficient
  435. if ( page.height() < height ) {
  436. page.css( "min-height", height - ( pageOuterHeight - pageHeight ) );
  437. }
  438. },
  439. loading: function() {
  440. // If this is the first call to this function, instantiate a loader widget
  441. var loader = this.loading._widget || $( $.mobile.loader.prototype.defaultHtml ).loader(),
  442. // Call the appropriate method on the loader
  443. returnValue = loader.loader.apply( loader, arguments );
  444. // Make sure the loader is retained for future calls to this function.
  445. this.loading._widget = loader;
  446. return returnValue;
  447. }
  448. });
  449. $.addDependents = function( elem, newDependents ) {
  450. var $elem = $( elem ),
  451. dependents = $elem.jqmData( "dependents" ) || $();
  452. $elem.jqmData( "dependents", $( dependents ).add( newDependents ) );
  453. };
  454. // plugins
  455. $.fn.extend({
  456. removeWithDependents: function() {
  457. $.removeWithDependents( this );
  458. },
  459. // Enhance child elements
  460. enhanceWithin: function() {
  461. var index,
  462. widgetElements = {},
  463. keepNative = $.mobile.page.prototype.keepNativeSelector(),
  464. that = this;
  465. // Add no js class to elements
  466. if ( $.mobile.nojs ) {
  467. $.mobile.nojs( this );
  468. }
  469. // Bind links for ajax nav
  470. if ( $.mobile.links ) {
  471. $.mobile.links( this );
  472. }
  473. // Degrade inputs for styleing
  474. if ( $.mobile.degradeInputsWithin ) {
  475. $.mobile.degradeInputsWithin( this );
  476. }
  477. // Run buttonmarkup
  478. if ( $.fn.buttonMarkup ) {
  479. this.find( $.fn.buttonMarkup.initSelector ).not( keepNative )
  480. .jqmEnhanceable().buttonMarkup();
  481. }
  482. // Add classes for fieldContain
  483. if ( $.fn.fieldcontain ) {
  484. this.find( ":jqmData(role='fieldcontain')" ).not( keepNative )
  485. .jqmEnhanceable().fieldcontain();
  486. }
  487. // Enhance widgets
  488. $.each( $.mobile.widgets, function( name, constructor ) {
  489. // If initSelector not false find elements
  490. if ( constructor.initSelector ) {
  491. // Filter elements that should not be enhanced based on parents
  492. var elements = $.mobile.enhanceable( that.find( constructor.initSelector ) );
  493. // If any matching elements remain filter ones with keepNativeSelector
  494. if ( elements.length > 0 ) {
  495. // $.mobile.page.prototype.keepNativeSelector is deprecated this is just for backcompat
  496. // Switch to $.mobile.keepNative in 1.5 which is just a value not a function
  497. elements = elements.not( keepNative );
  498. }
  499. // Enhance whatever is left
  500. if ( elements.length > 0 ) {
  501. widgetElements[ constructor.prototype.widgetName ] = elements;
  502. }
  503. }
  504. });
  505. for ( index in widgetElements ) {
  506. widgetElements[ index ][ index ]();
  507. }
  508. return this;
  509. },
  510. addDependents: function( newDependents ) {
  511. $.addDependents( this, newDependents );
  512. },
  513. // note that this helper doesn't attempt to handle the callback
  514. // or setting of an html element's text, its only purpose is
  515. // to return the html encoded version of the text in all cases. (thus the name)
  516. getEncodedText: function() {
  517. return $( "<a>" ).text( this.text() ).html();
  518. },
  519. // fluent helper function for the mobile namespaced equivalent
  520. jqmEnhanceable: function() {
  521. return $.mobile.enhanceable( this );
  522. },
  523. jqmHijackable: function() {
  524. return $.mobile.hijackable( this );
  525. }
  526. });
  527. $.removeWithDependents = function( nativeElement ) {
  528. var element = $( nativeElement );
  529. ( element.jqmData( "dependents" ) || $() ).remove();
  530. element.remove();
  531. };
  532. $.addDependents = function( nativeElement, newDependents ) {
  533. var element = $( nativeElement ),
  534. dependents = element.jqmData( "dependents" ) || $();
  535. element.jqmData( "dependents", $( dependents ).add( newDependents ) );
  536. };
  537. $.find.matches = function( expr, set ) {
  538. return $.find( expr, null, null, set );
  539. };
  540. $.find.matchesSelector = function( node, expr ) {
  541. return $.find( expr, null, null, [ node ] ).length > 0;
  542. };
  543. })( jQuery, this );
  544. (function( $, window, undefined ) {
  545. $.extend( $.mobile, {
  546. // Version of the jQuery Mobile Framework
  547. version: "1.4.5",
  548. // Deprecated and no longer used in 1.4 remove in 1.5
  549. // Define the url parameter used for referencing widget-generated sub-pages.
  550. // Translates to example.html&ui-page=subpageIdentifier
  551. // hash segment before &ui-page= is used to make Ajax request
  552. subPageUrlKey: "ui-page",
  553. hideUrlBar: true,
  554. // Keepnative Selector
  555. keepNative: ":jqmData(role='none'), :jqmData(role='nojs')",
  556. // Deprecated in 1.4 remove in 1.5
  557. // Class assigned to page currently in view, and during transitions
  558. activePageClass: "ui-page-active",
  559. // Deprecated in 1.4 remove in 1.5
  560. // Class used for "active" button state, from CSS framework
  561. activeBtnClass: "ui-btn-active",
  562. // Deprecated in 1.4 remove in 1.5
  563. // Class used for "focus" form element state, from CSS framework
  564. focusClass: "ui-focus",
  565. // Automatically handle clicks and form submissions through Ajax, when same-domain
  566. ajaxEnabled: true,
  567. // Automatically load and show pages based on location.hash
  568. hashListeningEnabled: true,
  569. // disable to prevent jquery from bothering with links
  570. linkBindingEnabled: true,
  571. // Set default page transition - 'none' for no transitions
  572. defaultPageTransition: "fade",
  573. // Set maximum window width for transitions to apply - 'false' for no limit
  574. maxTransitionWidth: false,
  575. // Minimum scroll distance that will be remembered when returning to a page
  576. // Deprecated remove in 1.5
  577. minScrollBack: 0,
  578. // Set default dialog transition - 'none' for no transitions
  579. defaultDialogTransition: "pop",
  580. // Error response message - appears when an Ajax page request fails
  581. pageLoadErrorMessage: "Error Loading Page",
  582. // For error messages, which theme does the box use?
  583. pageLoadErrorMessageTheme: "a",
  584. // replace calls to window.history.back with phonegaps navigation helper
  585. // where it is provided on the window object
  586. phonegapNavigationEnabled: false,
  587. //automatically initialize the DOM when it's ready
  588. autoInitializePage: true,
  589. pushStateEnabled: true,
  590. // allows users to opt in to ignoring content by marking a parent element as
  591. // data-ignored
  592. ignoreContentEnabled: false,
  593. buttonMarkup: {
  594. hoverDelay: 200
  595. },
  596. // disable the alteration of the dynamic base tag or links in the case
  597. // that a dynamic base tag isn't supported
  598. dynamicBaseEnabled: true,
  599. // default the property to remove dependency on assignment in init module
  600. pageContainer: $(),
  601. //enable cross-domain page support
  602. allowCrossDomainPages: false,
  603. dialogHashKey: "&ui-state=dialog"
  604. });
  605. })( jQuery, this );
  606. /*!
  607. * jQuery UI Widget c0ab71056b936627e8a7821f03c044aec6280a40
  608. * http://jqueryui.com
  609. *
  610. * Copyright 2013 jQuery Foundation and other contributors
  611. * Released under the MIT license.
  612. * http://jquery.org/license
  613. *
  614. * http://api.jqueryui.com/jQuery.widget/
  615. */
  616. (function( $, undefined ) {
  617. var uuid = 0,
  618. slice = Array.prototype.slice,
  619. _cleanData = $.cleanData;
  620. $.cleanData = function( elems ) {
  621. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  622. try {
  623. $( elem ).triggerHandler( "remove" );
  624. // http://bugs.jquery.com/ticket/8235
  625. } catch( e ) {}
  626. }
  627. _cleanData( elems );
  628. };
  629. $.widget = function( name, base, prototype ) {
  630. var fullName, existingConstructor, constructor, basePrototype,
  631. // proxiedPrototype allows the provided prototype to remain unmodified
  632. // so that it can be used as a mixin for multiple widgets (#8876)
  633. proxiedPrototype = {},
  634. namespace = name.split( "." )[ 0 ];
  635. name = name.split( "." )[ 1 ];
  636. fullName = namespace + "-" + name;
  637. if ( !prototype ) {
  638. prototype = base;
  639. base = $.Widget;
  640. }
  641. // create selector for plugin
  642. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  643. return !!$.data( elem, fullName );
  644. };
  645. $[ namespace ] = $[ namespace ] || {};
  646. existingConstructor = $[ namespace ][ name ];
  647. constructor = $[ namespace ][ name ] = function( options, element ) {
  648. // allow instantiation without "new" keyword
  649. if ( !this._createWidget ) {
  650. return new constructor( options, element );
  651. }
  652. // allow instantiation without initializing for simple inheritance
  653. // must use "new" keyword (the code above always passes args)
  654. if ( arguments.length ) {
  655. this._createWidget( options, element );
  656. }
  657. };
  658. // extend with the existing constructor to carry over any static properties
  659. $.extend( constructor, existingConstructor, {
  660. version: prototype.version,
  661. // copy the object used to create the prototype in case we need to
  662. // redefine the widget later
  663. _proto: $.extend( {}, prototype ),
  664. // track widgets that inherit from this widget in case this widget is
  665. // redefined after a widget inherits from it
  666. _childConstructors: []
  667. });
  668. basePrototype = new base();
  669. // we need to make the options hash a property directly on the new instance
  670. // otherwise we'll modify the options hash on the prototype that we're
  671. // inheriting from
  672. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  673. $.each( prototype, function( prop, value ) {
  674. if ( !$.isFunction( value ) ) {
  675. proxiedPrototype[ prop ] = value;
  676. return;
  677. }
  678. proxiedPrototype[ prop ] = (function() {
  679. var _super = function() {
  680. return base.prototype[ prop ].apply( this, arguments );
  681. },
  682. _superApply = function( args ) {
  683. return base.prototype[ prop ].apply( this, args );
  684. };
  685. return function() {
  686. var __super = this._super,
  687. __superApply = this._superApply,
  688. returnValue;
  689. this._super = _super;
  690. this._superApply = _superApply;
  691. returnValue = value.apply( this, arguments );
  692. this._super = __super;
  693. this._superApply = __superApply;
  694. return returnValue;
  695. };
  696. })();
  697. });
  698. constructor.prototype = $.widget.extend( basePrototype, {
  699. // TODO: remove support for widgetEventPrefix
  700. // always use the name + a colon as the prefix, e.g., draggable:start
  701. // don't prefix for widgets that aren't DOM-based
  702. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  703. }, proxiedPrototype, {
  704. constructor: constructor,
  705. namespace: namespace,
  706. widgetName: name,
  707. widgetFullName: fullName
  708. });
  709. // If this widget is being redefined then we need to find all widgets that
  710. // are inheriting from it and redefine all of them so that they inherit from
  711. // the new version of this widget. We're essentially trying to replace one
  712. // level in the prototype chain.
  713. if ( existingConstructor ) {
  714. $.each( existingConstructor._childConstructors, function( i, child ) {
  715. var childPrototype = child.prototype;
  716. // redefine the child widget using the same prototype that was
  717. // originally used, but inherit from the new version of the base
  718. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  719. });
  720. // remove the list of existing child constructors from the old constructor
  721. // so the old child constructors can be garbage collected
  722. delete existingConstructor._childConstructors;
  723. } else {
  724. base._childConstructors.push( constructor );
  725. }
  726. $.widget.bridge( name, constructor );
  727. return constructor;
  728. };
  729. $.widget.extend = function( target ) {
  730. var input = slice.call( arguments, 1 ),
  731. inputIndex = 0,
  732. inputLength = input.length,
  733. key,
  734. value;
  735. for ( ; inputIndex < inputLength; inputIndex++ ) {
  736. for ( key in input[ inputIndex ] ) {
  737. value = input[ inputIndex ][ key ];
  738. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  739. // Clone objects
  740. if ( $.isPlainObject( value ) ) {
  741. target[ key ] = $.isPlainObject( target[ key ] ) ?
  742. $.widget.extend( {}, target[ key ], value ) :
  743. // Don't extend strings, arrays, etc. with objects
  744. $.widget.extend( {}, value );
  745. // Copy everything else by reference
  746. } else {
  747. target[ key ] = value;
  748. }
  749. }
  750. }
  751. }
  752. return target;
  753. };
  754. $.widget.bridge = function( name, object ) {
  755. var fullName = object.prototype.widgetFullName || name;
  756. $.fn[ name ] = function( options ) {
  757. var isMethodCall = typeof options === "string",
  758. args = slice.call( arguments, 1 ),
  759. returnValue = this;
  760. // allow multiple hashes to be passed on init
  761. options = !isMethodCall && args.length ?
  762. $.widget.extend.apply( null, [ options ].concat(args) ) :
  763. options;
  764. if ( isMethodCall ) {
  765. this.each(function() {
  766. var methodValue,
  767. instance = $.data( this, fullName );
  768. if ( options === "instance" ) {
  769. returnValue = instance;
  770. return false;
  771. }
  772. if ( !instance ) {
  773. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  774. "attempted to call method '" + options + "'" );
  775. }
  776. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  777. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  778. }
  779. methodValue = instance[ options ].apply( instance, args );
  780. if ( methodValue !== instance && methodValue !== undefined ) {
  781. returnValue = methodValue && methodValue.jquery ?
  782. returnValue.pushStack( methodValue.get() ) :
  783. methodValue;
  784. return false;
  785. }
  786. });
  787. } else {
  788. this.each(function() {
  789. var instance = $.data( this, fullName );
  790. if ( instance ) {
  791. instance.option( options || {} )._init();
  792. } else {
  793. $.data( this, fullName, new object( options, this ) );
  794. }
  795. });
  796. }
  797. return returnValue;
  798. };
  799. };
  800. $.Widget = function( /* options, element */ ) {};
  801. $.Widget._childConstructors = [];
  802. $.Widget.prototype = {
  803. widgetName: "widget",
  804. widgetEventPrefix: "",
  805. defaultElement: "<div>",
  806. options: {
  807. disabled: false,
  808. // callbacks
  809. create: null
  810. },
  811. _createWidget: function( options, element ) {
  812. element = $( element || this.defaultElement || this )[ 0 ];
  813. this.element = $( element );
  814. this.uuid = uuid++;
  815. this.eventNamespace = "." + this.widgetName + this.uuid;
  816. this.options = $.widget.extend( {},
  817. this.options,
  818. this._getCreateOptions(),
  819. options );
  820. this.bindings = $();
  821. this.hoverable = $();
  822. this.focusable = $();
  823. if ( element !== this ) {
  824. $.data( element, this.widgetFullName, this );
  825. this._on( true, this.element, {
  826. remove: function( event ) {
  827. if ( event.target === element ) {
  828. this.destroy();
  829. }
  830. }
  831. });
  832. this.document = $( element.style ?
  833. // element within the document
  834. element.ownerDocument :
  835. // element is window or document
  836. element.document || element );
  837. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  838. }
  839. this._create();
  840. this._trigger( "create", null, this._getCreateEventData() );
  841. this._init();
  842. },
  843. _getCreateOptions: $.noop,
  844. _getCreateEventData: $.noop,
  845. _create: $.noop,
  846. _init: $.noop,
  847. destroy: function() {
  848. this._destroy();
  849. // we can probably remove the unbind calls in 2.0
  850. // all event bindings should go through this._on()
  851. this.element
  852. .unbind( this.eventNamespace )
  853. .removeData( this.widgetFullName )
  854. // support: jquery <1.6.3
  855. // http://bugs.jquery.com/ticket/9413
  856. .removeData( $.camelCase( this.widgetFullName ) );
  857. this.widget()
  858. .unbind( this.eventNamespace )
  859. .removeAttr( "aria-disabled" )
  860. .removeClass(
  861. this.widgetFullName + "-disabled " +
  862. "ui-state-disabled" );
  863. // clean up events and states
  864. this.bindings.unbind( this.eventNamespace );
  865. this.hoverable.removeClass( "ui-state-hover" );
  866. this.focusable.removeClass( "ui-state-focus" );
  867. },
  868. _destroy: $.noop,
  869. widget: function() {
  870. return this.element;
  871. },
  872. option: function( key, value ) {
  873. var options = key,
  874. parts,
  875. curOption,
  876. i;
  877. if ( arguments.length === 0 ) {
  878. // don't return a reference to the internal hash
  879. return $.widget.extend( {}, this.options );
  880. }
  881. if ( typeof key === "string" ) {
  882. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  883. options = {};
  884. parts = key.split( "." );
  885. key = parts.shift();
  886. if ( parts.length ) {
  887. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  888. for ( i = 0; i < parts.length - 1; i++ ) {
  889. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  890. curOption = curOption[ parts[ i ] ];
  891. }
  892. key = parts.pop();
  893. if ( value === undefined ) {
  894. return curOption[ key ] === undefined ? null : curOption[ key ];
  895. }
  896. curOption[ key ] = value;
  897. } else {
  898. if ( value === undefined ) {
  899. return this.options[ key ] === undefined ? null : this.options[ key ];
  900. }
  901. options[ key ] = value;
  902. }
  903. }
  904. this._setOptions( options );
  905. return this;
  906. },
  907. _setOptions: function( options ) {
  908. var key;
  909. for ( key in options ) {
  910. this._setOption( key, options[ key ] );
  911. }
  912. return this;
  913. },
  914. _setOption: function( key, value ) {
  915. this.options[ key ] = value;
  916. if ( key === "disabled" ) {
  917. this.widget()
  918. .toggleClass( this.widgetFullName + "-disabled", !!value );
  919. this.hoverable.removeClass( "ui-state-hover" );
  920. this.focusable.removeClass( "ui-state-focus" );
  921. }
  922. return this;
  923. },
  924. enable: function() {
  925. return this._setOptions({ disabled: false });
  926. },
  927. disable: function() {
  928. return this._setOptions({ disabled: true });
  929. },
  930. _on: function( suppressDisabledCheck, element, handlers ) {
  931. var delegateElement,
  932. instance = this;
  933. // no suppressDisabledCheck flag, shuffle arguments
  934. if ( typeof suppressDisabledCheck !== "boolean" ) {
  935. handlers = element;
  936. element = suppressDisabledCheck;
  937. suppressDisabledCheck = false;
  938. }
  939. // no element argument, shuffle and use this.element
  940. if ( !handlers ) {
  941. handlers = element;
  942. element = this.element;
  943. delegateElement = this.widget();
  944. } else {
  945. // accept selectors, DOM elements
  946. element = delegateElement = $( element );
  947. this.bindings = this.bindings.add( element );
  948. }
  949. $.each( handlers, function( event, handler ) {
  950. function handlerProxy() {
  951. // allow widgets to customize the disabled handling
  952. // - disabled as an array instead of boolean
  953. // - disabled class as method for disabling individual parts
  954. if ( !suppressDisabledCheck &&
  955. ( instance.options.disabled === true ||
  956. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  957. return;
  958. }
  959. return ( typeof handler === "string" ? instance[ handler ] : handler )
  960. .apply( instance, arguments );
  961. }
  962. // copy the guid so direct unbinding works
  963. if ( typeof handler !== "string" ) {
  964. handlerProxy.guid = handler.guid =
  965. handler.guid || handlerProxy.guid || $.guid++;
  966. }
  967. var match = event.match( /^(\w+)\s*(.*)$/ ),
  968. eventName = match[1] + instance.eventNamespace,
  969. selector = match[2];
  970. if ( selector ) {
  971. delegateElement.delegate( selector, eventName, handlerProxy );
  972. } else {
  973. element.bind( eventName, handlerProxy );
  974. }
  975. });
  976. },
  977. _off: function( element, eventName ) {
  978. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  979. element.unbind( eventName ).undelegate( eventName );
  980. },
  981. _delay: function( handler, delay ) {
  982. function handlerProxy() {
  983. return ( typeof handler === "string" ? instance[ handler ] : handler )
  984. .apply( instance, arguments );
  985. }
  986. var instance = this;
  987. return setTimeout( handlerProxy, delay || 0 );
  988. },
  989. _hoverable: function( element ) {
  990. this.hoverable = this.hoverable.add( element );
  991. this._on( element, {
  992. mouseenter: function( event ) {
  993. $( event.currentTarget ).addClass( "ui-state-hover" );
  994. },
  995. mouseleave: function( event ) {
  996. $( event.currentTarget ).removeClass( "ui-state-hover" );
  997. }
  998. });
  999. },
  1000. _focusable: function( element ) {
  1001. this.focusable = this.focusable.add( element );
  1002. this._on( element, {
  1003. focusin: function( event ) {
  1004. $( event.currentTarget ).addClass( "ui-state-focus" );
  1005. },
  1006. focusout: function( event ) {
  1007. $( event.currentTarget ).removeClass( "ui-state-focus" );
  1008. }
  1009. });
  1010. },
  1011. _trigger: function( type, event, data ) {
  1012. var prop, orig,
  1013. callback = this.options[ type ];
  1014. data = data || {};
  1015. event = $.Event( event );
  1016. event.type = ( type === this.widgetEventPrefix ?
  1017. type :
  1018. this.widgetEventPrefix + type ).toLowerCase();
  1019. // the original event may come from any element
  1020. // so we need to reset the target on the new event
  1021. event.target = this.element[ 0 ];
  1022. // copy original event properties over to the new event
  1023. orig = event.originalEvent;
  1024. if ( orig ) {
  1025. for ( prop in orig ) {
  1026. if ( !( prop in event ) ) {
  1027. event[ prop ] = orig[ prop ];
  1028. }
  1029. }
  1030. }
  1031. this.element.trigger( event, data );
  1032. return !( $.isFunction( callback ) &&
  1033. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  1034. event.isDefaultPrevented() );
  1035. }
  1036. };
  1037. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  1038. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  1039. if ( typeof options === "string" ) {
  1040. options = { effect: options };
  1041. }
  1042. var hasOptions,
  1043. effectName = !options ?
  1044. method :
  1045. options === true || typeof options === "number" ?
  1046. defaultEffect :
  1047. options.effect || defaultEffect;
  1048. options = options || {};
  1049. if ( typeof options === "number" ) {
  1050. options = { duration: options };
  1051. }
  1052. hasOptions = !$.isEmptyObject( options );
  1053. options.complete = callback;
  1054. if ( options.delay ) {
  1055. element.delay( options.delay );
  1056. }
  1057. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  1058. element[ method ]( options );
  1059. } else if ( effectName !== method && element[ effectName ] ) {
  1060. element[ effectName ]( options.duration, options.easing, callback );
  1061. } else {
  1062. element.queue(function( next ) {
  1063. $( this )[ method ]();
  1064. if ( callback ) {
  1065. callback.call( element[ 0 ] );
  1066. }
  1067. next();
  1068. });
  1069. }
  1070. };
  1071. });
  1072. })( jQuery );
  1073. (function( $, window, undefined ) {
  1074. var nsNormalizeDict = {},
  1075. oldFind = $.find,
  1076. rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
  1077. jqmDataRE = /:jqmData\(([^)]*)\)/g;
  1078. $.extend( $.mobile, {
  1079. // Namespace used framework-wide for data-attrs. Default is no namespace
  1080. ns: "",
  1081. // Retrieve an attribute from an element and perform some massaging of the value
  1082. getAttribute: function( element, key ) {
  1083. var data;
  1084. element = element.jquery ? element[0] : element;
  1085. if ( element && element.getAttribute ) {
  1086. data = element.getAttribute( "data-" + $.mobile.ns + key );
  1087. }
  1088. // Copied from core's src/data.js:dataAttr()
  1089. // Convert from a string to a proper data type
  1090. try {
  1091. data = data === "true" ? true :
  1092. data === "false" ? false :
  1093. data === "null" ? null :
  1094. // Only convert to a number if it doesn't change the string
  1095. +data + "" === data ? +data :
  1096. rbrace.test( data ) ? JSON.parse( data ) :
  1097. data;
  1098. } catch( err ) {}
  1099. return data;
  1100. },
  1101. // Expose our cache for testing purposes.
  1102. nsNormalizeDict: nsNormalizeDict,
  1103. // Take a data attribute property, prepend the namespace
  1104. // and then camel case the attribute string. Add the result
  1105. // to our nsNormalizeDict so we don't have to do this again.
  1106. nsNormalize: function( prop ) {
  1107. return nsNormalizeDict[ prop ] ||
  1108. ( nsNormalizeDict[ prop ] = $.camelCase( $.mobile.ns + prop ) );
  1109. },
  1110. // Find the closest javascript page element to gather settings data jsperf test
  1111. // http://jsperf.com/single-complex-selector-vs-many-complex-selectors/edit
  1112. // possibly naive, but it shows that the parsing overhead for *just* the page selector vs
  1113. // the page and dialog selector is negligable. This could probably be speed up by
  1114. // doing a similar parent node traversal to the one found in the inherited theme code above
  1115. closestPageData: function( $target ) {
  1116. return $target
  1117. .closest( ":jqmData(role='page'), :jqmData(role='dialog')" )
  1118. .data( "mobile-page" );
  1119. }
  1120. });
  1121. // Mobile version of data and removeData and hasData methods
  1122. // ensures all data is set and retrieved using jQuery Mobile's data namespace
  1123. $.fn.jqmData = function( prop, value ) {
  1124. var result;
  1125. if ( typeof prop !== "undefined" ) {
  1126. if ( prop ) {
  1127. prop = $.mobile.nsNormalize( prop );
  1128. }
  1129. // undefined is permitted as an explicit input for the second param
  1130. // in this case it returns the value and does not set it to undefined
  1131. if ( arguments.length < 2 || value === undefined ) {
  1132. result = this.data( prop );
  1133. } else {
  1134. result = this.data( prop, value );
  1135. }
  1136. }
  1137. return result;
  1138. };
  1139. $.jqmData = function( elem, prop, value ) {
  1140. var result;
  1141. if ( typeof prop !== "undefined" ) {
  1142. result = $.data( elem, prop ? $.mobile.nsNormalize( prop ) : prop, value );
  1143. }
  1144. return result;
  1145. };
  1146. $.fn.jqmRemoveData = function( prop ) {
  1147. return this.removeData( $.mobile.nsNormalize( prop ) );
  1148. };
  1149. $.jqmRemoveData = function( elem, prop ) {
  1150. return $.removeData( elem, $.mobile.nsNormalize( prop ) );
  1151. };
  1152. $.find = function( selector, context, ret, extra ) {
  1153. if ( selector.indexOf( ":jqmData" ) > -1 ) {
  1154. selector = selector.replace( jqmDataRE, "[data-" + ( $.mobile.ns || "" ) + "$1]" );
  1155. }
  1156. return oldFind.call( this, selector, context, ret, extra );
  1157. };
  1158. $.extend( $.find, oldFind );
  1159. })( jQuery, this );
  1160. (function( $, undefined ) {
  1161. var rcapitals = /[A-Z]/g,
  1162. replaceFunction = function( c ) {
  1163. return "-" + c.toLowerCase();
  1164. };
  1165. $.extend( $.Widget.prototype, {
  1166. _getCreateOptions: function() {
  1167. var option, value,
  1168. elem = this.element[ 0 ],
  1169. options = {};
  1170. //
  1171. if ( !$.mobile.getAttribute( elem, "defaults" ) ) {
  1172. for ( option in this.options ) {
  1173. value = $.mobile.getAttribute( elem, option.replace( rcapitals, replaceFunction ) );
  1174. if ( value != null ) {
  1175. options[ option ] = value;
  1176. }
  1177. }
  1178. }
  1179. return options;
  1180. }
  1181. });
  1182. //TODO: Remove in 1.5 for backcompat only
  1183. $.mobile.widget = $.Widget;
  1184. })( jQuery );
  1185. (function( $ ) {
  1186. // TODO move loader class down into the widget settings
  1187. var loaderClass = "ui-loader", $html = $( "html" );
  1188. $.widget( "mobile.loader", {
  1189. // NOTE if the global config settings are defined they will override these
  1190. // options
  1191. options: {
  1192. // the theme for the loading message
  1193. theme: "a",
  1194. // whether the text in the loading message is shown
  1195. textVisible: false,
  1196. // custom html for the inner content of the loading message
  1197. html: "",
  1198. // the text to be displayed when the popup is shown
  1199. text: "loading"
  1200. },
  1201. defaultHtml: "<div class='" + loaderClass + "'>" +
  1202. "<span class='ui-icon-loading'></span>" +
  1203. "<h1></h1>" +
  1204. "</div>",
  1205. // For non-fixed supportin browsers. Position at y center (if scrollTop supported), above the activeBtn (if defined), or just 100px from top
  1206. fakeFixLoader: function() {
  1207. var activeBtn = $( "." + $.mobile.activeBtnClass ).first();
  1208. this.element
  1209. .css({
  1210. top: $.support.scrollTop && this.window.scrollTop() + this.window.height() / 2 ||
  1211. activeBtn.length && activeBtn.offset().top || 100
  1212. });
  1213. },
  1214. // check position of loader to see if it appears to be "fixed" to center
  1215. // if not, use abs positioning
  1216. checkLoaderPosition: function() {
  1217. var offset = this.element.offset(),
  1218. scrollTop = this.window.scrollTop(),
  1219. screenHeight = $.mobile.getScreenHeight();
  1220. if ( offset.top < scrollTop || ( offset.top - scrollTop ) > screenHeight ) {
  1221. this.element.addClass( "ui-loader-fakefix" );
  1222. this.fakeFixLoader();
  1223. this.window
  1224. .unbind( "scroll", this.checkLoaderPosition )
  1225. .bind( "scroll", $.proxy( this.fakeFixLoader, this ) );
  1226. }
  1227. },
  1228. resetHtml: function() {
  1229. this.element.html( $( this.defaultHtml ).html() );
  1230. },
  1231. // Turn on/off page loading message. Theme doubles as an object argument
  1232. // with the following shape: { theme: '', text: '', html: '', textVisible: '' }
  1233. // NOTE that the $.mobile.loading* settings and params past the first are deprecated
  1234. // TODO sweet jesus we need to break some of this out
  1235. show: function( theme, msgText, textonly ) {
  1236. var textVisible, message, loadSettings;
  1237. this.resetHtml();
  1238. // use the prototype options so that people can set them globally at
  1239. // mobile init. Consistency, it's what's for dinner
  1240. if ( $.type( theme ) === "object" ) {
  1241. loadSettings = $.extend( {}, this.options, theme );
  1242. theme = loadSettings.theme;
  1243. } else {
  1244. loadSettings = this.options;
  1245. // here we prefer the theme value passed as a string argument, then
  1246. // we prefer the global option because we can't use undefined default
  1247. // prototype options, then the prototype option
  1248. theme = theme || loadSettings.theme;
  1249. }
  1250. // set the message text, prefer the param, then the settings object
  1251. // then loading message
  1252. message = msgText || ( loadSettings.text === false ? "" : loadSettings.text );
  1253. // prepare the dom
  1254. $html.addClass( "ui-loading" );
  1255. textVisible = loadSettings.textVisible;
  1256. // add the proper css given the options (theme, text, etc)
  1257. // Force text visibility if the second argument was supplied, or
  1258. // if the text was explicitly set in the object args
  1259. this.element.attr("class", loaderClass +
  1260. " ui-corner-all ui-body-" + theme +
  1261. " ui-loader-" + ( textVisible || msgText || theme.text ? "verbose" : "default" ) +
  1262. ( loadSettings.textonly || textonly ? " ui-loader-textonly" : "" ) );
  1263. // TODO verify that jquery.fn.html is ok to use in both cases here
  1264. // this might be overly defensive in preventing unknowing xss
  1265. // if the html attribute is defined on the loading settings, use that
  1266. // otherwise use the fallbacks from above
  1267. if ( loadSettings.html ) {
  1268. this.element.html( loadSettings.html );
  1269. } else {
  1270. this.element.find( "h1" ).text( message );
  1271. }
  1272. // If the pagecontainer widget has been defined we may use the :mobile-pagecontainer
  1273. // and attach to the element on which the pagecontainer widget has been defined. If not,
  1274. // we attach to the body.
  1275. this.element.appendTo( $.mobile.pagecontainer ?
  1276. $( ":mobile-pagecontainer" ) : $( "body" ) );
  1277. // check that the loader is visible
  1278. this.checkLoaderPosition();
  1279. // on scroll check the loader position
  1280. this.window.bind( "scroll", $.proxy( this.checkLoaderPosition, this ) );
  1281. },
  1282. hide: function() {
  1283. $html.removeClass( "ui-loading" );
  1284. if ( this.options.text ) {
  1285. this.element.removeClass( "ui-loader-fakefix" );
  1286. }
  1287. this.window.unbind( "scroll", this.fakeFixLoader );
  1288. this.window.unbind( "scroll", this.checkLoaderPosition );
  1289. }
  1290. });
  1291. })(jQuery, this);
  1292. /*!
  1293. * jQuery hashchange event - v1.3 - 7/21/2010
  1294. * http://benalman.com/projects/jquery-hashchange-plugin/
  1295. *
  1296. * Copyright (c) 2010 "Cowboy" Ben Alman
  1297. * Dual licensed under the MIT and GPL licenses.
  1298. * http://benalman.com/about/license/
  1299. */
  1300. // Script: jQuery hashchange event
  1301. //
  1302. // *Version: 1.3, Last updated: 7/21/2010*
  1303. //
  1304. // Project Home - http://benalman.com/projects/jquery-hashchange-plugin/
  1305. // GitHub - http://github.com/cowboy/jquery-hashchange/
  1306. // Source - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.js
  1307. // (Minified) - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.min.js (0.8kb gzipped)
  1308. //
  1309. // About: License
  1310. //
  1311. // Copyright (c) 2010 "Cowboy" Ben Alman,
  1312. // Dual licensed under the MIT and GPL licenses.
  1313. // http://benalman.com/about/license/
  1314. //
  1315. // About: Examples
  1316. //
  1317. // These working examples, complete with fully commented code, illustrate a few
  1318. // ways in which this plugin can be used.
  1319. //
  1320. // hashchange event - http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/
  1321. // document.domain - http://benalman.com/code/projects/jquery-hashchange/examples/document_domain/
  1322. //
  1323. // About: Support and Testing
  1324. //
  1325. // Information about what version or versions of jQuery this plugin has been
  1326. // tested with, what browsers it has been tested in, and where the unit tests
  1327. // reside (so you can test it yourself).
  1328. //
  1329. // jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2
  1330. // Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5,
  1331. // Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5.
  1332. // Unit Tests - http://benalman.com/code/projects/jquery-hashchange/unit/
  1333. //
  1334. // About: Known issues
  1335. //
  1336. // While this jQuery hashchange event implementation is quite stable and
  1337. // robust, there are a few unfortunate browser bugs surrounding expected
  1338. // hashchange event-based behaviors, independent of any JavaScript
  1339. // window.onhashchange abstraction. See the following examples for more
  1340. // information:
  1341. //
  1342. // Chrome: Back Button - http://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/
  1343. // Firefox: Remote XMLHttpRequest - http://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/
  1344. // WebKit: Back Button in an Iframe - http://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/
  1345. // Safari: Back Button from a different domain - http://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/
  1346. //
  1347. // Also note that should a browser natively support the window.onhashchange
  1348. // event, but not report that it does, the fallback polling loop will be used.
  1349. //
  1350. // About: Release History
  1351. //
  1352. // 1.3 - (7/21/2010) Reorganized IE6/7 Iframe code to make it more
  1353. // "removable" for mobile-only development. Added IE6/7 document.title
  1354. // support. Attempted to make Iframe as hidden as possible by using
  1355. // techniques from http://www.paciellogroup.com/blog/?p=604. Added
  1356. // support for the "shortcut" format $(window).hashchange( fn ) and
  1357. // $(window).hashchange() like jQuery provides for built-in events.
  1358. // Renamed jQuery.hashchangeDelay to <jQuery.fn.hashchange.delay> and
  1359. // lowered its default value to 50. Added <jQuery.fn.hashchange.domain>
  1360. // and <jQuery.fn.hashchange.src> properties plus document-domain.html
  1361. // file to address access denied issues when setting document.domain in
  1362. // IE6/7.
  1363. // 1.2 - (2/11/2010) Fixed a bug where coming back to a page using this plugin
  1364. // from a page on another domain would cause an error in Safari 4. Also,
  1365. // IE6/7 Iframe is now inserted after the body (this actually works),
  1366. // which prevents the page from scrolling when the event is first bound.
  1367. // Event can also now be bound before DOM ready, but it won't be usable
  1368. // before then in IE6/7.
  1369. // 1.1 - (1/21/2010) Incorporated document.documentMode test to fix IE8 bug
  1370. // where browser version is incorrectly reported as 8.0, despite
  1371. // inclusion of the X-UA-Compatible IE=EmulateIE7 meta tag.
  1372. // 1.0 - (1/9/2010) Initial Release. Broke out the jQuery BBQ event.special
  1373. // window.onhashchange functionality into a separate plugin for users
  1374. // who want just the basic event & back button support, without all the
  1375. // extra awesomeness that BBQ provides. This plugin will be included as
  1376. // part of jQuery BBQ, but also be available separately.
  1377. (function($,window,undefined){
  1378. '$:nomunge'; // Used by YUI compressor.
  1379. // Reused string.
  1380. var str_hashchange = 'hashchange',
  1381. // Method / object references.
  1382. doc = document,
  1383. fake_onhashchange,
  1384. special = $.event.special,
  1385. // Does the browser support window.onhashchange? Note that IE8 running in
  1386. // IE7 compatibility mode reports true for 'onhashchange' in window, even
  1387. // though the event isn't supported, so also test document.documentMode.
  1388. doc_mode = doc.documentMode,
  1389. supports_onhashchange = 'on' + str_hashchange in window && ( doc_mode === undefined || doc_mode > 7 );
  1390. // Get location.hash (or what you'd expect location.hash to be) sans any
  1391. // leading #. Thanks for making this necessary, Firefox!
  1392. function get_fragment( url ) {
  1393. url = url || location.href;
  1394. return '#' + url.replace( /^[^#]*#?(.*)$/, '$1' );
  1395. };
  1396. // Method: jQuery.fn.hashchange
  1397. //
  1398. // Bind a handler to the window.onhashchange event or trigger all bound
  1399. // window.onhashchange event handlers. This behavior is consistent with
  1400. // jQuery's built-in event handlers.
  1401. //
  1402. // Usage:
  1403. //
  1404. // > jQuery(window).hashchange( [ handler ] );
  1405. //
  1406. // Arguments:
  1407. //
  1408. // handler - (Function) Optional handler to be bound to the hashchange
  1409. // event. This is a "shortcut" for the more verbose form:
  1410. // jQuery(window).bind( 'hashchange', handler ). If handler is omitted,
  1411. // all bound window.onhashchange event handlers will be triggered. This
  1412. // is a shortcut for the more verbose
  1413. // jQuery(window).trigger( 'hashchange' ). These forms are described in
  1414. // the <hashchange event> section.
  1415. //
  1416. // Returns:
  1417. //
  1418. // (jQuery) The initial jQuery collection of elements.
  1419. // Allow the "shortcut" format $(elem).hashchange( fn ) for binding and
  1420. // $(elem).hashchange() for triggering, like jQuery does for built-in events.
  1421. $.fn[ str_hashchange ] = function( fn ) {
  1422. return fn ? this.bind( str_hashchange, fn ) : this.trigger( str_hashchange );
  1423. };
  1424. // Property: jQuery.fn.hashchange.delay
  1425. //
  1426. // The numeric interval (in milliseconds) at which the <hashchange event>
  1427. // polling loop executes. Defaults to 50.
  1428. // Property: jQuery.fn.hashchange.domain
  1429. //
  1430. // If you're setting document.domain in your JavaScript, and you want hash
  1431. // history to work in IE6/7, not only must this property be set, but you must
  1432. // also set document.domain BEFORE jQuery is loaded into the page. This
  1433. // property is only applicable if you are supporting IE6/7 (or IE8 operating
  1434. // in "IE7 compatibility" mode).
  1435. //
  1436. // In addition, the <jQuery.fn.hashchange.src> property must be set to the
  1437. // path of the included "document-domain.html" file, which can be renamed or
  1438. // modified if necessary (note that the document.domain specified must be the
  1439. // same in both your main JavaScript as well as in this file).
  1440. //
  1441. // Usage:
  1442. //
  1443. // jQuery.fn.hashchange.domain = document.domain;
  1444. // Property: jQuery.fn.hashchange.src
  1445. //
  1446. // If, for some reason, you need to specify an Iframe src file (for example,
  1447. // when setting document.domain as in <jQuery.fn.hashchange.domain>), you can
  1448. // do so using this property. Note that when using this property, history
  1449. // won't be recorded in IE6/7 until the Iframe src file loads. This property
  1450. // is only applicable if you are supporting IE6/7 (or IE8 operating in "IE7
  1451. // compatibility" mode).
  1452. //
  1453. // Usage:
  1454. //
  1455. // jQuery.fn.hashchange.src = 'path/to/file.html';
  1456. $.fn[ str_hashchange ].delay = 50;
  1457. /*
  1458. $.fn[ str_hashchange ].domain = null;
  1459. $.fn[ str_hashchange ].src = null;
  1460. */
  1461. // Event: hashchange event
  1462. //
  1463. // Fired when location.hash changes. In browsers that support it, the native
  1464. // HTML5 window.onhashchange event is used, otherwise a polling loop is
  1465. // initialized, running every <jQuery.fn.hashchange.delay> milliseconds to
  1466. // see if the hash has changed. In IE6/7 (and IE8 operating in "IE7
  1467. // compatibility" mode), a hidden Iframe is created to allow the back button
  1468. // and hash-based history to work.
  1469. //
  1470. // Usage as described in <jQuery.fn.hashchange>:
  1471. //
  1472. // > // Bind an event handler.
  1473. // > jQuery(window).hashchange( function(e) {
  1474. // > var hash = location.hash;
  1475. // > ...
  1476. // > });
  1477. // >
  1478. // > // Manually trigger the event handler.
  1479. // > jQuery(window).hashchange();
  1480. //
  1481. // A more verbose usage that allows for event namespacing:
  1482. //
  1483. // > // Bind an event handler.
  1484. // > jQuery(window).bind( 'hashchange', function(e) {
  1485. // > var hash = location.hash;
  1486. // > ...
  1487. // > });
  1488. // >
  1489. // > // Manually trigger the event handler.
  1490. // > jQuery(window).trigger( 'hashchange' );
  1491. //
  1492. // Additional Notes:
  1493. //
  1494. // * The polling loop and Iframe are not created until at least one handler
  1495. // is actually bound to the 'hashchange' event.
  1496. // * If you need the bound handler(s) to execute immediately, in cases where
  1497. // a location.hash exists on page load, via bookmark or page refresh for
  1498. // example, use jQuery(window).hashchange() or the more verbose
  1499. // jQuery(window).trigger( 'hashchange' ).
  1500. // * The event can be bound before DOM ready, but since it won't be usable
  1501. // before then in IE6/7 (due to the necessary Iframe), recommended usage is
  1502. // to bind it inside a DOM ready handler.
  1503. // Override existing $.event.special.hashchange methods (allowing this plugin
  1504. // to be defined after jQuery BBQ in BBQ's source code).
  1505. special[ str_hashchange ] = $.extend( special[ str_hashchange ], {
  1506. // Called only when the first 'hashchange' event is bound to window.
  1507. setup: function() {
  1508. // If window.onhashchange is supported natively, there's nothing to do..
  1509. if ( supports_onhashchange ) { return false; }
  1510. // Otherwise, we need to create our own. And we don't want to call this
  1511. // until the user binds to the event, just in case they never do, since it
  1512. // will create a polling loop and possibly even a hidden Iframe.
  1513. $( fake_onhashchange.start );
  1514. },
  1515. // Called only when the last 'hashchange' event is unbound from window.
  1516. teardown: function() {
  1517. // If window.onhashchange is supported natively, there's nothing to do..
  1518. if ( supports_onhashchange ) { return false; }
  1519. // Otherwise, we need to stop ours (if possible).
  1520. $( fake_onhashchange.stop );
  1521. }
  1522. });
  1523. // fake_onhashchange does all the work of triggering the window.onhashchange
  1524. // event for browsers that don't natively support it, including creating a
  1525. // polling loop to watch for hash changes and in IE 6/7 creating a hidden
  1526. // Iframe to enable back and forward.
  1527. fake_onhashchange = (function(){
  1528. var self = {},
  1529. timeout_id,
  1530. // Remember the initial hash so it doesn't get triggered immediately.
  1531. last_hash = get_fragment(),
  1532. fn_retval = function(val){ return val; },
  1533. history_set = fn_retval,
  1534. history_get = fn_retval;
  1535. // Start the polling loop.
  1536. self.start = function() {
  1537. timeout_id || poll();
  1538. };
  1539. // Stop the polling loop.
  1540. self.stop = function() {
  1541. timeout_id && clearTimeout( timeout_id );
  1542. timeout_id = undefined;
  1543. };
  1544. // This polling loop checks every $.fn.hashchange.delay milliseconds to see
  1545. // if location.hash has changed, and triggers the 'hashchange' event on
  1546. // window when necessary.
  1547. function poll() {
  1548. var hash = get_fragment(),
  1549. history_hash = history_get( last_hash );
  1550. if ( hash !== last_hash ) {
  1551. history_set( last_hash = hash, history_hash );
  1552. $(window).trigger( str_hashchange );
  1553. } else if ( history_hash !== last_hash ) {
  1554. location.href = location.href.replace( /#.*/, '' ) + history_hash;
  1555. }
  1556. timeout_id = setTimeout( poll, $.fn[ str_hashchange ].delay );
  1557. };
  1558. // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  1559. // vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv
  1560. // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  1561. window.attachEvent && !window.addEventListener && !supports_onhashchange && (function(){
  1562. // Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8
  1563. // when running in "IE7 compatibility" mode.
  1564. var iframe,
  1565. iframe_src;
  1566. // When the event is bound and polling starts in IE 6/7, create a hidden
  1567. // Iframe for history handling.
  1568. self.start = function(){
  1569. if ( !iframe ) {
  1570. iframe_src = $.fn[ str_hashchange ].src;
  1571. iframe_src = iframe_src && iframe_src + get_fragment();
  1572. // Create hidden Iframe. Attempt to make Iframe as hidden as possible
  1573. // by using techniques from http://www.paciellogroup.com/blog/?p=604.
  1574. iframe = $('<iframe tabindex="-1" title="empty"/>').hide()
  1575. // When Iframe has completely loaded, initialize the history and
  1576. // start polling.
  1577. .one( 'load', function(){
  1578. iframe_src || history_set( get_fragment() );
  1579. poll();
  1580. })
  1581. // Load Iframe src if specified, otherwise nothing.
  1582. .attr( 'src', iframe_src || 'javascript:0' )
  1583. // Append Iframe after the end of the body to prevent unnecessary
  1584. // initial page scrolling (yes, this works).
  1585. .insertAfter( 'body' )[0].contentWindow;
  1586. // Whenever `document.title` changes, update the Iframe's title to
  1587. // prettify the back/next history menu entries. Since IE sometimes
  1588. // errors with "Unspecified error" the very first time this is set
  1589. // (yes, very useful) wrap this with a try/catch block.
  1590. doc.onpropertychange = function(){
  1591. try {
  1592. if ( event.propertyName === 'title' ) {
  1593. iframe.document.title = doc.title;
  1594. }
  1595. } catch(e) {}
  1596. };
  1597. }
  1598. };
  1599. // Override the "stop" method since an IE6/7 Iframe was created. Even
  1600. // if there are no longer any bound event handlers, the polling loop
  1601. // is still necessary for back/next to work at all!
  1602. self.stop = fn_retval;
  1603. // Get history by looking at the hidden Iframe's location.hash.
  1604. history_get = function() {
  1605. return get_fragment( iframe.location.href );
  1606. };
  1607. // Set a new history item by opening and then closing the Iframe
  1608. // document, *then* setting its location.hash. If document.domain has
  1609. // been set, update that as well.
  1610. history_set = function( hash, history_hash ) {
  1611. var iframe_doc = iframe.document,
  1612. domain = $.fn[ str_hashchange ].domain;
  1613. if ( hash !== history_hash ) {
  1614. // Update Iframe with any initial `document.title` that might be set.
  1615. iframe_doc.title = doc.title;
  1616. // Opening the Iframe's document after it has been closed is what
  1617. // actually adds a history entry.
  1618. iframe_doc.open();
  1619. // Set document.domain for the Iframe document as well, if necessary.
  1620. domain && iframe_doc.write( '\x3cscript>document.domain="' + domain + '"\x3c/script>' );
  1621. iframe_doc.close();
  1622. // Update the Iframe's hash, for great justice.
  1623. iframe.location.hash = hash;
  1624. }
  1625. };
  1626. })();
  1627. // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1628. // ^^^^^^^^^^^^^^^^^^^ REMOVE IF NOT SUPPORTING IE6/7/8 ^^^^^^^^^^^^^^^^^^^
  1629. // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1630. return self;
  1631. })();
  1632. })(jQuery,this);
  1633. (function( $, undefined ) {
  1634. /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
  1635. window.matchMedia = window.matchMedia || (function( doc, undefined ) {
  1636. var bool,
  1637. docElem = doc.documentElement,
  1638. refNode = docElem.firstElementChild || docElem.firstChild,
  1639. // fakeBody required for <FF4 when executed in <head>
  1640. fakeBody = doc.createElement( "body" ),
  1641. div = doc.createElement( "div" );
  1642. div.id = "mq-test-1";
  1643. div.style.cssText = "position:absolute;top:-100em";
  1644. fakeBody.style.background = "none";
  1645. fakeBody.appendChild(div);
  1646. return function(q){
  1647. div.innerHTML = "&shy;<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
  1648. docElem.insertBefore( fakeBody, refNode );
  1649. bool = div.offsetWidth === 42;
  1650. docElem.removeChild( fakeBody );
  1651. return {
  1652. matches: bool,
  1653. media: q
  1654. };
  1655. };
  1656. }( document ));
  1657. // $.mobile.media uses matchMedia to return a boolean.
  1658. $.mobile.media = function( q ) {
  1659. return window.matchMedia( q ).matches;
  1660. };
  1661. })(jQuery);
  1662. (function( $, undefined ) {
  1663. var support = {
  1664. touch: "ontouchend" in document
  1665. };
  1666. $.mobile.support = $.mobile.support || {};
  1667. $.extend( $.support, support );
  1668. $.extend( $.mobile.support, support );
  1669. }( jQuery ));
  1670. (function( $, undefined ) {
  1671. $.extend( $.support, {
  1672. orientation: "orientation" in window && "onorientationchange" in window
  1673. });
  1674. }( jQuery ));
  1675. (function( $, undefined ) {
  1676. // thx Modernizr
  1677. function propExists( prop ) {
  1678. var uc_prop = prop.charAt( 0 ).toUpperCase() + prop.substr( 1 ),
  1679. props = ( prop + " " + vendors.join( uc_prop + " " ) + uc_prop ).split( " " ),
  1680. v;
  1681. for ( v in props ) {
  1682. if ( fbCSS[ props[ v ] ] !== undefined ) {
  1683. return true;
  1684. }
  1685. }
  1686. }
  1687. var fakeBody = $( "<body>" ).prependTo( "html" ),
  1688. fbCSS = fakeBody[ 0 ].style,
  1689. vendors = [ "Webkit", "Moz", "O" ],
  1690. webos = "palmGetResource" in window, //only used to rule out scrollTop
  1691. operamini = window.operamini && ({}).toString.call( window.operamini ) === "[object OperaMini]",
  1692. bb = window.blackberry && !propExists( "-webkit-transform" ), //only used to rule out box shadow, as it's filled opaque on BB 5 and lower
  1693. nokiaLTE7_3;
  1694. // inline SVG support test
  1695. function inlineSVG() {
  1696. // Thanks Modernizr & Erik Dahlstrom
  1697. var w = window,
  1698. svg = !!w.document.createElementNS && !!w.document.createElementNS( "http://www.w3.org/2000/svg", "svg" ).createSVGRect && !( w.opera && navigator.userAgent.indexOf( "Chrome" ) === -1 ),
  1699. support = function( data ) {
  1700. if ( !( data && svg ) ) {
  1701. $( "html" ).addClass( "ui-nosvg" );
  1702. }
  1703. },
  1704. img = new w.Image();
  1705. img.onerror = function() {
  1706. support( false );
  1707. };
  1708. img.onload = function() {
  1709. support( img.width === 1 && img.height === 1 );
  1710. };
  1711. img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
  1712. }
  1713. function transform3dTest() {
  1714. var mqProp = "transform-3d",
  1715. // Because the `translate3d` test below throws false positives in Android:
  1716. ret = $.mobile.media( "(-" + vendors.join( "-" + mqProp + "),(-" ) + "-" + mqProp + "),(" + mqProp + ")" ),
  1717. el, transforms, t;
  1718. if ( ret ) {
  1719. return !!ret;
  1720. }
  1721. el = document.createElement( "div" );
  1722. transforms = {
  1723. // We’re omitting Opera for the time being; MS uses unprefixed.
  1724. "MozTransform": "-moz-transform",
  1725. "transform": "transform"
  1726. };
  1727. fakeBody.append( el );
  1728. for ( t in transforms ) {
  1729. if ( el.style[ t ] !== undefined ) {
  1730. el.style[ t ] = "translate3d( 100px, 1px, 1px )";
  1731. ret = window.getComputedStyle( el ).getPropertyValue( transforms[ t ] );
  1732. }
  1733. }
  1734. return ( !!ret && ret !== "none" );
  1735. }
  1736. // Test for dynamic-updating base tag support ( allows us to avoid href,src attr rewriting )
  1737. function baseTagTest() {
  1738. var fauxBase = location.protocol + "//" + location.host + location.pathname + "ui-dir/",
  1739. base = $( "head base" ),
  1740. fauxEle = null,
  1741. href = "",
  1742. link, rebase;
  1743. if ( !base.length ) {
  1744. base = fauxEle = $( "<base>", { "href": fauxBase }).appendTo( "head" );
  1745. } else {
  1746. href = base.attr( "href" );
  1747. }
  1748. link = $( "<a href='testurl' />" ).prependTo( fakeBody );
  1749. rebase = link[ 0 ].href;
  1750. base[ 0 ].href = href || location.pathname;
  1751. if ( fauxEle ) {
  1752. fauxEle.remove();
  1753. }
  1754. return rebase.indexOf( fauxBase ) === 0;
  1755. }
  1756. // Thanks Modernizr
  1757. function cssPointerEventsTest() {
  1758. var element = document.createElement( "x" ),
  1759. documentElement = document.documentElement,
  1760. getComputedStyle = window.getComputedStyle,
  1761. supports;
  1762. if ( !( "pointerEvents" in element.style ) ) {
  1763. return false;
  1764. }
  1765. element.style.pointerEvents = "auto";
  1766. element.style.pointerEvents = "x";
  1767. documentElement.appendChild( element );
  1768. supports = getComputedStyle &&
  1769. getComputedStyle( element, "" ).pointerEvents === "auto";
  1770. documentElement.removeChild( element );
  1771. return !!supports;
  1772. }
  1773. function boundingRect() {
  1774. var div = document.createElement( "div" );
  1775. return typeof div.getBoundingClientRect !== "undefined";
  1776. }
  1777. // non-UA-based IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
  1778. // allows for inclusion of IE 6+, including Windows Mobile 7
  1779. $.extend( $.mobile, { browser: {} } );
  1780. $.mobile.browser.oldIE = (function() {
  1781. var v = 3,
  1782. div = document.createElement( "div" ),
  1783. a = div.all || [];
  1784. do {
  1785. div.innerHTML = "<!--[if gt IE " + ( ++v ) + "]><br><![endif]-->";
  1786. } while( a[0] );
  1787. return v > 4 ? v : !v;
  1788. })();
  1789. function fixedPosition() {
  1790. var w = window,
  1791. ua = navigator.userAgent,
  1792. platform = navigator.platform,
  1793. // Rendering engine is Webkit, and capture major version
  1794. wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ),
  1795. wkversion = !!wkmatch && wkmatch[ 1 ],
  1796. ffmatch = ua.match( /Fennec\/([0-9]+)/ ),
  1797. ffversion = !!ffmatch && ffmatch[ 1 ],
  1798. operammobilematch = ua.match( /Opera Mobi\/([0-9]+)/ ),
  1799. omversion = !!operammobilematch && operammobilematch[ 1 ];
  1800. if (
  1801. // iOS 4.3 and older : Platform is iPhone/Pad/Touch and Webkit version is less than 534 (ios5)
  1802. ( ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1 || platform.indexOf( "iPod" ) > -1 ) && wkversion && wkversion < 534 ) ||
  1803. // Opera Mini
  1804. ( w.operamini && ({}).toString.call( w.operamini ) === "[object OperaMini]" ) ||
  1805. ( operammobilematch && omversion < 7458 ) ||
  1806. //Android lte 2.1: Platform is Android and Webkit version is less than 533 (Android 2.2)
  1807. ( ua.indexOf( "Android" ) > -1 && wkversion && wkversion < 533 ) ||
  1808. // Firefox Mobile before 6.0 -
  1809. ( ffversion && ffversion < 6 ) ||
  1810. // WebOS less than 3
  1811. ( "palmGetResource" in window && wkversion && wkversion < 534 ) ||
  1812. // MeeGo
  1813. ( ua.indexOf( "MeeGo" ) > -1 && ua.indexOf( "NokiaBrowser/8.5.0" ) > -1 ) ) {
  1814. return false;
  1815. }
  1816. return true;
  1817. }
  1818. $.extend( $.support, {
  1819. // Note, Chrome for iOS has an extremely quirky implementation of popstate.
  1820. // We've chosen to take the shortest path to a bug fix here for issue #5426
  1821. // See the following link for information about the regex chosen
  1822. // https://developers.google.com/chrome/mobile/docs/user-agent#chrome_for_ios_user-agent
  1823. pushState: "pushState" in history &&
  1824. "replaceState" in history &&
  1825. // When running inside a FF iframe, calling replaceState causes an error
  1826. !( window.navigator.userAgent.indexOf( "Firefox" ) >= 0 && window.top !== window ) &&
  1827. ( window.navigator.userAgent.search(/CriOS/) === -1 ),
  1828. mediaquery: $.mobile.media( "only all" ),
  1829. cssPseudoElement: !!propExists( "content" ),
  1830. touchOverflow: !!propExists( "overflowScrolling" ),
  1831. cssTransform3d: transform3dTest(),
  1832. boxShadow: !!propExists( "boxShadow" ) && !bb,
  1833. fixedPosition: fixedPosition(),
  1834. scrollTop: ("pageXOffset" in window ||
  1835. "scrollTop" in document.documentElement ||
  1836. "scrollTop" in fakeBody[ 0 ]) && !webos && !operamini,
  1837. dynamicBaseTag: baseTagTest(),
  1838. cssPointerEvents: cssPointerEventsTest(),
  1839. boundingRect: boundingRect(),
  1840. inlineSVG: inlineSVG
  1841. });
  1842. fakeBody.remove();
  1843. // $.mobile.ajaxBlacklist is used to override ajaxEnabled on platforms that have known conflicts with hash history updates (BB5, Symbian)
  1844. // or that generally work better browsing in regular http for full page refreshes (Opera Mini)
  1845. // Note: This detection below is used as a last resort.
  1846. // We recommend only using these detection methods when all other more reliable/forward-looking approaches are not possible
  1847. nokiaLTE7_3 = (function() {
  1848. var ua = window.navigator.userAgent;
  1849. //The following is an attempt to match Nokia browsers that are running Symbian/s60, with webkit, version 7.3 or older
  1850. return ua.indexOf( "Nokia" ) > -1 &&
  1851. ( ua.indexOf( "Symbian/3" ) > -1 || ua.indexOf( "Series60/5" ) > -1 ) &&
  1852. ua.indexOf( "AppleWebKit" ) > -1 &&
  1853. ua.match( /(BrowserNG|NokiaBrowser)\/7\.[0-3]/ );
  1854. })();
  1855. // Support conditions that must be met in order to proceed
  1856. // default enhanced qualifications are media query support OR IE 7+
  1857. $.mobile.gradeA = function() {
  1858. return ( ( $.support.mediaquery && $.support.cssPseudoElement ) || $.mobile.browser.oldIE && $.mobile.browser.oldIE >= 8 ) && ( $.support.boundingRect || $.fn.jquery.match(/1\.[0-7+]\.[0-9+]?/) !== null );
  1859. };
  1860. $.mobile.ajaxBlacklist =
  1861. // BlackBerry browsers, pre-webkit
  1862. window.blackberry && !window.WebKitPoint ||
  1863. // Opera Mini
  1864. operamini ||
  1865. // Symbian webkits pre 7.3
  1866. nokiaLTE7_3;
  1867. // Lastly, this workaround is the only way we've found so far to get pre 7.3 Symbian webkit devices
  1868. // to render the stylesheets when they're referenced before this script, as we'd recommend doing.
  1869. // This simply reappends the CSS in place, which for some reason makes it apply
  1870. if ( nokiaLTE7_3 ) {
  1871. $(function() {
  1872. $( "head link[rel='stylesheet']" ).attr( "rel", "alternate stylesheet" ).attr( "rel", "stylesheet" );
  1873. });
  1874. }
  1875. // For ruling out shadows via css
  1876. if ( !$.support.boxShadow ) {
  1877. $( "html" ).addClass( "ui-noboxshadow" );
  1878. }
  1879. })( jQuery );
  1880. (function( $, undefined ) {
  1881. var $win = $.mobile.window, self,
  1882. dummyFnToInitNavigate = function() {
  1883. };
  1884. $.event.special.beforenavigate = {
  1885. setup: function() {
  1886. $win.on( "navigate", dummyFnToInitNavigate );
  1887. },
  1888. teardown: function() {
  1889. $win.off( "navigate", dummyFnToInitNavigate );
  1890. }
  1891. };
  1892. $.event.special.navigate = self = {
  1893. bound: false,
  1894. pushStateEnabled: true,
  1895. originalEventName: undefined,
  1896. // If pushstate support is present and push state support is defined to
  1897. // be true on the mobile namespace.
  1898. isPushStateEnabled: function() {
  1899. return $.support.pushState &&
  1900. $.mobile.pushStateEnabled === true &&
  1901. this.isHashChangeEnabled();
  1902. },
  1903. // !! assumes mobile namespace is present
  1904. isHashChangeEnabled: function() {
  1905. return $.mobile.hashListeningEnabled === true;
  1906. },
  1907. // TODO a lot of duplication between popstate and hashchange
  1908. popstate: function( event ) {
  1909. var newEvent = new $.Event( "navigate" ),
  1910. beforeNavigate = new $.Event( "beforenavigate" ),
  1911. state = event.originalEvent.state || {};
  1912. beforeNavigate.originalEvent = event;
  1913. $win.trigger( beforeNavigate );
  1914. if ( beforeNavigate.isDefaultPrevented() ) {
  1915. return;
  1916. }
  1917. if ( event.historyState ) {
  1918. $.extend(state, event.historyState);
  1919. }
  1920. // Make sure the original event is tracked for the end
  1921. // user to inspect incase they want to do something special
  1922. newEvent.originalEvent = event;
  1923. // NOTE we let the current stack unwind because any assignment to
  1924. // location.hash will stop the world and run this event handler. By
  1925. // doing this we create a similar behavior to hashchange on hash
  1926. // assignment
  1927. setTimeout(function() {
  1928. $win.trigger( newEvent, {
  1929. state: state
  1930. });
  1931. }, 0);
  1932. },
  1933. hashchange: function( event /*, data */ ) {
  1934. var newEvent = new $.Event( "navigate" ),
  1935. beforeNavigate = new $.Event( "beforenavigate" );
  1936. beforeNavigate.originalEvent = event;
  1937. $win.trigger( beforeNavigate );
  1938. if ( beforeNavigate.isDefaultPrevented() ) {
  1939. return;
  1940. }
  1941. // Make sure the original event is tracked for the end
  1942. // user to inspect incase they want to do something special
  1943. newEvent.originalEvent = event;
  1944. // Trigger the hashchange with state provided by the user
  1945. // that altered the hash
  1946. $win.trigger( newEvent, {
  1947. // Users that want to fully normalize the two events
  1948. // will need to do history management down the stack and
  1949. // add the state to the event before this binding is fired
  1950. // TODO consider allowing for the explicit addition of callbacks
  1951. // to be fired before this value is set to avoid event timing issues
  1952. state: event.hashchangeState || {}
  1953. });
  1954. },
  1955. // TODO We really only want to set this up once
  1956. // but I'm not clear if there's a beter way to achieve
  1957. // this with the jQuery special event structure
  1958. setup: function( /* data, namespaces */ ) {
  1959. if ( self.bound ) {
  1960. return;
  1961. }
  1962. self.bound = true;
  1963. if ( self.isPushStateEnabled() ) {
  1964. self.originalEventName = "popstate";
  1965. $win.bind( "popstate.navigate", self.popstate );
  1966. } else if ( self.isHashChangeEnabled() ) {
  1967. self.originalEventName = "hashchange";
  1968. $win.bind( "hashchange.navigate", self.hashchange );
  1969. }
  1970. }
  1971. };
  1972. })( jQuery );
  1973. (function( $, undefined ) {
  1974. var path, $base, dialogHashKey = "&ui-state=dialog";
  1975. $.mobile.path = path = {
  1976. uiStateKey: "&ui-state",
  1977. // This scary looking regular expression parses an absolute URL or its relative
  1978. // variants (protocol, site, document, query, and hash), into the various
  1979. // components (protocol, host, path, query, fragment, etc that make up the
  1980. // URL as well as some other commonly used sub-parts. When used with RegExp.exec()
  1981. // or String.match, it parses the URL into a results array that looks like this:
  1982. //
  1983. // [0]: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content
  1984. // [1]: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread
  1985. // [2]: http://jblas:password@mycompany.com:8080/mail/inbox
  1986. // [3]: http://jblas:password@mycompany.com:8080
  1987. // [4]: http:
  1988. // [5]: //
  1989. // [6]: jblas:password@mycompany.com:8080
  1990. // [7]: jblas:password
  1991. // [8]: jblas
  1992. // [9]: password
  1993. // [10]: mycompany.com:8080
  1994. // [11]: mycompany.com
  1995. // [12]: 8080
  1996. // [13]: /mail/inbox
  1997. // [14]: /mail/
  1998. // [15]: inbox
  1999. // [16]: ?msg=1234&type=unread
  2000. // [17]: #msg-content
  2001. //
  2002. urlParseRE: /^\s*(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,
  2003. // Abstraction to address xss (Issue #4787) by removing the authority in
  2004. // browsers that auto-decode it. All references to location.href should be
  2005. // replaced with a call to this method so that it can be dealt with properly here
  2006. getLocation: function( url ) {
  2007. var parsedUrl = this.parseUrl( url || location.href ),
  2008. uri = url ? parsedUrl : location,
  2009. // Make sure to parse the url or the location object for the hash because using
  2010. // location.hash is autodecoded in firefox, the rest of the url should be from
  2011. // the object (location unless we're testing) to avoid the inclusion of the
  2012. // authority
  2013. hash = parsedUrl.hash;
  2014. // mimic the browser with an empty string when the hash is empty
  2015. hash = hash === "#" ? "" : hash;
  2016. return uri.protocol +
  2017. parsedUrl.doubleSlash +
  2018. uri.host +
  2019. // The pathname must start with a slash if there's a protocol, because you
  2020. // can't have a protocol followed by a relative path. Also, it's impossible to
  2021. // calculate absolute URLs from relative ones if the absolute one doesn't have
  2022. // a leading "/".
  2023. ( ( uri.protocol !== "" && uri.pathname.substring( 0, 1 ) !== "/" ) ?
  2024. "/" : "" ) +
  2025. uri.pathname +
  2026. uri.search +
  2027. hash;
  2028. },
  2029. //return the original document url
  2030. getDocumentUrl: function( asParsedObject ) {
  2031. return asParsedObject ? $.extend( {}, path.documentUrl ) : path.documentUrl.href;
  2032. },
  2033. parseLocation: function() {
  2034. return this.parseUrl( this.getLocation() );
  2035. },
  2036. //Parse a URL into a structure that allows easy access to
  2037. //all of the URL components by name.
  2038. parseUrl: function( url ) {
  2039. // If we're passed an object, we'll assume that it is
  2040. // a parsed url object and just return it back to the caller.
  2041. if ( $.type( url ) === "object" ) {
  2042. return url;
  2043. }
  2044. var matches = path.urlParseRE.exec( url || "" ) || [];
  2045. // Create an object that allows the caller to access the sub-matches
  2046. // by name. Note that IE returns an empty string instead of undefined,
  2047. // like all other browsers do, so we normalize everything so its consistent
  2048. // no matter what browser we're running on.
  2049. return {
  2050. href: matches[ 0 ] || "",
  2051. hrefNoHash: matches[ 1 ] || "",
  2052. hrefNoSearch: matches[ 2 ] || "",
  2053. domain: matches[ 3 ] || "",
  2054. protocol: matches[ 4 ] || "",
  2055. doubleSlash: matches[ 5 ] || "",
  2056. authority: matches[ 6 ] || "",
  2057. username: matches[ 8 ] || "",
  2058. password: matches[ 9 ] || "",
  2059. host: matches[ 10 ] || "",
  2060. hostname: matches[ 11 ] || "",
  2061. port: matches[ 12 ] || "",
  2062. pathname: matches[ 13 ] || "",
  2063. directory: matches[ 14 ] || "",
  2064. filename: matches[ 15 ] || "",
  2065. search: matches[ 16 ] || "",
  2066. hash: matches[ 17 ] || ""
  2067. };
  2068. },
  2069. //Turn relPath into an asbolute path. absPath is
  2070. //an optional absolute path which describes what
  2071. //relPath is relative to.
  2072. makePathAbsolute: function( relPath, absPath ) {
  2073. var absStack,
  2074. relStack,
  2075. i, d;
  2076. if ( relPath && relPath.charAt( 0 ) === "/" ) {
  2077. return relPath;
  2078. }
  2079. relPath = relPath || "";
  2080. absPath = absPath ? absPath.replace( /^\/|(\/[^\/]*|[^\/]+)$/g, "" ) : "";
  2081. absStack = absPath ? absPath.split( "/" ) : [];
  2082. relStack = relPath.split( "/" );
  2083. for ( i = 0; i < relStack.length; i++ ) {
  2084. d = relStack[ i ];
  2085. switch ( d ) {
  2086. case ".":
  2087. break;
  2088. case "..":
  2089. if ( absStack.length ) {
  2090. absStack.pop();
  2091. }
  2092. break;
  2093. default:
  2094. absStack.push( d );
  2095. break;
  2096. }
  2097. }
  2098. return "/" + absStack.join( "/" );
  2099. },
  2100. //Returns true if both urls have the same domain.
  2101. isSameDomain: function( absUrl1, absUrl2 ) {
  2102. return path.parseUrl( absUrl1 ).domain.toLowerCase() ===
  2103. path.parseUrl( absUrl2 ).domain.toLowerCase();
  2104. },
  2105. //Returns true for any relative variant.
  2106. isRelativeUrl: function( url ) {
  2107. // All relative Url variants have one thing in common, no protocol.
  2108. return path.parseUrl( url ).protocol === "";
  2109. },
  2110. //Returns true for an absolute url.
  2111. isAbsoluteUrl: function( url ) {
  2112. return path.parseUrl( url ).protocol !== "";
  2113. },
  2114. //Turn the specified realtive URL into an absolute one. This function
  2115. //can handle all relative variants (protocol, site, document, query, fragment).
  2116. makeUrlAbsolute: function( relUrl, absUrl ) {
  2117. if ( !path.isRelativeUrl( relUrl ) ) {
  2118. return relUrl;
  2119. }
  2120. if ( absUrl === undefined ) {
  2121. absUrl = this.documentBase;
  2122. }
  2123. var relObj = path.parseUrl( relUrl ),
  2124. absObj = path.parseUrl( absUrl ),
  2125. protocol = relObj.protocol || absObj.protocol,
  2126. doubleSlash = relObj.protocol ? relObj.doubleSlash : ( relObj.doubleSlash || absObj.doubleSlash ),
  2127. authority = relObj.authority || absObj.authority,
  2128. hasPath = relObj.pathname !== "",
  2129. pathname = path.makePathAbsolute( relObj.pathname || absObj.filename, absObj.pathname ),
  2130. search = relObj.search || ( !hasPath && absObj.search ) || "",
  2131. hash = relObj.hash;
  2132. return protocol + doubleSlash + authority + pathname + search + hash;
  2133. },
  2134. //Add search (aka query) params to the specified url.
  2135. addSearchParams: function( url, params ) {
  2136. var u = path.parseUrl( url ),
  2137. p = ( typeof params === "object" ) ? $.param( params ) : params,
  2138. s = u.search || "?";
  2139. return u.hrefNoSearch + s + ( s.charAt( s.length - 1 ) !== "?" ? "&" : "" ) + p + ( u.hash || "" );
  2140. },
  2141. convertUrlToDataUrl: function( absUrl ) {
  2142. var result = absUrl,
  2143. u = path.parseUrl( absUrl );
  2144. if ( path.isEmbeddedPage( u ) ) {
  2145. // For embedded pages, remove the dialog hash key as in getFilePath(),
  2146. // and remove otherwise the Data Url won't match the id of the embedded Page.
  2147. result = u.hash
  2148. .split( dialogHashKey )[0]
  2149. .replace( /^#/, "" )
  2150. .replace( /\?.*$/, "" );
  2151. } else if ( path.isSameDomain( u, this.documentBase ) ) {
  2152. result = u.hrefNoHash.replace( this.documentBase.domain, "" ).split( dialogHashKey )[0];
  2153. }
  2154. return window.decodeURIComponent( result );
  2155. },
  2156. //get path from current hash, or from a file path
  2157. get: function( newPath ) {
  2158. if ( newPath === undefined ) {
  2159. newPath = path.parseLocation().hash;
  2160. }
  2161. return path.stripHash( newPath ).replace( /[^\/]*\.[^\/*]+$/, "" );
  2162. },
  2163. //set location hash to path
  2164. set: function( path ) {
  2165. location.hash = path;
  2166. },
  2167. //test if a given url (string) is a path
  2168. //NOTE might be exceptionally naive
  2169. isPath: function( url ) {
  2170. return ( /\// ).test( url );
  2171. },
  2172. //return a url path with the window's location protocol/hostname/pathname removed
  2173. clean: function( url ) {
  2174. return url.replace( this.documentBase.domain, "" );
  2175. },
  2176. //just return the url without an initial #
  2177. stripHash: function( url ) {
  2178. return url.replace( /^#/, "" );
  2179. },
  2180. stripQueryParams: function( url ) {
  2181. return url.replace( /\?.*$/, "" );
  2182. },
  2183. //remove the preceding hash, any query params, and dialog notations
  2184. cleanHash: function( hash ) {
  2185. return path.stripHash( hash.replace( /\?.*$/, "" ).replace( dialogHashKey, "" ) );
  2186. },
  2187. isHashValid: function( hash ) {
  2188. return ( /^#[^#]+$/ ).test( hash );
  2189. },
  2190. //check whether a url is referencing the same domain, or an external domain or different protocol
  2191. //could be mailto, etc
  2192. isExternal: function( url ) {
  2193. var u = path.parseUrl( url );
  2194. return !!( u.protocol &&
  2195. ( u.domain.toLowerCase() !== this.documentUrl.domain.toLowerCase() ) );
  2196. },
  2197. hasProtocol: function( url ) {
  2198. return ( /^(:?\w+:)/ ).test( url );
  2199. },
  2200. isEmbeddedPage: function( url ) {
  2201. var u = path.parseUrl( url );
  2202. //if the path is absolute, then we need to compare the url against
  2203. //both the this.documentUrl and the documentBase. The main reason for this
  2204. //is that links embedded within external documents will refer to the
  2205. //application document, whereas links embedded within the application
  2206. //document will be resolved against the document base.
  2207. if ( u.protocol !== "" ) {
  2208. return ( !this.isPath(u.hash) && u.hash && ( u.hrefNoHash === this.documentUrl.hrefNoHash || ( this.documentBaseDiffers && u.hrefNoHash === this.documentBase.hrefNoHash ) ) );
  2209. }
  2210. return ( /^#/ ).test( u.href );
  2211. },
  2212. squash: function( url, resolutionUrl ) {
  2213. var href, cleanedUrl, search, stateIndex, docUrl,
  2214. isPath = this.isPath( url ),
  2215. uri = this.parseUrl( url ),
  2216. preservedHash = uri.hash,
  2217. uiState = "";
  2218. // produce a url against which we can resolve the provided path
  2219. if ( !resolutionUrl ) {
  2220. if ( isPath ) {
  2221. resolutionUrl = path.getLocation();
  2222. } else {
  2223. docUrl = path.getDocumentUrl( true );
  2224. if ( path.isPath( docUrl.hash ) ) {
  2225. resolutionUrl = path.squash( docUrl.href );
  2226. } else {
  2227. resolutionUrl = docUrl.href;
  2228. }
  2229. }
  2230. }
  2231. // If the url is anything but a simple string, remove any preceding hash
  2232. // eg #foo/bar -> foo/bar
  2233. // #foo -> #foo
  2234. cleanedUrl = isPath ? path.stripHash( url ) : url;
  2235. // If the url is a full url with a hash check if the parsed hash is a path
  2236. // if it is, strip the #, and use it otherwise continue without change
  2237. cleanedUrl = path.isPath( uri.hash ) ? path.stripHash( uri.hash ) : cleanedUrl;
  2238. // Split the UI State keys off the href
  2239. stateIndex = cleanedUrl.indexOf( this.uiStateKey );
  2240. // store the ui state keys for use
  2241. if ( stateIndex > -1 ) {
  2242. uiState = cleanedUrl.slice( stateIndex );
  2243. cleanedUrl = cleanedUrl.slice( 0, stateIndex );
  2244. }
  2245. // make the cleanedUrl absolute relative to the resolution url
  2246. href = path.makeUrlAbsolute( cleanedUrl, resolutionUrl );
  2247. // grab the search from the resolved url since parsing from
  2248. // the passed url may not yield the correct result
  2249. search = this.parseUrl( href ).search;
  2250. // TODO all this crap is terrible, clean it up
  2251. if ( isPath ) {
  2252. // reject the hash if it's a path or it's just a dialog key
  2253. if ( path.isPath( preservedHash ) || preservedHash.replace("#", "").indexOf( this.uiStateKey ) === 0) {
  2254. preservedHash = "";
  2255. }
  2256. // Append the UI State keys where it exists and it's been removed
  2257. // from the url
  2258. if ( uiState && preservedHash.indexOf( this.uiStateKey ) === -1) {
  2259. preservedHash += uiState;
  2260. }
  2261. // make sure that pound is on the front of the hash
  2262. if ( preservedHash.indexOf( "#" ) === -1 && preservedHash !== "" ) {
  2263. preservedHash = "#" + preservedHash;
  2264. }
  2265. // reconstruct each of the pieces with the new search string and hash
  2266. href = path.parseUrl( href );
  2267. href = href.protocol + href.doubleSlash + href.host + href.pathname + search +
  2268. preservedHash;
  2269. } else {
  2270. href += href.indexOf( "#" ) > -1 ? uiState : "#" + uiState;
  2271. }
  2272. return href;
  2273. },
  2274. isPreservableHash: function( hash ) {
  2275. return hash.replace( "#", "" ).indexOf( this.uiStateKey ) === 0;
  2276. },
  2277. // Escape weird characters in the hash if it is to be used as a selector
  2278. hashToSelector: function( hash ) {
  2279. var hasHash = ( hash.substring( 0, 1 ) === "#" );
  2280. if ( hasHash ) {
  2281. hash = hash.substring( 1 );
  2282. }
  2283. return ( hasHash ? "#" : "" ) + hash.replace( /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g, "\\$1" );
  2284. },
  2285. // return the substring of a filepath before the dialogHashKey, for making a server
  2286. // request
  2287. getFilePath: function( path ) {
  2288. return path && path.split( dialogHashKey )[0];
  2289. },
  2290. // check if the specified url refers to the first page in the main
  2291. // application document.
  2292. isFirstPageUrl: function( url ) {
  2293. // We only deal with absolute paths.
  2294. var u = path.parseUrl( path.makeUrlAbsolute( url, this.documentBase ) ),
  2295. // Does the url have the same path as the document?
  2296. samePath = u.hrefNoHash === this.documentUrl.hrefNoHash ||
  2297. ( this.documentBaseDiffers &&
  2298. u.hrefNoHash === this.documentBase.hrefNoHash ),
  2299. // Get the first page element.
  2300. fp = $.mobile.firstPage,
  2301. // Get the id of the first page element if it has one.
  2302. fpId = fp && fp[0] ? fp[0].id : undefined;
  2303. // The url refers to the first page if the path matches the document and
  2304. // it either has no hash value, or the hash is exactly equal to the id
  2305. // of the first page element.
  2306. return samePath &&
  2307. ( !u.hash ||
  2308. u.hash === "#" ||
  2309. ( fpId && u.hash.replace( /^#/, "" ) === fpId ) );
  2310. },
  2311. // Some embedded browsers, like the web view in Phone Gap, allow
  2312. // cross-domain XHR requests if the document doing the request was loaded
  2313. // via the file:// protocol. This is usually to allow the application to
  2314. // "phone home" and fetch app specific data. We normally let the browser
  2315. // handle external/cross-domain urls, but if the allowCrossDomainPages
  2316. // option is true, we will allow cross-domain http/https requests to go
  2317. // through our page loading logic.
  2318. isPermittedCrossDomainRequest: function( docUrl, reqUrl ) {
  2319. return $.mobile.allowCrossDomainPages &&
  2320. (docUrl.protocol === "file:" || docUrl.protocol === "content:") &&
  2321. reqUrl.search( /^https?:/ ) !== -1;
  2322. }
  2323. };
  2324. path.documentUrl = path.parseLocation();
  2325. $base = $( "head" ).find( "base" );
  2326. path.documentBase = $base.length ?
  2327. path.parseUrl( path.makeUrlAbsolute( $base.attr( "href" ), path.documentUrl.href ) ) :
  2328. path.documentUrl;
  2329. path.documentBaseDiffers = (path.documentUrl.hrefNoHash !== path.documentBase.hrefNoHash);
  2330. //return the original document base url
  2331. path.getDocumentBase = function( asParsedObject ) {
  2332. return asParsedObject ? $.extend( {}, path.documentBase ) : path.documentBase.href;
  2333. };
  2334. // DEPRECATED as of 1.4.0 - remove in 1.5.0
  2335. $.extend( $.mobile, {
  2336. //return the original document url
  2337. getDocumentUrl: path.getDocumentUrl,
  2338. //return the original document base url
  2339. getDocumentBase: path.getDocumentBase
  2340. });
  2341. })( jQuery );
  2342. (function( $, undefined ) {
  2343. $.mobile.History = function( stack, index ) {
  2344. this.stack = stack || [];
  2345. this.activeIndex = index || 0;
  2346. };
  2347. $.extend($.mobile.History.prototype, {
  2348. getActive: function() {
  2349. return this.stack[ this.activeIndex ];
  2350. },
  2351. getLast: function() {
  2352. return this.stack[ this.previousIndex ];
  2353. },
  2354. getNext: function() {
  2355. return this.stack[ this.activeIndex + 1 ];
  2356. },
  2357. getPrev: function() {
  2358. return this.stack[ this.activeIndex - 1 ];
  2359. },
  2360. // addNew is used whenever a new page is added
  2361. add: function( url, data ) {
  2362. data = data || {};
  2363. //if there's forward history, wipe it
  2364. if ( this.getNext() ) {
  2365. this.clearForward();
  2366. }
  2367. // if the hash is included in the data make sure the shape
  2368. // is consistent for comparison
  2369. if ( data.hash && data.hash.indexOf( "#" ) === -1) {
  2370. data.hash = "#" + data.hash;
  2371. }
  2372. data.url = url;
  2373. this.stack.push( data );
  2374. this.activeIndex = this.stack.length - 1;
  2375. },
  2376. //wipe urls ahead of active index
  2377. clearForward: function() {
  2378. this.stack = this.stack.slice( 0, this.activeIndex + 1 );
  2379. },
  2380. find: function( url, stack, earlyReturn ) {
  2381. stack = stack || this.stack;
  2382. var entry, i, length = stack.length, index;
  2383. for ( i = 0; i < length; i++ ) {
  2384. entry = stack[i];
  2385. if ( decodeURIComponent(url) === decodeURIComponent(entry.url) ||
  2386. decodeURIComponent(url) === decodeURIComponent(entry.hash) ) {
  2387. index = i;
  2388. if ( earlyReturn ) {
  2389. return index;
  2390. }
  2391. }
  2392. }
  2393. return index;
  2394. },
  2395. closest: function( url ) {
  2396. var closest, a = this.activeIndex;
  2397. // First, take the slice of the history stack before the current index and search
  2398. // for a url match. If one is found, we'll avoid avoid looking through forward history
  2399. // NOTE the preference for backward history movement is driven by the fact that
  2400. // most mobile browsers only have a dedicated back button, and users rarely use
  2401. // the forward button in desktop browser anyhow
  2402. closest = this.find( url, this.stack.slice(0, a) );
  2403. // If nothing was found in backward history check forward. The `true`
  2404. // value passed as the third parameter causes the find method to break
  2405. // on the first match in the forward history slice. The starting index
  2406. // of the slice must then be added to the result to get the element index
  2407. // in the original history stack :( :(
  2408. //
  2409. // TODO this is hyper confusing and should be cleaned up (ugh so bad)
  2410. if ( closest === undefined ) {
  2411. closest = this.find( url, this.stack.slice(a), true );
  2412. closest = closest === undefined ? closest : closest + a;
  2413. }
  2414. return closest;
  2415. },
  2416. direct: function( opts ) {
  2417. var newActiveIndex = this.closest( opts.url ), a = this.activeIndex;
  2418. // save new page index, null check to prevent falsey 0 result
  2419. // record the previous index for reference
  2420. if ( newActiveIndex !== undefined ) {
  2421. this.activeIndex = newActiveIndex;
  2422. this.previousIndex = a;
  2423. }
  2424. // invoke callbacks where appropriate
  2425. //
  2426. // TODO this is also convoluted and confusing
  2427. if ( newActiveIndex < a ) {
  2428. ( opts.present || opts.back || $.noop )( this.getActive(), "back" );
  2429. } else if ( newActiveIndex > a ) {
  2430. ( opts.present || opts.forward || $.noop )( this.getActive(), "forward" );
  2431. } else if ( newActiveIndex === undefined && opts.missing ) {
  2432. opts.missing( this.getActive() );
  2433. }
  2434. }
  2435. });
  2436. })( jQuery );
  2437. (function( $, undefined ) {
  2438. var path = $.mobile.path,
  2439. initialHref = location.href;
  2440. $.mobile.Navigator = function( history ) {
  2441. this.history = history;
  2442. this.ignoreInitialHashChange = true;
  2443. $.mobile.window.bind({
  2444. "popstate.history": $.proxy( this.popstate, this ),
  2445. "hashchange.history": $.proxy( this.hashchange, this )
  2446. });
  2447. };
  2448. $.extend($.mobile.Navigator.prototype, {
  2449. squash: function( url, data ) {
  2450. var state, href, hash = path.isPath(url) ? path.stripHash(url) : url;
  2451. href = path.squash( url );
  2452. // make sure to provide this information when it isn't explicitly set in the
  2453. // data object that was passed to the squash method
  2454. state = $.extend({
  2455. hash: hash,
  2456. url: href
  2457. }, data);
  2458. // replace the current url with the new href and store the state
  2459. // Note that in some cases we might be replacing an url with the
  2460. // same url. We do this anyways because we need to make sure that
  2461. // all of our history entries have a state object associated with
  2462. // them. This allows us to work around the case where $.mobile.back()
  2463. // is called to transition from an external page to an embedded page.
  2464. // In that particular case, a hashchange event is *NOT* generated by the browser.
  2465. // Ensuring each history entry has a state object means that onPopState()
  2466. // will always trigger our hashchange callback even when a hashchange event
  2467. // is not fired.
  2468. window.history.replaceState( state, state.title || document.title, href );
  2469. return state;
  2470. },
  2471. hash: function( url, href ) {
  2472. var parsed, loc, hash, resolved;
  2473. // Grab the hash for recording. If the passed url is a path
  2474. // we used the parsed version of the squashed url to reconstruct,
  2475. // otherwise we assume it's a hash and store it directly
  2476. parsed = path.parseUrl( url );
  2477. loc = path.parseLocation();
  2478. if ( loc.pathname + loc.search === parsed.pathname + parsed.search ) {
  2479. // If the pathname and search of the passed url is identical to the current loc
  2480. // then we must use the hash. Otherwise there will be no event
  2481. // eg, url = "/foo/bar?baz#bang", location.href = "http://example.com/foo/bar?baz"
  2482. hash = parsed.hash ? parsed.hash : parsed.pathname + parsed.search;
  2483. } else if ( path.isPath(url) ) {
  2484. resolved = path.parseUrl( href );
  2485. // If the passed url is a path, make it domain relative and remove any trailing hash
  2486. hash = resolved.pathname + resolved.search + (path.isPreservableHash( resolved.hash )? resolved.hash.replace( "#", "" ) : "");
  2487. } else {
  2488. hash = url;
  2489. }
  2490. return hash;
  2491. },
  2492. // TODO reconsider name
  2493. go: function( url, data, noEvents ) {
  2494. var state, href, hash, popstateEvent,
  2495. isPopStateEvent = $.event.special.navigate.isPushStateEnabled();
  2496. // Get the url as it would look squashed on to the current resolution url
  2497. href = path.squash( url );
  2498. // sort out what the hash sould be from the url
  2499. hash = this.hash( url, href );
  2500. // Here we prevent the next hash change or popstate event from doing any
  2501. // history management. In the case of hashchange we don't swallow it
  2502. // if there will be no hashchange fired (since that won't reset the value)
  2503. // and will swallow the following hashchange
  2504. if ( noEvents && hash !== path.stripHash(path.parseLocation().hash) ) {
  2505. this.preventNextHashChange = noEvents;
  2506. }
  2507. // IMPORTANT in the case where popstate is supported the event will be triggered
  2508. // directly, stopping further execution - ie, interupting the flow of this
  2509. // method call to fire bindings at this expression. Below the navigate method
  2510. // there is a binding to catch this event and stop its propagation.
  2511. //
  2512. // We then trigger a new popstate event on the window with a null state
  2513. // so that the navigate events can conclude their work properly
  2514. //
  2515. // if the url is a path we want to preserve the query params that are available on
  2516. // the current url.
  2517. this.preventHashAssignPopState = true;
  2518. window.location.hash = hash;
  2519. // If popstate is enabled and the browser triggers `popstate` events when the hash
  2520. // is set (this often happens immediately in browsers like Chrome), then the
  2521. // this flag will be set to false already. If it's a browser that does not trigger
  2522. // a `popstate` on hash assignement or `replaceState` then we need avoid the branch
  2523. // that swallows the event created by the popstate generated by the hash assignment
  2524. // At the time of this writing this happens with Opera 12 and some version of IE
  2525. this.preventHashAssignPopState = false;
  2526. state = $.extend({
  2527. url: href,
  2528. hash: hash,
  2529. title: document.title
  2530. }, data);
  2531. if ( isPopStateEvent ) {
  2532. popstateEvent = new $.Event( "popstate" );
  2533. popstateEvent.originalEvent = {
  2534. type: "popstate",
  2535. state: null
  2536. };
  2537. this.squash( url, state );
  2538. // Trigger a new faux popstate event to replace the one that we
  2539. // caught that was triggered by the hash setting above.
  2540. if ( !noEvents ) {
  2541. this.ignorePopState = true;
  2542. $.mobile.window.trigger( popstateEvent );
  2543. }
  2544. }
  2545. // record the history entry so that the information can be included
  2546. // in hashchange event driven navigate events in a similar fashion to
  2547. // the state that's provided by popstate
  2548. this.history.add( state.url, state );
  2549. },
  2550. // This binding is intended to catch the popstate events that are fired
  2551. // when execution of the `$.navigate` method stops at window.location.hash = url;
  2552. // and completely prevent them from propagating. The popstate event will then be
  2553. // retriggered after execution resumes
  2554. //
  2555. // TODO grab the original event here and use it for the synthetic event in the
  2556. // second half of the navigate execution that will follow this binding
  2557. popstate: function( event ) {
  2558. var hash, state;
  2559. // Partly to support our test suite which manually alters the support
  2560. // value to test hashchange. Partly to prevent all around weirdness
  2561. if ( !$.event.special.navigate.isPushStateEnabled() ) {
  2562. return;
  2563. }
  2564. // If this is the popstate triggered by the actual alteration of the hash
  2565. // prevent it completely. History is tracked manually
  2566. if ( this.preventHashAssignPopState ) {
  2567. this.preventHashAssignPopState = false;
  2568. event.stopImmediatePropagation();
  2569. return;
  2570. }
  2571. // if this is the popstate triggered after the `replaceState` call in the go
  2572. // method, then simply ignore it. The history entry has already been captured
  2573. if ( this.ignorePopState ) {
  2574. this.ignorePopState = false;
  2575. return;
  2576. }
  2577. // If there is no state, and the history stack length is one were
  2578. // probably getting the page load popstate fired by browsers like chrome
  2579. // avoid it and set the one time flag to false.
  2580. // TODO: Do we really need all these conditions? Comparing location hrefs
  2581. // should be sufficient.
  2582. if ( !event.originalEvent.state &&
  2583. this.history.stack.length === 1 &&
  2584. this.ignoreInitialHashChange ) {
  2585. this.ignoreInitialHashChange = false;
  2586. if ( location.href === initialHref ) {
  2587. event.preventDefault();
  2588. return;
  2589. }
  2590. }
  2591. // account for direct manipulation of the hash. That is, we will receive a popstate
  2592. // when the hash is changed by assignment, and it won't have a state associated. We
  2593. // then need to squash the hash. See below for handling of hash assignment that
  2594. // matches an existing history entry
  2595. // TODO it might be better to only add to the history stack
  2596. // when the hash is adjacent to the active history entry
  2597. hash = path.parseLocation().hash;
  2598. if ( !event.originalEvent.state && hash ) {
  2599. // squash the hash that's been assigned on the URL with replaceState
  2600. // also grab the resulting state object for storage
  2601. state = this.squash( hash );
  2602. // record the new hash as an additional history entry
  2603. // to match the browser's treatment of hash assignment
  2604. this.history.add( state.url, state );
  2605. // pass the newly created state information
  2606. // along with the event
  2607. event.historyState = state;
  2608. // do not alter history, we've added a new history entry
  2609. // so we know where we are
  2610. return;
  2611. }
  2612. // If all else fails this is a popstate that comes from the back or forward buttons
  2613. // make sure to set the state of our history stack properly, and record the directionality
  2614. this.history.direct({
  2615. url: (event.originalEvent.state || {}).url || hash,
  2616. // When the url is either forward or backward in history include the entry
  2617. // as data on the event object for merging as data in the navigate event
  2618. present: function( historyEntry, direction ) {
  2619. // make sure to create a new object to pass down as the navigate event data
  2620. event.historyState = $.extend({}, historyEntry);
  2621. event.historyState.direction = direction;
  2622. }
  2623. });
  2624. },
  2625. // NOTE must bind before `navigate` special event hashchange binding otherwise the
  2626. // navigation data won't be attached to the hashchange event in time for those
  2627. // bindings to attach it to the `navigate` special event
  2628. // TODO add a check here that `hashchange.navigate` is bound already otherwise it's
  2629. // broken (exception?)
  2630. hashchange: function( event ) {
  2631. var history, hash;
  2632. // If hashchange listening is explicitly disabled or pushstate is supported
  2633. // avoid making use of the hashchange handler.
  2634. if (!$.event.special.navigate.isHashChangeEnabled() ||
  2635. $.event.special.navigate.isPushStateEnabled() ) {
  2636. return;
  2637. }
  2638. // On occasion explicitly want to prevent the next hash from propogating because we only
  2639. // with to alter the url to represent the new state do so here
  2640. if ( this.preventNextHashChange ) {
  2641. this.preventNextHashChange = false;
  2642. event.stopImmediatePropagation();
  2643. return;
  2644. }
  2645. history = this.history;
  2646. hash = path.parseLocation().hash;
  2647. // If this is a hashchange caused by the back or forward button
  2648. // make sure to set the state of our history stack properly
  2649. this.history.direct({
  2650. url: hash,
  2651. // When the url is either forward or backward in history include the entry
  2652. // as data on the event object for merging as data in the navigate event
  2653. present: function( historyEntry, direction ) {
  2654. // make sure to create a new object to pass down as the navigate event data
  2655. event.hashchangeState = $.extend({}, historyEntry);
  2656. event.hashchangeState.direction = direction;
  2657. },
  2658. // When we don't find a hash in our history clearly we're aiming to go there
  2659. // record the entry as new for future traversal
  2660. //
  2661. // NOTE it's not entirely clear that this is the right thing to do given that we
  2662. // can't know the users intention. It might be better to explicitly _not_
  2663. // support location.hash assignment in preference to $.navigate calls
  2664. // TODO first arg to add should be the href, but it causes issues in identifying
  2665. // embeded pages
  2666. missing: function() {
  2667. history.add( hash, {
  2668. hash: hash,
  2669. title: document.title
  2670. });
  2671. }
  2672. });
  2673. }
  2674. });
  2675. })( jQuery );
  2676. (function( $, undefined ) {
  2677. // TODO consider queueing navigation activity until previous activities have completed
  2678. // so that end users don't have to think about it. Punting for now
  2679. // TODO !! move the event bindings into callbacks on the navigate event
  2680. $.mobile.navigate = function( url, data, noEvents ) {
  2681. $.mobile.navigate.navigator.go( url, data, noEvents );
  2682. };
  2683. // expose the history on the navigate method in anticipation of full integration with
  2684. // existing navigation functionalty that is tightly coupled to the history information
  2685. $.mobile.navigate.history = new $.mobile.History();
  2686. // instantiate an instance of the navigator for use within the $.navigate method
  2687. $.mobile.navigate.navigator = new $.mobile.Navigator( $.mobile.navigate.history );
  2688. var loc = $.mobile.path.parseLocation();
  2689. $.mobile.navigate.history.add( loc.href, {hash: loc.hash} );
  2690. })( jQuery );
  2691. (function( $, undefined ) {
  2692. var props = {
  2693. "animation": {},
  2694. "transition": {}
  2695. },
  2696. testElement = document.createElement( "a" ),
  2697. vendorPrefixes = [ "", "webkit-", "moz-", "o-" ];
  2698. $.each( [ "animation", "transition" ], function( i, test ) {
  2699. // Get correct name for test
  2700. var testName = ( i === 0 ) ? test + "-" + "name" : test;
  2701. $.each( vendorPrefixes, function( j, prefix ) {
  2702. if ( testElement.style[ $.camelCase( prefix + testName ) ] !== undefined ) {
  2703. props[ test ][ "prefix" ] = prefix;
  2704. return false;
  2705. }
  2706. });
  2707. // Set event and duration names for later use
  2708. props[ test ][ "duration" ] =
  2709. $.camelCase( props[ test ][ "prefix" ] + test + "-" + "duration" );
  2710. props[ test ][ "event" ] =
  2711. $.camelCase( props[ test ][ "prefix" ] + test + "-" + "end" );
  2712. // All lower case if not a vendor prop
  2713. if ( props[ test ][ "prefix" ] === "" ) {
  2714. props[ test ][ "event" ] = props[ test ][ "event" ].toLowerCase();
  2715. }
  2716. });
  2717. // If a valid prefix was found then the it is supported by the browser
  2718. $.support.cssTransitions = ( props[ "transition" ][ "prefix" ] !== undefined );
  2719. $.support.cssAnimations = ( props[ "animation" ][ "prefix" ] !== undefined );
  2720. // Remove the testElement
  2721. $( testElement ).remove();
  2722. // Animation complete callback
  2723. $.fn.animationComplete = function( callback, type, fallbackTime ) {
  2724. var timer, duration,
  2725. that = this,
  2726. eventBinding = function() {
  2727. // Clear the timer so we don't call callback twice
  2728. clearTimeout( timer );
  2729. callback.apply( this, arguments );
  2730. },
  2731. animationType = ( !type || type === "animation" ) ? "animation" : "transition";
  2732. // Make sure selected type is supported by browser
  2733. if ( ( $.support.cssTransitions && animationType === "transition" ) ||
  2734. ( $.support.cssAnimations && animationType === "animation" ) ) {
  2735. // If a fallback time was not passed set one
  2736. if ( fallbackTime === undefined ) {
  2737. // Make sure the was not bound to document before checking .css
  2738. if ( $( this ).context !== document ) {
  2739. // Parse the durration since its in second multiple by 1000 for milliseconds
  2740. // Multiply by 3 to make sure we give the animation plenty of time.
  2741. duration = parseFloat(
  2742. $( this ).css( props[ animationType ].duration )
  2743. ) * 3000;
  2744. }
  2745. // If we could not read a duration use the default
  2746. if ( duration === 0 || duration === undefined || isNaN( duration ) ) {
  2747. duration = $.fn.animationComplete.defaultDuration;
  2748. }
  2749. }
  2750. // Sets up the fallback if event never comes
  2751. timer = setTimeout( function() {
  2752. $( that ).off( props[ animationType ].event, eventBinding );
  2753. callback.apply( that );
  2754. }, duration );
  2755. // Bind the event
  2756. return $( this ).one( props[ animationType ].event, eventBinding );
  2757. } else {
  2758. // CSS animation / transitions not supported
  2759. // Defer execution for consistency between webkit/non webkit
  2760. setTimeout( $.proxy( callback, this ), 0 );
  2761. return $( this );
  2762. }
  2763. };
  2764. // Allow default callback to be configured on mobileInit
  2765. $.fn.animationComplete.defaultDuration = 1000;
  2766. })( jQuery );
  2767. // This plugin is an experiment for abstracting away the touch and mouse
  2768. // events so that developers don't have to worry about which method of input
  2769. // the device their document is loaded on supports.
  2770. //
  2771. // The idea here is to allow the developer to register listeners for the
  2772. // basic mouse events, such as mousedown, mousemove, mouseup, and click,
  2773. // and the plugin will take care of registering the correct listeners
  2774. // behind the scenes to invoke the listener at the fastest possible time
  2775. // for that device, while still retaining the order of event firing in
  2776. // the traditional mouse environment, should multiple handlers be registered
  2777. // on the same element for different events.
  2778. //
  2779. // The current version exposes the following virtual events to jQuery bind methods:
  2780. // "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel"
  2781. (function( $, window, document, undefined ) {
  2782. var dataPropertyName = "virtualMouseBindings",
  2783. touchTargetPropertyName = "virtualTouchID",
  2784. virtualEventNames = "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split( " " ),
  2785. touchEventProps = "clientX clientY pageX pageY screenX screenY".split( " " ),
  2786. mouseHookProps = $.event.mouseHooks ? $.event.mouseHooks.props : [],
  2787. mouseEventProps = $.event.props.concat( mouseHookProps ),
  2788. activeDocHandlers = {},
  2789. resetTimerID = 0,
  2790. startX = 0,
  2791. startY = 0,
  2792. didScroll = false,
  2793. clickBlockList = [],
  2794. blockMouseTriggers = false,
  2795. blockTouchTriggers = false,
  2796. eventCaptureSupported = "addEventListener" in document,
  2797. $document = $( document ),
  2798. nextTouchID = 1,
  2799. lastTouchID = 0, threshold,
  2800. i;
  2801. $.vmouse = {
  2802. moveDistanceThreshold: 10,
  2803. clickDistanceThreshold: 10,
  2804. resetTimerDuration: 1500
  2805. };
  2806. function getNativeEvent( event ) {
  2807. while ( event && typeof event.originalEvent !== "undefined" ) {
  2808. event = event.originalEvent;
  2809. }
  2810. return event;
  2811. }
  2812. function createVirtualEvent( event, eventType ) {
  2813. var t = event.type,
  2814. oe, props, ne, prop, ct, touch, i, j, len;
  2815. event = $.Event( event );
  2816. event.type = eventType;
  2817. oe = event.originalEvent;
  2818. props = $.event.props;
  2819. // addresses separation of $.event.props in to $.event.mouseHook.props and Issue 3280
  2820. // https://github.com/jquery/jquery-mobile/issues/3280
  2821. if ( t.search( /^(mouse|click)/ ) > -1 ) {
  2822. props = mouseEventProps;
  2823. }
  2824. // copy original event properties over to the new event
  2825. // this would happen if we could call $.event.fix instead of $.Event
  2826. // but we don't have a way to force an event to be fixed multiple times
  2827. if ( oe ) {
  2828. for ( i = props.length, prop; i; ) {
  2829. prop = props[ --i ];
  2830. event[ prop ] = oe[ prop ];
  2831. }
  2832. }
  2833. // make sure that if the mouse and click virtual events are generated
  2834. // without a .which one is defined
  2835. if ( t.search(/mouse(down|up)|click/) > -1 && !event.which ) {
  2836. event.which = 1;
  2837. }
  2838. if ( t.search(/^touch/) !== -1 ) {
  2839. ne = getNativeEvent( oe );
  2840. t = ne.touches;
  2841. ct = ne.changedTouches;
  2842. touch = ( t && t.length ) ? t[0] : ( ( ct && ct.length ) ? ct[ 0 ] : undefined );
  2843. if ( touch ) {
  2844. for ( j = 0, len = touchEventProps.length; j < len; j++) {
  2845. prop = touchEventProps[ j ];
  2846. event[ prop ] = touch[ prop ];
  2847. }
  2848. }
  2849. }
  2850. return event;
  2851. }
  2852. function getVirtualBindingFlags( element ) {
  2853. var flags = {},
  2854. b, k;
  2855. while ( element ) {
  2856. b = $.data( element, dataPropertyName );
  2857. for ( k in b ) {
  2858. if ( b[ k ] ) {
  2859. flags[ k ] = flags.hasVirtualBinding = true;
  2860. }
  2861. }
  2862. element = element.parentNode;
  2863. }
  2864. return flags;
  2865. }
  2866. function getClosestElementWithVirtualBinding( element, eventType ) {
  2867. var b;
  2868. while ( element ) {
  2869. b = $.data( element, dataPropertyName );
  2870. if ( b && ( !eventType || b[ eventType ] ) ) {
  2871. return element;
  2872. }
  2873. element = element.parentNode;
  2874. }
  2875. return null;
  2876. }
  2877. function enableTouchBindings() {
  2878. blockTouchTriggers = false;
  2879. }
  2880. function disableTouchBindings() {
  2881. blockTouchTriggers = true;
  2882. }
  2883. function enableMouseBindings() {
  2884. lastTouchID = 0;
  2885. clickBlockList.length = 0;
  2886. blockMouseTriggers = false;
  2887. // When mouse bindings are enabled, our
  2888. // touch bindings are disabled.
  2889. disableTouchBindings();
  2890. }
  2891. function disableMouseBindings() {
  2892. // When mouse bindings are disabled, our
  2893. // touch bindings are enabled.
  2894. enableTouchBindings();
  2895. }
  2896. function startResetTimer() {
  2897. clearResetTimer();
  2898. resetTimerID = setTimeout( function() {
  2899. resetTimerID = 0;
  2900. enableMouseBindings();
  2901. }, $.vmouse.resetTimerDuration );
  2902. }
  2903. function clearResetTimer() {
  2904. if ( resetTimerID ) {
  2905. clearTimeout( resetTimerID );
  2906. resetTimerID = 0;
  2907. }
  2908. }
  2909. function triggerVirtualEvent( eventType, event, flags ) {
  2910. var ve;
  2911. if ( ( flags && flags[ eventType ] ) ||
  2912. ( !flags && getClosestElementWithVirtualBinding( event.target, eventType ) ) ) {
  2913. ve = createVirtualEvent( event, eventType );
  2914. $( event.target).trigger( ve );
  2915. }
  2916. return ve;
  2917. }
  2918. function mouseEventCallback( event ) {
  2919. var touchID = $.data( event.target, touchTargetPropertyName ),
  2920. ve;
  2921. if ( !blockMouseTriggers && ( !lastTouchID || lastTouchID !== touchID ) ) {
  2922. ve = triggerVirtualEvent( "v" + event.type, event );
  2923. if ( ve ) {
  2924. if ( ve.isDefaultPrevented() ) {
  2925. event.preventDefault();
  2926. }
  2927. if ( ve.isPropagationStopped() ) {
  2928. event.stopPropagation();
  2929. }
  2930. if ( ve.isImmediatePropagationStopped() ) {
  2931. event.stopImmediatePropagation();
  2932. }
  2933. }
  2934. }
  2935. }
  2936. function handleTouchStart( event ) {
  2937. var touches = getNativeEvent( event ).touches,
  2938. target, flags, t;
  2939. if ( touches && touches.length === 1 ) {
  2940. target = event.target;
  2941. flags = getVirtualBindingFlags( target );
  2942. if ( flags.hasVirtualBinding ) {
  2943. lastTouchID = nextTouchID++;
  2944. $.data( target, touchTargetPropertyName, lastTouchID );
  2945. clearResetTimer();
  2946. disableMouseBindings();
  2947. didScroll = false;
  2948. t = getNativeEvent( event ).touches[ 0 ];
  2949. startX = t.pageX;
  2950. startY = t.pageY;
  2951. triggerVirtualEvent( "vmouseover", event, flags );
  2952. triggerVirtualEvent( "vmousedown", event, flags );
  2953. }
  2954. }
  2955. }
  2956. function handleScroll( event ) {
  2957. if ( blockTouchTriggers ) {
  2958. return;
  2959. }
  2960. if ( !didScroll ) {
  2961. triggerVirtualEvent( "vmousecancel", event, getVirtualBindingFlags( event.target ) );
  2962. }
  2963. didScroll = true;
  2964. startResetTimer();
  2965. }
  2966. function handleTouchMove( event ) {
  2967. if ( blockTouchTriggers ) {
  2968. return;
  2969. }
  2970. var t = getNativeEvent( event ).touches[ 0 ],
  2971. didCancel = didScroll,
  2972. moveThreshold = $.vmouse.moveDistanceThreshold,
  2973. flags = getVirtualBindingFlags( event.target );
  2974. didScroll = didScroll ||
  2975. ( Math.abs( t.pageX - startX ) > moveThreshold ||
  2976. Math.abs( t.pageY - startY ) > moveThreshold );
  2977. if ( didScroll && !didCancel ) {
  2978. triggerVirtualEvent( "vmousecancel", event, flags );
  2979. }
  2980. triggerVirtualEvent( "vmousemove", event, flags );
  2981. startResetTimer();
  2982. }
  2983. function handleTouchEnd( event ) {
  2984. if ( blockTouchTriggers ) {
  2985. return;
  2986. }
  2987. disableTouchBindings();
  2988. var flags = getVirtualBindingFlags( event.target ),
  2989. ve, t;
  2990. triggerVirtualEvent( "vmouseup", event, flags );
  2991. if ( !didScroll ) {
  2992. ve = triggerVirtualEvent( "vclick", event, flags );
  2993. if ( ve && ve.isDefaultPrevented() ) {
  2994. // The target of the mouse events that follow the touchend
  2995. // event don't necessarily match the target used during the
  2996. // touch. This means we need to rely on coordinates for blocking
  2997. // any click that is generated.
  2998. t = getNativeEvent( event ).changedTouches[ 0 ];
  2999. clickBlockList.push({
  3000. touchID: lastTouchID,
  3001. x: t.clientX,
  3002. y: t.clientY
  3003. });
  3004. // Prevent any mouse events that follow from triggering
  3005. // virtual event notifications.
  3006. blockMouseTriggers = true;
  3007. }
  3008. }
  3009. triggerVirtualEvent( "vmouseout", event, flags);
  3010. didScroll = false;
  3011. startResetTimer();
  3012. }
  3013. function hasVirtualBindings( ele ) {
  3014. var bindings = $.data( ele, dataPropertyName ),
  3015. k;
  3016. if ( bindings ) {
  3017. for ( k in bindings ) {
  3018. if ( bindings[ k ] ) {
  3019. return true;
  3020. }
  3021. }
  3022. }
  3023. return false;
  3024. }
  3025. function dummyMouseHandler() {}
  3026. function getSpecialEventObject( eventType ) {
  3027. var realType = eventType.substr( 1 );
  3028. return {
  3029. setup: function(/* data, namespace */) {
  3030. // If this is the first virtual mouse binding for this element,
  3031. // add a bindings object to its data.
  3032. if ( !hasVirtualBindings( this ) ) {
  3033. $.data( this, dataPropertyName, {} );
  3034. }
  3035. // If setup is called, we know it is the first binding for this
  3036. // eventType, so initialize the count for the eventType to zero.
  3037. var bindings = $.data( this, dataPropertyName );
  3038. bindings[ eventType ] = true;
  3039. // If this is the first virtual mouse event for this type,
  3040. // register a global handler on the document.
  3041. activeDocHandlers[ eventType ] = ( activeDocHandlers[ eventType ] || 0 ) + 1;
  3042. if ( activeDocHandlers[ eventType ] === 1 ) {
  3043. $document.bind( realType, mouseEventCallback );
  3044. }
  3045. // Some browsers, like Opera Mini, won't dispatch mouse/click events
  3046. // for elements unless they actually have handlers registered on them.
  3047. // To get around this, we register dummy handlers on the elements.
  3048. $( this ).bind( realType, dummyMouseHandler );
  3049. // For now, if event capture is not supported, we rely on mouse handlers.
  3050. if ( eventCaptureSupported ) {
  3051. // If this is the first virtual mouse binding for the document,
  3052. // register our touchstart handler on the document.
  3053. activeDocHandlers[ "touchstart" ] = ( activeDocHandlers[ "touchstart" ] || 0) + 1;
  3054. if ( activeDocHandlers[ "touchstart" ] === 1 ) {
  3055. $document.bind( "touchstart", handleTouchStart )
  3056. .bind( "touchend", handleTouchEnd )
  3057. // On touch platforms, touching the screen and then dragging your finger
  3058. // causes the window content to scroll after some distance threshold is
  3059. // exceeded. On these platforms, a scroll prevents a click event from being
  3060. // dispatched, and on some platforms, even the touchend is suppressed. To
  3061. // mimic the suppression of the click event, we need to watch for a scroll
  3062. // event. Unfortunately, some platforms like iOS don't dispatch scroll
  3063. // events until *AFTER* the user lifts their finger (touchend). This means
  3064. // we need to watch both scroll and touchmove events to figure out whether
  3065. // or not a scroll happenens before the touchend event is fired.
  3066. .bind( "touchmove", handleTouchMove )
  3067. .bind( "scroll", handleScroll );
  3068. }
  3069. }
  3070. },
  3071. teardown: function(/* data, namespace */) {
  3072. // If this is the last virtual binding for this eventType,
  3073. // remove its global handler from the document.
  3074. --activeDocHandlers[ eventType ];
  3075. if ( !activeDocHandlers[ eventType ] ) {
  3076. $document.unbind( realType, mouseEventCallback );
  3077. }
  3078. if ( eventCaptureSupported ) {
  3079. // If this is the last virtual mouse binding in existence,
  3080. // remove our document touchstart listener.
  3081. --activeDocHandlers[ "touchstart" ];
  3082. if ( !activeDocHandlers[ "touchstart" ] ) {
  3083. $document.unbind( "touchstart", handleTouchStart )
  3084. .unbind( "touchmove", handleTouchMove )
  3085. .unbind( "touchend", handleTouchEnd )
  3086. .unbind( "scroll", handleScroll );
  3087. }
  3088. }
  3089. var $this = $( this ),
  3090. bindings = $.data( this, dataPropertyName );
  3091. // teardown may be called when an element was
  3092. // removed from the DOM. If this is the case,
  3093. // jQuery core may have already stripped the element
  3094. // of any data bindings so we need to check it before
  3095. // using it.
  3096. if ( bindings ) {
  3097. bindings[ eventType ] = false;
  3098. }
  3099. // Unregister the dummy event handler.
  3100. $this.unbind( realType, dummyMouseHandler );
  3101. // If this is the last virtual mouse binding on the
  3102. // element, remove the binding data from the element.
  3103. if ( !hasVirtualBindings( this ) ) {
  3104. $this.removeData( dataPropertyName );
  3105. }
  3106. }
  3107. };
  3108. }
  3109. // Expose our custom events to the jQuery bind/unbind mechanism.
  3110. for ( i = 0; i < virtualEventNames.length; i++ ) {
  3111. $.event.special[ virtualEventNames[ i ] ] = getSpecialEventObject( virtualEventNames[ i ] );
  3112. }
  3113. // Add a capture click handler to block clicks.
  3114. // Note that we require event capture support for this so if the device
  3115. // doesn't support it, we punt for now and rely solely on mouse events.
  3116. if ( eventCaptureSupported ) {
  3117. document.addEventListener( "click", function( e ) {
  3118. var cnt = clickBlockList.length,
  3119. target = e.target,
  3120. x, y, ele, i, o, touchID;
  3121. if ( cnt ) {
  3122. x = e.clientX;
  3123. y = e.clientY;
  3124. threshold = $.vmouse.clickDistanceThreshold;
  3125. // The idea here is to run through the clickBlockList to see if
  3126. // the current click event is in the proximity of one of our
  3127. // vclick events that had preventDefault() called on it. If we find
  3128. // one, then we block the click.
  3129. //
  3130. // Why do we have to rely on proximity?
  3131. //
  3132. // Because the target of the touch event that triggered the vclick
  3133. // can be different from the target of the click event synthesized
  3134. // by the browser. The target of a mouse/click event that is synthesized
  3135. // from a touch event seems to be implementation specific. For example,
  3136. // some browsers will fire mouse/click events for a link that is near
  3137. // a touch event, even though the target of the touchstart/touchend event
  3138. // says the user touched outside the link. Also, it seems that with most
  3139. // browsers, the target of the mouse/click event is not calculated until the
  3140. // time it is dispatched, so if you replace an element that you touched
  3141. // with another element, the target of the mouse/click will be the new
  3142. // element underneath that point.
  3143. //
  3144. // Aside from proximity, we also check to see if the target and any
  3145. // of its ancestors were the ones that blocked a click. This is necessary
  3146. // because of the strange mouse/click target calculation done in the
  3147. // Android 2.1 browser, where if you click on an element, and there is a
  3148. // mouse/click handler on one of its ancestors, the target will be the
  3149. // innermost child of the touched element, even if that child is no where
  3150. // near the point of touch.
  3151. ele = target;
  3152. while ( ele ) {
  3153. for ( i = 0; i < cnt; i++ ) {
  3154. o = clickBlockList[ i ];
  3155. touchID = 0;
  3156. if ( ( ele === target && Math.abs( o.x - x ) < threshold && Math.abs( o.y - y ) < threshold ) ||
  3157. $.data( ele, touchTargetPropertyName ) === o.touchID ) {
  3158. // XXX: We may want to consider removing matches from the block list
  3159. // instead of waiting for the reset timer to fire.
  3160. e.preventDefault();
  3161. e.stopPropagation();
  3162. return;
  3163. }
  3164. }
  3165. ele = ele.parentNode;
  3166. }
  3167. }
  3168. }, true);
  3169. }
  3170. })( jQuery, window, document );
  3171. (function( $, window, undefined ) {
  3172. var $document = $( document ),
  3173. supportTouch = $.mobile.support.touch,
  3174. scrollEvent = "touchmove scroll",
  3175. touchStartEvent = supportTouch ? "touchstart" : "mousedown",
  3176. touchStopEvent = supportTouch ? "touchend" : "mouseup",
  3177. touchMoveEvent = supportTouch ? "touchmove" : "mousemove";
  3178. // setup new event shortcuts
  3179. $.each( ( "touchstart touchmove touchend " +
  3180. "tap taphold " +
  3181. "swipe swipeleft swiperight " +
  3182. "scrollstart scrollstop" ).split( " " ), function( i, name ) {
  3183. $.fn[ name ] = function( fn ) {
  3184. return fn ? this.bind( name, fn ) : this.trigger( name );
  3185. };
  3186. // jQuery < 1.8
  3187. if ( $.attrFn ) {
  3188. $.attrFn[ name ] = true;
  3189. }
  3190. });
  3191. function triggerCustomEvent( obj, eventType, event, bubble ) {
  3192. var originalType = event.type;
  3193. event.type = eventType;
  3194. if ( bubble ) {
  3195. $.event.trigger( event, undefined, obj );
  3196. } else {
  3197. $.event.dispatch.call( obj, event );
  3198. }
  3199. event.type = originalType;
  3200. }
  3201. // also handles scrollstop
  3202. $.event.special.scrollstart = {
  3203. enabled: true,
  3204. setup: function() {
  3205. var thisObject = this,
  3206. $this = $( thisObject ),
  3207. scrolling,
  3208. timer;
  3209. function trigger( event, state ) {
  3210. scrolling = state;
  3211. triggerCustomEvent( thisObject, scrolling ? "scrollstart" : "scrollstop", event );
  3212. }
  3213. // iPhone triggers scroll after a small delay; use touchmove instead
  3214. $this.bind( scrollEvent, function( event ) {
  3215. if ( !$.event.special.scrollstart.enabled ) {
  3216. return;
  3217. }
  3218. if ( !scrolling ) {
  3219. trigger( event, true );
  3220. }
  3221. clearTimeout( timer );
  3222. timer = setTimeout( function() {
  3223. trigger( event, false );
  3224. }, 50 );
  3225. });
  3226. },
  3227. teardown: function() {
  3228. $( this ).unbind( scrollEvent );
  3229. }
  3230. };
  3231. // also handles taphold
  3232. $.event.special.tap = {
  3233. tapholdThreshold: 750,
  3234. emitTapOnTaphold: true,
  3235. setup: function() {
  3236. var thisObject = this,
  3237. $this = $( thisObject ),
  3238. isTaphold = false;
  3239. $this.bind( "vmousedown", function( event ) {
  3240. isTaphold = false;
  3241. if ( event.which && event.which !== 1 ) {
  3242. return false;
  3243. }
  3244. var origTarget = event.target,
  3245. timer;
  3246. function clearTapTimer() {
  3247. clearTimeout( timer );
  3248. }
  3249. function clearTapHandlers() {
  3250. clearTapTimer();
  3251. $this.unbind( "vclick", clickHandler )
  3252. .unbind( "vmouseup", clearTapTimer );
  3253. $document.unbind( "vmousecancel", clearTapHandlers );
  3254. }
  3255. function clickHandler( event ) {
  3256. clearTapHandlers();
  3257. // ONLY trigger a 'tap' event if the start target is
  3258. // the same as the stop target.
  3259. if ( !isTaphold && origTarget === event.target ) {
  3260. triggerCustomEvent( thisObject, "tap", event );
  3261. } else if ( isTaphold ) {
  3262. event.preventDefault();
  3263. }
  3264. }
  3265. $this.bind( "vmouseup", clearTapTimer )
  3266. .bind( "vclick", clickHandler );
  3267. $document.bind( "vmousecancel", clearTapHandlers );
  3268. timer = setTimeout( function() {
  3269. if ( !$.event.special.tap.emitTapOnTaphold ) {
  3270. isTaphold = true;
  3271. }
  3272. triggerCustomEvent( thisObject, "taphold", $.Event( "taphold", { target: origTarget } ) );
  3273. }, $.event.special.tap.tapholdThreshold );
  3274. });
  3275. },
  3276. teardown: function() {
  3277. $( this ).unbind( "vmousedown" ).unbind( "vclick" ).unbind( "vmouseup" );
  3278. $document.unbind( "vmousecancel" );
  3279. }
  3280. };
  3281. // Also handles swipeleft, swiperight
  3282. $.event.special.swipe = {
  3283. // More than this horizontal displacement, and we will suppress scrolling.
  3284. scrollSupressionThreshold: 30,
  3285. // More time than this, and it isn't a swipe.
  3286. durationThreshold: 1000,
  3287. // Swipe horizontal displacement must be more than this.
  3288. horizontalDistanceThreshold: 30,
  3289. // Swipe vertical displacement must be less than this.
  3290. verticalDistanceThreshold: 30,
  3291. getLocation: function ( event ) {
  3292. var winPageX = window.pageXOffset,
  3293. winPageY = window.pageYOffset,
  3294. x = event.clientX,
  3295. y = event.clientY;
  3296. if ( event.pageY === 0 && Math.floor( y ) > Math.floor( event.pageY ) ||
  3297. event.pageX === 0 && Math.floor( x ) > Math.floor( event.pageX ) ) {
  3298. // iOS4 clientX/clientY have the value that should have been
  3299. // in pageX/pageY. While pageX/page/ have the value 0
  3300. x = x - winPageX;
  3301. y = y - winPageY;
  3302. } else if ( y < ( event.pageY - winPageY) || x < ( event.pageX - winPageX ) ) {
  3303. // Some Android browsers have totally bogus values for clientX/Y
  3304. // when scrolling/zooming a page. Detectable since clientX/clientY
  3305. // should never be smaller than pageX/pageY minus page scroll
  3306. x = event.pageX - winPageX;
  3307. y = event.pageY - winPageY;
  3308. }
  3309. return {
  3310. x: x,
  3311. y: y
  3312. };
  3313. },
  3314. start: function( event ) {
  3315. var data = event.originalEvent.touches ?
  3316. event.originalEvent.touches[ 0 ] : event,
  3317. location = $.event.special.swipe.getLocation( data );
  3318. return {
  3319. time: ( new Date() ).getTime(),
  3320. coords: [ location.x, location.y ],
  3321. origin: $( event.target )
  3322. };
  3323. },
  3324. stop: function( event ) {
  3325. var data = event.originalEvent.touches ?
  3326. event.originalEvent.touches[ 0 ] : event,
  3327. location = $.event.special.swipe.getLocation( data );
  3328. return {
  3329. time: ( new Date() ).getTime(),
  3330. coords: [ location.x, location.y ]
  3331. };
  3332. },
  3333. handleSwipe: function( start, stop, thisObject, origTarget ) {
  3334. if ( stop.time - start.time < $.event.special.swipe.durationThreshold &&
  3335. Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold &&
  3336. Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) {
  3337. var direction = start.coords[0] > stop.coords[ 0 ] ? "swipeleft" : "swiperight";
  3338. triggerCustomEvent( thisObject, "swipe", $.Event( "swipe", { target: origTarget, swipestart: start, swipestop: stop }), true );
  3339. triggerCustomEvent( thisObject, direction,$.Event( direction, { target: origTarget, swipestart: start, swipestop: stop } ), true );
  3340. return true;
  3341. }
  3342. return false;
  3343. },
  3344. // This serves as a flag to ensure that at most one swipe event event is
  3345. // in work at any given time
  3346. eventInProgress: false,
  3347. setup: function() {
  3348. var events,
  3349. thisObject = this,
  3350. $this = $( thisObject ),
  3351. context = {};
  3352. // Retrieve the events data for this element and add the swipe context
  3353. events = $.data( this, "mobile-events" );
  3354. if ( !events ) {
  3355. events = { length: 0 };
  3356. $.data( this, "mobile-events", events );
  3357. }
  3358. events.length++;
  3359. events.swipe = context;
  3360. context.start = function( event ) {
  3361. // Bail if we're already working on a swipe event
  3362. if ( $.event.special.swipe.eventInProgress ) {
  3363. return;
  3364. }
  3365. $.event.special.swipe.eventInProgress = true;
  3366. var stop,
  3367. start = $.event.special.swipe.start( event ),
  3368. origTarget = event.target,
  3369. emitted = false;
  3370. context.move = function( event ) {
  3371. if ( !start || event.isDefaultPrevented() ) {
  3372. return;
  3373. }
  3374. stop = $.event.special.swipe.stop( event );
  3375. if ( !emitted ) {
  3376. emitted = $.event.special.swipe.handleSwipe( start, stop, thisObject, origTarget );
  3377. if ( emitted ) {
  3378. // Reset the context to make way for the next swipe event
  3379. $.event.special.swipe.eventInProgress = false;
  3380. }
  3381. }
  3382. // prevent scrolling
  3383. if ( Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.scrollSupressionThreshold ) {
  3384. event.preventDefault();
  3385. }
  3386. };
  3387. context.stop = function() {
  3388. emitted = true;
  3389. // Reset the context to make way for the next swipe event
  3390. $.event.special.swipe.eventInProgress = false;
  3391. $document.off( touchMoveEvent, context.move );
  3392. context.move = null;
  3393. };
  3394. $document.on( touchMoveEvent, context.move )
  3395. .one( touchStopEvent, context.stop );
  3396. };
  3397. $this.on( touchStartEvent, context.start );
  3398. },
  3399. teardown: function() {
  3400. var events, context;
  3401. events = $.data( this, "mobile-events" );
  3402. if ( events ) {
  3403. context = events.swipe;
  3404. delete events.swipe;
  3405. events.length--;
  3406. if ( events.length === 0 ) {
  3407. $.removeData( this, "mobile-events" );
  3408. }
  3409. }
  3410. if ( context ) {
  3411. if ( context.start ) {
  3412. $( this ).off( touchStartEvent, context.start );
  3413. }
  3414. if ( context.move ) {
  3415. $document.off( touchMoveEvent, context.move );
  3416. }
  3417. if ( context.stop ) {
  3418. $document.off( touchStopEvent, context.stop );
  3419. }
  3420. }
  3421. }
  3422. };
  3423. $.each({
  3424. scrollstop: "scrollstart",
  3425. taphold: "tap",
  3426. swipeleft: "swipe.left",
  3427. swiperight: "swipe.right"
  3428. }, function( event, sourceEvent ) {
  3429. $.event.special[ event ] = {
  3430. setup: function() {
  3431. $( this ).bind( sourceEvent, $.noop );
  3432. },
  3433. teardown: function() {
  3434. $( this ).unbind( sourceEvent );
  3435. }
  3436. };
  3437. });
  3438. })( jQuery, this );
  3439. // throttled resize event
  3440. (function( $ ) {
  3441. $.event.special.throttledresize = {
  3442. setup: function() {
  3443. $( this ).bind( "resize", handler );
  3444. },
  3445. teardown: function() {
  3446. $( this ).unbind( "resize", handler );
  3447. }
  3448. };
  3449. var throttle = 250,
  3450. handler = function() {
  3451. curr = ( new Date() ).getTime();
  3452. diff = curr - lastCall;
  3453. if ( diff >= throttle ) {
  3454. lastCall = curr;
  3455. $( this ).trigger( "throttledresize" );
  3456. } else {
  3457. if ( heldCall ) {
  3458. clearTimeout( heldCall );
  3459. }
  3460. // Promise a held call will still execute
  3461. heldCall = setTimeout( handler, throttle - diff );
  3462. }
  3463. },
  3464. lastCall = 0,
  3465. heldCall,
  3466. curr,
  3467. diff;
  3468. })( jQuery );
  3469. (function( $, window ) {
  3470. var win = $( window ),
  3471. event_name = "orientationchange",
  3472. get_orientation,
  3473. last_orientation,
  3474. initial_orientation_is_landscape,
  3475. initial_orientation_is_default,
  3476. portrait_map = { "0": true, "180": true },
  3477. ww, wh, landscape_threshold;
  3478. // It seems that some device/browser vendors use window.orientation values 0 and 180 to
  3479. // denote the "default" orientation. For iOS devices, and most other smart-phones tested,
  3480. // the default orientation is always "portrait", but in some Android and RIM based tablets,
  3481. // the default orientation is "landscape". The following code attempts to use the window
  3482. // dimensions to figure out what the current orientation is, and then makes adjustments
  3483. // to the to the portrait_map if necessary, so that we can properly decode the
  3484. // window.orientation value whenever get_orientation() is called.
  3485. //
  3486. // Note that we used to use a media query to figure out what the orientation the browser
  3487. // thinks it is in:
  3488. //
  3489. // initial_orientation_is_landscape = $.mobile.media("all and (orientation: landscape)");
  3490. //
  3491. // but there was an iPhone/iPod Touch bug beginning with iOS 4.2, up through iOS 5.1,
  3492. // where the browser *ALWAYS* applied the landscape media query. This bug does not
  3493. // happen on iPad.
  3494. if ( $.support.orientation ) {
  3495. // Check the window width and height to figure out what the current orientation
  3496. // of the device is at this moment. Note that we've initialized the portrait map
  3497. // values to 0 and 180, *AND* we purposely check for landscape so that if we guess
  3498. // wrong, , we default to the assumption that portrait is the default orientation.
  3499. // We use a threshold check below because on some platforms like iOS, the iPhone
  3500. // form-factor can report a larger width than height if the user turns on the
  3501. // developer console. The actual threshold value is somewhat arbitrary, we just
  3502. // need to make sure it is large enough to exclude the developer console case.
  3503. ww = window.innerWidth || win.width();
  3504. wh = window.innerHeight || win.height();
  3505. landscape_threshold = 50;
  3506. initial_orientation_is_landscape = ww > wh && ( ww - wh ) > landscape_threshold;
  3507. // Now check to see if the current window.orientation is 0 or 180.
  3508. initial_orientation_is_default = portrait_map[ window.orientation ];
  3509. // If the initial orientation is landscape, but window.orientation reports 0 or 180, *OR*
  3510. // if the initial orientation is portrait, but window.orientation reports 90 or -90, we
  3511. // need to flip our portrait_map values because landscape is the default orientation for
  3512. // this device/browser.
  3513. if ( ( initial_orientation_is_landscape && initial_orientation_is_default ) || ( !initial_orientation_is_landscape && !initial_orientation_is_default ) ) {
  3514. portrait_map = { "-90": true, "90": true };
  3515. }
  3516. }
  3517. $.event.special.orientationchange = $.extend( {}, $.event.special.orientationchange, {
  3518. setup: function() {
  3519. // If the event is supported natively, return false so that jQuery
  3520. // will bind to the event using DOM methods.
  3521. if ( $.support.orientation && !$.event.special.orientationchange.disabled ) {
  3522. return false;
  3523. }
  3524. // Get the current orientation to avoid initial double-triggering.
  3525. last_orientation = get_orientation();
  3526. // Because the orientationchange event doesn't exist, simulate the
  3527. // event by testing window dimensions on resize.
  3528. win.bind( "throttledresize", handler );
  3529. },
  3530. teardown: function() {
  3531. // If the event is not supported natively, return false so that
  3532. // jQuery will unbind the event using DOM methods.
  3533. if ( $.support.orientation && !$.event.special.orientationchange.disabled ) {
  3534. return false;
  3535. }
  3536. // Because the orientationchange event doesn't exist, unbind the
  3537. // resize event handler.
  3538. win.unbind( "throttledresize", handler );
  3539. },
  3540. add: function( handleObj ) {
  3541. // Save a reference to the bound event handler.
  3542. var old_handler = handleObj.handler;
  3543. handleObj.handler = function( event ) {
  3544. // Modify event object, adding the .orientation property.
  3545. event.orientation = get_orientation();
  3546. // Call the originally-bound event handler and return its result.
  3547. return old_handler.apply( this, arguments );
  3548. };
  3549. }
  3550. });
  3551. // If the event is not supported natively, this handler will be bound to
  3552. // the window resize event to simulate the orientationchange event.
  3553. function handler() {
  3554. // Get the current orientation.
  3555. var orientation = get_orientation();
  3556. if ( orientation !== last_orientation ) {
  3557. // The orientation has changed, so trigger the orientationchange event.
  3558. last_orientation = orientation;
  3559. win.trigger( event_name );
  3560. }
  3561. }
  3562. // Get the current page orientation. This method is exposed publicly, should it
  3563. // be needed, as jQuery.event.special.orientationchange.orientation()
  3564. $.event.special.orientationchange.orientation = get_orientation = function() {
  3565. var isPortrait = true, elem = document.documentElement;
  3566. // prefer window orientation to the calculation based on screensize as
  3567. // the actual screen resize takes place before or after the orientation change event
  3568. // has been fired depending on implementation (eg android 2.3 is before, iphone after).
  3569. // More testing is required to determine if a more reliable method of determining the new screensize
  3570. // is possible when orientationchange is fired. (eg, use media queries + element + opacity)
  3571. if ( $.support.orientation ) {
  3572. // if the window orientation registers as 0 or 180 degrees report
  3573. // portrait, otherwise landscape
  3574. isPortrait = portrait_map[ window.orientation ];
  3575. } else {
  3576. isPortrait = elem && elem.clientWidth / elem.clientHeight < 1.1;
  3577. }
  3578. return isPortrait ? "portrait" : "landscape";
  3579. };
  3580. $.fn[ event_name ] = function( fn ) {
  3581. return fn ? this.bind( event_name, fn ) : this.trigger( event_name );
  3582. };
  3583. // jQuery < 1.8
  3584. if ( $.attrFn ) {
  3585. $.attrFn[ event_name ] = true;
  3586. }
  3587. }( jQuery, this ));
  3588. (function( $, undefined ) {
  3589. // existing base tag?
  3590. var baseElement = $( "head" ).children( "base" ),
  3591. // base element management, defined depending on dynamic base tag support
  3592. // TODO move to external widget
  3593. base = {
  3594. // define base element, for use in routing asset urls that are referenced
  3595. // in Ajax-requested markup
  3596. element: ( baseElement.length ? baseElement :
  3597. $( "<base>", { href: $.mobile.path.documentBase.hrefNoHash } ).prependTo( $( "head" ) ) ),
  3598. linkSelector: "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]",
  3599. // set the generated BASE element's href to a new page's base path
  3600. set: function( href ) {
  3601. // we should do nothing if the user wants to manage their url base
  3602. // manually
  3603. if ( !$.mobile.dynamicBaseEnabled ) {
  3604. return;
  3605. }
  3606. // we should use the base tag if we can manipulate it dynamically
  3607. if ( $.support.dynamicBaseTag ) {
  3608. base.element.attr( "href",
  3609. $.mobile.path.makeUrlAbsolute( href, $.mobile.path.documentBase ) );
  3610. }
  3611. },
  3612. rewrite: function( href, page ) {
  3613. var newPath = $.mobile.path.get( href );
  3614. page.find( base.linkSelector ).each(function( i, link ) {
  3615. var thisAttr = $( link ).is( "[href]" ) ? "href" :
  3616. $( link ).is( "[src]" ) ? "src" : "action",
  3617. theLocation = $.mobile.path.parseLocation(),
  3618. thisUrl = $( link ).attr( thisAttr );
  3619. // XXX_jblas: We need to fix this so that it removes the document
  3620. // base URL, and then prepends with the new page URL.
  3621. // if full path exists and is same, chop it - helps IE out
  3622. thisUrl = thisUrl.replace( theLocation.protocol + theLocation.doubleSlash +
  3623. theLocation.host + theLocation.pathname, "" );
  3624. if ( !/^(\w+:|#|\/)/.test( thisUrl ) ) {
  3625. $( link ).attr( thisAttr, newPath + thisUrl );
  3626. }
  3627. });
  3628. },
  3629. // set the generated BASE element's href to a new page's base path
  3630. reset: function(/* href */) {
  3631. base.element.attr( "href", $.mobile.path.documentBase.hrefNoSearch );
  3632. }
  3633. };
  3634. $.mobile.base = base;
  3635. })( jQuery );
  3636. (function( $, undefined ) {
  3637. $.mobile.widgets = {};
  3638. var originalWidget = $.widget,
  3639. // Record the original, non-mobileinit-modified version of $.mobile.keepNative
  3640. // so we can later determine whether someone has modified $.mobile.keepNative
  3641. keepNativeFactoryDefault = $.mobile.keepNative;
  3642. $.widget = (function( orig ) {
  3643. return function() {
  3644. var constructor = orig.apply( this, arguments ),
  3645. name = constructor.prototype.widgetName;
  3646. constructor.initSelector = ( ( constructor.prototype.initSelector !== undefined ) ?
  3647. constructor.prototype.initSelector : ":jqmData(role='" + name + "')" );
  3648. $.mobile.widgets[ name ] = constructor;
  3649. return constructor;
  3650. };
  3651. })( $.widget );
  3652. // Make sure $.widget still has bridge and extend methods
  3653. $.extend( $.widget, originalWidget );
  3654. // For backcompat remove in 1.5
  3655. $.mobile.document.on( "create", function( event ) {
  3656. $( event.target ).enhanceWithin();
  3657. });
  3658. $.widget( "mobile.page", {
  3659. options: {
  3660. theme: "a",
  3661. domCache: false,
  3662. // Deprecated in 1.4 remove in 1.5
  3663. keepNativeDefault: $.mobile.keepNative,
  3664. // Deprecated in 1.4 remove in 1.5
  3665. contentTheme: null,
  3666. enhanced: false
  3667. },
  3668. // DEPRECATED for > 1.4
  3669. // TODO remove at 1.5
  3670. _createWidget: function() {
  3671. $.Widget.prototype._createWidget.apply( this, arguments );
  3672. this._trigger( "init" );
  3673. },
  3674. _create: function() {
  3675. // If false is returned by the callbacks do not create the page
  3676. if ( this._trigger( "beforecreate" ) === false ) {
  3677. return false;
  3678. }
  3679. if ( !this.options.enhanced ) {
  3680. this._enhance();
  3681. }
  3682. this._on( this.element, {
  3683. pagebeforehide: "removeContainerBackground",
  3684. pagebeforeshow: "_handlePageBeforeShow"
  3685. });
  3686. this.element.enhanceWithin();
  3687. // Dialog widget is deprecated in 1.4 remove this in 1.5
  3688. if ( $.mobile.getAttribute( this.element[0], "role" ) === "dialog" && $.mobile.dialog ) {
  3689. this.element.dialog();
  3690. }
  3691. },
  3692. _enhance: function () {
  3693. var attrPrefix = "data-" + $.mobile.ns,
  3694. self = this;
  3695. if ( this.options.role ) {
  3696. this.element.attr( "data-" + $.mobile.ns + "role", this.options.role );
  3697. }
  3698. this.element
  3699. .attr( "tabindex", "0" )
  3700. .addClass( "ui-page ui-page-theme-" + this.options.theme );
  3701. // Manipulation of content os Deprecated as of 1.4 remove in 1.5
  3702. this.element.find( "[" + attrPrefix + "role='content']" ).each( function() {
  3703. var $this = $( this ),
  3704. theme = this.getAttribute( attrPrefix + "theme" ) || undefined;
  3705. self.options.contentTheme = theme || self.options.contentTheme || ( self.options.dialog && self.options.theme ) || ( self.element.jqmData("role") === "dialog" && self.options.theme );
  3706. $this.addClass( "ui-content" );
  3707. if ( self.options.contentTheme ) {
  3708. $this.addClass( "ui-body-" + ( self.options.contentTheme ) );
  3709. }
  3710. // Add ARIA role
  3711. $this.attr( "role", "main" ).addClass( "ui-content" );
  3712. });
  3713. },
  3714. bindRemove: function( callback ) {
  3715. var page = this.element;
  3716. // when dom caching is not enabled or the page is embedded bind to remove the page on hide
  3717. if ( !page.data( "mobile-page" ).options.domCache &&
  3718. page.is( ":jqmData(external-page='true')" ) ) {
  3719. // TODO use _on - that is, sort out why it doesn't work in this case
  3720. page.bind( "pagehide.remove", callback || function( e, data ) {
  3721. //check if this is a same page transition and if so don't remove the page
  3722. if( !data.samePage ){
  3723. var $this = $( this ),
  3724. prEvent = new $.Event( "pageremove" );
  3725. $this.trigger( prEvent );
  3726. if ( !prEvent.isDefaultPrevented() ) {
  3727. $this.removeWithDependents();
  3728. }
  3729. }
  3730. });
  3731. }
  3732. },
  3733. _setOptions: function( o ) {
  3734. if ( o.theme !== undefined ) {
  3735. this.element.removeClass( "ui-page-theme-" + this.options.theme ).addClass( "ui-page-theme-" + o.theme );
  3736. }
  3737. if ( o.contentTheme !== undefined ) {
  3738. this.element.find( "[data-" + $.mobile.ns + "='content']" ).removeClass( "ui-body-" + this.options.contentTheme )
  3739. .addClass( "ui-body-" + o.contentTheme );
  3740. }
  3741. },
  3742. _handlePageBeforeShow: function(/* e */) {
  3743. this.setContainerBackground();
  3744. },
  3745. // Deprecated in 1.4 remove in 1.5
  3746. removeContainerBackground: function() {
  3747. this.element.closest( ":mobile-pagecontainer" ).pagecontainer({ "theme": "none" });
  3748. },
  3749. // Deprecated in 1.4 remove in 1.5
  3750. // set the page container background to the page theme
  3751. setContainerBackground: function( theme ) {
  3752. this.element.parent().pagecontainer( { "theme": theme || this.options.theme } );
  3753. },
  3754. // Deprecated in 1.4 remove in 1.5
  3755. keepNativeSelector: function() {
  3756. var options = this.options,
  3757. keepNative = $.trim( options.keepNative || "" ),
  3758. globalValue = $.trim( $.mobile.keepNative ),
  3759. optionValue = $.trim( options.keepNativeDefault ),
  3760. // Check if $.mobile.keepNative has changed from the factory default
  3761. newDefault = ( keepNativeFactoryDefault === globalValue ?
  3762. "" : globalValue ),
  3763. // If $.mobile.keepNative has not changed, use options.keepNativeDefault
  3764. oldDefault = ( newDefault === "" ? optionValue : "" );
  3765. // Concatenate keepNative selectors from all sources where the value has
  3766. // changed or, if nothing has changed, return the default
  3767. return ( ( keepNative ? [ keepNative ] : [] )
  3768. .concat( newDefault ? [ newDefault ] : [] )
  3769. .concat( oldDefault ? [ oldDefault ] : [] )
  3770. .join( ", " ) );
  3771. }
  3772. });
  3773. })( jQuery );
  3774. (function( $, undefined ) {
  3775. $.widget( "mobile.pagecontainer", {
  3776. options: {
  3777. theme: "a"
  3778. },
  3779. initSelector: false,
  3780. _create: function() {
  3781. this._trigger( "beforecreate" );
  3782. this.setLastScrollEnabled = true;
  3783. this._on( this.window, {
  3784. // disable an scroll setting when a hashchange has been fired,
  3785. // this only works because the recording of the scroll position
  3786. // is delayed for 100ms after the browser might have changed the
  3787. // position because of the hashchange
  3788. navigate: "_disableRecordScroll",
  3789. // bind to scrollstop for the first page, "pagechange" won't be
  3790. // fired in that case
  3791. scrollstop: "_delayedRecordScroll"
  3792. });
  3793. // TODO consider moving the navigation handler OUT of widget into
  3794. // some other object as glue between the navigate event and the
  3795. // content widget load and change methods
  3796. this._on( this.window, { navigate: "_filterNavigateEvents" });
  3797. // TODO move from page* events to content* events
  3798. this._on({ pagechange: "_afterContentChange" });
  3799. // handle initial hashchange from chrome :(
  3800. this.window.one( "navigate", $.proxy(function() {
  3801. this.setLastScrollEnabled = true;
  3802. }, this));
  3803. },
  3804. _setOptions: function( options ) {
  3805. if ( options.theme !== undefined && options.theme !== "none" ) {
  3806. this.element.removeClass( "ui-overlay-" + this.options.theme )
  3807. .addClass( "ui-overlay-" + options.theme );
  3808. } else if ( options.theme !== undefined ) {
  3809. this.element.removeClass( "ui-overlay-" + this.options.theme );
  3810. }
  3811. this._super( options );
  3812. },
  3813. _disableRecordScroll: function() {
  3814. this.setLastScrollEnabled = false;
  3815. },
  3816. _enableRecordScroll: function() {
  3817. this.setLastScrollEnabled = true;
  3818. },
  3819. // TODO consider the name here, since it's purpose specific
  3820. _afterContentChange: function() {
  3821. // once the page has changed, re-enable the scroll recording
  3822. this.setLastScrollEnabled = true;
  3823. // remove any binding that previously existed on the get scroll
  3824. // which may or may not be different than the scroll element
  3825. // determined for this page previously
  3826. this._off( this.window, "scrollstop" );
  3827. // determine and bind to the current scoll element which may be the
  3828. // window or in the case of touch overflow the element touch overflow
  3829. this._on( this.window, { scrollstop: "_delayedRecordScroll" });
  3830. },
  3831. _recordScroll: function() {
  3832. // this barrier prevents setting the scroll value based on
  3833. // the browser scrolling the window based on a hashchange
  3834. if ( !this.setLastScrollEnabled ) {
  3835. return;
  3836. }
  3837. var active = this._getActiveHistory(),
  3838. currentScroll, minScroll, defaultScroll;
  3839. if ( active ) {
  3840. currentScroll = this._getScroll();
  3841. minScroll = this._getMinScroll();
  3842. defaultScroll = this._getDefaultScroll();
  3843. // Set active page's lastScroll prop. If the location we're
  3844. // scrolling to is less than minScrollBack, let it go.
  3845. active.lastScroll = currentScroll < minScroll ? defaultScroll : currentScroll;
  3846. }
  3847. },
  3848. _delayedRecordScroll: function() {
  3849. setTimeout( $.proxy(this, "_recordScroll"), 100 );
  3850. },
  3851. _getScroll: function() {
  3852. return this.window.scrollTop();
  3853. },
  3854. _getMinScroll: function() {
  3855. return $.mobile.minScrollBack;
  3856. },
  3857. _getDefaultScroll: function() {
  3858. return $.mobile.defaultHomeScroll;
  3859. },
  3860. _filterNavigateEvents: function( e, data ) {
  3861. var url;
  3862. if ( e.originalEvent && e.originalEvent.isDefaultPrevented() ) {
  3863. return;
  3864. }
  3865. url = e.originalEvent.type.indexOf( "hashchange" ) > -1 ? data.state.hash : data.state.url;
  3866. if ( !url ) {
  3867. url = this._getHash();
  3868. }
  3869. if ( !url || url === "#" || url.indexOf( "#" + $.mobile.path.uiStateKey ) === 0 ) {
  3870. url = location.href;
  3871. }
  3872. this._handleNavigate( url, data.state );
  3873. },
  3874. _getHash: function() {
  3875. return $.mobile.path.parseLocation().hash;
  3876. },
  3877. // TODO active page should be managed by the container (ie, it should be a property)
  3878. getActivePage: function() {
  3879. return this.activePage;
  3880. },
  3881. // TODO the first page should be a property set during _create using the logic
  3882. // that currently resides in init
  3883. _getInitialContent: function() {
  3884. return $.mobile.firstPage;
  3885. },
  3886. // TODO each content container should have a history object
  3887. _getHistory: function() {
  3888. return $.mobile.navigate.history;
  3889. },
  3890. _getActiveHistory: function() {
  3891. return this._getHistory().getActive();
  3892. },
  3893. // TODO the document base should be determined at creation
  3894. _getDocumentBase: function() {
  3895. return $.mobile.path.documentBase;
  3896. },
  3897. back: function() {
  3898. this.go( -1 );
  3899. },
  3900. forward: function() {
  3901. this.go( 1 );
  3902. },
  3903. go: function( steps ) {
  3904. //if hashlistening is enabled use native history method
  3905. if ( $.mobile.hashListeningEnabled ) {
  3906. window.history.go( steps );
  3907. } else {
  3908. //we are not listening to the hash so handle history internally
  3909. var activeIndex = $.mobile.navigate.history.activeIndex,
  3910. index = activeIndex + parseInt( steps, 10 ),
  3911. url = $.mobile.navigate.history.stack[ index ].url,
  3912. direction = ( steps >= 1 )? "forward" : "back";
  3913. //update the history object
  3914. $.mobile.navigate.history.activeIndex = index;
  3915. $.mobile.navigate.history.previousIndex = activeIndex;
  3916. //change to the new page
  3917. this.change( url, { direction: direction, changeHash: false, fromHashChange: true } );
  3918. }
  3919. },
  3920. // TODO rename _handleDestination
  3921. _handleDestination: function( to ) {
  3922. var history;
  3923. // clean the hash for comparison if it's a url
  3924. if ( $.type(to) === "string" ) {
  3925. to = $.mobile.path.stripHash( to );
  3926. }
  3927. if ( to ) {
  3928. history = this._getHistory();
  3929. // At this point, 'to' can be one of 3 things, a cached page
  3930. // element from a history stack entry, an id, or site-relative /
  3931. // absolute URL. If 'to' is an id, we need to resolve it against
  3932. // the documentBase, not the location.href, since the hashchange
  3933. // could've been the result of a forward/backward navigation
  3934. // that crosses from an external page/dialog to an internal
  3935. // page/dialog.
  3936. //
  3937. // TODO move check to history object or path object?
  3938. to = !$.mobile.path.isPath( to ) ? ( $.mobile.path.makeUrlAbsolute( "#" + to, this._getDocumentBase() ) ) : to;
  3939. }
  3940. return to || this._getInitialContent();
  3941. },
  3942. _transitionFromHistory: function( direction, defaultTransition ) {
  3943. var history = this._getHistory(),
  3944. entry = ( direction === "back" ? history.getLast() : history.getActive() );
  3945. return ( entry && entry.transition ) || defaultTransition;
  3946. },
  3947. _handleDialog: function( changePageOptions, data ) {
  3948. var to, active, activeContent = this.getActivePage();
  3949. // If current active page is not a dialog skip the dialog and continue
  3950. // in the same direction
  3951. // Note: The dialog widget is deprecated as of 1.4.0 and will be removed in 1.5.0.
  3952. // Thus, as of 1.5.0 activeContent.data( "mobile-dialog" ) will always evaluate to
  3953. // falsy, so the second condition in the if-statement below can be removed altogether.
  3954. if ( activeContent && !activeContent.data( "mobile-dialog" ) ) {
  3955. // determine if we're heading forward or backward and continue
  3956. // accordingly past the current dialog
  3957. if ( data.direction === "back" ) {
  3958. this.back();
  3959. } else {
  3960. this.forward();
  3961. }
  3962. // prevent changePage call
  3963. return false;
  3964. } else {
  3965. // if the current active page is a dialog and we're navigating
  3966. // to a dialog use the dialog objected saved in the stack
  3967. to = data.pageUrl;
  3968. active = this._getActiveHistory();
  3969. // make sure to set the role, transition and reversal
  3970. // as most of this is lost by the domCache cleaning
  3971. $.extend( changePageOptions, {
  3972. role: active.role,
  3973. transition: this._transitionFromHistory(
  3974. data.direction,
  3975. changePageOptions.transition ),
  3976. reverse: data.direction === "back"
  3977. });
  3978. }
  3979. return to;
  3980. },
  3981. _handleNavigate: function( url, data ) {
  3982. //find first page via hash
  3983. // TODO stripping the hash twice with handleUrl
  3984. var to = $.mobile.path.stripHash( url ), history = this._getHistory(),
  3985. // transition is false if it's the first page, undefined
  3986. // otherwise (and may be overridden by default)
  3987. transition = history.stack.length === 0 ? "none" :
  3988. this._transitionFromHistory( data.direction ),
  3989. // default options for the changPage calls made after examining
  3990. // the current state of the page and the hash, NOTE that the
  3991. // transition is derived from the previous history entry
  3992. changePageOptions = {
  3993. changeHash: false,
  3994. fromHashChange: true,
  3995. reverse: data.direction === "back"
  3996. };
  3997. $.extend( changePageOptions, data, {
  3998. transition: transition
  3999. });
  4000. // TODO move to _handleDestination ?
  4001. // If this isn't the first page, if the current url is a dialog hash
  4002. // key, and the initial destination isn't equal to the current target
  4003. // page, use the special dialog handling
  4004. if ( history.activeIndex > 0 &&
  4005. to.indexOf( $.mobile.dialogHashKey ) > -1 ) {
  4006. to = this._handleDialog( changePageOptions, data );
  4007. if ( to === false ) {
  4008. return;
  4009. }
  4010. }
  4011. this._changeContent( this._handleDestination( to ), changePageOptions );
  4012. },
  4013. _changeContent: function( to, opts ) {
  4014. $.mobile.changePage( to, opts );
  4015. },
  4016. _getBase: function() {
  4017. return $.mobile.base;
  4018. },
  4019. _getNs: function() {
  4020. return $.mobile.ns;
  4021. },
  4022. _enhance: function( content, role ) {
  4023. // TODO consider supporting a custom callback, and passing in
  4024. // the settings which includes the role
  4025. return content.page({ role: role });
  4026. },
  4027. _include: function( page, settings ) {
  4028. // append to page and enhance
  4029. page.appendTo( this.element );
  4030. // use the page widget to enhance
  4031. this._enhance( page, settings.role );
  4032. // remove page on hide
  4033. page.page( "bindRemove" );
  4034. },
  4035. _find: function( absUrl ) {
  4036. // TODO consider supporting a custom callback
  4037. var fileUrl = this._createFileUrl( absUrl ),
  4038. dataUrl = this._createDataUrl( absUrl ),
  4039. page, initialContent = this._getInitialContent();
  4040. // Check to see if the page already exists in the DOM.
  4041. // NOTE do _not_ use the :jqmData pseudo selector because parenthesis
  4042. // are a valid url char and it breaks on the first occurence
  4043. page = this.element
  4044. .children( "[data-" + this._getNs() +
  4045. "url='" + $.mobile.path.hashToSelector( dataUrl ) + "']" );
  4046. // If we failed to find the page, check to see if the url is a
  4047. // reference to an embedded page. If so, it may have been dynamically
  4048. // injected by a developer, in which case it would be lacking a
  4049. // data-url attribute and in need of enhancement.
  4050. if ( page.length === 0 && dataUrl && !$.mobile.path.isPath( dataUrl ) ) {
  4051. page = this.element.children( $.mobile.path.hashToSelector("#" + dataUrl) )
  4052. .attr( "data-" + this._getNs() + "url", dataUrl )
  4053. .jqmData( "url", dataUrl );
  4054. }
  4055. // If we failed to find a page in the DOM, check the URL to see if it
  4056. // refers to the first page in the application. Also check to make sure
  4057. // our cached-first-page is actually in the DOM. Some user deployed
  4058. // apps are pruning the first page from the DOM for various reasons.
  4059. // We check for this case here because we don't want a first-page with
  4060. // an id falling through to the non-existent embedded page error case.
  4061. if ( page.length === 0 &&
  4062. $.mobile.path.isFirstPageUrl( fileUrl ) &&
  4063. initialContent &&
  4064. initialContent.parent().length ) {
  4065. page = $( initialContent );
  4066. }
  4067. return page;
  4068. },
  4069. _getLoader: function() {
  4070. return $.mobile.loading();
  4071. },
  4072. _showLoading: function( delay, theme, msg, textonly ) {
  4073. // This configurable timeout allows cached pages a brief
  4074. // delay to load without showing a message
  4075. if ( this._loadMsg ) {
  4076. return;
  4077. }
  4078. this._loadMsg = setTimeout($.proxy(function() {
  4079. this._getLoader().loader( "show", theme, msg, textonly );
  4080. this._loadMsg = 0;
  4081. }, this), delay );
  4082. },
  4083. _hideLoading: function() {
  4084. // Stop message show timer
  4085. clearTimeout( this._loadMsg );
  4086. this._loadMsg = 0;
  4087. // Hide loading message
  4088. this._getLoader().loader( "hide" );
  4089. },
  4090. _showError: function() {
  4091. // make sure to remove the current loading message
  4092. this._hideLoading();
  4093. // show the error message
  4094. this._showLoading( 0, $.mobile.pageLoadErrorMessageTheme, $.mobile.pageLoadErrorMessage, true );
  4095. // hide the error message after a delay
  4096. // TODO configuration
  4097. setTimeout( $.proxy(this, "_hideLoading"), 1500 );
  4098. },
  4099. _parse: function( html, fileUrl ) {
  4100. // TODO consider allowing customization of this method. It's very JQM specific
  4101. var page, all = $( "<div></div>" );
  4102. //workaround to allow scripts to execute when included in page divs
  4103. all.get( 0 ).innerHTML = html;
  4104. page = all.find( ":jqmData(role='page'), :jqmData(role='dialog')" ).first();
  4105. //if page elem couldn't be found, create one and insert the body element's contents
  4106. if ( !page.length ) {
  4107. page = $( "<div data-" + this._getNs() + "role='page'>" +
  4108. ( html.split( /<\/?body[^>]*>/gmi )[1] || "" ) +
  4109. "</div>" );
  4110. }
  4111. // TODO tagging a page with external to make sure that embedded pages aren't
  4112. // removed by the various page handling code is bad. Having page handling code
  4113. // in many places is bad. Solutions post 1.0
  4114. page.attr( "data-" + this._getNs() + "url", this._createDataUrl( fileUrl ) )
  4115. .attr( "data-" + this._getNs() + "external-page", true );
  4116. return page;
  4117. },
  4118. _setLoadedTitle: function( page, html ) {
  4119. //page title regexp
  4120. var newPageTitle = html.match( /<title[^>]*>([^<]*)/ ) && RegExp.$1;
  4121. if ( newPageTitle && !page.jqmData("title") ) {
  4122. newPageTitle = $( "<div>" + newPageTitle + "</div>" ).text();
  4123. page.jqmData( "title", newPageTitle );
  4124. }
  4125. },
  4126. _isRewritableBaseTag: function() {
  4127. return $.mobile.dynamicBaseEnabled && !$.support.dynamicBaseTag;
  4128. },
  4129. _createDataUrl: function( absoluteUrl ) {
  4130. return $.mobile.path.convertUrlToDataUrl( absoluteUrl );
  4131. },
  4132. _createFileUrl: function( absoluteUrl ) {
  4133. return $.mobile.path.getFilePath( absoluteUrl );
  4134. },
  4135. _triggerWithDeprecated: function( name, data, page ) {
  4136. var deprecatedEvent = $.Event( "page" + name ),
  4137. newEvent = $.Event( this.widgetName + name );
  4138. // DEPRECATED
  4139. // trigger the old deprecated event on the page if it's provided
  4140. ( page || this.element ).trigger( deprecatedEvent, data );
  4141. // use the widget trigger method for the new content* event
  4142. this._trigger( name, newEvent, data );
  4143. return {
  4144. deprecatedEvent: deprecatedEvent,
  4145. event: newEvent
  4146. };
  4147. },
  4148. // TODO it would be nice to split this up more but everything appears to be "one off"
  4149. // or require ordering such that other bits are sprinkled in between parts that
  4150. // could be abstracted out as a group
  4151. _loadSuccess: function( absUrl, triggerData, settings, deferred ) {
  4152. var fileUrl = this._createFileUrl( absUrl );
  4153. return $.proxy(function( html, textStatus, xhr ) {
  4154. //pre-parse html to check for a data-url,
  4155. //use it as the new fileUrl, base path, etc
  4156. var content,
  4157. // TODO handle dialogs again
  4158. pageElemRegex = new RegExp( "(<[^>]+\\bdata-" + this._getNs() + "role=[\"']?page[\"']?[^>]*>)" ),
  4159. dataUrlRegex = new RegExp( "\\bdata-" + this._getNs() + "url=[\"']?([^\"'>]*)[\"']?" );
  4160. // data-url must be provided for the base tag so resource requests
  4161. // can be directed to the correct url. loading into a temprorary
  4162. // element makes these requests immediately
  4163. if ( pageElemRegex.test( html ) &&
  4164. RegExp.$1 &&
  4165. dataUrlRegex.test( RegExp.$1 ) &&
  4166. RegExp.$1 ) {
  4167. fileUrl = $.mobile.path.getFilePath( $("<div>" + RegExp.$1 + "</div>").text() );
  4168. // We specify that, if a data-url attribute is given on the page div, its value
  4169. // must be given non-URL-encoded. However, in this part of the code, fileUrl is
  4170. // assumed to be URL-encoded, so we URL-encode the retrieved value here
  4171. fileUrl = this.window[ 0 ].encodeURIComponent( fileUrl );
  4172. }
  4173. //dont update the base tag if we are prefetching
  4174. if ( settings.prefetch === undefined ) {
  4175. this._getBase().set( fileUrl );
  4176. }
  4177. content = this._parse( html, fileUrl );
  4178. this._setLoadedTitle( content, html );
  4179. // Add the content reference and xhr to our triggerData.
  4180. triggerData.xhr = xhr;
  4181. triggerData.textStatus = textStatus;
  4182. // DEPRECATED
  4183. triggerData.page = content;
  4184. triggerData.content = content;
  4185. triggerData.toPage = content;
  4186. // If the default behavior is prevented, stop here!
  4187. // Note that it is the responsibility of the listener/handler
  4188. // that called preventDefault(), to resolve/reject the
  4189. // deferred object within the triggerData.
  4190. if ( this._triggerWithDeprecated( "load", triggerData ).event.isDefaultPrevented() ) {
  4191. return;
  4192. }
  4193. // rewrite src and href attrs to use a base url if the base tag won't work
  4194. if ( this._isRewritableBaseTag() && content ) {
  4195. this._getBase().rewrite( fileUrl, content );
  4196. }
  4197. this._include( content, settings );
  4198. // Remove loading message.
  4199. if ( settings.showLoadMsg ) {
  4200. this._hideLoading();
  4201. }
  4202. deferred.resolve( absUrl, settings, content );
  4203. }, this);
  4204. },
  4205. _loadDefaults: {
  4206. type: "get",
  4207. data: undefined,
  4208. // DEPRECATED
  4209. reloadPage: false,
  4210. reload: false,
  4211. // By default we rely on the role defined by the @data-role attribute.
  4212. role: undefined,
  4213. showLoadMsg: false,
  4214. // This delay allows loads that pull from browser cache to
  4215. // occur without showing the loading message.
  4216. loadMsgDelay: 50
  4217. },
  4218. load: function( url, options ) {
  4219. // This function uses deferred notifications to let callers
  4220. // know when the content is done loading, or if an error has occurred.
  4221. var deferred = ( options && options.deferred ) || $.Deferred(),
  4222. // Examining the option "reloadPage" passed by the user is deprecated as of 1.4.0
  4223. // and will be removed in 1.5.0.
  4224. // Copy option "reloadPage" to "reload", but only if option "reload" is not present
  4225. reloadOptionExtension =
  4226. ( ( options && options.reload === undefined &&
  4227. options.reloadPage !== undefined ) ?
  4228. { reload: options.reloadPage } : {} ),
  4229. // The default load options with overrides specified by the caller.
  4230. settings = $.extend( {}, this._loadDefaults, options, reloadOptionExtension ),
  4231. // The DOM element for the content after it has been loaded.
  4232. content = null,
  4233. // The absolute version of the URL passed into the function. This
  4234. // version of the URL may contain dialog/subcontent params in it.
  4235. absUrl = $.mobile.path.makeUrlAbsolute( url, this._findBaseWithDefault() ),
  4236. fileUrl, dataUrl, pblEvent, triggerData;
  4237. // If the caller provided data, and we're using "get" request,
  4238. // append the data to the URL.
  4239. if ( settings.data && settings.type === "get" ) {
  4240. absUrl = $.mobile.path.addSearchParams( absUrl, settings.data );
  4241. settings.data = undefined;
  4242. }
  4243. // If the caller is using a "post" request, reload must be true
  4244. if ( settings.data && settings.type === "post" ) {
  4245. settings.reload = true;
  4246. }
  4247. // The absolute version of the URL minus any dialog/subcontent params.
  4248. // In otherwords the real URL of the content to be loaded.
  4249. fileUrl = this._createFileUrl( absUrl );
  4250. // The version of the Url actually stored in the data-url attribute of
  4251. // the content. For embedded content, it is just the id of the page. For
  4252. // content within the same domain as the document base, it is the site
  4253. // relative path. For cross-domain content (Phone Gap only) the entire
  4254. // absolute Url is used to load the content.
  4255. dataUrl = this._createDataUrl( absUrl );
  4256. content = this._find( absUrl );
  4257. // If it isn't a reference to the first content and refers to missing
  4258. // embedded content reject the deferred and return
  4259. if ( content.length === 0 &&
  4260. $.mobile.path.isEmbeddedPage(fileUrl) &&
  4261. !$.mobile.path.isFirstPageUrl(fileUrl) ) {
  4262. deferred.reject( absUrl, settings );
  4263. return deferred.promise();
  4264. }
  4265. // Reset base to the default document base
  4266. // TODO figure out why we doe this
  4267. this._getBase().reset();
  4268. // If the content we are interested in is already in the DOM,
  4269. // and the caller did not indicate that we should force a
  4270. // reload of the file, we are done. Resolve the deferrred so that
  4271. // users can bind to .done on the promise
  4272. if ( content.length && !settings.reload ) {
  4273. this._enhance( content, settings.role );
  4274. deferred.resolve( absUrl, settings, content );
  4275. //if we are reloading the content make sure we update
  4276. // the base if its not a prefetch
  4277. if ( !settings.prefetch ) {
  4278. this._getBase().set(url);
  4279. }
  4280. return deferred.promise();
  4281. }
  4282. triggerData = {
  4283. url: url,
  4284. absUrl: absUrl,
  4285. toPage: url,
  4286. prevPage: options ? options.fromPage : undefined,
  4287. dataUrl: dataUrl,
  4288. deferred: deferred,
  4289. options: settings
  4290. };
  4291. // Let listeners know we're about to load content.
  4292. pblEvent = this._triggerWithDeprecated( "beforeload", triggerData );
  4293. // If the default behavior is prevented, stop here!
  4294. if ( pblEvent.deprecatedEvent.isDefaultPrevented() ||
  4295. pblEvent.event.isDefaultPrevented() ) {
  4296. return deferred.promise();
  4297. }
  4298. if ( settings.showLoadMsg ) {
  4299. this._showLoading( settings.loadMsgDelay );
  4300. }
  4301. // Reset base to the default document base.
  4302. // only reset if we are not prefetching
  4303. if ( settings.prefetch === undefined ) {
  4304. this._getBase().reset();
  4305. }
  4306. if ( !( $.mobile.allowCrossDomainPages ||
  4307. $.mobile.path.isSameDomain($.mobile.path.documentUrl, absUrl ) ) ) {
  4308. deferred.reject( absUrl, settings );
  4309. return deferred.promise();
  4310. }
  4311. // Load the new content.
  4312. $.ajax({
  4313. url: fileUrl,
  4314. type: settings.type,
  4315. data: settings.data,
  4316. contentType: settings.contentType,
  4317. dataType: "html",
  4318. success: this._loadSuccess( absUrl, triggerData, settings, deferred ),
  4319. error: this._loadError( absUrl, triggerData, settings, deferred )
  4320. });
  4321. return deferred.promise();
  4322. },
  4323. _loadError: function( absUrl, triggerData, settings, deferred ) {
  4324. return $.proxy(function( xhr, textStatus, errorThrown ) {
  4325. //set base back to current path
  4326. this._getBase().set( $.mobile.path.get() );
  4327. // Add error info to our triggerData.
  4328. triggerData.xhr = xhr;
  4329. triggerData.textStatus = textStatus;
  4330. triggerData.errorThrown = errorThrown;
  4331. // Let listeners know the page load failed.
  4332. var plfEvent = this._triggerWithDeprecated( "loadfailed", triggerData );
  4333. // If the default behavior is prevented, stop here!
  4334. // Note that it is the responsibility of the listener/handler
  4335. // that called preventDefault(), to resolve/reject the
  4336. // deferred object within the triggerData.
  4337. if ( plfEvent.deprecatedEvent.isDefaultPrevented() ||
  4338. plfEvent.event.isDefaultPrevented() ) {
  4339. return;
  4340. }
  4341. // Remove loading message.
  4342. if ( settings.showLoadMsg ) {
  4343. this._showError();
  4344. }
  4345. deferred.reject( absUrl, settings );
  4346. }, this);
  4347. },
  4348. _getTransitionHandler: function( transition ) {
  4349. transition = $.mobile._maybeDegradeTransition( transition );
  4350. //find the transition handler for the specified transition. If there
  4351. //isn't one in our transitionHandlers dictionary, use the default one.
  4352. //call the handler immediately to kick-off the transition.
  4353. return $.mobile.transitionHandlers[ transition ] || $.mobile.defaultTransitionHandler;
  4354. },
  4355. // TODO move into transition handlers?
  4356. _triggerCssTransitionEvents: function( to, from, prefix ) {
  4357. var samePage = false;
  4358. prefix = prefix || "";
  4359. // TODO decide if these events should in fact be triggered on the container
  4360. if ( from ) {
  4361. //Check if this is a same page transition and tell the handler in page
  4362. if( to[0] === from[0] ){
  4363. samePage = true;
  4364. }
  4365. //trigger before show/hide events
  4366. // TODO deprecate nextPage in favor of next
  4367. this._triggerWithDeprecated( prefix + "hide", {
  4368. // Deprecated in 1.4 remove in 1.5
  4369. nextPage: to,
  4370. toPage: to,
  4371. prevPage: from,
  4372. samePage: samePage
  4373. }, from );
  4374. }
  4375. // TODO deprecate prevPage in favor of previous
  4376. this._triggerWithDeprecated( prefix + "show", {
  4377. prevPage: from || $( "" ),
  4378. toPage: to
  4379. }, to );
  4380. },
  4381. // TODO make private once change has been defined in the widget
  4382. _cssTransition: function( to, from, options ) {
  4383. var transition = options.transition,
  4384. reverse = options.reverse,
  4385. deferred = options.deferred,
  4386. TransitionHandler,
  4387. promise;
  4388. this._triggerCssTransitionEvents( to, from, "before" );
  4389. // TODO put this in a binding to events *outside* the widget
  4390. this._hideLoading();
  4391. TransitionHandler = this._getTransitionHandler( transition );
  4392. promise = ( new TransitionHandler( transition, reverse, to, from ) ).transition();
  4393. promise.done( $.proxy( function() {
  4394. this._triggerCssTransitionEvents( to, from );
  4395. }, this ));
  4396. // TODO temporary accomodation of argument deferred
  4397. promise.done(function() {
  4398. deferred.resolve.apply( deferred, arguments );
  4399. });
  4400. },
  4401. _releaseTransitionLock: function() {
  4402. //release transition lock so navigation is free again
  4403. isPageTransitioning = false;
  4404. if ( pageTransitionQueue.length > 0 ) {
  4405. $.mobile.changePage.apply( null, pageTransitionQueue.pop() );
  4406. }
  4407. },
  4408. _removeActiveLinkClass: function( force ) {
  4409. //clear out the active button state
  4410. $.mobile.removeActiveLinkClass( force );
  4411. },
  4412. _loadUrl: function( to, triggerData, settings ) {
  4413. // preserve the original target as the dataUrl value will be
  4414. // simplified eg, removing ui-state, and removing query params
  4415. // from the hash this is so that users who want to use query
  4416. // params have access to them in the event bindings for the page
  4417. // life cycle See issue #5085
  4418. settings.target = to;
  4419. settings.deferred = $.Deferred();
  4420. this.load( to, settings );
  4421. settings.deferred.done($.proxy(function( url, options, content ) {
  4422. isPageTransitioning = false;
  4423. // store the original absolute url so that it can be provided
  4424. // to events in the triggerData of the subsequent changePage call
  4425. options.absUrl = triggerData.absUrl;
  4426. this.transition( content, triggerData, options );
  4427. }, this));
  4428. settings.deferred.fail($.proxy(function(/* url, options */) {
  4429. this._removeActiveLinkClass( true );
  4430. this._releaseTransitionLock();
  4431. this._triggerWithDeprecated( "changefailed", triggerData );
  4432. }, this));
  4433. },
  4434. _triggerPageBeforeChange: function( to, triggerData, settings ) {
  4435. var returnEvents;
  4436. triggerData.prevPage = this.activePage;
  4437. $.extend( triggerData, {
  4438. toPage: to,
  4439. options: settings
  4440. });
  4441. // NOTE: preserve the original target as the dataUrl value will be
  4442. // simplified eg, removing ui-state, and removing query params from
  4443. // the hash this is so that users who want to use query params have
  4444. // access to them in the event bindings for the page life cycle
  4445. // See issue #5085
  4446. if ( $.type(to) === "string" ) {
  4447. // if the toPage is a string simply convert it
  4448. triggerData.absUrl = $.mobile.path.makeUrlAbsolute( to, this._findBaseWithDefault() );
  4449. } else {
  4450. // if the toPage is a jQuery object grab the absolute url stored
  4451. // in the loadPage callback where it exists
  4452. triggerData.absUrl = settings.absUrl;
  4453. }
  4454. // Let listeners know we're about to change the current page.
  4455. returnEvents = this._triggerWithDeprecated( "beforechange", triggerData );
  4456. // If the default behavior is prevented, stop here!
  4457. if ( returnEvents.event.isDefaultPrevented() ||
  4458. returnEvents.deprecatedEvent.isDefaultPrevented() ) {
  4459. return false;
  4460. }
  4461. return true;
  4462. },
  4463. change: function( to, options ) {
  4464. // If we are in the midst of a transition, queue the current request.
  4465. // We'll call changePage() once we're done with the current transition
  4466. // to service the request.
  4467. if ( isPageTransitioning ) {
  4468. pageTransitionQueue.unshift( arguments );
  4469. return;
  4470. }
  4471. var settings = $.extend( {}, $.mobile.changePage.defaults, options ),
  4472. triggerData = {};
  4473. // Make sure we have a fromPage.
  4474. settings.fromPage = settings.fromPage || this.activePage;
  4475. // if the page beforechange default is prevented return early
  4476. if ( !this._triggerPageBeforeChange(to, triggerData, settings) ) {
  4477. return;
  4478. }
  4479. // We allow "pagebeforechange" observers to modify the to in
  4480. // the trigger data to allow for redirects. Make sure our to is
  4481. // updated. We also need to re-evaluate whether it is a string,
  4482. // because an object can also be replaced by a string
  4483. to = triggerData.toPage;
  4484. // If the caller passed us a url, call loadPage()
  4485. // to make sure it is loaded into the DOM. We'll listen
  4486. // to the promise object it returns so we know when
  4487. // it is done loading or if an error ocurred.
  4488. if ( $.type(to) === "string" ) {
  4489. // Set the isPageTransitioning flag to prevent any requests from
  4490. // entering this method while we are in the midst of loading a page
  4491. // or transitioning.
  4492. isPageTransitioning = true;
  4493. this._loadUrl( to, triggerData, settings );
  4494. } else {
  4495. this.transition( to, triggerData, settings );
  4496. }
  4497. },
  4498. transition: function( toPage, triggerData, settings ) {
  4499. var fromPage, url, pageUrl, fileUrl,
  4500. active, activeIsInitialPage,
  4501. historyDir, pageTitle, isDialog,
  4502. alreadyThere, newPageTitle,
  4503. params, cssTransitionDeferred,
  4504. beforeTransition;
  4505. // If we are in the midst of a transition, queue the current request.
  4506. // We'll call changePage() once we're done with the current transition
  4507. // to service the request.
  4508. if ( isPageTransitioning ) {
  4509. // make sure to only queue the to and settings values so the arguments
  4510. // work with a call to the change method
  4511. pageTransitionQueue.unshift( [toPage, settings] );
  4512. return;
  4513. }
  4514. // DEPRECATED - this call only, in favor of the before transition
  4515. // if the page beforechange default is prevented return early
  4516. if ( !this._triggerPageBeforeChange(toPage, triggerData, settings) ) {
  4517. return;
  4518. }
  4519. triggerData.prevPage = settings.fromPage;
  4520. // if the (content|page)beforetransition default is prevented return early
  4521. // Note, we have to check for both the deprecated and new events
  4522. beforeTransition = this._triggerWithDeprecated( "beforetransition", triggerData );
  4523. if (beforeTransition.deprecatedEvent.isDefaultPrevented() ||
  4524. beforeTransition.event.isDefaultPrevented() ) {
  4525. return;
  4526. }
  4527. // Set the isPageTransitioning flag to prevent any requests from
  4528. // entering this method while we are in the midst of loading a page
  4529. // or transitioning.
  4530. isPageTransitioning = true;
  4531. // If we are going to the first-page of the application, we need to make
  4532. // sure settings.dataUrl is set to the application document url. This allows
  4533. // us to avoid generating a document url with an id hash in the case where the
  4534. // first-page of the document has an id attribute specified.
  4535. if ( toPage[ 0 ] === $.mobile.firstPage[ 0 ] && !settings.dataUrl ) {
  4536. settings.dataUrl = $.mobile.path.documentUrl.hrefNoHash;
  4537. }
  4538. // The caller passed us a real page DOM element. Update our
  4539. // internal state and then trigger a transition to the page.
  4540. fromPage = settings.fromPage;
  4541. url = ( settings.dataUrl && $.mobile.path.convertUrlToDataUrl(settings.dataUrl) ) ||
  4542. toPage.jqmData( "url" );
  4543. // The pageUrl var is usually the same as url, except when url is obscured
  4544. // as a dialog url. pageUrl always contains the file path
  4545. pageUrl = url;
  4546. fileUrl = $.mobile.path.getFilePath( url );
  4547. active = $.mobile.navigate.history.getActive();
  4548. activeIsInitialPage = $.mobile.navigate.history.activeIndex === 0;
  4549. historyDir = 0;
  4550. pageTitle = document.title;
  4551. isDialog = ( settings.role === "dialog" ||
  4552. toPage.jqmData( "role" ) === "dialog" ) &&
  4553. toPage.jqmData( "dialog" ) !== true;
  4554. // By default, we prevent changePage requests when the fromPage and toPage
  4555. // are the same element, but folks that generate content
  4556. // manually/dynamically and reuse pages want to be able to transition to
  4557. // the same page. To allow this, they will need to change the default
  4558. // value of allowSamePageTransition to true, *OR*, pass it in as an
  4559. // option when they manually call changePage(). It should be noted that
  4560. // our default transition animations assume that the formPage and toPage
  4561. // are different elements, so they may behave unexpectedly. It is up to
  4562. // the developer that turns on the allowSamePageTransitiona option to
  4563. // either turn off transition animations, or make sure that an appropriate
  4564. // animation transition is used.
  4565. if ( fromPage && fromPage[0] === toPage[0] &&
  4566. !settings.allowSamePageTransition ) {
  4567. isPageTransitioning = false;
  4568. this._triggerWithDeprecated( "transition", triggerData );
  4569. this._triggerWithDeprecated( "change", triggerData );
  4570. // Even if there is no page change to be done, we should keep the
  4571. // urlHistory in sync with the hash changes
  4572. if ( settings.fromHashChange ) {
  4573. $.mobile.navigate.history.direct({ url: url });
  4574. }
  4575. return;
  4576. }
  4577. // We need to make sure the page we are given has already been enhanced.
  4578. toPage.page({ role: settings.role });
  4579. // If the changePage request was sent from a hashChange event, check to
  4580. // see if the page is already within the urlHistory stack. If so, we'll
  4581. // assume the user hit the forward/back button and will try to match the
  4582. // transition accordingly.
  4583. if ( settings.fromHashChange ) {
  4584. historyDir = settings.direction === "back" ? -1 : 1;
  4585. }
  4586. // Kill the keyboard.
  4587. // XXX_jblas: We need to stop crawling the entire document to kill focus.
  4588. // Instead, we should be tracking focus with a delegate()
  4589. // handler so we already have the element in hand at this
  4590. // point.
  4591. // Wrap this in a try/catch block since IE9 throw "Unspecified error" if
  4592. // document.activeElement is undefined when we are in an IFrame.
  4593. try {
  4594. if ( document.activeElement &&
  4595. document.activeElement.nodeName.toLowerCase() !== "body" ) {
  4596. $( document.activeElement ).blur();
  4597. } else {
  4598. $( "input:focus, textarea:focus, select:focus" ).blur();
  4599. }
  4600. } catch( e ) {}
  4601. // Record whether we are at a place in history where a dialog used to be -
  4602. // if so, do not add a new history entry and do not change the hash either
  4603. alreadyThere = false;
  4604. // If we're displaying the page as a dialog, we don't want the url
  4605. // for the dialog content to be used in the hash. Instead, we want
  4606. // to append the dialogHashKey to the url of the current page.
  4607. if ( isDialog && active ) {
  4608. // on the initial page load active.url is undefined and in that case
  4609. // should be an empty string. Moving the undefined -> empty string back
  4610. // into urlHistory.addNew seemed imprudent given undefined better
  4611. // represents the url state
  4612. // If we are at a place in history that once belonged to a dialog, reuse
  4613. // this state without adding to urlHistory and without modifying the
  4614. // hash. However, if a dialog is already displayed at this point, and
  4615. // we're about to display another dialog, then we must add another hash
  4616. // and history entry on top so that one may navigate back to the
  4617. // original dialog
  4618. if ( active.url &&
  4619. active.url.indexOf( $.mobile.dialogHashKey ) > -1 &&
  4620. this.activePage &&
  4621. !this.activePage.hasClass( "ui-dialog" ) &&
  4622. $.mobile.navigate.history.activeIndex > 0 ) {
  4623. settings.changeHash = false;
  4624. alreadyThere = true;
  4625. }
  4626. // Normally, we tack on a dialog hash key, but if this is the location
  4627. // of a stale dialog, we reuse the URL from the entry
  4628. url = ( active.url || "" );
  4629. // account for absolute urls instead of just relative urls use as hashes
  4630. if ( !alreadyThere && url.indexOf("#") > -1 ) {
  4631. url += $.mobile.dialogHashKey;
  4632. } else {
  4633. url += "#" + $.mobile.dialogHashKey;
  4634. }
  4635. }
  4636. // if title element wasn't found, try the page div data attr too
  4637. // If this is a deep-link or a reload ( active === undefined ) then just
  4638. // use pageTitle
  4639. newPageTitle = ( !active ) ? pageTitle : toPage.jqmData( "title" ) ||
  4640. toPage.children( ":jqmData(role='header')" ).find( ".ui-title" ).text();
  4641. if ( !!newPageTitle && pageTitle === document.title ) {
  4642. pageTitle = newPageTitle;
  4643. }
  4644. if ( !toPage.jqmData( "title" ) ) {
  4645. toPage.jqmData( "title", pageTitle );
  4646. }
  4647. // Make sure we have a transition defined.
  4648. settings.transition = settings.transition ||
  4649. ( ( historyDir && !activeIsInitialPage ) ? active.transition : undefined ) ||
  4650. ( isDialog ? $.mobile.defaultDialogTransition : $.mobile.defaultPageTransition );
  4651. //add page to history stack if it's not back or forward
  4652. if ( !historyDir && alreadyThere ) {
  4653. $.mobile.navigate.history.getActive().pageUrl = pageUrl;
  4654. }
  4655. // Set the location hash.
  4656. if ( url && !settings.fromHashChange ) {
  4657. // rebuilding the hash here since we loose it earlier on
  4658. // TODO preserve the originally passed in path
  4659. if ( !$.mobile.path.isPath( url ) && url.indexOf( "#" ) < 0 ) {
  4660. url = "#" + url;
  4661. }
  4662. // TODO the property names here are just silly
  4663. params = {
  4664. transition: settings.transition,
  4665. title: pageTitle,
  4666. pageUrl: pageUrl,
  4667. role: settings.role
  4668. };
  4669. if ( settings.changeHash !== false && $.mobile.hashListeningEnabled ) {
  4670. $.mobile.navigate( this.window[ 0 ].encodeURI( url ), params, true);
  4671. } else if ( toPage[ 0 ] !== $.mobile.firstPage[ 0 ] ) {
  4672. $.mobile.navigate.history.add( url, params );
  4673. }
  4674. }
  4675. //set page title
  4676. document.title = pageTitle;
  4677. //set "toPage" as activePage deprecated in 1.4 remove in 1.5
  4678. $.mobile.activePage = toPage;
  4679. //new way to handle activePage
  4680. this.activePage = toPage;
  4681. // If we're navigating back in the URL history, set reverse accordingly.
  4682. settings.reverse = settings.reverse || historyDir < 0;
  4683. cssTransitionDeferred = $.Deferred();
  4684. this._cssTransition(toPage, fromPage, {
  4685. transition: settings.transition,
  4686. reverse: settings.reverse,
  4687. deferred: cssTransitionDeferred
  4688. });
  4689. cssTransitionDeferred.done($.proxy(function( name, reverse, $to, $from, alreadyFocused ) {
  4690. $.mobile.removeActiveLinkClass();
  4691. //if there's a duplicateCachedPage, remove it from the DOM now that it's hidden
  4692. if ( settings.duplicateCachedPage ) {
  4693. settings.duplicateCachedPage.remove();
  4694. }
  4695. // despite visibility: hidden addresses issue #2965
  4696. // https://github.com/jquery/jquery-mobile/issues/2965
  4697. if ( !alreadyFocused ) {
  4698. $.mobile.focusPage( toPage );
  4699. }
  4700. this._releaseTransitionLock();
  4701. this._triggerWithDeprecated( "transition", triggerData );
  4702. this._triggerWithDeprecated( "change", triggerData );
  4703. }, this));
  4704. },
  4705. // determine the current base url
  4706. _findBaseWithDefault: function() {
  4707. var closestBase = ( this.activePage &&
  4708. $.mobile.getClosestBaseUrl( this.activePage ) );
  4709. return closestBase || $.mobile.path.documentBase.hrefNoHash;
  4710. }
  4711. });
  4712. // The following handlers should be bound after mobileinit has been triggered
  4713. // the following deferred is resolved in the init file
  4714. $.mobile.navreadyDeferred = $.Deferred();
  4715. //these variables make all page containers use the same queue and only navigate one at a time
  4716. // queue to hold simultanious page transitions
  4717. var pageTransitionQueue = [],
  4718. // indicates whether or not page is in process of transitioning
  4719. isPageTransitioning = false;
  4720. })( jQuery );
  4721. (function( $, undefined ) {
  4722. // resolved on domready
  4723. var domreadyDeferred = $.Deferred(),
  4724. // resolved and nulled on window.load()
  4725. loadDeferred = $.Deferred(),
  4726. // function that resolves the above deferred
  4727. pageIsFullyLoaded = function() {
  4728. // Resolve and null the deferred
  4729. loadDeferred.resolve();
  4730. loadDeferred = null;
  4731. },
  4732. documentUrl = $.mobile.path.documentUrl,
  4733. // used to track last vclicked element to make sure its value is added to form data
  4734. $lastVClicked = null;
  4735. /* Event Bindings - hashchange, submit, and click */
  4736. function findClosestLink( ele ) {
  4737. while ( ele ) {
  4738. // Look for the closest element with a nodeName of "a".
  4739. // Note that we are checking if we have a valid nodeName
  4740. // before attempting to access it. This is because the
  4741. // node we get called with could have originated from within
  4742. // an embedded SVG document where some symbol instance elements
  4743. // don't have nodeName defined on them, or strings are of type
  4744. // SVGAnimatedString.
  4745. if ( ( typeof ele.nodeName === "string" ) && ele.nodeName.toLowerCase() === "a" ) {
  4746. break;
  4747. }
  4748. ele = ele.parentNode;
  4749. }
  4750. return ele;
  4751. }
  4752. $.mobile.loadPage = function( url, opts ) {
  4753. var container;
  4754. opts = opts || {};
  4755. container = ( opts.pageContainer || $.mobile.pageContainer );
  4756. // create the deferred that will be supplied to loadPage callers
  4757. // and resolved by the content widget's load method
  4758. opts.deferred = $.Deferred();
  4759. // Preferring to allow exceptions for uninitialized opts.pageContainer
  4760. // widgets so we know if we need to force init here for users
  4761. container.pagecontainer( "load", url, opts );
  4762. // provide the deferred
  4763. return opts.deferred.promise();
  4764. };
  4765. //define vars for interal use
  4766. /* internal utility functions */
  4767. // NOTE Issue #4950 Android phonegap doesn't navigate back properly
  4768. // when a full page refresh has taken place. It appears that hashchange
  4769. // and replacestate history alterations work fine but we need to support
  4770. // both forms of history traversal in our code that uses backward history
  4771. // movement
  4772. $.mobile.back = function() {
  4773. var nav = window.navigator;
  4774. // if the setting is on and the navigator object is
  4775. // available use the phonegap navigation capability
  4776. if ( this.phonegapNavigationEnabled &&
  4777. nav &&
  4778. nav.app &&
  4779. nav.app.backHistory ) {
  4780. nav.app.backHistory();
  4781. } else {
  4782. $.mobile.pageContainer.pagecontainer( "back" );
  4783. }
  4784. };
  4785. // Direct focus to the page title, or otherwise first focusable element
  4786. $.mobile.focusPage = function ( page ) {
  4787. var autofocus = page.find( "[autofocus]" ),
  4788. pageTitle = page.find( ".ui-title:eq(0)" );
  4789. if ( autofocus.length ) {
  4790. autofocus.focus();
  4791. return;
  4792. }
  4793. if ( pageTitle.length ) {
  4794. pageTitle.focus();
  4795. } else{
  4796. page.focus();
  4797. }
  4798. };
  4799. // No-op implementation of transition degradation
  4800. $.mobile._maybeDegradeTransition = $.mobile._maybeDegradeTransition || function( transition ) {
  4801. return transition;
  4802. };
  4803. // Exposed $.mobile methods
  4804. $.mobile.changePage = function( to, options ) {
  4805. $.mobile.pageContainer.pagecontainer( "change", to, options );
  4806. };
  4807. $.mobile.changePage.defaults = {
  4808. transition: undefined,
  4809. reverse: false,
  4810. changeHash: true,
  4811. fromHashChange: false,
  4812. role: undefined, // By default we rely on the role defined by the @data-role attribute.
  4813. duplicateCachedPage: undefined,
  4814. pageContainer: undefined,
  4815. showLoadMsg: true, //loading message shows by default when pages are being fetched during changePage
  4816. dataUrl: undefined,
  4817. fromPage: undefined,
  4818. allowSamePageTransition: false
  4819. };
  4820. $.mobile._registerInternalEvents = function() {
  4821. var getAjaxFormData = function( $form, calculateOnly ) {
  4822. var url, ret = true, formData, vclickedName, method;
  4823. if ( !$.mobile.ajaxEnabled ||
  4824. // test that the form is, itself, ajax false
  4825. $form.is( ":jqmData(ajax='false')" ) ||
  4826. // test that $.mobile.ignoreContentEnabled is set and
  4827. // the form or one of it's parents is ajax=false
  4828. !$form.jqmHijackable().length ||
  4829. $form.attr( "target" ) ) {
  4830. return false;
  4831. }
  4832. url = ( $lastVClicked && $lastVClicked.attr( "formaction" ) ) ||
  4833. $form.attr( "action" );
  4834. method = ( $form.attr( "method" ) || "get" ).toLowerCase();
  4835. // If no action is specified, browsers default to using the
  4836. // URL of the document containing the form. Since we dynamically
  4837. // pull in pages from external documents, the form should submit
  4838. // to the URL for the source document of the page containing
  4839. // the form.
  4840. if ( !url ) {
  4841. // Get the @data-url for the page containing the form.
  4842. url = $.mobile.getClosestBaseUrl( $form );
  4843. // NOTE: If the method is "get", we need to strip off the query string
  4844. // because it will get replaced with the new form data. See issue #5710.
  4845. if ( method === "get" ) {
  4846. url = $.mobile.path.parseUrl( url ).hrefNoSearch;
  4847. }
  4848. if ( url === $.mobile.path.documentBase.hrefNoHash ) {
  4849. // The url we got back matches the document base,
  4850. // which means the page must be an internal/embedded page,
  4851. // so default to using the actual document url as a browser
  4852. // would.
  4853. url = documentUrl.hrefNoSearch;
  4854. }
  4855. }
  4856. url = $.mobile.path.makeUrlAbsolute( url, $.mobile.getClosestBaseUrl( $form ) );
  4857. if ( ( $.mobile.path.isExternal( url ) && !$.mobile.path.isPermittedCrossDomainRequest( documentUrl, url ) ) ) {
  4858. return false;
  4859. }
  4860. if ( !calculateOnly ) {
  4861. formData = $form.serializeArray();
  4862. if ( $lastVClicked && $lastVClicked[ 0 ].form === $form[ 0 ] ) {
  4863. vclickedName = $lastVClicked.attr( "name" );
  4864. if ( vclickedName ) {
  4865. // Make sure the last clicked element is included in the form
  4866. $.each( formData, function( key, value ) {
  4867. if ( value.name === vclickedName ) {
  4868. // Unset vclickedName - we've found it in the serialized data already
  4869. vclickedName = "";
  4870. return false;
  4871. }
  4872. });
  4873. if ( vclickedName ) {
  4874. formData.push( { name: vclickedName, value: $lastVClicked.attr( "value" ) } );
  4875. }
  4876. }
  4877. }
  4878. ret = {
  4879. url: url,
  4880. options: {
  4881. type: method,
  4882. data: $.param( formData ),
  4883. transition: $form.jqmData( "transition" ),
  4884. reverse: $form.jqmData( "direction" ) === "reverse",
  4885. reloadPage: true
  4886. }
  4887. };
  4888. }
  4889. return ret;
  4890. };
  4891. //bind to form submit events, handle with Ajax
  4892. $.mobile.document.delegate( "form", "submit", function( event ) {
  4893. var formData;
  4894. if ( !event.isDefaultPrevented() ) {
  4895. formData = getAjaxFormData( $( this ) );
  4896. if ( formData ) {
  4897. $.mobile.changePage( formData.url, formData.options );
  4898. event.preventDefault();
  4899. }
  4900. }
  4901. });
  4902. //add active state on vclick
  4903. $.mobile.document.bind( "vclick", function( event ) {
  4904. var $btn, btnEls, target = event.target, needClosest = false;
  4905. // if this isn't a left click we don't care. Its important to note
  4906. // that when the virtual event is generated it will create the which attr
  4907. if ( event.which > 1 || !$.mobile.linkBindingEnabled ) {
  4908. return;
  4909. }
  4910. // Record that this element was clicked, in case we need it for correct
  4911. // form submission during the "submit" handler above
  4912. $lastVClicked = $( target );
  4913. // Try to find a target element to which the active class will be applied
  4914. if ( $.data( target, "mobile-button" ) ) {
  4915. // If the form will not be submitted via AJAX, do not add active class
  4916. if ( !getAjaxFormData( $( target ).closest( "form" ), true ) ) {
  4917. return;
  4918. }
  4919. // We will apply the active state to this button widget - the parent
  4920. // of the input that was clicked will have the associated data
  4921. if ( target.parentNode ) {
  4922. target = target.parentNode;
  4923. }
  4924. } else {
  4925. target = findClosestLink( target );
  4926. if ( !( target && $.mobile.path.parseUrl( target.getAttribute( "href" ) || "#" ).hash !== "#" ) ) {
  4927. return;
  4928. }
  4929. // TODO teach $.mobile.hijackable to operate on raw dom elements so the
  4930. // link wrapping can be avoided
  4931. if ( !$( target ).jqmHijackable().length ) {
  4932. return;
  4933. }
  4934. }
  4935. // Avoid calling .closest by using the data set during .buttonMarkup()
  4936. // List items have the button data in the parent of the element clicked
  4937. if ( !!~target.className.indexOf( "ui-link-inherit" ) ) {
  4938. if ( target.parentNode ) {
  4939. btnEls = $.data( target.parentNode, "buttonElements" );
  4940. }
  4941. // Otherwise, look for the data on the target itself
  4942. } else {
  4943. btnEls = $.data( target, "buttonElements" );
  4944. }
  4945. // If found, grab the button's outer element
  4946. if ( btnEls ) {
  4947. target = btnEls.outer;
  4948. } else {
  4949. needClosest = true;
  4950. }
  4951. $btn = $( target );
  4952. // If the outer element wasn't found by the our heuristics, use .closest()
  4953. if ( needClosest ) {
  4954. $btn = $btn.closest( ".ui-btn" );
  4955. }
  4956. if ( $btn.length > 0 &&
  4957. !( $btn.hasClass( "ui-state-disabled" ||
  4958. // DEPRECATED as of 1.4.0 - remove after 1.4.0 release
  4959. // only ui-state-disabled should be present thereafter
  4960. $btn.hasClass( "ui-disabled" ) ) ) ) {
  4961. $.mobile.removeActiveLinkClass( true );
  4962. $.mobile.activeClickedLink = $btn;
  4963. $.mobile.activeClickedLink.addClass( $.mobile.activeBtnClass );
  4964. }
  4965. });
  4966. // click routing - direct to HTTP or Ajax, accordingly
  4967. $.mobile.document.bind( "click", function( event ) {
  4968. if ( !$.mobile.linkBindingEnabled || event.isDefaultPrevented() ) {
  4969. return;
  4970. }
  4971. var link = findClosestLink( event.target ),
  4972. $link = $( link ),
  4973. //remove active link class if external (then it won't be there if you come back)
  4974. httpCleanup = function() {
  4975. window.setTimeout(function() { $.mobile.removeActiveLinkClass( true ); }, 200 );
  4976. },
  4977. baseUrl, href,
  4978. useDefaultUrlHandling, isExternal,
  4979. transition, reverse, role;
  4980. // If a button was clicked, clean up the active class added by vclick above
  4981. if ( $.mobile.activeClickedLink &&
  4982. $.mobile.activeClickedLink[ 0 ] === event.target.parentNode ) {
  4983. httpCleanup();
  4984. }
  4985. // If there is no link associated with the click or its not a left
  4986. // click we want to ignore the click
  4987. // TODO teach $.mobile.hijackable to operate on raw dom elements so the link wrapping
  4988. // can be avoided
  4989. if ( !link || event.which > 1 || !$link.jqmHijackable().length ) {
  4990. return;
  4991. }
  4992. //if there's a data-rel=back attr, go back in history
  4993. if ( $link.is( ":jqmData(rel='back')" ) ) {
  4994. $.mobile.back();
  4995. return false;
  4996. }
  4997. baseUrl = $.mobile.getClosestBaseUrl( $link );
  4998. //get href, if defined, otherwise default to empty hash
  4999. href = $.mobile.path.makeUrlAbsolute( $link.attr( "href" ) || "#", baseUrl );
  5000. //if ajax is disabled, exit early
  5001. if ( !$.mobile.ajaxEnabled && !$.mobile.path.isEmbeddedPage( href ) ) {
  5002. httpCleanup();
  5003. //use default click handling
  5004. return;
  5005. }
  5006. // XXX_jblas: Ideally links to application pages should be specified as
  5007. // an url to the application document with a hash that is either
  5008. // the site relative path or id to the page. But some of the
  5009. // internal code that dynamically generates sub-pages for nested
  5010. // lists and select dialogs, just write a hash in the link they
  5011. // create. This means the actual URL path is based on whatever
  5012. // the current value of the base tag is at the time this code
  5013. // is called.
  5014. if ( href.search( "#" ) !== -1 &&
  5015. !( $.mobile.path.isExternal( href ) && $.mobile.path.isAbsoluteUrl( href ) ) ) {
  5016. href = href.replace( /[^#]*#/, "" );
  5017. if ( !href ) {
  5018. //link was an empty hash meant purely
  5019. //for interaction, so we ignore it.
  5020. event.preventDefault();
  5021. return;
  5022. } else if ( $.mobile.path.isPath( href ) ) {
  5023. //we have apath so make it the href we want to load.
  5024. href = $.mobile.path.makeUrlAbsolute( href, baseUrl );
  5025. } else {
  5026. //we have a simple id so use the documentUrl as its base.
  5027. href = $.mobile.path.makeUrlAbsolute( "#" + href, documentUrl.hrefNoHash );
  5028. }
  5029. }
  5030. // Should we handle this link, or let the browser deal with it?
  5031. useDefaultUrlHandling = $link.is( "[rel='external']" ) || $link.is( ":jqmData(ajax='false')" ) || $link.is( "[target]" );
  5032. // Some embedded browsers, like the web view in Phone Gap, allow cross-domain XHR
  5033. // requests if the document doing the request was loaded via the file:// protocol.
  5034. // This is usually to allow the application to "phone home" and fetch app specific
  5035. // data. We normally let the browser handle external/cross-domain urls, but if the
  5036. // allowCrossDomainPages option is true, we will allow cross-domain http/https
  5037. // requests to go through our page loading logic.
  5038. //check for protocol or rel and its not an embedded page
  5039. //TODO overlap in logic from isExternal, rel=external check should be
  5040. // moved into more comprehensive isExternalLink
  5041. isExternal = useDefaultUrlHandling || ( $.mobile.path.isExternal( href ) && !$.mobile.path.isPermittedCrossDomainRequest( documentUrl, href ) );
  5042. if ( isExternal ) {
  5043. httpCleanup();
  5044. //use default click handling
  5045. return;
  5046. }
  5047. //use ajax
  5048. transition = $link.jqmData( "transition" );
  5049. reverse = $link.jqmData( "direction" ) === "reverse" ||
  5050. // deprecated - remove by 1.0
  5051. $link.jqmData( "back" );
  5052. //this may need to be more specific as we use data-rel more
  5053. role = $link.attr( "data-" + $.mobile.ns + "rel" ) || undefined;
  5054. $.mobile.changePage( href, { transition: transition, reverse: reverse, role: role, link: $link } );
  5055. event.preventDefault();
  5056. });
  5057. //prefetch pages when anchors with data-prefetch are encountered
  5058. $.mobile.document.delegate( ".ui-page", "pageshow.prefetch", function() {
  5059. var urls = [];
  5060. $( this ).find( "a:jqmData(prefetch)" ).each(function() {
  5061. var $link = $( this ),
  5062. url = $link.attr( "href" );
  5063. if ( url && $.inArray( url, urls ) === -1 ) {
  5064. urls.push( url );
  5065. $.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ),prefetch: true } );
  5066. }
  5067. });
  5068. });
  5069. // TODO ensure that the navigate binding in the content widget happens at the right time
  5070. $.mobile.pageContainer.pagecontainer();
  5071. //set page min-heights to be device specific
  5072. $.mobile.document.bind( "pageshow", function() {
  5073. // We need to wait for window.load to make sure that styles have already been rendered,
  5074. // otherwise heights of external toolbars will have the wrong value
  5075. if ( loadDeferred ) {
  5076. loadDeferred.done( $.mobile.resetActivePageHeight );
  5077. } else {
  5078. $.mobile.resetActivePageHeight();
  5079. }
  5080. });
  5081. $.mobile.window.bind( "throttledresize", $.mobile.resetActivePageHeight );
  5082. };//navreadyDeferred done callback
  5083. $( function() { domreadyDeferred.resolve(); } );
  5084. // Account for the possibility that the load event has already fired
  5085. if ( document.readyState === "complete" ) {
  5086. pageIsFullyLoaded();
  5087. } else {
  5088. $.mobile.window.load( pageIsFullyLoaded );
  5089. }
  5090. $.when( domreadyDeferred, $.mobile.navreadyDeferred ).done( function() { $.mobile._registerInternalEvents(); } );
  5091. })( jQuery );
  5092. (function( $, window, undefined ) {
  5093. // TODO remove direct references to $.mobile and properties, we should
  5094. // favor injection with params to the constructor
  5095. $.mobile.Transition = function() {
  5096. this.init.apply( this, arguments );
  5097. };
  5098. $.extend($.mobile.Transition.prototype, {
  5099. toPreClass: " ui-page-pre-in",
  5100. init: function( name, reverse, $to, $from ) {
  5101. $.extend(this, {
  5102. name: name,
  5103. reverse: reverse,
  5104. $to: $to,
  5105. $from: $from,
  5106. deferred: new $.Deferred()
  5107. });
  5108. },
  5109. cleanFrom: function() {
  5110. this.$from
  5111. .removeClass( $.mobile.activePageClass + " out in reverse " + this.name )
  5112. .height( "" );
  5113. },
  5114. // NOTE overridden by child object prototypes, noop'd here as defaults
  5115. beforeDoneIn: function() {},
  5116. beforeDoneOut: function() {},
  5117. beforeStartOut: function() {},
  5118. doneIn: function() {
  5119. this.beforeDoneIn();
  5120. this.$to.removeClass( "out in reverse " + this.name ).height( "" );
  5121. this.toggleViewportClass();
  5122. // In some browsers (iOS5), 3D transitions block the ability to scroll to the desired location during transition
  5123. // This ensures we jump to that spot after the fact, if we aren't there already.
  5124. if ( $.mobile.window.scrollTop() !== this.toScroll ) {
  5125. this.scrollPage();
  5126. }
  5127. if ( !this.sequential ) {
  5128. this.$to.addClass( $.mobile.activePageClass );
  5129. }
  5130. this.deferred.resolve( this.name, this.reverse, this.$to, this.$from, true );
  5131. },
  5132. doneOut: function( screenHeight, reverseClass, none, preventFocus ) {
  5133. this.beforeDoneOut();
  5134. this.startIn( screenHeight, reverseClass, none, preventFocus );
  5135. },
  5136. hideIn: function( callback ) {
  5137. // Prevent flickering in phonegap container: see comments at #4024 regarding iOS
  5138. this.$to.css( "z-index", -10 );
  5139. callback.call( this );
  5140. this.$to.css( "z-index", "" );
  5141. },
  5142. scrollPage: function() {
  5143. // By using scrollTo instead of silentScroll, we can keep things better in order
  5144. // Just to be precautios, disable scrollstart listening like silentScroll would
  5145. $.event.special.scrollstart.enabled = false;
  5146. //if we are hiding the url bar or the page was previously scrolled scroll to hide or return to position
  5147. if ( $.mobile.hideUrlBar || this.toScroll !== $.mobile.defaultHomeScroll ) {
  5148. window.scrollTo( 0, this.toScroll );
  5149. }
  5150. // reenable scrollstart listening like silentScroll would
  5151. setTimeout( function() {
  5152. $.event.special.scrollstart.enabled = true;
  5153. }, 150 );
  5154. },
  5155. startIn: function( screenHeight, reverseClass, none, preventFocus ) {
  5156. this.hideIn(function() {
  5157. this.$to.addClass( $.mobile.activePageClass + this.toPreClass );
  5158. // Send focus to page as it is now display: block
  5159. if ( !preventFocus ) {
  5160. $.mobile.focusPage( this.$to );
  5161. }
  5162. // Set to page height
  5163. this.$to.height( screenHeight + this.toScroll );
  5164. if ( !none ) {
  5165. this.scrollPage();
  5166. }
  5167. });
  5168. this.$to
  5169. .removeClass( this.toPreClass )
  5170. .addClass( this.name + " in " + reverseClass );
  5171. if ( !none ) {
  5172. this.$to.animationComplete( $.proxy(function() {
  5173. this.doneIn();
  5174. }, this ));
  5175. } else {
  5176. this.doneIn();
  5177. }
  5178. },
  5179. startOut: function( screenHeight, reverseClass, none ) {
  5180. this.beforeStartOut( screenHeight, reverseClass, none );
  5181. // Set the from page's height and start it transitioning out
  5182. // Note: setting an explicit height helps eliminate tiling in the transitions
  5183. this.$from
  5184. .height( screenHeight + $.mobile.window.scrollTop() )
  5185. .addClass( this.name + " out" + reverseClass );
  5186. },
  5187. toggleViewportClass: function() {
  5188. $.mobile.pageContainer.toggleClass( "ui-mobile-viewport-transitioning viewport-" + this.name );
  5189. },
  5190. transition: function() {
  5191. // NOTE many of these could be calculated/recorded in the constructor, it's my
  5192. // opinion that binding them as late as possible has value with regards to
  5193. // better transitions with fewer bugs. Ie, it's not guaranteed that the
  5194. // object will be created and transition will be run immediately after as
  5195. // it is today. So we wait until transition is invoked to gather the following
  5196. var none,
  5197. reverseClass = this.reverse ? " reverse" : "",
  5198. screenHeight = $.mobile.getScreenHeight(),
  5199. maxTransitionOverride = $.mobile.maxTransitionWidth !== false &&
  5200. $.mobile.window.width() > $.mobile.maxTransitionWidth;
  5201. this.toScroll = $.mobile.navigate.history.getActive().lastScroll || $.mobile.defaultHomeScroll;
  5202. none = !$.support.cssTransitions || !$.support.cssAnimations ||
  5203. maxTransitionOverride || !this.name || this.name === "none" ||
  5204. Math.max( $.mobile.window.scrollTop(), this.toScroll ) >
  5205. $.mobile.getMaxScrollForTransition();
  5206. this.toggleViewportClass();
  5207. if ( this.$from && !none ) {
  5208. this.startOut( screenHeight, reverseClass, none );
  5209. } else {
  5210. this.doneOut( screenHeight, reverseClass, none, true );
  5211. }
  5212. return this.deferred.promise();
  5213. }
  5214. });
  5215. })( jQuery, this );
  5216. (function( $ ) {
  5217. $.mobile.SerialTransition = function() {
  5218. this.init.apply(this, arguments);
  5219. };
  5220. $.extend($.mobile.SerialTransition.prototype, $.mobile.Transition.prototype, {
  5221. sequential: true,
  5222. beforeDoneOut: function() {
  5223. if ( this.$from ) {
  5224. this.cleanFrom();
  5225. }
  5226. },
  5227. beforeStartOut: function( screenHeight, reverseClass, none ) {
  5228. this.$from.animationComplete($.proxy(function() {
  5229. this.doneOut( screenHeight, reverseClass, none );
  5230. }, this ));
  5231. }
  5232. });
  5233. })( jQuery );
  5234. (function( $ ) {
  5235. $.mobile.ConcurrentTransition = function() {
  5236. this.init.apply(this, arguments);
  5237. };
  5238. $.extend($.mobile.ConcurrentTransition.prototype, $.mobile.Transition.prototype, {
  5239. sequential: false,
  5240. beforeDoneIn: function() {
  5241. if ( this.$from ) {
  5242. this.cleanFrom();
  5243. }
  5244. },
  5245. beforeStartOut: function( screenHeight, reverseClass, none ) {
  5246. this.doneOut( screenHeight, reverseClass, none );
  5247. }
  5248. });
  5249. })( jQuery );
  5250. (function( $ ) {
  5251. // generate the handlers from the above
  5252. var defaultGetMaxScrollForTransition = function() {
  5253. return $.mobile.getScreenHeight() * 3;
  5254. };
  5255. //transition handler dictionary for 3rd party transitions
  5256. $.mobile.transitionHandlers = {
  5257. "sequential": $.mobile.SerialTransition,
  5258. "simultaneous": $.mobile.ConcurrentTransition
  5259. };
  5260. // Make our transition handler the public default.
  5261. $.mobile.defaultTransitionHandler = $.mobile.transitionHandlers.sequential;
  5262. $.mobile.transitionFallbacks = {};
  5263. // If transition is defined, check if css 3D transforms are supported, and if not, if a fallback is specified
  5264. $.mobile._maybeDegradeTransition = function( transition ) {
  5265. if ( transition && !$.support.cssTransform3d && $.mobile.transitionFallbacks[ transition ] ) {
  5266. transition = $.mobile.transitionFallbacks[ transition ];
  5267. }
  5268. return transition;
  5269. };
  5270. // Set the getMaxScrollForTransition to default if no implementation was set by user
  5271. $.mobile.getMaxScrollForTransition = $.mobile.getMaxScrollForTransition || defaultGetMaxScrollForTransition;
  5272. })( jQuery );
  5273. /*
  5274. * fallback transition for flip in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5275. */
  5276. (function( $, window, undefined ) {
  5277. $.mobile.transitionFallbacks.flip = "fade";
  5278. })( jQuery, this );
  5279. /*
  5280. * fallback transition for flow in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5281. */
  5282. (function( $, window, undefined ) {
  5283. $.mobile.transitionFallbacks.flow = "fade";
  5284. })( jQuery, this );
  5285. /*
  5286. * fallback transition for pop in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5287. */
  5288. (function( $, window, undefined ) {
  5289. $.mobile.transitionFallbacks.pop = "fade";
  5290. })( jQuery, this );
  5291. /*
  5292. * fallback transition for slide in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5293. */
  5294. (function( $, window, undefined ) {
  5295. // Use the simultaneous transitions handler for slide transitions
  5296. $.mobile.transitionHandlers.slide = $.mobile.transitionHandlers.simultaneous;
  5297. // Set the slide transitions's fallback to "fade"
  5298. $.mobile.transitionFallbacks.slide = "fade";
  5299. })( jQuery, this );
  5300. /*
  5301. * fallback transition for slidedown in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5302. */
  5303. (function( $, window, undefined ) {
  5304. $.mobile.transitionFallbacks.slidedown = "fade";
  5305. })( jQuery, this );
  5306. /*
  5307. * fallback transition for slidefade in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5308. */
  5309. (function( $, window, undefined ) {
  5310. // Set the slide transitions's fallback to "fade"
  5311. $.mobile.transitionFallbacks.slidefade = "fade";
  5312. })( jQuery, this );
  5313. /*
  5314. * fallback transition for slideup in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5315. */
  5316. (function( $, window, undefined ) {
  5317. $.mobile.transitionFallbacks.slideup = "fade";
  5318. })( jQuery, this );
  5319. /*
  5320. * fallback transition for turn in non-3D supporting browsers (which tend to handle complex transitions poorly in general
  5321. */
  5322. (function( $, window, undefined ) {
  5323. $.mobile.transitionFallbacks.turn = "fade";
  5324. })( jQuery, this );
  5325. (function( $, undefined ) {
  5326. $.mobile.degradeInputs = {
  5327. color: false,
  5328. date: false,
  5329. datetime: false,
  5330. "datetime-local": false,
  5331. email: false,
  5332. month: false,
  5333. number: false,
  5334. range: "number",
  5335. search: "text",
  5336. tel: false,
  5337. time: false,
  5338. url: false,
  5339. week: false
  5340. };
  5341. // Backcompat remove in 1.5
  5342. $.mobile.page.prototype.options.degradeInputs = $.mobile.degradeInputs;
  5343. // Auto self-init widgets
  5344. $.mobile.degradeInputsWithin = function( target ) {
  5345. target = $( target );
  5346. // Degrade inputs to avoid poorly implemented native functionality
  5347. target.find( "input" ).not( $.mobile.page.prototype.keepNativeSelector() ).each(function() {
  5348. var element = $( this ),
  5349. type = this.getAttribute( "type" ),
  5350. optType = $.mobile.degradeInputs[ type ] || "text",
  5351. html, hasType, findstr, repstr;
  5352. if ( $.mobile.degradeInputs[ type ] ) {
  5353. html = $( "<div>" ).html( element.clone() ).html();
  5354. // In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead
  5355. hasType = html.indexOf( " type=" ) > -1;
  5356. findstr = hasType ? /\s+type=["']?\w+['"]?/ : /\/?>/;
  5357. repstr = " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\"" + ( hasType ? "" : ">" );
  5358. element.replaceWith( html.replace( findstr, repstr ) );
  5359. }
  5360. });
  5361. };
  5362. })( jQuery );
  5363. (function( $, window, undefined ) {
  5364. $.widget( "mobile.page", $.mobile.page, {
  5365. options: {
  5366. // Accepts left, right and none
  5367. closeBtn: "left",
  5368. closeBtnText: "Close",
  5369. overlayTheme: "a",
  5370. corners: true,
  5371. dialog: false
  5372. },
  5373. _create: function() {
  5374. this._super();
  5375. if ( this.options.dialog ) {
  5376. $.extend( this, {
  5377. _inner: this.element.children(),
  5378. _headerCloseButton: null
  5379. });
  5380. if ( !this.options.enhanced ) {
  5381. this._setCloseBtn( this.options.closeBtn );
  5382. }
  5383. }
  5384. },
  5385. _enhance: function() {
  5386. this._super();
  5387. // Class the markup for dialog styling and wrap interior
  5388. if ( this.options.dialog ) {
  5389. this.element.addClass( "ui-dialog" )
  5390. .wrapInner( $( "<div/>", {
  5391. // ARIA role
  5392. "role" : "dialog",
  5393. "class" : "ui-dialog-contain ui-overlay-shadow" +
  5394. ( this.options.corners ? " ui-corner-all" : "" )
  5395. }));
  5396. }
  5397. },
  5398. _setOptions: function( options ) {
  5399. var closeButtonLocation, closeButtonText,
  5400. currentOpts = this.options;
  5401. if ( options.corners !== undefined ) {
  5402. this._inner.toggleClass( "ui-corner-all", !!options.corners );
  5403. }
  5404. if ( options.overlayTheme !== undefined ) {
  5405. if ( $.mobile.activePage[ 0 ] === this.element[ 0 ] ) {
  5406. currentOpts.overlayTheme = options.overlayTheme;
  5407. this._handlePageBeforeShow();
  5408. }
  5409. }
  5410. if ( options.closeBtnText !== undefined ) {
  5411. closeButtonLocation = currentOpts.closeBtn;
  5412. closeButtonText = options.closeBtnText;
  5413. }
  5414. if ( options.closeBtn !== undefined ) {
  5415. closeButtonLocation = options.closeBtn;
  5416. }
  5417. if ( closeButtonLocation ) {
  5418. this._setCloseBtn( closeButtonLocation, closeButtonText );
  5419. }
  5420. this._super( options );
  5421. },
  5422. _handlePageBeforeShow: function () {
  5423. if ( this.options.overlayTheme && this.options.dialog ) {
  5424. this.removeContainerBackground();
  5425. this.setContainerBackground( this.options.overlayTheme );
  5426. } else {
  5427. this._super();
  5428. }
  5429. },
  5430. _setCloseBtn: function( location, text ) {
  5431. var dst,
  5432. btn = this._headerCloseButton;
  5433. // Sanitize value
  5434. location = "left" === location ? "left" : "right" === location ? "right" : "none";
  5435. if ( "none" === location ) {
  5436. if ( btn ) {
  5437. btn.remove();
  5438. btn = null;
  5439. }
  5440. } else if ( btn ) {
  5441. btn.removeClass( "ui-btn-left ui-btn-right" ).addClass( "ui-btn-" + location );
  5442. if ( text ) {
  5443. btn.text( text );
  5444. }
  5445. } else {
  5446. dst = this._inner.find( ":jqmData(role='header')" ).first();
  5447. btn = $( "<a></a>", {
  5448. "href": "#",
  5449. "class": "ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-" + location
  5450. })
  5451. .attr( "data-" + $.mobile.ns + "rel", "back" )
  5452. .text( text || this.options.closeBtnText || "" )
  5453. .prependTo( dst );
  5454. }
  5455. this._headerCloseButton = btn;
  5456. }
  5457. });
  5458. })( jQuery, this );
  5459. (function( $, window, undefined ) {
  5460. $.widget( "mobile.dialog", {
  5461. options: {
  5462. // Accepts left, right and none
  5463. closeBtn: "left",
  5464. closeBtnText: "Close",
  5465. overlayTheme: "a",
  5466. corners: true
  5467. },
  5468. // Override the theme set by the page plugin on pageshow
  5469. _handlePageBeforeShow: function() {
  5470. this._isCloseable = true;
  5471. if ( this.options.overlayTheme ) {
  5472. this.element
  5473. .page( "removeContainerBackground" )
  5474. .page( "setContainerBackground", this.options.overlayTheme );
  5475. }
  5476. },
  5477. _handlePageBeforeHide: function() {
  5478. this._isCloseable = false;
  5479. },
  5480. // click and submit events:
  5481. // - clicks and submits should use the closing transition that the dialog
  5482. // opened with unless a data-transition is specified on the link/form
  5483. // - if the click was on the close button, or the link has a data-rel="back"
  5484. // it'll go back in history naturally
  5485. _handleVClickSubmit: function( event ) {
  5486. var attrs,
  5487. $target = $( event.target ).closest( event.type === "vclick" ? "a" : "form" );
  5488. if ( $target.length && !$target.jqmData( "transition" ) ) {
  5489. attrs = {};
  5490. attrs[ "data-" + $.mobile.ns + "transition" ] =
  5491. ( $.mobile.navigate.history.getActive() || {} )[ "transition" ] ||
  5492. $.mobile.defaultDialogTransition;
  5493. attrs[ "data-" + $.mobile.ns + "direction" ] = "reverse";
  5494. $target.attr( attrs );
  5495. }
  5496. },
  5497. _create: function() {
  5498. var elem = this.element,
  5499. opts = this.options;
  5500. // Class the markup for dialog styling and wrap interior
  5501. elem.addClass( "ui-dialog" )
  5502. .wrapInner( $( "<div/>", {
  5503. // ARIA role
  5504. "role" : "dialog",
  5505. "class" : "ui-dialog-contain ui-overlay-shadow" +
  5506. ( !!opts.corners ? " ui-corner-all" : "" )
  5507. }));
  5508. $.extend( this, {
  5509. _isCloseable: false,
  5510. _inner: elem.children(),
  5511. _headerCloseButton: null
  5512. });
  5513. this._on( elem, {
  5514. vclick: "_handleVClickSubmit",
  5515. submit: "_handleVClickSubmit",
  5516. pagebeforeshow: "_handlePageBeforeShow",
  5517. pagebeforehide: "_handlePageBeforeHide"
  5518. });
  5519. this._setCloseBtn( opts.closeBtn );
  5520. },
  5521. _setOptions: function( options ) {
  5522. var closeButtonLocation, closeButtonText,
  5523. currentOpts = this.options;
  5524. if ( options.corners !== undefined ) {
  5525. this._inner.toggleClass( "ui-corner-all", !!options.corners );
  5526. }
  5527. if ( options.overlayTheme !== undefined ) {
  5528. if ( $.mobile.activePage[ 0 ] === this.element[ 0 ] ) {
  5529. currentOpts.overlayTheme = options.overlayTheme;
  5530. this._handlePageBeforeShow();
  5531. }
  5532. }
  5533. if ( options.closeBtnText !== undefined ) {
  5534. closeButtonLocation = currentOpts.closeBtn;
  5535. closeButtonText = options.closeBtnText;
  5536. }
  5537. if ( options.closeBtn !== undefined ) {
  5538. closeButtonLocation = options.closeBtn;
  5539. }
  5540. if ( closeButtonLocation ) {
  5541. this._setCloseBtn( closeButtonLocation, closeButtonText );
  5542. }
  5543. this._super( options );
  5544. },
  5545. _setCloseBtn: function( location, text ) {
  5546. var dst,
  5547. btn = this._headerCloseButton;
  5548. // Sanitize value
  5549. location = "left" === location ? "left" : "right" === location ? "right" : "none";
  5550. if ( "none" === location ) {
  5551. if ( btn ) {
  5552. btn.remove();
  5553. btn = null;
  5554. }
  5555. } else if ( btn ) {
  5556. btn.removeClass( "ui-btn-left ui-btn-right" ).addClass( "ui-btn-" + location );
  5557. if ( text ) {
  5558. btn.text( text );
  5559. }
  5560. } else {
  5561. dst = this._inner.find( ":jqmData(role='header')" ).first();
  5562. btn = $( "<a></a>", {
  5563. "role": "button",
  5564. "href": "#",
  5565. "class": "ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-" + location
  5566. })
  5567. .text( text || this.options.closeBtnText || "" )
  5568. .prependTo( dst );
  5569. this._on( btn, { click: "close" } );
  5570. }
  5571. this._headerCloseButton = btn;
  5572. },
  5573. // Close method goes back in history
  5574. close: function() {
  5575. var hist = $.mobile.navigate.history;
  5576. if ( this._isCloseable ) {
  5577. this._isCloseable = false;
  5578. // If the hash listening is enabled and there is at least one preceding history
  5579. // entry it's ok to go back. Initial pages with the dialog hash state are an example
  5580. // where the stack check is necessary
  5581. if ( $.mobile.hashListeningEnabled && hist.activeIndex > 0 ) {
  5582. $.mobile.back();
  5583. } else {
  5584. $.mobile.pageContainer.pagecontainer( "back" );
  5585. }
  5586. }
  5587. }
  5588. });
  5589. })( jQuery, this );
  5590. (function( $, undefined ) {
  5591. var rInitialLetter = /([A-Z])/g,
  5592. // Construct iconpos class from iconpos value
  5593. iconposClass = function( iconpos ) {
  5594. return ( "ui-btn-icon-" + ( iconpos === null ? "left" : iconpos ) );
  5595. };
  5596. $.widget( "mobile.collapsible", {
  5597. options: {
  5598. enhanced: false,
  5599. expandCueText: null,
  5600. collapseCueText: null,
  5601. collapsed: true,
  5602. heading: "h1,h2,h3,h4,h5,h6,legend",
  5603. collapsedIcon: null,
  5604. expandedIcon: null,
  5605. iconpos: null,
  5606. theme: null,
  5607. contentTheme: null,
  5608. inset: null,
  5609. corners: null,
  5610. mini: null
  5611. },
  5612. _create: function() {
  5613. var elem = this.element,
  5614. ui = {
  5615. accordion: elem
  5616. .closest( ":jqmData(role='collapsible-set')," +
  5617. ":jqmData(role='collapsibleset')" +
  5618. ( $.mobile.collapsibleset ? ", :mobile-collapsibleset" :
  5619. "" ) )
  5620. .addClass( "ui-collapsible-set" )
  5621. };
  5622. this._ui = ui;
  5623. this._renderedOptions = this._getOptions( this.options );
  5624. if ( this.options.enhanced ) {
  5625. ui.heading = this.element.children( ".ui-collapsible-heading" );
  5626. ui.content = ui.heading.next();
  5627. ui.anchor = ui.heading.children();
  5628. ui.status = ui.anchor.children( ".ui-collapsible-heading-status" );
  5629. } else {
  5630. this._enhance( elem, ui );
  5631. }
  5632. this._on( ui.heading, {
  5633. "tap": function() {
  5634. ui.heading.find( "a" ).first().addClass( $.mobile.activeBtnClass );
  5635. },
  5636. "click": function( event ) {
  5637. this._handleExpandCollapse( !ui.heading.hasClass( "ui-collapsible-heading-collapsed" ) );
  5638. event.preventDefault();
  5639. event.stopPropagation();
  5640. }
  5641. });
  5642. },
  5643. // Adjust the keys inside options for inherited values
  5644. _getOptions: function( options ) {
  5645. var key,
  5646. accordion = this._ui.accordion,
  5647. accordionWidget = this._ui.accordionWidget;
  5648. // Copy options
  5649. options = $.extend( {}, options );
  5650. if ( accordion.length && !accordionWidget ) {
  5651. this._ui.accordionWidget =
  5652. accordionWidget = accordion.data( "mobile-collapsibleset" );
  5653. }
  5654. for ( key in options ) {
  5655. // Retrieve the option value first from the options object passed in and, if
  5656. // null, from the parent accordion or, if that's null too, or if there's no
  5657. // parent accordion, then from the defaults.
  5658. options[ key ] =
  5659. ( options[ key ] != null ) ? options[ key ] :
  5660. ( accordionWidget ) ? accordionWidget.options[ key ] :
  5661. accordion.length ? $.mobile.getAttribute( accordion[ 0 ],
  5662. key.replace( rInitialLetter, "-$1" ).toLowerCase() ):
  5663. null;
  5664. if ( null == options[ key ] ) {
  5665. options[ key ] = $.mobile.collapsible.defaults[ key ];
  5666. }
  5667. }
  5668. return options;
  5669. },
  5670. _themeClassFromOption: function( prefix, value ) {
  5671. return ( value ? ( value === "none" ? "" : prefix + value ) : "" );
  5672. },
  5673. _enhance: function( elem, ui ) {
  5674. var iconclass,
  5675. opts = this._renderedOptions,
  5676. contentThemeClass = this._themeClassFromOption( "ui-body-", opts.contentTheme );
  5677. elem.addClass( "ui-collapsible " +
  5678. ( opts.inset ? "ui-collapsible-inset " : "" ) +
  5679. ( opts.inset && opts.corners ? "ui-corner-all " : "" ) +
  5680. ( contentThemeClass ? "ui-collapsible-themed-content " : "" ) );
  5681. ui.originalHeading = elem.children( this.options.heading ).first(),
  5682. ui.content = elem
  5683. .wrapInner( "<div " +
  5684. "class='ui-collapsible-content " +
  5685. contentThemeClass + "'></div>" )
  5686. .children( ".ui-collapsible-content" ),
  5687. ui.heading = ui.originalHeading;
  5688. // Replace collapsibleHeading if it's a legend
  5689. if ( ui.heading.is( "legend" ) ) {
  5690. ui.heading = $( "<div role='heading'>"+ ui.heading.html() +"</div>" );
  5691. ui.placeholder = $( "<div><!-- placeholder for legend --></div>" ).insertBefore( ui.originalHeading );
  5692. ui.originalHeading.remove();
  5693. }
  5694. iconclass = ( opts.collapsed ? ( opts.collapsedIcon ? "ui-icon-" + opts.collapsedIcon : "" ):
  5695. ( opts.expandedIcon ? "ui-icon-" + opts.expandedIcon : "" ) );
  5696. ui.status = $( "<span class='ui-collapsible-heading-status'></span>" );
  5697. ui.anchor = ui.heading
  5698. .detach()
  5699. //modify markup & attributes
  5700. .addClass( "ui-collapsible-heading" )
  5701. .append( ui.status )
  5702. .wrapInner( "<a href='#' class='ui-collapsible-heading-toggle'></a>" )
  5703. .find( "a" )
  5704. .first()
  5705. .addClass( "ui-btn " +
  5706. ( iconclass ? iconclass + " " : "" ) +
  5707. ( iconclass ? iconposClass( opts.iconpos ) +
  5708. " " : "" ) +
  5709. this._themeClassFromOption( "ui-btn-", opts.theme ) + " " +
  5710. ( opts.mini ? "ui-mini " : "" ) );
  5711. //drop heading in before content
  5712. ui.heading.insertBefore( ui.content );
  5713. this._handleExpandCollapse( this.options.collapsed );
  5714. return ui;
  5715. },
  5716. refresh: function() {
  5717. this._applyOptions( this.options );
  5718. this._renderedOptions = this._getOptions( this.options );
  5719. },
  5720. _applyOptions: function( options ) {
  5721. var isCollapsed, newTheme, oldTheme, hasCorners, hasIcon,
  5722. elem = this.element,
  5723. currentOpts = this._renderedOptions,
  5724. ui = this._ui,
  5725. anchor = ui.anchor,
  5726. status = ui.status,
  5727. opts = this._getOptions( options );
  5728. // First and foremost we need to make sure the collapsible is in the proper
  5729. // state, in case somebody decided to change the collapsed option at the
  5730. // same time as another option
  5731. if ( options.collapsed !== undefined ) {
  5732. this._handleExpandCollapse( options.collapsed );
  5733. }
  5734. isCollapsed = elem.hasClass( "ui-collapsible-collapsed" );
  5735. // We only need to apply the cue text for the current state right away.
  5736. // The cue text for the alternate state will be stored in the options
  5737. // and applied the next time the collapsible's state is toggled
  5738. if ( isCollapsed ) {
  5739. if ( opts.expandCueText !== undefined ) {
  5740. status.text( opts.expandCueText );
  5741. }
  5742. } else {
  5743. if ( opts.collapseCueText !== undefined ) {
  5744. status.text( opts.collapseCueText );
  5745. }
  5746. }
  5747. // Update icon
  5748. // Is it supposed to have an icon?
  5749. hasIcon =
  5750. // If the collapsedIcon is being set, consult that
  5751. ( opts.collapsedIcon !== undefined ? opts.collapsedIcon !== false :
  5752. // Otherwise consult the existing option value
  5753. currentOpts.collapsedIcon !== false );
  5754. // If any icon-related options have changed, make sure the new icon
  5755. // state is reflected by first removing all icon-related classes
  5756. // reflecting the current state and then adding all icon-related
  5757. // classes for the new state
  5758. if ( !( opts.iconpos === undefined &&
  5759. opts.collapsedIcon === undefined &&
  5760. opts.expandedIcon === undefined ) ) {
  5761. // Remove all current icon-related classes
  5762. anchor.removeClass( [ iconposClass( currentOpts.iconpos ) ]
  5763. .concat( ( currentOpts.expandedIcon ?
  5764. [ "ui-icon-" + currentOpts.expandedIcon ] : [] ) )
  5765. .concat( ( currentOpts.collapsedIcon ?
  5766. [ "ui-icon-" + currentOpts.collapsedIcon ] : [] ) )
  5767. .join( " " ) );
  5768. // Add new classes if an icon is supposed to be present
  5769. if ( hasIcon ) {
  5770. anchor.addClass(
  5771. [ iconposClass( opts.iconpos !== undefined ?
  5772. opts.iconpos : currentOpts.iconpos ) ]
  5773. .concat( isCollapsed ?
  5774. [ "ui-icon-" + ( opts.collapsedIcon !== undefined ?
  5775. opts.collapsedIcon :
  5776. currentOpts.collapsedIcon ) ] :
  5777. [ "ui-icon-" + ( opts.expandedIcon !== undefined ?
  5778. opts.expandedIcon :
  5779. currentOpts.expandedIcon ) ] )
  5780. .join( " " ) );
  5781. }
  5782. }
  5783. if ( opts.theme !== undefined ) {
  5784. oldTheme = this._themeClassFromOption( "ui-btn-", currentOpts.theme );
  5785. newTheme = this._themeClassFromOption( "ui-btn-", opts.theme );
  5786. anchor.removeClass( oldTheme ).addClass( newTheme );
  5787. }
  5788. if ( opts.contentTheme !== undefined ) {
  5789. oldTheme = this._themeClassFromOption( "ui-body-",
  5790. currentOpts.contentTheme );
  5791. newTheme = this._themeClassFromOption( "ui-body-",
  5792. opts.contentTheme );
  5793. ui.content.removeClass( oldTheme ).addClass( newTheme );
  5794. }
  5795. if ( opts.inset !== undefined ) {
  5796. elem.toggleClass( "ui-collapsible-inset", opts.inset );
  5797. hasCorners = !!( opts.inset && ( opts.corners || currentOpts.corners ) );
  5798. }
  5799. if ( opts.corners !== undefined ) {
  5800. hasCorners = !!( opts.corners && ( opts.inset || currentOpts.inset ) );
  5801. }
  5802. if ( hasCorners !== undefined ) {
  5803. elem.toggleClass( "ui-corner-all", hasCorners );
  5804. }
  5805. if ( opts.mini !== undefined ) {
  5806. anchor.toggleClass( "ui-mini", opts.mini );
  5807. }
  5808. },
  5809. _setOptions: function( options ) {
  5810. this._applyOptions( options );
  5811. this._super( options );
  5812. this._renderedOptions = this._getOptions( this.options );
  5813. },
  5814. _handleExpandCollapse: function( isCollapse ) {
  5815. var opts = this._renderedOptions,
  5816. ui = this._ui;
  5817. ui.status.text( isCollapse ? opts.expandCueText : opts.collapseCueText );
  5818. ui.heading
  5819. .toggleClass( "ui-collapsible-heading-collapsed", isCollapse )
  5820. .find( "a" ).first()
  5821. .toggleClass( "ui-icon-" + opts.expandedIcon, !isCollapse )
  5822. // logic or cause same icon for expanded/collapsed state would remove the ui-icon-class
  5823. .toggleClass( "ui-icon-" + opts.collapsedIcon, ( isCollapse || opts.expandedIcon === opts.collapsedIcon ) )
  5824. .removeClass( $.mobile.activeBtnClass );
  5825. this.element.toggleClass( "ui-collapsible-collapsed", isCollapse );
  5826. ui.content
  5827. .toggleClass( "ui-collapsible-content-collapsed", isCollapse )
  5828. .attr( "aria-hidden", isCollapse )
  5829. .trigger( "updatelayout" );
  5830. this.options.collapsed = isCollapse;
  5831. this._trigger( isCollapse ? "collapse" : "expand" );
  5832. },
  5833. expand: function() {
  5834. this._handleExpandCollapse( false );
  5835. },
  5836. collapse: function() {
  5837. this._handleExpandCollapse( true );
  5838. },
  5839. _destroy: function() {
  5840. var ui = this._ui,
  5841. opts = this.options;
  5842. if ( opts.enhanced ) {
  5843. return;
  5844. }
  5845. if ( ui.placeholder ) {
  5846. ui.originalHeading.insertBefore( ui.placeholder );
  5847. ui.placeholder.remove();
  5848. ui.heading.remove();
  5849. } else {
  5850. ui.status.remove();
  5851. ui.heading
  5852. .removeClass( "ui-collapsible-heading ui-collapsible-heading-collapsed" )
  5853. .children()
  5854. .contents()
  5855. .unwrap();
  5856. }
  5857. ui.anchor.contents().unwrap();
  5858. ui.content.contents().unwrap();
  5859. this.element
  5860. .removeClass( "ui-collapsible ui-collapsible-collapsed " +
  5861. "ui-collapsible-themed-content ui-collapsible-inset ui-corner-all" );
  5862. }
  5863. });
  5864. // Defaults to be used by all instances of collapsible if per-instance values
  5865. // are unset or if nothing is specified by way of inheritance from an accordion.
  5866. // Note that this hash does not contain options "collapsed" or "heading",
  5867. // because those are not inheritable.
  5868. $.mobile.collapsible.defaults = {
  5869. expandCueText: " click to expand contents",
  5870. collapseCueText: " click to collapse contents",
  5871. collapsedIcon: "plus",
  5872. contentTheme: "inherit",
  5873. expandedIcon: "minus",
  5874. iconpos: "left",
  5875. inset: true,
  5876. corners: true,
  5877. theme: "inherit",
  5878. mini: false
  5879. };
  5880. })( jQuery );
  5881. (function( $, undefined ) {
  5882. var uiScreenHiddenRegex = /\bui-screen-hidden\b/;
  5883. function noHiddenClass( elements ) {
  5884. var index,
  5885. length = elements.length,
  5886. result = [];
  5887. for ( index = 0; index < length; index++ ) {
  5888. if ( !elements[ index ].className.match( uiScreenHiddenRegex ) ) {
  5889. result.push( elements[ index ] );
  5890. }
  5891. }
  5892. return $( result );
  5893. }
  5894. $.mobile.behaviors.addFirstLastClasses = {
  5895. _getVisibles: function( $els, create ) {
  5896. var visibles;
  5897. if ( create ) {
  5898. visibles = noHiddenClass( $els );
  5899. } else {
  5900. visibles = $els.filter( ":visible" );
  5901. if ( visibles.length === 0 ) {
  5902. visibles = noHiddenClass( $els );
  5903. }
  5904. }
  5905. return visibles;
  5906. },
  5907. _addFirstLastClasses: function( $els, $visibles, create ) {
  5908. $els.removeClass( "ui-first-child ui-last-child" );
  5909. $visibles.eq( 0 ).addClass( "ui-first-child" ).end().last().addClass( "ui-last-child" );
  5910. if ( !create ) {
  5911. this.element.trigger( "updatelayout" );
  5912. }
  5913. },
  5914. _removeFirstLastClasses: function( $els ) {
  5915. $els.removeClass( "ui-first-child ui-last-child" );
  5916. }
  5917. };
  5918. })( jQuery );
  5919. (function( $, undefined ) {
  5920. var childCollapsiblesSelector = ":mobile-collapsible, " + $.mobile.collapsible.initSelector;
  5921. $.widget( "mobile.collapsibleset", $.extend( {
  5922. // The initSelector is deprecated as of 1.4.0. In 1.5.0 we will use
  5923. // :jqmData(role='collapsibleset') which will allow us to get rid of the line
  5924. // below altogether, because the autoinit will generate such an initSelector
  5925. initSelector: ":jqmData(role='collapsible-set'),:jqmData(role='collapsibleset')",
  5926. options: $.extend( {
  5927. enhanced: false
  5928. }, $.mobile.collapsible.defaults ),
  5929. _handleCollapsibleExpand: function( event ) {
  5930. var closestCollapsible = $( event.target ).closest( ".ui-collapsible" );
  5931. if ( closestCollapsible.parent().is( ":mobile-collapsibleset, :jqmData(role='collapsible-set')" ) ) {
  5932. closestCollapsible
  5933. .siblings( ".ui-collapsible:not(.ui-collapsible-collapsed)" )
  5934. .collapsible( "collapse" );
  5935. }
  5936. },
  5937. _create: function() {
  5938. var elem = this.element,
  5939. opts = this.options;
  5940. $.extend( this, {
  5941. _classes: ""
  5942. });
  5943. if ( !opts.enhanced ) {
  5944. elem.addClass( "ui-collapsible-set " +
  5945. this._themeClassFromOption( "ui-group-theme-", opts.theme ) + " " +
  5946. ( opts.corners && opts.inset ? "ui-corner-all " : "" ) );
  5947. this.element.find( $.mobile.collapsible.initSelector ).collapsible();
  5948. }
  5949. this._on( elem, { collapsibleexpand: "_handleCollapsibleExpand" } );
  5950. },
  5951. _themeClassFromOption: function( prefix, value ) {
  5952. return ( value ? ( value === "none" ? "" : prefix + value ) : "" );
  5953. },
  5954. _init: function() {
  5955. this._refresh( true );
  5956. // Because the corners are handled by the collapsible itself and the default state is collapsed
  5957. // That was causing https://github.com/jquery/jquery-mobile/issues/4116
  5958. this.element
  5959. .children( childCollapsiblesSelector )
  5960. .filter( ":jqmData(collapsed='false')" )
  5961. .collapsible( "expand" );
  5962. },
  5963. _setOptions: function( options ) {
  5964. var ret, hasCorners,
  5965. elem = this.element,
  5966. themeClass = this._themeClassFromOption( "ui-group-theme-", options.theme );
  5967. if ( themeClass ) {
  5968. elem
  5969. .removeClass( this._themeClassFromOption( "ui-group-theme-", this.options.theme ) )
  5970. .addClass( themeClass );
  5971. }
  5972. if ( options.inset !== undefined ) {
  5973. hasCorners = !!( options.inset && ( options.corners || this.options.corners ) );
  5974. }
  5975. if ( options.corners !== undefined ) {
  5976. hasCorners = !!( options.corners && ( options.inset || this.options.inset ) );
  5977. }
  5978. if ( hasCorners !== undefined ) {
  5979. elem.toggleClass( "ui-corner-all", hasCorners );
  5980. }
  5981. ret = this._super( options );
  5982. this.element.children( ":mobile-collapsible" ).collapsible( "refresh" );
  5983. return ret;
  5984. },
  5985. _destroy: function() {
  5986. var el = this.element;
  5987. this._removeFirstLastClasses( el.children( childCollapsiblesSelector ) );
  5988. el
  5989. .removeClass( "ui-collapsible-set ui-corner-all " +
  5990. this._themeClassFromOption( "ui-group-theme-", this.options.theme ) )
  5991. .children( ":mobile-collapsible" )
  5992. .collapsible( "destroy" );
  5993. },
  5994. _refresh: function( create ) {
  5995. var collapsiblesInSet = this.element.children( childCollapsiblesSelector );
  5996. this.element.find( $.mobile.collapsible.initSelector ).not( ".ui-collapsible" ).collapsible();
  5997. this._addFirstLastClasses( collapsiblesInSet, this._getVisibles( collapsiblesInSet, create ), create );
  5998. },
  5999. refresh: function() {
  6000. this._refresh( false );
  6001. }
  6002. }, $.mobile.behaviors.addFirstLastClasses ) );
  6003. })( jQuery );
  6004. (function( $, undefined ) {
  6005. // Deprecated in 1.4
  6006. $.fn.fieldcontain = function(/* options */) {
  6007. return this.addClass( "ui-field-contain" );
  6008. };
  6009. })( jQuery );
  6010. (function( $, undefined ) {
  6011. $.fn.grid = function( options ) {
  6012. return this.each(function() {
  6013. var $this = $( this ),
  6014. o = $.extend({
  6015. grid: null
  6016. }, options ),
  6017. $kids = $this.children(),
  6018. gridCols = { solo:1, a:2, b:3, c:4, d:5 },
  6019. grid = o.grid,
  6020. iterator,
  6021. letter;
  6022. if ( !grid ) {
  6023. if ( $kids.length <= 5 ) {
  6024. for ( letter in gridCols ) {
  6025. if ( gridCols[ letter ] === $kids.length ) {
  6026. grid = letter;
  6027. }
  6028. }
  6029. } else {
  6030. grid = "a";
  6031. $this.addClass( "ui-grid-duo" );
  6032. }
  6033. }
  6034. iterator = gridCols[grid];
  6035. $this.addClass( "ui-grid-" + grid );
  6036. $kids.filter( ":nth-child(" + iterator + "n+1)" ).addClass( "ui-block-a" );
  6037. if ( iterator > 1 ) {
  6038. $kids.filter( ":nth-child(" + iterator + "n+2)" ).addClass( "ui-block-b" );
  6039. }
  6040. if ( iterator > 2 ) {
  6041. $kids.filter( ":nth-child(" + iterator + "n+3)" ).addClass( "ui-block-c" );
  6042. }
  6043. if ( iterator > 3 ) {
  6044. $kids.filter( ":nth-child(" + iterator + "n+4)" ).addClass( "ui-block-d" );
  6045. }
  6046. if ( iterator > 4 ) {
  6047. $kids.filter( ":nth-child(" + iterator + "n+5)" ).addClass( "ui-block-e" );
  6048. }
  6049. });
  6050. };
  6051. })( jQuery );
  6052. (function( $, undefined ) {
  6053. $.widget( "mobile.navbar", {
  6054. options: {
  6055. iconpos: "top",
  6056. grid: null
  6057. },
  6058. _create: function() {
  6059. var $navbar = this.element,
  6060. $navbtns = $navbar.find( "a, button" ),
  6061. iconpos = $navbtns.filter( ":jqmData(icon)" ).length ? this.options.iconpos : undefined;
  6062. $navbar.addClass( "ui-navbar" )
  6063. .attr( "role", "navigation" )
  6064. .find( "ul" )
  6065. .jqmEnhanceable()
  6066. .grid({ grid: this.options.grid });
  6067. $navbtns
  6068. .each( function() {
  6069. var icon = $.mobile.getAttribute( this, "icon" ),
  6070. theme = $.mobile.getAttribute( this, "theme" ),
  6071. classes = "ui-btn";
  6072. if ( theme ) {
  6073. classes += " ui-btn-" + theme;
  6074. }
  6075. if ( icon ) {
  6076. classes += " ui-icon-" + icon + " ui-btn-icon-" + iconpos;
  6077. }
  6078. $( this ).addClass( classes );
  6079. });
  6080. $navbar.delegate( "a", "vclick", function( /* event */ ) {
  6081. var activeBtn = $( this );
  6082. if ( !( activeBtn.hasClass( "ui-state-disabled" ) ||
  6083. // DEPRECATED as of 1.4.0 - remove after 1.4.0 release
  6084. // only ui-state-disabled should be present thereafter
  6085. activeBtn.hasClass( "ui-disabled" ) ||
  6086. activeBtn.hasClass( $.mobile.activeBtnClass ) ) ) {
  6087. $navbtns.removeClass( $.mobile.activeBtnClass );
  6088. activeBtn.addClass( $.mobile.activeBtnClass );
  6089. // The code below is a workaround to fix #1181
  6090. $( document ).one( "pagehide", function() {
  6091. activeBtn.removeClass( $.mobile.activeBtnClass );
  6092. });
  6093. }
  6094. });
  6095. // Buttons in the navbar with ui-state-persist class should regain their active state before page show
  6096. $navbar.closest( ".ui-page" ).bind( "pagebeforeshow", function() {
  6097. $navbtns.filter( ".ui-state-persist" ).addClass( $.mobile.activeBtnClass );
  6098. });
  6099. }
  6100. });
  6101. })( jQuery );
  6102. (function( $, undefined ) {
  6103. var getAttr = $.mobile.getAttribute;
  6104. $.widget( "mobile.listview", $.extend( {
  6105. options: {
  6106. theme: null,
  6107. countTheme: null, /* Deprecated in 1.4 */
  6108. dividerTheme: null,
  6109. icon: "carat-r",
  6110. splitIcon: "carat-r",
  6111. splitTheme: null,
  6112. corners: true,
  6113. shadow: true,
  6114. inset: false
  6115. },
  6116. _create: function() {
  6117. var t = this,
  6118. listviewClasses = "";
  6119. listviewClasses += t.options.inset ? " ui-listview-inset" : "";
  6120. if ( !!t.options.inset ) {
  6121. listviewClasses += t.options.corners ? " ui-corner-all" : "";
  6122. listviewClasses += t.options.shadow ? " ui-shadow" : "";
  6123. }
  6124. // create listview markup
  6125. t.element.addClass( " ui-listview" + listviewClasses );
  6126. t.refresh( true );
  6127. },
  6128. // TODO: Remove in 1.5
  6129. _findFirstElementByTagName: function( ele, nextProp, lcName, ucName ) {
  6130. var dict = {};
  6131. dict[ lcName ] = dict[ ucName ] = true;
  6132. while ( ele ) {
  6133. if ( dict[ ele.nodeName ] ) {
  6134. return ele;
  6135. }
  6136. ele = ele[ nextProp ];
  6137. }
  6138. return null;
  6139. },
  6140. // TODO: Remove in 1.5
  6141. _addThumbClasses: function( containers ) {
  6142. var i, img, len = containers.length;
  6143. for ( i = 0; i < len; i++ ) {
  6144. img = $( this._findFirstElementByTagName( containers[ i ].firstChild, "nextSibling", "img", "IMG" ) );
  6145. if ( img.length ) {
  6146. $( this._findFirstElementByTagName( img[ 0 ].parentNode, "parentNode", "li", "LI" ) ).addClass( img.hasClass( "ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" );
  6147. }
  6148. }
  6149. },
  6150. _getChildrenByTagName: function( ele, lcName, ucName ) {
  6151. var results = [],
  6152. dict = {};
  6153. dict[ lcName ] = dict[ ucName ] = true;
  6154. ele = ele.firstChild;
  6155. while ( ele ) {
  6156. if ( dict[ ele.nodeName ] ) {
  6157. results.push( ele );
  6158. }
  6159. ele = ele.nextSibling;
  6160. }
  6161. return $( results );
  6162. },
  6163. _beforeListviewRefresh: $.noop,
  6164. _afterListviewRefresh: $.noop,
  6165. refresh: function( create ) {
  6166. var buttonClass, pos, numli, item, itemClass, itemTheme, itemIcon, icon, a,
  6167. isDivider, startCount, newStartCount, value, last, splittheme, splitThemeClass, spliticon,
  6168. altButtonClass, dividerTheme, li,
  6169. o = this.options,
  6170. $list = this.element,
  6171. ol = !!$.nodeName( $list[ 0 ], "ol" ),
  6172. start = $list.attr( "start" ),
  6173. itemClassDict = {},
  6174. countBubbles = $list.find( ".ui-li-count" ),
  6175. countTheme = getAttr( $list[ 0 ], "counttheme" ) || this.options.countTheme,
  6176. countThemeClass = countTheme ? "ui-body-" + countTheme : "ui-body-inherit";
  6177. if ( o.theme ) {
  6178. $list.addClass( "ui-group-theme-" + o.theme );
  6179. }
  6180. // Check if a start attribute has been set while taking a value of 0 into account
  6181. if ( ol && ( start || start === 0 ) ) {
  6182. startCount = parseInt( start, 10 ) - 1;
  6183. $list.css( "counter-reset", "listnumbering " + startCount );
  6184. }
  6185. this._beforeListviewRefresh();
  6186. li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" );
  6187. for ( pos = 0, numli = li.length; pos < numli; pos++ ) {
  6188. item = li.eq( pos );
  6189. itemClass = "";
  6190. if ( create || item[ 0 ].className.search( /\bui-li-static\b|\bui-li-divider\b/ ) < 0 ) {
  6191. a = this._getChildrenByTagName( item[ 0 ], "a", "A" );
  6192. isDivider = ( getAttr( item[ 0 ], "role" ) === "list-divider" );
  6193. value = item.attr( "value" );
  6194. itemTheme = getAttr( item[ 0 ], "theme" );
  6195. if ( a.length && a[ 0 ].className.search( /\bui-btn\b/ ) < 0 && !isDivider ) {
  6196. itemIcon = getAttr( item[ 0 ], "icon" );
  6197. icon = ( itemIcon === false ) ? false : ( itemIcon || o.icon );
  6198. // TODO: Remove in 1.5 together with links.js (links.js / .ui-link deprecated in 1.4)
  6199. a.removeClass( "ui-link" );
  6200. buttonClass = "ui-btn";
  6201. if ( itemTheme ) {
  6202. buttonClass += " ui-btn-" + itemTheme;
  6203. }
  6204. if ( a.length > 1 ) {
  6205. itemClass = "ui-li-has-alt";
  6206. last = a.last();
  6207. splittheme = getAttr( last[ 0 ], "theme" ) || o.splitTheme || getAttr( item[ 0 ], "theme", true );
  6208. splitThemeClass = splittheme ? " ui-btn-" + splittheme : "";
  6209. spliticon = getAttr( last[ 0 ], "icon" ) || getAttr( item[ 0 ], "icon" ) || o.splitIcon;
  6210. altButtonClass = "ui-btn ui-btn-icon-notext ui-icon-" + spliticon + splitThemeClass;
  6211. last
  6212. .attr( "title", $.trim( last.getEncodedText() ) )
  6213. .addClass( altButtonClass )
  6214. .empty();
  6215. // Reduce to the first anchor, because only the first gets the buttonClass
  6216. a = a.first();
  6217. } else if ( icon ) {
  6218. buttonClass += " ui-btn-icon-right ui-icon-" + icon;
  6219. }
  6220. // Apply buttonClass to the (first) anchor
  6221. a.addClass( buttonClass );
  6222. } else if ( isDivider ) {
  6223. dividerTheme = ( getAttr( item[ 0 ], "theme" ) || o.dividerTheme || o.theme );
  6224. itemClass = "ui-li-divider ui-bar-" + ( dividerTheme ? dividerTheme : "inherit" );
  6225. item.attr( "role", "heading" );
  6226. } else if ( a.length <= 0 ) {
  6227. itemClass = "ui-li-static ui-body-" + ( itemTheme ? itemTheme : "inherit" );
  6228. }
  6229. if ( ol && value ) {
  6230. newStartCount = parseInt( value , 10 ) - 1;
  6231. item.css( "counter-reset", "listnumbering " + newStartCount );
  6232. }
  6233. }
  6234. // Instead of setting item class directly on the list item
  6235. // at this point in time, push the item into a dictionary
  6236. // that tells us what class to set on it so we can do this after this
  6237. // processing loop is finished.
  6238. if ( !itemClassDict[ itemClass ] ) {
  6239. itemClassDict[ itemClass ] = [];
  6240. }
  6241. itemClassDict[ itemClass ].push( item[ 0 ] );
  6242. }
  6243. // Set the appropriate listview item classes on each list item.
  6244. // The main reason we didn't do this
  6245. // in the for-loop above is because we can eliminate per-item function overhead
  6246. // by calling addClass() and children() once or twice afterwards. This
  6247. // can give us a significant boost on platforms like WP7.5.
  6248. for ( itemClass in itemClassDict ) {
  6249. $( itemClassDict[ itemClass ] ).addClass( itemClass );
  6250. }
  6251. countBubbles.each( function() {
  6252. $( this ).closest( "li" ).addClass( "ui-li-has-count" );
  6253. });
  6254. if ( countThemeClass ) {
  6255. countBubbles.not( "[class*='ui-body-']" ).addClass( countThemeClass );
  6256. }
  6257. // Deprecated in 1.4. From 1.5 you have to add class ui-li-has-thumb or ui-li-has-icon to the LI.
  6258. this._addThumbClasses( li );
  6259. this._addThumbClasses( li.find( ".ui-btn" ) );
  6260. this._afterListviewRefresh();
  6261. this._addFirstLastClasses( li, this._getVisibles( li, create ), create );
  6262. }
  6263. }, $.mobile.behaviors.addFirstLastClasses ) );
  6264. })( jQuery );
  6265. (function( $, undefined ) {
  6266. function defaultAutodividersSelector( elt ) {
  6267. // look for the text in the given element
  6268. var text = $.trim( elt.text() ) || null;
  6269. if ( !text ) {
  6270. return null;
  6271. }
  6272. // create the text for the divider (first uppercased letter)
  6273. text = text.slice( 0, 1 ).toUpperCase();
  6274. return text;
  6275. }
  6276. $.widget( "mobile.listview", $.mobile.listview, {
  6277. options: {
  6278. autodividers: false,
  6279. autodividersSelector: defaultAutodividersSelector
  6280. },
  6281. _beforeListviewRefresh: function() {
  6282. if ( this.options.autodividers ) {
  6283. this._replaceDividers();
  6284. this._superApply( arguments );
  6285. }
  6286. },
  6287. _replaceDividers: function() {
  6288. var i, lis, li, dividerText,
  6289. lastDividerText = null,
  6290. list = this.element,
  6291. divider;
  6292. list.children( "li:jqmData(role='list-divider')" ).remove();
  6293. lis = list.children( "li" );
  6294. for ( i = 0; i < lis.length ; i++ ) {
  6295. li = lis[ i ];
  6296. dividerText = this.options.autodividersSelector( $( li ) );
  6297. if ( dividerText && lastDividerText !== dividerText ) {
  6298. divider = document.createElement( "li" );
  6299. divider.appendChild( document.createTextNode( dividerText ) );
  6300. divider.setAttribute( "data-" + $.mobile.ns + "role", "list-divider" );
  6301. li.parentNode.insertBefore( divider, li );
  6302. }
  6303. lastDividerText = dividerText;
  6304. }
  6305. }
  6306. });
  6307. })( jQuery );
  6308. (function( $, undefined ) {
  6309. var rdivider = /(^|\s)ui-li-divider($|\s)/,
  6310. rhidden = /(^|\s)ui-screen-hidden($|\s)/;
  6311. $.widget( "mobile.listview", $.mobile.listview, {
  6312. options: {
  6313. hideDividers: false
  6314. },
  6315. _afterListviewRefresh: function() {
  6316. var items, idx, item, hideDivider = true;
  6317. this._superApply( arguments );
  6318. if ( this.options.hideDividers ) {
  6319. items = this._getChildrenByTagName( this.element[ 0 ], "li", "LI" );
  6320. for ( idx = items.length - 1 ; idx > -1 ; idx-- ) {
  6321. item = items[ idx ];
  6322. if ( item.className.match( rdivider ) ) {
  6323. if ( hideDivider ) {
  6324. item.className = item.className + " ui-screen-hidden";
  6325. }
  6326. hideDivider = true;
  6327. } else {
  6328. if ( !item.className.match( rhidden ) ) {
  6329. hideDivider = false;
  6330. }
  6331. }
  6332. }
  6333. }
  6334. }
  6335. });
  6336. })( jQuery );
  6337. (function( $, undefined ) {
  6338. $.mobile.nojs = function( target ) {
  6339. $( ":jqmData(role='nojs')", target ).addClass( "ui-nojs" );
  6340. };
  6341. })( jQuery );
  6342. (function( $, undefined ) {
  6343. $.mobile.behaviors.formReset = {
  6344. _handleFormReset: function() {
  6345. this._on( this.element.closest( "form" ), {
  6346. reset: function() {
  6347. this._delay( "_reset" );
  6348. }
  6349. });
  6350. }
  6351. };
  6352. })( jQuery );
  6353. /*
  6354. * "checkboxradio" plugin
  6355. */
  6356. (function( $, undefined ) {
  6357. var escapeId = $.mobile.path.hashToSelector;
  6358. $.widget( "mobile.checkboxradio", $.extend( {
  6359. initSelector: "input:not( :jqmData(role='flipswitch' ) )[type='checkbox'],input[type='radio']:not( :jqmData(role='flipswitch' ))",
  6360. options: {
  6361. theme: "inherit",
  6362. mini: false,
  6363. wrapperClass: null,
  6364. enhanced: false,
  6365. iconpos: "left"
  6366. },
  6367. _create: function() {
  6368. var input = this.element,
  6369. o = this.options,
  6370. inheritAttr = function( input, dataAttr ) {
  6371. return input.jqmData( dataAttr ) ||
  6372. input.closest( "form, fieldset" ).jqmData( dataAttr );
  6373. },
  6374. label = this.options.enhanced ?
  6375. {
  6376. element: this.element.siblings( "label" ),
  6377. isParent: false
  6378. } :
  6379. this._findLabel(),
  6380. inputtype = input[0].type,
  6381. checkedClass = "ui-" + inputtype + "-on",
  6382. uncheckedClass = "ui-" + inputtype + "-off";
  6383. if ( inputtype !== "checkbox" && inputtype !== "radio" ) {
  6384. return;
  6385. }
  6386. if ( this.element[0].disabled ) {
  6387. this.options.disabled = true;
  6388. }
  6389. o.iconpos = inheritAttr( input, "iconpos" ) ||
  6390. label.element.attr( "data-" + $.mobile.ns + "iconpos" ) || o.iconpos,
  6391. // Establish options
  6392. o.mini = inheritAttr( input, "mini" ) || o.mini;
  6393. // Expose for other methods
  6394. $.extend( this, {
  6395. input: input,
  6396. label: label.element,
  6397. labelIsParent: label.isParent,
  6398. inputtype: inputtype,
  6399. checkedClass: checkedClass,
  6400. uncheckedClass: uncheckedClass
  6401. });
  6402. if ( !this.options.enhanced ) {
  6403. this._enhance();
  6404. }
  6405. this._on( label.element, {
  6406. vmouseover: "_handleLabelVMouseOver",
  6407. vclick: "_handleLabelVClick"
  6408. });
  6409. this._on( input, {
  6410. vmousedown: "_cacheVals",
  6411. vclick: "_handleInputVClick",
  6412. focus: "_handleInputFocus",
  6413. blur: "_handleInputBlur"
  6414. });
  6415. this._handleFormReset();
  6416. this.refresh();
  6417. },
  6418. _findLabel: function() {
  6419. var parentLabel, label, isParent,
  6420. input = this.element,
  6421. labelsList = input[ 0 ].labels;
  6422. if( labelsList && labelsList.length > 0 ) {
  6423. label = $( labelsList[ 0 ] );
  6424. isParent = $.contains( label[ 0 ], input[ 0 ] );
  6425. } else {
  6426. parentLabel = input.closest( "label" );
  6427. isParent = ( parentLabel.length > 0 );
  6428. // NOTE: Windows Phone could not find the label through a selector
  6429. // filter works though.
  6430. label = isParent ? parentLabel :
  6431. $( this.document[ 0 ].getElementsByTagName( "label" ) )
  6432. .filter( "[for='" + escapeId( input[ 0 ].id ) + "']" )
  6433. .first();
  6434. }
  6435. return {
  6436. element: label,
  6437. isParent: isParent
  6438. };
  6439. },
  6440. _enhance: function() {
  6441. this.label.addClass( "ui-btn ui-corner-all");
  6442. if ( this.labelIsParent ) {
  6443. this.input.add( this.label ).wrapAll( this._wrapper() );
  6444. } else {
  6445. //this.element.replaceWith( this.input.add( this.label ).wrapAll( this._wrapper() ) );
  6446. this.element.wrap( this._wrapper() );
  6447. this.element.parent().prepend( this.label );
  6448. }
  6449. // Wrap the input + label in a div
  6450. this._setOptions({
  6451. "theme": this.options.theme,
  6452. "iconpos": this.options.iconpos,
  6453. "mini": this.options.mini
  6454. });
  6455. },
  6456. _wrapper: function() {
  6457. return $( "<div class='" +
  6458. ( this.options.wrapperClass ? this.options.wrapperClass : "" ) +
  6459. " ui-" + this.inputtype +
  6460. ( this.options.disabled ? " ui-state-disabled" : "" ) + "' ></div>" );
  6461. },
  6462. _handleInputFocus: function() {
  6463. this.label.addClass( $.mobile.focusClass );
  6464. },
  6465. _handleInputBlur: function() {
  6466. this.label.removeClass( $.mobile.focusClass );
  6467. },
  6468. _handleInputVClick: function() {
  6469. // Adds checked attribute to checked input when keyboard is used
  6470. this.element.prop( "checked", this.element.is( ":checked" ) );
  6471. this._getInputSet().not( this.element ).prop( "checked", false );
  6472. this._updateAll( true );
  6473. },
  6474. _handleLabelVMouseOver: function( event ) {
  6475. if ( this.label.parent().hasClass( "ui-state-disabled" ) ) {
  6476. event.stopPropagation();
  6477. }
  6478. },
  6479. _handleLabelVClick: function( event ) {
  6480. var input = this.element;
  6481. if ( input.is( ":disabled" ) ) {
  6482. event.preventDefault();
  6483. return;
  6484. }
  6485. this._cacheVals();
  6486. input.prop( "checked", this.inputtype === "radio" && true || !input.prop( "checked" ) );
  6487. // trigger click handler's bound directly to the input as a substitute for
  6488. // how label clicks behave normally in the browsers
  6489. // TODO: it would be nice to let the browser's handle the clicks and pass them
  6490. // through to the associate input. we can swallow that click at the parent
  6491. // wrapper element level
  6492. input.triggerHandler( "click" );
  6493. // Input set for common radio buttons will contain all the radio
  6494. // buttons, but will not for checkboxes. clearing the checked status
  6495. // of other radios ensures the active button state is applied properly
  6496. this._getInputSet().not( input ).prop( "checked", false );
  6497. this._updateAll();
  6498. return false;
  6499. },
  6500. _cacheVals: function() {
  6501. this._getInputSet().each( function() {
  6502. $( this ).attr("data-" + $.mobile.ns + "cacheVal", this.checked );
  6503. });
  6504. },
  6505. // Returns those radio buttons that are supposed to be in the same group as
  6506. // this radio button. In the case of a checkbox or a radio lacking a name
  6507. // attribute, it returns this.element.
  6508. _getInputSet: function() {
  6509. var selector, formId,
  6510. radio = this.element[ 0 ],
  6511. name = radio.name,
  6512. form = radio.form,
  6513. doc = this.element.parents().last().get( 0 ),
  6514. // A radio is always a member of its own group
  6515. radios = this.element;
  6516. // Only start running selectors if this is an attached radio button with a name
  6517. if ( name && this.inputtype === "radio" && doc ) {
  6518. selector = "input[type='radio'][name='" + escapeId( name ) + "']";
  6519. // If we're inside a form
  6520. if ( form ) {
  6521. formId = form.getAttribute( "id" );
  6522. // If the form has an ID, collect radios scattered throught the document which
  6523. // nevertheless are part of the form by way of the value of their form attribute
  6524. if ( formId ) {
  6525. radios = $( selector + "[form='" + escapeId( formId ) + "']", doc );
  6526. }
  6527. // Also add to those the radios in the form itself
  6528. radios = $( form ).find( selector ).filter( function() {
  6529. // Some radios inside the form may belong to some other form by virtue of
  6530. // having a form attribute defined on them, so we must filter them out here
  6531. return ( this.form === form );
  6532. }).add( radios );
  6533. // If we're outside a form
  6534. } else {
  6535. // Collect all those radios which are also outside of a form and match our name
  6536. radios = $( selector, doc ).filter( function() {
  6537. return !this.form;
  6538. });
  6539. }
  6540. }
  6541. return radios;
  6542. },
  6543. _updateAll: function( changeTriggered ) {
  6544. var self = this;
  6545. this._getInputSet().each( function() {
  6546. var $this = $( this );
  6547. if ( ( this.checked || self.inputtype === "checkbox" ) && !changeTriggered ) {
  6548. $this.trigger( "change" );
  6549. }
  6550. })
  6551. .checkboxradio( "refresh" );
  6552. },
  6553. _reset: function() {
  6554. this.refresh();
  6555. },
  6556. // Is the widget supposed to display an icon?
  6557. _hasIcon: function() {
  6558. var controlgroup, controlgroupWidget,
  6559. controlgroupConstructor = $.mobile.controlgroup;
  6560. // If the controlgroup widget is defined ...
  6561. if ( controlgroupConstructor ) {
  6562. controlgroup = this.element.closest(
  6563. ":mobile-controlgroup," +
  6564. controlgroupConstructor.prototype.initSelector );
  6565. // ... and the checkbox is in a controlgroup ...
  6566. if ( controlgroup.length > 0 ) {
  6567. // ... look for a controlgroup widget instance, and ...
  6568. controlgroupWidget = $.data( controlgroup[ 0 ], "mobile-controlgroup" );
  6569. // ... if found, decide based on the option value, ...
  6570. return ( ( controlgroupWidget ? controlgroupWidget.options.type :
  6571. // ... otherwise decide based on the "type" data attribute.
  6572. controlgroup.attr( "data-" + $.mobile.ns + "type" ) ) !== "horizontal" );
  6573. }
  6574. }
  6575. // Normally, the widget displays an icon.
  6576. return true;
  6577. },
  6578. refresh: function() {
  6579. var isChecked = this.element[ 0 ].checked,
  6580. active = $.mobile.activeBtnClass,
  6581. iconposClass = "ui-btn-icon-" + this.options.iconpos,
  6582. addClasses = [],
  6583. removeClasses = [];
  6584. if ( this._hasIcon() ) {
  6585. removeClasses.push( active );
  6586. addClasses.push( iconposClass );
  6587. } else {
  6588. removeClasses.push( iconposClass );
  6589. ( isChecked ? addClasses : removeClasses ).push( active );
  6590. }
  6591. if ( isChecked ) {
  6592. addClasses.push( this.checkedClass );
  6593. removeClasses.push( this.uncheckedClass );
  6594. } else {
  6595. addClasses.push( this.uncheckedClass );
  6596. removeClasses.push( this.checkedClass );
  6597. }
  6598. this.widget().toggleClass( "ui-state-disabled", this.element.prop( "disabled" ) );
  6599. this.label
  6600. .addClass( addClasses.join( " " ) )
  6601. .removeClass( removeClasses.join( " " ) );
  6602. },
  6603. widget: function() {
  6604. return this.label.parent();
  6605. },
  6606. _setOptions: function( options ) {
  6607. var label = this.label,
  6608. currentOptions = this.options,
  6609. outer = this.widget(),
  6610. hasIcon = this._hasIcon();
  6611. if ( options.disabled !== undefined ) {
  6612. this.input.prop( "disabled", !!options.disabled );
  6613. outer.toggleClass( "ui-state-disabled", !!options.disabled );
  6614. }
  6615. if ( options.mini !== undefined ) {
  6616. outer.toggleClass( "ui-mini", !!options.mini );
  6617. }
  6618. if ( options.theme !== undefined ) {
  6619. label
  6620. .removeClass( "ui-btn-" + currentOptions.theme )
  6621. .addClass( "ui-btn-" + options.theme );
  6622. }
  6623. if ( options.wrapperClass !== undefined ) {
  6624. outer
  6625. .removeClass( currentOptions.wrapperClass )
  6626. .addClass( options.wrapperClass );
  6627. }
  6628. if ( options.iconpos !== undefined && hasIcon ) {
  6629. label.removeClass( "ui-btn-icon-" + currentOptions.iconpos ).addClass( "ui-btn-icon-" + options.iconpos );
  6630. } else if ( !hasIcon ) {
  6631. label.removeClass( "ui-btn-icon-" + currentOptions.iconpos );
  6632. }
  6633. this._super( options );
  6634. }
  6635. }, $.mobile.behaviors.formReset ) );
  6636. })( jQuery );
  6637. (function( $, undefined ) {
  6638. $.widget( "mobile.button", {
  6639. initSelector: "input[type='button'], input[type='submit'], input[type='reset']",
  6640. options: {
  6641. theme: null,
  6642. icon: null,
  6643. iconpos: "left",
  6644. iconshadow: false, /* TODO: Deprecated in 1.4, remove in 1.5. */
  6645. corners: true,
  6646. shadow: true,
  6647. inline: null,
  6648. mini: null,
  6649. wrapperClass: null,
  6650. enhanced: false
  6651. },
  6652. _create: function() {
  6653. if ( this.element.is( ":disabled" ) ) {
  6654. this.options.disabled = true;
  6655. }
  6656. if ( !this.options.enhanced ) {
  6657. this._enhance();
  6658. }
  6659. $.extend( this, {
  6660. wrapper: this.element.parent()
  6661. });
  6662. this._on( {
  6663. focus: function() {
  6664. this.widget().addClass( $.mobile.focusClass );
  6665. },
  6666. blur: function() {
  6667. this.widget().removeClass( $.mobile.focusClass );
  6668. }
  6669. });
  6670. this.refresh( true );
  6671. },
  6672. _enhance: function() {
  6673. this.element.wrap( this._button() );
  6674. },
  6675. _button: function() {
  6676. var options = this.options,
  6677. iconClasses = this._getIconClasses( this.options );
  6678. return $("<div class='ui-btn ui-input-btn" +
  6679. ( options.wrapperClass ? " " + options.wrapperClass : "" ) +
  6680. ( options.theme ? " ui-btn-" + options.theme : "" ) +
  6681. ( options.corners ? " ui-corner-all" : "" ) +
  6682. ( options.shadow ? " ui-shadow" : "" ) +
  6683. ( options.inline ? " ui-btn-inline" : "" ) +
  6684. ( options.mini ? " ui-mini" : "" ) +
  6685. ( options.disabled ? " ui-state-disabled" : "" ) +
  6686. ( iconClasses ? ( " " + iconClasses ) : "" ) +
  6687. "' >" + this.element.val() + "</div>" );
  6688. },
  6689. widget: function() {
  6690. return this.wrapper;
  6691. },
  6692. _destroy: function() {
  6693. this.element.insertBefore( this.wrapper );
  6694. this.wrapper.remove();
  6695. },
  6696. _getIconClasses: function( options ) {
  6697. return ( options.icon ? ( "ui-icon-" + options.icon +
  6698. ( options.iconshadow ? " ui-shadow-icon" : "" ) + /* TODO: Deprecated in 1.4, remove in 1.5. */
  6699. " ui-btn-icon-" + options.iconpos ) : "" );
  6700. },
  6701. _setOptions: function( options ) {
  6702. var outer = this.widget();
  6703. if ( options.theme !== undefined ) {
  6704. outer
  6705. .removeClass( this.options.theme )
  6706. .addClass( "ui-btn-" + options.theme );
  6707. }
  6708. if ( options.corners !== undefined ) {
  6709. outer.toggleClass( "ui-corner-all", options.corners );
  6710. }
  6711. if ( options.shadow !== undefined ) {
  6712. outer.toggleClass( "ui-shadow", options.shadow );
  6713. }
  6714. if ( options.inline !== undefined ) {
  6715. outer.toggleClass( "ui-btn-inline", options.inline );
  6716. }
  6717. if ( options.mini !== undefined ) {
  6718. outer.toggleClass( "ui-mini", options.mini );
  6719. }
  6720. if ( options.disabled !== undefined ) {
  6721. this.element.prop( "disabled", options.disabled );
  6722. outer.toggleClass( "ui-state-disabled", options.disabled );
  6723. }
  6724. if ( options.icon !== undefined ||
  6725. options.iconshadow !== undefined || /* TODO: Deprecated in 1.4, remove in 1.5. */
  6726. options.iconpos !== undefined ) {
  6727. outer
  6728. .removeClass( this._getIconClasses( this.options ) )
  6729. .addClass( this._getIconClasses(
  6730. $.extend( {}, this.options, options ) ) );
  6731. }
  6732. this._super( options );
  6733. },
  6734. refresh: function( create ) {
  6735. var originalElement,
  6736. isDisabled = this.element.prop( "disabled" );
  6737. if ( this.options.icon && this.options.iconpos === "notext" && this.element.attr( "title" ) ) {
  6738. this.element.attr( "title", this.element.val() );
  6739. }
  6740. if ( !create ) {
  6741. originalElement = this.element.detach();
  6742. $( this.wrapper ).text( this.element.val() ).append( originalElement );
  6743. }
  6744. if ( this.options.disabled !== isDisabled ) {
  6745. this._setOptions({ disabled: isDisabled });
  6746. }
  6747. }
  6748. });
  6749. })( jQuery );
  6750. (function( $ ) {
  6751. var meta = $( "meta[name=viewport]" ),
  6752. initialContent = meta.attr( "content" ),
  6753. disabledZoom = initialContent + ",maximum-scale=1, user-scalable=no",
  6754. enabledZoom = initialContent + ",maximum-scale=10, user-scalable=yes",
  6755. disabledInitially = /(user-scalable[\s]*=[\s]*no)|(maximum-scale[\s]*=[\s]*1)[$,\s]/.test( initialContent );
  6756. $.mobile.zoom = $.extend( {}, {
  6757. enabled: !disabledInitially,
  6758. locked: false,
  6759. disable: function( lock ) {
  6760. if ( !disabledInitially && !$.mobile.zoom.locked ) {
  6761. meta.attr( "content", disabledZoom );
  6762. $.mobile.zoom.enabled = false;
  6763. $.mobile.zoom.locked = lock || false;
  6764. }
  6765. },
  6766. enable: function( unlock ) {
  6767. if ( !disabledInitially && ( !$.mobile.zoom.locked || unlock === true ) ) {
  6768. meta.attr( "content", enabledZoom );
  6769. $.mobile.zoom.enabled = true;
  6770. $.mobile.zoom.locked = false;
  6771. }
  6772. },
  6773. restore: function() {
  6774. if ( !disabledInitially ) {
  6775. meta.attr( "content", initialContent );
  6776. $.mobile.zoom.enabled = true;
  6777. }
  6778. }
  6779. });
  6780. }( jQuery ));
  6781. (function( $, undefined ) {
  6782. $.widget( "mobile.textinput", {
  6783. initSelector: "input[type='text']," +
  6784. "input[type='search']," +
  6785. ":jqmData(type='search')," +
  6786. "input[type='number']," +
  6787. ":jqmData(type='number')," +
  6788. "input[type='password']," +
  6789. "input[type='email']," +
  6790. "input[type='url']," +
  6791. "input[type='tel']," +
  6792. "textarea," +
  6793. "input[type='time']," +
  6794. "input[type='date']," +
  6795. "input[type='month']," +
  6796. "input[type='week']," +
  6797. "input[type='datetime']," +
  6798. "input[type='datetime-local']," +
  6799. "input[type='color']," +
  6800. "input:not([type])," +
  6801. "input[type='file']",
  6802. options: {
  6803. theme: null,
  6804. corners: true,
  6805. mini: false,
  6806. // This option defaults to true on iOS devices.
  6807. preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
  6808. wrapperClass: "",
  6809. enhanced: false
  6810. },
  6811. _create: function() {
  6812. var options = this.options,
  6813. isSearch = this.element.is( "[type='search'], :jqmData(type='search')" ),
  6814. isTextarea = this.element[ 0 ].tagName === "TEXTAREA",
  6815. isRange = this.element.is( "[data-" + ( $.mobile.ns || "" ) + "type='range']" ),
  6816. inputNeedsWrap = ( (this.element.is( "input" ) ||
  6817. this.element.is( "[data-" + ( $.mobile.ns || "" ) + "type='search']" ) ) &&
  6818. !isRange );
  6819. if ( this.element.prop( "disabled" ) ) {
  6820. options.disabled = true;
  6821. }
  6822. $.extend( this, {
  6823. classes: this._classesFromOptions(),
  6824. isSearch: isSearch,
  6825. isTextarea: isTextarea,
  6826. isRange: isRange,
  6827. inputNeedsWrap: inputNeedsWrap
  6828. });
  6829. this._autoCorrect();
  6830. if ( !options.enhanced ) {
  6831. this._enhance();
  6832. }
  6833. this._on( {
  6834. "focus": "_handleFocus",
  6835. "blur": "_handleBlur"
  6836. });
  6837. },
  6838. refresh: function() {
  6839. this.setOptions({
  6840. "disabled" : this.element.is( ":disabled" )
  6841. });
  6842. },
  6843. _enhance: function() {
  6844. var elementClasses = [];
  6845. if ( this.isTextarea ) {
  6846. elementClasses.push( "ui-input-text" );
  6847. }
  6848. if ( this.isTextarea || this.isRange ) {
  6849. elementClasses.push( "ui-shadow-inset" );
  6850. }
  6851. //"search" and "text" input widgets
  6852. if ( this.inputNeedsWrap ) {
  6853. this.element.wrap( this._wrap() );
  6854. } else {
  6855. elementClasses = elementClasses.concat( this.classes );
  6856. }
  6857. this.element.addClass( elementClasses.join( " " ) );
  6858. },
  6859. widget: function() {
  6860. return ( this.inputNeedsWrap ) ? this.element.parent() : this.element;
  6861. },
  6862. _classesFromOptions: function() {
  6863. var options = this.options,
  6864. classes = [];
  6865. classes.push( "ui-body-" + ( ( options.theme === null ) ? "inherit" : options.theme ) );
  6866. if ( options.corners ) {
  6867. classes.push( "ui-corner-all" );
  6868. }
  6869. if ( options.mini ) {
  6870. classes.push( "ui-mini" );
  6871. }
  6872. if ( options.disabled ) {
  6873. classes.push( "ui-state-disabled" );
  6874. }
  6875. if ( options.wrapperClass ) {
  6876. classes.push( options.wrapperClass );
  6877. }
  6878. return classes;
  6879. },
  6880. _wrap: function() {
  6881. return $( "<div class='" +
  6882. ( this.isSearch ? "ui-input-search " : "ui-input-text " ) +
  6883. this.classes.join( " " ) + " " +
  6884. "ui-shadow-inset'></div>" );
  6885. },
  6886. _autoCorrect: function() {
  6887. // XXX: Temporary workaround for issue 785 (Apple bug 8910589).
  6888. // Turn off autocorrect and autocomplete on non-iOS 5 devices
  6889. // since the popup they use can't be dismissed by the user. Note
  6890. // that we test for the presence of the feature by looking for
  6891. // the autocorrect property on the input element. We currently
  6892. // have no test for iOS 5 or newer so we're temporarily using
  6893. // the touchOverflow support flag for jQM 1.0. Yes, I feel dirty.
  6894. // - jblas
  6895. if ( typeof this.element[0].autocorrect !== "undefined" &&
  6896. !$.support.touchOverflow ) {
  6897. // Set the attribute instead of the property just in case there
  6898. // is code that attempts to make modifications via HTML.
  6899. this.element[0].setAttribute( "autocorrect", "off" );
  6900. this.element[0].setAttribute( "autocomplete", "off" );
  6901. }
  6902. },
  6903. _handleBlur: function() {
  6904. this.widget().removeClass( $.mobile.focusClass );
  6905. if ( this.options.preventFocusZoom ) {
  6906. $.mobile.zoom.enable( true );
  6907. }
  6908. },
  6909. _handleFocus: function() {
  6910. // In many situations, iOS will zoom into the input upon tap, this
  6911. // prevents that from happening
  6912. if ( this.options.preventFocusZoom ) {
  6913. $.mobile.zoom.disable( true );
  6914. }
  6915. this.widget().addClass( $.mobile.focusClass );
  6916. },
  6917. _setOptions: function ( options ) {
  6918. var outer = this.widget();
  6919. this._super( options );
  6920. if ( !( options.disabled === undefined &&
  6921. options.mini === undefined &&
  6922. options.corners === undefined &&
  6923. options.theme === undefined &&
  6924. options.wrapperClass === undefined ) ) {
  6925. outer.removeClass( this.classes.join( " " ) );
  6926. this.classes = this._classesFromOptions();
  6927. outer.addClass( this.classes.join( " " ) );
  6928. }
  6929. if ( options.disabled !== undefined ) {
  6930. this.element.prop( "disabled", !!options.disabled );
  6931. }
  6932. },
  6933. _destroy: function() {
  6934. if ( this.options.enhanced ) {
  6935. return;
  6936. }
  6937. if ( this.inputNeedsWrap ) {
  6938. this.element.unwrap();
  6939. }
  6940. this.element.removeClass( "ui-input-text " + this.classes.join( " " ) );
  6941. }
  6942. });
  6943. })( jQuery );
  6944. (function( $, undefined ) {
  6945. $.widget( "mobile.slider", $.extend( {
  6946. initSelector: "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')",
  6947. widgetEventPrefix: "slide",
  6948. options: {
  6949. theme: null,
  6950. trackTheme: null,
  6951. corners: true,
  6952. mini: false,
  6953. highlight: false
  6954. },
  6955. _create: function() {
  6956. // TODO: Each of these should have comments explain what they're for
  6957. var self = this,
  6958. control = this.element,
  6959. trackTheme = this.options.trackTheme || $.mobile.getAttribute( control[ 0 ], "theme" ),
  6960. trackThemeClass = trackTheme ? " ui-bar-" + trackTheme : " ui-bar-inherit",
  6961. cornerClass = ( this.options.corners || control.jqmData( "corners" ) ) ? " ui-corner-all" : "",
  6962. miniClass = ( this.options.mini || control.jqmData( "mini" ) ) ? " ui-mini" : "",
  6963. cType = control[ 0 ].nodeName.toLowerCase(),
  6964. isToggleSwitch = ( cType === "select" ),
  6965. isRangeslider = control.parent().is( ":jqmData(role='rangeslider')" ),
  6966. selectClass = ( isToggleSwitch ) ? "ui-slider-switch" : "",
  6967. controlID = control.attr( "id" ),
  6968. $label = $( "[for='" + controlID + "']" ),
  6969. labelID = $label.attr( "id" ) || controlID + "-label",
  6970. min = !isToggleSwitch ? parseFloat( control.attr( "min" ) ) : 0,
  6971. max = !isToggleSwitch ? parseFloat( control.attr( "max" ) ) : control.find( "option" ).length-1,
  6972. step = window.parseFloat( control.attr( "step" ) || 1 ),
  6973. domHandle = document.createElement( "a" ),
  6974. handle = $( domHandle ),
  6975. domSlider = document.createElement( "div" ),
  6976. slider = $( domSlider ),
  6977. valuebg = this.options.highlight && !isToggleSwitch ? (function() {
  6978. var bg = document.createElement( "div" );
  6979. bg.className = "ui-slider-bg " + $.mobile.activeBtnClass;
  6980. return $( bg ).prependTo( slider );
  6981. })() : false,
  6982. options,
  6983. wrapper,
  6984. j, length,
  6985. i, optionsCount, origTabIndex,
  6986. side, activeClass, sliderImg;
  6987. $label.attr( "id", labelID );
  6988. this.isToggleSwitch = isToggleSwitch;
  6989. domHandle.setAttribute( "href", "#" );
  6990. domSlider.setAttribute( "role", "application" );
  6991. domSlider.className = [ this.isToggleSwitch ? "ui-slider ui-slider-track ui-shadow-inset " : "ui-slider-track ui-shadow-inset ", selectClass, trackThemeClass, cornerClass, miniClass ].join( "" );
  6992. domHandle.className = "ui-slider-handle";
  6993. domSlider.appendChild( domHandle );
  6994. handle.attr({
  6995. "role": "slider",
  6996. "aria-valuemin": min,
  6997. "aria-valuemax": max,
  6998. "aria-valuenow": this._value(),
  6999. "aria-valuetext": this._value(),
  7000. "title": this._value(),
  7001. "aria-labelledby": labelID
  7002. });
  7003. $.extend( this, {
  7004. slider: slider,
  7005. handle: handle,
  7006. control: control,
  7007. type: cType,
  7008. step: step,
  7009. max: max,
  7010. min: min,
  7011. valuebg: valuebg,
  7012. isRangeslider: isRangeslider,
  7013. dragging: false,
  7014. beforeStart: null,
  7015. userModified: false,
  7016. mouseMoved: false
  7017. });
  7018. if ( isToggleSwitch ) {
  7019. // TODO: restore original tabindex (if any) in a destroy method
  7020. origTabIndex = control.attr( "tabindex" );
  7021. if ( origTabIndex ) {
  7022. handle.attr( "tabindex", origTabIndex );
  7023. }
  7024. control.attr( "tabindex", "-1" ).focus(function() {
  7025. $( this ).blur();
  7026. handle.focus();
  7027. });
  7028. wrapper = document.createElement( "div" );
  7029. wrapper.className = "ui-slider-inneroffset";
  7030. for ( j = 0, length = domSlider.childNodes.length; j < length; j++ ) {
  7031. wrapper.appendChild( domSlider.childNodes[j] );
  7032. }
  7033. domSlider.appendChild( wrapper );
  7034. // slider.wrapInner( "<div class='ui-slider-inneroffset'></div>" );
  7035. // make the handle move with a smooth transition
  7036. handle.addClass( "ui-slider-handle-snapping" );
  7037. options = control.find( "option" );
  7038. for ( i = 0, optionsCount = options.length; i < optionsCount; i++ ) {
  7039. side = !i ? "b" : "a";
  7040. activeClass = !i ? "" : " " + $.mobile.activeBtnClass;
  7041. sliderImg = document.createElement( "span" );
  7042. sliderImg.className = [ "ui-slider-label ui-slider-label-", side, activeClass ].join( "" );
  7043. sliderImg.setAttribute( "role", "img" );
  7044. sliderImg.appendChild( document.createTextNode( options[i].innerHTML ) );
  7045. $( sliderImg ).prependTo( slider );
  7046. }
  7047. self._labels = $( ".ui-slider-label", slider );
  7048. }
  7049. // monitor the input for updated values
  7050. control.addClass( isToggleSwitch ? "ui-slider-switch" : "ui-slider-input" );
  7051. this._on( control, {
  7052. "change": "_controlChange",
  7053. "keyup": "_controlKeyup",
  7054. "blur": "_controlBlur",
  7055. "vmouseup": "_controlVMouseUp"
  7056. });
  7057. slider.bind( "vmousedown", $.proxy( this._sliderVMouseDown, this ) )
  7058. .bind( "vclick", false );
  7059. // We have to instantiate a new function object for the unbind to work properly
  7060. // since the method itself is defined in the prototype (causing it to unbind everything)
  7061. this._on( document, { "vmousemove": "_preventDocumentDrag" });
  7062. this._on( slider.add( document ), { "vmouseup": "_sliderVMouseUp" });
  7063. slider.insertAfter( control );
  7064. // wrap in a div for styling purposes
  7065. if ( !isToggleSwitch && !isRangeslider ) {
  7066. wrapper = this.options.mini ? "<div class='ui-slider ui-mini'>" : "<div class='ui-slider'>";
  7067. control.add( slider ).wrapAll( wrapper );
  7068. }
  7069. // bind the handle event callbacks and set the context to the widget instance
  7070. this._on( this.handle, {
  7071. "vmousedown": "_handleVMouseDown",
  7072. "keydown": "_handleKeydown",
  7073. "keyup": "_handleKeyup"
  7074. });
  7075. this.handle.bind( "vclick", false );
  7076. this._handleFormReset();
  7077. this.refresh( undefined, undefined, true );
  7078. },
  7079. _setOptions: function( options ) {
  7080. if ( options.theme !== undefined ) {
  7081. this._setTheme( options.theme );
  7082. }
  7083. if ( options.trackTheme !== undefined ) {
  7084. this._setTrackTheme( options.trackTheme );
  7085. }
  7086. if ( options.corners !== undefined ) {
  7087. this._setCorners( options.corners );
  7088. }
  7089. if ( options.mini !== undefined ) {
  7090. this._setMini( options.mini );
  7091. }
  7092. if ( options.highlight !== undefined ) {
  7093. this._setHighlight( options.highlight );
  7094. }
  7095. if ( options.disabled !== undefined ) {
  7096. this._setDisabled( options.disabled );
  7097. }
  7098. this._super( options );
  7099. },
  7100. _controlChange: function( event ) {
  7101. // if the user dragged the handle, the "change" event was triggered from inside refresh(); don't call refresh() again
  7102. if ( this._trigger( "controlchange", event ) === false ) {
  7103. return false;
  7104. }
  7105. if ( !this.mouseMoved ) {
  7106. this.refresh( this._value(), true );
  7107. }
  7108. },
  7109. _controlKeyup: function(/* event */) { // necessary?
  7110. this.refresh( this._value(), true, true );
  7111. },
  7112. _controlBlur: function(/* event */) {
  7113. this.refresh( this._value(), true );
  7114. },
  7115. // it appears the clicking the up and down buttons in chrome on
  7116. // range/number inputs doesn't trigger a change until the field is
  7117. // blurred. Here we check thif the value has changed and refresh
  7118. _controlVMouseUp: function(/* event */) {
  7119. this._checkedRefresh();
  7120. },
  7121. // NOTE force focus on handle
  7122. _handleVMouseDown: function(/* event */) {
  7123. this.handle.focus();
  7124. },
  7125. _handleKeydown: function( event ) {
  7126. var index = this._value();
  7127. if ( this.options.disabled ) {
  7128. return;
  7129. }
  7130. // In all cases prevent the default and mark the handle as active
  7131. switch ( event.keyCode ) {
  7132. case $.mobile.keyCode.HOME:
  7133. case $.mobile.keyCode.END:
  7134. case $.mobile.keyCode.PAGE_UP:
  7135. case $.mobile.keyCode.PAGE_DOWN:
  7136. case $.mobile.keyCode.UP:
  7137. case $.mobile.keyCode.RIGHT:
  7138. case $.mobile.keyCode.DOWN:
  7139. case $.mobile.keyCode.LEFT:
  7140. event.preventDefault();
  7141. if ( !this._keySliding ) {
  7142. this._keySliding = true;
  7143. this.handle.addClass( "ui-state-active" ); /* TODO: We don't use this class for styling. Do we need to add it? */
  7144. }
  7145. break;
  7146. }
  7147. // move the slider according to the keypress
  7148. switch ( event.keyCode ) {
  7149. case $.mobile.keyCode.HOME:
  7150. this.refresh( this.min );
  7151. break;
  7152. case $.mobile.keyCode.END:
  7153. this.refresh( this.max );
  7154. break;
  7155. case $.mobile.keyCode.PAGE_UP:
  7156. case $.mobile.keyCode.UP:
  7157. case $.mobile.keyCode.RIGHT:
  7158. this.refresh( index + this.step );
  7159. break;
  7160. case $.mobile.keyCode.PAGE_DOWN:
  7161. case $.mobile.keyCode.DOWN:
  7162. case $.mobile.keyCode.LEFT:
  7163. this.refresh( index - this.step );
  7164. break;
  7165. }
  7166. }, // remove active mark
  7167. _handleKeyup: function(/* event */) {
  7168. if ( this._keySliding ) {
  7169. this._keySliding = false;
  7170. this.handle.removeClass( "ui-state-active" ); /* See comment above. */
  7171. }
  7172. },
  7173. _sliderVMouseDown: function( event ) {
  7174. // NOTE: we don't do this in refresh because we still want to
  7175. // support programmatic alteration of disabled inputs
  7176. if ( this.options.disabled || !( event.which === 1 || event.which === 0 || event.which === undefined ) ) {
  7177. return false;
  7178. }
  7179. if ( this._trigger( "beforestart", event ) === false ) {
  7180. return false;
  7181. }
  7182. this.dragging = true;
  7183. this.userModified = false;
  7184. this.mouseMoved = false;
  7185. if ( this.isToggleSwitch ) {
  7186. this.beforeStart = this.element[0].selectedIndex;
  7187. }
  7188. this.refresh( event );
  7189. this._trigger( "start" );
  7190. return false;
  7191. },
  7192. _sliderVMouseUp: function() {
  7193. if ( this.dragging ) {
  7194. this.dragging = false;
  7195. if ( this.isToggleSwitch ) {
  7196. // make the handle move with a smooth transition
  7197. this.handle.addClass( "ui-slider-handle-snapping" );
  7198. if ( this.mouseMoved ) {
  7199. // this is a drag, change the value only if user dragged enough
  7200. if ( this.userModified ) {
  7201. this.refresh( this.beforeStart === 0 ? 1 : 0 );
  7202. } else {
  7203. this.refresh( this.beforeStart );
  7204. }
  7205. } else {
  7206. // this is just a click, change the value
  7207. this.refresh( this.beforeStart === 0 ? 1 : 0 );
  7208. }
  7209. }
  7210. this.mouseMoved = false;
  7211. this._trigger( "stop" );
  7212. return false;
  7213. }
  7214. },
  7215. _preventDocumentDrag: function( event ) {
  7216. // NOTE: we don't do this in refresh because we still want to
  7217. // support programmatic alteration of disabled inputs
  7218. if ( this._trigger( "drag", event ) === false) {
  7219. return false;
  7220. }
  7221. if ( this.dragging && !this.options.disabled ) {
  7222. // this.mouseMoved must be updated before refresh() because it will be used in the control "change" event
  7223. this.mouseMoved = true;
  7224. if ( this.isToggleSwitch ) {
  7225. // make the handle move in sync with the mouse
  7226. this.handle.removeClass( "ui-slider-handle-snapping" );
  7227. }
  7228. this.refresh( event );
  7229. // only after refresh() you can calculate this.userModified
  7230. this.userModified = this.beforeStart !== this.element[0].selectedIndex;
  7231. return false;
  7232. }
  7233. },
  7234. _checkedRefresh: function() {
  7235. if ( this.value !== this._value() ) {
  7236. this.refresh( this._value() );
  7237. }
  7238. },
  7239. _value: function() {
  7240. return this.isToggleSwitch ? this.element[0].selectedIndex : parseFloat( this.element.val() ) ;
  7241. },
  7242. _reset: function() {
  7243. this.refresh( undefined, false, true );
  7244. },
  7245. refresh: function( val, isfromControl, preventInputUpdate ) {
  7246. // NOTE: we don't return here because we want to support programmatic
  7247. // alteration of the input value, which should still update the slider
  7248. var self = this,
  7249. parentTheme = $.mobile.getAttribute( this.element[ 0 ], "theme" ),
  7250. theme = this.options.theme || parentTheme,
  7251. themeClass = theme ? " ui-btn-" + theme : "",
  7252. trackTheme = this.options.trackTheme || parentTheme,
  7253. trackThemeClass = trackTheme ? " ui-bar-" + trackTheme : " ui-bar-inherit",
  7254. cornerClass = this.options.corners ? " ui-corner-all" : "",
  7255. miniClass = this.options.mini ? " ui-mini" : "",
  7256. left, width, data, tol,
  7257. pxStep, percent,
  7258. control, isInput, optionElements, min, max, step,
  7259. newval, valModStep, alignValue, percentPerStep,
  7260. handlePercent, aPercent, bPercent,
  7261. valueChanged;
  7262. 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( "" );
  7263. if ( this.options.disabled || this.element.prop( "disabled" ) ) {
  7264. this.disable();
  7265. }
  7266. // set the stored value for comparison later
  7267. this.value = this._value();
  7268. if ( this.options.highlight && !this.isToggleSwitch && this.slider.find( ".ui-slider-bg" ).length === 0 ) {
  7269. this.valuebg = (function() {
  7270. var bg = document.createElement( "div" );
  7271. bg.className = "ui-slider-bg " + $.mobile.activeBtnClass;
  7272. return $( bg ).prependTo( self.slider );
  7273. })();
  7274. }
  7275. this.handle.addClass( "ui-btn" + themeClass + " ui-shadow" );
  7276. control = this.element;
  7277. isInput = !this.isToggleSwitch;
  7278. optionElements = isInput ? [] : control.find( "option" );
  7279. min = isInput ? parseFloat( control.attr( "min" ) ) : 0;
  7280. max = isInput ? parseFloat( control.attr( "max" ) ) : optionElements.length - 1;
  7281. step = ( isInput && parseFloat( control.attr( "step" ) ) > 0 ) ? parseFloat( control.attr( "step" ) ) : 1;
  7282. if ( typeof val === "object" ) {
  7283. data = val;
  7284. // a slight tolerance helped get to the ends of the slider
  7285. tol = 8;
  7286. left = this.slider.offset().left;
  7287. width = this.slider.width();
  7288. pxStep = width/((max-min)/step);
  7289. if ( !this.dragging ||
  7290. data.pageX < left - tol ||
  7291. data.pageX > left + width + tol ) {
  7292. return;
  7293. }
  7294. if ( pxStep > 1 ) {
  7295. percent = ( ( data.pageX - left ) / width ) * 100;
  7296. } else {
  7297. percent = Math.round( ( ( data.pageX - left ) / width ) * 100 );
  7298. }
  7299. } else {
  7300. if ( val == null ) {
  7301. val = isInput ? parseFloat( control.val() || 0 ) : control[0].selectedIndex;
  7302. }
  7303. percent = ( parseFloat( val ) - min ) / ( max - min ) * 100;
  7304. }
  7305. if ( isNaN( percent ) ) {
  7306. return;
  7307. }
  7308. newval = ( percent / 100 ) * ( max - min ) + min;
  7309. //from jQuery UI slider, the following source will round to the nearest step
  7310. valModStep = ( newval - min ) % step;
  7311. alignValue = newval - valModStep;
  7312. if ( Math.abs( valModStep ) * 2 >= step ) {
  7313. alignValue += ( valModStep > 0 ) ? step : ( -step );
  7314. }
  7315. percentPerStep = 100/((max-min)/step);
  7316. // Since JavaScript has problems with large floats, round
  7317. // the final value to 5 digits after the decimal point (see jQueryUI: #4124)
  7318. newval = parseFloat( alignValue.toFixed(5) );
  7319. if ( typeof pxStep === "undefined" ) {
  7320. pxStep = width / ( (max-min) / step );
  7321. }
  7322. if ( pxStep > 1 && isInput ) {
  7323. percent = ( newval - min ) * percentPerStep * ( 1 / step );
  7324. }
  7325. if ( percent < 0 ) {
  7326. percent = 0;
  7327. }
  7328. if ( percent > 100 ) {
  7329. percent = 100;
  7330. }
  7331. if ( newval < min ) {
  7332. newval = min;
  7333. }
  7334. if ( newval > max ) {
  7335. newval = max;
  7336. }
  7337. this.handle.css( "left", percent + "%" );
  7338. this.handle[0].setAttribute( "aria-valuenow", isInput ? newval : optionElements.eq( newval ).attr( "value" ) );
  7339. this.handle[0].setAttribute( "aria-valuetext", isInput ? newval : optionElements.eq( newval ).getEncodedText() );
  7340. this.handle[0].setAttribute( "title", isInput ? newval : optionElements.eq( newval ).getEncodedText() );
  7341. if ( this.valuebg ) {
  7342. this.valuebg.css( "width", percent + "%" );
  7343. }
  7344. // drag the label widths
  7345. if ( this._labels ) {
  7346. handlePercent = this.handle.width() / this.slider.width() * 100;
  7347. aPercent = percent && handlePercent + ( 100 - handlePercent ) * percent / 100;
  7348. bPercent = percent === 100 ? 0 : Math.min( handlePercent + 100 - aPercent, 100 );
  7349. this._labels.each(function() {
  7350. var ab = $( this ).hasClass( "ui-slider-label-a" );
  7351. $( this ).width( ( ab ? aPercent : bPercent ) + "%" );
  7352. });
  7353. }
  7354. if ( !preventInputUpdate ) {
  7355. valueChanged = false;
  7356. // update control"s value
  7357. if ( isInput ) {
  7358. valueChanged = parseFloat( control.val() ) !== newval;
  7359. control.val( newval );
  7360. } else {
  7361. valueChanged = control[ 0 ].selectedIndex !== newval;
  7362. control[ 0 ].selectedIndex = newval;
  7363. }
  7364. if ( this._trigger( "beforechange", val ) === false) {
  7365. return false;
  7366. }
  7367. if ( !isfromControl && valueChanged ) {
  7368. control.trigger( "change" );
  7369. }
  7370. }
  7371. },
  7372. _setHighlight: function( value ) {
  7373. value = !!value;
  7374. if ( value ) {
  7375. this.options.highlight = !!value;
  7376. this.refresh();
  7377. } else if ( this.valuebg ) {
  7378. this.valuebg.remove();
  7379. this.valuebg = false;
  7380. }
  7381. },
  7382. _setTheme: function( value ) {
  7383. this.handle
  7384. .removeClass( "ui-btn-" + this.options.theme )
  7385. .addClass( "ui-btn-" + value );
  7386. var currentTheme = this.options.theme ? this.options.theme : "inherit",
  7387. newTheme = value ? value : "inherit";
  7388. this.control
  7389. .removeClass( "ui-body-" + currentTheme )
  7390. .addClass( "ui-body-" + newTheme );
  7391. },
  7392. _setTrackTheme: function( value ) {
  7393. var currentTrackTheme = this.options.trackTheme ? this.options.trackTheme : "inherit",
  7394. newTrackTheme = value ? value : "inherit";
  7395. this.slider
  7396. .removeClass( "ui-body-" + currentTrackTheme )
  7397. .addClass( "ui-body-" + newTrackTheme );
  7398. },
  7399. _setMini: function( value ) {
  7400. value = !!value;
  7401. if ( !this.isToggleSwitch && !this.isRangeslider ) {
  7402. this.slider.parent().toggleClass( "ui-mini", value );
  7403. this.element.toggleClass( "ui-mini", value );
  7404. }
  7405. this.slider.toggleClass( "ui-mini", value );
  7406. },
  7407. _setCorners: function( value ) {
  7408. this.slider.toggleClass( "ui-corner-all", value );
  7409. if ( !this.isToggleSwitch ) {
  7410. this.control.toggleClass( "ui-corner-all", value );
  7411. }
  7412. },
  7413. _setDisabled: function( value ) {
  7414. value = !!value;
  7415. this.element.prop( "disabled", value );
  7416. this.slider
  7417. .toggleClass( "ui-state-disabled", value )
  7418. .attr( "aria-disabled", value );
  7419. this.element.toggleClass( "ui-state-disabled", value );
  7420. }
  7421. }, $.mobile.behaviors.formReset ) );
  7422. })( jQuery );
  7423. (function( $, undefined ) {
  7424. var popup;
  7425. function getPopup() {
  7426. if ( !popup ) {
  7427. popup = $( "<div></div>", {
  7428. "class": "ui-slider-popup ui-shadow ui-corner-all"
  7429. });
  7430. }
  7431. return popup.clone();
  7432. }
  7433. $.widget( "mobile.slider", $.mobile.slider, {
  7434. options: {
  7435. popupEnabled: false,
  7436. showValue: false
  7437. },
  7438. _create: function() {
  7439. this._super();
  7440. $.extend( this, {
  7441. _currentValue: null,
  7442. _popup: null,
  7443. _popupVisible: false
  7444. });
  7445. this._setOption( "popupEnabled", this.options.popupEnabled );
  7446. this._on( this.handle, { "vmousedown" : "_showPopup" } );
  7447. this._on( this.slider.add( this.document ), { "vmouseup" : "_hidePopup" } );
  7448. this._refresh();
  7449. },
  7450. // position the popup centered 5px above the handle
  7451. _positionPopup: function() {
  7452. var dstOffset = this.handle.offset();
  7453. this._popup.offset( {
  7454. left: dstOffset.left + ( this.handle.width() - this._popup.width() ) / 2,
  7455. top: dstOffset.top - this._popup.outerHeight() - 5
  7456. });
  7457. },
  7458. _setOption: function( key, value ) {
  7459. this._super( key, value );
  7460. if ( key === "showValue" ) {
  7461. this.handle.html( value && !this.options.mini ? this._value() : "" );
  7462. } else if ( key === "popupEnabled" ) {
  7463. if ( value && !this._popup ) {
  7464. this._popup = getPopup()
  7465. .addClass( "ui-body-" + ( this.options.theme || "a" ) )
  7466. .hide()
  7467. .insertBefore( this.element );
  7468. }
  7469. }
  7470. },
  7471. // show value on the handle and in popup
  7472. refresh: function() {
  7473. this._super.apply( this, arguments );
  7474. this._refresh();
  7475. },
  7476. _refresh: function() {
  7477. var o = this.options, newValue;
  7478. if ( o.popupEnabled ) {
  7479. // remove the title attribute from the handle (which is
  7480. // responsible for the annoying tooltip); NB we have
  7481. // to do it here as the jqm slider sets it every time
  7482. // the slider's value changes :(
  7483. this.handle.removeAttr( "title" );
  7484. }
  7485. newValue = this._value();
  7486. if ( newValue === this._currentValue ) {
  7487. return;
  7488. }
  7489. this._currentValue = newValue;
  7490. if ( o.popupEnabled && this._popup ) {
  7491. this._positionPopup();
  7492. this._popup.html( newValue );
  7493. }
  7494. if ( o.showValue && !this.options.mini ) {
  7495. this.handle.html( newValue );
  7496. }
  7497. },
  7498. _showPopup: function() {
  7499. if ( this.options.popupEnabled && !this._popupVisible ) {
  7500. this.handle.html( "" );
  7501. this._popup.show();
  7502. this._positionPopup();
  7503. this._popupVisible = true;
  7504. }
  7505. },
  7506. _hidePopup: function() {
  7507. var o = this.options;
  7508. if ( o.popupEnabled && this._popupVisible ) {
  7509. if ( o.showValue && !o.mini ) {
  7510. this.handle.html( this._value() );
  7511. }
  7512. this._popup.hide();
  7513. this._popupVisible = false;
  7514. }
  7515. }
  7516. });
  7517. })( jQuery );
  7518. (function( $, undefined ) {
  7519. $.widget( "mobile.flipswitch", $.extend({
  7520. options: {
  7521. onText: "On",
  7522. offText: "Off",
  7523. theme: null,
  7524. enhanced: false,
  7525. wrapperClass: null,
  7526. corners: true,
  7527. mini: false
  7528. },
  7529. _create: function() {
  7530. if ( !this.options.enhanced ) {
  7531. this._enhance();
  7532. } else {
  7533. $.extend( this, {
  7534. flipswitch: this.element.parent(),
  7535. on: this.element.find( ".ui-flipswitch-on" ).eq( 0 ),
  7536. off: this.element.find( ".ui-flipswitch-off" ).eq(0),
  7537. type: this.element.get( 0 ).tagName
  7538. });
  7539. }
  7540. this._handleFormReset();
  7541. // Transfer tabindex to "on" element and make input unfocusable
  7542. this._originalTabIndex = this.element.attr( "tabindex" );
  7543. if ( this._originalTabIndex != null ) {
  7544. this.on.attr( "tabindex", this._originalTabIndex );
  7545. }
  7546. this.element.attr( "tabindex", "-1" );
  7547. this._on({
  7548. "focus" : "_handleInputFocus"
  7549. });
  7550. if ( this.element.is( ":disabled" ) ) {
  7551. this._setOptions({
  7552. "disabled": true
  7553. });
  7554. }
  7555. this._on( this.flipswitch, {
  7556. "click": "_toggle",
  7557. "swipeleft": "_left",
  7558. "swiperight": "_right"
  7559. });
  7560. this._on( this.on, {
  7561. "keydown": "_keydown"
  7562. });
  7563. this._on( {
  7564. "change": "refresh"
  7565. });
  7566. },
  7567. _handleInputFocus: function() {
  7568. this.on.focus();
  7569. },
  7570. widget: function() {
  7571. return this.flipswitch;
  7572. },
  7573. _left: function() {
  7574. this.flipswitch.removeClass( "ui-flipswitch-active" );
  7575. if ( this.type === "SELECT" ) {
  7576. this.element.get( 0 ).selectedIndex = 0;
  7577. } else {
  7578. this.element.prop( "checked", false );
  7579. }
  7580. this.element.trigger( "change" );
  7581. },
  7582. _right: function() {
  7583. this.flipswitch.addClass( "ui-flipswitch-active" );
  7584. if ( this.type === "SELECT" ) {
  7585. this.element.get( 0 ).selectedIndex = 1;
  7586. } else {
  7587. this.element.prop( "checked", true );
  7588. }
  7589. this.element.trigger( "change" );
  7590. },
  7591. _enhance: function() {
  7592. var flipswitch = $( "<div>" ),
  7593. options = this.options,
  7594. element = this.element,
  7595. theme = options.theme ? options.theme : "inherit",
  7596. // The "on" button is an anchor so it's focusable
  7597. on = $( "<a></a>", {
  7598. "href": "#"
  7599. }),
  7600. off = $( "<span></span>" ),
  7601. type = element.get( 0 ).tagName,
  7602. onText = ( type === "INPUT" ) ?
  7603. options.onText : element.find( "option" ).eq( 1 ).text(),
  7604. offText = ( type === "INPUT" ) ?
  7605. options.offText : element.find( "option" ).eq( 0 ).text();
  7606. on
  7607. .addClass( "ui-flipswitch-on ui-btn ui-shadow ui-btn-inherit" )
  7608. .text( onText );
  7609. off
  7610. .addClass( "ui-flipswitch-off" )
  7611. .text( offText );
  7612. flipswitch
  7613. .addClass( "ui-flipswitch ui-shadow-inset " +
  7614. "ui-bar-" + theme + " " +
  7615. ( options.wrapperClass ? options.wrapperClass : "" ) + " " +
  7616. ( ( element.is( ":checked" ) ||
  7617. element
  7618. .find( "option" )
  7619. .eq( 1 )
  7620. .is( ":selected" ) ) ? "ui-flipswitch-active" : "" ) +
  7621. ( element.is(":disabled") ? " ui-state-disabled": "") +
  7622. ( options.corners ? " ui-corner-all": "" ) +
  7623. ( options.mini ? " ui-mini": "" ) )
  7624. .append( on, off );
  7625. element
  7626. .addClass( "ui-flipswitch-input" )
  7627. .after( flipswitch )
  7628. .appendTo( flipswitch );
  7629. $.extend( this, {
  7630. flipswitch: flipswitch,
  7631. on: on,
  7632. off: off,
  7633. type: type
  7634. });
  7635. },
  7636. _reset: function() {
  7637. this.refresh();
  7638. },
  7639. refresh: function() {
  7640. var direction,
  7641. existingDirection = this.flipswitch.hasClass( "ui-flipswitch-active" ) ? "_right" : "_left";
  7642. if ( this.type === "SELECT" ) {
  7643. direction = ( this.element.get( 0 ).selectedIndex > 0 ) ? "_right": "_left";
  7644. } else {
  7645. direction = this.element.prop( "checked" ) ? "_right": "_left";
  7646. }
  7647. if ( direction !== existingDirection ) {
  7648. this[ direction ]();
  7649. }
  7650. },
  7651. _toggle: function() {
  7652. var direction = this.flipswitch.hasClass( "ui-flipswitch-active" ) ? "_left" : "_right";
  7653. this[ direction ]();
  7654. },
  7655. _keydown: function( e ) {
  7656. if ( e.which === $.mobile.keyCode.LEFT ) {
  7657. this._left();
  7658. } else if ( e.which === $.mobile.keyCode.RIGHT ) {
  7659. this._right();
  7660. } else if ( e.which === $.mobile.keyCode.SPACE ) {
  7661. this._toggle();
  7662. e.preventDefault();
  7663. }
  7664. },
  7665. _setOptions: function( options ) {
  7666. if ( options.theme !== undefined ) {
  7667. var currentTheme = options.theme ? options.theme : "inherit",
  7668. newTheme = options.theme ? options.theme : "inherit";
  7669. this.widget()
  7670. .removeClass( "ui-bar-" + currentTheme )
  7671. .addClass( "ui-bar-" + newTheme );
  7672. }
  7673. if ( options.onText !== undefined ) {
  7674. this.on.text( options.onText );
  7675. }
  7676. if ( options.offText !== undefined ) {
  7677. this.off.text( options.offText );
  7678. }
  7679. if ( options.disabled !== undefined ) {
  7680. this.widget().toggleClass( "ui-state-disabled", options.disabled );
  7681. }
  7682. if ( options.mini !== undefined ) {
  7683. this.widget().toggleClass( "ui-mini", options.mini );
  7684. }
  7685. if ( options.corners !== undefined ) {
  7686. this.widget().toggleClass( "ui-corner-all", options.corners );
  7687. }
  7688. this._super( options );
  7689. },
  7690. _destroy: function() {
  7691. if ( this.options.enhanced ) {
  7692. return;
  7693. }
  7694. if ( this._originalTabIndex != null ) {
  7695. this.element.attr( "tabindex", this._originalTabIndex );
  7696. } else {
  7697. this.element.removeAttr( "tabindex" );
  7698. }
  7699. this.on.remove();
  7700. this.off.remove();
  7701. this.element.unwrap();
  7702. this.flipswitch.remove();
  7703. this.removeClass( "ui-flipswitch-input" );
  7704. }
  7705. }, $.mobile.behaviors.formReset ) );
  7706. })( jQuery );
  7707. (function( $, undefined ) {
  7708. $.widget( "mobile.rangeslider", $.extend( {
  7709. options: {
  7710. theme: null,
  7711. trackTheme: null,
  7712. corners: true,
  7713. mini: false,
  7714. highlight: true
  7715. },
  7716. _create: function() {
  7717. var $el = this.element,
  7718. elClass = this.options.mini ? "ui-rangeslider ui-mini" : "ui-rangeslider",
  7719. _inputFirst = $el.find( "input" ).first(),
  7720. _inputLast = $el.find( "input" ).last(),
  7721. _label = $el.find( "label" ).first(),
  7722. _sliderWidgetFirst = $.data( _inputFirst.get( 0 ), "mobile-slider" ) ||
  7723. $.data( _inputFirst.slider().get( 0 ), "mobile-slider" ),
  7724. _sliderWidgetLast = $.data( _inputLast.get(0), "mobile-slider" ) ||
  7725. $.data( _inputLast.slider().get( 0 ), "mobile-slider" ),
  7726. _sliderFirst = _sliderWidgetFirst.slider,
  7727. _sliderLast = _sliderWidgetLast.slider,
  7728. firstHandle = _sliderWidgetFirst.handle,
  7729. _sliders = $( "<div class='ui-rangeslider-sliders' />" ).appendTo( $el );
  7730. _inputFirst.addClass( "ui-rangeslider-first" );
  7731. _inputLast.addClass( "ui-rangeslider-last" );
  7732. $el.addClass( elClass );
  7733. _sliderFirst.appendTo( _sliders );
  7734. _sliderLast.appendTo( _sliders );
  7735. _label.insertBefore( $el );
  7736. firstHandle.prependTo( _sliderLast );
  7737. $.extend( this, {
  7738. _inputFirst: _inputFirst,
  7739. _inputLast: _inputLast,
  7740. _sliderFirst: _sliderFirst,
  7741. _sliderLast: _sliderLast,
  7742. _label: _label,
  7743. _targetVal: null,
  7744. _sliderTarget: false,
  7745. _sliders: _sliders,
  7746. _proxy: false
  7747. });
  7748. this.refresh();
  7749. this._on( this.element.find( "input.ui-slider-input" ), {
  7750. "slidebeforestart": "_slidebeforestart",
  7751. "slidestop": "_slidestop",
  7752. "slidedrag": "_slidedrag",
  7753. "slidebeforechange": "_change",
  7754. "blur": "_change",
  7755. "keyup": "_change"
  7756. });
  7757. this._on({
  7758. "mousedown":"_change"
  7759. });
  7760. this._on( this.element.closest( "form" ), {
  7761. "reset":"_handleReset"
  7762. });
  7763. this._on( firstHandle, {
  7764. "vmousedown": "_dragFirstHandle"
  7765. });
  7766. },
  7767. _handleReset: function() {
  7768. var self = this;
  7769. //we must wait for the stack to unwind before updateing other wise sliders will not have updated yet
  7770. setTimeout( function() {
  7771. self._updateHighlight();
  7772. },0);
  7773. },
  7774. _dragFirstHandle: function( event ) {
  7775. //if the first handle is dragged send the event to the first slider
  7776. $.data( this._inputFirst.get(0), "mobile-slider" ).dragging = true;
  7777. $.data( this._inputFirst.get(0), "mobile-slider" ).refresh( event );
  7778. $.data( this._inputFirst.get(0), "mobile-slider" )._trigger( "start" );
  7779. return false;
  7780. },
  7781. _slidedrag: function( event ) {
  7782. var first = $( event.target ).is( this._inputFirst ),
  7783. otherSlider = ( first ) ? this._inputLast : this._inputFirst;
  7784. this._sliderTarget = false;
  7785. //if the drag was initiated on an extreme and the other handle is focused send the events to
  7786. //the closest handle
  7787. if ( ( this._proxy === "first" && first ) || ( this._proxy === "last" && !first ) ) {
  7788. $.data( otherSlider.get(0), "mobile-slider" ).dragging = true;
  7789. $.data( otherSlider.get(0), "mobile-slider" ).refresh( event );
  7790. return false;
  7791. }
  7792. },
  7793. _slidestop: function( event ) {
  7794. var first = $( event.target ).is( this._inputFirst );
  7795. this._proxy = false;
  7796. //this stops dragging of the handle and brings the active track to the front
  7797. //this makes clicks on the track go the the last handle used
  7798. this.element.find( "input" ).trigger( "vmouseup" );
  7799. this._sliderFirst.css( "z-index", first ? 1 : "" );
  7800. },
  7801. _slidebeforestart: function( event ) {
  7802. this._sliderTarget = false;
  7803. //if the track is the target remember this and the original value
  7804. if ( $( event.originalEvent.target ).hasClass( "ui-slider-track" ) ) {
  7805. this._sliderTarget = true;
  7806. this._targetVal = $( event.target ).val();
  7807. }
  7808. },
  7809. _setOptions: function( options ) {
  7810. if ( options.theme !== undefined ) {
  7811. this._setTheme( options.theme );
  7812. }
  7813. if ( options.trackTheme !== undefined ) {
  7814. this._setTrackTheme( options.trackTheme );
  7815. }
  7816. if ( options.mini !== undefined ) {
  7817. this._setMini( options.mini );
  7818. }
  7819. if ( options.highlight !== undefined ) {
  7820. this._setHighlight( options.highlight );
  7821. }
  7822. if ( options.disabled !== undefined ) {
  7823. this._setDisabled( options.disabled );
  7824. }
  7825. this._super( options );
  7826. this.refresh();
  7827. },
  7828. refresh: function() {
  7829. var $el = this.element,
  7830. o = this.options;
  7831. if ( this._inputFirst.is( ":disabled" ) || this._inputLast.is( ":disabled" ) ) {
  7832. this.options.disabled = true;
  7833. }
  7834. $el.find( "input" ).slider({
  7835. theme: o.theme,
  7836. trackTheme: o.trackTheme,
  7837. disabled: o.disabled,
  7838. corners: o.corners,
  7839. mini: o.mini,
  7840. highlight: o.highlight
  7841. }).slider( "refresh" );
  7842. this._updateHighlight();
  7843. },
  7844. _change: function( event ) {
  7845. if ( event.type === "keyup" ) {
  7846. this._updateHighlight();
  7847. return false;
  7848. }
  7849. var self = this,
  7850. min = parseFloat( this._inputFirst.val(), 10 ),
  7851. max = parseFloat( this._inputLast.val(), 10 ),
  7852. first = $( event.target ).hasClass( "ui-rangeslider-first" ),
  7853. thisSlider = first ? this._inputFirst : this._inputLast,
  7854. otherSlider = first ? this._inputLast : this._inputFirst;
  7855. if ( ( this._inputFirst.val() > this._inputLast.val() && event.type === "mousedown" && !$(event.target).hasClass("ui-slider-handle")) ) {
  7856. thisSlider.blur();
  7857. } else if ( event.type === "mousedown" ) {
  7858. return;
  7859. }
  7860. if ( min > max && !this._sliderTarget ) {
  7861. //this prevents min from being greater then max
  7862. thisSlider.val( first ? max: min ).slider( "refresh" );
  7863. this._trigger( "normalize" );
  7864. } else if ( min > max ) {
  7865. //this makes it so clicks on the target on either extreme go to the closest handle
  7866. thisSlider.val( this._targetVal ).slider( "refresh" );
  7867. //You must wait for the stack to unwind so first slider is updated before updating second
  7868. setTimeout( function() {
  7869. otherSlider.val( first ? min: max ).slider( "refresh" );
  7870. $.data( otherSlider.get(0), "mobile-slider" ).handle.focus();
  7871. self._sliderFirst.css( "z-index", first ? "" : 1 );
  7872. self._trigger( "normalize" );
  7873. }, 0 );
  7874. this._proxy = ( first ) ? "first" : "last";
  7875. }
  7876. //fixes issue where when both _sliders are at min they cannot be adjusted
  7877. if ( min === max ) {
  7878. $.data( thisSlider.get(0), "mobile-slider" ).handle.css( "z-index", 1 );
  7879. $.data( otherSlider.get(0), "mobile-slider" ).handle.css( "z-index", 0 );
  7880. } else {
  7881. $.data( otherSlider.get(0), "mobile-slider" ).handle.css( "z-index", "" );
  7882. $.data( thisSlider.get(0), "mobile-slider" ).handle.css( "z-index", "" );
  7883. }
  7884. this._updateHighlight();
  7885. if ( min >= max ) {
  7886. return false;
  7887. }
  7888. },
  7889. _updateHighlight: function() {
  7890. var min = parseInt( $.data( this._inputFirst.get(0), "mobile-slider" ).handle.get(0).style.left, 10 ),
  7891. max = parseInt( $.data( this._inputLast.get(0), "mobile-slider" ).handle.get(0).style.left, 10 ),
  7892. width = (max - min);
  7893. this.element.find( ".ui-slider-bg" ).css({
  7894. "margin-left": min + "%",
  7895. "width": width + "%"
  7896. });
  7897. },
  7898. _setTheme: function( value ) {
  7899. this._inputFirst.slider( "option", "theme", value );
  7900. this._inputLast.slider( "option", "theme", value );
  7901. },
  7902. _setTrackTheme: function( value ) {
  7903. this._inputFirst.slider( "option", "trackTheme", value );
  7904. this._inputLast.slider( "option", "trackTheme", value );
  7905. },
  7906. _setMini: function( value ) {
  7907. this._inputFirst.slider( "option", "mini", value );
  7908. this._inputLast.slider( "option", "mini", value );
  7909. this.element.toggleClass( "ui-mini", !!value );
  7910. },
  7911. _setHighlight: function( value ) {
  7912. this._inputFirst.slider( "option", "highlight", value );
  7913. this._inputLast.slider( "option", "highlight", value );
  7914. },
  7915. _setDisabled: function( value ) {
  7916. this._inputFirst.prop( "disabled", value );
  7917. this._inputLast.prop( "disabled", value );
  7918. },
  7919. _destroy: function() {
  7920. this._label.prependTo( this.element );
  7921. this.element.removeClass( "ui-rangeslider ui-mini" );
  7922. this._inputFirst.after( this._sliderFirst );
  7923. this._inputLast.after( this._sliderLast );
  7924. this._sliders.remove();
  7925. this.element.find( "input" ).removeClass( "ui-rangeslider-first ui-rangeslider-last" ).slider( "destroy" );
  7926. }
  7927. }, $.mobile.behaviors.formReset ) );
  7928. })( jQuery );
  7929. (function( $, undefined ) {
  7930. $.widget( "mobile.textinput", $.mobile.textinput, {
  7931. options: {
  7932. clearBtn: false,
  7933. clearBtnText: "Clear text"
  7934. },
  7935. _create: function() {
  7936. this._super();
  7937. if ( this.isSearch ) {
  7938. this.options.clearBtn = true;
  7939. }
  7940. if ( !!this.options.clearBtn && this.inputNeedsWrap ) {
  7941. this._addClearBtn();
  7942. }
  7943. },
  7944. clearButton: function() {
  7945. return $( "<a href='#' tabindex='-1' aria-hidden='true' " +
  7946. "class='ui-input-clear ui-btn ui-icon-delete ui-btn-icon-notext ui-corner-all'>" +
  7947. "</a>" )
  7948. .attr( "title", this.options.clearBtnText )
  7949. .text( this.options.clearBtnText );
  7950. },
  7951. _clearBtnClick: function( event ) {
  7952. this.element.val( "" )
  7953. .focus()
  7954. .trigger( "change" );
  7955. this._clearBtn.addClass( "ui-input-clear-hidden" );
  7956. event.preventDefault();
  7957. },
  7958. _addClearBtn: function() {
  7959. if ( !this.options.enhanced ) {
  7960. this._enhanceClear();
  7961. }
  7962. $.extend( this, {
  7963. _clearBtn: this.widget().find("a.ui-input-clear")
  7964. });
  7965. this._bindClearEvents();
  7966. this._toggleClear();
  7967. },
  7968. _enhanceClear: function() {
  7969. this.clearButton().appendTo( this.widget() );
  7970. this.widget().addClass( "ui-input-has-clear" );
  7971. },
  7972. _bindClearEvents: function() {
  7973. this._on( this._clearBtn, {
  7974. "click": "_clearBtnClick"
  7975. });
  7976. this._on({
  7977. "keyup": "_toggleClear",
  7978. "change": "_toggleClear",
  7979. "input": "_toggleClear",
  7980. "focus": "_toggleClear",
  7981. "blur": "_toggleClear",
  7982. "cut": "_toggleClear",
  7983. "paste": "_toggleClear"
  7984. });
  7985. },
  7986. _unbindClear: function() {
  7987. this._off( this._clearBtn, "click");
  7988. this._off( this.element, "keyup change input focus blur cut paste" );
  7989. },
  7990. _setOptions: function( options ) {
  7991. this._super( options );
  7992. if ( options.clearBtn !== undefined &&
  7993. !this.element.is( "textarea, :jqmData(type='range')" ) ) {
  7994. if ( options.clearBtn ) {
  7995. this._addClearBtn();
  7996. } else {
  7997. this._destroyClear();
  7998. }
  7999. }
  8000. if ( options.clearBtnText !== undefined && this._clearBtn !== undefined ) {
  8001. this._clearBtn.text( options.clearBtnText )
  8002. .attr("title", options.clearBtnText);
  8003. }
  8004. },
  8005. _toggleClear: function() {
  8006. this._delay( "_toggleClearClass", 0 );
  8007. },
  8008. _toggleClearClass: function() {
  8009. this._clearBtn.toggleClass( "ui-input-clear-hidden", !this.element.val() );
  8010. },
  8011. _destroyClear: function() {
  8012. this.widget().removeClass( "ui-input-has-clear" );
  8013. this._unbindClear();
  8014. this._clearBtn.remove();
  8015. },
  8016. _destroy: function() {
  8017. this._super();
  8018. if ( this.options.clearBtn ) {
  8019. this._destroyClear();
  8020. }
  8021. }
  8022. });
  8023. })( jQuery );
  8024. (function( $, undefined ) {
  8025. $.widget( "mobile.textinput", $.mobile.textinput, {
  8026. options: {
  8027. autogrow:true,
  8028. keyupTimeoutBuffer: 100
  8029. },
  8030. _create: function() {
  8031. this._super();
  8032. if ( this.options.autogrow && this.isTextarea ) {
  8033. this._autogrow();
  8034. }
  8035. },
  8036. _autogrow: function() {
  8037. this.element.addClass( "ui-textinput-autogrow" );
  8038. this._on({
  8039. "keyup": "_timeout",
  8040. "change": "_timeout",
  8041. "input": "_timeout",
  8042. "paste": "_timeout"
  8043. });
  8044. // Attach to the various you-have-become-visible notifications that the
  8045. // various framework elements emit.
  8046. // TODO: Remove all but the updatelayout handler once #6426 is fixed.
  8047. this._on( true, this.document, {
  8048. // TODO: Move to non-deprecated event
  8049. "pageshow": "_handleShow",
  8050. "popupbeforeposition": "_handleShow",
  8051. "updatelayout": "_handleShow",
  8052. "panelopen": "_handleShow"
  8053. });
  8054. },
  8055. // Synchronously fix the widget height if this widget's parents are such
  8056. // that they show/hide content at runtime. We still need to check whether
  8057. // the widget is actually visible in case it is contained inside multiple
  8058. // such containers. For example: panel contains collapsible contains
  8059. // autogrow textinput. The panel may emit "panelopen" indicating that its
  8060. // content has become visible, but the collapsible is still collapsed, so
  8061. // the autogrow textarea is still not visible.
  8062. _handleShow: function( event ) {
  8063. if ( $.contains( event.target, this.element[ 0 ] ) &&
  8064. this.element.is( ":visible" ) ) {
  8065. if ( event.type !== "popupbeforeposition" ) {
  8066. this.element
  8067. .addClass( "ui-textinput-autogrow-resize" )
  8068. .animationComplete(
  8069. $.proxy( function() {
  8070. this.element.removeClass( "ui-textinput-autogrow-resize" );
  8071. }, this ),
  8072. "transition" );
  8073. }
  8074. this._prepareHeightUpdate();
  8075. }
  8076. },
  8077. _unbindAutogrow: function() {
  8078. this.element.removeClass( "ui-textinput-autogrow" );
  8079. this._off( this.element, "keyup change input paste" );
  8080. this._off( this.document,
  8081. "pageshow popupbeforeposition updatelayout panelopen" );
  8082. },
  8083. keyupTimeout: null,
  8084. _prepareHeightUpdate: function( delay ) {
  8085. if ( this.keyupTimeout ) {
  8086. clearTimeout( this.keyupTimeout );
  8087. }
  8088. if ( delay === undefined ) {
  8089. this._updateHeight();
  8090. } else {
  8091. this.keyupTimeout = this._delay( "_updateHeight", delay );
  8092. }
  8093. },
  8094. _timeout: function() {
  8095. this._prepareHeightUpdate( this.options.keyupTimeoutBuffer );
  8096. },
  8097. _updateHeight: function() {
  8098. var paddingTop, paddingBottom, paddingHeight, scrollHeight, clientHeight,
  8099. borderTop, borderBottom, borderHeight, height,
  8100. scrollTop = this.window.scrollTop();
  8101. this.keyupTimeout = 0;
  8102. // IE8 textareas have the onpage property - others do not
  8103. if ( !( "onpage" in this.element[ 0 ] ) ) {
  8104. this.element.css({
  8105. "height": 0,
  8106. "min-height": 0,
  8107. "max-height": 0
  8108. });
  8109. }
  8110. scrollHeight = this.element[ 0 ].scrollHeight;
  8111. clientHeight = this.element[ 0 ].clientHeight;
  8112. borderTop = parseFloat( this.element.css( "border-top-width" ) );
  8113. borderBottom = parseFloat( this.element.css( "border-bottom-width" ) );
  8114. borderHeight = borderTop + borderBottom;
  8115. height = scrollHeight + borderHeight + 15;
  8116. // Issue 6179: Padding is not included in scrollHeight and
  8117. // clientHeight by Firefox if no scrollbar is visible. Because
  8118. // textareas use the border-box box-sizing model, padding should be
  8119. // included in the new (assigned) height. Because the height is set
  8120. // to 0, clientHeight == 0 in Firefox. Therefore, we can use this to
  8121. // check if padding must be added.
  8122. if ( clientHeight === 0 ) {
  8123. paddingTop = parseFloat( this.element.css( "padding-top" ) );
  8124. paddingBottom = parseFloat( this.element.css( "padding-bottom" ) );
  8125. paddingHeight = paddingTop + paddingBottom;
  8126. height += paddingHeight;
  8127. }
  8128. this.element.css({
  8129. "height": height,
  8130. "min-height": "",
  8131. "max-height": ""
  8132. });
  8133. this.window.scrollTop( scrollTop );
  8134. },
  8135. refresh: function() {
  8136. if ( this.options.autogrow && this.isTextarea ) {
  8137. this._updateHeight();
  8138. }
  8139. },
  8140. _setOptions: function( options ) {
  8141. this._super( options );
  8142. if ( options.autogrow !== undefined && this.isTextarea ) {
  8143. if ( options.autogrow ) {
  8144. this._autogrow();
  8145. } else {
  8146. this._unbindAutogrow();
  8147. }
  8148. }
  8149. }
  8150. });
  8151. })( jQuery );
  8152. (function( $, undefined ) {
  8153. $.widget( "mobile.selectmenu", $.extend( {
  8154. initSelector: "select:not( :jqmData(role='slider')):not( :jqmData(role='flipswitch') )",
  8155. options: {
  8156. theme: null,
  8157. icon: "carat-d",
  8158. iconpos: "right",
  8159. inline: false,
  8160. corners: true,
  8161. shadow: true,
  8162. iconshadow: false, /* TODO: Deprecated in 1.4, remove in 1.5. */
  8163. overlayTheme: null,
  8164. dividerTheme: null,
  8165. hidePlaceholderMenuItems: true,
  8166. closeText: "Close",
  8167. nativeMenu: true,
  8168. // This option defaults to true on iOS devices.
  8169. preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
  8170. mini: false
  8171. },
  8172. _button: function() {
  8173. return $( "<div/>" );
  8174. },
  8175. _setDisabled: function( value ) {
  8176. this.element.attr( "disabled", value );
  8177. this.button.attr( "aria-disabled", value );
  8178. return this._setOption( "disabled", value );
  8179. },
  8180. _focusButton : function() {
  8181. var self = this;
  8182. setTimeout( function() {
  8183. self.button.focus();
  8184. }, 40);
  8185. },
  8186. _selectOptions: function() {
  8187. return this.select.find( "option" );
  8188. },
  8189. // setup items that are generally necessary for select menu extension
  8190. _preExtension: function() {
  8191. var inline = this.options.inline || this.element.jqmData( "inline" ),
  8192. mini = this.options.mini || this.element.jqmData( "mini" ),
  8193. classes = "";
  8194. // 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
  8195. /* if ( $el[0].className.length ) {
  8196. classes = $el[0].className;
  8197. } */
  8198. if ( !!~this.element[0].className.indexOf( "ui-btn-left" ) ) {
  8199. classes = " ui-btn-left";
  8200. }
  8201. if ( !!~this.element[0].className.indexOf( "ui-btn-right" ) ) {
  8202. classes = " ui-btn-right";
  8203. }
  8204. if ( inline ) {
  8205. classes += " ui-btn-inline";
  8206. }
  8207. if ( mini ) {
  8208. classes += " ui-mini";
  8209. }
  8210. this.select = this.element.removeClass( "ui-btn-left ui-btn-right" ).wrap( "<div class='ui-select" + classes + "'>" );
  8211. this.selectId = this.select.attr( "id" ) || ( "select-" + this.uuid );
  8212. this.buttonId = this.selectId + "-button";
  8213. this.label = $( "label[for='"+ this.selectId +"']" );
  8214. this.isMultiple = this.select[ 0 ].multiple;
  8215. },
  8216. _destroy: function() {
  8217. var wrapper = this.element.parents( ".ui-select" );
  8218. if ( wrapper.length > 0 ) {
  8219. if ( wrapper.is( ".ui-btn-left, .ui-btn-right" ) ) {
  8220. this.element.addClass( wrapper.hasClass( "ui-btn-left" ) ? "ui-btn-left" : "ui-btn-right" );
  8221. }
  8222. this.element.insertAfter( wrapper );
  8223. wrapper.remove();
  8224. }
  8225. },
  8226. _create: function() {
  8227. this._preExtension();
  8228. this.button = this._button();
  8229. var self = this,
  8230. options = this.options,
  8231. iconpos = options.icon ? ( options.iconpos || this.select.jqmData( "iconpos" ) ) : false,
  8232. button = this.button
  8233. .insertBefore( this.select )
  8234. .attr( "id", this.buttonId )
  8235. .addClass( "ui-btn" +
  8236. ( options.icon ? ( " ui-icon-" + options.icon + " ui-btn-icon-" + iconpos +
  8237. ( options.iconshadow ? " ui-shadow-icon" : "" ) ) : "" ) + /* TODO: Remove in 1.5. */
  8238. ( options.theme ? " ui-btn-" + options.theme : "" ) +
  8239. ( options.corners ? " ui-corner-all" : "" ) +
  8240. ( options.shadow ? " ui-shadow" : "" ) );
  8241. this.setButtonText();
  8242. // Opera does not properly support opacity on select elements
  8243. // In Mini, it hides the element, but not its text
  8244. // On the desktop,it seems to do the opposite
  8245. // for these reasons, using the nativeMenu option results in a full native select in Opera
  8246. if ( options.nativeMenu && window.opera && window.opera.version ) {
  8247. button.addClass( "ui-select-nativeonly" );
  8248. }
  8249. // Add counter for multi selects
  8250. if ( this.isMultiple ) {
  8251. this.buttonCount = $( "<span>" )
  8252. .addClass( "ui-li-count ui-body-inherit" )
  8253. .hide()
  8254. .appendTo( button.addClass( "ui-li-has-count" ) );
  8255. }
  8256. // Disable if specified
  8257. if ( options.disabled || this.element.attr( "disabled" )) {
  8258. this.disable();
  8259. }
  8260. // Events on native select
  8261. this.select.change(function() {
  8262. self.refresh();
  8263. if ( !!options.nativeMenu ) {
  8264. self._delay( function() {
  8265. self.select.blur();
  8266. });
  8267. }
  8268. });
  8269. this._handleFormReset();
  8270. this._on( this.button, {
  8271. keydown: "_handleKeydown"
  8272. });
  8273. this.build();
  8274. },
  8275. build: function() {
  8276. var self = this;
  8277. this.select
  8278. .appendTo( self.button )
  8279. .bind( "vmousedown", function() {
  8280. // Add active class to button
  8281. self.button.addClass( $.mobile.activeBtnClass );
  8282. })
  8283. .bind( "focus", function() {
  8284. self.button.addClass( $.mobile.focusClass );
  8285. })
  8286. .bind( "blur", function() {
  8287. self.button.removeClass( $.mobile.focusClass );
  8288. })
  8289. .bind( "focus vmouseover", function() {
  8290. self.button.trigger( "vmouseover" );
  8291. })
  8292. .bind( "vmousemove", function() {
  8293. // Remove active class on scroll/touchmove
  8294. self.button.removeClass( $.mobile.activeBtnClass );
  8295. })
  8296. .bind( "change blur vmouseout", function() {
  8297. self.button.trigger( "vmouseout" )
  8298. .removeClass( $.mobile.activeBtnClass );
  8299. });
  8300. // In many situations, iOS will zoom into the select upon tap, this prevents that from happening
  8301. self.button.bind( "vmousedown", function() {
  8302. if ( self.options.preventFocusZoom ) {
  8303. $.mobile.zoom.disable( true );
  8304. }
  8305. });
  8306. self.label.bind( "click focus", function() {
  8307. if ( self.options.preventFocusZoom ) {
  8308. $.mobile.zoom.disable( true );
  8309. }
  8310. });
  8311. self.select.bind( "focus", function() {
  8312. if ( self.options.preventFocusZoom ) {
  8313. $.mobile.zoom.disable( true );
  8314. }
  8315. });
  8316. self.button.bind( "mouseup", function() {
  8317. if ( self.options.preventFocusZoom ) {
  8318. setTimeout(function() {
  8319. $.mobile.zoom.enable( true );
  8320. }, 0 );
  8321. }
  8322. });
  8323. self.select.bind( "blur", function() {
  8324. if ( self.options.preventFocusZoom ) {
  8325. $.mobile.zoom.enable( true );
  8326. }
  8327. });
  8328. },
  8329. selected: function() {
  8330. return this._selectOptions().filter( ":selected" );
  8331. },
  8332. selectedIndices: function() {
  8333. var self = this;
  8334. return this.selected().map(function() {
  8335. return self._selectOptions().index( this );
  8336. }).get();
  8337. },
  8338. setButtonText: function() {
  8339. var self = this,
  8340. selected = this.selected(),
  8341. text = this.placeholder,
  8342. span = $( document.createElement( "span" ) );
  8343. this.button.children( "span" ).not( ".ui-li-count" ).remove().end().end().prepend( (function() {
  8344. if ( selected.length ) {
  8345. text = selected.map(function() {
  8346. return $( this ).text();
  8347. }).get().join( ", " );
  8348. } else {
  8349. text = self.placeholder;
  8350. }
  8351. if ( text ) {
  8352. span.text( text );
  8353. } else {
  8354. // Set the contents to &nbsp; which we write as &#160; to be XHTML compliant - see gh-6699
  8355. span.html( "&#160;" );
  8356. }
  8357. // TODO possibly aggregate multiple select option classes
  8358. return span
  8359. .addClass( self.select.attr( "class" ) )
  8360. .addClass( selected.attr( "class" ) )
  8361. .removeClass( "ui-screen-hidden" );
  8362. })());
  8363. },
  8364. setButtonCount: function() {
  8365. var selected = this.selected();
  8366. // multiple count inside button
  8367. if ( this.isMultiple ) {
  8368. this.buttonCount[ selected.length > 1 ? "show" : "hide" ]().text( selected.length );
  8369. }
  8370. },
  8371. _handleKeydown: function( /* event */ ) {
  8372. this._delay( "_refreshButton" );
  8373. },
  8374. _reset: function() {
  8375. this.refresh();
  8376. },
  8377. _refreshButton: function() {
  8378. this.setButtonText();
  8379. this.setButtonCount();
  8380. },
  8381. refresh: function() {
  8382. this._refreshButton();
  8383. },
  8384. // open and close preserved in native selects
  8385. // to simplify users code when looping over selects
  8386. open: $.noop,
  8387. close: $.noop,
  8388. disable: function() {
  8389. this._setDisabled( true );
  8390. this.button.addClass( "ui-state-disabled" );
  8391. },
  8392. enable: function() {
  8393. this._setDisabled( false );
  8394. this.button.removeClass( "ui-state-disabled" );
  8395. }
  8396. }, $.mobile.behaviors.formReset ) );
  8397. })( jQuery );
  8398. (function( $, undefined ) {
  8399. $.mobile.links = function( target ) {
  8400. //links within content areas, tests included with page
  8401. $( target )
  8402. .find( "a" )
  8403. .jqmEnhanceable()
  8404. .filter( ":jqmData(rel='popup')[href][href!='']" )
  8405. .each( function() {
  8406. // Accessibility info for popups
  8407. var element = this,
  8408. idref = element.getAttribute( "href" ).substring( 1 );
  8409. if ( idref ) {
  8410. element.setAttribute( "aria-haspopup", true );
  8411. element.setAttribute( "aria-owns", idref );
  8412. element.setAttribute( "aria-expanded", false );
  8413. }
  8414. })
  8415. .end()
  8416. .not( ".ui-btn, :jqmData(role='none'), :jqmData(role='nojs')" )
  8417. .addClass( "ui-link" );
  8418. };
  8419. })( jQuery );
  8420. (function( $, undefined ) {
  8421. function fitSegmentInsideSegment( windowSize, segmentSize, offset, desired ) {
  8422. var returnValue = desired;
  8423. if ( windowSize < segmentSize ) {
  8424. // Center segment if it's bigger than the window
  8425. returnValue = offset + ( windowSize - segmentSize ) / 2;
  8426. } else {
  8427. // Otherwise center it at the desired coordinate while keeping it completely inside the window
  8428. returnValue = Math.min( Math.max( offset, desired - segmentSize / 2 ), offset + windowSize - segmentSize );
  8429. }
  8430. return returnValue;
  8431. }
  8432. function getWindowCoordinates( theWindow ) {
  8433. return {
  8434. x: theWindow.scrollLeft(),
  8435. y: theWindow.scrollTop(),
  8436. cx: ( theWindow[ 0 ].innerWidth || theWindow.width() ),
  8437. cy: ( theWindow[ 0 ].innerHeight || theWindow.height() )
  8438. };
  8439. }
  8440. $.widget( "mobile.popup", {
  8441. options: {
  8442. wrapperClass: null,
  8443. theme: null,
  8444. overlayTheme: null,
  8445. shadow: true,
  8446. corners: true,
  8447. transition: "none",
  8448. positionTo: "origin",
  8449. tolerance: null,
  8450. closeLinkSelector: "a:jqmData(rel='back')",
  8451. closeLinkEvents: "click.popup",
  8452. navigateEvents: "navigate.popup",
  8453. closeEvents: "navigate.popup pagebeforechange.popup",
  8454. dismissible: true,
  8455. enhanced: false,
  8456. // NOTE Windows Phone 7 has a scroll position caching issue that
  8457. // requires us to disable popup history management by default
  8458. // https://github.com/jquery/jquery-mobile/issues/4784
  8459. //
  8460. // NOTE this option is modified in _create!
  8461. history: !$.mobile.browser.oldIE
  8462. },
  8463. // When the user depresses the mouse/finger on an element inside the popup while the popup is
  8464. // open, we ignore resize events for a short while. This prevents #6961.
  8465. _handleDocumentVmousedown: function( theEvent ) {
  8466. if ( this._isOpen && $.contains( this._ui.container[ 0 ], theEvent.target ) ) {
  8467. this._ignoreResizeEvents();
  8468. }
  8469. },
  8470. _create: function() {
  8471. var theElement = this.element,
  8472. myId = theElement.attr( "id" ),
  8473. currentOptions = this.options;
  8474. // We need to adjust the history option to be false if there's no AJAX nav.
  8475. // We can't do it in the option declarations because those are run before
  8476. // it is determined whether there shall be AJAX nav.
  8477. currentOptions.history = currentOptions.history && $.mobile.ajaxEnabled && $.mobile.hashListeningEnabled;
  8478. this._on( this.document, {
  8479. "vmousedown": "_handleDocumentVmousedown"
  8480. });
  8481. // Define instance variables
  8482. $.extend( this, {
  8483. _scrollTop: 0,
  8484. _page: theElement.closest( ".ui-page" ),
  8485. _ui: null,
  8486. _fallbackTransition: "",
  8487. _currentTransition: false,
  8488. _prerequisites: null,
  8489. _isOpen: false,
  8490. _tolerance: null,
  8491. _resizeData: null,
  8492. _ignoreResizeTo: 0,
  8493. _orientationchangeInProgress: false
  8494. });
  8495. if ( this._page.length === 0 ) {
  8496. this._page = $( "body" );
  8497. }
  8498. if ( currentOptions.enhanced ) {
  8499. this._ui = {
  8500. container: theElement.parent(),
  8501. screen: theElement.parent().prev(),
  8502. placeholder: $( this.document[ 0 ].getElementById( myId + "-placeholder" ) )
  8503. };
  8504. } else {
  8505. this._ui = this._enhance( theElement, myId );
  8506. this._applyTransition( currentOptions.transition );
  8507. }
  8508. this
  8509. ._setTolerance( currentOptions.tolerance )
  8510. ._ui.focusElement = this._ui.container;
  8511. // Event handlers
  8512. this._on( this._ui.screen, { "vclick": "_eatEventAndClose" } );
  8513. this._on( this.window, {
  8514. orientationchange: $.proxy( this, "_handleWindowOrientationchange" ),
  8515. resize: $.proxy( this, "_handleWindowResize" ),
  8516. keyup: $.proxy( this, "_handleWindowKeyUp" )
  8517. });
  8518. this._on( this.document, { "focusin": "_handleDocumentFocusIn" } );
  8519. },
  8520. _enhance: function( theElement, myId ) {
  8521. var currentOptions = this.options,
  8522. wrapperClass = currentOptions.wrapperClass,
  8523. ui = {
  8524. screen: $( "<div class='ui-screen-hidden ui-popup-screen " +
  8525. this._themeClassFromOption( "ui-overlay-", currentOptions.overlayTheme ) + "'></div>" ),
  8526. placeholder: $( "<div style='display: none;'><!-- placeholder --></div>" ),
  8527. container: $( "<div class='ui-popup-container ui-popup-hidden ui-popup-truncate" +
  8528. ( wrapperClass ? ( " " + wrapperClass ) : "" ) + "'></div>" )
  8529. },
  8530. fragment = this.document[ 0 ].createDocumentFragment();
  8531. fragment.appendChild( ui.screen[ 0 ] );
  8532. fragment.appendChild( ui.container[ 0 ] );
  8533. if ( myId ) {
  8534. ui.screen.attr( "id", myId + "-screen" );
  8535. ui.container.attr( "id", myId + "-popup" );
  8536. ui.placeholder
  8537. .attr( "id", myId + "-placeholder" )
  8538. .html( "<!-- placeholder for " + myId + " -->" );
  8539. }
  8540. // Apply the proto
  8541. this._page[ 0 ].appendChild( fragment );
  8542. // Leave a placeholder where the element used to be
  8543. ui.placeholder.insertAfter( theElement );
  8544. theElement
  8545. .detach()
  8546. .addClass( "ui-popup " +
  8547. this._themeClassFromOption( "ui-body-", currentOptions.theme ) + " " +
  8548. ( currentOptions.shadow ? "ui-overlay-shadow " : "" ) +
  8549. ( currentOptions.corners ? "ui-corner-all " : "" ) )
  8550. .appendTo( ui.container );
  8551. return ui;
  8552. },
  8553. _eatEventAndClose: function( theEvent ) {
  8554. theEvent.preventDefault();
  8555. theEvent.stopImmediatePropagation();
  8556. if ( this.options.dismissible ) {
  8557. this.close();
  8558. }
  8559. return false;
  8560. },
  8561. // Make sure the screen covers the entire document - CSS is sometimes not
  8562. // enough to accomplish this.
  8563. _resizeScreen: function() {
  8564. var screen = this._ui.screen,
  8565. popupHeight = this._ui.container.outerHeight( true ),
  8566. screenHeight = screen.removeAttr( "style" ).height(),
  8567. // Subtracting 1 here is necessary for an obscure Andrdoid 4.0 bug where
  8568. // the browser hangs if the screen covers the entire document :/
  8569. documentHeight = this.document.height() - 1;
  8570. if ( screenHeight < documentHeight ) {
  8571. screen.height( documentHeight );
  8572. } else if ( popupHeight > screenHeight ) {
  8573. screen.height( popupHeight );
  8574. }
  8575. },
  8576. _handleWindowKeyUp: function( theEvent ) {
  8577. if ( this._isOpen && theEvent.keyCode === $.mobile.keyCode.ESCAPE ) {
  8578. return this._eatEventAndClose( theEvent );
  8579. }
  8580. },
  8581. _expectResizeEvent: function() {
  8582. var windowCoordinates = getWindowCoordinates( this.window );
  8583. if ( this._resizeData ) {
  8584. if ( windowCoordinates.x === this._resizeData.windowCoordinates.x &&
  8585. windowCoordinates.y === this._resizeData.windowCoordinates.y &&
  8586. windowCoordinates.cx === this._resizeData.windowCoordinates.cx &&
  8587. windowCoordinates.cy === this._resizeData.windowCoordinates.cy ) {
  8588. // timeout not refreshed
  8589. return false;
  8590. } else {
  8591. // clear existing timeout - it will be refreshed below
  8592. clearTimeout( this._resizeData.timeoutId );
  8593. }
  8594. }
  8595. this._resizeData = {
  8596. timeoutId: this._delay( "_resizeTimeout", 200 ),
  8597. windowCoordinates: windowCoordinates
  8598. };
  8599. return true;
  8600. },
  8601. _resizeTimeout: function() {
  8602. if ( this._isOpen ) {
  8603. if ( !this._expectResizeEvent() ) {
  8604. if ( this._ui.container.hasClass( "ui-popup-hidden" ) ) {
  8605. // effectively rapid-open the popup while leaving the screen intact
  8606. this._ui.container.removeClass( "ui-popup-hidden ui-popup-truncate" );
  8607. this.reposition( { positionTo: "window" } );
  8608. this._ignoreResizeEvents();
  8609. }
  8610. this._resizeScreen();
  8611. this._resizeData = null;
  8612. this._orientationchangeInProgress = false;
  8613. }
  8614. } else {
  8615. this._resizeData = null;
  8616. this._orientationchangeInProgress = false;
  8617. }
  8618. },
  8619. _stopIgnoringResizeEvents: function() {
  8620. this._ignoreResizeTo = 0;
  8621. },
  8622. _ignoreResizeEvents: function() {
  8623. if ( this._ignoreResizeTo ) {
  8624. clearTimeout( this._ignoreResizeTo );
  8625. }
  8626. this._ignoreResizeTo = this._delay( "_stopIgnoringResizeEvents", 1000 );
  8627. },
  8628. _handleWindowResize: function(/* theEvent */) {
  8629. if ( this._isOpen && this._ignoreResizeTo === 0 ) {
  8630. if ( ( this._expectResizeEvent() || this._orientationchangeInProgress ) &&
  8631. !this._ui.container.hasClass( "ui-popup-hidden" ) ) {
  8632. // effectively rapid-close the popup while leaving the screen intact
  8633. this._ui.container
  8634. .addClass( "ui-popup-hidden ui-popup-truncate" )
  8635. .removeAttr( "style" );
  8636. }
  8637. }
  8638. },
  8639. _handleWindowOrientationchange: function(/* theEvent */) {
  8640. if ( !this._orientationchangeInProgress && this._isOpen && this._ignoreResizeTo === 0 ) {
  8641. this._expectResizeEvent();
  8642. this._orientationchangeInProgress = true;
  8643. }
  8644. },
  8645. // When the popup is open, attempting to focus on an element that is not a
  8646. // child of the popup will redirect focus to the popup
  8647. _handleDocumentFocusIn: function( theEvent ) {
  8648. var target,
  8649. targetElement = theEvent.target,
  8650. ui = this._ui;
  8651. if ( !this._isOpen ) {
  8652. return;
  8653. }
  8654. if ( targetElement !== ui.container[ 0 ] ) {
  8655. target = $( targetElement );
  8656. if ( !$.contains( ui.container[ 0 ], targetElement ) ) {
  8657. $( this.document[ 0 ].activeElement ).one( "focus", $.proxy( function() {
  8658. this._safelyBlur( targetElement );
  8659. }, this ) );
  8660. ui.focusElement.focus();
  8661. theEvent.preventDefault();
  8662. theEvent.stopImmediatePropagation();
  8663. return false;
  8664. } else if ( ui.focusElement[ 0 ] === ui.container[ 0 ] ) {
  8665. ui.focusElement = target;
  8666. }
  8667. }
  8668. this._ignoreResizeEvents();
  8669. },
  8670. _themeClassFromOption: function( prefix, value ) {
  8671. return ( value ? ( value === "none" ? "" : ( prefix + value ) ) : ( prefix + "inherit" ) );
  8672. },
  8673. _applyTransition: function( value ) {
  8674. if ( value ) {
  8675. this._ui.container.removeClass( this._fallbackTransition );
  8676. if ( value !== "none" ) {
  8677. this._fallbackTransition = $.mobile._maybeDegradeTransition( value );
  8678. if ( this._fallbackTransition === "none" ) {
  8679. this._fallbackTransition = "";
  8680. }
  8681. this._ui.container.addClass( this._fallbackTransition );
  8682. }
  8683. }
  8684. return this;
  8685. },
  8686. _setOptions: function( newOptions ) {
  8687. var currentOptions = this.options,
  8688. theElement = this.element,
  8689. screen = this._ui.screen;
  8690. if ( newOptions.wrapperClass !== undefined ) {
  8691. this._ui.container
  8692. .removeClass( currentOptions.wrapperClass )
  8693. .addClass( newOptions.wrapperClass );
  8694. }
  8695. if ( newOptions.theme !== undefined ) {
  8696. theElement
  8697. .removeClass( this._themeClassFromOption( "ui-body-", currentOptions.theme ) )
  8698. .addClass( this._themeClassFromOption( "ui-body-", newOptions.theme ) );
  8699. }
  8700. if ( newOptions.overlayTheme !== undefined ) {
  8701. screen
  8702. .removeClass( this._themeClassFromOption( "ui-overlay-", currentOptions.overlayTheme ) )
  8703. .addClass( this._themeClassFromOption( "ui-overlay-", newOptions.overlayTheme ) );
  8704. if ( this._isOpen ) {
  8705. screen.addClass( "in" );
  8706. }
  8707. }
  8708. if ( newOptions.shadow !== undefined ) {
  8709. theElement.toggleClass( "ui-overlay-shadow", newOptions.shadow );
  8710. }
  8711. if ( newOptions.corners !== undefined ) {
  8712. theElement.toggleClass( "ui-corner-all", newOptions.corners );
  8713. }
  8714. if ( newOptions.transition !== undefined ) {
  8715. if ( !this._currentTransition ) {
  8716. this._applyTransition( newOptions.transition );
  8717. }
  8718. }
  8719. if ( newOptions.tolerance !== undefined ) {
  8720. this._setTolerance( newOptions.tolerance );
  8721. }
  8722. if ( newOptions.disabled !== undefined ) {
  8723. if ( newOptions.disabled ) {
  8724. this.close();
  8725. }
  8726. }
  8727. return this._super( newOptions );
  8728. },
  8729. _setTolerance: function( value ) {
  8730. var tol = { t: 30, r: 15, b: 30, l: 15 },
  8731. ar;
  8732. if ( value !== undefined ) {
  8733. ar = String( value ).split( "," );
  8734. $.each( ar, function( idx, val ) { ar[ idx ] = parseInt( val, 10 ); } );
  8735. switch( ar.length ) {
  8736. // All values are to be the same
  8737. case 1:
  8738. if ( !isNaN( ar[ 0 ] ) ) {
  8739. tol.t = tol.r = tol.b = tol.l = ar[ 0 ];
  8740. }
  8741. break;
  8742. // The first value denotes top/bottom tolerance, and the second value denotes left/right tolerance
  8743. case 2:
  8744. if ( !isNaN( ar[ 0 ] ) ) {
  8745. tol.t = tol.b = ar[ 0 ];
  8746. }
  8747. if ( !isNaN( ar[ 1 ] ) ) {
  8748. tol.l = tol.r = ar[ 1 ];
  8749. }
  8750. break;
  8751. // The array contains values in the order top, right, bottom, left
  8752. case 4:
  8753. if ( !isNaN( ar[ 0 ] ) ) {
  8754. tol.t = ar[ 0 ];
  8755. }
  8756. if ( !isNaN( ar[ 1 ] ) ) {
  8757. tol.r = ar[ 1 ];
  8758. }
  8759. if ( !isNaN( ar[ 2 ] ) ) {
  8760. tol.b = ar[ 2 ];
  8761. }
  8762. if ( !isNaN( ar[ 3 ] ) ) {
  8763. tol.l = ar[ 3 ];
  8764. }
  8765. break;
  8766. default:
  8767. break;
  8768. }
  8769. }
  8770. this._tolerance = tol;
  8771. return this;
  8772. },
  8773. _clampPopupWidth: function( infoOnly ) {
  8774. var menuSize,
  8775. windowCoordinates = getWindowCoordinates( this.window ),
  8776. // rectangle within which the popup must fit
  8777. rectangle = {
  8778. x: this._tolerance.l,
  8779. y: windowCoordinates.y + this._tolerance.t,
  8780. cx: windowCoordinates.cx - this._tolerance.l - this._tolerance.r,
  8781. cy: windowCoordinates.cy - this._tolerance.t - this._tolerance.b
  8782. };
  8783. if ( !infoOnly ) {
  8784. // Clamp the width of the menu before grabbing its size
  8785. this._ui.container.css( "max-width", rectangle.cx );
  8786. }
  8787. menuSize = {
  8788. cx: this._ui.container.outerWidth( true ),
  8789. cy: this._ui.container.outerHeight( true )
  8790. };
  8791. return { rc: rectangle, menuSize: menuSize };
  8792. },
  8793. _calculateFinalLocation: function( desired, clampInfo ) {
  8794. var returnValue,
  8795. rectangle = clampInfo.rc,
  8796. menuSize = clampInfo.menuSize;
  8797. // Center the menu over the desired coordinates, while not going outside
  8798. // the window tolerances. This will center wrt. the window if the popup is
  8799. // too large.
  8800. returnValue = {
  8801. left: fitSegmentInsideSegment( rectangle.cx, menuSize.cx, rectangle.x, desired.x ),
  8802. top: fitSegmentInsideSegment( rectangle.cy, menuSize.cy, rectangle.y, desired.y )
  8803. };
  8804. // Make sure the top of the menu is visible
  8805. returnValue.top = Math.max( 0, returnValue.top );
  8806. // If the height of the menu is smaller than the height of the document
  8807. // align the bottom with the bottom of the document
  8808. returnValue.top -= Math.min( returnValue.top,
  8809. Math.max( 0, returnValue.top + menuSize.cy - this.document.height() ) );
  8810. return returnValue;
  8811. },
  8812. // Try and center the overlay over the given coordinates
  8813. _placementCoords: function( desired ) {
  8814. return this._calculateFinalLocation( desired, this._clampPopupWidth() );
  8815. },
  8816. _createPrerequisites: function( screenPrerequisite, containerPrerequisite, whenDone ) {
  8817. var prerequisites,
  8818. self = this;
  8819. // It is important to maintain both the local variable prerequisites and
  8820. // self._prerequisites. The local variable remains in the closure of the
  8821. // functions which call the callbacks passed in. The comparison between the
  8822. // local variable and self._prerequisites is necessary, because once a
  8823. // function has been passed to .animationComplete() it will be called next
  8824. // time an animation completes, even if that's not the animation whose end
  8825. // the function was supposed to catch (for example, if an abort happens
  8826. // during the opening animation, the .animationComplete handler is not
  8827. // called for that animation anymore, but the handler remains attached, so
  8828. // it is called the next time the popup is opened - making it stale.
  8829. // Comparing the local variable prerequisites to the widget-level variable
  8830. // self._prerequisites ensures that callbacks triggered by a stale
  8831. // .animationComplete will be ignored.
  8832. prerequisites = {
  8833. screen: $.Deferred(),
  8834. container: $.Deferred()
  8835. };
  8836. prerequisites.screen.then( function() {
  8837. if ( prerequisites === self._prerequisites ) {
  8838. screenPrerequisite();
  8839. }
  8840. });
  8841. prerequisites.container.then( function() {
  8842. if ( prerequisites === self._prerequisites ) {
  8843. containerPrerequisite();
  8844. }
  8845. });
  8846. $.when( prerequisites.screen, prerequisites.container ).done( function() {
  8847. if ( prerequisites === self._prerequisites ) {
  8848. self._prerequisites = null;
  8849. whenDone();
  8850. }
  8851. });
  8852. self._prerequisites = prerequisites;
  8853. },
  8854. _animate: function( args ) {
  8855. // NOTE before removing the default animation of the screen
  8856. // this had an animate callback that would resolve the deferred
  8857. // now the deferred is resolved immediately
  8858. // TODO remove the dependency on the screen deferred
  8859. this._ui.screen
  8860. .removeClass( args.classToRemove )
  8861. .addClass( args.screenClassToAdd );
  8862. args.prerequisites.screen.resolve();
  8863. if ( args.transition && args.transition !== "none" ) {
  8864. if ( args.applyTransition ) {
  8865. this._applyTransition( args.transition );
  8866. }
  8867. if ( this._fallbackTransition ) {
  8868. this._ui.container
  8869. .addClass( args.containerClassToAdd )
  8870. .removeClass( args.classToRemove )
  8871. .animationComplete( $.proxy( args.prerequisites.container, "resolve" ) );
  8872. return;
  8873. }
  8874. }
  8875. this._ui.container.removeClass( args.classToRemove );
  8876. args.prerequisites.container.resolve();
  8877. },
  8878. // The desired coordinates passed in will be returned untouched if no reference element can be identified via
  8879. // desiredPosition.positionTo. Nevertheless, this function ensures that its return value always contains valid
  8880. // x and y coordinates by specifying the center middle of the window if the coordinates are absent.
  8881. // options: { x: coordinate, y: coordinate, positionTo: string: "origin", "window", or jQuery selector
  8882. _desiredCoords: function( openOptions ) {
  8883. var offset,
  8884. dst = null,
  8885. windowCoordinates = getWindowCoordinates( this.window ),
  8886. x = openOptions.x,
  8887. y = openOptions.y,
  8888. pTo = openOptions.positionTo;
  8889. // Establish which element will serve as the reference
  8890. if ( pTo && pTo !== "origin" ) {
  8891. if ( pTo === "window" ) {
  8892. x = windowCoordinates.cx / 2 + windowCoordinates.x;
  8893. y = windowCoordinates.cy / 2 + windowCoordinates.y;
  8894. } else {
  8895. try {
  8896. dst = $( pTo );
  8897. } catch( err ) {
  8898. dst = null;
  8899. }
  8900. if ( dst ) {
  8901. dst.filter( ":visible" );
  8902. if ( dst.length === 0 ) {
  8903. dst = null;
  8904. }
  8905. }
  8906. }
  8907. }
  8908. // If an element was found, center over it
  8909. if ( dst ) {
  8910. offset = dst.offset();
  8911. x = offset.left + dst.outerWidth() / 2;
  8912. y = offset.top + dst.outerHeight() / 2;
  8913. }
  8914. // Make sure x and y are valid numbers - center over the window
  8915. if ( $.type( x ) !== "number" || isNaN( x ) ) {
  8916. x = windowCoordinates.cx / 2 + windowCoordinates.x;
  8917. }
  8918. if ( $.type( y ) !== "number" || isNaN( y ) ) {
  8919. y = windowCoordinates.cy / 2 + windowCoordinates.y;
  8920. }
  8921. return { x: x, y: y };
  8922. },
  8923. _reposition: function( openOptions ) {
  8924. // We only care about position-related parameters for repositioning
  8925. openOptions = {
  8926. x: openOptions.x,
  8927. y: openOptions.y,
  8928. positionTo: openOptions.positionTo
  8929. };
  8930. this._trigger( "beforeposition", undefined, openOptions );
  8931. this._ui.container.offset( this._placementCoords( this._desiredCoords( openOptions ) ) );
  8932. },
  8933. reposition: function( openOptions ) {
  8934. if ( this._isOpen ) {
  8935. this._reposition( openOptions );
  8936. }
  8937. },
  8938. _safelyBlur: function( currentElement ){
  8939. if ( currentElement !== this.window[ 0 ] &&
  8940. currentElement.nodeName.toLowerCase() !== "body" ) {
  8941. $( currentElement ).blur();
  8942. }
  8943. },
  8944. _openPrerequisitesComplete: function() {
  8945. var id = this.element.attr( "id" ),
  8946. firstFocus = this._ui.container.find( ":focusable" ).first();
  8947. this._ui.container.addClass( "ui-popup-active" );
  8948. this._isOpen = true;
  8949. this._resizeScreen();
  8950. // Check to see if currElement is not a child of the container. If it's not, blur
  8951. if ( !$.contains( this._ui.container[ 0 ], this.document[ 0 ].activeElement ) ) {
  8952. this._safelyBlur( this.document[ 0 ].activeElement );
  8953. }
  8954. if ( firstFocus.length > 0 ) {
  8955. this._ui.focusElement = firstFocus;
  8956. }
  8957. this._ignoreResizeEvents();
  8958. if ( id ) {
  8959. this.document.find( "[aria-haspopup='true'][aria-owns='" + id + "']" ).attr( "aria-expanded", true );
  8960. }
  8961. this._trigger( "afteropen" );
  8962. },
  8963. _open: function( options ) {
  8964. var openOptions = $.extend( {}, this.options, options ),
  8965. // TODO move blacklist to private method
  8966. androidBlacklist = ( function() {
  8967. var ua = navigator.userAgent,
  8968. // Rendering engine is Webkit, and capture major version
  8969. wkmatch = ua.match( /AppleWebKit\/([0-9\.]+)/ ),
  8970. wkversion = !!wkmatch && wkmatch[ 1 ],
  8971. androidmatch = ua.match( /Android (\d+(?:\.\d+))/ ),
  8972. andversion = !!androidmatch && androidmatch[ 1 ],
  8973. chromematch = ua.indexOf( "Chrome" ) > -1;
  8974. // Platform is Android, WebKit version is greater than 534.13 ( Android 3.2.1 ) and not Chrome.
  8975. if ( androidmatch !== null && andversion === "4.0" && wkversion && wkversion > 534.13 && !chromematch ) {
  8976. return true;
  8977. }
  8978. return false;
  8979. }());
  8980. // Count down to triggering "popupafteropen" - we have two prerequisites:
  8981. // 1. The popup window animation completes (container())
  8982. // 2. The screen opacity animation completes (screen())
  8983. this._createPrerequisites(
  8984. $.noop,
  8985. $.noop,
  8986. $.proxy( this, "_openPrerequisitesComplete" ) );
  8987. this._currentTransition = openOptions.transition;
  8988. this._applyTransition( openOptions.transition );
  8989. this._ui.screen.removeClass( "ui-screen-hidden" );
  8990. this._ui.container.removeClass( "ui-popup-truncate" );
  8991. // Give applications a chance to modify the contents of the container before it appears
  8992. this._reposition( openOptions );
  8993. this._ui.container.removeClass( "ui-popup-hidden" );
  8994. if ( this.options.overlayTheme && androidBlacklist ) {
  8995. /* 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
  8996. This fix closes the following bugs ( I use "closes" with reluctance, and stress that this issue should be revisited as soon as possible ):
  8997. https://github.com/jquery/jquery-mobile/issues/4816
  8998. https://github.com/jquery/jquery-mobile/issues/4844
  8999. https://github.com/jquery/jquery-mobile/issues/4874
  9000. */
  9001. // TODO sort out why this._page isn't working
  9002. this.element.closest( ".ui-page" ).addClass( "ui-popup-open" );
  9003. }
  9004. this._animate({
  9005. additionalCondition: true,
  9006. transition: openOptions.transition,
  9007. classToRemove: "",
  9008. screenClassToAdd: "in",
  9009. containerClassToAdd: "in",
  9010. applyTransition: false,
  9011. prerequisites: this._prerequisites
  9012. });
  9013. },
  9014. _closePrerequisiteScreen: function() {
  9015. this._ui.screen
  9016. .removeClass( "out" )
  9017. .addClass( "ui-screen-hidden" );
  9018. },
  9019. _closePrerequisiteContainer: function() {
  9020. this._ui.container
  9021. .removeClass( "reverse out" )
  9022. .addClass( "ui-popup-hidden ui-popup-truncate" )
  9023. .removeAttr( "style" );
  9024. },
  9025. _closePrerequisitesDone: function() {
  9026. var container = this._ui.container,
  9027. id = this.element.attr( "id" );
  9028. // remove the global mutex for popups
  9029. $.mobile.popup.active = undefined;
  9030. // Blur elements inside the container, including the container
  9031. $( ":focus", container[ 0 ] ).add( container[ 0 ] ).blur();
  9032. if ( id ) {
  9033. this.document.find( "[aria-haspopup='true'][aria-owns='" + id + "']" ).attr( "aria-expanded", false );
  9034. }
  9035. // alert users that the popup is closed
  9036. this._trigger( "afterclose" );
  9037. },
  9038. _close: function( immediate ) {
  9039. this._ui.container.removeClass( "ui-popup-active" );
  9040. this._page.removeClass( "ui-popup-open" );
  9041. this._isOpen = false;
  9042. // Count down to triggering "popupafterclose" - we have two prerequisites:
  9043. // 1. The popup window reverse animation completes (container())
  9044. // 2. The screen opacity animation completes (screen())
  9045. this._createPrerequisites(
  9046. $.proxy( this, "_closePrerequisiteScreen" ),
  9047. $.proxy( this, "_closePrerequisiteContainer" ),
  9048. $.proxy( this, "_closePrerequisitesDone" ) );
  9049. this._animate( {
  9050. additionalCondition: this._ui.screen.hasClass( "in" ),
  9051. transition: ( immediate ? "none" : ( this._currentTransition ) ),
  9052. classToRemove: "in",
  9053. screenClassToAdd: "out",
  9054. containerClassToAdd: "reverse out",
  9055. applyTransition: true,
  9056. prerequisites: this._prerequisites
  9057. });
  9058. },
  9059. _unenhance: function() {
  9060. if ( this.options.enhanced ) {
  9061. return;
  9062. }
  9063. // Put the element back to where the placeholder was and remove the "ui-popup" class
  9064. this._setOptions( { theme: $.mobile.popup.prototype.options.theme } );
  9065. this.element
  9066. // Cannot directly insertAfter() - we need to detach() first, because
  9067. // insertAfter() will do nothing if the payload div was not attached
  9068. // to the DOM at the time the widget was created, and so the payload
  9069. // will remain inside the container even after we call insertAfter().
  9070. // If that happens and we remove the container a few lines below, we
  9071. // will cause an infinite recursion - #5244
  9072. .detach()
  9073. .insertAfter( this._ui.placeholder )
  9074. .removeClass( "ui-popup ui-overlay-shadow ui-corner-all ui-body-inherit" );
  9075. this._ui.screen.remove();
  9076. this._ui.container.remove();
  9077. this._ui.placeholder.remove();
  9078. },
  9079. _destroy: function() {
  9080. if ( $.mobile.popup.active === this ) {
  9081. this.element.one( "popupafterclose", $.proxy( this, "_unenhance" ) );
  9082. this.close();
  9083. } else {
  9084. this._unenhance();
  9085. }
  9086. return this;
  9087. },
  9088. _closePopup: function( theEvent, data ) {
  9089. var parsedDst, toUrl,
  9090. currentOptions = this.options,
  9091. immediate = false;
  9092. if ( ( theEvent && theEvent.isDefaultPrevented() ) || $.mobile.popup.active !== this ) {
  9093. return;
  9094. }
  9095. // restore location on screen
  9096. window.scrollTo( 0, this._scrollTop );
  9097. if ( theEvent && theEvent.type === "pagebeforechange" && data ) {
  9098. // Determine whether we need to rapid-close the popup, or whether we can
  9099. // take the time to run the closing transition
  9100. if ( typeof data.toPage === "string" ) {
  9101. parsedDst = data.toPage;
  9102. } else {
  9103. parsedDst = data.toPage.jqmData( "url" );
  9104. }
  9105. parsedDst = $.mobile.path.parseUrl( parsedDst );
  9106. toUrl = parsedDst.pathname + parsedDst.search + parsedDst.hash;
  9107. if ( this._myUrl !== $.mobile.path.makeUrlAbsolute( toUrl ) ) {
  9108. // Going to a different page - close immediately
  9109. immediate = true;
  9110. } else {
  9111. theEvent.preventDefault();
  9112. }
  9113. }
  9114. // remove nav bindings
  9115. this.window.off( currentOptions.closeEvents );
  9116. // unbind click handlers added when history is disabled
  9117. this.element.undelegate( currentOptions.closeLinkSelector, currentOptions.closeLinkEvents );
  9118. this._close( immediate );
  9119. },
  9120. // any navigation event after a popup is opened should close the popup
  9121. // NOTE the pagebeforechange is bound to catch navigation events that don't
  9122. // alter the url (eg, dialogs from popups)
  9123. _bindContainerClose: function() {
  9124. this.window
  9125. .on( this.options.closeEvents, $.proxy( this, "_closePopup" ) );
  9126. },
  9127. widget: function() {
  9128. return this._ui.container;
  9129. },
  9130. // TODO no clear deliniation of what should be here and
  9131. // what should be in _open. Seems to be "visual" vs "history" for now
  9132. open: function( options ) {
  9133. var url, hashkey, activePage, currentIsDialog, hasHash, urlHistory,
  9134. self = this,
  9135. currentOptions = this.options;
  9136. // make sure open is idempotent
  9137. if ( $.mobile.popup.active || currentOptions.disabled ) {
  9138. return this;
  9139. }
  9140. // set the global popup mutex
  9141. $.mobile.popup.active = this;
  9142. this._scrollTop = this.window.scrollTop();
  9143. // if history alteration is disabled close on navigate events
  9144. // and leave the url as is
  9145. if ( !( currentOptions.history ) ) {
  9146. self._open( options );
  9147. self._bindContainerClose();
  9148. // When histoy is disabled we have to grab the data-rel
  9149. // back link clicks so we can close the popup instead of
  9150. // relying on history to do it for us
  9151. self.element
  9152. .delegate( currentOptions.closeLinkSelector, currentOptions.closeLinkEvents, function( theEvent ) {
  9153. self.close();
  9154. theEvent.preventDefault();
  9155. });
  9156. return this;
  9157. }
  9158. // cache some values for min/readability
  9159. urlHistory = $.mobile.navigate.history;
  9160. hashkey = $.mobile.dialogHashKey;
  9161. activePage = $.mobile.activePage;
  9162. currentIsDialog = ( activePage ? activePage.hasClass( "ui-dialog" ) : false );
  9163. this._myUrl = url = urlHistory.getActive().url;
  9164. hasHash = ( url.indexOf( hashkey ) > -1 ) && !currentIsDialog && ( urlHistory.activeIndex > 0 );
  9165. if ( hasHash ) {
  9166. self._open( options );
  9167. self._bindContainerClose();
  9168. return this;
  9169. }
  9170. // if the current url has no dialog hash key proceed as normal
  9171. // otherwise, if the page is a dialog simply tack on the hash key
  9172. if ( url.indexOf( hashkey ) === -1 && !currentIsDialog ) {
  9173. url = url + (url.indexOf( "#" ) > -1 ? hashkey : "#" + hashkey);
  9174. } else {
  9175. url = $.mobile.path.parseLocation().hash + hashkey;
  9176. }
  9177. // swallow the the initial navigation event, and bind for the next
  9178. this.window.one( "beforenavigate", function( theEvent ) {
  9179. theEvent.preventDefault();
  9180. self._open( options );
  9181. self._bindContainerClose();
  9182. });
  9183. this.urlAltered = true;
  9184. $.mobile.navigate( url, { role: "dialog" } );
  9185. return this;
  9186. },
  9187. close: function() {
  9188. // make sure close is idempotent
  9189. if ( $.mobile.popup.active !== this ) {
  9190. return this;
  9191. }
  9192. this._scrollTop = this.window.scrollTop();
  9193. if ( this.options.history && this.urlAltered ) {
  9194. $.mobile.back();
  9195. this.urlAltered = false;
  9196. } else {
  9197. // simulate the nav bindings having fired
  9198. this._closePopup();
  9199. }
  9200. return this;
  9201. }
  9202. });
  9203. // TODO this can be moved inside the widget
  9204. $.mobile.popup.handleLink = function( $link ) {
  9205. var offset,
  9206. path = $.mobile.path,
  9207. // NOTE make sure to get only the hash from the href because ie7 (wp7)
  9208. // returns the absolute href in this case ruining the element selection
  9209. popup = $( path.hashToSelector( path.parseUrl( $link.attr( "href" ) ).hash ) ).first();
  9210. if ( popup.length > 0 && popup.data( "mobile-popup" ) ) {
  9211. offset = $link.offset();
  9212. popup.popup( "open", {
  9213. x: offset.left + $link.outerWidth() / 2,
  9214. y: offset.top + $link.outerHeight() / 2,
  9215. transition: $link.jqmData( "transition" ),
  9216. positionTo: $link.jqmData( "position-to" )
  9217. });
  9218. }
  9219. //remove after delay
  9220. setTimeout( function() {
  9221. $link.removeClass( $.mobile.activeBtnClass );
  9222. }, 300 );
  9223. };
  9224. // TODO move inside _create
  9225. $.mobile.document.on( "pagebeforechange", function( theEvent, data ) {
  9226. if ( data.options.role === "popup" ) {
  9227. $.mobile.popup.handleLink( data.options.link );
  9228. theEvent.preventDefault();
  9229. }
  9230. });
  9231. })( jQuery );
  9232. /*
  9233. * custom "selectmenu" plugin
  9234. */
  9235. (function( $, undefined ) {
  9236. var unfocusableItemSelector = ".ui-disabled,.ui-state-disabled,.ui-li-divider,.ui-screen-hidden,:jqmData(role='placeholder')",
  9237. goToAdjacentItem = function( item, target, direction ) {
  9238. var adjacent = item[ direction + "All" ]()
  9239. .not( unfocusableItemSelector )
  9240. .first();
  9241. // if there's a previous option, focus it
  9242. if ( adjacent.length ) {
  9243. target
  9244. .blur()
  9245. .attr( "tabindex", "-1" );
  9246. adjacent.find( "a" ).first().focus();
  9247. }
  9248. };
  9249. $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
  9250. _create: function() {
  9251. var o = this.options;
  9252. // Custom selects cannot exist inside popups, so revert the "nativeMenu"
  9253. // option to true if a parent is a popup
  9254. o.nativeMenu = o.nativeMenu || ( this.element.parents( ":jqmData(role='popup'),:mobile-popup" ).length > 0 );
  9255. return this._super();
  9256. },
  9257. _handleSelectFocus: function() {
  9258. this.element.blur();
  9259. this.button.focus();
  9260. },
  9261. _handleKeydown: function( event ) {
  9262. this._super( event );
  9263. this._handleButtonVclickKeydown( event );
  9264. },
  9265. _handleButtonVclickKeydown: function( event ) {
  9266. if ( this.options.disabled || this.isOpen || this.options.nativeMenu ) {
  9267. return;
  9268. }
  9269. if (event.type === "vclick" ||
  9270. event.keyCode && (event.keyCode === $.mobile.keyCode.ENTER || event.keyCode === $.mobile.keyCode.SPACE)) {
  9271. this._decideFormat();
  9272. if ( this.menuType === "overlay" ) {
  9273. this.button.attr( "href", "#" + this.popupId ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "popup" );
  9274. } else {
  9275. this.button.attr( "href", "#" + this.dialogId ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "dialog" );
  9276. }
  9277. this.isOpen = true;
  9278. // Do not prevent default, so the navigation may have a chance to actually open the chosen format
  9279. }
  9280. },
  9281. _handleListFocus: function( e ) {
  9282. var params = ( e.type === "focusin" ) ?
  9283. { tabindex: "0", event: "vmouseover" }:
  9284. { tabindex: "-1", event: "vmouseout" };
  9285. $( e.target )
  9286. .attr( "tabindex", params.tabindex )
  9287. .trigger( params.event );
  9288. },
  9289. _handleListKeydown: function( event ) {
  9290. var target = $( event.target ),
  9291. li = target.closest( "li" );
  9292. // switch logic based on which key was pressed
  9293. switch ( event.keyCode ) {
  9294. // up or left arrow keys
  9295. case 38:
  9296. goToAdjacentItem( li, target, "prev" );
  9297. return false;
  9298. // down or right arrow keys
  9299. case 40:
  9300. goToAdjacentItem( li, target, "next" );
  9301. return false;
  9302. // If enter or space is pressed, trigger click
  9303. case 13:
  9304. case 32:
  9305. target.trigger( "click" );
  9306. return false;
  9307. }
  9308. },
  9309. _handleMenuPageHide: function() {
  9310. // After the dialog's done, we may want to trigger change if the value has actually changed
  9311. this._delayedTrigger();
  9312. // TODO centralize page removal binding / handling in the page plugin.
  9313. // Suggestion from @jblas to do refcounting
  9314. //
  9315. // TODO extremely confusing dependency on the open method where the pagehide.remove
  9316. // bindings are stripped to prevent the parent page from disappearing. The way
  9317. // we're keeping pages in the DOM right now sucks
  9318. //
  9319. // rebind the page remove that was unbound in the open function
  9320. // to allow for the parent page removal from actions other than the use
  9321. // of a dialog sized custom select
  9322. //
  9323. // doing this here provides for the back button on the custom select dialog
  9324. this.thisPage.page( "bindRemove" );
  9325. },
  9326. _handleHeaderCloseClick: function() {
  9327. if ( this.menuType === "overlay" ) {
  9328. this.close();
  9329. return false;
  9330. }
  9331. },
  9332. _handleListItemClick: function( event ) {
  9333. var listItem = $( event.target ).closest( "li" ),
  9334. // Index of option tag to be selected
  9335. oldIndex = this.select[ 0 ].selectedIndex,
  9336. newIndex = $.mobile.getAttribute( listItem, "option-index" ),
  9337. option = this._selectOptions().eq( newIndex )[ 0 ];
  9338. // Toggle selected status on the tag for multi selects
  9339. option.selected = this.isMultiple ? !option.selected : true;
  9340. // Toggle checkbox class for multiple selects
  9341. if ( this.isMultiple ) {
  9342. listItem.find( "a" )
  9343. .toggleClass( "ui-checkbox-on", option.selected )
  9344. .toggleClass( "ui-checkbox-off", !option.selected );
  9345. }
  9346. // If it's not a multiple select, trigger change after it has finished closing
  9347. if ( !this.isMultiple && oldIndex !== newIndex ) {
  9348. this._triggerChange = true;
  9349. }
  9350. // Trigger change if it's a multiple select
  9351. // Hide custom select for single selects only - otherwise focus clicked item
  9352. // We need to grab the clicked item the hard way, because the list may have been rebuilt
  9353. if ( this.isMultiple ) {
  9354. this.select.trigger( "change" );
  9355. this.list.find( "li:not(.ui-li-divider)" ).eq( newIndex )
  9356. .find( "a" ).first().focus();
  9357. }
  9358. else {
  9359. this.close();
  9360. }
  9361. event.preventDefault();
  9362. },
  9363. build: function() {
  9364. var selectId, popupId, dialogId, label, thisPage, isMultiple, menuId,
  9365. themeAttr, overlayTheme, overlayThemeAttr, dividerThemeAttr,
  9366. menuPage, listbox, list, header, headerTitle, menuPageContent,
  9367. menuPageClose, headerClose,
  9368. o = this.options;
  9369. if ( o.nativeMenu ) {
  9370. return this._super();
  9371. }
  9372. selectId = this.selectId;
  9373. popupId = selectId + "-listbox";
  9374. dialogId = selectId + "-dialog";
  9375. label = this.label;
  9376. thisPage = this.element.closest( ".ui-page" );
  9377. isMultiple = this.element[ 0 ].multiple;
  9378. menuId = selectId + "-menu";
  9379. themeAttr = o.theme ? ( " data-" + $.mobile.ns + "theme='" + o.theme + "'" ) : "";
  9380. overlayTheme = o.overlayTheme || o.theme || null;
  9381. overlayThemeAttr = overlayTheme ? ( " data-" + $.mobile.ns +
  9382. "overlay-theme='" + overlayTheme + "'" ) : "";
  9383. dividerThemeAttr = ( o.dividerTheme && isMultiple ) ? ( " data-" + $.mobile.ns + "divider-theme='" + o.dividerTheme + "'" ) : "";
  9384. menuPage = $( "<div data-" + $.mobile.ns + "role='dialog' class='ui-selectmenu' id='" + dialogId + "'" + themeAttr + overlayThemeAttr + ">" +
  9385. "<div data-" + $.mobile.ns + "role='header'>" +
  9386. "<div class='ui-title'></div>"+
  9387. "</div>"+
  9388. "<div data-" + $.mobile.ns + "role='content'></div>"+
  9389. "</div>" );
  9390. listbox = $( "<div" + themeAttr + overlayThemeAttr + " id='" + popupId +
  9391. "' class='ui-selectmenu'></div>" )
  9392. .insertAfter( this.select )
  9393. .popup();
  9394. list = $( "<ul class='ui-selectmenu-list' id='" + menuId + "' role='listbox' aria-labelledby='" + this.buttonId + "'" + themeAttr + dividerThemeAttr + "></ul>" ).appendTo( listbox );
  9395. header = $( "<div class='ui-header ui-bar-" + ( o.theme ? o.theme : "inherit" ) + "'></div>" ).prependTo( listbox );
  9396. headerTitle = $( "<h1 class='ui-title'></h1>" ).appendTo( header );
  9397. if ( this.isMultiple ) {
  9398. headerClose = $( "<a>", {
  9399. "role": "button",
  9400. "text": o.closeText,
  9401. "href": "#",
  9402. "class": "ui-btn ui-corner-all ui-btn-left ui-btn-icon-notext ui-icon-delete"
  9403. }).appendTo( header );
  9404. }
  9405. $.extend( this, {
  9406. selectId: selectId,
  9407. menuId: menuId,
  9408. popupId: popupId,
  9409. dialogId: dialogId,
  9410. thisPage: thisPage,
  9411. menuPage: menuPage,
  9412. label: label,
  9413. isMultiple: isMultiple,
  9414. theme: o.theme,
  9415. listbox: listbox,
  9416. list: list,
  9417. header: header,
  9418. headerTitle: headerTitle,
  9419. headerClose: headerClose,
  9420. menuPageContent: menuPageContent,
  9421. menuPageClose: menuPageClose,
  9422. placeholder: ""
  9423. });
  9424. // Create list from select, update state
  9425. this.refresh();
  9426. if ( this._origTabIndex === undefined ) {
  9427. // Map undefined to false, because this._origTabIndex === undefined
  9428. // indicates that we have not yet checked whether the select has
  9429. // originally had a tabindex attribute, whereas false indicates that
  9430. // we have checked the select for such an attribute, and have found
  9431. // none present.
  9432. this._origTabIndex = ( this.select[ 0 ].getAttribute( "tabindex" ) === null ) ? false : this.select.attr( "tabindex" );
  9433. }
  9434. this.select.attr( "tabindex", "-1" );
  9435. this._on( this.select, { focus : "_handleSelectFocus" } );
  9436. // Button events
  9437. this._on( this.button, {
  9438. vclick: "_handleButtonVclickKeydown"
  9439. });
  9440. // Events for list items
  9441. this.list.attr( "role", "listbox" );
  9442. this._on( this.list, {
  9443. "focusin": "_handleListFocus",
  9444. "focusout": "_handleListFocus",
  9445. "keydown": "_handleListKeydown",
  9446. "click li:not(.ui-disabled,.ui-state-disabled,.ui-li-divider)": "_handleListItemClick"
  9447. });
  9448. // button refocus ensures proper height calculation
  9449. // by removing the inline style and ensuring page inclusion
  9450. this._on( this.menuPage, { pagehide: "_handleMenuPageHide" } );
  9451. // Events on the popup
  9452. this._on( this.listbox, { popupafterclose: "_popupClosed" } );
  9453. // Close button on small overlays
  9454. if ( this.isMultiple ) {
  9455. this._on( this.headerClose, { click: "_handleHeaderCloseClick" } );
  9456. }
  9457. return this;
  9458. },
  9459. _popupClosed: function() {
  9460. this.close();
  9461. this._delayedTrigger();
  9462. },
  9463. _delayedTrigger: function() {
  9464. if ( this._triggerChange ) {
  9465. this.element.trigger( "change" );
  9466. }
  9467. this._triggerChange = false;
  9468. },
  9469. _isRebuildRequired: function() {
  9470. var list = this.list.find( "li" ),
  9471. options = this._selectOptions().not( ".ui-screen-hidden" );
  9472. // TODO exceedingly naive method to determine difference
  9473. // ignores value changes etc in favor of a forcedRebuild
  9474. // from the user in the refresh method
  9475. return options.text() !== list.text();
  9476. },
  9477. selected: function() {
  9478. return this._selectOptions().filter( ":selected:not( :jqmData(placeholder='true') )" );
  9479. },
  9480. refresh: function( force ) {
  9481. var self, indices;
  9482. if ( this.options.nativeMenu ) {
  9483. return this._super( force );
  9484. }
  9485. self = this;
  9486. if ( force || this._isRebuildRequired() ) {
  9487. self._buildList();
  9488. }
  9489. indices = this.selectedIndices();
  9490. self.setButtonText();
  9491. self.setButtonCount();
  9492. self.list.find( "li:not(.ui-li-divider)" )
  9493. .find( "a" ).removeClass( $.mobile.activeBtnClass ).end()
  9494. .attr( "aria-selected", false )
  9495. .each(function( i ) {
  9496. var item = $( this );
  9497. if ( $.inArray( i, indices ) > -1 ) {
  9498. // Aria selected attr
  9499. item.attr( "aria-selected", true );
  9500. // Multiple selects: add the "on" checkbox state to the icon
  9501. if ( self.isMultiple ) {
  9502. item.find( "a" ).removeClass( "ui-checkbox-off" ).addClass( "ui-checkbox-on" );
  9503. } else {
  9504. if ( item.hasClass( "ui-screen-hidden" ) ) {
  9505. item.next().find( "a" ).addClass( $.mobile.activeBtnClass );
  9506. } else {
  9507. item.find( "a" ).addClass( $.mobile.activeBtnClass );
  9508. }
  9509. }
  9510. } else if ( self.isMultiple ) {
  9511. item.find( "a" ).removeClass( "ui-checkbox-on" ).addClass( "ui-checkbox-off" );
  9512. }
  9513. });
  9514. },
  9515. close: function() {
  9516. if ( this.options.disabled || !this.isOpen ) {
  9517. return;
  9518. }
  9519. var self = this;
  9520. if ( self.menuType === "page" ) {
  9521. self.menuPage.dialog( "close" );
  9522. self.list.appendTo( self.listbox );
  9523. } else {
  9524. self.listbox.popup( "close" );
  9525. }
  9526. self._focusButton();
  9527. // allow the dialog to be closed again
  9528. self.isOpen = false;
  9529. },
  9530. open: function() {
  9531. this.button.click();
  9532. },
  9533. _focusMenuItem: function() {
  9534. var selector = this.list.find( "a." + $.mobile.activeBtnClass );
  9535. if ( selector.length === 0 ) {
  9536. selector = this.list.find( "li:not(" + unfocusableItemSelector + ") a.ui-btn" );
  9537. }
  9538. selector.first().focus();
  9539. },
  9540. _decideFormat: function() {
  9541. var self = this,
  9542. $window = this.window,
  9543. selfListParent = self.list.parent(),
  9544. menuHeight = selfListParent.outerHeight(),
  9545. scrollTop = $window.scrollTop(),
  9546. btnOffset = self.button.offset().top,
  9547. screenHeight = $window.height();
  9548. if ( menuHeight > screenHeight - 80 || !$.support.scrollTop ) {
  9549. self.menuPage.appendTo( $.mobile.pageContainer ).page();
  9550. self.menuPageContent = self.menuPage.find( ".ui-content" );
  9551. self.menuPageClose = self.menuPage.find( ".ui-header a" );
  9552. // prevent the parent page from being removed from the DOM,
  9553. // otherwise the results of selecting a list item in the dialog
  9554. // fall into a black hole
  9555. self.thisPage.unbind( "pagehide.remove" );
  9556. //for WebOS/Opera Mini (set lastscroll using button offset)
  9557. if ( scrollTop === 0 && btnOffset > screenHeight ) {
  9558. self.thisPage.one( "pagehide", function() {
  9559. $( this ).jqmData( "lastScroll", btnOffset );
  9560. });
  9561. }
  9562. self.menuPage.one( {
  9563. pageshow: $.proxy( this, "_focusMenuItem" ),
  9564. pagehide: $.proxy( this, "close" )
  9565. });
  9566. self.menuType = "page";
  9567. self.menuPageContent.append( self.list );
  9568. self.menuPage
  9569. .find( "div .ui-title" )
  9570. .text( self.label.getEncodedText() || self.placeholder );
  9571. } else {
  9572. self.menuType = "overlay";
  9573. self.listbox.one( { popupafteropen: $.proxy( this, "_focusMenuItem" ) } );
  9574. }
  9575. },
  9576. _buildList: function() {
  9577. var self = this,
  9578. o = this.options,
  9579. placeholder = this.placeholder,
  9580. needPlaceholder = true,
  9581. dataIcon = "false",
  9582. $options, numOptions, select,
  9583. dataPrefix = "data-" + $.mobile.ns,
  9584. dataIndexAttr = dataPrefix + "option-index",
  9585. dataIconAttr = dataPrefix + "icon",
  9586. dataRoleAttr = dataPrefix + "role",
  9587. dataPlaceholderAttr = dataPrefix + "placeholder",
  9588. fragment = document.createDocumentFragment(),
  9589. isPlaceholderItem = false,
  9590. optGroup,
  9591. i,
  9592. option, $option, parent, text, anchor, classes,
  9593. optLabel, divider, item;
  9594. self.list.empty().filter( ".ui-listview" ).listview( "destroy" );
  9595. $options = this._selectOptions();
  9596. numOptions = $options.length;
  9597. select = this.select[ 0 ];
  9598. for ( i = 0; i < numOptions;i++, isPlaceholderItem = false) {
  9599. option = $options[i];
  9600. $option = $( option );
  9601. // Do not create options based on ui-screen-hidden select options
  9602. if ( $option.hasClass( "ui-screen-hidden" ) ) {
  9603. continue;
  9604. }
  9605. parent = option.parentNode;
  9606. classes = [];
  9607. // Although using .text() here raises the risk that, when we later paste this into the
  9608. // list item we end up pasting possibly malicious things like <script> tags, that risk
  9609. // only arises if we do something like $( "<li><a href='#'>" + text + "</a></li>" ). We
  9610. // don't do that. We do document.createTextNode( text ) instead, which guarantees that
  9611. // whatever we paste in will end up as text, with characters like <, > and & escaped.
  9612. text = $option.text();
  9613. anchor = document.createElement( "a" );
  9614. anchor.setAttribute( "href", "#" );
  9615. anchor.appendChild( document.createTextNode( text ) );
  9616. // Are we inside an optgroup?
  9617. if ( parent !== select && parent.nodeName.toLowerCase() === "optgroup" ) {
  9618. optLabel = parent.getAttribute( "label" );
  9619. if ( optLabel !== optGroup ) {
  9620. divider = document.createElement( "li" );
  9621. divider.setAttribute( dataRoleAttr, "list-divider" );
  9622. divider.setAttribute( "role", "option" );
  9623. divider.setAttribute( "tabindex", "-1" );
  9624. divider.appendChild( document.createTextNode( optLabel ) );
  9625. fragment.appendChild( divider );
  9626. optGroup = optLabel;
  9627. }
  9628. }
  9629. if ( needPlaceholder && ( !option.getAttribute( "value" ) || text.length === 0 || $option.jqmData( "placeholder" ) ) ) {
  9630. needPlaceholder = false;
  9631. isPlaceholderItem = true;
  9632. // If we have identified a placeholder, record the fact that it was
  9633. // us who have added the placeholder to the option and mark it
  9634. // retroactively in the select as well
  9635. if ( null === option.getAttribute( dataPlaceholderAttr ) ) {
  9636. this._removePlaceholderAttr = true;
  9637. }
  9638. option.setAttribute( dataPlaceholderAttr, true );
  9639. if ( o.hidePlaceholderMenuItems ) {
  9640. classes.push( "ui-screen-hidden" );
  9641. }
  9642. if ( placeholder !== text ) {
  9643. placeholder = self.placeholder = text;
  9644. }
  9645. }
  9646. item = document.createElement( "li" );
  9647. if ( option.disabled ) {
  9648. classes.push( "ui-state-disabled" );
  9649. item.setAttribute( "aria-disabled", true );
  9650. }
  9651. item.setAttribute( dataIndexAttr, i );
  9652. item.setAttribute( dataIconAttr, dataIcon );
  9653. if ( isPlaceholderItem ) {
  9654. item.setAttribute( dataPlaceholderAttr, true );
  9655. }
  9656. item.className = classes.join( " " );
  9657. item.setAttribute( "role", "option" );
  9658. anchor.setAttribute( "tabindex", "-1" );
  9659. if ( this.isMultiple ) {
  9660. $( anchor ).addClass( "ui-btn ui-checkbox-off ui-btn-icon-right" );
  9661. }
  9662. item.appendChild( anchor );
  9663. fragment.appendChild( item );
  9664. }
  9665. self.list[0].appendChild( fragment );
  9666. // Hide header if it's not a multiselect and there's no placeholder
  9667. if ( !this.isMultiple && !placeholder.length ) {
  9668. this.header.addClass( "ui-screen-hidden" );
  9669. } else {
  9670. this.headerTitle.text( this.placeholder );
  9671. }
  9672. // Now populated, create listview
  9673. self.list.listview();
  9674. },
  9675. _button: function() {
  9676. return this.options.nativeMenu ?
  9677. this._super() :
  9678. $( "<a>", {
  9679. "href": "#",
  9680. "role": "button",
  9681. // TODO value is undefined at creation
  9682. "id": this.buttonId,
  9683. "aria-haspopup": "true",
  9684. // TODO value is undefined at creation
  9685. "aria-owns": this.menuId
  9686. });
  9687. },
  9688. _destroy: function() {
  9689. if ( !this.options.nativeMenu ) {
  9690. this.close();
  9691. // Restore the tabindex attribute to its original value
  9692. if ( this._origTabIndex !== undefined ) {
  9693. if ( this._origTabIndex !== false ) {
  9694. this.select.attr( "tabindex", this._origTabIndex );
  9695. } else {
  9696. this.select.removeAttr( "tabindex" );
  9697. }
  9698. }
  9699. // Remove the placeholder attribute if we were the ones to add it
  9700. if ( this._removePlaceholderAttr ) {
  9701. this._selectOptions().removeAttr( "data-" + $.mobile.ns + "placeholder" );
  9702. }
  9703. // Remove the popup
  9704. this.listbox.remove();
  9705. // Remove the dialog
  9706. this.menuPage.remove();
  9707. }
  9708. // Chain up
  9709. this._super();
  9710. }
  9711. });
  9712. })( jQuery );
  9713. // buttonMarkup is deprecated as of 1.4.0 and will be removed in 1.5.0.
  9714. (function( $, undefined ) {
  9715. // General policy: Do not access data-* attributes except during enhancement.
  9716. // In all other cases we determine the state of the button exclusively from its
  9717. // className. That's why optionsToClasses expects a full complement of options,
  9718. // and the jQuery plugin completes the set of options from the default values.
  9719. // Map classes to buttonMarkup boolean options - used in classNameToOptions()
  9720. var reverseBoolOptionMap = {
  9721. "ui-shadow" : "shadow",
  9722. "ui-corner-all" : "corners",
  9723. "ui-btn-inline" : "inline",
  9724. "ui-shadow-icon" : "iconshadow", /* TODO: Remove in 1.5 */
  9725. "ui-mini" : "mini"
  9726. },
  9727. getAttrFixed = function() {
  9728. var ret = $.mobile.getAttribute.apply( this, arguments );
  9729. return ( ret == null ? undefined : ret );
  9730. },
  9731. capitalLettersRE = /[A-Z]/g;
  9732. // optionsToClasses:
  9733. // @options: A complete set of options to convert to class names.
  9734. // @existingClasses: extra classes to add to the result
  9735. //
  9736. // Converts @options to buttonMarkup classes and returns the result as an array
  9737. // that can be converted to an element's className with .join( " " ). All
  9738. // possible options must be set inside @options. Use $.fn.buttonMarkup.defaults
  9739. // to get a complete set and use $.extend to override your choice of options
  9740. // from that set.
  9741. function optionsToClasses( options, existingClasses ) {
  9742. var classes = existingClasses ? existingClasses : [];
  9743. // Add classes to the array - first ui-btn
  9744. classes.push( "ui-btn" );
  9745. // If there is a theme
  9746. if ( options.theme ) {
  9747. classes.push( "ui-btn-" + options.theme );
  9748. }
  9749. // If there's an icon, add the icon-related classes
  9750. if ( options.icon ) {
  9751. classes = classes.concat([
  9752. "ui-icon-" + options.icon,
  9753. "ui-btn-icon-" + options.iconpos
  9754. ]);
  9755. if ( options.iconshadow ) {
  9756. classes.push( "ui-shadow-icon" ); /* TODO: Remove in 1.5 */
  9757. }
  9758. }
  9759. // Add the appropriate class for each boolean option
  9760. if ( options.inline ) {
  9761. classes.push( "ui-btn-inline" );
  9762. }
  9763. if ( options.shadow ) {
  9764. classes.push( "ui-shadow" );
  9765. }
  9766. if ( options.corners ) {
  9767. classes.push( "ui-corner-all" );
  9768. }
  9769. if ( options.mini ) {
  9770. classes.push( "ui-mini" );
  9771. }
  9772. // Create a string from the array and return it
  9773. return classes;
  9774. }
  9775. // classNameToOptions:
  9776. // @classes: A string containing a .className-style space-separated class list
  9777. //
  9778. // Loops over @classes and calculates an options object based on the
  9779. // buttonMarkup-related classes it finds. It records unrecognized classes in an
  9780. // array.
  9781. //
  9782. // Returns: An object containing the following items:
  9783. //
  9784. // "options": buttonMarkup options found to be present because of the
  9785. // presence/absence of corresponding classes
  9786. //
  9787. // "unknownClasses": a string containing all the non-buttonMarkup-related
  9788. // classes found in @classes
  9789. //
  9790. // "alreadyEnhanced": A boolean indicating whether the ui-btn class was among
  9791. // those found to be present
  9792. function classNameToOptions( classes ) {
  9793. var idx, map, unknownClass,
  9794. alreadyEnhanced = false,
  9795. noIcon = true,
  9796. o = {
  9797. icon: "",
  9798. inline: false,
  9799. shadow: false,
  9800. corners: false,
  9801. iconshadow: false,
  9802. mini: false
  9803. },
  9804. unknownClasses = [];
  9805. classes = classes.split( " " );
  9806. // Loop over the classes
  9807. for ( idx = 0 ; idx < classes.length ; idx++ ) {
  9808. // Assume it's an unrecognized class
  9809. unknownClass = true;
  9810. // Recognize boolean options from the presence of classes
  9811. map = reverseBoolOptionMap[ classes[ idx ] ];
  9812. if ( map !== undefined ) {
  9813. unknownClass = false;
  9814. o[ map ] = true;
  9815. // Recognize the presence of an icon and establish the icon position
  9816. } else if ( classes[ idx ].indexOf( "ui-btn-icon-" ) === 0 ) {
  9817. unknownClass = false;
  9818. noIcon = false;
  9819. o.iconpos = classes[ idx ].substring( 12 );
  9820. // Establish which icon is present
  9821. } else if ( classes[ idx ].indexOf( "ui-icon-" ) === 0 ) {
  9822. unknownClass = false;
  9823. o.icon = classes[ idx ].substring( 8 );
  9824. // Establish the theme - this recognizes one-letter theme swatch names
  9825. } else if ( classes[ idx ].indexOf( "ui-btn-" ) === 0 && classes[ idx ].length === 8 ) {
  9826. unknownClass = false;
  9827. o.theme = classes[ idx ].substring( 7 );
  9828. // Recognize that this element has already been buttonMarkup-enhanced
  9829. } else if ( classes[ idx ] === "ui-btn" ) {
  9830. unknownClass = false;
  9831. alreadyEnhanced = true;
  9832. }
  9833. // If this class has not been recognized, add it to the list
  9834. if ( unknownClass ) {
  9835. unknownClasses.push( classes[ idx ] );
  9836. }
  9837. }
  9838. // If a "ui-btn-icon-*" icon position class is absent there cannot be an icon
  9839. if ( noIcon ) {
  9840. o.icon = "";
  9841. }
  9842. return {
  9843. options: o,
  9844. unknownClasses: unknownClasses,
  9845. alreadyEnhanced: alreadyEnhanced
  9846. };
  9847. }
  9848. function camelCase2Hyphenated( c ) {
  9849. return "-" + c.toLowerCase();
  9850. }
  9851. // $.fn.buttonMarkup:
  9852. // DOM: gets/sets .className
  9853. //
  9854. // @options: options to apply to the elements in the jQuery object
  9855. // @overwriteClasses: boolean indicating whether to honour existing classes
  9856. //
  9857. // Calculates the classes to apply to the elements in the jQuery object based on
  9858. // the options passed in. If @overwriteClasses is true, it sets the className
  9859. // property of each element in the jQuery object to the buttonMarkup classes
  9860. // it calculates based on the options passed in.
  9861. //
  9862. // If you wish to preserve any classes that are already present on the elements
  9863. // inside the jQuery object, including buttonMarkup-related classes that were
  9864. // added by a previous call to $.fn.buttonMarkup() or during page enhancement
  9865. // then you should omit @overwriteClasses or set it to false.
  9866. $.fn.buttonMarkup = function( options, overwriteClasses ) {
  9867. var idx, data, el, retrievedOptions, optionKey,
  9868. defaults = $.fn.buttonMarkup.defaults;
  9869. for ( idx = 0 ; idx < this.length ; idx++ ) {
  9870. el = this[ idx ];
  9871. data = overwriteClasses ?
  9872. // Assume this element is not enhanced and ignore its classes
  9873. { alreadyEnhanced: false, unknownClasses: [] } :
  9874. // Otherwise analyze existing classes to establish existing options and
  9875. // classes
  9876. classNameToOptions( el.className );
  9877. retrievedOptions = $.extend( {},
  9878. // If the element already has the class ui-btn, then we assume that
  9879. // it has passed through buttonMarkup before - otherwise, the options
  9880. // returned by classNameToOptions do not correctly reflect the state of
  9881. // the element
  9882. ( data.alreadyEnhanced ? data.options : {} ),
  9883. // Finally, apply the options passed in
  9884. options );
  9885. // If this is the first call on this element, retrieve remaining options
  9886. // from the data-attributes
  9887. if ( !data.alreadyEnhanced ) {
  9888. for ( optionKey in defaults ) {
  9889. if ( retrievedOptions[ optionKey ] === undefined ) {
  9890. retrievedOptions[ optionKey ] = getAttrFixed( el,
  9891. optionKey.replace( capitalLettersRE, camelCase2Hyphenated )
  9892. );
  9893. }
  9894. }
  9895. }
  9896. el.className = optionsToClasses(
  9897. // Merge all the options and apply them as classes
  9898. $.extend( {},
  9899. // The defaults form the basis
  9900. defaults,
  9901. // Add the computed options
  9902. retrievedOptions
  9903. ),
  9904. // ... and re-apply any unrecognized classes that were found
  9905. data.unknownClasses ).join( " " );
  9906. if ( el.tagName.toLowerCase() !== "button" ) {
  9907. el.setAttribute( "role", "button" );
  9908. }
  9909. }
  9910. return this;
  9911. };
  9912. // buttonMarkup defaults. This must be a complete set, i.e., a value must be
  9913. // given here for all recognized options
  9914. $.fn.buttonMarkup.defaults = {
  9915. icon: "",
  9916. iconpos: "left",
  9917. theme: null,
  9918. inline: false,
  9919. shadow: true,
  9920. corners: true,
  9921. iconshadow: false, /* TODO: Remove in 1.5. Option deprecated in 1.4. */
  9922. mini: false
  9923. };
  9924. $.extend( $.fn.buttonMarkup, {
  9925. initSelector: "a:jqmData(role='button'), .ui-bar > a, .ui-bar > :jqmData(role='controlgroup') > a, button:not(:jqmData(role='navbar') button)"
  9926. });
  9927. })( jQuery );
  9928. (function( $, undefined ) {
  9929. $.widget( "mobile.controlgroup", $.extend( {
  9930. options: {
  9931. enhanced: false,
  9932. theme: null,
  9933. shadow: false,
  9934. corners: true,
  9935. excludeInvisible: true,
  9936. type: "vertical",
  9937. mini: false
  9938. },
  9939. _create: function() {
  9940. var elem = this.element,
  9941. opts = this.options,
  9942. keepNative = $.mobile.page.prototype.keepNativeSelector();
  9943. // Run buttonmarkup
  9944. if ( $.fn.buttonMarkup ) {
  9945. this.element
  9946. .find( $.fn.buttonMarkup.initSelector )
  9947. .not( keepNative )
  9948. .buttonMarkup();
  9949. }
  9950. // Enhance child widgets
  9951. $.each( this._childWidgets, $.proxy( function( number, widgetName ) {
  9952. if ( $.mobile[ widgetName ] ) {
  9953. this.element
  9954. .find( $.mobile[ widgetName ].initSelector )
  9955. .not( keepNative )[ widgetName ]();
  9956. }
  9957. }, this ));
  9958. $.extend( this, {
  9959. _ui: null,
  9960. _initialRefresh: true
  9961. });
  9962. if ( opts.enhanced ) {
  9963. this._ui = {
  9964. groupLegend: elem.children( ".ui-controlgroup-label" ).children(),
  9965. childWrapper: elem.children( ".ui-controlgroup-controls" )
  9966. };
  9967. } else {
  9968. this._ui = this._enhance();
  9969. }
  9970. },
  9971. _childWidgets: [ "checkboxradio", "selectmenu", "button" ],
  9972. _themeClassFromOption: function( value ) {
  9973. return ( value ? ( value === "none" ? "" : "ui-group-theme-" + value ) : "" );
  9974. },
  9975. _enhance: function() {
  9976. var elem = this.element,
  9977. opts = this.options,
  9978. ui = {
  9979. groupLegend: elem.children( "legend" ),
  9980. childWrapper: elem
  9981. .addClass( "ui-controlgroup " +
  9982. "ui-controlgroup-" +
  9983. ( opts.type === "horizontal" ? "horizontal" : "vertical" ) + " " +
  9984. this._themeClassFromOption( opts.theme ) + " " +
  9985. ( opts.corners ? "ui-corner-all " : "" ) +
  9986. ( opts.mini ? "ui-mini " : "" ) )
  9987. .wrapInner( "<div " +
  9988. "class='ui-controlgroup-controls " +
  9989. ( opts.shadow === true ? "ui-shadow" : "" ) + "'></div>" )
  9990. .children()
  9991. };
  9992. if ( ui.groupLegend.length > 0 ) {
  9993. $( "<div role='heading' class='ui-controlgroup-label'></div>" )
  9994. .append( ui.groupLegend )
  9995. .prependTo( elem );
  9996. }
  9997. return ui;
  9998. },
  9999. _init: function() {
  10000. this.refresh();
  10001. },
  10002. _setOptions: function( options ) {
  10003. var callRefresh, returnValue,
  10004. elem = this.element;
  10005. // Must have one of horizontal or vertical
  10006. if ( options.type !== undefined ) {
  10007. elem
  10008. .removeClass( "ui-controlgroup-horizontal ui-controlgroup-vertical" )
  10009. .addClass( "ui-controlgroup-" + ( options.type === "horizontal" ? "horizontal" : "vertical" ) );
  10010. callRefresh = true;
  10011. }
  10012. if ( options.theme !== undefined ) {
  10013. elem
  10014. .removeClass( this._themeClassFromOption( this.options.theme ) )
  10015. .addClass( this._themeClassFromOption( options.theme ) );
  10016. }
  10017. if ( options.corners !== undefined ) {
  10018. elem.toggleClass( "ui-corner-all", options.corners );
  10019. }
  10020. if ( options.mini !== undefined ) {
  10021. elem.toggleClass( "ui-mini", options.mini );
  10022. }
  10023. if ( options.shadow !== undefined ) {
  10024. this._ui.childWrapper.toggleClass( "ui-shadow", options.shadow );
  10025. }
  10026. if ( options.excludeInvisible !== undefined ) {
  10027. this.options.excludeInvisible = options.excludeInvisible;
  10028. callRefresh = true;
  10029. }
  10030. returnValue = this._super( options );
  10031. if ( callRefresh ) {
  10032. this.refresh();
  10033. }
  10034. return returnValue;
  10035. },
  10036. container: function() {
  10037. return this._ui.childWrapper;
  10038. },
  10039. refresh: function() {
  10040. var $el = this.container(),
  10041. els = $el.find( ".ui-btn" ).not( ".ui-slider-handle" ),
  10042. create = this._initialRefresh;
  10043. if ( $.mobile.checkboxradio ) {
  10044. $el.find( ":mobile-checkboxradio" ).checkboxradio( "refresh" );
  10045. }
  10046. this._addFirstLastClasses( els,
  10047. this.options.excludeInvisible ? this._getVisibles( els, create ) : els,
  10048. create );
  10049. this._initialRefresh = false;
  10050. },
  10051. // Caveat: If the legend is not the first child of the controlgroup at enhance
  10052. // time, it will be after _destroy().
  10053. _destroy: function() {
  10054. var ui, buttons,
  10055. opts = this.options;
  10056. if ( opts.enhanced ) {
  10057. return this;
  10058. }
  10059. ui = this._ui;
  10060. buttons = this.element
  10061. .removeClass( "ui-controlgroup " +
  10062. "ui-controlgroup-horizontal ui-controlgroup-vertical ui-corner-all ui-mini " +
  10063. this._themeClassFromOption( opts.theme ) )
  10064. .find( ".ui-btn" )
  10065. .not( ".ui-slider-handle" );
  10066. this._removeFirstLastClasses( buttons );
  10067. ui.groupLegend.unwrap();
  10068. ui.childWrapper.children().unwrap();
  10069. }
  10070. }, $.mobile.behaviors.addFirstLastClasses ) );
  10071. })(jQuery);
  10072. (function( $, undefined ) {
  10073. $.widget( "mobile.toolbar", {
  10074. initSelector: ":jqmData(role='footer'), :jqmData(role='header')",
  10075. options: {
  10076. theme: null,
  10077. addBackBtn: false,
  10078. backBtnTheme: null,
  10079. backBtnText: "Back"
  10080. },
  10081. _create: function() {
  10082. var leftbtn, rightbtn,
  10083. role = this.element.is( ":jqmData(role='header')" ) ? "header" : "footer",
  10084. page = this.element.closest( ".ui-page" );
  10085. if ( page.length === 0 ) {
  10086. page = false;
  10087. this._on( this.document, {
  10088. "pageshow": "refresh"
  10089. });
  10090. }
  10091. $.extend( this, {
  10092. role: role,
  10093. page: page,
  10094. leftbtn: leftbtn,
  10095. rightbtn: rightbtn
  10096. });
  10097. this.element.attr( "role", role === "header" ? "banner" : "contentinfo" ).addClass( "ui-" + role );
  10098. this.refresh();
  10099. this._setOptions( this.options );
  10100. },
  10101. _setOptions: function( o ) {
  10102. if ( o.addBackBtn !== undefined ) {
  10103. this._updateBackButton();
  10104. }
  10105. if ( o.backBtnTheme != null ) {
  10106. this.element
  10107. .find( ".ui-toolbar-back-btn" )
  10108. .addClass( "ui-btn ui-btn-" + o.backBtnTheme );
  10109. }
  10110. if ( o.backBtnText !== undefined ) {
  10111. this.element.find( ".ui-toolbar-back-btn .ui-btn-text" ).text( o.backBtnText );
  10112. }
  10113. if ( o.theme !== undefined ) {
  10114. var currentTheme = this.options.theme ? this.options.theme : "inherit",
  10115. newTheme = o.theme ? o.theme : "inherit";
  10116. this.element.removeClass( "ui-bar-" + currentTheme ).addClass( "ui-bar-" + newTheme );
  10117. }
  10118. this._super( o );
  10119. },
  10120. refresh: function() {
  10121. if ( this.role === "header" ) {
  10122. this._addHeaderButtonClasses();
  10123. }
  10124. if ( !this.page ) {
  10125. this._setRelative();
  10126. if ( this.role === "footer" ) {
  10127. this.element.appendTo( "body" );
  10128. } else if ( this.role === "header" ) {
  10129. this._updateBackButton();
  10130. }
  10131. }
  10132. this._addHeadingClasses();
  10133. this._btnMarkup();
  10134. },
  10135. //we only want this to run on non fixed toolbars so make it easy to override
  10136. _setRelative: function() {
  10137. $( "[data-"+ $.mobile.ns + "role='page']" ).css({ "position": "relative" });
  10138. },
  10139. // Deprecated in 1.4. As from 1.5 button classes have to be present in the markup.
  10140. _btnMarkup: function() {
  10141. this.element
  10142. .children( "a" )
  10143. .filter( ":not([data-" + $.mobile.ns + "role='none'])" )
  10144. .attr( "data-" + $.mobile.ns + "role", "button" );
  10145. this.element.trigger( "create" );
  10146. },
  10147. // Deprecated in 1.4. As from 1.5 ui-btn-left/right classes have to be present in the markup.
  10148. _addHeaderButtonClasses: function() {
  10149. var headerAnchors = this.element.children( "a, button" );
  10150. // Do not mistake a back button for a left toolbar button
  10151. this.leftbtn = headerAnchors.hasClass( "ui-btn-left" ) &&
  10152. !headerAnchors.hasClass( "ui-toolbar-back-btn" );
  10153. this.rightbtn = headerAnchors.hasClass( "ui-btn-right" );
  10154. // Filter out right buttons and back buttons
  10155. this.leftbtn = this.leftbtn ||
  10156. headerAnchors.eq( 0 )
  10157. .not( ".ui-btn-right,.ui-toolbar-back-btn" )
  10158. .addClass( "ui-btn-left" )
  10159. .length;
  10160. this.rightbtn = this.rightbtn || headerAnchors.eq( 1 ).addClass( "ui-btn-right" ).length;
  10161. },
  10162. _updateBackButton: function() {
  10163. var backButton,
  10164. options = this.options,
  10165. theme = options.backBtnTheme || options.theme;
  10166. // Retrieve the back button or create a new, empty one
  10167. backButton = this._backButton = ( this._backButton || {} );
  10168. // We add a back button only if the option to do so is on
  10169. if ( this.options.addBackBtn &&
  10170. // This must also be a header toolbar
  10171. this.role === "header" &&
  10172. // There must be multiple pages in the DOM
  10173. $( ".ui-page" ).length > 1 &&
  10174. ( this.page ?
  10175. // If the toolbar is internal the page's URL must differ from the hash
  10176. ( this.page[ 0 ].getAttribute( "data-" + $.mobile.ns + "url" ) !==
  10177. $.mobile.path.stripHash( location.hash ) ) :
  10178. // Otherwise, if the toolbar is external there must be at least one
  10179. // history item to which one can go back
  10180. ( $.mobile.navigate && $.mobile.navigate.history &&
  10181. $.mobile.navigate.history.activeIndex > 0 ) ) &&
  10182. // The toolbar does not have a left button
  10183. !this.leftbtn ) {
  10184. // Skip back button creation if one is already present
  10185. if ( !backButton.attached ) {
  10186. this.backButton = backButton.element = ( backButton.element ||
  10187. $( "<a role='button' href='javascript:void(0);' " +
  10188. "class='ui-btn ui-corner-all ui-shadow ui-btn-left " +
  10189. ( theme ? "ui-btn-" + theme + " " : "" ) +
  10190. "ui-toolbar-back-btn ui-icon-carat-l ui-btn-icon-left' " +
  10191. "data-" + $.mobile.ns + "rel='back'>" + options.backBtnText +
  10192. "</a>" ) )
  10193. .prependTo( this.element );
  10194. backButton.attached = true;
  10195. }
  10196. // If we are not adding a back button, then remove the one present, if any
  10197. } else if ( backButton.element ) {
  10198. backButton.element.detach();
  10199. backButton.attached = false;
  10200. }
  10201. },
  10202. _addHeadingClasses: function() {
  10203. this.element.children( "h1, h2, h3, h4, h5, h6" )
  10204. .addClass( "ui-title" )
  10205. // Regardless of h element number in src, it becomes h1 for the enhanced page
  10206. .attr({
  10207. "role": "heading",
  10208. "aria-level": "1"
  10209. });
  10210. },
  10211. _destroy: function() {
  10212. var currentTheme;
  10213. this.element.children( "h1, h2, h3, h4, h5, h6" )
  10214. .removeClass( "ui-title" )
  10215. .removeAttr( "role" )
  10216. .removeAttr( "aria-level" );
  10217. if ( this.role === "header" ) {
  10218. this.element.children( "a, button" )
  10219. .removeClass( "ui-btn-left ui-btn-right ui-btn ui-shadow ui-corner-all" );
  10220. if ( this.backButton) {
  10221. this.backButton.remove();
  10222. }
  10223. }
  10224. currentTheme = this.options.theme ? this.options.theme : "inherit";
  10225. this.element.removeClass( "ui-bar-" + currentTheme );
  10226. this.element.removeClass( "ui-" + this.role ).removeAttr( "role" );
  10227. }
  10228. });
  10229. })( jQuery );
  10230. (function( $, undefined ) {
  10231. $.widget( "mobile.toolbar", $.mobile.toolbar, {
  10232. options: {
  10233. position:null,
  10234. visibleOnPageShow: true,
  10235. disablePageZoom: true,
  10236. transition: "slide", //can be none, fade, slide (slide maps to slideup or slidedown)
  10237. fullscreen: false,
  10238. tapToggle: true,
  10239. tapToggleBlacklist: "a, button, input, select, textarea, .ui-header-fixed, .ui-footer-fixed, .ui-flipswitch, .ui-popup, .ui-panel, .ui-panel-dismiss-open",
  10240. hideDuringFocus: "input, textarea, select",
  10241. updatePagePadding: true,
  10242. trackPersistentToolbars: true,
  10243. // Browser detection! Weeee, here we go...
  10244. // Unfortunately, position:fixed is costly, not to mention probably impossible, to feature-detect accurately.
  10245. // Some tests exist, but they currently return false results in critical devices and browsers, which could lead to a broken experience.
  10246. // Testing fixed positioning is also pretty obtrusive to page load, requiring injected elements and scrolling the window
  10247. // The following function serves to rule out some popular browsers with known fixed-positioning issues
  10248. // This is a plugin option like any other, so feel free to improve or overwrite it
  10249. supportBlacklist: function() {
  10250. return !$.support.fixedPosition;
  10251. }
  10252. },
  10253. _create: function() {
  10254. this._super();
  10255. this.pagecontainer = $( ":mobile-pagecontainer" );
  10256. if ( this.options.position === "fixed" && !this.options.supportBlacklist() ) {
  10257. this._makeFixed();
  10258. }
  10259. },
  10260. _makeFixed: function() {
  10261. this.element.addClass( "ui-"+ this.role +"-fixed" );
  10262. this.updatePagePadding();
  10263. this._addTransitionClass();
  10264. this._bindPageEvents();
  10265. this._bindToggleHandlers();
  10266. },
  10267. _setOptions: function( o ) {
  10268. if ( o.position === "fixed" && this.options.position !== "fixed" ) {
  10269. this._makeFixed();
  10270. }
  10271. if ( this.options.position === "fixed" && !this.options.supportBlacklist() ) {
  10272. var $page = ( !!this.page )? this.page: ( $(".ui-page-active").length > 0 )? $(".ui-page-active"): $(".ui-page").eq(0);
  10273. if ( o.fullscreen !== undefined) {
  10274. if ( o.fullscreen ) {
  10275. this.element.addClass( "ui-"+ this.role +"-fullscreen" );
  10276. $page.addClass( "ui-page-" + this.role + "-fullscreen" );
  10277. }
  10278. // If not fullscreen, add class to page to set top or bottom padding
  10279. else {
  10280. this.element.removeClass( "ui-"+ this.role +"-fullscreen" );
  10281. $page.removeClass( "ui-page-" + this.role + "-fullscreen" ).addClass( "ui-page-" + this.role+ "-fixed" );
  10282. }
  10283. }
  10284. }
  10285. this._super(o);
  10286. },
  10287. _addTransitionClass: function() {
  10288. var tclass = this.options.transition;
  10289. if ( tclass && tclass !== "none" ) {
  10290. // use appropriate slide for header or footer
  10291. if ( tclass === "slide" ) {
  10292. tclass = this.element.hasClass( "ui-header" ) ? "slidedown" : "slideup";
  10293. }
  10294. this.element.addClass( tclass );
  10295. }
  10296. },
  10297. _bindPageEvents: function() {
  10298. var page = ( !!this.page )? this.element.closest( ".ui-page" ): this.document;
  10299. //page event bindings
  10300. // Fixed toolbars require page zoom to be disabled, otherwise usability issues crop up
  10301. // This method is meant to disable zoom while a fixed-positioned toolbar page is visible
  10302. this._on( page , {
  10303. "pagebeforeshow": "_handlePageBeforeShow",
  10304. "webkitAnimationStart":"_handleAnimationStart",
  10305. "animationstart":"_handleAnimationStart",
  10306. "updatelayout": "_handleAnimationStart",
  10307. "pageshow": "_handlePageShow",
  10308. "pagebeforehide": "_handlePageBeforeHide"
  10309. });
  10310. },
  10311. _handlePageBeforeShow: function( ) {
  10312. var o = this.options;
  10313. if ( o.disablePageZoom ) {
  10314. $.mobile.zoom.disable( true );
  10315. }
  10316. if ( !o.visibleOnPageShow ) {
  10317. this.hide( true );
  10318. }
  10319. },
  10320. _handleAnimationStart: function() {
  10321. if ( this.options.updatePagePadding ) {
  10322. this.updatePagePadding( ( !!this.page )? this.page: ".ui-page-active" );
  10323. }
  10324. },
  10325. _handlePageShow: function() {
  10326. this.updatePagePadding( ( !!this.page )? this.page: ".ui-page-active" );
  10327. if ( this.options.updatePagePadding ) {
  10328. this._on( this.window, { "throttledresize": "updatePagePadding" } );
  10329. }
  10330. },
  10331. _handlePageBeforeHide: function( e, ui ) {
  10332. var o = this.options,
  10333. thisFooter, thisHeader, nextFooter, nextHeader;
  10334. if ( o.disablePageZoom ) {
  10335. $.mobile.zoom.enable( true );
  10336. }
  10337. if ( o.updatePagePadding ) {
  10338. this._off( this.window, "throttledresize" );
  10339. }
  10340. if ( o.trackPersistentToolbars ) {
  10341. thisFooter = $( ".ui-footer-fixed:jqmData(id)", this.page );
  10342. thisHeader = $( ".ui-header-fixed:jqmData(id)", this.page );
  10343. nextFooter = thisFooter.length && ui.nextPage && $( ".ui-footer-fixed:jqmData(id='" + thisFooter.jqmData( "id" ) + "')", ui.nextPage ) || $();
  10344. nextHeader = thisHeader.length && ui.nextPage && $( ".ui-header-fixed:jqmData(id='" + thisHeader.jqmData( "id" ) + "')", ui.nextPage ) || $();
  10345. if ( nextFooter.length || nextHeader.length ) {
  10346. nextFooter.add( nextHeader ).appendTo( $.mobile.pageContainer );
  10347. ui.nextPage.one( "pageshow", function() {
  10348. nextHeader.prependTo( this );
  10349. nextFooter.appendTo( this );
  10350. });
  10351. }
  10352. }
  10353. },
  10354. _visible: true,
  10355. // This will set the content element's top or bottom padding equal to the toolbar's height
  10356. updatePagePadding: function( tbPage ) {
  10357. var $el = this.element,
  10358. header = ( this.role ==="header" ),
  10359. pos = parseFloat( $el.css( header ? "top" : "bottom" ) );
  10360. // This behavior only applies to "fixed", not "fullscreen"
  10361. if ( this.options.fullscreen ) { return; }
  10362. // tbPage argument can be a Page object or an event, if coming from throttled resize.
  10363. tbPage = ( tbPage && tbPage.type === undefined && tbPage ) || this.page || $el.closest( ".ui-page" );
  10364. tbPage = ( !!this.page )? this.page: ".ui-page-active";
  10365. $( tbPage ).css( "padding-" + ( header ? "top" : "bottom" ), $el.outerHeight() + pos );
  10366. },
  10367. _useTransition: function( notransition ) {
  10368. var $win = this.window,
  10369. $el = this.element,
  10370. scroll = $win.scrollTop(),
  10371. elHeight = $el.height(),
  10372. pHeight = ( !!this.page )? $el.closest( ".ui-page" ).height():$(".ui-page-active").height(),
  10373. viewportHeight = $.mobile.getScreenHeight();
  10374. return !notransition &&
  10375. ( this.options.transition && this.options.transition !== "none" &&
  10376. (
  10377. ( this.role === "header" && !this.options.fullscreen && scroll > elHeight ) ||
  10378. ( this.role === "footer" && !this.options.fullscreen && scroll + viewportHeight < pHeight - elHeight )
  10379. ) || this.options.fullscreen
  10380. );
  10381. },
  10382. show: function( notransition ) {
  10383. var hideClass = "ui-fixed-hidden",
  10384. $el = this.element;
  10385. if ( this._useTransition( notransition ) ) {
  10386. $el
  10387. .removeClass( "out " + hideClass )
  10388. .addClass( "in" )
  10389. .animationComplete(function () {
  10390. $el.removeClass( "in" );
  10391. });
  10392. }
  10393. else {
  10394. $el.removeClass( hideClass );
  10395. }
  10396. this._visible = true;
  10397. },
  10398. hide: function( notransition ) {
  10399. var hideClass = "ui-fixed-hidden",
  10400. $el = this.element,
  10401. // if it's a slide transition, our new transitions need the reverse class as well to slide outward
  10402. outclass = "out" + ( this.options.transition === "slide" ? " reverse" : "" );
  10403. if ( this._useTransition( notransition ) ) {
  10404. $el
  10405. .addClass( outclass )
  10406. .removeClass( "in" )
  10407. .animationComplete(function() {
  10408. $el.addClass( hideClass ).removeClass( outclass );
  10409. });
  10410. }
  10411. else {
  10412. $el.addClass( hideClass ).removeClass( outclass );
  10413. }
  10414. this._visible = false;
  10415. },
  10416. toggle: function() {
  10417. this[ this._visible ? "hide" : "show" ]();
  10418. },
  10419. _bindToggleHandlers: function() {
  10420. var self = this,
  10421. o = self.options,
  10422. delayShow, delayHide,
  10423. isVisible = true,
  10424. page = ( !!this.page )? this.page: $(".ui-page");
  10425. // tap toggle
  10426. page
  10427. .bind( "vclick", function( e ) {
  10428. if ( o.tapToggle && !$( e.target ).closest( o.tapToggleBlacklist ).length ) {
  10429. self.toggle();
  10430. }
  10431. })
  10432. .bind( "focusin focusout", function( e ) {
  10433. //this hides the toolbars on a keyboard pop to give more screen room and prevent ios bug which
  10434. //positions fixed toolbars in the middle of the screen on pop if the input is near the top or
  10435. //bottom of the screen addresses issues #4410 Footer navbar moves up when clicking on a textbox in an Android environment
  10436. //and issue #4113 Header and footer change their position after keyboard popup - iOS
  10437. //and issue #4410 Footer navbar moves up when clicking on a textbox in an Android environment
  10438. if ( screen.width < 1025 && $( e.target ).is( o.hideDuringFocus ) && !$( e.target ).closest( ".ui-header-fixed, .ui-footer-fixed" ).length ) {
  10439. //Fix for issue #4724 Moving through form in Mobile Safari with "Next" and "Previous" system
  10440. //controls causes fixed position, tap-toggle false Header to reveal itself
  10441. // isVisible instead of self._visible because the focusin and focusout events fire twice at the same time
  10442. // Also use a delay for hiding the toolbars because on Android native browser focusin is direclty followed
  10443. // by a focusout when a native selects opens and the other way around when it closes.
  10444. if ( e.type === "focusout" && !isVisible ) {
  10445. isVisible = true;
  10446. //wait for the stack to unwind and see if we have jumped to another input
  10447. clearTimeout( delayHide );
  10448. delayShow = setTimeout( function() {
  10449. self.show();
  10450. }, 0 );
  10451. } else if ( e.type === "focusin" && !!isVisible ) {
  10452. //if we have jumped to another input clear the time out to cancel the show.
  10453. clearTimeout( delayShow );
  10454. isVisible = false;
  10455. delayHide = setTimeout( function() {
  10456. self.hide();
  10457. }, 0 );
  10458. }
  10459. }
  10460. });
  10461. },
  10462. _setRelative: function() {
  10463. if( this.options.position !== "fixed" ){
  10464. $( "[data-"+ $.mobile.ns + "role='page']" ).css({ "position": "relative" });
  10465. }
  10466. },
  10467. _destroy: function() {
  10468. var pageClasses, toolbarClasses, hasFixed, header, hasFullscreen,
  10469. page = this.pagecontainer.pagecontainer( "getActivePage" );
  10470. this._super();
  10471. if ( this.options.position === "fixed" ) {
  10472. hasFixed = $( "body>.ui-" + this.role + "-fixed" )
  10473. .add( page.find( ".ui-" + this.options.role + "-fixed" ) )
  10474. .not( this.element ).length > 0;
  10475. hasFullscreen = $( "body>.ui-" + this.role + "-fixed" )
  10476. .add( page.find( ".ui-" + this.options.role + "-fullscreen" ) )
  10477. .not( this.element ).length > 0;
  10478. toolbarClasses = "ui-header-fixed ui-footer-fixed ui-header-fullscreen in out" +
  10479. " ui-footer-fullscreen fade slidedown slideup ui-fixed-hidden";
  10480. this.element.removeClass( toolbarClasses );
  10481. if ( !hasFullscreen ) {
  10482. pageClasses = "ui-page-" + this.role + "-fullscreen";
  10483. }
  10484. if ( !hasFixed ) {
  10485. header = this.role === "header";
  10486. pageClasses += " ui-page-" + this.role + "-fixed";
  10487. page.css( "padding-" + ( header ? "top" : "bottom" ), "" );
  10488. }
  10489. page.removeClass( pageClasses );
  10490. }
  10491. }
  10492. });
  10493. })( jQuery );
  10494. (function( $, undefined ) {
  10495. $.widget( "mobile.toolbar", $.mobile.toolbar, {
  10496. _makeFixed: function() {
  10497. this._super();
  10498. this._workarounds();
  10499. },
  10500. //check the browser and version and run needed workarounds
  10501. _workarounds: function() {
  10502. var ua = navigator.userAgent,
  10503. platform = navigator.platform,
  10504. // Rendering engine is Webkit, and capture major version
  10505. wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ),
  10506. wkversion = !!wkmatch && wkmatch[ 1 ],
  10507. os = null,
  10508. self = this;
  10509. //set the os we are working in if it dosent match one with workarounds return
  10510. if ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1 || platform.indexOf( "iPod" ) > -1 ) {
  10511. os = "ios";
  10512. } else if ( ua.indexOf( "Android" ) > -1 ) {
  10513. os = "android";
  10514. } else {
  10515. return;
  10516. }
  10517. //check os version if it dosent match one with workarounds return
  10518. if ( os === "ios" ) {
  10519. //iOS workarounds
  10520. self._bindScrollWorkaround();
  10521. } else if ( os === "android" && wkversion && wkversion < 534 ) {
  10522. //Android 2.3 run all Android 2.3 workaround
  10523. self._bindScrollWorkaround();
  10524. self._bindListThumbWorkaround();
  10525. } else {
  10526. return;
  10527. }
  10528. },
  10529. //Utility class for checking header and footer positions relative to viewport
  10530. _viewportOffset: function() {
  10531. var $el = this.element,
  10532. header = $el.hasClass( "ui-header" ),
  10533. offset = Math.abs( $el.offset().top - this.window.scrollTop() );
  10534. if ( !header ) {
  10535. offset = Math.round( offset - this.window.height() + $el.outerHeight() ) - 60;
  10536. }
  10537. return offset;
  10538. },
  10539. //bind events for _triggerRedraw() function
  10540. _bindScrollWorkaround: function() {
  10541. var self = this;
  10542. //bind to scrollstop and check if the toolbars are correctly positioned
  10543. this._on( this.window, { scrollstop: function() {
  10544. var viewportOffset = self._viewportOffset();
  10545. //check if the header is visible and if its in the right place
  10546. if ( viewportOffset > 2 && self._visible ) {
  10547. self._triggerRedraw();
  10548. }
  10549. }});
  10550. },
  10551. //this addresses issue #4250 Persistent footer instability in v1.1 with long select lists in Android 2.3.3
  10552. //and issue #3748 Android 2.x: Page transitions broken when fixed toolbars used
  10553. //the absolutely positioned thumbnail in a list view causes problems with fixed position buttons above in a nav bar
  10554. //setting the li's to -webkit-transform:translate3d(0,0,0); solves this problem to avoide potential issues in other
  10555. //platforms we scope this with the class ui-android-2x-fix
  10556. _bindListThumbWorkaround: function() {
  10557. this.element.closest( ".ui-page" ).addClass( "ui-android-2x-fixed" );
  10558. },
  10559. //this addresses issues #4337 Fixed header problem after scrolling content on iOS and Android
  10560. //and device bugs project issue #1 Form elements can lose click hit area in position: fixed containers.
  10561. //this also addresses not on fixed toolbars page in docs
  10562. //adding 1px of padding to the bottom then removing it causes a "redraw"
  10563. //which positions the toolbars correctly (they will always be visually correct)
  10564. _triggerRedraw: function() {
  10565. var paddingBottom = parseFloat( $( ".ui-page-active" ).css( "padding-bottom" ) );
  10566. //trigger page redraw to fix incorrectly positioned fixed elements
  10567. $( ".ui-page-active" ).css( "padding-bottom", ( paddingBottom + 1 ) + "px" );
  10568. //if the padding is reset with out a timeout the reposition will not occure.
  10569. //this is independant of JQM the browser seems to need the time to react.
  10570. setTimeout( function() {
  10571. $( ".ui-page-active" ).css( "padding-bottom", paddingBottom + "px" );
  10572. }, 0 );
  10573. },
  10574. destroy: function() {
  10575. this._super();
  10576. //Remove the class we added to the page previously in android 2.x
  10577. this.element.closest( ".ui-page-active" ).removeClass( "ui-android-2x-fix" );
  10578. }
  10579. });
  10580. })( jQuery );
  10581. ( function( $, undefined ) {
  10582. var ieHack = ( $.mobile.browser.oldIE && $.mobile.browser.oldIE <= 8 ),
  10583. uiTemplate = $(
  10584. "<div class='ui-popup-arrow-guide'></div>" +
  10585. "<div class='ui-popup-arrow-container" + ( ieHack ? " ie" : "" ) + "'>" +
  10586. "<div class='ui-popup-arrow'></div>" +
  10587. "</div>"
  10588. );
  10589. function getArrow() {
  10590. var clone = uiTemplate.clone(),
  10591. gd = clone.eq( 0 ),
  10592. ct = clone.eq( 1 ),
  10593. ar = ct.children();
  10594. return { arEls: ct.add( gd ), gd: gd, ct: ct, ar: ar };
  10595. }
  10596. $.widget( "mobile.popup", $.mobile.popup, {
  10597. options: {
  10598. arrow: ""
  10599. },
  10600. _create: function() {
  10601. var ar,
  10602. ret = this._super();
  10603. if ( this.options.arrow ) {
  10604. this._ui.arrow = ar = this._addArrow();
  10605. }
  10606. return ret;
  10607. },
  10608. _addArrow: function() {
  10609. var theme,
  10610. opts = this.options,
  10611. ar = getArrow();
  10612. theme = this._themeClassFromOption( "ui-body-", opts.theme );
  10613. ar.ar.addClass( theme + ( opts.shadow ? " ui-overlay-shadow" : "" ) );
  10614. ar.arEls.hide().appendTo( this.element );
  10615. return ar;
  10616. },
  10617. _unenhance: function() {
  10618. var ar = this._ui.arrow;
  10619. if ( ar ) {
  10620. ar.arEls.remove();
  10621. }
  10622. return this._super();
  10623. },
  10624. // Pretend to show an arrow described by @p and @dir and calculate the
  10625. // distance from the desired point. If a best-distance is passed in, return
  10626. // the minimum of the one passed in and the one calculated.
  10627. _tryAnArrow: function( p, dir, desired, s, best ) {
  10628. var result, r, diff, desiredForArrow = {}, tip = {};
  10629. // If the arrow has no wiggle room along the edge of the popup, it cannot
  10630. // be displayed along the requested edge without it sticking out.
  10631. if ( s.arFull[ p.dimKey ] > s.guideDims[ p.dimKey ] ) {
  10632. return best;
  10633. }
  10634. desiredForArrow[ p.fst ] = desired[ p.fst ] +
  10635. ( s.arHalf[ p.oDimKey ] + s.menuHalf[ p.oDimKey ] ) * p.offsetFactor -
  10636. s.contentBox[ p.fst ] + ( s.clampInfo.menuSize[ p.oDimKey ] - s.contentBox[ p.oDimKey ] ) * p.arrowOffsetFactor;
  10637. desiredForArrow[ p.snd ] = desired[ p.snd ];
  10638. result = s.result || this._calculateFinalLocation( desiredForArrow, s.clampInfo );
  10639. r = { x: result.left, y: result.top };
  10640. tip[ p.fst ] = r[ p.fst ] + s.contentBox[ p.fst ] + p.tipOffset;
  10641. tip[ p.snd ] = Math.max( result[ p.prop ] + s.guideOffset[ p.prop ] + s.arHalf[ p.dimKey ],
  10642. Math.min( result[ p.prop ] + s.guideOffset[ p.prop ] + s.guideDims[ p.dimKey ] - s.arHalf[ p.dimKey ],
  10643. desired[ p.snd ] ) );
  10644. diff = Math.abs( desired.x - tip.x ) + Math.abs( desired.y - tip.y );
  10645. if ( !best || diff < best.diff ) {
  10646. // Convert tip offset to coordinates inside the popup
  10647. tip[ p.snd ] -= s.arHalf[ p.dimKey ] + result[ p.prop ] + s.contentBox[ p.snd ];
  10648. best = { dir: dir, diff: diff, result: result, posProp: p.prop, posVal: tip[ p.snd ] };
  10649. }
  10650. return best;
  10651. },
  10652. _getPlacementState: function( clamp ) {
  10653. var offset, gdOffset,
  10654. ar = this._ui.arrow,
  10655. state = {
  10656. clampInfo: this._clampPopupWidth( !clamp ),
  10657. arFull: { cx: ar.ct.width(), cy: ar.ct.height() },
  10658. guideDims: { cx: ar.gd.width(), cy: ar.gd.height() },
  10659. guideOffset: ar.gd.offset()
  10660. };
  10661. offset = this.element.offset();
  10662. ar.gd.css( { left: 0, top: 0, right: 0, bottom: 0 } );
  10663. gdOffset = ar.gd.offset();
  10664. state.contentBox = {
  10665. x: gdOffset.left - offset.left,
  10666. y: gdOffset.top - offset.top,
  10667. cx: ar.gd.width(),
  10668. cy: ar.gd.height()
  10669. };
  10670. ar.gd.removeAttr( "style" );
  10671. // The arrow box moves between guideOffset and guideOffset + guideDims - arFull
  10672. state.guideOffset = { left: state.guideOffset.left - offset.left, top: state.guideOffset.top - offset.top };
  10673. state.arHalf = { cx: state.arFull.cx / 2, cy: state.arFull.cy / 2 };
  10674. state.menuHalf = { cx: state.clampInfo.menuSize.cx / 2, cy: state.clampInfo.menuSize.cy / 2 };
  10675. return state;
  10676. },
  10677. _placementCoords: function( desired ) {
  10678. var state, best, params, elOffset, bgRef,
  10679. optionValue = this.options.arrow,
  10680. ar = this._ui.arrow;
  10681. if ( !ar ) {
  10682. return this._super( desired );
  10683. }
  10684. ar.arEls.show();
  10685. bgRef = {};
  10686. state = this._getPlacementState( true );
  10687. params = {
  10688. "l": { fst: "x", snd: "y", prop: "top", dimKey: "cy", oDimKey: "cx", offsetFactor: 1, tipOffset: -state.arHalf.cx, arrowOffsetFactor: 0 },
  10689. "r": { fst: "x", snd: "y", prop: "top", dimKey: "cy", oDimKey: "cx", offsetFactor: -1, tipOffset: state.arHalf.cx + state.contentBox.cx, arrowOffsetFactor: 1 },
  10690. "b": { fst: "y", snd: "x", prop: "left", dimKey: "cx", oDimKey: "cy", offsetFactor: -1, tipOffset: state.arHalf.cy + state.contentBox.cy, arrowOffsetFactor: 1 },
  10691. "t": { fst: "y", snd: "x", prop: "left", dimKey: "cx", oDimKey: "cy", offsetFactor: 1, tipOffset: -state.arHalf.cy, arrowOffsetFactor: 0 }
  10692. };
  10693. // Try each side specified in the options to see on which one the arrow
  10694. // should be placed such that the distance between the tip of the arrow and
  10695. // the desired coordinates is the shortest.
  10696. $.each( ( optionValue === true ? "l,t,r,b" : optionValue ).split( "," ),
  10697. $.proxy( function( key, value ) {
  10698. best = this._tryAnArrow( params[ value ], value, desired, state, best );
  10699. }, this ) );
  10700. // Could not place the arrow along any of the edges - behave as if showing
  10701. // the arrow was turned off.
  10702. if ( !best ) {
  10703. ar.arEls.hide();
  10704. return this._super( desired );
  10705. }
  10706. // Move the arrow into place
  10707. ar.ct
  10708. .removeClass( "ui-popup-arrow-l ui-popup-arrow-t ui-popup-arrow-r ui-popup-arrow-b" )
  10709. .addClass( "ui-popup-arrow-" + best.dir )
  10710. .removeAttr( "style" ).css( best.posProp, best.posVal )
  10711. .show();
  10712. // Do not move/size the background div on IE, because we use the arrow div for background as well.
  10713. if ( !ieHack ) {
  10714. elOffset = this.element.offset();
  10715. bgRef[ params[ best.dir ].fst ] = ar.ct.offset();
  10716. bgRef[ params[ best.dir ].snd ] = {
  10717. left: elOffset.left + state.contentBox.x,
  10718. top: elOffset.top + state.contentBox.y
  10719. };
  10720. }
  10721. return best.result;
  10722. },
  10723. _setOptions: function( opts ) {
  10724. var newTheme,
  10725. oldTheme = this.options.theme,
  10726. ar = this._ui.arrow,
  10727. ret = this._super( opts );
  10728. if ( opts.arrow !== undefined ) {
  10729. if ( !ar && opts.arrow ) {
  10730. this._ui.arrow = this._addArrow();
  10731. // Important to return here so we don't set the same options all over
  10732. // again below.
  10733. return;
  10734. } else if ( ar && !opts.arrow ) {
  10735. ar.arEls.remove();
  10736. this._ui.arrow = null;
  10737. }
  10738. }
  10739. // Reassign with potentially new arrow
  10740. ar = this._ui.arrow;
  10741. if ( ar ) {
  10742. if ( opts.theme !== undefined ) {
  10743. oldTheme = this._themeClassFromOption( "ui-body-", oldTheme );
  10744. newTheme = this._themeClassFromOption( "ui-body-", opts.theme );
  10745. ar.ar.removeClass( oldTheme ).addClass( newTheme );
  10746. }
  10747. if ( opts.shadow !== undefined ) {
  10748. ar.ar.toggleClass( "ui-overlay-shadow", opts.shadow );
  10749. }
  10750. }
  10751. return ret;
  10752. },
  10753. _destroy: function() {
  10754. var ar = this._ui.arrow;
  10755. if ( ar ) {
  10756. ar.arEls.remove();
  10757. }
  10758. return this._super();
  10759. }
  10760. });
  10761. })( jQuery );
  10762. (function( $, undefined ) {
  10763. $.widget( "mobile.panel", {
  10764. options: {
  10765. classes: {
  10766. panel: "ui-panel",
  10767. panelOpen: "ui-panel-open",
  10768. panelClosed: "ui-panel-closed",
  10769. panelFixed: "ui-panel-fixed",
  10770. panelInner: "ui-panel-inner",
  10771. modal: "ui-panel-dismiss",
  10772. modalOpen: "ui-panel-dismiss-open",
  10773. pageContainer: "ui-panel-page-container",
  10774. pageWrapper: "ui-panel-wrapper",
  10775. pageFixedToolbar: "ui-panel-fixed-toolbar",
  10776. pageContentPrefix: "ui-panel-page-content", /* Used for wrapper and fixed toolbars position, display and open classes. */
  10777. animate: "ui-panel-animate"
  10778. },
  10779. animate: true,
  10780. theme: null,
  10781. position: "left",
  10782. dismissible: true,
  10783. display: "reveal", //accepts reveal, push, overlay
  10784. swipeClose: true,
  10785. positionFixed: false
  10786. },
  10787. _closeLink: null,
  10788. _parentPage: null,
  10789. _page: null,
  10790. _modal: null,
  10791. _panelInner: null,
  10792. _wrapper: null,
  10793. _fixedToolbars: null,
  10794. _create: function() {
  10795. var el = this.element,
  10796. parentPage = el.closest( ".ui-page, :jqmData(role='page')" );
  10797. // expose some private props to other methods
  10798. $.extend( this, {
  10799. _closeLink: el.find( ":jqmData(rel='close')" ),
  10800. _parentPage: ( parentPage.length > 0 ) ? parentPage : false,
  10801. _openedPage: null,
  10802. _page: this._getPage,
  10803. _panelInner: this._getPanelInner(),
  10804. _fixedToolbars: this._getFixedToolbars
  10805. });
  10806. if ( this.options.display !== "overlay" ){
  10807. this._getWrapper();
  10808. }
  10809. this._addPanelClasses();
  10810. // if animating, add the class to do so
  10811. if ( $.support.cssTransform3d && !!this.options.animate ) {
  10812. this.element.addClass( this.options.classes.animate );
  10813. }
  10814. this._bindUpdateLayout();
  10815. this._bindCloseEvents();
  10816. this._bindLinkListeners();
  10817. this._bindPageEvents();
  10818. if ( !!this.options.dismissible ) {
  10819. this._createModal();
  10820. }
  10821. this._bindSwipeEvents();
  10822. },
  10823. _getPanelInner: function() {
  10824. var panelInner = this.element.find( "." + this.options.classes.panelInner );
  10825. if ( panelInner.length === 0 ) {
  10826. panelInner = this.element.children().wrapAll( "<div class='" + this.options.classes.panelInner + "' />" ).parent();
  10827. }
  10828. return panelInner;
  10829. },
  10830. _createModal: function() {
  10831. var self = this,
  10832. target = self._parentPage ? self._parentPage.parent() : self.element.parent();
  10833. self._modal = $( "<div class='" + self.options.classes.modal + "'></div>" )
  10834. .on( "mousedown", function() {
  10835. self.close();
  10836. })
  10837. .appendTo( target );
  10838. },
  10839. _getPage: function() {
  10840. var page = this._openedPage || this._parentPage || $( "." + $.mobile.activePageClass );
  10841. return page;
  10842. },
  10843. _getWrapper: function() {
  10844. var wrapper = this._page().find( "." + this.options.classes.pageWrapper );
  10845. if ( wrapper.length === 0 ) {
  10846. wrapper = this._page().children( ".ui-header:not(.ui-header-fixed), .ui-content:not(.ui-popup), .ui-footer:not(.ui-footer-fixed)" )
  10847. .wrapAll( "<div class='" + this.options.classes.pageWrapper + "'></div>" )
  10848. .parent();
  10849. }
  10850. this._wrapper = wrapper;
  10851. },
  10852. _getFixedToolbars: function() {
  10853. var extFixedToolbars = $( "body" ).children( ".ui-header-fixed, .ui-footer-fixed" ),
  10854. intFixedToolbars = this._page().find( ".ui-header-fixed, .ui-footer-fixed" ),
  10855. fixedToolbars = extFixedToolbars.add( intFixedToolbars ).addClass( this.options.classes.pageFixedToolbar );
  10856. return fixedToolbars;
  10857. },
  10858. _getPosDisplayClasses: function( prefix ) {
  10859. return prefix + "-position-" + this.options.position + " " + prefix + "-display-" + this.options.display;
  10860. },
  10861. _getPanelClasses: function() {
  10862. var panelClasses = this.options.classes.panel +
  10863. " " + this._getPosDisplayClasses( this.options.classes.panel ) +
  10864. " " + this.options.classes.panelClosed +
  10865. " " + "ui-body-" + ( this.options.theme ? this.options.theme : "inherit" );
  10866. if ( !!this.options.positionFixed ) {
  10867. panelClasses += " " + this.options.classes.panelFixed;
  10868. }
  10869. return panelClasses;
  10870. },
  10871. _addPanelClasses: function() {
  10872. this.element.addClass( this._getPanelClasses() );
  10873. },
  10874. _handleCloseClick: function( event ) {
  10875. if ( !event.isDefaultPrevented() ) {
  10876. this.close();
  10877. }
  10878. },
  10879. _bindCloseEvents: function() {
  10880. this._on( this._closeLink, {
  10881. "click": "_handleCloseClick"
  10882. });
  10883. this._on({
  10884. "click a:jqmData(ajax='false')": "_handleCloseClick"
  10885. });
  10886. },
  10887. _positionPanel: function( scrollToTop ) {
  10888. var self = this,
  10889. panelInnerHeight = self._panelInner.outerHeight(),
  10890. expand = panelInnerHeight > $.mobile.getScreenHeight();
  10891. if ( expand || !self.options.positionFixed ) {
  10892. if ( expand ) {
  10893. self._unfixPanel();
  10894. $.mobile.resetActivePageHeight( panelInnerHeight );
  10895. }
  10896. if ( scrollToTop ) {
  10897. this.window[ 0 ].scrollTo( 0, $.mobile.defaultHomeScroll );
  10898. }
  10899. } else {
  10900. self._fixPanel();
  10901. }
  10902. },
  10903. _bindFixListener: function() {
  10904. this._on( $( window ), { "throttledresize": "_positionPanel" });
  10905. },
  10906. _unbindFixListener: function() {
  10907. this._off( $( window ), "throttledresize" );
  10908. },
  10909. _unfixPanel: function() {
  10910. if ( !!this.options.positionFixed && $.support.fixedPosition ) {
  10911. this.element.removeClass( this.options.classes.panelFixed );
  10912. }
  10913. },
  10914. _fixPanel: function() {
  10915. if ( !!this.options.positionFixed && $.support.fixedPosition ) {
  10916. this.element.addClass( this.options.classes.panelFixed );
  10917. }
  10918. },
  10919. _bindUpdateLayout: function() {
  10920. var self = this;
  10921. self.element.on( "updatelayout", function(/* e */) {
  10922. if ( self._open ) {
  10923. self._positionPanel();
  10924. }
  10925. });
  10926. },
  10927. _bindLinkListeners: function() {
  10928. this._on( "body", {
  10929. "click a": "_handleClick"
  10930. });
  10931. },
  10932. _handleClick: function( e ) {
  10933. var link,
  10934. panelId = this.element.attr( "id" );
  10935. if ( e.currentTarget.href.split( "#" )[ 1 ] === panelId && panelId !== undefined ) {
  10936. e.preventDefault();
  10937. link = $( e.target );
  10938. if ( link.hasClass( "ui-btn" ) ) {
  10939. link.addClass( $.mobile.activeBtnClass );
  10940. this.element.one( "panelopen panelclose", function() {
  10941. link.removeClass( $.mobile.activeBtnClass );
  10942. });
  10943. }
  10944. this.toggle();
  10945. }
  10946. },
  10947. _bindSwipeEvents: function() {
  10948. var self = this,
  10949. area = self._modal ? self.element.add( self._modal ) : self.element;
  10950. // on swipe, close the panel
  10951. if ( !!self.options.swipeClose ) {
  10952. if ( self.options.position === "left" ) {
  10953. area.on( "swipeleft.panel", function(/* e */) {
  10954. self.close();
  10955. });
  10956. } else {
  10957. area.on( "swiperight.panel", function(/* e */) {
  10958. self.close();
  10959. });
  10960. }
  10961. }
  10962. },
  10963. _bindPageEvents: function() {
  10964. var self = this;
  10965. this.document
  10966. // Close the panel if another panel on the page opens
  10967. .on( "panelbeforeopen", function( e ) {
  10968. if ( self._open && e.target !== self.element[ 0 ] ) {
  10969. self.close();
  10970. }
  10971. })
  10972. // On escape, close? might need to have a target check too...
  10973. .on( "keyup.panel", function( e ) {
  10974. if ( e.keyCode === 27 && self._open ) {
  10975. self.close();
  10976. }
  10977. });
  10978. if ( !this._parentPage && this.options.display !== "overlay" ) {
  10979. this._on( this.document, {
  10980. "pageshow": function() {
  10981. this._openedPage = null;
  10982. this._getWrapper();
  10983. }
  10984. });
  10985. }
  10986. // Clean up open panels after page hide
  10987. if ( self._parentPage ) {
  10988. this.document.on( "pagehide", ":jqmData(role='page')", function() {
  10989. if ( self._open ) {
  10990. self.close( true );
  10991. }
  10992. });
  10993. } else {
  10994. this.document.on( "pagebeforehide", function() {
  10995. if ( self._open ) {
  10996. self.close( true );
  10997. }
  10998. });
  10999. }
  11000. },
  11001. // state storage of open or closed
  11002. _open: false,
  11003. _pageContentOpenClasses: null,
  11004. _modalOpenClasses: null,
  11005. open: function( immediate ) {
  11006. if ( !this._open ) {
  11007. var self = this,
  11008. o = self.options,
  11009. _openPanel = function() {
  11010. self._off( self.document , "panelclose" );
  11011. self._page().jqmData( "panel", "open" );
  11012. if ( $.support.cssTransform3d && !!o.animate && o.display !== "overlay" ) {
  11013. self._wrapper.addClass( o.classes.animate );
  11014. self._fixedToolbars().addClass( o.classes.animate );
  11015. }
  11016. if ( !immediate && $.support.cssTransform3d && !!o.animate ) {
  11017. ( self._wrapper || self.element )
  11018. .animationComplete( complete, "transition" );
  11019. } else {
  11020. setTimeout( complete, 0 );
  11021. }
  11022. if ( o.theme && o.display !== "overlay" ) {
  11023. self._page().parent()
  11024. .addClass( o.classes.pageContainer + "-themed " + o.classes.pageContainer + "-" + o.theme );
  11025. }
  11026. self.element
  11027. .removeClass( o.classes.panelClosed )
  11028. .addClass( o.classes.panelOpen );
  11029. self._positionPanel( true );
  11030. self._pageContentOpenClasses = self._getPosDisplayClasses( o.classes.pageContentPrefix );
  11031. if ( o.display !== "overlay" ) {
  11032. self._page().parent().addClass( o.classes.pageContainer );
  11033. self._wrapper.addClass( self._pageContentOpenClasses );
  11034. self._fixedToolbars().addClass( self._pageContentOpenClasses );
  11035. }
  11036. self._modalOpenClasses = self._getPosDisplayClasses( o.classes.modal ) + " " + o.classes.modalOpen;
  11037. if ( self._modal ) {
  11038. self._modal
  11039. .addClass( self._modalOpenClasses )
  11040. .height( Math.max( self._modal.height(), self.document.height() ) );
  11041. }
  11042. },
  11043. complete = function() {
  11044. // Bail if the panel was closed before the opening animation has completed
  11045. if ( !self._open ) {
  11046. return;
  11047. }
  11048. if ( o.display !== "overlay" ) {
  11049. self._wrapper.addClass( o.classes.pageContentPrefix + "-open" );
  11050. self._fixedToolbars().addClass( o.classes.pageContentPrefix + "-open" );
  11051. }
  11052. self._bindFixListener();
  11053. self._trigger( "open" );
  11054. self._openedPage = self._page();
  11055. };
  11056. self._trigger( "beforeopen" );
  11057. if ( self._page().jqmData( "panel" ) === "open" ) {
  11058. self._on( self.document, {
  11059. "panelclose": _openPanel
  11060. });
  11061. } else {
  11062. _openPanel();
  11063. }
  11064. self._open = true;
  11065. }
  11066. },
  11067. close: function( immediate ) {
  11068. if ( this._open ) {
  11069. var self = this,
  11070. o = this.options,
  11071. _closePanel = function() {
  11072. self.element.removeClass( o.classes.panelOpen );
  11073. if ( o.display !== "overlay" ) {
  11074. self._wrapper.removeClass( self._pageContentOpenClasses );
  11075. self._fixedToolbars().removeClass( self._pageContentOpenClasses );
  11076. }
  11077. if ( !immediate && $.support.cssTransform3d && !!o.animate ) {
  11078. ( self._wrapper || self.element )
  11079. .animationComplete( complete, "transition" );
  11080. } else {
  11081. setTimeout( complete, 0 );
  11082. }
  11083. if ( self._modal ) {
  11084. self._modal
  11085. .removeClass( self._modalOpenClasses )
  11086. .height( "" );
  11087. }
  11088. },
  11089. complete = function() {
  11090. if ( o.theme && o.display !== "overlay" ) {
  11091. self._page().parent().removeClass( o.classes.pageContainer + "-themed " + o.classes.pageContainer + "-" + o.theme );
  11092. }
  11093. self.element.addClass( o.classes.panelClosed );
  11094. if ( o.display !== "overlay" ) {
  11095. self._page().parent().removeClass( o.classes.pageContainer );
  11096. self._wrapper.removeClass( o.classes.pageContentPrefix + "-open" );
  11097. self._fixedToolbars().removeClass( o.classes.pageContentPrefix + "-open" );
  11098. }
  11099. if ( $.support.cssTransform3d && !!o.animate && o.display !== "overlay" ) {
  11100. self._wrapper.removeClass( o.classes.animate );
  11101. self._fixedToolbars().removeClass( o.classes.animate );
  11102. }
  11103. self._fixPanel();
  11104. self._unbindFixListener();
  11105. $.mobile.resetActivePageHeight();
  11106. self._page().jqmRemoveData( "panel" );
  11107. self._trigger( "close" );
  11108. self._openedPage = null;
  11109. };
  11110. self._trigger( "beforeclose" );
  11111. _closePanel();
  11112. self._open = false;
  11113. }
  11114. },
  11115. toggle: function() {
  11116. this[ this._open ? "close" : "open" ]();
  11117. },
  11118. _destroy: function() {
  11119. var otherPanels,
  11120. o = this.options,
  11121. multiplePanels = ( $( "body > :mobile-panel" ).length + $.mobile.activePage.find( ":mobile-panel" ).length ) > 1;
  11122. if ( o.display !== "overlay" ) {
  11123. // remove the wrapper if not in use by another panel
  11124. otherPanels = $( "body > :mobile-panel" ).add( $.mobile.activePage.find( ":mobile-panel" ) );
  11125. if ( otherPanels.not( ".ui-panel-display-overlay" ).not( this.element ).length === 0 ) {
  11126. this._wrapper.children().unwrap();
  11127. }
  11128. if ( this._open ) {
  11129. this._fixedToolbars().removeClass( o.classes.pageContentPrefix + "-open" );
  11130. if ( $.support.cssTransform3d && !!o.animate ) {
  11131. this._fixedToolbars().removeClass( o.classes.animate );
  11132. }
  11133. this._page().parent().removeClass( o.classes.pageContainer );
  11134. if ( o.theme ) {
  11135. this._page().parent().removeClass( o.classes.pageContainer + "-themed " + o.classes.pageContainer + "-" + o.theme );
  11136. }
  11137. }
  11138. }
  11139. if ( !multiplePanels ) {
  11140. this.document.off( "panelopen panelclose" );
  11141. }
  11142. if ( this._open ) {
  11143. this._page().jqmRemoveData( "panel" );
  11144. }
  11145. this._panelInner.children().unwrap();
  11146. this.element
  11147. .removeClass( [ this._getPanelClasses(), o.classes.panelOpen, o.classes.animate ].join( " " ) )
  11148. .off( "swipeleft.panel swiperight.panel" )
  11149. .off( "panelbeforeopen" )
  11150. .off( "panelhide" )
  11151. .off( "keyup.panel" )
  11152. .off( "updatelayout" );
  11153. if ( this._modal ) {
  11154. this._modal.remove();
  11155. }
  11156. }
  11157. });
  11158. })( jQuery );
  11159. (function( $, undefined ) {
  11160. $.widget( "mobile.table", {
  11161. options: {
  11162. classes: {
  11163. table: "ui-table"
  11164. },
  11165. enhanced: false
  11166. },
  11167. _create: function() {
  11168. if ( !this.options.enhanced ) {
  11169. this.element.addClass( this.options.classes.table );
  11170. }
  11171. // extend here, assign on refresh > _setHeaders
  11172. $.extend( this, {
  11173. // Expose headers and allHeaders properties on the widget
  11174. // headers references the THs within the first TR in the table
  11175. headers: undefined,
  11176. // allHeaders references headers, plus all THs in the thead, which may
  11177. // include several rows, or not
  11178. allHeaders: undefined
  11179. });
  11180. this._refresh( true );
  11181. },
  11182. _setHeaders: function() {
  11183. var trs = this.element.find( "thead tr" );
  11184. this.headers = this.element.find( "tr:eq(0)" ).children();
  11185. this.allHeaders = this.headers.add( trs.children() );
  11186. },
  11187. refresh: function() {
  11188. this._refresh();
  11189. },
  11190. rebuild: $.noop,
  11191. _refresh: function( /* create */ ) {
  11192. var table = this.element,
  11193. trs = table.find( "thead tr" );
  11194. // updating headers on refresh (fixes #5880)
  11195. this._setHeaders();
  11196. // Iterate over the trs
  11197. trs.each( function() {
  11198. var columnCount = 0;
  11199. // Iterate over the children of the tr
  11200. $( this ).children().each( function() {
  11201. var span = parseInt( this.getAttribute( "colspan" ), 10 ),
  11202. selector = ":nth-child(" + ( columnCount + 1 ) + ")",
  11203. j;
  11204. this.setAttribute( "data-" + $.mobile.ns + "colstart", columnCount + 1 );
  11205. if ( span ) {
  11206. for( j = 0; j < span - 1; j++ ) {
  11207. columnCount++;
  11208. selector += ", :nth-child(" + ( columnCount + 1 ) + ")";
  11209. }
  11210. }
  11211. // Store "cells" data on header as a reference to all cells in the
  11212. // same column as this TH
  11213. $( this ).jqmData( "cells", table.find( "tr" ).not( trs.eq( 0 ) ).not( this ).children( selector ) );
  11214. columnCount++;
  11215. });
  11216. });
  11217. }
  11218. });
  11219. })( jQuery );
  11220. (function( $, undefined ) {
  11221. $.widget( "mobile.table", $.mobile.table, {
  11222. options: {
  11223. mode: "columntoggle",
  11224. columnBtnTheme: null,
  11225. columnPopupTheme: null,
  11226. columnBtnText: "Columns...",
  11227. classes: $.extend( $.mobile.table.prototype.options.classes, {
  11228. popup: "ui-table-columntoggle-popup",
  11229. columnBtn: "ui-table-columntoggle-btn",
  11230. priorityPrefix: "ui-table-priority-",
  11231. columnToggleTable: "ui-table-columntoggle"
  11232. })
  11233. },
  11234. _create: function() {
  11235. this._super();
  11236. if ( this.options.mode !== "columntoggle" ) {
  11237. return;
  11238. }
  11239. $.extend( this, {
  11240. _menu: null
  11241. });
  11242. if ( this.options.enhanced ) {
  11243. this._menu = $( this.document[ 0 ].getElementById( this._id() + "-popup" ) ).children().first();
  11244. this._addToggles( this._menu, true );
  11245. } else {
  11246. this._menu = this._enhanceColToggle();
  11247. this.element.addClass( this.options.classes.columnToggleTable );
  11248. }
  11249. this._setupEvents();
  11250. this._setToggleState();
  11251. },
  11252. _id: function() {
  11253. return ( this.element.attr( "id" ) || ( this.widgetName + this.uuid ) );
  11254. },
  11255. _setupEvents: function() {
  11256. //NOTE: inputs are bound in bindToggles,
  11257. // so it can be called on refresh, too
  11258. // update column toggles on resize
  11259. this._on( this.window, {
  11260. throttledresize: "_setToggleState"
  11261. });
  11262. this._on( this._menu, {
  11263. "change input": "_menuInputChange"
  11264. });
  11265. },
  11266. _addToggles: function( menu, keep ) {
  11267. var inputs,
  11268. checkboxIndex = 0,
  11269. opts = this.options,
  11270. container = menu.controlgroup( "container" );
  11271. // allow update of menu on refresh (fixes #5880)
  11272. if ( keep ) {
  11273. inputs = menu.find( "input" );
  11274. } else {
  11275. container.empty();
  11276. }
  11277. // create the hide/show toggles
  11278. this.headers.not( "td" ).each( function() {
  11279. var input, cells,
  11280. header = $( this ),
  11281. priority = $.mobile.getAttribute( this, "priority" );
  11282. if ( priority ) {
  11283. cells = header.add( header.jqmData( "cells" ) );
  11284. cells.addClass( opts.classes.priorityPrefix + priority );
  11285. // Make sure the (new?) checkbox is associated with its header via .jqmData() and
  11286. // that, vice versa, the header is also associated with the checkbox
  11287. input = ( keep ? inputs.eq( checkboxIndex++ ) :
  11288. $("<label><input type='checkbox' checked />" +
  11289. ( header.children( "abbr" ).first().attr( "title" ) ||
  11290. header.text() ) +
  11291. "</label>" )
  11292. .appendTo( container )
  11293. .children( 0 )
  11294. .checkboxradio( {
  11295. theme: opts.columnPopupTheme
  11296. }) )
  11297. // Associate the header with the checkbox
  11298. .jqmData( "header", header )
  11299. .jqmData( "cells", cells );
  11300. // Associate the checkbox with the header
  11301. header.jqmData( "input", input );
  11302. }
  11303. });
  11304. // set bindings here
  11305. if ( !keep ) {
  11306. menu.controlgroup( "refresh" );
  11307. }
  11308. },
  11309. _menuInputChange: function( evt ) {
  11310. var input = $( evt.target ),
  11311. checked = input[ 0 ].checked;
  11312. input.jqmData( "cells" )
  11313. .toggleClass( "ui-table-cell-hidden", !checked )
  11314. .toggleClass( "ui-table-cell-visible", checked );
  11315. },
  11316. _unlockCells: function( cells ) {
  11317. // allow hide/show via CSS only = remove all toggle-locks
  11318. cells.removeClass( "ui-table-cell-hidden ui-table-cell-visible");
  11319. },
  11320. _enhanceColToggle: function() {
  11321. var id , menuButton, popup, menu,
  11322. table = this.element,
  11323. opts = this.options,
  11324. ns = $.mobile.ns,
  11325. fragment = this.document[ 0 ].createDocumentFragment();
  11326. id = this._id() + "-popup";
  11327. menuButton = $( "<a href='#" + id + "' " +
  11328. "class='" + opts.classes.columnBtn + " ui-btn " +
  11329. "ui-btn-" + ( opts.columnBtnTheme || "a" ) +
  11330. " ui-corner-all ui-shadow ui-mini' " +
  11331. "data-" + ns + "rel='popup'>" + opts.columnBtnText + "</a>" );
  11332. popup = $( "<div class='" + opts.classes.popup + "' id='" + id + "'></div>" );
  11333. menu = $( "<fieldset></fieldset>" ).controlgroup();
  11334. // set extension here, send "false" to trigger build/rebuild
  11335. this._addToggles( menu, false );
  11336. menu.appendTo( popup );
  11337. fragment.appendChild( popup[ 0 ] );
  11338. fragment.appendChild( menuButton[ 0 ] );
  11339. table.before( fragment );
  11340. popup.popup();
  11341. return menu;
  11342. },
  11343. rebuild: function() {
  11344. this._super();
  11345. if ( this.options.mode === "columntoggle" ) {
  11346. // NOTE: rebuild passes "false", while refresh passes "undefined"
  11347. // both refresh the table, but inside addToggles, !false will be true,
  11348. // so a rebuild call can be indentified
  11349. this._refresh( false );
  11350. }
  11351. },
  11352. _refresh: function( create ) {
  11353. var headers, hiddenColumns, index;
  11354. // Calling _super() here updates this.headers
  11355. this._super( create );
  11356. if ( !create && this.options.mode === "columntoggle" ) {
  11357. headers = this.headers;
  11358. hiddenColumns = [];
  11359. // Find the index of the column header associated with each old checkbox among the
  11360. // post-refresh headers and, if the header is still there, make sure the corresponding
  11361. // column will be hidden if the pre-refresh checkbox indicates that the column is
  11362. // hidden by recording its index in the array of hidden columns.
  11363. this._menu.find( "input" ).each( function() {
  11364. var input = $( this ),
  11365. header = input.jqmData( "header" ),
  11366. index = headers.index( header[ 0 ] );
  11367. if ( index > -1 && !input.prop( "checked" ) ) {
  11368. // The column header associated with /this/ checkbox is still present in the
  11369. // post-refresh table and the checkbox is not checked, so the column associated
  11370. // with this column header is currently hidden. Let's record that.
  11371. hiddenColumns.push( index );
  11372. }
  11373. });
  11374. // columns not being replaced must be cleared from input toggle-locks
  11375. this._unlockCells( this.element.find( ".ui-table-cell-hidden, " +
  11376. ".ui-table-cell-visible" ) );
  11377. // update columntoggles and cells
  11378. this._addToggles( this._menu, create );
  11379. // At this point all columns are visible, so uncheck the checkboxes that correspond to
  11380. // those columns we've found to be hidden
  11381. for ( index = hiddenColumns.length - 1 ; index > -1 ; index-- ) {
  11382. headers.eq( hiddenColumns[ index ] ).jqmData( "input" )
  11383. .prop( "checked", false )
  11384. .checkboxradio( "refresh" )
  11385. .trigger( "change" );
  11386. }
  11387. }
  11388. },
  11389. _setToggleState: function() {
  11390. this._menu.find( "input" ).each( function() {
  11391. var checkbox = $( this );
  11392. this.checked = checkbox.jqmData( "cells" ).eq( 0 ).css( "display" ) === "table-cell";
  11393. checkbox.checkboxradio( "refresh" );
  11394. });
  11395. },
  11396. _destroy: function() {
  11397. this._super();
  11398. }
  11399. });
  11400. })( jQuery );
  11401. (function( $, undefined ) {
  11402. $.widget( "mobile.table", $.mobile.table, {
  11403. options: {
  11404. mode: "reflow",
  11405. classes: $.extend( $.mobile.table.prototype.options.classes, {
  11406. reflowTable: "ui-table-reflow",
  11407. cellLabels: "ui-table-cell-label"
  11408. })
  11409. },
  11410. _create: function() {
  11411. this._super();
  11412. // If it's not reflow mode, return here.
  11413. if ( this.options.mode !== "reflow" ) {
  11414. return;
  11415. }
  11416. if ( !this.options.enhanced ) {
  11417. this.element.addClass( this.options.classes.reflowTable );
  11418. this._updateReflow();
  11419. }
  11420. },
  11421. rebuild: function() {
  11422. this._super();
  11423. if ( this.options.mode === "reflow" ) {
  11424. this._refresh( false );
  11425. }
  11426. },
  11427. _refresh: function( create ) {
  11428. this._super( create );
  11429. if ( !create && this.options.mode === "reflow" ) {
  11430. this._updateReflow( );
  11431. }
  11432. },
  11433. _updateReflow: function() {
  11434. var table = this,
  11435. opts = this.options;
  11436. // get headers in reverse order so that top-level headers are appended last
  11437. $( table.allHeaders.get().reverse() ).each( function() {
  11438. var cells = $( this ).jqmData( "cells" ),
  11439. colstart = $.mobile.getAttribute( this, "colstart" ),
  11440. hierarchyClass = cells.not( this ).filter( "thead th" ).length && " ui-table-cell-label-top",
  11441. contents = $( this ).clone().contents(),
  11442. iteration, filter;
  11443. if ( contents.length > 0 ) {
  11444. if ( hierarchyClass ) {
  11445. iteration = parseInt( this.getAttribute( "colspan" ), 10 );
  11446. filter = "";
  11447. if ( iteration ) {
  11448. filter = "td:nth-child("+ iteration +"n + " + ( colstart ) +")";
  11449. }
  11450. table._addLabels( cells.filter( filter ),
  11451. opts.classes.cellLabels + hierarchyClass, contents );
  11452. } else {
  11453. table._addLabels( cells, opts.classes.cellLabels, contents );
  11454. }
  11455. }
  11456. });
  11457. },
  11458. _addLabels: function( cells, label, contents ) {
  11459. if ( contents.length === 1 && contents[ 0 ].nodeName.toLowerCase() === "abbr" ) {
  11460. contents = contents.eq( 0 ).attr( "title" );
  11461. }
  11462. // .not fixes #6006
  11463. cells
  11464. .not( ":has(b." + label + ")" )
  11465. .prepend( $( "<b class='" + label + "'></b>" ).append( contents ) );
  11466. }
  11467. });
  11468. })( jQuery );
  11469. (function( $, undefined ) {
  11470. // TODO rename filterCallback/deprecate and default to the item itself as the first argument
  11471. var defaultFilterCallback = function( index, searchValue ) {
  11472. return ( ( "" + ( $.mobile.getAttribute( this, "filtertext" ) || $( this ).text() ) )
  11473. .toLowerCase().indexOf( searchValue ) === -1 );
  11474. };
  11475. $.widget( "mobile.filterable", {
  11476. initSelector: ":jqmData(filter='true')",
  11477. options: {
  11478. filterReveal: false,
  11479. filterCallback: defaultFilterCallback,
  11480. enhanced: false,
  11481. input: null,
  11482. children: "> li, > option, > optgroup option, > tbody tr, > .ui-controlgroup-controls > .ui-btn, > .ui-controlgroup-controls > .ui-checkbox, > .ui-controlgroup-controls > .ui-radio"
  11483. },
  11484. _create: function() {
  11485. var opts = this.options;
  11486. $.extend( this, {
  11487. _search: null,
  11488. _timer: 0
  11489. });
  11490. this._setInput( opts.input );
  11491. if ( !opts.enhanced ) {
  11492. this._filterItems( ( ( this._search && this._search.val() ) || "" ).toLowerCase() );
  11493. }
  11494. },
  11495. _onKeyUp: function() {
  11496. var val, lastval,
  11497. search = this._search;
  11498. if ( search ) {
  11499. val = search.val().toLowerCase(),
  11500. lastval = $.mobile.getAttribute( search[ 0 ], "lastval" ) + "";
  11501. if ( lastval && lastval === val ) {
  11502. // Execute the handler only once per value change
  11503. return;
  11504. }
  11505. if ( this._timer ) {
  11506. window.clearTimeout( this._timer );
  11507. this._timer = 0;
  11508. }
  11509. this._timer = this._delay( function() {
  11510. if ( this._trigger( "beforefilter", null, { input: search } ) === false ) {
  11511. return false;
  11512. }
  11513. // Change val as lastval for next execution
  11514. search[ 0 ].setAttribute( "data-" + $.mobile.ns + "lastval", val );
  11515. this._filterItems( val );
  11516. this._timer = 0;
  11517. }, 250 );
  11518. }
  11519. },
  11520. _getFilterableItems: function() {
  11521. var elem = this.element,
  11522. children = this.options.children,
  11523. items = !children ? { length: 0 }:
  11524. $.isFunction( children ) ? children():
  11525. children.nodeName ? $( children ):
  11526. children.jquery ? children:
  11527. this.element.find( children );
  11528. if ( items.length === 0 ) {
  11529. items = elem.children();
  11530. }
  11531. return items;
  11532. },
  11533. _filterItems: function( val ) {
  11534. var idx, callback, length, dst,
  11535. show = [],
  11536. hide = [],
  11537. opts = this.options,
  11538. filterItems = this._getFilterableItems();
  11539. if ( val != null ) {
  11540. callback = opts.filterCallback || defaultFilterCallback;
  11541. length = filterItems.length;
  11542. // Partition the items into those to be hidden and those to be shown
  11543. for ( idx = 0 ; idx < length ; idx++ ) {
  11544. dst = ( callback.call( filterItems[ idx ], idx, val ) ) ? hide : show;
  11545. dst.push( filterItems[ idx ] );
  11546. }
  11547. }
  11548. // If nothing is hidden, then the decision whether to hide or show the items
  11549. // is based on the "filterReveal" option.
  11550. if ( hide.length === 0 ) {
  11551. filterItems[ ( opts.filterReveal && val.length === 0 ) ?
  11552. "addClass" : "removeClass" ]( "ui-screen-hidden" );
  11553. } else {
  11554. $( hide ).addClass( "ui-screen-hidden" );
  11555. $( show ).removeClass( "ui-screen-hidden" );
  11556. }
  11557. this._refreshChildWidget();
  11558. this._trigger( "filter", null, {
  11559. items: filterItems
  11560. });
  11561. },
  11562. // The Default implementation of _refreshChildWidget attempts to call
  11563. // refresh on collapsibleset, controlgroup, selectmenu, or listview
  11564. _refreshChildWidget: function() {
  11565. var widget, idx,
  11566. recognizedWidgets = [ "collapsibleset", "selectmenu", "controlgroup", "listview" ];
  11567. for ( idx = recognizedWidgets.length - 1 ; idx > -1 ; idx-- ) {
  11568. widget = recognizedWidgets[ idx ];
  11569. if ( $.mobile[ widget ] ) {
  11570. widget = this.element.data( "mobile-" + widget );
  11571. if ( widget && $.isFunction( widget.refresh ) ) {
  11572. widget.refresh();
  11573. }
  11574. }
  11575. }
  11576. },
  11577. // TODO: When the input is not internal, do not even store it in this._search
  11578. _setInput: function ( selector ) {
  11579. var search = this._search;
  11580. // Stop a pending filter operation
  11581. if ( this._timer ) {
  11582. window.clearTimeout( this._timer );
  11583. this._timer = 0;
  11584. }
  11585. if ( search ) {
  11586. this._off( search, "keyup change input" );
  11587. search = null;
  11588. }
  11589. if ( selector ) {
  11590. search = selector.jquery ? selector:
  11591. selector.nodeName ? $( selector ):
  11592. this.document.find( selector );
  11593. this._on( search, {
  11594. keydown: "_onKeyDown",
  11595. keypress: "_onKeyPress",
  11596. keyup: "_onKeyUp",
  11597. change: "_onKeyUp",
  11598. input: "_onKeyUp"
  11599. });
  11600. }
  11601. this._search = search;
  11602. },
  11603. // Prevent form submission
  11604. _onKeyDown: function( event ) {
  11605. if ( event.keyCode === $.ui.keyCode.ENTER ) {
  11606. event.preventDefault();
  11607. this._preventKeyPress = true;
  11608. }
  11609. },
  11610. _onKeyPress: function( event ) {
  11611. if ( this._preventKeyPress ) {
  11612. event.preventDefault();
  11613. this._preventKeyPress = false;
  11614. }
  11615. },
  11616. _setOptions: function( options ) {
  11617. var refilter = !( ( options.filterReveal === undefined ) &&
  11618. ( options.filterCallback === undefined ) &&
  11619. ( options.children === undefined ) );
  11620. this._super( options );
  11621. if ( options.input !== undefined ) {
  11622. this._setInput( options.input );
  11623. refilter = true;
  11624. }
  11625. if ( refilter ) {
  11626. this.refresh();
  11627. }
  11628. },
  11629. _destroy: function() {
  11630. var opts = this.options,
  11631. items = this._getFilterableItems();
  11632. if ( opts.enhanced ) {
  11633. items.toggleClass( "ui-screen-hidden", opts.filterReveal );
  11634. } else {
  11635. items.removeClass( "ui-screen-hidden" );
  11636. }
  11637. },
  11638. refresh: function() {
  11639. if ( this._timer ) {
  11640. window.clearTimeout( this._timer );
  11641. this._timer = 0;
  11642. }
  11643. this._filterItems( ( ( this._search && this._search.val() ) || "" ).toLowerCase() );
  11644. }
  11645. });
  11646. })( jQuery );
  11647. (function( $, undefined ) {
  11648. // Create a function that will replace the _setOptions function of a widget,
  11649. // and will pass the options on to the input of the filterable.
  11650. var replaceSetOptions = function( self, orig ) {
  11651. return function( options ) {
  11652. orig.call( this, options );
  11653. self._syncTextInputOptions( options );
  11654. };
  11655. },
  11656. rDividerListItem = /(^|\s)ui-li-divider(\s|$)/,
  11657. origDefaultFilterCallback = $.mobile.filterable.prototype.options.filterCallback;
  11658. // Override the default filter callback with one that does not hide list dividers
  11659. $.mobile.filterable.prototype.options.filterCallback = function( index, searchValue ) {
  11660. return !this.className.match( rDividerListItem ) &&
  11661. origDefaultFilterCallback.call( this, index, searchValue );
  11662. };
  11663. $.widget( "mobile.filterable", $.mobile.filterable, {
  11664. options: {
  11665. filterPlaceholder: "Filter items...",
  11666. filterTheme: null
  11667. },
  11668. _create: function() {
  11669. var idx, widgetName,
  11670. elem = this.element,
  11671. recognizedWidgets = [ "collapsibleset", "selectmenu", "controlgroup", "listview" ],
  11672. createHandlers = {};
  11673. this._super();
  11674. $.extend( this, {
  11675. _widget: null
  11676. });
  11677. for ( idx = recognizedWidgets.length - 1 ; idx > -1 ; idx-- ) {
  11678. widgetName = recognizedWidgets[ idx ];
  11679. if ( $.mobile[ widgetName ] ) {
  11680. if ( this._setWidget( elem.data( "mobile-" + widgetName ) ) ) {
  11681. break;
  11682. } else {
  11683. createHandlers[ widgetName + "create" ] = "_handleCreate";
  11684. }
  11685. }
  11686. }
  11687. if ( !this._widget ) {
  11688. this._on( elem, createHandlers );
  11689. }
  11690. },
  11691. _handleCreate: function( evt ) {
  11692. this._setWidget( this.element.data( "mobile-" + evt.type.substring( 0, evt.type.length - 6 ) ) );
  11693. },
  11694. _trigger: function( type, event, data ) {
  11695. if ( this._widget && this._widget.widgetFullName === "mobile-listview" &&
  11696. type === "beforefilter" ) {
  11697. // Also trigger listviewbeforefilter if this widget is also a listview
  11698. this._widget._trigger( "beforefilter", event, data );
  11699. }
  11700. // Passing back the response enables calling preventDefault()
  11701. return this._super( type, event, data );
  11702. },
  11703. _setWidget: function( widget ) {
  11704. if ( !this._widget && widget ) {
  11705. this._widget = widget;
  11706. this._widget._setOptions = replaceSetOptions( this, this._widget._setOptions );
  11707. }
  11708. if ( !!this._widget ) {
  11709. this._syncTextInputOptions( this._widget.options );
  11710. if ( this._widget.widgetName === "listview" ) {
  11711. this._widget.options.hideDividers = true;
  11712. this._widget.element.listview( "refresh" );
  11713. }
  11714. }
  11715. return !!this._widget;
  11716. },
  11717. _isSearchInternal: function() {
  11718. return ( this._search && this._search.jqmData( "ui-filterable-" + this.uuid + "-internal" ) );
  11719. },
  11720. _setInput: function( selector ) {
  11721. var opts = this.options,
  11722. updatePlaceholder = true,
  11723. textinputOpts = {};
  11724. if ( !selector ) {
  11725. if ( this._isSearchInternal() ) {
  11726. // Ignore the call to set a new input if the selector goes to falsy and
  11727. // the current textinput is already of the internally generated variety.
  11728. return;
  11729. } else {
  11730. // Generating a new textinput widget. No need to set the placeholder
  11731. // further down the function.
  11732. updatePlaceholder = false;
  11733. selector = $( "<input " +
  11734. "data-" + $.mobile.ns + "type='search' " +
  11735. "placeholder='" + opts.filterPlaceholder + "'></input>" )
  11736. .jqmData( "ui-filterable-" + this.uuid + "-internal", true );
  11737. $( "<form class='ui-filterable'></form>" )
  11738. .append( selector )
  11739. .submit( function( evt ) {
  11740. evt.preventDefault();
  11741. selector.blur();
  11742. })
  11743. .insertBefore( this.element );
  11744. if ( $.mobile.textinput ) {
  11745. if ( this.options.filterTheme != null ) {
  11746. textinputOpts[ "theme" ] = opts.filterTheme;
  11747. }
  11748. selector.textinput( textinputOpts );
  11749. }
  11750. }
  11751. }
  11752. this._super( selector );
  11753. if ( this._isSearchInternal() && updatePlaceholder ) {
  11754. this._search.attr( "placeholder", this.options.filterPlaceholder );
  11755. }
  11756. },
  11757. _setOptions: function( options ) {
  11758. var ret = this._super( options );
  11759. // Need to set the filterPlaceholder after having established the search input
  11760. if ( options.filterPlaceholder !== undefined ) {
  11761. if ( this._isSearchInternal() ) {
  11762. this._search.attr( "placeholder", options.filterPlaceholder );
  11763. }
  11764. }
  11765. if ( options.filterTheme !== undefined && this._search && $.mobile.textinput ) {
  11766. this._search.textinput( "option", "theme", options.filterTheme );
  11767. }
  11768. return ret;
  11769. },
  11770. // The listview implementation accompanying this filterable backcompat layer will call
  11771. // filterable.refresh() after it's done refreshing the listview to make sure the filterable
  11772. // filters out any new items added. However, when the listview refresh has been initiated by
  11773. // the filterable itself, then such filtering has already taken place, and calling the
  11774. // filterable's refresh() method will cause an infinite recursion. We stop this by setting a
  11775. // flag that will cause the filterable's refresh() method to short-circuit.
  11776. _refreshChildWidget: function() {
  11777. this._refreshingChildWidget = true;
  11778. this._superApply( arguments );
  11779. this._refreshingChildWidget = false;
  11780. },
  11781. refresh: function() {
  11782. if ( !this._refreshingChildWidget ) {
  11783. this._superApply( arguments );
  11784. }
  11785. },
  11786. _destroy: function() {
  11787. if ( this._isSearchInternal() ) {
  11788. this._search.remove();
  11789. }
  11790. this._super();
  11791. },
  11792. _syncTextInputOptions: function( options ) {
  11793. var idx,
  11794. textinputOptions = {};
  11795. // We only sync options if the filterable's textinput is of the internally
  11796. // generated variety, rather than one specified by the user.
  11797. if ( this._isSearchInternal() && $.mobile.textinput ) {
  11798. // Apply only the options understood by textinput
  11799. for ( idx in $.mobile.textinput.prototype.options ) {
  11800. if ( options[ idx ] !== undefined ) {
  11801. if ( idx === "theme" && this.options.filterTheme != null ) {
  11802. textinputOptions[ idx ] = this.options.filterTheme;
  11803. } else {
  11804. textinputOptions[ idx ] = options[ idx ];
  11805. }
  11806. }
  11807. }
  11808. this._search.textinput( "option", textinputOptions );
  11809. }
  11810. }
  11811. });
  11812. // Instantiate a filterable on a listview that has the data-filter="true" attribute
  11813. // This is not necessary for static content, because the auto-enhance takes care of instantiating
  11814. // the filterable upon encountering data-filter="true". However, because of 1.3.x it is expected
  11815. // that a listview with data-filter="true" will be filterable even if you just instantiate a
  11816. // listview on it. The extension below ensures that this continues to happen in 1.4.x.
  11817. $.widget( "mobile.listview", $.mobile.listview, {
  11818. options: {
  11819. filter: false
  11820. },
  11821. _create: function() {
  11822. if ( this.options.filter === true &&
  11823. !this.element.data( "mobile-filterable" ) ) {
  11824. this.element.filterable();
  11825. }
  11826. return this._super();
  11827. },
  11828. refresh: function() {
  11829. var filterable;
  11830. this._superApply( arguments );
  11831. if ( this.options.filter === true ) {
  11832. filterable = this.element.data( "mobile-filterable" );
  11833. if ( filterable ) {
  11834. filterable.refresh();
  11835. }
  11836. }
  11837. }
  11838. });
  11839. })( jQuery );
  11840. /*!
  11841. * jQuery UI Tabs fadf2b312a05040436451c64bbfaf4814bc62c56
  11842. * http://jqueryui.com
  11843. *
  11844. * Copyright 2013 jQuery Foundation and other contributors
  11845. * Released under the MIT license.
  11846. * http://jquery.org/license
  11847. *
  11848. * http://api.jqueryui.com/tabs/
  11849. *
  11850. * Depends:
  11851. * jquery.ui.core.js
  11852. * jquery.ui.widget.js
  11853. */
  11854. (function( $, undefined ) {
  11855. var tabId = 0,
  11856. rhash = /#.*$/;
  11857. function getNextTabId() {
  11858. return ++tabId;
  11859. }
  11860. function isLocal( anchor ) {
  11861. return anchor.hash.length > 1 &&
  11862. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  11863. decodeURIComponent( location.href.replace( rhash, "" ) );
  11864. }
  11865. $.widget( "ui.tabs", {
  11866. version: "fadf2b312a05040436451c64bbfaf4814bc62c56",
  11867. delay: 300,
  11868. options: {
  11869. active: null,
  11870. collapsible: false,
  11871. event: "click",
  11872. heightStyle: "content",
  11873. hide: null,
  11874. show: null,
  11875. // callbacks
  11876. activate: null,
  11877. beforeActivate: null,
  11878. beforeLoad: null,
  11879. load: null
  11880. },
  11881. _create: function() {
  11882. var that = this,
  11883. options = this.options;
  11884. this.running = false;
  11885. this.element
  11886. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11887. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11888. // Prevent users from focusing disabled tabs via click
  11889. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11890. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11891. event.preventDefault();
  11892. }
  11893. })
  11894. // support: IE <9
  11895. // Preventing the default action in mousedown doesn't prevent IE
  11896. // from focusing the element, so if the anchor gets focused, blur.
  11897. // We don't have to worry about focusing the previously focused
  11898. // element since clicking on a non-focusable element should focus
  11899. // the body anyway.
  11900. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11901. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11902. this.blur();
  11903. }
  11904. });
  11905. this._processTabs();
  11906. options.active = this._initialActive();
  11907. // Take disabling tabs via class attribute from HTML
  11908. // into account and update option properly.
  11909. if ( $.isArray( options.disabled ) ) {
  11910. options.disabled = $.unique( options.disabled.concat(
  11911. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11912. return that.tabs.index( li );
  11913. })
  11914. ) ).sort();
  11915. }
  11916. // check for length avoids error when initializing empty list
  11917. if ( this.options.active !== false && this.anchors.length ) {
  11918. this.active = this._findActive( options.active );
  11919. } else {
  11920. this.active = $();
  11921. }
  11922. this._refresh();
  11923. if ( this.active.length ) {
  11924. this.load( options.active );
  11925. }
  11926. },
  11927. _initialActive: function() {
  11928. var active = this.options.active,
  11929. collapsible = this.options.collapsible,
  11930. locationHash = location.hash.substring( 1 );
  11931. if ( active === null ) {
  11932. // check the fragment identifier in the URL
  11933. if ( locationHash ) {
  11934. this.tabs.each(function( i, tab ) {
  11935. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11936. active = i;
  11937. return false;
  11938. }
  11939. });
  11940. }
  11941. // check for a tab marked active via a class
  11942. if ( active === null ) {
  11943. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11944. }
  11945. // no active tab, set to false
  11946. if ( active === null || active === -1 ) {
  11947. active = this.tabs.length ? 0 : false;
  11948. }
  11949. }
  11950. // handle numbers: negative, out of range
  11951. if ( active !== false ) {
  11952. active = this.tabs.index( this.tabs.eq( active ) );
  11953. if ( active === -1 ) {
  11954. active = collapsible ? false : 0;
  11955. }
  11956. }
  11957. // don't allow collapsible: false and active: false
  11958. if ( !collapsible && active === false && this.anchors.length ) {
  11959. active = 0;
  11960. }
  11961. return active;
  11962. },
  11963. _getCreateEventData: function() {
  11964. return {
  11965. tab: this.active,
  11966. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11967. };
  11968. },
  11969. _tabKeydown: function( event ) {
  11970. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11971. selectedIndex = this.tabs.index( focusedTab ),
  11972. goingForward = true;
  11973. if ( this._handlePageNav( event ) ) {
  11974. return;
  11975. }
  11976. switch ( event.keyCode ) {
  11977. case $.ui.keyCode.RIGHT:
  11978. case $.ui.keyCode.DOWN:
  11979. selectedIndex++;
  11980. break;
  11981. case $.ui.keyCode.UP:
  11982. case $.ui.keyCode.LEFT:
  11983. goingForward = false;
  11984. selectedIndex--;
  11985. break;
  11986. case $.ui.keyCode.END:
  11987. selectedIndex = this.anchors.length - 1;
  11988. break;
  11989. case $.ui.keyCode.HOME:
  11990. selectedIndex = 0;
  11991. break;
  11992. case $.ui.keyCode.SPACE:
  11993. // Activate only, no collapsing
  11994. event.preventDefault();
  11995. clearTimeout( this.activating );
  11996. this._activate( selectedIndex );
  11997. return;
  11998. case $.ui.keyCode.ENTER:
  11999. // Toggle (cancel delayed activation, allow collapsing)
  12000. event.preventDefault();
  12001. clearTimeout( this.activating );
  12002. // Determine if we should collapse or activate
  12003. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  12004. return;
  12005. default:
  12006. return;
  12007. }
  12008. // Focus the appropriate tab, based on which key was pressed
  12009. event.preventDefault();
  12010. clearTimeout( this.activating );
  12011. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  12012. // Navigating with control key will prevent automatic activation
  12013. if ( !event.ctrlKey ) {
  12014. // Update aria-selected immediately so that AT think the tab is already selected.
  12015. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  12016. // but the tab will already be activated by the time the announcement finishes.
  12017. focusedTab.attr( "aria-selected", "false" );
  12018. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  12019. this.activating = this._delay(function() {
  12020. this.option( "active", selectedIndex );
  12021. }, this.delay );
  12022. }
  12023. },
  12024. _panelKeydown: function( event ) {
  12025. if ( this._handlePageNav( event ) ) {
  12026. return;
  12027. }
  12028. // Ctrl+up moves focus to the current tab
  12029. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  12030. event.preventDefault();
  12031. this.active.focus();
  12032. }
  12033. },
  12034. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12035. _handlePageNav: function( event ) {
  12036. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12037. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12038. return true;
  12039. }
  12040. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12041. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12042. return true;
  12043. }
  12044. },
  12045. _findNextTab: function( index, goingForward ) {
  12046. var lastTabIndex = this.tabs.length - 1;
  12047. function constrain() {
  12048. if ( index > lastTabIndex ) {
  12049. index = 0;
  12050. }
  12051. if ( index < 0 ) {
  12052. index = lastTabIndex;
  12053. }
  12054. return index;
  12055. }
  12056. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12057. index = goingForward ? index + 1 : index - 1;
  12058. }
  12059. return index;
  12060. },
  12061. _focusNextTab: function( index, goingForward ) {
  12062. index = this._findNextTab( index, goingForward );
  12063. this.tabs.eq( index ).focus();
  12064. return index;
  12065. },
  12066. _setOption: function( key, value ) {
  12067. if ( key === "active" ) {
  12068. // _activate() will handle invalid values and update this.options
  12069. this._activate( value );
  12070. return;
  12071. }
  12072. if ( key === "disabled" ) {
  12073. // don't use the widget factory's disabled handling
  12074. this._setupDisabled( value );
  12075. return;
  12076. }
  12077. this._super( key, value);
  12078. if ( key === "collapsible" ) {
  12079. this.element.toggleClass( "ui-tabs-collapsible", value );
  12080. // Setting collapsible: false while collapsed; open first panel
  12081. if ( !value && this.options.active === false ) {
  12082. this._activate( 0 );
  12083. }
  12084. }
  12085. if ( key === "event" ) {
  12086. this._setupEvents( value );
  12087. }
  12088. if ( key === "heightStyle" ) {
  12089. this._setupHeightStyle( value );
  12090. }
  12091. },
  12092. _tabId: function( tab ) {
  12093. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  12094. },
  12095. _sanitizeSelector: function( hash ) {
  12096. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12097. },
  12098. refresh: function() {
  12099. var options = this.options,
  12100. lis = this.tablist.children( ":has(a[href])" );
  12101. // get disabled tabs from class attribute from HTML
  12102. // this will get converted to a boolean if needed in _refresh()
  12103. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12104. return lis.index( tab );
  12105. });
  12106. this._processTabs();
  12107. // was collapsed or no tabs
  12108. if ( options.active === false || !this.anchors.length ) {
  12109. options.active = false;
  12110. this.active = $();
  12111. // was active, but active tab is gone
  12112. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12113. // all remaining tabs are disabled
  12114. if ( this.tabs.length === options.disabled.length ) {
  12115. options.active = false;
  12116. this.active = $();
  12117. // activate previous tab
  12118. } else {
  12119. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12120. }
  12121. // was active, active tab still exists
  12122. } else {
  12123. // make sure active index is correct
  12124. options.active = this.tabs.index( this.active );
  12125. }
  12126. this._refresh();
  12127. },
  12128. _refresh: function() {
  12129. this._setupDisabled( this.options.disabled );
  12130. this._setupEvents( this.options.event );
  12131. this._setupHeightStyle( this.options.heightStyle );
  12132. this.tabs.not( this.active ).attr({
  12133. "aria-selected": "false",
  12134. tabIndex: -1
  12135. });
  12136. this.panels.not( this._getPanelForTab( this.active ) )
  12137. .hide()
  12138. .attr({
  12139. "aria-expanded": "false",
  12140. "aria-hidden": "true"
  12141. });
  12142. // Make sure one tab is in the tab order
  12143. if ( !this.active.length ) {
  12144. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12145. } else {
  12146. this.active
  12147. .addClass( "ui-tabs-active ui-state-active" )
  12148. .attr({
  12149. "aria-selected": "true",
  12150. tabIndex: 0
  12151. });
  12152. this._getPanelForTab( this.active )
  12153. .show()
  12154. .attr({
  12155. "aria-expanded": "true",
  12156. "aria-hidden": "false"
  12157. });
  12158. }
  12159. },
  12160. _processTabs: function() {
  12161. var that = this;
  12162. this.tablist = this._getList()
  12163. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12164. .attr( "role", "tablist" );
  12165. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12166. .addClass( "ui-state-default ui-corner-top" )
  12167. .attr({
  12168. role: "tab",
  12169. tabIndex: -1
  12170. });
  12171. this.anchors = this.tabs.map(function() {
  12172. return $( "a", this )[ 0 ];
  12173. })
  12174. .addClass( "ui-tabs-anchor" )
  12175. .attr({
  12176. role: "presentation",
  12177. tabIndex: -1
  12178. });
  12179. this.panels = $();
  12180. this.anchors.each(function( i, anchor ) {
  12181. var selector, panel, panelId,
  12182. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12183. tab = $( anchor ).closest( "li" ),
  12184. originalAriaControls = tab.attr( "aria-controls" );
  12185. // inline tab
  12186. if ( isLocal( anchor ) ) {
  12187. selector = anchor.hash;
  12188. panel = that.element.find( that._sanitizeSelector( selector ) );
  12189. // remote tab
  12190. } else {
  12191. panelId = that._tabId( tab );
  12192. selector = "#" + panelId;
  12193. panel = that.element.find( selector );
  12194. if ( !panel.length ) {
  12195. panel = that._createPanel( panelId );
  12196. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12197. }
  12198. panel.attr( "aria-live", "polite" );
  12199. }
  12200. if ( panel.length) {
  12201. that.panels = that.panels.add( panel );
  12202. }
  12203. if ( originalAriaControls ) {
  12204. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12205. }
  12206. tab.attr({
  12207. "aria-controls": selector.substring( 1 ),
  12208. "aria-labelledby": anchorId
  12209. });
  12210. panel.attr( "aria-labelledby", anchorId );
  12211. });
  12212. this.panels
  12213. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12214. .attr( "role", "tabpanel" );
  12215. },
  12216. // allow overriding how to find the list for rare usage scenarios (#7715)
  12217. _getList: function() {
  12218. return this.element.find( "ol,ul" ).eq( 0 );
  12219. },
  12220. _createPanel: function( id ) {
  12221. return $( "<div>" )
  12222. .attr( "id", id )
  12223. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12224. .data( "ui-tabs-destroy", true );
  12225. },
  12226. _setupDisabled: function( disabled ) {
  12227. if ( $.isArray( disabled ) ) {
  12228. if ( !disabled.length ) {
  12229. disabled = false;
  12230. } else if ( disabled.length === this.anchors.length ) {
  12231. disabled = true;
  12232. }
  12233. }
  12234. // disable tabs
  12235. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  12236. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  12237. $( li )
  12238. .addClass( "ui-state-disabled" )
  12239. .attr( "aria-disabled", "true" );
  12240. } else {
  12241. $( li )
  12242. .removeClass( "ui-state-disabled" )
  12243. .removeAttr( "aria-disabled" );
  12244. }
  12245. }
  12246. this.options.disabled = disabled;
  12247. },
  12248. _setupEvents: function( event ) {
  12249. var events = {
  12250. click: function( event ) {
  12251. event.preventDefault();
  12252. }
  12253. };
  12254. if ( event ) {
  12255. $.each( event.split(" "), function( index, eventName ) {
  12256. events[ eventName ] = "_eventHandler";
  12257. });
  12258. }
  12259. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  12260. this._on( this.anchors, events );
  12261. this._on( this.tabs, { keydown: "_tabKeydown" } );
  12262. this._on( this.panels, { keydown: "_panelKeydown" } );
  12263. this._focusable( this.tabs );
  12264. this._hoverable( this.tabs );
  12265. },
  12266. _setupHeightStyle: function( heightStyle ) {
  12267. var maxHeight,
  12268. parent = this.element.parent();
  12269. if ( heightStyle === "fill" ) {
  12270. maxHeight = parent.height();
  12271. maxHeight -= this.element.outerHeight() - this.element.height();
  12272. this.element.siblings( ":visible" ).each(function() {
  12273. var elem = $( this ),
  12274. position = elem.css( "position" );
  12275. if ( position === "absolute" || position === "fixed" ) {
  12276. return;
  12277. }
  12278. maxHeight -= elem.outerHeight( true );
  12279. });
  12280. this.element.children().not( this.panels ).each(function() {
  12281. maxHeight -= $( this ).outerHeight( true );
  12282. });
  12283. this.panels.each(function() {
  12284. $( this ).height( Math.max( 0, maxHeight -
  12285. $( this ).innerHeight() + $( this ).height() ) );
  12286. })
  12287. .css( "overflow", "auto" );
  12288. } else if ( heightStyle === "auto" ) {
  12289. maxHeight = 0;
  12290. this.panels.each(function() {
  12291. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  12292. }).height( maxHeight );
  12293. }
  12294. },
  12295. _eventHandler: function( event ) {
  12296. var options = this.options,
  12297. active = this.active,
  12298. anchor = $( event.currentTarget ),
  12299. tab = anchor.closest( "li" ),
  12300. clickedIsActive = tab[ 0 ] === active[ 0 ],
  12301. collapsing = clickedIsActive && options.collapsible,
  12302. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  12303. toHide = !active.length ? $() : this._getPanelForTab( active ),
  12304. eventData = {
  12305. oldTab: active,
  12306. oldPanel: toHide,
  12307. newTab: collapsing ? $() : tab,
  12308. newPanel: toShow
  12309. };
  12310. event.preventDefault();
  12311. if ( tab.hasClass( "ui-state-disabled" ) ||
  12312. // tab is already loading
  12313. tab.hasClass( "ui-tabs-loading" ) ||
  12314. // can't switch durning an animation
  12315. this.running ||
  12316. // click on active header, but not collapsible
  12317. ( clickedIsActive && !options.collapsible ) ||
  12318. // allow canceling activation
  12319. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  12320. return;
  12321. }
  12322. options.active = collapsing ? false : this.tabs.index( tab );
  12323. this.active = clickedIsActive ? $() : tab;
  12324. if ( this.xhr ) {
  12325. this.xhr.abort();
  12326. }
  12327. if ( !toHide.length && !toShow.length ) {
  12328. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  12329. }
  12330. if ( toShow.length ) {
  12331. this.load( this.tabs.index( tab ), event );
  12332. }
  12333. this._toggle( event, eventData );
  12334. },
  12335. // handles show/hide for selecting tabs
  12336. _toggle: function( event, eventData ) {
  12337. var that = this,
  12338. toShow = eventData.newPanel,
  12339. toHide = eventData.oldPanel;
  12340. this.running = true;
  12341. function complete() {
  12342. that.running = false;
  12343. that._trigger( "activate", event, eventData );
  12344. }
  12345. function show() {
  12346. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12347. if ( toShow.length && that.options.show ) {
  12348. that._show( toShow, that.options.show, complete );
  12349. } else {
  12350. toShow.show();
  12351. complete();
  12352. }
  12353. }
  12354. // start out by hiding, then showing, then completing
  12355. if ( toHide.length && this.options.hide ) {
  12356. this._hide( toHide, this.options.hide, function() {
  12357. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12358. show();
  12359. });
  12360. } else {
  12361. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12362. toHide.hide();
  12363. show();
  12364. }
  12365. toHide.attr({
  12366. "aria-expanded": "false",
  12367. "aria-hidden": "true"
  12368. });
  12369. eventData.oldTab.attr( "aria-selected", "false" );
  12370. // If we're switching tabs, remove the old tab from the tab order.
  12371. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12372. // If we're collapsing, then keep the collapsing tab in the tab order.
  12373. if ( toShow.length && toHide.length ) {
  12374. eventData.oldTab.attr( "tabIndex", -1 );
  12375. } else if ( toShow.length ) {
  12376. this.tabs.filter(function() {
  12377. return $( this ).attr( "tabIndex" ) === 0;
  12378. })
  12379. .attr( "tabIndex", -1 );
  12380. }
  12381. toShow.attr({
  12382. "aria-expanded": "true",
  12383. "aria-hidden": "false"
  12384. });
  12385. eventData.newTab.attr({
  12386. "aria-selected": "true",
  12387. tabIndex: 0
  12388. });
  12389. },
  12390. _activate: function( index ) {
  12391. var anchor,
  12392. active = this._findActive( index );
  12393. // trying to activate the already active panel
  12394. if ( active[ 0 ] === this.active[ 0 ] ) {
  12395. return;
  12396. }
  12397. // trying to collapse, simulate a click on the current active header
  12398. if ( !active.length ) {
  12399. active = this.active;
  12400. }
  12401. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  12402. this._eventHandler({
  12403. target: anchor,
  12404. currentTarget: anchor,
  12405. preventDefault: $.noop
  12406. });
  12407. },
  12408. _findActive: function( index ) {
  12409. return index === false ? $() : this.tabs.eq( index );
  12410. },
  12411. _getIndex: function( index ) {
  12412. // meta-function to give users option to provide a href string instead of a numerical index.
  12413. if ( typeof index === "string" ) {
  12414. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  12415. }
  12416. return index;
  12417. },
  12418. _destroy: function() {
  12419. if ( this.xhr ) {
  12420. this.xhr.abort();
  12421. }
  12422. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  12423. this.tablist
  12424. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12425. .removeAttr( "role" );
  12426. this.anchors
  12427. .removeClass( "ui-tabs-anchor" )
  12428. .removeAttr( "role" )
  12429. .removeAttr( "tabIndex" )
  12430. .removeUniqueId();
  12431. this.tabs.add( this.panels ).each(function() {
  12432. if ( $.data( this, "ui-tabs-destroy" ) ) {
  12433. $( this ).remove();
  12434. } else {
  12435. $( this )
  12436. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  12437. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  12438. .removeAttr( "tabIndex" )
  12439. .removeAttr( "aria-live" )
  12440. .removeAttr( "aria-busy" )
  12441. .removeAttr( "aria-selected" )
  12442. .removeAttr( "aria-labelledby" )
  12443. .removeAttr( "aria-hidden" )
  12444. .removeAttr( "aria-expanded" )
  12445. .removeAttr( "role" );
  12446. }
  12447. });
  12448. this.tabs.each(function() {
  12449. var li = $( this ),
  12450. prev = li.data( "ui-tabs-aria-controls" );
  12451. if ( prev ) {
  12452. li
  12453. .attr( "aria-controls", prev )
  12454. .removeData( "ui-tabs-aria-controls" );
  12455. } else {
  12456. li.removeAttr( "aria-controls" );
  12457. }
  12458. });
  12459. this.panels.show();
  12460. if ( this.options.heightStyle !== "content" ) {
  12461. this.panels.css( "height", "" );
  12462. }
  12463. },
  12464. enable: function( index ) {
  12465. var disabled = this.options.disabled;
  12466. if ( disabled === false ) {
  12467. return;
  12468. }
  12469. if ( index === undefined ) {
  12470. disabled = false;
  12471. } else {
  12472. index = this._getIndex( index );
  12473. if ( $.isArray( disabled ) ) {
  12474. disabled = $.map( disabled, function( num ) {
  12475. return num !== index ? num : null;
  12476. });
  12477. } else {
  12478. disabled = $.map( this.tabs, function( li, num ) {
  12479. return num !== index ? num : null;
  12480. });
  12481. }
  12482. }
  12483. this._setupDisabled( disabled );
  12484. },
  12485. disable: function( index ) {
  12486. var disabled = this.options.disabled;
  12487. if ( disabled === true ) {
  12488. return;
  12489. }
  12490. if ( index === undefined ) {
  12491. disabled = true;
  12492. } else {
  12493. index = this._getIndex( index );
  12494. if ( $.inArray( index, disabled ) !== -1 ) {
  12495. return;
  12496. }
  12497. if ( $.isArray( disabled ) ) {
  12498. disabled = $.merge( [ index ], disabled ).sort();
  12499. } else {
  12500. disabled = [ index ];
  12501. }
  12502. }
  12503. this._setupDisabled( disabled );
  12504. },
  12505. load: function( index, event ) {
  12506. index = this._getIndex( index );
  12507. var that = this,
  12508. tab = this.tabs.eq( index ),
  12509. anchor = tab.find( ".ui-tabs-anchor" ),
  12510. panel = this._getPanelForTab( tab ),
  12511. eventData = {
  12512. tab: tab,
  12513. panel: panel
  12514. };
  12515. // not remote
  12516. if ( isLocal( anchor[ 0 ] ) ) {
  12517. return;
  12518. }
  12519. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  12520. // support: jQuery <1.8
  12521. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  12522. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12523. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  12524. tab.addClass( "ui-tabs-loading" );
  12525. panel.attr( "aria-busy", "true" );
  12526. this.xhr
  12527. .success(function( response ) {
  12528. // support: jQuery <1.8
  12529. // http://bugs.jquery.com/ticket/11778
  12530. setTimeout(function() {
  12531. panel.html( response );
  12532. that._trigger( "load", event, eventData );
  12533. }, 1 );
  12534. })
  12535. .complete(function( jqXHR, status ) {
  12536. // support: jQuery <1.8
  12537. // http://bugs.jquery.com/ticket/11778
  12538. setTimeout(function() {
  12539. if ( status === "abort" ) {
  12540. that.panels.stop( false, true );
  12541. }
  12542. tab.removeClass( "ui-tabs-loading" );
  12543. panel.removeAttr( "aria-busy" );
  12544. if ( jqXHR === that.xhr ) {
  12545. delete that.xhr;
  12546. }
  12547. }, 1 );
  12548. });
  12549. }
  12550. },
  12551. _ajaxSettings: function( anchor, event, eventData ) {
  12552. var that = this;
  12553. return {
  12554. url: anchor.attr( "href" ),
  12555. beforeSend: function( jqXHR, settings ) {
  12556. return that._trigger( "beforeLoad", event,
  12557. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  12558. }
  12559. };
  12560. },
  12561. _getPanelForTab: function( tab ) {
  12562. var id = $( tab ).attr( "aria-controls" );
  12563. return this.element.find( this._sanitizeSelector( "#" + id ) );
  12564. }
  12565. });
  12566. })( jQuery );
  12567. (function( $, undefined ) {
  12568. })( jQuery );
  12569. (function( $, window ) {
  12570. $.mobile.iosorientationfixEnabled = true;
  12571. // This fix addresses an iOS bug, so return early if the UA claims it's something else.
  12572. var ua = navigator.userAgent,
  12573. zoom,
  12574. evt, x, y, z, aig;
  12575. if ( !( /iPhone|iPad|iPod/.test( navigator.platform ) && /OS [1-5]_[0-9_]* like Mac OS X/i.test( ua ) && ua.indexOf( "AppleWebKit" ) > -1 ) ) {
  12576. $.mobile.iosorientationfixEnabled = false;
  12577. return;
  12578. }
  12579. zoom = $.mobile.zoom;
  12580. function checkTilt( e ) {
  12581. evt = e.originalEvent;
  12582. aig = evt.accelerationIncludingGravity;
  12583. x = Math.abs( aig.x );
  12584. y = Math.abs( aig.y );
  12585. z = Math.abs( aig.z );
  12586. // If portrait orientation and in one of the danger zones
  12587. if ( !window.orientation && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ) {
  12588. if ( zoom.enabled ) {
  12589. zoom.disable();
  12590. }
  12591. } else if ( !zoom.enabled ) {
  12592. zoom.enable();
  12593. }
  12594. }
  12595. $.mobile.document.on( "mobileinit", function() {
  12596. if ( $.mobile.iosorientationfixEnabled ) {
  12597. $.mobile.window
  12598. .bind( "orientationchange.iosorientationfix", zoom.enable )
  12599. .bind( "devicemotion.iosorientationfix", checkTilt );
  12600. }
  12601. });
  12602. }( jQuery, this ));
  12603. (function( $, window, undefined ) {
  12604. var $html = $( "html" ),
  12605. $window = $.mobile.window;
  12606. //remove initial build class (only present on first pageshow)
  12607. function hideRenderingClass() {
  12608. $html.removeClass( "ui-mobile-rendering" );
  12609. }
  12610. // trigger mobileinit event - useful hook for configuring $.mobile settings before they're used
  12611. $( window.document ).trigger( "mobileinit" );
  12612. // support conditions
  12613. // if device support condition(s) aren't met, leave things as they are -> a basic, usable experience,
  12614. // otherwise, proceed with the enhancements
  12615. if ( !$.mobile.gradeA() ) {
  12616. return;
  12617. }
  12618. // override ajaxEnabled on platforms that have known conflicts with hash history updates
  12619. // or generally work better browsing in regular http for full page refreshes (BB5, Opera Mini)
  12620. if ( $.mobile.ajaxBlacklist ) {
  12621. $.mobile.ajaxEnabled = false;
  12622. }
  12623. // Add mobile, initial load "rendering" classes to docEl
  12624. $html.addClass( "ui-mobile ui-mobile-rendering" );
  12625. // This is a fallback. If anything goes wrong (JS errors, etc), or events don't fire,
  12626. // this ensures the rendering class is removed after 5 seconds, so content is visible and accessible
  12627. setTimeout( hideRenderingClass, 5000 );
  12628. $.extend( $.mobile, {
  12629. // find and enhance the pages in the dom and transition to the first page.
  12630. initializePage: function() {
  12631. // find present pages
  12632. var path = $.mobile.path,
  12633. $pages = $( ":jqmData(role='page'), :jqmData(role='dialog')" ),
  12634. hash = path.stripHash( path.stripQueryParams(path.parseLocation().hash) ),
  12635. theLocation = $.mobile.path.parseLocation(),
  12636. hashPage = hash ? document.getElementById( hash ) : undefined;
  12637. // if no pages are found, create one with body's inner html
  12638. if ( !$pages.length ) {
  12639. $pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 );
  12640. }
  12641. // add dialogs, set data-url attrs
  12642. $pages.each(function() {
  12643. var $this = $( this );
  12644. // unless the data url is already set set it to the pathname
  12645. if ( !$this[ 0 ].getAttribute( "data-" + $.mobile.ns + "url" ) ) {
  12646. $this.attr( "data-" + $.mobile.ns + "url", $this.attr( "id" ) ||
  12647. path.convertUrlToDataUrl( theLocation.pathname + theLocation.search ) );
  12648. }
  12649. });
  12650. // define first page in dom case one backs out to the directory root (not always the first page visited, but defined as fallback)
  12651. $.mobile.firstPage = $pages.first();
  12652. // define page container
  12653. $.mobile.pageContainer = $.mobile.firstPage
  12654. .parent()
  12655. .addClass( "ui-mobile-viewport" )
  12656. .pagecontainer();
  12657. // initialize navigation events now, after mobileinit has occurred and the page container
  12658. // has been created but before the rest of the library is alerted to that fact
  12659. $.mobile.navreadyDeferred.resolve();
  12660. // alert listeners that the pagecontainer has been determined for binding
  12661. // to events triggered on it
  12662. $window.trigger( "pagecontainercreate" );
  12663. // cue page loading message
  12664. $.mobile.loading( "show" );
  12665. //remove initial build class (only present on first pageshow)
  12666. hideRenderingClass();
  12667. // if hashchange listening is disabled, there's no hash deeplink,
  12668. // the hash is not valid (contains more than one # or does not start with #)
  12669. // or there is no page with that hash, change to the first page in the DOM
  12670. // Remember, however, that the hash can also be a path!
  12671. if ( ! ( $.mobile.hashListeningEnabled &&
  12672. $.mobile.path.isHashValid( location.hash ) &&
  12673. ( $( hashPage ).is( ":jqmData(role='page')" ) ||
  12674. $.mobile.path.isPath( hash ) ||
  12675. hash === $.mobile.dialogHashKey ) ) ) {
  12676. // make sure to set initial popstate state if it exists
  12677. // so that navigation back to the initial page works properly
  12678. if ( $.event.special.navigate.isPushStateEnabled() ) {
  12679. $.mobile.navigate.navigator.squash( path.parseLocation().href );
  12680. }
  12681. $.mobile.changePage( $.mobile.firstPage, {
  12682. transition: "none",
  12683. reverse: true,
  12684. changeHash: false,
  12685. fromHashChange: true
  12686. });
  12687. } else {
  12688. // trigger hashchange or navigate to squash and record the correct
  12689. // history entry for an initial hash path
  12690. if ( !$.event.special.navigate.isPushStateEnabled() ) {
  12691. $window.trigger( "hashchange", [true] );
  12692. } else {
  12693. // TODO figure out how to simplify this interaction with the initial history entry
  12694. // at the bottom js/navigate/navigate.js
  12695. $.mobile.navigate.history.stack = [];
  12696. $.mobile.navigate( $.mobile.path.isPath( location.hash ) ? location.hash : location.href );
  12697. }
  12698. }
  12699. }
  12700. });
  12701. $(function() {
  12702. //Run inlineSVG support test
  12703. $.support.inlineSVG();
  12704. // check which scrollTop value should be used by scrolling to 1 immediately at domready
  12705. // then check what the scroll top is. Android will report 0... others 1
  12706. // note that this initial scroll won't hide the address bar. It's just for the check.
  12707. // hide iOS browser chrome on load if hideUrlBar is true this is to try and do it as soon as possible
  12708. if ( $.mobile.hideUrlBar ) {
  12709. window.scrollTo( 0, 1 );
  12710. }
  12711. // if defaultHomeScroll hasn't been set yet, see if scrollTop is 1
  12712. // it should be 1 in most browsers, but android treats 1 as 0 (for hiding addr bar)
  12713. // so if it's 1, use 0 from now on
  12714. $.mobile.defaultHomeScroll = ( !$.support.scrollTop || $.mobile.window.scrollTop() === 1 ) ? 0 : 1;
  12715. //dom-ready inits
  12716. if ( $.mobile.autoInitializePage ) {
  12717. $.mobile.initializePage();
  12718. }
  12719. // window load event
  12720. // hide iOS browser chrome on load if hideUrlBar is true this is as fall back incase we were too early before
  12721. if ( $.mobile.hideUrlBar ) {
  12722. $window.load( $.mobile.silentScroll );
  12723. }
  12724. if ( !$.support.cssPointerEvents ) {
  12725. // IE and Opera don't support CSS pointer-events: none that we use to disable link-based buttons
  12726. // by adding the 'ui-disabled' class to them. Using a JavaScript workaround for those browser.
  12727. // https://github.com/jquery/jquery-mobile/issues/3558
  12728. // DEPRECATED as of 1.4.0 - remove ui-disabled after 1.4.0 release
  12729. // only ui-state-disabled should be present thereafter
  12730. $.mobile.document.delegate( ".ui-state-disabled,.ui-disabled", "vclick",
  12731. function( e ) {
  12732. e.preventDefault();
  12733. e.stopImmediatePropagation();
  12734. }
  12735. );
  12736. }
  12737. });
  12738. }( jQuery, this ));
  12739. }));