select2.full.js 372 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389
  1. /**
  2. * @license almond 0.2.9 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
  3. * Available via the MIT or new BSD license.
  4. * see: http://github.com/jrburke/almond for details
  5. */
  6. //Going sloppy to avoid 'use strict' string cost, but strict practices should
  7. //be followed.
  8. /*jslint sloppy: true */
  9. /*global setTimeout: false */
  10. var requirejs, require, define;
  11. (function (undef) {
  12. var main, req, makeMap, handlers,
  13. defined = {},
  14. waiting = {},
  15. config = {},
  16. defining = {},
  17. hasOwn = Object.prototype.hasOwnProperty,
  18. aps = [].slice,
  19. jsSuffixRegExp = /\.js$/;
  20. function hasProp(obj, prop) {
  21. return hasOwn.call(obj, prop);
  22. }
  23. /**
  24. * Given a relative module name, like ./something, normalize it to
  25. * a real name that can be mapped to a path.
  26. * @param {String} name the relative name
  27. * @param {String} baseName a real name that the name arg is relative
  28. * to.
  29. * @returns {String} normalized name
  30. */
  31. function normalize(name, baseName) {
  32. var nameParts, nameSegment, mapValue, foundMap, lastIndex,
  33. foundI, foundStarMap, starI, i, j, part,
  34. baseParts = baseName && baseName.split("/"),
  35. map = config.map,
  36. starMap = (map && map['*']) || {};
  37. //Adjust any relative paths.
  38. if (name && name.charAt(0) === ".") {
  39. //If have a base name, try to normalize against it,
  40. //otherwise, assume it is a top-level require that will
  41. //be relative to baseUrl in the end.
  42. if (baseName) {
  43. //Convert baseName to array, and lop off the last part,
  44. //so that . matches that "directory" and not name of the baseName's
  45. //module. For instance, baseName of "one/two/three", maps to
  46. //"one/two/three.js", but we want the directory, "one/two" for
  47. //this normalization.
  48. baseParts = baseParts.slice(0, baseParts.length - 1);
  49. name = name.split('/');
  50. lastIndex = name.length - 1;
  51. // Node .js allowance:
  52. if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
  53. name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
  54. }
  55. name = baseParts.concat(name);
  56. //start trimDots
  57. for (i = 0; i < name.length; i += 1) {
  58. part = name[i];
  59. if (part === ".") {
  60. name.splice(i, 1);
  61. i -= 1;
  62. } else if (part === "..") {
  63. if (i === 1 && (name[2] === '..' || name[0] === '..')) {
  64. //End of the line. Keep at least one non-dot
  65. //path segment at the front so it can be mapped
  66. //correctly to disk. Otherwise, there is likely
  67. //no path mapping for a path starting with '..'.
  68. //This can still fail, but catches the most reasonable
  69. //uses of ..
  70. break;
  71. } else if (i > 0) {
  72. name.splice(i - 1, 2);
  73. i -= 2;
  74. }
  75. }
  76. }
  77. //end trimDots
  78. name = name.join("/");
  79. } else if (name.indexOf('./') === 0) {
  80. // No baseName, so this is ID is resolved relative
  81. // to baseUrl, pull off the leading dot.
  82. name = name.substring(2);
  83. }
  84. }
  85. //Apply map config if available.
  86. if ((baseParts || starMap) && map) {
  87. nameParts = name.split('/');
  88. for (i = nameParts.length; i > 0; i -= 1) {
  89. nameSegment = nameParts.slice(0, i).join("/");
  90. if (baseParts) {
  91. //Find the longest baseName segment match in the config.
  92. //So, do joins on the biggest to smallest lengths of baseParts.
  93. for (j = baseParts.length; j > 0; j -= 1) {
  94. mapValue = map[baseParts.slice(0, j).join('/')];
  95. //baseName segment has config, find if it has one for
  96. //this name.
  97. if (mapValue) {
  98. mapValue = mapValue[nameSegment];
  99. if (mapValue) {
  100. //Match, update name to the new value.
  101. foundMap = mapValue;
  102. foundI = i;
  103. break;
  104. }
  105. }
  106. }
  107. }
  108. if (foundMap) {
  109. break;
  110. }
  111. //Check for a star map match, but just hold on to it,
  112. //if there is a shorter segment match later in a matching
  113. //config, then favor over this star map.
  114. if (!foundStarMap && starMap && starMap[nameSegment]) {
  115. foundStarMap = starMap[nameSegment];
  116. starI = i;
  117. }
  118. }
  119. if (!foundMap && foundStarMap) {
  120. foundMap = foundStarMap;
  121. foundI = starI;
  122. }
  123. if (foundMap) {
  124. nameParts.splice(0, foundI, foundMap);
  125. name = nameParts.join('/');
  126. }
  127. }
  128. return name;
  129. }
  130. function makeRequire(relName, forceSync) {
  131. return function () {
  132. //A version of a require function that passes a moduleName
  133. //value for items that may need to
  134. //look up paths relative to the moduleName
  135. return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync]));
  136. };
  137. }
  138. function makeNormalize(relName) {
  139. return function (name) {
  140. return normalize(name, relName);
  141. };
  142. }
  143. function makeLoad(depName) {
  144. return function (value) {
  145. defined[depName] = value;
  146. };
  147. }
  148. function callDep(name) {
  149. if (hasProp(waiting, name)) {
  150. var args = waiting[name];
  151. delete waiting[name];
  152. defining[name] = true;
  153. main.apply(undef, args);
  154. }
  155. if (!hasProp(defined, name) && !hasProp(defining, name)) {
  156. throw new Error('No ' + name);
  157. }
  158. return defined[name];
  159. }
  160. //Turns a plugin!resource to [plugin, resource]
  161. //with the plugin being undefined if the name
  162. //did not have a plugin prefix.
  163. function splitPrefix(name) {
  164. var prefix,
  165. index = name ? name.indexOf('!') : -1;
  166. if (index > -1) {
  167. prefix = name.substring(0, index);
  168. name = name.substring(index + 1, name.length);
  169. }
  170. return [prefix, name];
  171. }
  172. /**
  173. * Makes a name map, normalizing the name, and using a plugin
  174. * for normalization if necessary. Grabs a ref to plugin
  175. * too, as an optimization.
  176. */
  177. makeMap = function (name, relName) {
  178. var plugin,
  179. parts = splitPrefix(name),
  180. prefix = parts[0];
  181. name = parts[1];
  182. if (prefix) {
  183. prefix = normalize(prefix, relName);
  184. plugin = callDep(prefix);
  185. }
  186. //Normalize according
  187. if (prefix) {
  188. if (plugin && plugin.normalize) {
  189. name = plugin.normalize(name, makeNormalize(relName));
  190. } else {
  191. name = normalize(name, relName);
  192. }
  193. } else {
  194. name = normalize(name, relName);
  195. parts = splitPrefix(name);
  196. prefix = parts[0];
  197. name = parts[1];
  198. if (prefix) {
  199. plugin = callDep(prefix);
  200. }
  201. }
  202. //Using ridiculous property names for space reasons
  203. return {
  204. f: prefix ? prefix + '!' + name : name, //fullName
  205. n: name,
  206. pr: prefix,
  207. p: plugin
  208. };
  209. };
  210. function makeConfig(name) {
  211. return function () {
  212. return (config && config.config && config.config[name]) || {};
  213. };
  214. }
  215. handlers = {
  216. require: function (name) {
  217. return makeRequire(name);
  218. },
  219. exports: function (name) {
  220. var e = defined[name];
  221. if (typeof e !== 'undefined') {
  222. return e;
  223. } else {
  224. return (defined[name] = {});
  225. }
  226. },
  227. module: function (name) {
  228. return {
  229. id: name,
  230. uri: '',
  231. exports: defined[name],
  232. config: makeConfig(name)
  233. };
  234. }
  235. };
  236. main = function (name, deps, callback, relName) {
  237. var cjsModule, depName, ret, map, i,
  238. args = [],
  239. callbackType = typeof callback,
  240. usingExports;
  241. //Use name if no relName
  242. relName = relName || name;
  243. //Call the callback to define the module, if necessary.
  244. if (callbackType === 'undefined' || callbackType === 'function') {
  245. //Pull out the defined dependencies and pass the ordered
  246. //values to the callback.
  247. //Default to [require, exports, module] if no deps
  248. deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
  249. for (i = 0; i < deps.length; i += 1) {
  250. map = makeMap(deps[i], relName);
  251. depName = map.f;
  252. //Fast path CommonJS standard dependencies.
  253. if (depName === "require") {
  254. args[i] = handlers.require(name);
  255. } else if (depName === "exports") {
  256. //CommonJS module spec 1.1
  257. args[i] = handlers.exports(name);
  258. usingExports = true;
  259. } else if (depName === "module") {
  260. //CommonJS module spec 1.1
  261. cjsModule = args[i] = handlers.module(name);
  262. } else if (hasProp(defined, depName) ||
  263. hasProp(waiting, depName) ||
  264. hasProp(defining, depName)) {
  265. args[i] = callDep(depName);
  266. } else if (map.p) {
  267. map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
  268. args[i] = defined[depName];
  269. } else {
  270. throw new Error(name + ' missing ' + depName);
  271. }
  272. }
  273. ret = callback ? callback.apply(defined[name], args) : undefined;
  274. if (name) {
  275. //If setting exports via "module" is in play,
  276. //favor that over return value and exports. After that,
  277. //favor a non-undefined return value over exports use.
  278. if (cjsModule && cjsModule.exports !== undef &&
  279. cjsModule.exports !== defined[name]) {
  280. defined[name] = cjsModule.exports;
  281. } else if (ret !== undef || !usingExports) {
  282. //Use the return value from the function.
  283. defined[name] = ret;
  284. }
  285. }
  286. } else if (name) {
  287. //May just be an object definition for the module. Only
  288. //worry about defining if have a module name.
  289. defined[name] = callback;
  290. }
  291. };
  292. requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
  293. if (typeof deps === "string") {
  294. if (handlers[deps]) {
  295. //callback in this case is really relName
  296. return handlers[deps](callback);
  297. }
  298. //Just return the module wanted. In this scenario, the
  299. //deps arg is the module name, and second arg (if passed)
  300. //is just the relName.
  301. //Normalize module name, if it contains . or ..
  302. return callDep(makeMap(deps, callback).f);
  303. } else if (!deps.splice) {
  304. //deps is a config object, not an array.
  305. config = deps;
  306. if (config.deps) {
  307. req(config.deps, config.callback);
  308. }
  309. if (!callback) {
  310. return;
  311. }
  312. if (callback.splice) {
  313. //callback is an array, which means it is a dependency list.
  314. //Adjust args if there are dependencies
  315. deps = callback;
  316. callback = relName;
  317. relName = null;
  318. } else {
  319. deps = undef;
  320. }
  321. }
  322. //Support require(['a'])
  323. callback = callback || function () {};
  324. //If relName is a function, it is an errback handler,
  325. //so remove it.
  326. if (typeof relName === 'function') {
  327. relName = forceSync;
  328. forceSync = alt;
  329. }
  330. //Simulate async callback;
  331. if (forceSync) {
  332. main(undef, deps, callback, relName);
  333. } else {
  334. //Using a non-zero value because of concern for what old browsers
  335. //do, and latest browsers "upgrade" to 4 if lower value is used:
  336. //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
  337. //If want a value immediately, use require('id') instead -- something
  338. //that works in almond on the global level, but not guaranteed and
  339. //unlikely to work in other AMD implementations.
  340. setTimeout(function () {
  341. main(undef, deps, callback, relName);
  342. }, 4);
  343. }
  344. return req;
  345. };
  346. /**
  347. * Just drops the config on the floor, but returns req in case
  348. * the config return value is used.
  349. */
  350. req.config = function (cfg) {
  351. return req(cfg);
  352. };
  353. /**
  354. * Expose module registry for debugging and tooling
  355. */
  356. requirejs._defined = defined;
  357. define = function (name, deps, callback) {
  358. //This module may not have dependencies
  359. if (!deps.splice) {
  360. //deps is not an array, so probably means
  361. //an object literal or factory function for
  362. //the value. Adjust args.
  363. callback = deps;
  364. deps = [];
  365. }
  366. if (!hasProp(defined, name) && !hasProp(waiting, name)) {
  367. waiting[name] = [name, deps, callback];
  368. }
  369. };
  370. define.amd = {
  371. jQuery: true
  372. };
  373. }());
  374. define("almond", function(){});
  375. /*!
  376. * jQuery JavaScript Library v2.1.0
  377. * http://jquery.com/
  378. *
  379. * Includes Sizzle.js
  380. * http://sizzlejs.com/
  381. *
  382. * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
  383. * Released under the MIT license
  384. * http://jquery.org/license
  385. *
  386. * Date: 2014-01-23T21:10Z
  387. */
  388. (function( global, factory ) {
  389. if ( typeof module === "object" && typeof module.exports === "object" ) {
  390. // For CommonJS and CommonJS-like environments where a proper window is present,
  391. // execute the factory and get jQuery
  392. // For environments that do not inherently posses a window with a document
  393. // (such as Node.js), expose a jQuery-making factory as module.exports
  394. // This accentuates the need for the creation of a real window
  395. // e.g. var jQuery = require("jquery")(window);
  396. // See ticket #14549 for more info
  397. module.exports = global.document ?
  398. factory( global, true ) :
  399. function( w ) {
  400. if ( !w.document ) {
  401. throw new Error( "jQuery requires a window with a document" );
  402. }
  403. return factory( w );
  404. };
  405. } else {
  406. factory( global );
  407. }
  408. // Pass this if window is not defined yet
  409. }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  410. // Can't do this because several apps including ASP.NET trace
  411. // the stack via arguments.caller.callee and Firefox dies if
  412. // you try to trace through "use strict" call chains. (#13335)
  413. // Support: Firefox 18+
  414. //
  415. var arr = [];
  416. var slice = arr.slice;
  417. var concat = arr.concat;
  418. var push = arr.push;
  419. var indexOf = arr.indexOf;
  420. var class2type = {};
  421. var toString = class2type.toString;
  422. var hasOwn = class2type.hasOwnProperty;
  423. var trim = "".trim;
  424. var support = {};
  425. var
  426. // Use the correct document accordingly with window argument (sandbox)
  427. document = window.document,
  428. version = "2.1.0",
  429. // Define a local copy of jQuery
  430. jQuery = function( selector, context ) {
  431. // The jQuery object is actually just the init constructor 'enhanced'
  432. // Need init if jQuery is called (just allow error to be thrown if not included)
  433. return new jQuery.fn.init( selector, context );
  434. },
  435. // Matches dashed string for camelizing
  436. rmsPrefix = /^-ms-/,
  437. rdashAlpha = /-([\da-z])/gi,
  438. // Used by jQuery.camelCase as callback to replace()
  439. fcamelCase = function( all, letter ) {
  440. return letter.toUpperCase();
  441. };
  442. jQuery.fn = jQuery.prototype = {
  443. // The current version of jQuery being used
  444. jquery: version,
  445. constructor: jQuery,
  446. // Start with an empty selector
  447. selector: "",
  448. // The default length of a jQuery object is 0
  449. length: 0,
  450. toArray: function() {
  451. return slice.call( this );
  452. },
  453. // Get the Nth element in the matched element set OR
  454. // Get the whole matched element set as a clean array
  455. get: function( num ) {
  456. return num != null ?
  457. // Return a 'clean' array
  458. ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
  459. // Return just the object
  460. slice.call( this );
  461. },
  462. // Take an array of elements and push it onto the stack
  463. // (returning the new matched element set)
  464. pushStack: function( elems ) {
  465. // Build a new jQuery matched element set
  466. var ret = jQuery.merge( this.constructor(), elems );
  467. // Add the old object onto the stack (as a reference)
  468. ret.prevObject = this;
  469. ret.context = this.context;
  470. // Return the newly-formed element set
  471. return ret;
  472. },
  473. // Execute a callback for every element in the matched set.
  474. // (You can seed the arguments with an array of args, but this is
  475. // only used internally.)
  476. each: function( callback, args ) {
  477. return jQuery.each( this, callback, args );
  478. },
  479. map: function( callback ) {
  480. return this.pushStack( jQuery.map(this, function( elem, i ) {
  481. return callback.call( elem, i, elem );
  482. }));
  483. },
  484. slice: function() {
  485. return this.pushStack( slice.apply( this, arguments ) );
  486. },
  487. first: function() {
  488. return this.eq( 0 );
  489. },
  490. last: function() {
  491. return this.eq( -1 );
  492. },
  493. eq: function( i ) {
  494. var len = this.length,
  495. j = +i + ( i < 0 ? len : 0 );
  496. return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
  497. },
  498. end: function() {
  499. return this.prevObject || this.constructor(null);
  500. },
  501. // For internal use only.
  502. // Behaves like an Array's method, not like a jQuery method.
  503. push: push,
  504. sort: arr.sort,
  505. splice: arr.splice
  506. };
  507. jQuery.extend = jQuery.fn.extend = function() {
  508. var options, name, src, copy, copyIsArray, clone,
  509. target = arguments[0] || {},
  510. i = 1,
  511. length = arguments.length,
  512. deep = false;
  513. // Handle a deep copy situation
  514. if ( typeof target === "boolean" ) {
  515. deep = target;
  516. // skip the boolean and the target
  517. target = arguments[ i ] || {};
  518. i++;
  519. }
  520. // Handle case when target is a string or something (possible in deep copy)
  521. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  522. target = {};
  523. }
  524. // extend jQuery itself if only one argument is passed
  525. if ( i === length ) {
  526. target = this;
  527. i--;
  528. }
  529. for ( ; i < length; i++ ) {
  530. // Only deal with non-null/undefined values
  531. if ( (options = arguments[ i ]) != null ) {
  532. // Extend the base object
  533. for ( name in options ) {
  534. src = target[ name ];
  535. copy = options[ name ];
  536. // Prevent never-ending loop
  537. if ( target === copy ) {
  538. continue;
  539. }
  540. // Recurse if we're merging plain objects or arrays
  541. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  542. if ( copyIsArray ) {
  543. copyIsArray = false;
  544. clone = src && jQuery.isArray(src) ? src : [];
  545. } else {
  546. clone = src && jQuery.isPlainObject(src) ? src : {};
  547. }
  548. // Never move original objects, clone them
  549. target[ name ] = jQuery.extend( deep, clone, copy );
  550. // Don't bring in undefined values
  551. } else if ( copy !== undefined ) {
  552. target[ name ] = copy;
  553. }
  554. }
  555. }
  556. }
  557. // Return the modified object
  558. return target;
  559. };
  560. jQuery.extend({
  561. // Unique for each copy of jQuery on the page
  562. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  563. // Assume jQuery is ready without the ready module
  564. isReady: true,
  565. error: function( msg ) {
  566. throw new Error( msg );
  567. },
  568. noop: function() {},
  569. // See test/unit/core.js for details concerning isFunction.
  570. // Since version 1.3, DOM methods and functions like alert
  571. // aren't supported. They return false on IE (#2968).
  572. isFunction: function( obj ) {
  573. return jQuery.type(obj) === "function";
  574. },
  575. isArray: Array.isArray,
  576. isWindow: function( obj ) {
  577. return obj != null && obj === obj.window;
  578. },
  579. isNumeric: function( obj ) {
  580. // parseFloat NaNs numeric-cast false positives (null|true|false|"")
  581. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  582. // subtraction forces infinities to NaN
  583. return obj - parseFloat( obj ) >= 0;
  584. },
  585. isPlainObject: function( obj ) {
  586. // Not plain objects:
  587. // - Any object or value whose internal [[Class]] property is not "[object Object]"
  588. // - DOM nodes
  589. // - window
  590. if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  591. return false;
  592. }
  593. // Support: Firefox <20
  594. // The try/catch suppresses exceptions thrown when attempting to access
  595. // the "constructor" property of certain host objects, ie. |window.location|
  596. // https://bugzilla.mozilla.org/show_bug.cgi?id=814622
  597. try {
  598. if ( obj.constructor &&
  599. !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
  600. return false;
  601. }
  602. } catch ( e ) {
  603. return false;
  604. }
  605. // If the function hasn't returned already, we're confident that
  606. // |obj| is a plain object, created by {} or constructed with new Object
  607. return true;
  608. },
  609. isEmptyObject: function( obj ) {
  610. var name;
  611. for ( name in obj ) {
  612. return false;
  613. }
  614. return true;
  615. },
  616. type: function( obj ) {
  617. if ( obj == null ) {
  618. return obj + "";
  619. }
  620. // Support: Android < 4.0, iOS < 6 (functionish RegExp)
  621. return typeof obj === "object" || typeof obj === "function" ?
  622. class2type[ toString.call(obj) ] || "object" :
  623. typeof obj;
  624. },
  625. // Evaluates a script in a global context
  626. globalEval: function( code ) {
  627. var script,
  628. indirect = eval;
  629. code = jQuery.trim( code );
  630. if ( code ) {
  631. // If the code includes a valid, prologue position
  632. // strict mode pragma, execute code by injecting a
  633. // script tag into the document.
  634. if ( code.indexOf("use strict") === 1 ) {
  635. script = document.createElement("script");
  636. script.text = code;
  637. document.head.appendChild( script ).parentNode.removeChild( script );
  638. } else {
  639. // Otherwise, avoid the DOM node creation, insertion
  640. // and removal by using an indirect global eval
  641. indirect( code );
  642. }
  643. }
  644. },
  645. // Convert dashed to camelCase; used by the css and data modules
  646. // Microsoft forgot to hump their vendor prefix (#9572)
  647. camelCase: function( string ) {
  648. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  649. },
  650. nodeName: function( elem, name ) {
  651. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  652. },
  653. // args is for internal usage only
  654. each: function( obj, callback, args ) {
  655. var value,
  656. i = 0,
  657. length = obj.length,
  658. isArray = isArraylike( obj );
  659. if ( args ) {
  660. if ( isArray ) {
  661. for ( ; i < length; i++ ) {
  662. value = callback.apply( obj[ i ], args );
  663. if ( value === false ) {
  664. break;
  665. }
  666. }
  667. } else {
  668. for ( i in obj ) {
  669. value = callback.apply( obj[ i ], args );
  670. if ( value === false ) {
  671. break;
  672. }
  673. }
  674. }
  675. // A special, fast, case for the most common use of each
  676. } else {
  677. if ( isArray ) {
  678. for ( ; i < length; i++ ) {
  679. value = callback.call( obj[ i ], i, obj[ i ] );
  680. if ( value === false ) {
  681. break;
  682. }
  683. }
  684. } else {
  685. for ( i in obj ) {
  686. value = callback.call( obj[ i ], i, obj[ i ] );
  687. if ( value === false ) {
  688. break;
  689. }
  690. }
  691. }
  692. }
  693. return obj;
  694. },
  695. trim: function( text ) {
  696. return text == null ? "" : trim.call( text );
  697. },
  698. // results is for internal usage only
  699. makeArray: function( arr, results ) {
  700. var ret = results || [];
  701. if ( arr != null ) {
  702. if ( isArraylike( Object(arr) ) ) {
  703. jQuery.merge( ret,
  704. typeof arr === "string" ?
  705. [ arr ] : arr
  706. );
  707. } else {
  708. push.call( ret, arr );
  709. }
  710. }
  711. return ret;
  712. },
  713. inArray: function( elem, arr, i ) {
  714. return arr == null ? -1 : indexOf.call( arr, elem, i );
  715. },
  716. merge: function( first, second ) {
  717. var len = +second.length,
  718. j = 0,
  719. i = first.length;
  720. for ( ; j < len; j++ ) {
  721. first[ i++ ] = second[ j ];
  722. }
  723. first.length = i;
  724. return first;
  725. },
  726. grep: function( elems, callback, invert ) {
  727. var callbackInverse,
  728. matches = [],
  729. i = 0,
  730. length = elems.length,
  731. callbackExpect = !invert;
  732. // Go through the array, only saving the items
  733. // that pass the validator function
  734. for ( ; i < length; i++ ) {
  735. callbackInverse = !callback( elems[ i ], i );
  736. if ( callbackInverse !== callbackExpect ) {
  737. matches.push( elems[ i ] );
  738. }
  739. }
  740. return matches;
  741. },
  742. // arg is for internal usage only
  743. map: function( elems, callback, arg ) {
  744. var value,
  745. i = 0,
  746. length = elems.length,
  747. isArray = isArraylike( elems ),
  748. ret = [];
  749. // Go through the array, translating each of the items to their new values
  750. if ( isArray ) {
  751. for ( ; i < length; i++ ) {
  752. value = callback( elems[ i ], i, arg );
  753. if ( value != null ) {
  754. ret.push( value );
  755. }
  756. }
  757. // Go through every key on the object,
  758. } else {
  759. for ( i in elems ) {
  760. value = callback( elems[ i ], i, arg );
  761. if ( value != null ) {
  762. ret.push( value );
  763. }
  764. }
  765. }
  766. // Flatten any nested arrays
  767. return concat.apply( [], ret );
  768. },
  769. // A global GUID counter for objects
  770. guid: 1,
  771. // Bind a function to a context, optionally partially applying any
  772. // arguments.
  773. proxy: function( fn, context ) {
  774. var tmp, args, proxy;
  775. if ( typeof context === "string" ) {
  776. tmp = fn[ context ];
  777. context = fn;
  778. fn = tmp;
  779. }
  780. // Quick check to determine if target is callable, in the spec
  781. // this throws a TypeError, but we will just return undefined.
  782. if ( !jQuery.isFunction( fn ) ) {
  783. return undefined;
  784. }
  785. // Simulated bind
  786. args = slice.call( arguments, 2 );
  787. proxy = function() {
  788. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  789. };
  790. // Set the guid of unique handler to the same of original handler, so it can be removed
  791. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  792. return proxy;
  793. },
  794. now: Date.now,
  795. // jQuery.support is not used in Core but other projects attach their
  796. // properties to it so it needs to exist.
  797. support: support
  798. });
  799. // Populate the class2type map
  800. jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
  801. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  802. });
  803. function isArraylike( obj ) {
  804. var length = obj.length,
  805. type = jQuery.type( obj );
  806. if ( type === "function" || jQuery.isWindow( obj ) ) {
  807. return false;
  808. }
  809. if ( obj.nodeType === 1 && length ) {
  810. return true;
  811. }
  812. return type === "array" || length === 0 ||
  813. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  814. }
  815. var Sizzle =
  816. /*!
  817. * Sizzle CSS Selector Engine v1.10.16
  818. * http://sizzlejs.com/
  819. *
  820. * Copyright 2013 jQuery Foundation, Inc. and other contributors
  821. * Released under the MIT license
  822. * http://jquery.org/license
  823. *
  824. * Date: 2014-01-13
  825. */
  826. (function( window ) {
  827. var i,
  828. support,
  829. Expr,
  830. getText,
  831. isXML,
  832. compile,
  833. outermostContext,
  834. sortInput,
  835. hasDuplicate,
  836. // Local document vars
  837. setDocument,
  838. document,
  839. docElem,
  840. documentIsHTML,
  841. rbuggyQSA,
  842. rbuggyMatches,
  843. matches,
  844. contains,
  845. // Instance-specific data
  846. expando = "sizzle" + -(new Date()),
  847. preferredDoc = window.document,
  848. dirruns = 0,
  849. done = 0,
  850. classCache = createCache(),
  851. tokenCache = createCache(),
  852. compilerCache = createCache(),
  853. sortOrder = function( a, b ) {
  854. if ( a === b ) {
  855. hasDuplicate = true;
  856. }
  857. return 0;
  858. },
  859. // General-purpose constants
  860. strundefined = typeof undefined,
  861. MAX_NEGATIVE = 1 << 31,
  862. // Instance methods
  863. hasOwn = ({}).hasOwnProperty,
  864. arr = [],
  865. pop = arr.pop,
  866. push_native = arr.push,
  867. push = arr.push,
  868. slice = arr.slice,
  869. // Use a stripped-down indexOf if we can't use a native one
  870. indexOf = arr.indexOf || function( elem ) {
  871. var i = 0,
  872. len = this.length;
  873. for ( ; i < len; i++ ) {
  874. if ( this[i] === elem ) {
  875. return i;
  876. }
  877. }
  878. return -1;
  879. },
  880. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  881. // Regular expressions
  882. // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
  883. whitespace = "[\\x20\\t\\r\\n\\f]",
  884. // http://www.w3.org/TR/css3-syntax/#characters
  885. characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
  886. // Loosely modeled on CSS identifier characters
  887. // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
  888. // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  889. identifier = characterEncoding.replace( "w", "w#" ),
  890. // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
  891. attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
  892. "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
  893. // Prefer arguments quoted,
  894. // then not containing pseudos/brackets,
  895. // then attribute selectors/non-parenthetical expressions,
  896. // then anything else
  897. // These preferences are here to reduce the number of selectors
  898. // needing tokenize in the PSEUDO preFilter
  899. pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
  900. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  901. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  902. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  903. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  904. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  905. rpseudo = new RegExp( pseudos ),
  906. ridentifier = new RegExp( "^" + identifier + "$" ),
  907. matchExpr = {
  908. "ID": new RegExp( "^#(" + characterEncoding + ")" ),
  909. "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
  910. "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
  911. "ATTR": new RegExp( "^" + attributes ),
  912. "PSEUDO": new RegExp( "^" + pseudos ),
  913. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  914. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  915. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  916. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  917. // For use in libraries implementing .is()
  918. // We use this for POS matching in `select`
  919. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  920. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  921. },
  922. rinputs = /^(?:input|select|textarea|button)$/i,
  923. rheader = /^h\d$/i,
  924. rnative = /^[^{]+\{\s*\[native \w/,
  925. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  926. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  927. rsibling = /[+~]/,
  928. rescape = /'|\\/g,
  929. // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  930. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  931. funescape = function( _, escaped, escapedWhitespace ) {
  932. var high = "0x" + escaped - 0x10000;
  933. // NaN means non-codepoint
  934. // Support: Firefox
  935. // Workaround erroneous numeric interpretation of +"0x"
  936. return high !== high || escapedWhitespace ?
  937. escaped :
  938. high < 0 ?
  939. // BMP codepoint
  940. String.fromCharCode( high + 0x10000 ) :
  941. // Supplemental Plane codepoint (surrogate pair)
  942. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  943. };
  944. // Optimize for push.apply( _, NodeList )
  945. try {
  946. push.apply(
  947. (arr = slice.call( preferredDoc.childNodes )),
  948. preferredDoc.childNodes
  949. );
  950. // Support: Android<4.0
  951. // Detect silently failing push.apply
  952. arr[ preferredDoc.childNodes.length ].nodeType;
  953. } catch ( e ) {
  954. push = { apply: arr.length ?
  955. // Leverage slice if possible
  956. function( target, els ) {
  957. push_native.apply( target, slice.call(els) );
  958. } :
  959. // Support: IE<9
  960. // Otherwise append directly
  961. function( target, els ) {
  962. var j = target.length,
  963. i = 0;
  964. // Can't trust NodeList.length
  965. while ( (target[j++] = els[i++]) ) {}
  966. target.length = j - 1;
  967. }
  968. };
  969. }
  970. function Sizzle( selector, context, results, seed ) {
  971. var match, elem, m, nodeType,
  972. // QSA vars
  973. i, groups, old, nid, newContext, newSelector;
  974. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  975. setDocument( context );
  976. }
  977. context = context || document;
  978. results = results || [];
  979. if ( !selector || typeof selector !== "string" ) {
  980. return results;
  981. }
  982. if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
  983. return [];
  984. }
  985. if ( documentIsHTML && !seed ) {
  986. // Shortcuts
  987. if ( (match = rquickExpr.exec( selector )) ) {
  988. // Speed-up: Sizzle("#ID")
  989. if ( (m = match[1]) ) {
  990. if ( nodeType === 9 ) {
  991. elem = context.getElementById( m );
  992. // Check parentNode to catch when Blackberry 4.6 returns
  993. // nodes that are no longer in the document (jQuery #6963)
  994. if ( elem && elem.parentNode ) {
  995. // Handle the case where IE, Opera, and Webkit return items
  996. // by name instead of ID
  997. if ( elem.id === m ) {
  998. results.push( elem );
  999. return results;
  1000. }
  1001. } else {
  1002. return results;
  1003. }
  1004. } else {
  1005. // Context is not a document
  1006. if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
  1007. contains( context, elem ) && elem.id === m ) {
  1008. results.push( elem );
  1009. return results;
  1010. }
  1011. }
  1012. // Speed-up: Sizzle("TAG")
  1013. } else if ( match[2] ) {
  1014. push.apply( results, context.getElementsByTagName( selector ) );
  1015. return results;
  1016. // Speed-up: Sizzle(".CLASS")
  1017. } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
  1018. push.apply( results, context.getElementsByClassName( m ) );
  1019. return results;
  1020. }
  1021. }
  1022. // QSA path
  1023. if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  1024. nid = old = expando;
  1025. newContext = context;
  1026. newSelector = nodeType === 9 && selector;
  1027. // qSA works strangely on Element-rooted queries
  1028. // We can work around this by specifying an extra ID on the root
  1029. // and working up from there (Thanks to Andrew Dupont for the technique)
  1030. // IE 8 doesn't work on object elements
  1031. if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  1032. groups = tokenize( selector );
  1033. if ( (old = context.getAttribute("id")) ) {
  1034. nid = old.replace( rescape, "\\$&" );
  1035. } else {
  1036. context.setAttribute( "id", nid );
  1037. }
  1038. nid = "[id='" + nid + "'] ";
  1039. i = groups.length;
  1040. while ( i-- ) {
  1041. groups[i] = nid + toSelector( groups[i] );
  1042. }
  1043. newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
  1044. newSelector = groups.join(",");
  1045. }
  1046. if ( newSelector ) {
  1047. try {
  1048. push.apply( results,
  1049. newContext.querySelectorAll( newSelector )
  1050. );
  1051. return results;
  1052. } catch(qsaError) {
  1053. } finally {
  1054. if ( !old ) {
  1055. context.removeAttribute("id");
  1056. }
  1057. }
  1058. }
  1059. }
  1060. }
  1061. // All others
  1062. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  1063. }
  1064. /**
  1065. * Create key-value caches of limited size
  1066. * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
  1067. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  1068. * deleting the oldest entry
  1069. */
  1070. function createCache() {
  1071. var keys = [];
  1072. function cache( key, value ) {
  1073. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  1074. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  1075. // Only keep the most recent entries
  1076. delete cache[ keys.shift() ];
  1077. }
  1078. return (cache[ key + " " ] = value);
  1079. }
  1080. return cache;
  1081. }
  1082. /**
  1083. * Mark a function for special use by Sizzle
  1084. * @param {Function} fn The function to mark
  1085. */
  1086. function markFunction( fn ) {
  1087. fn[ expando ] = true;
  1088. return fn;
  1089. }
  1090. /**
  1091. * Support testing using an element
  1092. * @param {Function} fn Passed the created div and expects a boolean result
  1093. */
  1094. function assert( fn ) {
  1095. var div = document.createElement("div");
  1096. try {
  1097. return !!fn( div );
  1098. } catch (e) {
  1099. return false;
  1100. } finally {
  1101. // Remove from its parent by default
  1102. if ( div.parentNode ) {
  1103. div.parentNode.removeChild( div );
  1104. }
  1105. // release memory in IE
  1106. div = null;
  1107. }
  1108. }
  1109. /**
  1110. * Adds the same handler for all of the specified attrs
  1111. * @param {String} attrs Pipe-separated list of attributes
  1112. * @param {Function} handler The method that will be applied
  1113. */
  1114. function addHandle( attrs, handler ) {
  1115. var arr = attrs.split("|"),
  1116. i = attrs.length;
  1117. while ( i-- ) {
  1118. Expr.attrHandle[ arr[i] ] = handler;
  1119. }
  1120. }
  1121. /**
  1122. * Checks document order of two siblings
  1123. * @param {Element} a
  1124. * @param {Element} b
  1125. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  1126. */
  1127. function siblingCheck( a, b ) {
  1128. var cur = b && a,
  1129. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  1130. ( ~b.sourceIndex || MAX_NEGATIVE ) -
  1131. ( ~a.sourceIndex || MAX_NEGATIVE );
  1132. // Use IE sourceIndex if available on both nodes
  1133. if ( diff ) {
  1134. return diff;
  1135. }
  1136. // Check if b follows a
  1137. if ( cur ) {
  1138. while ( (cur = cur.nextSibling) ) {
  1139. if ( cur === b ) {
  1140. return -1;
  1141. }
  1142. }
  1143. }
  1144. return a ? 1 : -1;
  1145. }
  1146. /**
  1147. * Returns a function to use in pseudos for input types
  1148. * @param {String} type
  1149. */
  1150. function createInputPseudo( type ) {
  1151. return function( elem ) {
  1152. var name = elem.nodeName.toLowerCase();
  1153. return name === "input" && elem.type === type;
  1154. };
  1155. }
  1156. /**
  1157. * Returns a function to use in pseudos for buttons
  1158. * @param {String} type
  1159. */
  1160. function createButtonPseudo( type ) {
  1161. return function( elem ) {
  1162. var name = elem.nodeName.toLowerCase();
  1163. return (name === "input" || name === "button") && elem.type === type;
  1164. };
  1165. }
  1166. /**
  1167. * Returns a function to use in pseudos for positionals
  1168. * @param {Function} fn
  1169. */
  1170. function createPositionalPseudo( fn ) {
  1171. return markFunction(function( argument ) {
  1172. argument = +argument;
  1173. return markFunction(function( seed, matches ) {
  1174. var j,
  1175. matchIndexes = fn( [], seed.length, argument ),
  1176. i = matchIndexes.length;
  1177. // Match elements found at the specified indexes
  1178. while ( i-- ) {
  1179. if ( seed[ (j = matchIndexes[i]) ] ) {
  1180. seed[j] = !(matches[j] = seed[j]);
  1181. }
  1182. }
  1183. });
  1184. });
  1185. }
  1186. /**
  1187. * Checks a node for validity as a Sizzle context
  1188. * @param {Element|Object=} context
  1189. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  1190. */
  1191. function testContext( context ) {
  1192. return context && typeof context.getElementsByTagName !== strundefined && context;
  1193. }
  1194. // Expose support vars for convenience
  1195. support = Sizzle.support = {};
  1196. /**
  1197. * Detects XML nodes
  1198. * @param {Element|Object} elem An element or a document
  1199. * @returns {Boolean} True iff elem is a non-HTML XML node
  1200. */
  1201. isXML = Sizzle.isXML = function( elem ) {
  1202. // documentElement is verified for cases where it doesn't yet exist
  1203. // (such as loading iframes in IE - #4833)
  1204. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  1205. return documentElement ? documentElement.nodeName !== "HTML" : false;
  1206. };
  1207. /**
  1208. * Sets document-related variables once based on the current document
  1209. * @param {Element|Object} [doc] An element or document object to use to set the document
  1210. * @returns {Object} Returns the current document
  1211. */
  1212. setDocument = Sizzle.setDocument = function( node ) {
  1213. var hasCompare,
  1214. doc = node ? node.ownerDocument || node : preferredDoc,
  1215. parent = doc.defaultView;
  1216. // If no document and documentElement is available, return
  1217. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  1218. return document;
  1219. }
  1220. // Set our document
  1221. document = doc;
  1222. docElem = doc.documentElement;
  1223. // Support tests
  1224. documentIsHTML = !isXML( doc );
  1225. // Support: IE>8
  1226. // If iframe document is assigned to "document" variable and if iframe has been reloaded,
  1227. // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
  1228. // IE6-8 do not support the defaultView property so parent will be undefined
  1229. if ( parent && parent !== parent.top ) {
  1230. // IE11 does not have attachEvent, so all must suffer
  1231. if ( parent.addEventListener ) {
  1232. parent.addEventListener( "unload", function() {
  1233. setDocument();
  1234. }, false );
  1235. } else if ( parent.attachEvent ) {
  1236. parent.attachEvent( "onunload", function() {
  1237. setDocument();
  1238. });
  1239. }
  1240. }
  1241. /* Attributes
  1242. ---------------------------------------------------------------------- */
  1243. // Support: IE<8
  1244. // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
  1245. support.attributes = assert(function( div ) {
  1246. div.className = "i";
  1247. return !div.getAttribute("className");
  1248. });
  1249. /* getElement(s)By*
  1250. ---------------------------------------------------------------------- */
  1251. // Check if getElementsByTagName("*") returns only elements
  1252. support.getElementsByTagName = assert(function( div ) {
  1253. div.appendChild( doc.createComment("") );
  1254. return !div.getElementsByTagName("*").length;
  1255. });
  1256. // Check if getElementsByClassName can be trusted
  1257. support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
  1258. div.innerHTML = "<div class='a'></div><div class='a i'></div>";
  1259. // Support: Safari<4
  1260. // Catch class over-caching
  1261. div.firstChild.className = "i";
  1262. // Support: Opera<10
  1263. // Catch gEBCN failure to find non-leading classes
  1264. return div.getElementsByClassName("i").length === 2;
  1265. });
  1266. // Support: IE<10
  1267. // Check if getElementById returns elements by name
  1268. // The broken getElementById methods don't pick up programatically-set names,
  1269. // so use a roundabout getElementsByName test
  1270. support.getById = assert(function( div ) {
  1271. docElem.appendChild( div ).id = expando;
  1272. return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
  1273. });
  1274. // ID find and filter
  1275. if ( support.getById ) {
  1276. Expr.find["ID"] = function( id, context ) {
  1277. if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
  1278. var m = context.getElementById( id );
  1279. // Check parentNode to catch when Blackberry 4.6 returns
  1280. // nodes that are no longer in the document #6963
  1281. return m && m.parentNode ? [m] : [];
  1282. }
  1283. };
  1284. Expr.filter["ID"] = function( id ) {
  1285. var attrId = id.replace( runescape, funescape );
  1286. return function( elem ) {
  1287. return elem.getAttribute("id") === attrId;
  1288. };
  1289. };
  1290. } else {
  1291. // Support: IE6/7
  1292. // getElementById is not reliable as a find shortcut
  1293. delete Expr.find["ID"];
  1294. Expr.filter["ID"] = function( id ) {
  1295. var attrId = id.replace( runescape, funescape );
  1296. return function( elem ) {
  1297. var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
  1298. return node && node.value === attrId;
  1299. };
  1300. };
  1301. }
  1302. // Tag
  1303. Expr.find["TAG"] = support.getElementsByTagName ?
  1304. function( tag, context ) {
  1305. if ( typeof context.getElementsByTagName !== strundefined ) {
  1306. return context.getElementsByTagName( tag );
  1307. }
  1308. } :
  1309. function( tag, context ) {
  1310. var elem,
  1311. tmp = [],
  1312. i = 0,
  1313. results = context.getElementsByTagName( tag );
  1314. // Filter out possible comments
  1315. if ( tag === "*" ) {
  1316. while ( (elem = results[i++]) ) {
  1317. if ( elem.nodeType === 1 ) {
  1318. tmp.push( elem );
  1319. }
  1320. }
  1321. return tmp;
  1322. }
  1323. return results;
  1324. };
  1325. // Class
  1326. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  1327. if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
  1328. return context.getElementsByClassName( className );
  1329. }
  1330. };
  1331. /* QSA/matchesSelector
  1332. ---------------------------------------------------------------------- */
  1333. // QSA and matchesSelector support
  1334. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  1335. rbuggyMatches = [];
  1336. // qSa(:focus) reports false when true (Chrome 21)
  1337. // We allow this because of a bug in IE8/9 that throws an error
  1338. // whenever `document.activeElement` is accessed on an iframe
  1339. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  1340. // See http://bugs.jquery.com/ticket/13378
  1341. rbuggyQSA = [];
  1342. if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
  1343. // Build QSA regex
  1344. // Regex strategy adopted from Diego Perini
  1345. assert(function( div ) {
  1346. // Select is set to empty string on purpose
  1347. // This is to test IE's treatment of not explicitly
  1348. // setting a boolean content attribute,
  1349. // since its presence should be enough
  1350. // http://bugs.jquery.com/ticket/12359
  1351. div.innerHTML = "<select t=''><option selected=''></option></select>";
  1352. // Support: IE8, Opera 10-12
  1353. // Nothing should be selected when empty strings follow ^= or $= or *=
  1354. if ( div.querySelectorAll("[t^='']").length ) {
  1355. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  1356. }
  1357. // Support: IE8
  1358. // Boolean attributes and "value" are not treated correctly
  1359. if ( !div.querySelectorAll("[selected]").length ) {
  1360. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  1361. }
  1362. // Webkit/Opera - :checked should return selected option elements
  1363. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1364. // IE8 throws error here and will not see later tests
  1365. if ( !div.querySelectorAll(":checked").length ) {
  1366. rbuggyQSA.push(":checked");
  1367. }
  1368. });
  1369. assert(function( div ) {
  1370. // Support: Windows 8 Native Apps
  1371. // The type and name attributes are restricted during .innerHTML assignment
  1372. var input = doc.createElement("input");
  1373. input.setAttribute( "type", "hidden" );
  1374. div.appendChild( input ).setAttribute( "name", "D" );
  1375. // Support: IE8
  1376. // Enforce case-sensitivity of name attribute
  1377. if ( div.querySelectorAll("[name=d]").length ) {
  1378. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  1379. }
  1380. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1381. // IE8 throws error here and will not see later tests
  1382. if ( !div.querySelectorAll(":enabled").length ) {
  1383. rbuggyQSA.push( ":enabled", ":disabled" );
  1384. }
  1385. // Opera 10-11 does not throw on post-comma invalid pseudos
  1386. div.querySelectorAll("*,:x");
  1387. rbuggyQSA.push(",.*:");
  1388. });
  1389. }
  1390. if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
  1391. docElem.mozMatchesSelector ||
  1392. docElem.oMatchesSelector ||
  1393. docElem.msMatchesSelector) )) ) {
  1394. assert(function( div ) {
  1395. // Check to see if it's possible to do matchesSelector
  1396. // on a disconnected node (IE 9)
  1397. support.disconnectedMatch = matches.call( div, "div" );
  1398. // This should fail with an exception
  1399. // Gecko does not error, returns false instead
  1400. matches.call( div, "[s!='']:x" );
  1401. rbuggyMatches.push( "!=", pseudos );
  1402. });
  1403. }
  1404. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  1405. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  1406. /* Contains
  1407. ---------------------------------------------------------------------- */
  1408. hasCompare = rnative.test( docElem.compareDocumentPosition );
  1409. // Element contains another
  1410. // Purposefully does not implement inclusive descendent
  1411. // As in, an element does not contain itself
  1412. contains = hasCompare || rnative.test( docElem.contains ) ?
  1413. function( a, b ) {
  1414. var adown = a.nodeType === 9 ? a.documentElement : a,
  1415. bup = b && b.parentNode;
  1416. return a === bup || !!( bup && bup.nodeType === 1 && (
  1417. adown.contains ?
  1418. adown.contains( bup ) :
  1419. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  1420. ));
  1421. } :
  1422. function( a, b ) {
  1423. if ( b ) {
  1424. while ( (b = b.parentNode) ) {
  1425. if ( b === a ) {
  1426. return true;
  1427. }
  1428. }
  1429. }
  1430. return false;
  1431. };
  1432. /* Sorting
  1433. ---------------------------------------------------------------------- */
  1434. // Document order sorting
  1435. sortOrder = hasCompare ?
  1436. function( a, b ) {
  1437. // Flag for duplicate removal
  1438. if ( a === b ) {
  1439. hasDuplicate = true;
  1440. return 0;
  1441. }
  1442. // Sort on method existence if only one input has compareDocumentPosition
  1443. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1444. if ( compare ) {
  1445. return compare;
  1446. }
  1447. // Calculate position if both inputs belong to the same document
  1448. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  1449. a.compareDocumentPosition( b ) :
  1450. // Otherwise we know they are disconnected
  1451. 1;
  1452. // Disconnected nodes
  1453. if ( compare & 1 ||
  1454. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  1455. // Choose the first element that is related to our preferred document
  1456. if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  1457. return -1;
  1458. }
  1459. if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  1460. return 1;
  1461. }
  1462. // Maintain original order
  1463. return sortInput ?
  1464. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1465. 0;
  1466. }
  1467. return compare & 4 ? -1 : 1;
  1468. } :
  1469. function( a, b ) {
  1470. // Exit early if the nodes are identical
  1471. if ( a === b ) {
  1472. hasDuplicate = true;
  1473. return 0;
  1474. }
  1475. var cur,
  1476. i = 0,
  1477. aup = a.parentNode,
  1478. bup = b.parentNode,
  1479. ap = [ a ],
  1480. bp = [ b ];
  1481. // Parentless nodes are either documents or disconnected
  1482. if ( !aup || !bup ) {
  1483. return a === doc ? -1 :
  1484. b === doc ? 1 :
  1485. aup ? -1 :
  1486. bup ? 1 :
  1487. sortInput ?
  1488. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1489. 0;
  1490. // If the nodes are siblings, we can do a quick check
  1491. } else if ( aup === bup ) {
  1492. return siblingCheck( a, b );
  1493. }
  1494. // Otherwise we need full lists of their ancestors for comparison
  1495. cur = a;
  1496. while ( (cur = cur.parentNode) ) {
  1497. ap.unshift( cur );
  1498. }
  1499. cur = b;
  1500. while ( (cur = cur.parentNode) ) {
  1501. bp.unshift( cur );
  1502. }
  1503. // Walk down the tree looking for a discrepancy
  1504. while ( ap[i] === bp[i] ) {
  1505. i++;
  1506. }
  1507. return i ?
  1508. // Do a sibling check if the nodes have a common ancestor
  1509. siblingCheck( ap[i], bp[i] ) :
  1510. // Otherwise nodes in our document sort first
  1511. ap[i] === preferredDoc ? -1 :
  1512. bp[i] === preferredDoc ? 1 :
  1513. 0;
  1514. };
  1515. return doc;
  1516. };
  1517. Sizzle.matches = function( expr, elements ) {
  1518. return Sizzle( expr, null, null, elements );
  1519. };
  1520. Sizzle.matchesSelector = function( elem, expr ) {
  1521. // Set document vars if needed
  1522. if ( ( elem.ownerDocument || elem ) !== document ) {
  1523. setDocument( elem );
  1524. }
  1525. // Make sure that attribute selectors are quoted
  1526. expr = expr.replace( rattributeQuotes, "='$1']" );
  1527. if ( support.matchesSelector && documentIsHTML &&
  1528. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  1529. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  1530. try {
  1531. var ret = matches.call( elem, expr );
  1532. // IE 9's matchesSelector returns false on disconnected nodes
  1533. if ( ret || support.disconnectedMatch ||
  1534. // As well, disconnected nodes are said to be in a document
  1535. // fragment in IE 9
  1536. elem.document && elem.document.nodeType !== 11 ) {
  1537. return ret;
  1538. }
  1539. } catch(e) {}
  1540. }
  1541. return Sizzle( expr, document, null, [elem] ).length > 0;
  1542. };
  1543. Sizzle.contains = function( context, elem ) {
  1544. // Set document vars if needed
  1545. if ( ( context.ownerDocument || context ) !== document ) {
  1546. setDocument( context );
  1547. }
  1548. return contains( context, elem );
  1549. };
  1550. Sizzle.attr = function( elem, name ) {
  1551. // Set document vars if needed
  1552. if ( ( elem.ownerDocument || elem ) !== document ) {
  1553. setDocument( elem );
  1554. }
  1555. var fn = Expr.attrHandle[ name.toLowerCase() ],
  1556. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1557. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  1558. fn( elem, name, !documentIsHTML ) :
  1559. undefined;
  1560. return val !== undefined ?
  1561. val :
  1562. support.attributes || !documentIsHTML ?
  1563. elem.getAttribute( name ) :
  1564. (val = elem.getAttributeNode(name)) && val.specified ?
  1565. val.value :
  1566. null;
  1567. };
  1568. Sizzle.error = function( msg ) {
  1569. throw new Error( "Syntax error, unrecognized expression: " + msg );
  1570. };
  1571. /**
  1572. * Document sorting and removing duplicates
  1573. * @param {ArrayLike} results
  1574. */
  1575. Sizzle.uniqueSort = function( results ) {
  1576. var elem,
  1577. duplicates = [],
  1578. j = 0,
  1579. i = 0;
  1580. // Unless we *know* we can detect duplicates, assume their presence
  1581. hasDuplicate = !support.detectDuplicates;
  1582. sortInput = !support.sortStable && results.slice( 0 );
  1583. results.sort( sortOrder );
  1584. if ( hasDuplicate ) {
  1585. while ( (elem = results[i++]) ) {
  1586. if ( elem === results[ i ] ) {
  1587. j = duplicates.push( i );
  1588. }
  1589. }
  1590. while ( j-- ) {
  1591. results.splice( duplicates[ j ], 1 );
  1592. }
  1593. }
  1594. // Clear input after sorting to release objects
  1595. // See https://github.com/jquery/sizzle/pull/225
  1596. sortInput = null;
  1597. return results;
  1598. };
  1599. /**
  1600. * Utility function for retrieving the text value of an array of DOM nodes
  1601. * @param {Array|Element} elem
  1602. */
  1603. getText = Sizzle.getText = function( elem ) {
  1604. var node,
  1605. ret = "",
  1606. i = 0,
  1607. nodeType = elem.nodeType;
  1608. if ( !nodeType ) {
  1609. // If no nodeType, this is expected to be an array
  1610. while ( (node = elem[i++]) ) {
  1611. // Do not traverse comment nodes
  1612. ret += getText( node );
  1613. }
  1614. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  1615. // Use textContent for elements
  1616. // innerText usage removed for consistency of new lines (jQuery #11153)
  1617. if ( typeof elem.textContent === "string" ) {
  1618. return elem.textContent;
  1619. } else {
  1620. // Traverse its children
  1621. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1622. ret += getText( elem );
  1623. }
  1624. }
  1625. } else if ( nodeType === 3 || nodeType === 4 ) {
  1626. return elem.nodeValue;
  1627. }
  1628. // Do not include comment or processing instruction nodes
  1629. return ret;
  1630. };
  1631. Expr = Sizzle.selectors = {
  1632. // Can be adjusted by the user
  1633. cacheLength: 50,
  1634. createPseudo: markFunction,
  1635. match: matchExpr,
  1636. attrHandle: {},
  1637. find: {},
  1638. relative: {
  1639. ">": { dir: "parentNode", first: true },
  1640. " ": { dir: "parentNode" },
  1641. "+": { dir: "previousSibling", first: true },
  1642. "~": { dir: "previousSibling" }
  1643. },
  1644. preFilter: {
  1645. "ATTR": function( match ) {
  1646. match[1] = match[1].replace( runescape, funescape );
  1647. // Move the given value to match[3] whether quoted or unquoted
  1648. match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
  1649. if ( match[2] === "~=" ) {
  1650. match[3] = " " + match[3] + " ";
  1651. }
  1652. return match.slice( 0, 4 );
  1653. },
  1654. "CHILD": function( match ) {
  1655. /* matches from matchExpr["CHILD"]
  1656. 1 type (only|nth|...)
  1657. 2 what (child|of-type)
  1658. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1659. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1660. 5 sign of xn-component
  1661. 6 x of xn-component
  1662. 7 sign of y-component
  1663. 8 y of y-component
  1664. */
  1665. match[1] = match[1].toLowerCase();
  1666. if ( match[1].slice( 0, 3 ) === "nth" ) {
  1667. // nth-* requires argument
  1668. if ( !match[3] ) {
  1669. Sizzle.error( match[0] );
  1670. }
  1671. // numeric x and y parameters for Expr.filter.CHILD
  1672. // remember that false/true cast respectively to 0/1
  1673. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  1674. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  1675. // other types prohibit arguments
  1676. } else if ( match[3] ) {
  1677. Sizzle.error( match[0] );
  1678. }
  1679. return match;
  1680. },
  1681. "PSEUDO": function( match ) {
  1682. var excess,
  1683. unquoted = !match[5] && match[2];
  1684. if ( matchExpr["CHILD"].test( match[0] ) ) {
  1685. return null;
  1686. }
  1687. // Accept quoted arguments as-is
  1688. if ( match[3] && match[4] !== undefined ) {
  1689. match[2] = match[4];
  1690. // Strip excess characters from unquoted arguments
  1691. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1692. // Get excess from tokenize (recursively)
  1693. (excess = tokenize( unquoted, true )) &&
  1694. // advance to the next closing parenthesis
  1695. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1696. // excess is a negative index
  1697. match[0] = match[0].slice( 0, excess );
  1698. match[2] = unquoted.slice( 0, excess );
  1699. }
  1700. // Return only captures needed by the pseudo filter method (type and argument)
  1701. return match.slice( 0, 3 );
  1702. }
  1703. },
  1704. filter: {
  1705. "TAG": function( nodeNameSelector ) {
  1706. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1707. return nodeNameSelector === "*" ?
  1708. function() { return true; } :
  1709. function( elem ) {
  1710. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1711. };
  1712. },
  1713. "CLASS": function( className ) {
  1714. var pattern = classCache[ className + " " ];
  1715. return pattern ||
  1716. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1717. classCache( className, function( elem ) {
  1718. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
  1719. });
  1720. },
  1721. "ATTR": function( name, operator, check ) {
  1722. return function( elem ) {
  1723. var result = Sizzle.attr( elem, name );
  1724. if ( result == null ) {
  1725. return operator === "!=";
  1726. }
  1727. if ( !operator ) {
  1728. return true;
  1729. }
  1730. result += "";
  1731. return operator === "=" ? result === check :
  1732. operator === "!=" ? result !== check :
  1733. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1734. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1735. operator === "$=" ? check && result.slice( -check.length ) === check :
  1736. operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
  1737. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1738. false;
  1739. };
  1740. },
  1741. "CHILD": function( type, what, argument, first, last ) {
  1742. var simple = type.slice( 0, 3 ) !== "nth",
  1743. forward = type.slice( -4 ) !== "last",
  1744. ofType = what === "of-type";
  1745. return first === 1 && last === 0 ?
  1746. // Shortcut for :nth-*(n)
  1747. function( elem ) {
  1748. return !!elem.parentNode;
  1749. } :
  1750. function( elem, context, xml ) {
  1751. var cache, outerCache, node, diff, nodeIndex, start,
  1752. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1753. parent = elem.parentNode,
  1754. name = ofType && elem.nodeName.toLowerCase(),
  1755. useCache = !xml && !ofType;
  1756. if ( parent ) {
  1757. // :(first|last|only)-(child|of-type)
  1758. if ( simple ) {
  1759. while ( dir ) {
  1760. node = elem;
  1761. while ( (node = node[ dir ]) ) {
  1762. if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
  1763. return false;
  1764. }
  1765. }
  1766. // Reverse direction for :only-* (if we haven't yet done so)
  1767. start = dir = type === "only" && !start && "nextSibling";
  1768. }
  1769. return true;
  1770. }
  1771. start = [ forward ? parent.firstChild : parent.lastChild ];
  1772. // non-xml :nth-child(...) stores cache data on `parent`
  1773. if ( forward && useCache ) {
  1774. // Seek `elem` from a previously-cached index
  1775. outerCache = parent[ expando ] || (parent[ expando ] = {});
  1776. cache = outerCache[ type ] || [];
  1777. nodeIndex = cache[0] === dirruns && cache[1];
  1778. diff = cache[0] === dirruns && cache[2];
  1779. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1780. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1781. // Fallback to seeking `elem` from the start
  1782. (diff = nodeIndex = 0) || start.pop()) ) {
  1783. // When found, cache indexes on `parent` and break
  1784. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1785. outerCache[ type ] = [ dirruns, nodeIndex, diff ];
  1786. break;
  1787. }
  1788. }
  1789. // Use previously-cached element index if available
  1790. } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
  1791. diff = cache[1];
  1792. // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1793. } else {
  1794. // Use the same loop as above to seek `elem` from the start
  1795. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1796. (diff = nodeIndex = 0) || start.pop()) ) {
  1797. if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
  1798. // Cache the index of each encountered element
  1799. if ( useCache ) {
  1800. (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
  1801. }
  1802. if ( node === elem ) {
  1803. break;
  1804. }
  1805. }
  1806. }
  1807. }
  1808. // Incorporate the offset, then check against cycle size
  1809. diff -= last;
  1810. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1811. }
  1812. };
  1813. },
  1814. "PSEUDO": function( pseudo, argument ) {
  1815. // pseudo-class names are case-insensitive
  1816. // http://www.w3.org/TR/selectors/#pseudo-classes
  1817. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1818. // Remember that setFilters inherits from pseudos
  1819. var args,
  1820. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1821. Sizzle.error( "unsupported pseudo: " + pseudo );
  1822. // The user may use createPseudo to indicate that
  1823. // arguments are needed to create the filter function
  1824. // just as Sizzle does
  1825. if ( fn[ expando ] ) {
  1826. return fn( argument );
  1827. }
  1828. // But maintain support for old signatures
  1829. if ( fn.length > 1 ) {
  1830. args = [ pseudo, pseudo, "", argument ];
  1831. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1832. markFunction(function( seed, matches ) {
  1833. var idx,
  1834. matched = fn( seed, argument ),
  1835. i = matched.length;
  1836. while ( i-- ) {
  1837. idx = indexOf.call( seed, matched[i] );
  1838. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1839. }
  1840. }) :
  1841. function( elem ) {
  1842. return fn( elem, 0, args );
  1843. };
  1844. }
  1845. return fn;
  1846. }
  1847. },
  1848. pseudos: {
  1849. // Potentially complex pseudos
  1850. "not": markFunction(function( selector ) {
  1851. // Trim the selector passed to compile
  1852. // to avoid treating leading and trailing
  1853. // spaces as combinators
  1854. var input = [],
  1855. results = [],
  1856. matcher = compile( selector.replace( rtrim, "$1" ) );
  1857. return matcher[ expando ] ?
  1858. markFunction(function( seed, matches, context, xml ) {
  1859. var elem,
  1860. unmatched = matcher( seed, null, xml, [] ),
  1861. i = seed.length;
  1862. // Match elements unmatched by `matcher`
  1863. while ( i-- ) {
  1864. if ( (elem = unmatched[i]) ) {
  1865. seed[i] = !(matches[i] = elem);
  1866. }
  1867. }
  1868. }) :
  1869. function( elem, context, xml ) {
  1870. input[0] = elem;
  1871. matcher( input, null, xml, results );
  1872. return !results.pop();
  1873. };
  1874. }),
  1875. "has": markFunction(function( selector ) {
  1876. return function( elem ) {
  1877. return Sizzle( selector, elem ).length > 0;
  1878. };
  1879. }),
  1880. "contains": markFunction(function( text ) {
  1881. return function( elem ) {
  1882. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  1883. };
  1884. }),
  1885. // "Whether an element is represented by a :lang() selector
  1886. // is based solely on the element's language value
  1887. // being equal to the identifier C,
  1888. // or beginning with the identifier C immediately followed by "-".
  1889. // The matching of C against the element's language value is performed case-insensitively.
  1890. // The identifier C does not have to be a valid language name."
  1891. // http://www.w3.org/TR/selectors/#lang-pseudo
  1892. "lang": markFunction( function( lang ) {
  1893. // lang value must be a valid identifier
  1894. if ( !ridentifier.test(lang || "") ) {
  1895. Sizzle.error( "unsupported lang: " + lang );
  1896. }
  1897. lang = lang.replace( runescape, funescape ).toLowerCase();
  1898. return function( elem ) {
  1899. var elemLang;
  1900. do {
  1901. if ( (elemLang = documentIsHTML ?
  1902. elem.lang :
  1903. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  1904. elemLang = elemLang.toLowerCase();
  1905. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  1906. }
  1907. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  1908. return false;
  1909. };
  1910. }),
  1911. // Miscellaneous
  1912. "target": function( elem ) {
  1913. var hash = window.location && window.location.hash;
  1914. return hash && hash.slice( 1 ) === elem.id;
  1915. },
  1916. "root": function( elem ) {
  1917. return elem === docElem;
  1918. },
  1919. "focus": function( elem ) {
  1920. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1921. },
  1922. // Boolean properties
  1923. "enabled": function( elem ) {
  1924. return elem.disabled === false;
  1925. },
  1926. "disabled": function( elem ) {
  1927. return elem.disabled === true;
  1928. },
  1929. "checked": function( elem ) {
  1930. // In CSS3, :checked should return both checked and selected elements
  1931. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1932. var nodeName = elem.nodeName.toLowerCase();
  1933. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1934. },
  1935. "selected": function( elem ) {
  1936. // Accessing this property makes selected-by-default
  1937. // options in Safari work properly
  1938. if ( elem.parentNode ) {
  1939. elem.parentNode.selectedIndex;
  1940. }
  1941. return elem.selected === true;
  1942. },
  1943. // Contents
  1944. "empty": function( elem ) {
  1945. // http://www.w3.org/TR/selectors/#empty-pseudo
  1946. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1947. // but not by others (comment: 8; processing instruction: 7; etc.)
  1948. // nodeType < 6 works because attributes (2) do not appear as children
  1949. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1950. if ( elem.nodeType < 6 ) {
  1951. return false;
  1952. }
  1953. }
  1954. return true;
  1955. },
  1956. "parent": function( elem ) {
  1957. return !Expr.pseudos["empty"]( elem );
  1958. },
  1959. // Element/input types
  1960. "header": function( elem ) {
  1961. return rheader.test( elem.nodeName );
  1962. },
  1963. "input": function( elem ) {
  1964. return rinputs.test( elem.nodeName );
  1965. },
  1966. "button": function( elem ) {
  1967. var name = elem.nodeName.toLowerCase();
  1968. return name === "input" && elem.type === "button" || name === "button";
  1969. },
  1970. "text": function( elem ) {
  1971. var attr;
  1972. return elem.nodeName.toLowerCase() === "input" &&
  1973. elem.type === "text" &&
  1974. // Support: IE<8
  1975. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1976. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  1977. },
  1978. // Position-in-collection
  1979. "first": createPositionalPseudo(function() {
  1980. return [ 0 ];
  1981. }),
  1982. "last": createPositionalPseudo(function( matchIndexes, length ) {
  1983. return [ length - 1 ];
  1984. }),
  1985. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1986. return [ argument < 0 ? argument + length : argument ];
  1987. }),
  1988. "even": createPositionalPseudo(function( matchIndexes, length ) {
  1989. var i = 0;
  1990. for ( ; i < length; i += 2 ) {
  1991. matchIndexes.push( i );
  1992. }
  1993. return matchIndexes;
  1994. }),
  1995. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  1996. var i = 1;
  1997. for ( ; i < length; i += 2 ) {
  1998. matchIndexes.push( i );
  1999. }
  2000. return matchIndexes;
  2001. }),
  2002. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  2003. var i = argument < 0 ? argument + length : argument;
  2004. for ( ; --i >= 0; ) {
  2005. matchIndexes.push( i );
  2006. }
  2007. return matchIndexes;
  2008. }),
  2009. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  2010. var i = argument < 0 ? argument + length : argument;
  2011. for ( ; ++i < length; ) {
  2012. matchIndexes.push( i );
  2013. }
  2014. return matchIndexes;
  2015. })
  2016. }
  2017. };
  2018. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  2019. // Add button/input type pseudos
  2020. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  2021. Expr.pseudos[ i ] = createInputPseudo( i );
  2022. }
  2023. for ( i in { submit: true, reset: true } ) {
  2024. Expr.pseudos[ i ] = createButtonPseudo( i );
  2025. }
  2026. // Easy API for creating new setFilters
  2027. function setFilters() {}
  2028. setFilters.prototype = Expr.filters = Expr.pseudos;
  2029. Expr.setFilters = new setFilters();
  2030. function tokenize( selector, parseOnly ) {
  2031. var matched, match, tokens, type,
  2032. soFar, groups, preFilters,
  2033. cached = tokenCache[ selector + " " ];
  2034. if ( cached ) {
  2035. return parseOnly ? 0 : cached.slice( 0 );
  2036. }
  2037. soFar = selector;
  2038. groups = [];
  2039. preFilters = Expr.preFilter;
  2040. while ( soFar ) {
  2041. // Comma and first run
  2042. if ( !matched || (match = rcomma.exec( soFar )) ) {
  2043. if ( match ) {
  2044. // Don't consume trailing commas as valid
  2045. soFar = soFar.slice( match[0].length ) || soFar;
  2046. }
  2047. groups.push( (tokens = []) );
  2048. }
  2049. matched = false;
  2050. // Combinators
  2051. if ( (match = rcombinators.exec( soFar )) ) {
  2052. matched = match.shift();
  2053. tokens.push({
  2054. value: matched,
  2055. // Cast descendant combinators to space
  2056. type: match[0].replace( rtrim, " " )
  2057. });
  2058. soFar = soFar.slice( matched.length );
  2059. }
  2060. // Filters
  2061. for ( type in Expr.filter ) {
  2062. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  2063. (match = preFilters[ type ]( match ))) ) {
  2064. matched = match.shift();
  2065. tokens.push({
  2066. value: matched,
  2067. type: type,
  2068. matches: match
  2069. });
  2070. soFar = soFar.slice( matched.length );
  2071. }
  2072. }
  2073. if ( !matched ) {
  2074. break;
  2075. }
  2076. }
  2077. // Return the length of the invalid excess
  2078. // if we're just parsing
  2079. // Otherwise, throw an error or return tokens
  2080. return parseOnly ?
  2081. soFar.length :
  2082. soFar ?
  2083. Sizzle.error( selector ) :
  2084. // Cache the tokens
  2085. tokenCache( selector, groups ).slice( 0 );
  2086. }
  2087. function toSelector( tokens ) {
  2088. var i = 0,
  2089. len = tokens.length,
  2090. selector = "";
  2091. for ( ; i < len; i++ ) {
  2092. selector += tokens[i].value;
  2093. }
  2094. return selector;
  2095. }
  2096. function addCombinator( matcher, combinator, base ) {
  2097. var dir = combinator.dir,
  2098. checkNonElements = base && dir === "parentNode",
  2099. doneName = done++;
  2100. return combinator.first ?
  2101. // Check against closest ancestor/preceding element
  2102. function( elem, context, xml ) {
  2103. while ( (elem = elem[ dir ]) ) {
  2104. if ( elem.nodeType === 1 || checkNonElements ) {
  2105. return matcher( elem, context, xml );
  2106. }
  2107. }
  2108. } :
  2109. // Check against all ancestor/preceding elements
  2110. function( elem, context, xml ) {
  2111. var oldCache, outerCache,
  2112. newCache = [ dirruns, doneName ];
  2113. // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
  2114. if ( xml ) {
  2115. while ( (elem = elem[ dir ]) ) {
  2116. if ( elem.nodeType === 1 || checkNonElements ) {
  2117. if ( matcher( elem, context, xml ) ) {
  2118. return true;
  2119. }
  2120. }
  2121. }
  2122. } else {
  2123. while ( (elem = elem[ dir ]) ) {
  2124. if ( elem.nodeType === 1 || checkNonElements ) {
  2125. outerCache = elem[ expando ] || (elem[ expando ] = {});
  2126. if ( (oldCache = outerCache[ dir ]) &&
  2127. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  2128. // Assign to newCache so results back-propagate to previous elements
  2129. return (newCache[ 2 ] = oldCache[ 2 ]);
  2130. } else {
  2131. // Reuse newcache so results back-propagate to previous elements
  2132. outerCache[ dir ] = newCache;
  2133. // A match means we're done; a fail means we have to keep checking
  2134. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  2135. return true;
  2136. }
  2137. }
  2138. }
  2139. }
  2140. }
  2141. };
  2142. }
  2143. function elementMatcher( matchers ) {
  2144. return matchers.length > 1 ?
  2145. function( elem, context, xml ) {
  2146. var i = matchers.length;
  2147. while ( i-- ) {
  2148. if ( !matchers[i]( elem, context, xml ) ) {
  2149. return false;
  2150. }
  2151. }
  2152. return true;
  2153. } :
  2154. matchers[0];
  2155. }
  2156. function condense( unmatched, map, filter, context, xml ) {
  2157. var elem,
  2158. newUnmatched = [],
  2159. i = 0,
  2160. len = unmatched.length,
  2161. mapped = map != null;
  2162. for ( ; i < len; i++ ) {
  2163. if ( (elem = unmatched[i]) ) {
  2164. if ( !filter || filter( elem, context, xml ) ) {
  2165. newUnmatched.push( elem );
  2166. if ( mapped ) {
  2167. map.push( i );
  2168. }
  2169. }
  2170. }
  2171. }
  2172. return newUnmatched;
  2173. }
  2174. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  2175. if ( postFilter && !postFilter[ expando ] ) {
  2176. postFilter = setMatcher( postFilter );
  2177. }
  2178. if ( postFinder && !postFinder[ expando ] ) {
  2179. postFinder = setMatcher( postFinder, postSelector );
  2180. }
  2181. return markFunction(function( seed, results, context, xml ) {
  2182. var temp, i, elem,
  2183. preMap = [],
  2184. postMap = [],
  2185. preexisting = results.length,
  2186. // Get initial elements from seed or context
  2187. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  2188. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  2189. matcherIn = preFilter && ( seed || !selector ) ?
  2190. condense( elems, preMap, preFilter, context, xml ) :
  2191. elems,
  2192. matcherOut = matcher ?
  2193. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  2194. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  2195. // ...intermediate processing is necessary
  2196. [] :
  2197. // ...otherwise use results directly
  2198. results :
  2199. matcherIn;
  2200. // Find primary matches
  2201. if ( matcher ) {
  2202. matcher( matcherIn, matcherOut, context, xml );
  2203. }
  2204. // Apply postFilter
  2205. if ( postFilter ) {
  2206. temp = condense( matcherOut, postMap );
  2207. postFilter( temp, [], context, xml );
  2208. // Un-match failing elements by moving them back to matcherIn
  2209. i = temp.length;
  2210. while ( i-- ) {
  2211. if ( (elem = temp[i]) ) {
  2212. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  2213. }
  2214. }
  2215. }
  2216. if ( seed ) {
  2217. if ( postFinder || preFilter ) {
  2218. if ( postFinder ) {
  2219. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  2220. temp = [];
  2221. i = matcherOut.length;
  2222. while ( i-- ) {
  2223. if ( (elem = matcherOut[i]) ) {
  2224. // Restore matcherIn since elem is not yet a final match
  2225. temp.push( (matcherIn[i] = elem) );
  2226. }
  2227. }
  2228. postFinder( null, (matcherOut = []), temp, xml );
  2229. }
  2230. // Move matched elements from seed to results to keep them synchronized
  2231. i = matcherOut.length;
  2232. while ( i-- ) {
  2233. if ( (elem = matcherOut[i]) &&
  2234. (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
  2235. seed[temp] = !(results[temp] = elem);
  2236. }
  2237. }
  2238. }
  2239. // Add elements to results, through postFinder if defined
  2240. } else {
  2241. matcherOut = condense(
  2242. matcherOut === results ?
  2243. matcherOut.splice( preexisting, matcherOut.length ) :
  2244. matcherOut
  2245. );
  2246. if ( postFinder ) {
  2247. postFinder( null, results, matcherOut, xml );
  2248. } else {
  2249. push.apply( results, matcherOut );
  2250. }
  2251. }
  2252. });
  2253. }
  2254. function matcherFromTokens( tokens ) {
  2255. var checkContext, matcher, j,
  2256. len = tokens.length,
  2257. leadingRelative = Expr.relative[ tokens[0].type ],
  2258. implicitRelative = leadingRelative || Expr.relative[" "],
  2259. i = leadingRelative ? 1 : 0,
  2260. // The foundational matcher ensures that elements are reachable from top-level context(s)
  2261. matchContext = addCombinator( function( elem ) {
  2262. return elem === checkContext;
  2263. }, implicitRelative, true ),
  2264. matchAnyContext = addCombinator( function( elem ) {
  2265. return indexOf.call( checkContext, elem ) > -1;
  2266. }, implicitRelative, true ),
  2267. matchers = [ function( elem, context, xml ) {
  2268. return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  2269. (checkContext = context).nodeType ?
  2270. matchContext( elem, context, xml ) :
  2271. matchAnyContext( elem, context, xml ) );
  2272. } ];
  2273. for ( ; i < len; i++ ) {
  2274. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  2275. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  2276. } else {
  2277. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  2278. // Return special upon seeing a positional matcher
  2279. if ( matcher[ expando ] ) {
  2280. // Find the next relative operator (if any) for proper handling
  2281. j = ++i;
  2282. for ( ; j < len; j++ ) {
  2283. if ( Expr.relative[ tokens[j].type ] ) {
  2284. break;
  2285. }
  2286. }
  2287. return setMatcher(
  2288. i > 1 && elementMatcher( matchers ),
  2289. i > 1 && toSelector(
  2290. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  2291. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  2292. ).replace( rtrim, "$1" ),
  2293. matcher,
  2294. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  2295. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  2296. j < len && toSelector( tokens )
  2297. );
  2298. }
  2299. matchers.push( matcher );
  2300. }
  2301. }
  2302. return elementMatcher( matchers );
  2303. }
  2304. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  2305. var bySet = setMatchers.length > 0,
  2306. byElement = elementMatchers.length > 0,
  2307. superMatcher = function( seed, context, xml, results, outermost ) {
  2308. var elem, j, matcher,
  2309. matchedCount = 0,
  2310. i = "0",
  2311. unmatched = seed && [],
  2312. setMatched = [],
  2313. contextBackup = outermostContext,
  2314. // We must always have either seed elements or outermost context
  2315. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  2316. // Use integer dirruns iff this is the outermost matcher
  2317. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  2318. len = elems.length;
  2319. if ( outermost ) {
  2320. outermostContext = context !== document && context;
  2321. }
  2322. // Add elements passing elementMatchers directly to results
  2323. // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
  2324. // Support: IE<9, Safari
  2325. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  2326. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  2327. if ( byElement && elem ) {
  2328. j = 0;
  2329. while ( (matcher = elementMatchers[j++]) ) {
  2330. if ( matcher( elem, context, xml ) ) {
  2331. results.push( elem );
  2332. break;
  2333. }
  2334. }
  2335. if ( outermost ) {
  2336. dirruns = dirrunsUnique;
  2337. }
  2338. }
  2339. // Track unmatched elements for set filters
  2340. if ( bySet ) {
  2341. // They will have gone through all possible matchers
  2342. if ( (elem = !matcher && elem) ) {
  2343. matchedCount--;
  2344. }
  2345. // Lengthen the array for every element, matched or not
  2346. if ( seed ) {
  2347. unmatched.push( elem );
  2348. }
  2349. }
  2350. }
  2351. // Apply set filters to unmatched elements
  2352. matchedCount += i;
  2353. if ( bySet && i !== matchedCount ) {
  2354. j = 0;
  2355. while ( (matcher = setMatchers[j++]) ) {
  2356. matcher( unmatched, setMatched, context, xml );
  2357. }
  2358. if ( seed ) {
  2359. // Reintegrate element matches to eliminate the need for sorting
  2360. if ( matchedCount > 0 ) {
  2361. while ( i-- ) {
  2362. if ( !(unmatched[i] || setMatched[i]) ) {
  2363. setMatched[i] = pop.call( results );
  2364. }
  2365. }
  2366. }
  2367. // Discard index placeholder values to get only actual matches
  2368. setMatched = condense( setMatched );
  2369. }
  2370. // Add matches to results
  2371. push.apply( results, setMatched );
  2372. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  2373. if ( outermost && !seed && setMatched.length > 0 &&
  2374. ( matchedCount + setMatchers.length ) > 1 ) {
  2375. Sizzle.uniqueSort( results );
  2376. }
  2377. }
  2378. // Override manipulation of globals by nested matchers
  2379. if ( outermost ) {
  2380. dirruns = dirrunsUnique;
  2381. outermostContext = contextBackup;
  2382. }
  2383. return unmatched;
  2384. };
  2385. return bySet ?
  2386. markFunction( superMatcher ) :
  2387. superMatcher;
  2388. }
  2389. compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
  2390. var i,
  2391. setMatchers = [],
  2392. elementMatchers = [],
  2393. cached = compilerCache[ selector + " " ];
  2394. if ( !cached ) {
  2395. // Generate a function of recursive functions that can be used to check each element
  2396. if ( !group ) {
  2397. group = tokenize( selector );
  2398. }
  2399. i = group.length;
  2400. while ( i-- ) {
  2401. cached = matcherFromTokens( group[i] );
  2402. if ( cached[ expando ] ) {
  2403. setMatchers.push( cached );
  2404. } else {
  2405. elementMatchers.push( cached );
  2406. }
  2407. }
  2408. // Cache the compiled function
  2409. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  2410. }
  2411. return cached;
  2412. };
  2413. function multipleContexts( selector, contexts, results ) {
  2414. var i = 0,
  2415. len = contexts.length;
  2416. for ( ; i < len; i++ ) {
  2417. Sizzle( selector, contexts[i], results );
  2418. }
  2419. return results;
  2420. }
  2421. function select( selector, context, results, seed ) {
  2422. var i, tokens, token, type, find,
  2423. match = tokenize( selector );
  2424. if ( !seed ) {
  2425. // Try to minimize operations if there is only one group
  2426. if ( match.length === 1 ) {
  2427. // Take a shortcut and set the context if the root selector is an ID
  2428. tokens = match[0] = match[0].slice( 0 );
  2429. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  2430. support.getById && context.nodeType === 9 && documentIsHTML &&
  2431. Expr.relative[ tokens[1].type ] ) {
  2432. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  2433. if ( !context ) {
  2434. return results;
  2435. }
  2436. selector = selector.slice( tokens.shift().value.length );
  2437. }
  2438. // Fetch a seed set for right-to-left matching
  2439. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  2440. while ( i-- ) {
  2441. token = tokens[i];
  2442. // Abort if we hit a combinator
  2443. if ( Expr.relative[ (type = token.type) ] ) {
  2444. break;
  2445. }
  2446. if ( (find = Expr.find[ type ]) ) {
  2447. // Search, expanding context for leading sibling combinators
  2448. if ( (seed = find(
  2449. token.matches[0].replace( runescape, funescape ),
  2450. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  2451. )) ) {
  2452. // If seed is empty or no tokens remain, we can return early
  2453. tokens.splice( i, 1 );
  2454. selector = seed.length && toSelector( tokens );
  2455. if ( !selector ) {
  2456. push.apply( results, seed );
  2457. return results;
  2458. }
  2459. break;
  2460. }
  2461. }
  2462. }
  2463. }
  2464. }
  2465. // Compile and execute a filtering function
  2466. // Provide `match` to avoid retokenization if we modified the selector above
  2467. compile( selector, match )(
  2468. seed,
  2469. context,
  2470. !documentIsHTML,
  2471. results,
  2472. rsibling.test( selector ) && testContext( context.parentNode ) || context
  2473. );
  2474. return results;
  2475. }
  2476. // One-time assignments
  2477. // Sort stability
  2478. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  2479. // Support: Chrome<14
  2480. // Always assume duplicates if they aren't passed to the comparison function
  2481. support.detectDuplicates = !!hasDuplicate;
  2482. // Initialize against the default document
  2483. setDocument();
  2484. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  2485. // Detached nodes confoundingly follow *each other*
  2486. support.sortDetached = assert(function( div1 ) {
  2487. // Should return 1, but returns 4 (following)
  2488. return div1.compareDocumentPosition( document.createElement("div") ) & 1;
  2489. });
  2490. // Support: IE<8
  2491. // Prevent attribute/property "interpolation"
  2492. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  2493. if ( !assert(function( div ) {
  2494. div.innerHTML = "<a href='#'></a>";
  2495. return div.firstChild.getAttribute("href") === "#" ;
  2496. }) ) {
  2497. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  2498. if ( !isXML ) {
  2499. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  2500. }
  2501. });
  2502. }
  2503. // Support: IE<9
  2504. // Use defaultValue in place of getAttribute("value")
  2505. if ( !support.attributes || !assert(function( div ) {
  2506. div.innerHTML = "<input/>";
  2507. div.firstChild.setAttribute( "value", "" );
  2508. return div.firstChild.getAttribute( "value" ) === "";
  2509. }) ) {
  2510. addHandle( "value", function( elem, name, isXML ) {
  2511. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  2512. return elem.defaultValue;
  2513. }
  2514. });
  2515. }
  2516. // Support: IE<9
  2517. // Use getAttributeNode to fetch booleans when getAttribute lies
  2518. if ( !assert(function( div ) {
  2519. return div.getAttribute("disabled") == null;
  2520. }) ) {
  2521. addHandle( booleans, function( elem, name, isXML ) {
  2522. var val;
  2523. if ( !isXML ) {
  2524. return elem[ name ] === true ? name.toLowerCase() :
  2525. (val = elem.getAttributeNode( name )) && val.specified ?
  2526. val.value :
  2527. null;
  2528. }
  2529. });
  2530. }
  2531. return Sizzle;
  2532. })( window );
  2533. jQuery.find = Sizzle;
  2534. jQuery.expr = Sizzle.selectors;
  2535. jQuery.expr[":"] = jQuery.expr.pseudos;
  2536. jQuery.unique = Sizzle.uniqueSort;
  2537. jQuery.text = Sizzle.getText;
  2538. jQuery.isXMLDoc = Sizzle.isXML;
  2539. jQuery.contains = Sizzle.contains;
  2540. var rneedsContext = jQuery.expr.match.needsContext;
  2541. var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
  2542. var risSimple = /^.[^:#\[\.,]*$/;
  2543. // Implement the identical functionality for filter and not
  2544. function winnow( elements, qualifier, not ) {
  2545. if ( jQuery.isFunction( qualifier ) ) {
  2546. return jQuery.grep( elements, function( elem, i ) {
  2547. /* jshint -W018 */
  2548. return !!qualifier.call( elem, i, elem ) !== not;
  2549. });
  2550. }
  2551. if ( qualifier.nodeType ) {
  2552. return jQuery.grep( elements, function( elem ) {
  2553. return ( elem === qualifier ) !== not;
  2554. });
  2555. }
  2556. if ( typeof qualifier === "string" ) {
  2557. if ( risSimple.test( qualifier ) ) {
  2558. return jQuery.filter( qualifier, elements, not );
  2559. }
  2560. qualifier = jQuery.filter( qualifier, elements );
  2561. }
  2562. return jQuery.grep( elements, function( elem ) {
  2563. return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
  2564. });
  2565. }
  2566. jQuery.filter = function( expr, elems, not ) {
  2567. var elem = elems[ 0 ];
  2568. if ( not ) {
  2569. expr = ":not(" + expr + ")";
  2570. }
  2571. return elems.length === 1 && elem.nodeType === 1 ?
  2572. jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
  2573. jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  2574. return elem.nodeType === 1;
  2575. }));
  2576. };
  2577. jQuery.fn.extend({
  2578. find: function( selector ) {
  2579. var i,
  2580. len = this.length,
  2581. ret = [],
  2582. self = this;
  2583. if ( typeof selector !== "string" ) {
  2584. return this.pushStack( jQuery( selector ).filter(function() {
  2585. for ( i = 0; i < len; i++ ) {
  2586. if ( jQuery.contains( self[ i ], this ) ) {
  2587. return true;
  2588. }
  2589. }
  2590. }) );
  2591. }
  2592. for ( i = 0; i < len; i++ ) {
  2593. jQuery.find( selector, self[ i ], ret );
  2594. }
  2595. // Needed because $( selector, context ) becomes $( context ).find( selector )
  2596. ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
  2597. ret.selector = this.selector ? this.selector + " " + selector : selector;
  2598. return ret;
  2599. },
  2600. filter: function( selector ) {
  2601. return this.pushStack( winnow(this, selector || [], false) );
  2602. },
  2603. not: function( selector ) {
  2604. return this.pushStack( winnow(this, selector || [], true) );
  2605. },
  2606. is: function( selector ) {
  2607. return !!winnow(
  2608. this,
  2609. // If this is a positional/relative selector, check membership in the returned set
  2610. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  2611. typeof selector === "string" && rneedsContext.test( selector ) ?
  2612. jQuery( selector ) :
  2613. selector || [],
  2614. false
  2615. ).length;
  2616. }
  2617. });
  2618. // Initialize a jQuery object
  2619. // A central reference to the root jQuery(document)
  2620. var rootjQuery,
  2621. // A simple way to check for HTML strings
  2622. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  2623. // Strict HTML recognition (#11290: must start with <)
  2624. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
  2625. init = jQuery.fn.init = function( selector, context ) {
  2626. var match, elem;
  2627. // HANDLE: $(""), $(null), $(undefined), $(false)
  2628. if ( !selector ) {
  2629. return this;
  2630. }
  2631. // Handle HTML strings
  2632. if ( typeof selector === "string" ) {
  2633. if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
  2634. // Assume that strings that start and end with <> are HTML and skip the regex check
  2635. match = [ null, selector, null ];
  2636. } else {
  2637. match = rquickExpr.exec( selector );
  2638. }
  2639. // Match html or make sure no context is specified for #id
  2640. if ( match && (match[1] || !context) ) {
  2641. // HANDLE: $(html) -> $(array)
  2642. if ( match[1] ) {
  2643. context = context instanceof jQuery ? context[0] : context;
  2644. // scripts is true for back-compat
  2645. // Intentionally let the error be thrown if parseHTML is not present
  2646. jQuery.merge( this, jQuery.parseHTML(
  2647. match[1],
  2648. context && context.nodeType ? context.ownerDocument || context : document,
  2649. true
  2650. ) );
  2651. // HANDLE: $(html, props)
  2652. if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
  2653. for ( match in context ) {
  2654. // Properties of context are called as methods if possible
  2655. if ( jQuery.isFunction( this[ match ] ) ) {
  2656. this[ match ]( context[ match ] );
  2657. // ...and otherwise set as attributes
  2658. } else {
  2659. this.attr( match, context[ match ] );
  2660. }
  2661. }
  2662. }
  2663. return this;
  2664. // HANDLE: $(#id)
  2665. } else {
  2666. elem = document.getElementById( match[2] );
  2667. // Check parentNode to catch when Blackberry 4.6 returns
  2668. // nodes that are no longer in the document #6963
  2669. if ( elem && elem.parentNode ) {
  2670. // Inject the element directly into the jQuery object
  2671. this.length = 1;
  2672. this[0] = elem;
  2673. }
  2674. this.context = document;
  2675. this.selector = selector;
  2676. return this;
  2677. }
  2678. // HANDLE: $(expr, $(...))
  2679. } else if ( !context || context.jquery ) {
  2680. return ( context || rootjQuery ).find( selector );
  2681. // HANDLE: $(expr, context)
  2682. // (which is just equivalent to: $(context).find(expr)
  2683. } else {
  2684. return this.constructor( context ).find( selector );
  2685. }
  2686. // HANDLE: $(DOMElement)
  2687. } else if ( selector.nodeType ) {
  2688. this.context = this[0] = selector;
  2689. this.length = 1;
  2690. return this;
  2691. // HANDLE: $(function)
  2692. // Shortcut for document ready
  2693. } else if ( jQuery.isFunction( selector ) ) {
  2694. return typeof rootjQuery.ready !== "undefined" ?
  2695. rootjQuery.ready( selector ) :
  2696. // Execute immediately if ready is not present
  2697. selector( jQuery );
  2698. }
  2699. if ( selector.selector !== undefined ) {
  2700. this.selector = selector.selector;
  2701. this.context = selector.context;
  2702. }
  2703. return jQuery.makeArray( selector, this );
  2704. };
  2705. // Give the init function the jQuery prototype for later instantiation
  2706. init.prototype = jQuery.fn;
  2707. // Initialize central reference
  2708. rootjQuery = jQuery( document );
  2709. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  2710. // methods guaranteed to produce a unique set when starting from a unique set
  2711. guaranteedUnique = {
  2712. children: true,
  2713. contents: true,
  2714. next: true,
  2715. prev: true
  2716. };
  2717. jQuery.extend({
  2718. dir: function( elem, dir, until ) {
  2719. var matched = [],
  2720. truncate = until !== undefined;
  2721. while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
  2722. if ( elem.nodeType === 1 ) {
  2723. if ( truncate && jQuery( elem ).is( until ) ) {
  2724. break;
  2725. }
  2726. matched.push( elem );
  2727. }
  2728. }
  2729. return matched;
  2730. },
  2731. sibling: function( n, elem ) {
  2732. var matched = [];
  2733. for ( ; n; n = n.nextSibling ) {
  2734. if ( n.nodeType === 1 && n !== elem ) {
  2735. matched.push( n );
  2736. }
  2737. }
  2738. return matched;
  2739. }
  2740. });
  2741. jQuery.fn.extend({
  2742. has: function( target ) {
  2743. var targets = jQuery( target, this ),
  2744. l = targets.length;
  2745. return this.filter(function() {
  2746. var i = 0;
  2747. for ( ; i < l; i++ ) {
  2748. if ( jQuery.contains( this, targets[i] ) ) {
  2749. return true;
  2750. }
  2751. }
  2752. });
  2753. },
  2754. closest: function( selectors, context ) {
  2755. var cur,
  2756. i = 0,
  2757. l = this.length,
  2758. matched = [],
  2759. pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
  2760. jQuery( selectors, context || this.context ) :
  2761. 0;
  2762. for ( ; i < l; i++ ) {
  2763. for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
  2764. // Always skip document fragments
  2765. if ( cur.nodeType < 11 && (pos ?
  2766. pos.index(cur) > -1 :
  2767. // Don't pass non-elements to Sizzle
  2768. cur.nodeType === 1 &&
  2769. jQuery.find.matchesSelector(cur, selectors)) ) {
  2770. matched.push( cur );
  2771. break;
  2772. }
  2773. }
  2774. }
  2775. return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
  2776. },
  2777. // Determine the position of an element within
  2778. // the matched set of elements
  2779. index: function( elem ) {
  2780. // No argument, return index in parent
  2781. if ( !elem ) {
  2782. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  2783. }
  2784. // index in selector
  2785. if ( typeof elem === "string" ) {
  2786. return indexOf.call( jQuery( elem ), this[ 0 ] );
  2787. }
  2788. // Locate the position of the desired element
  2789. return indexOf.call( this,
  2790. // If it receives a jQuery object, the first element is used
  2791. elem.jquery ? elem[ 0 ] : elem
  2792. );
  2793. },
  2794. add: function( selector, context ) {
  2795. return this.pushStack(
  2796. jQuery.unique(
  2797. jQuery.merge( this.get(), jQuery( selector, context ) )
  2798. )
  2799. );
  2800. },
  2801. addBack: function( selector ) {
  2802. return this.add( selector == null ?
  2803. this.prevObject : this.prevObject.filter(selector)
  2804. );
  2805. }
  2806. });
  2807. function sibling( cur, dir ) {
  2808. while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
  2809. return cur;
  2810. }
  2811. jQuery.each({
  2812. parent: function( elem ) {
  2813. var parent = elem.parentNode;
  2814. return parent && parent.nodeType !== 11 ? parent : null;
  2815. },
  2816. parents: function( elem ) {
  2817. return jQuery.dir( elem, "parentNode" );
  2818. },
  2819. parentsUntil: function( elem, i, until ) {
  2820. return jQuery.dir( elem, "parentNode", until );
  2821. },
  2822. next: function( elem ) {
  2823. return sibling( elem, "nextSibling" );
  2824. },
  2825. prev: function( elem ) {
  2826. return sibling( elem, "previousSibling" );
  2827. },
  2828. nextAll: function( elem ) {
  2829. return jQuery.dir( elem, "nextSibling" );
  2830. },
  2831. prevAll: function( elem ) {
  2832. return jQuery.dir( elem, "previousSibling" );
  2833. },
  2834. nextUntil: function( elem, i, until ) {
  2835. return jQuery.dir( elem, "nextSibling", until );
  2836. },
  2837. prevUntil: function( elem, i, until ) {
  2838. return jQuery.dir( elem, "previousSibling", until );
  2839. },
  2840. siblings: function( elem ) {
  2841. return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
  2842. },
  2843. children: function( elem ) {
  2844. return jQuery.sibling( elem.firstChild );
  2845. },
  2846. contents: function( elem ) {
  2847. return elem.contentDocument || jQuery.merge( [], elem.childNodes );
  2848. }
  2849. }, function( name, fn ) {
  2850. jQuery.fn[ name ] = function( until, selector ) {
  2851. var matched = jQuery.map( this, fn, until );
  2852. if ( name.slice( -5 ) !== "Until" ) {
  2853. selector = until;
  2854. }
  2855. if ( selector && typeof selector === "string" ) {
  2856. matched = jQuery.filter( selector, matched );
  2857. }
  2858. if ( this.length > 1 ) {
  2859. // Remove duplicates
  2860. if ( !guaranteedUnique[ name ] ) {
  2861. jQuery.unique( matched );
  2862. }
  2863. // Reverse order for parents* and prev-derivatives
  2864. if ( rparentsprev.test( name ) ) {
  2865. matched.reverse();
  2866. }
  2867. }
  2868. return this.pushStack( matched );
  2869. };
  2870. });
  2871. var rnotwhite = (/\S+/g);
  2872. // String to Object options format cache
  2873. var optionsCache = {};
  2874. // Convert String-formatted options into Object-formatted ones and store in cache
  2875. function createOptions( options ) {
  2876. var object = optionsCache[ options ] = {};
  2877. jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
  2878. object[ flag ] = true;
  2879. });
  2880. return object;
  2881. }
  2882. /*
  2883. * Create a callback list using the following parameters:
  2884. *
  2885. * options: an optional list of space-separated options that will change how
  2886. * the callback list behaves or a more traditional option object
  2887. *
  2888. * By default a callback list will act like an event callback list and can be
  2889. * "fired" multiple times.
  2890. *
  2891. * Possible options:
  2892. *
  2893. * once: will ensure the callback list can only be fired once (like a Deferred)
  2894. *
  2895. * memory: will keep track of previous values and will call any callback added
  2896. * after the list has been fired right away with the latest "memorized"
  2897. * values (like a Deferred)
  2898. *
  2899. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2900. *
  2901. * stopOnFalse: interrupt callings when a callback returns false
  2902. *
  2903. */
  2904. jQuery.Callbacks = function( options ) {
  2905. // Convert options from String-formatted to Object-formatted if needed
  2906. // (we check in cache first)
  2907. options = typeof options === "string" ?
  2908. ( optionsCache[ options ] || createOptions( options ) ) :
  2909. jQuery.extend( {}, options );
  2910. var // Last fire value (for non-forgettable lists)
  2911. memory,
  2912. // Flag to know if list was already fired
  2913. fired,
  2914. // Flag to know if list is currently firing
  2915. firing,
  2916. // First callback to fire (used internally by add and fireWith)
  2917. firingStart,
  2918. // End of the loop when firing
  2919. firingLength,
  2920. // Index of currently firing callback (modified by remove if needed)
  2921. firingIndex,
  2922. // Actual callback list
  2923. list = [],
  2924. // Stack of fire calls for repeatable lists
  2925. stack = !options.once && [],
  2926. // Fire callbacks
  2927. fire = function( data ) {
  2928. memory = options.memory && data;
  2929. fired = true;
  2930. firingIndex = firingStart || 0;
  2931. firingStart = 0;
  2932. firingLength = list.length;
  2933. firing = true;
  2934. for ( ; list && firingIndex < firingLength; firingIndex++ ) {
  2935. if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
  2936. memory = false; // To prevent further calls using add
  2937. break;
  2938. }
  2939. }
  2940. firing = false;
  2941. if ( list ) {
  2942. if ( stack ) {
  2943. if ( stack.length ) {
  2944. fire( stack.shift() );
  2945. }
  2946. } else if ( memory ) {
  2947. list = [];
  2948. } else {
  2949. self.disable();
  2950. }
  2951. }
  2952. },
  2953. // Actual Callbacks object
  2954. self = {
  2955. // Add a callback or a collection of callbacks to the list
  2956. add: function() {
  2957. if ( list ) {
  2958. // First, we save the current length
  2959. var start = list.length;
  2960. (function add( args ) {
  2961. jQuery.each( args, function( _, arg ) {
  2962. var type = jQuery.type( arg );
  2963. if ( type === "function" ) {
  2964. if ( !options.unique || !self.has( arg ) ) {
  2965. list.push( arg );
  2966. }
  2967. } else if ( arg && arg.length && type !== "string" ) {
  2968. // Inspect recursively
  2969. add( arg );
  2970. }
  2971. });
  2972. })( arguments );
  2973. // Do we need to add the callbacks to the
  2974. // current firing batch?
  2975. if ( firing ) {
  2976. firingLength = list.length;
  2977. // With memory, if we're not firing then
  2978. // we should call right away
  2979. } else if ( memory ) {
  2980. firingStart = start;
  2981. fire( memory );
  2982. }
  2983. }
  2984. return this;
  2985. },
  2986. // Remove a callback from the list
  2987. remove: function() {
  2988. if ( list ) {
  2989. jQuery.each( arguments, function( _, arg ) {
  2990. var index;
  2991. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  2992. list.splice( index, 1 );
  2993. // Handle firing indexes
  2994. if ( firing ) {
  2995. if ( index <= firingLength ) {
  2996. firingLength--;
  2997. }
  2998. if ( index <= firingIndex ) {
  2999. firingIndex--;
  3000. }
  3001. }
  3002. }
  3003. });
  3004. }
  3005. return this;
  3006. },
  3007. // Check if a given callback is in the list.
  3008. // If no argument is given, return whether or not list has callbacks attached.
  3009. has: function( fn ) {
  3010. return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
  3011. },
  3012. // Remove all callbacks from the list
  3013. empty: function() {
  3014. list = [];
  3015. firingLength = 0;
  3016. return this;
  3017. },
  3018. // Have the list do nothing anymore
  3019. disable: function() {
  3020. list = stack = memory = undefined;
  3021. return this;
  3022. },
  3023. // Is it disabled?
  3024. disabled: function() {
  3025. return !list;
  3026. },
  3027. // Lock the list in its current state
  3028. lock: function() {
  3029. stack = undefined;
  3030. if ( !memory ) {
  3031. self.disable();
  3032. }
  3033. return this;
  3034. },
  3035. // Is it locked?
  3036. locked: function() {
  3037. return !stack;
  3038. },
  3039. // Call all callbacks with the given context and arguments
  3040. fireWith: function( context, args ) {
  3041. if ( list && ( !fired || stack ) ) {
  3042. args = args || [];
  3043. args = [ context, args.slice ? args.slice() : args ];
  3044. if ( firing ) {
  3045. stack.push( args );
  3046. } else {
  3047. fire( args );
  3048. }
  3049. }
  3050. return this;
  3051. },
  3052. // Call all the callbacks with the given arguments
  3053. fire: function() {
  3054. self.fireWith( this, arguments );
  3055. return this;
  3056. },
  3057. // To know if the callbacks have already been called at least once
  3058. fired: function() {
  3059. return !!fired;
  3060. }
  3061. };
  3062. return self;
  3063. };
  3064. jQuery.extend({
  3065. Deferred: function( func ) {
  3066. var tuples = [
  3067. // action, add listener, listener list, final state
  3068. [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
  3069. [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
  3070. [ "notify", "progress", jQuery.Callbacks("memory") ]
  3071. ],
  3072. state = "pending",
  3073. promise = {
  3074. state: function() {
  3075. return state;
  3076. },
  3077. always: function() {
  3078. deferred.done( arguments ).fail( arguments );
  3079. return this;
  3080. },
  3081. then: function( /* fnDone, fnFail, fnProgress */ ) {
  3082. var fns = arguments;
  3083. return jQuery.Deferred(function( newDefer ) {
  3084. jQuery.each( tuples, function( i, tuple ) {
  3085. var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
  3086. // deferred[ done | fail | progress ] for forwarding actions to newDefer
  3087. deferred[ tuple[1] ](function() {
  3088. var returned = fn && fn.apply( this, arguments );
  3089. if ( returned && jQuery.isFunction( returned.promise ) ) {
  3090. returned.promise()
  3091. .done( newDefer.resolve )
  3092. .fail( newDefer.reject )
  3093. .progress( newDefer.notify );
  3094. } else {
  3095. newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
  3096. }
  3097. });
  3098. });
  3099. fns = null;
  3100. }).promise();
  3101. },
  3102. // Get a promise for this deferred
  3103. // If obj is provided, the promise aspect is added to the object
  3104. promise: function( obj ) {
  3105. return obj != null ? jQuery.extend( obj, promise ) : promise;
  3106. }
  3107. },
  3108. deferred = {};
  3109. // Keep pipe for back-compat
  3110. promise.pipe = promise.then;
  3111. // Add list-specific methods
  3112. jQuery.each( tuples, function( i, tuple ) {
  3113. var list = tuple[ 2 ],
  3114. stateString = tuple[ 3 ];
  3115. // promise[ done | fail | progress ] = list.add
  3116. promise[ tuple[1] ] = list.add;
  3117. // Handle state
  3118. if ( stateString ) {
  3119. list.add(function() {
  3120. // state = [ resolved | rejected ]
  3121. state = stateString;
  3122. // [ reject_list | resolve_list ].disable; progress_list.lock
  3123. }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
  3124. }
  3125. // deferred[ resolve | reject | notify ]
  3126. deferred[ tuple[0] ] = function() {
  3127. deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
  3128. return this;
  3129. };
  3130. deferred[ tuple[0] + "With" ] = list.fireWith;
  3131. });
  3132. // Make the deferred a promise
  3133. promise.promise( deferred );
  3134. // Call given func if any
  3135. if ( func ) {
  3136. func.call( deferred, deferred );
  3137. }
  3138. // All done!
  3139. return deferred;
  3140. },
  3141. // Deferred helper
  3142. when: function( subordinate /* , ..., subordinateN */ ) {
  3143. var i = 0,
  3144. resolveValues = slice.call( arguments ),
  3145. length = resolveValues.length,
  3146. // the count of uncompleted subordinates
  3147. remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
  3148. // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
  3149. deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
  3150. // Update function for both resolve and progress values
  3151. updateFunc = function( i, contexts, values ) {
  3152. return function( value ) {
  3153. contexts[ i ] = this;
  3154. values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  3155. if ( values === progressValues ) {
  3156. deferred.notifyWith( contexts, values );
  3157. } else if ( !( --remaining ) ) {
  3158. deferred.resolveWith( contexts, values );
  3159. }
  3160. };
  3161. },
  3162. progressValues, progressContexts, resolveContexts;
  3163. // add listeners to Deferred subordinates; treat others as resolved
  3164. if ( length > 1 ) {
  3165. progressValues = new Array( length );
  3166. progressContexts = new Array( length );
  3167. resolveContexts = new Array( length );
  3168. for ( ; i < length; i++ ) {
  3169. if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
  3170. resolveValues[ i ].promise()
  3171. .done( updateFunc( i, resolveContexts, resolveValues ) )
  3172. .fail( deferred.reject )
  3173. .progress( updateFunc( i, progressContexts, progressValues ) );
  3174. } else {
  3175. --remaining;
  3176. }
  3177. }
  3178. }
  3179. // if we're not waiting on anything, resolve the master
  3180. if ( !remaining ) {
  3181. deferred.resolveWith( resolveContexts, resolveValues );
  3182. }
  3183. return deferred.promise();
  3184. }
  3185. });
  3186. // The deferred used on DOM ready
  3187. var readyList;
  3188. jQuery.fn.ready = function( fn ) {
  3189. // Add the callback
  3190. jQuery.ready.promise().done( fn );
  3191. return this;
  3192. };
  3193. jQuery.extend({
  3194. // Is the DOM ready to be used? Set to true once it occurs.
  3195. isReady: false,
  3196. // A counter to track how many items to wait for before
  3197. // the ready event fires. See #6781
  3198. readyWait: 1,
  3199. // Hold (or release) the ready event
  3200. holdReady: function( hold ) {
  3201. if ( hold ) {
  3202. jQuery.readyWait++;
  3203. } else {
  3204. jQuery.ready( true );
  3205. }
  3206. },
  3207. // Handle when the DOM is ready
  3208. ready: function( wait ) {
  3209. // Abort if there are pending holds or we're already ready
  3210. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  3211. return;
  3212. }
  3213. // Remember that the DOM is ready
  3214. jQuery.isReady = true;
  3215. // If a normal DOM Ready event fired, decrement, and wait if need be
  3216. if ( wait !== true && --jQuery.readyWait > 0 ) {
  3217. return;
  3218. }
  3219. // If there are functions bound, to execute
  3220. readyList.resolveWith( document, [ jQuery ] );
  3221. // Trigger any bound ready events
  3222. if ( jQuery.fn.trigger ) {
  3223. jQuery( document ).trigger("ready").off("ready");
  3224. }
  3225. }
  3226. });
  3227. /**
  3228. * The ready event handler and self cleanup method
  3229. */
  3230. function completed() {
  3231. document.removeEventListener( "DOMContentLoaded", completed, false );
  3232. window.removeEventListener( "load", completed, false );
  3233. jQuery.ready();
  3234. }
  3235. jQuery.ready.promise = function( obj ) {
  3236. if ( !readyList ) {
  3237. readyList = jQuery.Deferred();
  3238. // Catch cases where $(document).ready() is called after the browser event has already occurred.
  3239. // we once tried to use readyState "interactive" here, but it caused issues like the one
  3240. // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
  3241. if ( document.readyState === "complete" ) {
  3242. // Handle it asynchronously to allow scripts the opportunity to delay ready
  3243. setTimeout( jQuery.ready );
  3244. } else {
  3245. // Use the handy event callback
  3246. document.addEventListener( "DOMContentLoaded", completed, false );
  3247. // A fallback to window.onload, that will always work
  3248. window.addEventListener( "load", completed, false );
  3249. }
  3250. }
  3251. return readyList.promise( obj );
  3252. };
  3253. // Kick off the DOM ready check even if the user does not
  3254. jQuery.ready.promise();
  3255. // Multifunctional method to get and set values of a collection
  3256. // The value/s can optionally be executed if it's a function
  3257. var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  3258. var i = 0,
  3259. len = elems.length,
  3260. bulk = key == null;
  3261. // Sets many values
  3262. if ( jQuery.type( key ) === "object" ) {
  3263. chainable = true;
  3264. for ( i in key ) {
  3265. jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
  3266. }
  3267. // Sets one value
  3268. } else if ( value !== undefined ) {
  3269. chainable = true;
  3270. if ( !jQuery.isFunction( value ) ) {
  3271. raw = true;
  3272. }
  3273. if ( bulk ) {
  3274. // Bulk operations run against the entire set
  3275. if ( raw ) {
  3276. fn.call( elems, value );
  3277. fn = null;
  3278. // ...except when executing function values
  3279. } else {
  3280. bulk = fn;
  3281. fn = function( elem, key, value ) {
  3282. return bulk.call( jQuery( elem ), value );
  3283. };
  3284. }
  3285. }
  3286. if ( fn ) {
  3287. for ( ; i < len; i++ ) {
  3288. fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
  3289. }
  3290. }
  3291. }
  3292. return chainable ?
  3293. elems :
  3294. // Gets
  3295. bulk ?
  3296. fn.call( elems ) :
  3297. len ? fn( elems[0], key ) : emptyGet;
  3298. };
  3299. /**
  3300. * Determines whether an object can have data
  3301. */
  3302. jQuery.acceptData = function( owner ) {
  3303. // Accepts only:
  3304. // - Node
  3305. // - Node.ELEMENT_NODE
  3306. // - Node.DOCUMENT_NODE
  3307. // - Object
  3308. // - Any
  3309. /* jshint -W018 */
  3310. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  3311. };
  3312. function Data() {
  3313. // Support: Android < 4,
  3314. // Old WebKit does not have Object.preventExtensions/freeze method,
  3315. // return new empty object instead with no [[set]] accessor
  3316. Object.defineProperty( this.cache = {}, 0, {
  3317. get: function() {
  3318. return {};
  3319. }
  3320. });
  3321. this.expando = jQuery.expando + Math.random();
  3322. }
  3323. Data.uid = 1;
  3324. Data.accepts = jQuery.acceptData;
  3325. Data.prototype = {
  3326. key: function( owner ) {
  3327. // We can accept data for non-element nodes in modern browsers,
  3328. // but we should not, see #8335.
  3329. // Always return the key for a frozen object.
  3330. if ( !Data.accepts( owner ) ) {
  3331. return 0;
  3332. }
  3333. var descriptor = {},
  3334. // Check if the owner object already has a cache key
  3335. unlock = owner[ this.expando ];
  3336. // If not, create one
  3337. if ( !unlock ) {
  3338. unlock = Data.uid++;
  3339. // Secure it in a non-enumerable, non-writable property
  3340. try {
  3341. descriptor[ this.expando ] = { value: unlock };
  3342. Object.defineProperties( owner, descriptor );
  3343. // Support: Android < 4
  3344. // Fallback to a less secure definition
  3345. } catch ( e ) {
  3346. descriptor[ this.expando ] = unlock;
  3347. jQuery.extend( owner, descriptor );
  3348. }
  3349. }
  3350. // Ensure the cache object
  3351. if ( !this.cache[ unlock ] ) {
  3352. this.cache[ unlock ] = {};
  3353. }
  3354. return unlock;
  3355. },
  3356. set: function( owner, data, value ) {
  3357. var prop,
  3358. // There may be an unlock assigned to this node,
  3359. // if there is no entry for this "owner", create one inline
  3360. // and set the unlock as though an owner entry had always existed
  3361. unlock = this.key( owner ),
  3362. cache = this.cache[ unlock ];
  3363. // Handle: [ owner, key, value ] args
  3364. if ( typeof data === "string" ) {
  3365. cache[ data ] = value;
  3366. // Handle: [ owner, { properties } ] args
  3367. } else {
  3368. // Fresh assignments by object are shallow copied
  3369. if ( jQuery.isEmptyObject( cache ) ) {
  3370. jQuery.extend( this.cache[ unlock ], data );
  3371. // Otherwise, copy the properties one-by-one to the cache object
  3372. } else {
  3373. for ( prop in data ) {
  3374. cache[ prop ] = data[ prop ];
  3375. }
  3376. }
  3377. }
  3378. return cache;
  3379. },
  3380. get: function( owner, key ) {
  3381. // Either a valid cache is found, or will be created.
  3382. // New caches will be created and the unlock returned,
  3383. // allowing direct access to the newly created
  3384. // empty data object. A valid owner object must be provided.
  3385. var cache = this.cache[ this.key( owner ) ];
  3386. return key === undefined ?
  3387. cache : cache[ key ];
  3388. },
  3389. access: function( owner, key, value ) {
  3390. var stored;
  3391. // In cases where either:
  3392. //
  3393. // 1. No key was specified
  3394. // 2. A string key was specified, but no value provided
  3395. //
  3396. // Take the "read" path and allow the get method to determine
  3397. // which value to return, respectively either:
  3398. //
  3399. // 1. The entire cache object
  3400. // 2. The data stored at the key
  3401. //
  3402. if ( key === undefined ||
  3403. ((key && typeof key === "string") && value === undefined) ) {
  3404. stored = this.get( owner, key );
  3405. return stored !== undefined ?
  3406. stored : this.get( owner, jQuery.camelCase(key) );
  3407. }
  3408. // [*]When the key is not a string, or both a key and value
  3409. // are specified, set or extend (existing objects) with either:
  3410. //
  3411. // 1. An object of properties
  3412. // 2. A key and value
  3413. //
  3414. this.set( owner, key, value );
  3415. // Since the "set" path can have two possible entry points
  3416. // return the expected data based on which path was taken[*]
  3417. return value !== undefined ? value : key;
  3418. },
  3419. remove: function( owner, key ) {
  3420. var i, name, camel,
  3421. unlock = this.key( owner ),
  3422. cache = this.cache[ unlock ];
  3423. if ( key === undefined ) {
  3424. this.cache[ unlock ] = {};
  3425. } else {
  3426. // Support array or space separated string of keys
  3427. if ( jQuery.isArray( key ) ) {
  3428. // If "name" is an array of keys...
  3429. // When data is initially created, via ("key", "val") signature,
  3430. // keys will be converted to camelCase.
  3431. // Since there is no way to tell _how_ a key was added, remove
  3432. // both plain key and camelCase key. #12786
  3433. // This will only penalize the array argument path.
  3434. name = key.concat( key.map( jQuery.camelCase ) );
  3435. } else {
  3436. camel = jQuery.camelCase( key );
  3437. // Try the string as a key before any manipulation
  3438. if ( key in cache ) {
  3439. name = [ key, camel ];
  3440. } else {
  3441. // If a key with the spaces exists, use it.
  3442. // Otherwise, create an array by matching non-whitespace
  3443. name = camel;
  3444. name = name in cache ?
  3445. [ name ] : ( name.match( rnotwhite ) || [] );
  3446. }
  3447. }
  3448. i = name.length;
  3449. while ( i-- ) {
  3450. delete cache[ name[ i ] ];
  3451. }
  3452. }
  3453. },
  3454. hasData: function( owner ) {
  3455. return !jQuery.isEmptyObject(
  3456. this.cache[ owner[ this.expando ] ] || {}
  3457. );
  3458. },
  3459. discard: function( owner ) {
  3460. if ( owner[ this.expando ] ) {
  3461. delete this.cache[ owner[ this.expando ] ];
  3462. }
  3463. }
  3464. };
  3465. var data_priv = new Data();
  3466. var data_user = new Data();
  3467. /*
  3468. Implementation Summary
  3469. 1. Enforce API surface and semantic compatibility with 1.9.x branch
  3470. 2. Improve the module's maintainability by reducing the storage
  3471. paths to a single mechanism.
  3472. 3. Use the same single mechanism to support "private" and "user" data.
  3473. 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  3474. 5. Avoid exposing implementation details on user objects (eg. expando properties)
  3475. 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  3476. */
  3477. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  3478. rmultiDash = /([A-Z])/g;
  3479. function dataAttr( elem, key, data ) {
  3480. var name;
  3481. // If nothing was found internally, try to fetch any
  3482. // data from the HTML5 data-* attribute
  3483. if ( data === undefined && elem.nodeType === 1 ) {
  3484. name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
  3485. data = elem.getAttribute( name );
  3486. if ( typeof data === "string" ) {
  3487. try {
  3488. data = data === "true" ? true :
  3489. data === "false" ? false :
  3490. data === "null" ? null :
  3491. // Only convert to a number if it doesn't change the string
  3492. +data + "" === data ? +data :
  3493. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  3494. data;
  3495. } catch( e ) {}
  3496. // Make sure we set the data so it isn't changed later
  3497. data_user.set( elem, key, data );
  3498. } else {
  3499. data = undefined;
  3500. }
  3501. }
  3502. return data;
  3503. }
  3504. jQuery.extend({
  3505. hasData: function( elem ) {
  3506. return data_user.hasData( elem ) || data_priv.hasData( elem );
  3507. },
  3508. data: function( elem, name, data ) {
  3509. return data_user.access( elem, name, data );
  3510. },
  3511. removeData: function( elem, name ) {
  3512. data_user.remove( elem, name );
  3513. },
  3514. // TODO: Now that all calls to _data and _removeData have been replaced
  3515. // with direct calls to data_priv methods, these can be deprecated.
  3516. _data: function( elem, name, data ) {
  3517. return data_priv.access( elem, name, data );
  3518. },
  3519. _removeData: function( elem, name ) {
  3520. data_priv.remove( elem, name );
  3521. }
  3522. });
  3523. jQuery.fn.extend({
  3524. data: function( key, value ) {
  3525. var i, name, data,
  3526. elem = this[ 0 ],
  3527. attrs = elem && elem.attributes;
  3528. // Gets all values
  3529. if ( key === undefined ) {
  3530. if ( this.length ) {
  3531. data = data_user.get( elem );
  3532. if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
  3533. i = attrs.length;
  3534. while ( i-- ) {
  3535. name = attrs[ i ].name;
  3536. if ( name.indexOf( "data-" ) === 0 ) {
  3537. name = jQuery.camelCase( name.slice(5) );
  3538. dataAttr( elem, name, data[ name ] );
  3539. }
  3540. }
  3541. data_priv.set( elem, "hasDataAttrs", true );
  3542. }
  3543. }
  3544. return data;
  3545. }
  3546. // Sets multiple values
  3547. if ( typeof key === "object" ) {
  3548. return this.each(function() {
  3549. data_user.set( this, key );
  3550. });
  3551. }
  3552. return access( this, function( value ) {
  3553. var data,
  3554. camelKey = jQuery.camelCase( key );
  3555. // The calling jQuery object (element matches) is not empty
  3556. // (and therefore has an element appears at this[ 0 ]) and the
  3557. // `value` parameter was not undefined. An empty jQuery object
  3558. // will result in `undefined` for elem = this[ 0 ] which will
  3559. // throw an exception if an attempt to read a data cache is made.
  3560. if ( elem && value === undefined ) {
  3561. // Attempt to get data from the cache
  3562. // with the key as-is
  3563. data = data_user.get( elem, key );
  3564. if ( data !== undefined ) {
  3565. return data;
  3566. }
  3567. // Attempt to get data from the cache
  3568. // with the key camelized
  3569. data = data_user.get( elem, camelKey );
  3570. if ( data !== undefined ) {
  3571. return data;
  3572. }
  3573. // Attempt to "discover" the data in
  3574. // HTML5 custom data-* attrs
  3575. data = dataAttr( elem, camelKey, undefined );
  3576. if ( data !== undefined ) {
  3577. return data;
  3578. }
  3579. // We tried really hard, but the data doesn't exist.
  3580. return;
  3581. }
  3582. // Set the data...
  3583. this.each(function() {
  3584. // First, attempt to store a copy or reference of any
  3585. // data that might've been store with a camelCased key.
  3586. var data = data_user.get( this, camelKey );
  3587. // For HTML5 data-* attribute interop, we have to
  3588. // store property names with dashes in a camelCase form.
  3589. // This might not apply to all properties...*
  3590. data_user.set( this, camelKey, value );
  3591. // *... In the case of properties that might _actually_
  3592. // have dashes, we need to also store a copy of that
  3593. // unchanged property.
  3594. if ( key.indexOf("-") !== -1 && data !== undefined ) {
  3595. data_user.set( this, key, value );
  3596. }
  3597. });
  3598. }, null, value, arguments.length > 1, null, true );
  3599. },
  3600. removeData: function( key ) {
  3601. return this.each(function() {
  3602. data_user.remove( this, key );
  3603. });
  3604. }
  3605. });
  3606. jQuery.extend({
  3607. queue: function( elem, type, data ) {
  3608. var queue;
  3609. if ( elem ) {
  3610. type = ( type || "fx" ) + "queue";
  3611. queue = data_priv.get( elem, type );
  3612. // Speed up dequeue by getting out quickly if this is just a lookup
  3613. if ( data ) {
  3614. if ( !queue || jQuery.isArray( data ) ) {
  3615. queue = data_priv.access( elem, type, jQuery.makeArray(data) );
  3616. } else {
  3617. queue.push( data );
  3618. }
  3619. }
  3620. return queue || [];
  3621. }
  3622. },
  3623. dequeue: function( elem, type ) {
  3624. type = type || "fx";
  3625. var queue = jQuery.queue( elem, type ),
  3626. startLength = queue.length,
  3627. fn = queue.shift(),
  3628. hooks = jQuery._queueHooks( elem, type ),
  3629. next = function() {
  3630. jQuery.dequeue( elem, type );
  3631. };
  3632. // If the fx queue is dequeued, always remove the progress sentinel
  3633. if ( fn === "inprogress" ) {
  3634. fn = queue.shift();
  3635. startLength--;
  3636. }
  3637. if ( fn ) {
  3638. // Add a progress sentinel to prevent the fx queue from being
  3639. // automatically dequeued
  3640. if ( type === "fx" ) {
  3641. queue.unshift( "inprogress" );
  3642. }
  3643. // clear up the last queue stop function
  3644. delete hooks.stop;
  3645. fn.call( elem, next, hooks );
  3646. }
  3647. if ( !startLength && hooks ) {
  3648. hooks.empty.fire();
  3649. }
  3650. },
  3651. // not intended for public consumption - generates a queueHooks object, or returns the current one
  3652. _queueHooks: function( elem, type ) {
  3653. var key = type + "queueHooks";
  3654. return data_priv.get( elem, key ) || data_priv.access( elem, key, {
  3655. empty: jQuery.Callbacks("once memory").add(function() {
  3656. data_priv.remove( elem, [ type + "queue", key ] );
  3657. })
  3658. });
  3659. }
  3660. });
  3661. jQuery.fn.extend({
  3662. queue: function( type, data ) {
  3663. var setter = 2;
  3664. if ( typeof type !== "string" ) {
  3665. data = type;
  3666. type = "fx";
  3667. setter--;
  3668. }
  3669. if ( arguments.length < setter ) {
  3670. return jQuery.queue( this[0], type );
  3671. }
  3672. return data === undefined ?
  3673. this :
  3674. this.each(function() {
  3675. var queue = jQuery.queue( this, type, data );
  3676. // ensure a hooks for this queue
  3677. jQuery._queueHooks( this, type );
  3678. if ( type === "fx" && queue[0] !== "inprogress" ) {
  3679. jQuery.dequeue( this, type );
  3680. }
  3681. });
  3682. },
  3683. dequeue: function( type ) {
  3684. return this.each(function() {
  3685. jQuery.dequeue( this, type );
  3686. });
  3687. },
  3688. clearQueue: function( type ) {
  3689. return this.queue( type || "fx", [] );
  3690. },
  3691. // Get a promise resolved when queues of a certain type
  3692. // are emptied (fx is the type by default)
  3693. promise: function( type, obj ) {
  3694. var tmp,
  3695. count = 1,
  3696. defer = jQuery.Deferred(),
  3697. elements = this,
  3698. i = this.length,
  3699. resolve = function() {
  3700. if ( !( --count ) ) {
  3701. defer.resolveWith( elements, [ elements ] );
  3702. }
  3703. };
  3704. if ( typeof type !== "string" ) {
  3705. obj = type;
  3706. type = undefined;
  3707. }
  3708. type = type || "fx";
  3709. while ( i-- ) {
  3710. tmp = data_priv.get( elements[ i ], type + "queueHooks" );
  3711. if ( tmp && tmp.empty ) {
  3712. count++;
  3713. tmp.empty.add( resolve );
  3714. }
  3715. }
  3716. resolve();
  3717. return defer.promise( obj );
  3718. }
  3719. });
  3720. var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
  3721. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  3722. var isHidden = function( elem, el ) {
  3723. // isHidden might be called from jQuery#filter function;
  3724. // in that case, element will be second argument
  3725. elem = el || elem;
  3726. return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
  3727. };
  3728. var rcheckableType = (/^(?:checkbox|radio)$/i);
  3729. (function() {
  3730. var fragment = document.createDocumentFragment(),
  3731. div = fragment.appendChild( document.createElement( "div" ) );
  3732. // #11217 - WebKit loses check when the name is after the checked attribute
  3733. div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
  3734. // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
  3735. // old WebKit doesn't clone checked state correctly in fragments
  3736. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  3737. // Make sure textarea (and checkbox) defaultValue is properly cloned
  3738. // Support: IE9-IE11+
  3739. div.innerHTML = "<textarea>x</textarea>";
  3740. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  3741. })();
  3742. var strundefined = typeof undefined;
  3743. support.focusinBubbles = "onfocusin" in window;
  3744. var
  3745. rkeyEvent = /^key/,
  3746. rmouseEvent = /^(?:mouse|contextmenu)|click/,
  3747. rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  3748. rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
  3749. function returnTrue() {
  3750. return true;
  3751. }
  3752. function returnFalse() {
  3753. return false;
  3754. }
  3755. function safeActiveElement() {
  3756. try {
  3757. return document.activeElement;
  3758. } catch ( err ) { }
  3759. }
  3760. /*
  3761. * Helper functions for managing events -- not part of the public interface.
  3762. * Props to Dean Edwards' addEvent library for many of the ideas.
  3763. */
  3764. jQuery.event = {
  3765. global: {},
  3766. add: function( elem, types, handler, data, selector ) {
  3767. var handleObjIn, eventHandle, tmp,
  3768. events, t, handleObj,
  3769. special, handlers, type, namespaces, origType,
  3770. elemData = data_priv.get( elem );
  3771. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  3772. if ( !elemData ) {
  3773. return;
  3774. }
  3775. // Caller can pass in an object of custom data in lieu of the handler
  3776. if ( handler.handler ) {
  3777. handleObjIn = handler;
  3778. handler = handleObjIn.handler;
  3779. selector = handleObjIn.selector;
  3780. }
  3781. // Make sure that the handler has a unique ID, used to find/remove it later
  3782. if ( !handler.guid ) {
  3783. handler.guid = jQuery.guid++;
  3784. }
  3785. // Init the element's event structure and main handler, if this is the first
  3786. if ( !(events = elemData.events) ) {
  3787. events = elemData.events = {};
  3788. }
  3789. if ( !(eventHandle = elemData.handle) ) {
  3790. eventHandle = elemData.handle = function( e ) {
  3791. // Discard the second event of a jQuery.event.trigger() and
  3792. // when an event is called after a page has unloaded
  3793. return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
  3794. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  3795. };
  3796. }
  3797. // Handle multiple events separated by a space
  3798. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3799. t = types.length;
  3800. while ( t-- ) {
  3801. tmp = rtypenamespace.exec( types[t] ) || [];
  3802. type = origType = tmp[1];
  3803. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3804. // There *must* be a type, no attaching namespace-only handlers
  3805. if ( !type ) {
  3806. continue;
  3807. }
  3808. // If event changes its type, use the special event handlers for the changed type
  3809. special = jQuery.event.special[ type ] || {};
  3810. // If selector defined, determine special event api type, otherwise given type
  3811. type = ( selector ? special.delegateType : special.bindType ) || type;
  3812. // Update special based on newly reset type
  3813. special = jQuery.event.special[ type ] || {};
  3814. // handleObj is passed to all event handlers
  3815. handleObj = jQuery.extend({
  3816. type: type,
  3817. origType: origType,
  3818. data: data,
  3819. handler: handler,
  3820. guid: handler.guid,
  3821. selector: selector,
  3822. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  3823. namespace: namespaces.join(".")
  3824. }, handleObjIn );
  3825. // Init the event handler queue if we're the first
  3826. if ( !(handlers = events[ type ]) ) {
  3827. handlers = events[ type ] = [];
  3828. handlers.delegateCount = 0;
  3829. // Only use addEventListener if the special events handler returns false
  3830. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  3831. if ( elem.addEventListener ) {
  3832. elem.addEventListener( type, eventHandle, false );
  3833. }
  3834. }
  3835. }
  3836. if ( special.add ) {
  3837. special.add.call( elem, handleObj );
  3838. if ( !handleObj.handler.guid ) {
  3839. handleObj.handler.guid = handler.guid;
  3840. }
  3841. }
  3842. // Add to the element's handler list, delegates in front
  3843. if ( selector ) {
  3844. handlers.splice( handlers.delegateCount++, 0, handleObj );
  3845. } else {
  3846. handlers.push( handleObj );
  3847. }
  3848. // Keep track of which events have ever been used, for event optimization
  3849. jQuery.event.global[ type ] = true;
  3850. }
  3851. },
  3852. // Detach an event or set of events from an element
  3853. remove: function( elem, types, handler, selector, mappedTypes ) {
  3854. var j, origCount, tmp,
  3855. events, t, handleObj,
  3856. special, handlers, type, namespaces, origType,
  3857. elemData = data_priv.hasData( elem ) && data_priv.get( elem );
  3858. if ( !elemData || !(events = elemData.events) ) {
  3859. return;
  3860. }
  3861. // Once for each type.namespace in types; type may be omitted
  3862. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3863. t = types.length;
  3864. while ( t-- ) {
  3865. tmp = rtypenamespace.exec( types[t] ) || [];
  3866. type = origType = tmp[1];
  3867. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3868. // Unbind all events (on this namespace, if provided) for the element
  3869. if ( !type ) {
  3870. for ( type in events ) {
  3871. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  3872. }
  3873. continue;
  3874. }
  3875. special = jQuery.event.special[ type ] || {};
  3876. type = ( selector ? special.delegateType : special.bindType ) || type;
  3877. handlers = events[ type ] || [];
  3878. tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
  3879. // Remove matching events
  3880. origCount = j = handlers.length;
  3881. while ( j-- ) {
  3882. handleObj = handlers[ j ];
  3883. if ( ( mappedTypes || origType === handleObj.origType ) &&
  3884. ( !handler || handler.guid === handleObj.guid ) &&
  3885. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  3886. ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
  3887. handlers.splice( j, 1 );
  3888. if ( handleObj.selector ) {
  3889. handlers.delegateCount--;
  3890. }
  3891. if ( special.remove ) {
  3892. special.remove.call( elem, handleObj );
  3893. }
  3894. }
  3895. }
  3896. // Remove generic event handler if we removed something and no more handlers exist
  3897. // (avoids potential for endless recursion during removal of special event handlers)
  3898. if ( origCount && !handlers.length ) {
  3899. if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  3900. jQuery.removeEvent( elem, type, elemData.handle );
  3901. }
  3902. delete events[ type ];
  3903. }
  3904. }
  3905. // Remove the expando if it's no longer used
  3906. if ( jQuery.isEmptyObject( events ) ) {
  3907. delete elemData.handle;
  3908. data_priv.remove( elem, "events" );
  3909. }
  3910. },
  3911. trigger: function( event, data, elem, onlyHandlers ) {
  3912. var i, cur, tmp, bubbleType, ontype, handle, special,
  3913. eventPath = [ elem || document ],
  3914. type = hasOwn.call( event, "type" ) ? event.type : event,
  3915. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
  3916. cur = tmp = elem = elem || document;
  3917. // Don't do events on text and comment nodes
  3918. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  3919. return;
  3920. }
  3921. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  3922. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  3923. return;
  3924. }
  3925. if ( type.indexOf(".") >= 0 ) {
  3926. // Namespaced trigger; create a regexp to match event type in handle()
  3927. namespaces = type.split(".");
  3928. type = namespaces.shift();
  3929. namespaces.sort();
  3930. }
  3931. ontype = type.indexOf(":") < 0 && "on" + type;
  3932. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  3933. event = event[ jQuery.expando ] ?
  3934. event :
  3935. new jQuery.Event( type, typeof event === "object" && event );
  3936. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  3937. event.isTrigger = onlyHandlers ? 2 : 3;
  3938. event.namespace = namespaces.join(".");
  3939. event.namespace_re = event.namespace ?
  3940. new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
  3941. null;
  3942. // Clean up the event in case it is being reused
  3943. event.result = undefined;
  3944. if ( !event.target ) {
  3945. event.target = elem;
  3946. }
  3947. // Clone any incoming data and prepend the event, creating the handler arg list
  3948. data = data == null ?
  3949. [ event ] :
  3950. jQuery.makeArray( data, [ event ] );
  3951. // Allow special events to draw outside the lines
  3952. special = jQuery.event.special[ type ] || {};
  3953. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  3954. return;
  3955. }
  3956. // Determine event propagation path in advance, per W3C events spec (#9951)
  3957. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  3958. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  3959. bubbleType = special.delegateType || type;
  3960. if ( !rfocusMorph.test( bubbleType + type ) ) {
  3961. cur = cur.parentNode;
  3962. }
  3963. for ( ; cur; cur = cur.parentNode ) {
  3964. eventPath.push( cur );
  3965. tmp = cur;
  3966. }
  3967. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  3968. if ( tmp === (elem.ownerDocument || document) ) {
  3969. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  3970. }
  3971. }
  3972. // Fire handlers on the event path
  3973. i = 0;
  3974. while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
  3975. event.type = i > 1 ?
  3976. bubbleType :
  3977. special.bindType || type;
  3978. // jQuery handler
  3979. handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
  3980. if ( handle ) {
  3981. handle.apply( cur, data );
  3982. }
  3983. // Native handler
  3984. handle = ontype && cur[ ontype ];
  3985. if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
  3986. event.result = handle.apply( cur, data );
  3987. if ( event.result === false ) {
  3988. event.preventDefault();
  3989. }
  3990. }
  3991. }
  3992. event.type = type;
  3993. // If nobody prevented the default action, do it now
  3994. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  3995. if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
  3996. jQuery.acceptData( elem ) ) {
  3997. // Call a native DOM method on the target with the same name name as the event.
  3998. // Don't do default actions on window, that's where global variables be (#6170)
  3999. if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
  4000. // Don't re-trigger an onFOO event when we call its FOO() method
  4001. tmp = elem[ ontype ];
  4002. if ( tmp ) {
  4003. elem[ ontype ] = null;
  4004. }
  4005. // Prevent re-triggering of the same event, since we already bubbled it above
  4006. jQuery.event.triggered = type;
  4007. elem[ type ]();
  4008. jQuery.event.triggered = undefined;
  4009. if ( tmp ) {
  4010. elem[ ontype ] = tmp;
  4011. }
  4012. }
  4013. }
  4014. }
  4015. return event.result;
  4016. },
  4017. dispatch: function( event ) {
  4018. // Make a writable jQuery.Event from the native event object
  4019. event = jQuery.event.fix( event );
  4020. var i, j, ret, matched, handleObj,
  4021. handlerQueue = [],
  4022. args = slice.call( arguments ),
  4023. handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
  4024. special = jQuery.event.special[ event.type ] || {};
  4025. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  4026. args[0] = event;
  4027. event.delegateTarget = this;
  4028. // Call the preDispatch hook for the mapped type, and let it bail if desired
  4029. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  4030. return;
  4031. }
  4032. // Determine handlers
  4033. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  4034. // Run delegates first; they may want to stop propagation beneath us
  4035. i = 0;
  4036. while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
  4037. event.currentTarget = matched.elem;
  4038. j = 0;
  4039. while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
  4040. // Triggered event must either 1) have no namespace, or
  4041. // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
  4042. if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
  4043. event.handleObj = handleObj;
  4044. event.data = handleObj.data;
  4045. ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
  4046. .apply( matched.elem, args );
  4047. if ( ret !== undefined ) {
  4048. if ( (event.result = ret) === false ) {
  4049. event.preventDefault();
  4050. event.stopPropagation();
  4051. }
  4052. }
  4053. }
  4054. }
  4055. }
  4056. // Call the postDispatch hook for the mapped type
  4057. if ( special.postDispatch ) {
  4058. special.postDispatch.call( this, event );
  4059. }
  4060. return event.result;
  4061. },
  4062. handlers: function( event, handlers ) {
  4063. var i, matches, sel, handleObj,
  4064. handlerQueue = [],
  4065. delegateCount = handlers.delegateCount,
  4066. cur = event.target;
  4067. // Find delegate handlers
  4068. // Black-hole SVG <use> instance trees (#13180)
  4069. // Avoid non-left-click bubbling in Firefox (#3861)
  4070. if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
  4071. for ( ; cur !== this; cur = cur.parentNode || this ) {
  4072. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  4073. if ( cur.disabled !== true || event.type !== "click" ) {
  4074. matches = [];
  4075. for ( i = 0; i < delegateCount; i++ ) {
  4076. handleObj = handlers[ i ];
  4077. // Don't conflict with Object.prototype properties (#13203)
  4078. sel = handleObj.selector + " ";
  4079. if ( matches[ sel ] === undefined ) {
  4080. matches[ sel ] = handleObj.needsContext ?
  4081. jQuery( sel, this ).index( cur ) >= 0 :
  4082. jQuery.find( sel, this, null, [ cur ] ).length;
  4083. }
  4084. if ( matches[ sel ] ) {
  4085. matches.push( handleObj );
  4086. }
  4087. }
  4088. if ( matches.length ) {
  4089. handlerQueue.push({ elem: cur, handlers: matches });
  4090. }
  4091. }
  4092. }
  4093. }
  4094. // Add the remaining (directly-bound) handlers
  4095. if ( delegateCount < handlers.length ) {
  4096. handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
  4097. }
  4098. return handlerQueue;
  4099. },
  4100. // Includes some event props shared by KeyEvent and MouseEvent
  4101. props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
  4102. fixHooks: {},
  4103. keyHooks: {
  4104. props: "char charCode key keyCode".split(" "),
  4105. filter: function( event, original ) {
  4106. // Add which for key events
  4107. if ( event.which == null ) {
  4108. event.which = original.charCode != null ? original.charCode : original.keyCode;
  4109. }
  4110. return event;
  4111. }
  4112. },
  4113. mouseHooks: {
  4114. props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
  4115. filter: function( event, original ) {
  4116. var eventDoc, doc, body,
  4117. button = original.button;
  4118. // Calculate pageX/Y if missing and clientX/Y available
  4119. if ( event.pageX == null && original.clientX != null ) {
  4120. eventDoc = event.target.ownerDocument || document;
  4121. doc = eventDoc.documentElement;
  4122. body = eventDoc.body;
  4123. event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
  4124. event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
  4125. }
  4126. // Add which for click: 1 === left; 2 === middle; 3 === right
  4127. // Note: button is not normalized, so don't use it
  4128. if ( !event.which && button !== undefined ) {
  4129. event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
  4130. }
  4131. return event;
  4132. }
  4133. },
  4134. fix: function( event ) {
  4135. if ( event[ jQuery.expando ] ) {
  4136. return event;
  4137. }
  4138. // Create a writable copy of the event object and normalize some properties
  4139. var i, prop, copy,
  4140. type = event.type,
  4141. originalEvent = event,
  4142. fixHook = this.fixHooks[ type ];
  4143. if ( !fixHook ) {
  4144. this.fixHooks[ type ] = fixHook =
  4145. rmouseEvent.test( type ) ? this.mouseHooks :
  4146. rkeyEvent.test( type ) ? this.keyHooks :
  4147. {};
  4148. }
  4149. copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
  4150. event = new jQuery.Event( originalEvent );
  4151. i = copy.length;
  4152. while ( i-- ) {
  4153. prop = copy[ i ];
  4154. event[ prop ] = originalEvent[ prop ];
  4155. }
  4156. // Support: Cordova 2.5 (WebKit) (#13255)
  4157. // All events should have a target; Cordova deviceready doesn't
  4158. if ( !event.target ) {
  4159. event.target = document;
  4160. }
  4161. // Support: Safari 6.0+, Chrome < 28
  4162. // Target should not be a text node (#504, #13143)
  4163. if ( event.target.nodeType === 3 ) {
  4164. event.target = event.target.parentNode;
  4165. }
  4166. return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
  4167. },
  4168. special: {
  4169. load: {
  4170. // Prevent triggered image.load events from bubbling to window.load
  4171. noBubble: true
  4172. },
  4173. focus: {
  4174. // Fire native event if possible so blur/focus sequence is correct
  4175. trigger: function() {
  4176. if ( this !== safeActiveElement() && this.focus ) {
  4177. this.focus();
  4178. return false;
  4179. }
  4180. },
  4181. delegateType: "focusin"
  4182. },
  4183. blur: {
  4184. trigger: function() {
  4185. if ( this === safeActiveElement() && this.blur ) {
  4186. this.blur();
  4187. return false;
  4188. }
  4189. },
  4190. delegateType: "focusout"
  4191. },
  4192. click: {
  4193. // For checkbox, fire native event so checked state will be right
  4194. trigger: function() {
  4195. if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
  4196. this.click();
  4197. return false;
  4198. }
  4199. },
  4200. // For cross-browser consistency, don't fire native .click() on links
  4201. _default: function( event ) {
  4202. return jQuery.nodeName( event.target, "a" );
  4203. }
  4204. },
  4205. beforeunload: {
  4206. postDispatch: function( event ) {
  4207. // Support: Firefox 20+
  4208. // Firefox doesn't alert if the returnValue field is not set.
  4209. if ( event.result !== undefined ) {
  4210. event.originalEvent.returnValue = event.result;
  4211. }
  4212. }
  4213. }
  4214. },
  4215. simulate: function( type, elem, event, bubble ) {
  4216. // Piggyback on a donor event to simulate a different one.
  4217. // Fake originalEvent to avoid donor's stopPropagation, but if the
  4218. // simulated event prevents default then we do the same on the donor.
  4219. var e = jQuery.extend(
  4220. new jQuery.Event(),
  4221. event,
  4222. {
  4223. type: type,
  4224. isSimulated: true,
  4225. originalEvent: {}
  4226. }
  4227. );
  4228. if ( bubble ) {
  4229. jQuery.event.trigger( e, null, elem );
  4230. } else {
  4231. jQuery.event.dispatch.call( elem, e );
  4232. }
  4233. if ( e.isDefaultPrevented() ) {
  4234. event.preventDefault();
  4235. }
  4236. }
  4237. };
  4238. jQuery.removeEvent = function( elem, type, handle ) {
  4239. if ( elem.removeEventListener ) {
  4240. elem.removeEventListener( type, handle, false );
  4241. }
  4242. };
  4243. jQuery.Event = function( src, props ) {
  4244. // Allow instantiation without the 'new' keyword
  4245. if ( !(this instanceof jQuery.Event) ) {
  4246. return new jQuery.Event( src, props );
  4247. }
  4248. // Event object
  4249. if ( src && src.type ) {
  4250. this.originalEvent = src;
  4251. this.type = src.type;
  4252. // Events bubbling up the document may have been marked as prevented
  4253. // by a handler lower down the tree; reflect the correct value.
  4254. this.isDefaultPrevented = src.defaultPrevented ||
  4255. // Support: Android < 4.0
  4256. src.defaultPrevented === undefined &&
  4257. src.getPreventDefault && src.getPreventDefault() ?
  4258. returnTrue :
  4259. returnFalse;
  4260. // Event type
  4261. } else {
  4262. this.type = src;
  4263. }
  4264. // Put explicitly provided properties onto the event object
  4265. if ( props ) {
  4266. jQuery.extend( this, props );
  4267. }
  4268. // Create a timestamp if incoming event doesn't have one
  4269. this.timeStamp = src && src.timeStamp || jQuery.now();
  4270. // Mark it as fixed
  4271. this[ jQuery.expando ] = true;
  4272. };
  4273. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4274. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4275. jQuery.Event.prototype = {
  4276. isDefaultPrevented: returnFalse,
  4277. isPropagationStopped: returnFalse,
  4278. isImmediatePropagationStopped: returnFalse,
  4279. preventDefault: function() {
  4280. var e = this.originalEvent;
  4281. this.isDefaultPrevented = returnTrue;
  4282. if ( e && e.preventDefault ) {
  4283. e.preventDefault();
  4284. }
  4285. },
  4286. stopPropagation: function() {
  4287. var e = this.originalEvent;
  4288. this.isPropagationStopped = returnTrue;
  4289. if ( e && e.stopPropagation ) {
  4290. e.stopPropagation();
  4291. }
  4292. },
  4293. stopImmediatePropagation: function() {
  4294. this.isImmediatePropagationStopped = returnTrue;
  4295. this.stopPropagation();
  4296. }
  4297. };
  4298. // Create mouseenter/leave events using mouseover/out and event-time checks
  4299. // Support: Chrome 15+
  4300. jQuery.each({
  4301. mouseenter: "mouseover",
  4302. mouseleave: "mouseout"
  4303. }, function( orig, fix ) {
  4304. jQuery.event.special[ orig ] = {
  4305. delegateType: fix,
  4306. bindType: fix,
  4307. handle: function( event ) {
  4308. var ret,
  4309. target = this,
  4310. related = event.relatedTarget,
  4311. handleObj = event.handleObj;
  4312. // For mousenter/leave call the handler if related is outside the target.
  4313. // NB: No relatedTarget if the mouse left/entered the browser window
  4314. if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
  4315. event.type = handleObj.origType;
  4316. ret = handleObj.handler.apply( this, arguments );
  4317. event.type = fix;
  4318. }
  4319. return ret;
  4320. }
  4321. };
  4322. });
  4323. // Create "bubbling" focus and blur events
  4324. // Support: Firefox, Chrome, Safari
  4325. if ( !support.focusinBubbles ) {
  4326. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  4327. // Attach a single capturing handler on the document while someone wants focusin/focusout
  4328. var handler = function( event ) {
  4329. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
  4330. };
  4331. jQuery.event.special[ fix ] = {
  4332. setup: function() {
  4333. var doc = this.ownerDocument || this,
  4334. attaches = data_priv.access( doc, fix );
  4335. if ( !attaches ) {
  4336. doc.addEventListener( orig, handler, true );
  4337. }
  4338. data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
  4339. },
  4340. teardown: function() {
  4341. var doc = this.ownerDocument || this,
  4342. attaches = data_priv.access( doc, fix ) - 1;
  4343. if ( !attaches ) {
  4344. doc.removeEventListener( orig, handler, true );
  4345. data_priv.remove( doc, fix );
  4346. } else {
  4347. data_priv.access( doc, fix, attaches );
  4348. }
  4349. }
  4350. };
  4351. });
  4352. }
  4353. jQuery.fn.extend({
  4354. on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
  4355. var origFn, type;
  4356. // Types can be a map of types/handlers
  4357. if ( typeof types === "object" ) {
  4358. // ( types-Object, selector, data )
  4359. if ( typeof selector !== "string" ) {
  4360. // ( types-Object, data )
  4361. data = data || selector;
  4362. selector = undefined;
  4363. }
  4364. for ( type in types ) {
  4365. this.on( type, selector, data, types[ type ], one );
  4366. }
  4367. return this;
  4368. }
  4369. if ( data == null && fn == null ) {
  4370. // ( types, fn )
  4371. fn = selector;
  4372. data = selector = undefined;
  4373. } else if ( fn == null ) {
  4374. if ( typeof selector === "string" ) {
  4375. // ( types, selector, fn )
  4376. fn = data;
  4377. data = undefined;
  4378. } else {
  4379. // ( types, data, fn )
  4380. fn = data;
  4381. data = selector;
  4382. selector = undefined;
  4383. }
  4384. }
  4385. if ( fn === false ) {
  4386. fn = returnFalse;
  4387. } else if ( !fn ) {
  4388. return this;
  4389. }
  4390. if ( one === 1 ) {
  4391. origFn = fn;
  4392. fn = function( event ) {
  4393. // Can use an empty set, since event contains the info
  4394. jQuery().off( event );
  4395. return origFn.apply( this, arguments );
  4396. };
  4397. // Use same guid so caller can remove using origFn
  4398. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  4399. }
  4400. return this.each( function() {
  4401. jQuery.event.add( this, types, fn, data, selector );
  4402. });
  4403. },
  4404. one: function( types, selector, data, fn ) {
  4405. return this.on( types, selector, data, fn, 1 );
  4406. },
  4407. off: function( types, selector, fn ) {
  4408. var handleObj, type;
  4409. if ( types && types.preventDefault && types.handleObj ) {
  4410. // ( event ) dispatched jQuery.Event
  4411. handleObj = types.handleObj;
  4412. jQuery( types.delegateTarget ).off(
  4413. handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
  4414. handleObj.selector,
  4415. handleObj.handler
  4416. );
  4417. return this;
  4418. }
  4419. if ( typeof types === "object" ) {
  4420. // ( types-object [, selector] )
  4421. for ( type in types ) {
  4422. this.off( type, selector, types[ type ] );
  4423. }
  4424. return this;
  4425. }
  4426. if ( selector === false || typeof selector === "function" ) {
  4427. // ( types [, fn] )
  4428. fn = selector;
  4429. selector = undefined;
  4430. }
  4431. if ( fn === false ) {
  4432. fn = returnFalse;
  4433. }
  4434. return this.each(function() {
  4435. jQuery.event.remove( this, types, fn, selector );
  4436. });
  4437. },
  4438. trigger: function( type, data ) {
  4439. return this.each(function() {
  4440. jQuery.event.trigger( type, data, this );
  4441. });
  4442. },
  4443. triggerHandler: function( type, data ) {
  4444. var elem = this[0];
  4445. if ( elem ) {
  4446. return jQuery.event.trigger( type, data, elem, true );
  4447. }
  4448. }
  4449. });
  4450. var
  4451. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
  4452. rtagName = /<([\w:]+)/,
  4453. rhtml = /<|&#?\w+;/,
  4454. rnoInnerhtml = /<(?:script|style|link)/i,
  4455. // checked="checked" or checked
  4456. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4457. rscriptType = /^$|\/(?:java|ecma)script/i,
  4458. rscriptTypeMasked = /^true\/(.*)/,
  4459. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
  4460. // We have to close these tags to support XHTML (#13200)
  4461. wrapMap = {
  4462. // Support: IE 9
  4463. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  4464. thead: [ 1, "<table>", "</table>" ],
  4465. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  4466. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  4467. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  4468. _default: [ 0, "", "" ]
  4469. };
  4470. // Support: IE 9
  4471. wrapMap.optgroup = wrapMap.option;
  4472. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  4473. wrapMap.th = wrapMap.td;
  4474. // Support: 1.x compatibility
  4475. // Manipulating tables requires a tbody
  4476. function manipulationTarget( elem, content ) {
  4477. return jQuery.nodeName( elem, "table" ) &&
  4478. jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
  4479. elem.getElementsByTagName("tbody")[0] ||
  4480. elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
  4481. elem;
  4482. }
  4483. // Replace/restore the type attribute of script elements for safe DOM manipulation
  4484. function disableScript( elem ) {
  4485. elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
  4486. return elem;
  4487. }
  4488. function restoreScript( elem ) {
  4489. var match = rscriptTypeMasked.exec( elem.type );
  4490. if ( match ) {
  4491. elem.type = match[ 1 ];
  4492. } else {
  4493. elem.removeAttribute("type");
  4494. }
  4495. return elem;
  4496. }
  4497. // Mark scripts as having already been evaluated
  4498. function setGlobalEval( elems, refElements ) {
  4499. var i = 0,
  4500. l = elems.length;
  4501. for ( ; i < l; i++ ) {
  4502. data_priv.set(
  4503. elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
  4504. );
  4505. }
  4506. }
  4507. function cloneCopyEvent( src, dest ) {
  4508. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  4509. if ( dest.nodeType !== 1 ) {
  4510. return;
  4511. }
  4512. // 1. Copy private data: events, handlers, etc.
  4513. if ( data_priv.hasData( src ) ) {
  4514. pdataOld = data_priv.access( src );
  4515. pdataCur = data_priv.set( dest, pdataOld );
  4516. events = pdataOld.events;
  4517. if ( events ) {
  4518. delete pdataCur.handle;
  4519. pdataCur.events = {};
  4520. for ( type in events ) {
  4521. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  4522. jQuery.event.add( dest, type, events[ type ][ i ] );
  4523. }
  4524. }
  4525. }
  4526. }
  4527. // 2. Copy user data
  4528. if ( data_user.hasData( src ) ) {
  4529. udataOld = data_user.access( src );
  4530. udataCur = jQuery.extend( {}, udataOld );
  4531. data_user.set( dest, udataCur );
  4532. }
  4533. }
  4534. function getAll( context, tag ) {
  4535. var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
  4536. context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
  4537. [];
  4538. return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
  4539. jQuery.merge( [ context ], ret ) :
  4540. ret;
  4541. }
  4542. // Support: IE >= 9
  4543. function fixInput( src, dest ) {
  4544. var nodeName = dest.nodeName.toLowerCase();
  4545. // Fails to persist the checked state of a cloned checkbox or radio button.
  4546. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  4547. dest.checked = src.checked;
  4548. // Fails to return the selected option to the default selected state when cloning options
  4549. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4550. dest.defaultValue = src.defaultValue;
  4551. }
  4552. }
  4553. jQuery.extend({
  4554. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4555. var i, l, srcElements, destElements,
  4556. clone = elem.cloneNode( true ),
  4557. inPage = jQuery.contains( elem.ownerDocument, elem );
  4558. // Support: IE >= 9
  4559. // Fix Cloning issues
  4560. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  4561. !jQuery.isXMLDoc( elem ) ) {
  4562. // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
  4563. destElements = getAll( clone );
  4564. srcElements = getAll( elem );
  4565. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  4566. fixInput( srcElements[ i ], destElements[ i ] );
  4567. }
  4568. }
  4569. // Copy the events from the original to the clone
  4570. if ( dataAndEvents ) {
  4571. if ( deepDataAndEvents ) {
  4572. srcElements = srcElements || getAll( elem );
  4573. destElements = destElements || getAll( clone );
  4574. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  4575. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  4576. }
  4577. } else {
  4578. cloneCopyEvent( elem, clone );
  4579. }
  4580. }
  4581. // Preserve script evaluation history
  4582. destElements = getAll( clone, "script" );
  4583. if ( destElements.length > 0 ) {
  4584. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  4585. }
  4586. // Return the cloned set
  4587. return clone;
  4588. },
  4589. buildFragment: function( elems, context, scripts, selection ) {
  4590. var elem, tmp, tag, wrap, contains, j,
  4591. fragment = context.createDocumentFragment(),
  4592. nodes = [],
  4593. i = 0,
  4594. l = elems.length;
  4595. for ( ; i < l; i++ ) {
  4596. elem = elems[ i ];
  4597. if ( elem || elem === 0 ) {
  4598. // Add nodes directly
  4599. if ( jQuery.type( elem ) === "object" ) {
  4600. // Support: QtWebKit
  4601. // jQuery.merge because push.apply(_, arraylike) throws
  4602. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  4603. // Convert non-html into a text node
  4604. } else if ( !rhtml.test( elem ) ) {
  4605. nodes.push( context.createTextNode( elem ) );
  4606. // Convert html into DOM nodes
  4607. } else {
  4608. tmp = tmp || fragment.appendChild( context.createElement("div") );
  4609. // Deserialize a standard representation
  4610. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  4611. wrap = wrapMap[ tag ] || wrapMap._default;
  4612. tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
  4613. // Descend through wrappers to the right content
  4614. j = wrap[ 0 ];
  4615. while ( j-- ) {
  4616. tmp = tmp.lastChild;
  4617. }
  4618. // Support: QtWebKit
  4619. // jQuery.merge because push.apply(_, arraylike) throws
  4620. jQuery.merge( nodes, tmp.childNodes );
  4621. // Remember the top-level container
  4622. tmp = fragment.firstChild;
  4623. // Fixes #12346
  4624. // Support: Webkit, IE
  4625. tmp.textContent = "";
  4626. }
  4627. }
  4628. }
  4629. // Remove wrapper from fragment
  4630. fragment.textContent = "";
  4631. i = 0;
  4632. while ( (elem = nodes[ i++ ]) ) {
  4633. // #4087 - If origin and destination elements are the same, and this is
  4634. // that element, do not do anything
  4635. if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
  4636. continue;
  4637. }
  4638. contains = jQuery.contains( elem.ownerDocument, elem );
  4639. // Append to fragment
  4640. tmp = getAll( fragment.appendChild( elem ), "script" );
  4641. // Preserve script evaluation history
  4642. if ( contains ) {
  4643. setGlobalEval( tmp );
  4644. }
  4645. // Capture executables
  4646. if ( scripts ) {
  4647. j = 0;
  4648. while ( (elem = tmp[ j++ ]) ) {
  4649. if ( rscriptType.test( elem.type || "" ) ) {
  4650. scripts.push( elem );
  4651. }
  4652. }
  4653. }
  4654. }
  4655. return fragment;
  4656. },
  4657. cleanData: function( elems ) {
  4658. var data, elem, events, type, key, j,
  4659. special = jQuery.event.special,
  4660. i = 0;
  4661. for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
  4662. if ( jQuery.acceptData( elem ) ) {
  4663. key = elem[ data_priv.expando ];
  4664. if ( key && (data = data_priv.cache[ key ]) ) {
  4665. events = Object.keys( data.events || {} );
  4666. if ( events.length ) {
  4667. for ( j = 0; (type = events[j]) !== undefined; j++ ) {
  4668. if ( special[ type ] ) {
  4669. jQuery.event.remove( elem, type );
  4670. // This is a shortcut to avoid jQuery.event.remove's overhead
  4671. } else {
  4672. jQuery.removeEvent( elem, type, data.handle );
  4673. }
  4674. }
  4675. }
  4676. if ( data_priv.cache[ key ] ) {
  4677. // Discard any remaining `private` data
  4678. delete data_priv.cache[ key ];
  4679. }
  4680. }
  4681. }
  4682. // Discard any remaining `user` data
  4683. delete data_user.cache[ elem[ data_user.expando ] ];
  4684. }
  4685. }
  4686. });
  4687. jQuery.fn.extend({
  4688. text: function( value ) {
  4689. return access( this, function( value ) {
  4690. return value === undefined ?
  4691. jQuery.text( this ) :
  4692. this.empty().each(function() {
  4693. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4694. this.textContent = value;
  4695. }
  4696. });
  4697. }, null, value, arguments.length );
  4698. },
  4699. append: function() {
  4700. return this.domManip( arguments, function( elem ) {
  4701. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4702. var target = manipulationTarget( this, elem );
  4703. target.appendChild( elem );
  4704. }
  4705. });
  4706. },
  4707. prepend: function() {
  4708. return this.domManip( arguments, function( elem ) {
  4709. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4710. var target = manipulationTarget( this, elem );
  4711. target.insertBefore( elem, target.firstChild );
  4712. }
  4713. });
  4714. },
  4715. before: function() {
  4716. return this.domManip( arguments, function( elem ) {
  4717. if ( this.parentNode ) {
  4718. this.parentNode.insertBefore( elem, this );
  4719. }
  4720. });
  4721. },
  4722. after: function() {
  4723. return this.domManip( arguments, function( elem ) {
  4724. if ( this.parentNode ) {
  4725. this.parentNode.insertBefore( elem, this.nextSibling );
  4726. }
  4727. });
  4728. },
  4729. remove: function( selector, keepData /* Internal Use Only */ ) {
  4730. var elem,
  4731. elems = selector ? jQuery.filter( selector, this ) : this,
  4732. i = 0;
  4733. for ( ; (elem = elems[i]) != null; i++ ) {
  4734. if ( !keepData && elem.nodeType === 1 ) {
  4735. jQuery.cleanData( getAll( elem ) );
  4736. }
  4737. if ( elem.parentNode ) {
  4738. if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
  4739. setGlobalEval( getAll( elem, "script" ) );
  4740. }
  4741. elem.parentNode.removeChild( elem );
  4742. }
  4743. }
  4744. return this;
  4745. },
  4746. empty: function() {
  4747. var elem,
  4748. i = 0;
  4749. for ( ; (elem = this[i]) != null; i++ ) {
  4750. if ( elem.nodeType === 1 ) {
  4751. // Prevent memory leaks
  4752. jQuery.cleanData( getAll( elem, false ) );
  4753. // Remove any remaining nodes
  4754. elem.textContent = "";
  4755. }
  4756. }
  4757. return this;
  4758. },
  4759. clone: function( dataAndEvents, deepDataAndEvents ) {
  4760. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4761. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4762. return this.map(function() {
  4763. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  4764. });
  4765. },
  4766. html: function( value ) {
  4767. return access( this, function( value ) {
  4768. var elem = this[ 0 ] || {},
  4769. i = 0,
  4770. l = this.length;
  4771. if ( value === undefined && elem.nodeType === 1 ) {
  4772. return elem.innerHTML;
  4773. }
  4774. // See if we can take a shortcut and just use innerHTML
  4775. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  4776. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  4777. value = value.replace( rxhtmlTag, "<$1></$2>" );
  4778. try {
  4779. for ( ; i < l; i++ ) {
  4780. elem = this[ i ] || {};
  4781. // Remove element nodes and prevent memory leaks
  4782. if ( elem.nodeType === 1 ) {
  4783. jQuery.cleanData( getAll( elem, false ) );
  4784. elem.innerHTML = value;
  4785. }
  4786. }
  4787. elem = 0;
  4788. // If using innerHTML throws an exception, use the fallback method
  4789. } catch( e ) {}
  4790. }
  4791. if ( elem ) {
  4792. this.empty().append( value );
  4793. }
  4794. }, null, value, arguments.length );
  4795. },
  4796. replaceWith: function() {
  4797. var arg = arguments[ 0 ];
  4798. // Make the changes, replacing each context element with the new content
  4799. this.domManip( arguments, function( elem ) {
  4800. arg = this.parentNode;
  4801. jQuery.cleanData( getAll( this ) );
  4802. if ( arg ) {
  4803. arg.replaceChild( elem, this );
  4804. }
  4805. });
  4806. // Force removal if there was no new content (e.g., from empty arguments)
  4807. return arg && (arg.length || arg.nodeType) ? this : this.remove();
  4808. },
  4809. detach: function( selector ) {
  4810. return this.remove( selector, true );
  4811. },
  4812. domManip: function( args, callback ) {
  4813. // Flatten any nested arrays
  4814. args = concat.apply( [], args );
  4815. var fragment, first, scripts, hasScripts, node, doc,
  4816. i = 0,
  4817. l = this.length,
  4818. set = this,
  4819. iNoClone = l - 1,
  4820. value = args[ 0 ],
  4821. isFunction = jQuery.isFunction( value );
  4822. // We can't cloneNode fragments that contain checked, in WebKit
  4823. if ( isFunction ||
  4824. ( l > 1 && typeof value === "string" &&
  4825. !support.checkClone && rchecked.test( value ) ) ) {
  4826. return this.each(function( index ) {
  4827. var self = set.eq( index );
  4828. if ( isFunction ) {
  4829. args[ 0 ] = value.call( this, index, self.html() );
  4830. }
  4831. self.domManip( args, callback );
  4832. });
  4833. }
  4834. if ( l ) {
  4835. fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
  4836. first = fragment.firstChild;
  4837. if ( fragment.childNodes.length === 1 ) {
  4838. fragment = first;
  4839. }
  4840. if ( first ) {
  4841. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  4842. hasScripts = scripts.length;
  4843. // Use the original fragment for the last item instead of the first because it can end up
  4844. // being emptied incorrectly in certain situations (#8070).
  4845. for ( ; i < l; i++ ) {
  4846. node = fragment;
  4847. if ( i !== iNoClone ) {
  4848. node = jQuery.clone( node, true, true );
  4849. // Keep references to cloned scripts for later restoration
  4850. if ( hasScripts ) {
  4851. // Support: QtWebKit
  4852. // jQuery.merge because push.apply(_, arraylike) throws
  4853. jQuery.merge( scripts, getAll( node, "script" ) );
  4854. }
  4855. }
  4856. callback.call( this[ i ], node, i );
  4857. }
  4858. if ( hasScripts ) {
  4859. doc = scripts[ scripts.length - 1 ].ownerDocument;
  4860. // Reenable scripts
  4861. jQuery.map( scripts, restoreScript );
  4862. // Evaluate executable scripts on first document insertion
  4863. for ( i = 0; i < hasScripts; i++ ) {
  4864. node = scripts[ i ];
  4865. if ( rscriptType.test( node.type || "" ) &&
  4866. !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
  4867. if ( node.src ) {
  4868. // Optional AJAX dependency, but won't run scripts if not present
  4869. if ( jQuery._evalUrl ) {
  4870. jQuery._evalUrl( node.src );
  4871. }
  4872. } else {
  4873. jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
  4874. }
  4875. }
  4876. }
  4877. }
  4878. }
  4879. }
  4880. return this;
  4881. }
  4882. });
  4883. jQuery.each({
  4884. appendTo: "append",
  4885. prependTo: "prepend",
  4886. insertBefore: "before",
  4887. insertAfter: "after",
  4888. replaceAll: "replaceWith"
  4889. }, function( name, original ) {
  4890. jQuery.fn[ name ] = function( selector ) {
  4891. var elems,
  4892. ret = [],
  4893. insert = jQuery( selector ),
  4894. last = insert.length - 1,
  4895. i = 0;
  4896. for ( ; i <= last; i++ ) {
  4897. elems = i === last ? this : this.clone( true );
  4898. jQuery( insert[ i ] )[ original ]( elems );
  4899. // Support: QtWebKit
  4900. // .get() because push.apply(_, arraylike) throws
  4901. push.apply( ret, elems.get() );
  4902. }
  4903. return this.pushStack( ret );
  4904. };
  4905. });
  4906. var iframe,
  4907. elemdisplay = {};
  4908. /**
  4909. * Retrieve the actual display of a element
  4910. * @param {String} name nodeName of the element
  4911. * @param {Object} doc Document object
  4912. */
  4913. // Called only from within defaultDisplay
  4914. function actualDisplay( name, doc ) {
  4915. var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
  4916. // getDefaultComputedStyle might be reliably used only on attached element
  4917. display = window.getDefaultComputedStyle ?
  4918. // Use of this method is a temporary fix (more like optmization) until something better comes along,
  4919. // since it was removed from specification and supported only in FF
  4920. window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" );
  4921. // We don't have any data stored on the element,
  4922. // so use "detach" method as fast way to get rid of the element
  4923. elem.detach();
  4924. return display;
  4925. }
  4926. /**
  4927. * Try to determine the default display value of an element
  4928. * @param {String} nodeName
  4929. */
  4930. function defaultDisplay( nodeName ) {
  4931. var doc = document,
  4932. display = elemdisplay[ nodeName ];
  4933. if ( !display ) {
  4934. display = actualDisplay( nodeName, doc );
  4935. // If the simple way fails, read from inside an iframe
  4936. if ( display === "none" || !display ) {
  4937. // Use the already-created iframe if possible
  4938. iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
  4939. // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
  4940. doc = iframe[ 0 ].contentDocument;
  4941. // Support: IE
  4942. doc.write();
  4943. doc.close();
  4944. display = actualDisplay( nodeName, doc );
  4945. iframe.detach();
  4946. }
  4947. // Store the correct default display
  4948. elemdisplay[ nodeName ] = display;
  4949. }
  4950. return display;
  4951. }
  4952. var rmargin = (/^margin/);
  4953. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  4954. var getStyles = function( elem ) {
  4955. return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
  4956. };
  4957. function curCSS( elem, name, computed ) {
  4958. var width, minWidth, maxWidth, ret,
  4959. style = elem.style;
  4960. computed = computed || getStyles( elem );
  4961. // Support: IE9
  4962. // getPropertyValue is only needed for .css('filter') in IE9, see #12537
  4963. if ( computed ) {
  4964. ret = computed.getPropertyValue( name ) || computed[ name ];
  4965. }
  4966. if ( computed ) {
  4967. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  4968. ret = jQuery.style( elem, name );
  4969. }
  4970. // Support: iOS < 6
  4971. // A tribute to the "awesome hack by Dean Edwards"
  4972. // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
  4973. // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
  4974. if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  4975. // Remember the original values
  4976. width = style.width;
  4977. minWidth = style.minWidth;
  4978. maxWidth = style.maxWidth;
  4979. // Put in the new values to get a computed value out
  4980. style.minWidth = style.maxWidth = style.width = ret;
  4981. ret = computed.width;
  4982. // Revert the changed values
  4983. style.width = width;
  4984. style.minWidth = minWidth;
  4985. style.maxWidth = maxWidth;
  4986. }
  4987. }
  4988. return ret !== undefined ?
  4989. // Support: IE
  4990. // IE returns zIndex value as an integer.
  4991. ret + "" :
  4992. ret;
  4993. }
  4994. function addGetHookIf( conditionFn, hookFn ) {
  4995. // Define the hook, we'll check on the first run if it's really needed.
  4996. return {
  4997. get: function() {
  4998. if ( conditionFn() ) {
  4999. // Hook not needed (or it's not possible to use it due to missing dependency),
  5000. // remove it.
  5001. // Since there are no other hooks for marginRight, remove the whole object.
  5002. delete this.get;
  5003. return;
  5004. }
  5005. // Hook needed; redefine it so that the support test is not executed again.
  5006. return (this.get = hookFn).apply( this, arguments );
  5007. }
  5008. };
  5009. }
  5010. (function() {
  5011. var pixelPositionVal, boxSizingReliableVal,
  5012. // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
  5013. divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;" +
  5014. "-moz-box-sizing:content-box;box-sizing:content-box",
  5015. docElem = document.documentElement,
  5016. container = document.createElement( "div" ),
  5017. div = document.createElement( "div" );
  5018. div.style.backgroundClip = "content-box";
  5019. div.cloneNode( true ).style.backgroundClip = "";
  5020. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  5021. container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;" +
  5022. "margin-top:1px";
  5023. container.appendChild( div );
  5024. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  5025. // so they're executed at the same time to save the second computation.
  5026. function computePixelPositionAndBoxSizingReliable() {
  5027. // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
  5028. div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
  5029. "box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;" +
  5030. "position:absolute;top:1%";
  5031. docElem.appendChild( container );
  5032. var divStyle = window.getComputedStyle( div, null );
  5033. pixelPositionVal = divStyle.top !== "1%";
  5034. boxSizingReliableVal = divStyle.width === "4px";
  5035. docElem.removeChild( container );
  5036. }
  5037. // Use window.getComputedStyle because jsdom on node.js will break without it.
  5038. if ( window.getComputedStyle ) {
  5039. jQuery.extend(support, {
  5040. pixelPosition: function() {
  5041. // This test is executed only once but we still do memoizing
  5042. // since we can use the boxSizingReliable pre-computing.
  5043. // No need to check if the test was already performed, though.
  5044. computePixelPositionAndBoxSizingReliable();
  5045. return pixelPositionVal;
  5046. },
  5047. boxSizingReliable: function() {
  5048. if ( boxSizingReliableVal == null ) {
  5049. computePixelPositionAndBoxSizingReliable();
  5050. }
  5051. return boxSizingReliableVal;
  5052. },
  5053. reliableMarginRight: function() {
  5054. // Support: Android 2.3
  5055. // Check if div with explicit width and no margin-right incorrectly
  5056. // gets computed margin-right based on width of container. (#3333)
  5057. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5058. // This support function is only executed once so no memoizing is needed.
  5059. var ret,
  5060. marginDiv = div.appendChild( document.createElement( "div" ) );
  5061. marginDiv.style.cssText = div.style.cssText = divReset;
  5062. marginDiv.style.marginRight = marginDiv.style.width = "0";
  5063. div.style.width = "1px";
  5064. docElem.appendChild( container );
  5065. ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
  5066. docElem.removeChild( container );
  5067. // Clean up the div for other support tests.
  5068. div.innerHTML = "";
  5069. return ret;
  5070. }
  5071. });
  5072. }
  5073. })();
  5074. // A method for quickly swapping in/out CSS properties to get correct calculations.
  5075. jQuery.swap = function( elem, options, callback, args ) {
  5076. var ret, name,
  5077. old = {};
  5078. // Remember the old values, and insert the new ones
  5079. for ( name in options ) {
  5080. old[ name ] = elem.style[ name ];
  5081. elem.style[ name ] = options[ name ];
  5082. }
  5083. ret = callback.apply( elem, args || [] );
  5084. // Revert the old values
  5085. for ( name in options ) {
  5086. elem.style[ name ] = old[ name ];
  5087. }
  5088. return ret;
  5089. };
  5090. var
  5091. // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
  5092. // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  5093. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  5094. rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
  5095. rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
  5096. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5097. cssNormalTransform = {
  5098. letterSpacing: 0,
  5099. fontWeight: 400
  5100. },
  5101. cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
  5102. // return a css property mapped to a potentially vendor prefixed property
  5103. function vendorPropName( style, name ) {
  5104. // shortcut for names that are not vendor prefixed
  5105. if ( name in style ) {
  5106. return name;
  5107. }
  5108. // check for vendor prefixed names
  5109. var capName = name[0].toUpperCase() + name.slice(1),
  5110. origName = name,
  5111. i = cssPrefixes.length;
  5112. while ( i-- ) {
  5113. name = cssPrefixes[ i ] + capName;
  5114. if ( name in style ) {
  5115. return name;
  5116. }
  5117. }
  5118. return origName;
  5119. }
  5120. function setPositiveNumber( elem, value, subtract ) {
  5121. var matches = rnumsplit.exec( value );
  5122. return matches ?
  5123. // Guard against undefined "subtract", e.g., when used as in cssHooks
  5124. Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
  5125. value;
  5126. }
  5127. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  5128. var i = extra === ( isBorderBox ? "border" : "content" ) ?
  5129. // If we already have the right measurement, avoid augmentation
  5130. 4 :
  5131. // Otherwise initialize for horizontal or vertical properties
  5132. name === "width" ? 1 : 0,
  5133. val = 0;
  5134. for ( ; i < 4; i += 2 ) {
  5135. // both box models exclude margin, so add it if we want it
  5136. if ( extra === "margin" ) {
  5137. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  5138. }
  5139. if ( isBorderBox ) {
  5140. // border-box includes padding, so remove it if we want content
  5141. if ( extra === "content" ) {
  5142. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5143. }
  5144. // at this point, extra isn't border nor margin, so remove border
  5145. if ( extra !== "margin" ) {
  5146. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5147. }
  5148. } else {
  5149. // at this point, extra isn't content, so add padding
  5150. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5151. // at this point, extra isn't content nor padding, so add border
  5152. if ( extra !== "padding" ) {
  5153. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5154. }
  5155. }
  5156. }
  5157. return val;
  5158. }
  5159. function getWidthOrHeight( elem, name, extra ) {
  5160. // Start with offset property, which is equivalent to the border-box value
  5161. var valueIsBorderBox = true,
  5162. val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
  5163. styles = getStyles( elem ),
  5164. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  5165. // some non-html elements return undefined for offsetWidth, so check for null/undefined
  5166. // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
  5167. // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
  5168. if ( val <= 0 || val == null ) {
  5169. // Fall back to computed then uncomputed css if necessary
  5170. val = curCSS( elem, name, styles );
  5171. if ( val < 0 || val == null ) {
  5172. val = elem.style[ name ];
  5173. }
  5174. // Computed unit is not pixels. Stop here and return.
  5175. if ( rnumnonpx.test(val) ) {
  5176. return val;
  5177. }
  5178. // we need the check for style in case a browser which returns unreliable values
  5179. // for getComputedStyle silently falls back to the reliable elem.style
  5180. valueIsBorderBox = isBorderBox &&
  5181. ( support.boxSizingReliable() || val === elem.style[ name ] );
  5182. // Normalize "", auto, and prepare for extra
  5183. val = parseFloat( val ) || 0;
  5184. }
  5185. // use the active box-sizing model to add/subtract irrelevant styles
  5186. return ( val +
  5187. augmentWidthOrHeight(
  5188. elem,
  5189. name,
  5190. extra || ( isBorderBox ? "border" : "content" ),
  5191. valueIsBorderBox,
  5192. styles
  5193. )
  5194. ) + "px";
  5195. }
  5196. function showHide( elements, show ) {
  5197. var display, elem, hidden,
  5198. values = [],
  5199. index = 0,
  5200. length = elements.length;
  5201. for ( ; index < length; index++ ) {
  5202. elem = elements[ index ];
  5203. if ( !elem.style ) {
  5204. continue;
  5205. }
  5206. values[ index ] = data_priv.get( elem, "olddisplay" );
  5207. display = elem.style.display;
  5208. if ( show ) {
  5209. // Reset the inline display of this element to learn if it is
  5210. // being hidden by cascaded rules or not
  5211. if ( !values[ index ] && display === "none" ) {
  5212. elem.style.display = "";
  5213. }
  5214. // Set elements which have been overridden with display: none
  5215. // in a stylesheet to whatever the default browser style is
  5216. // for such an element
  5217. if ( elem.style.display === "" && isHidden( elem ) ) {
  5218. values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
  5219. }
  5220. } else {
  5221. if ( !values[ index ] ) {
  5222. hidden = isHidden( elem );
  5223. if ( display && display !== "none" || !hidden ) {
  5224. data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css(elem, "display") );
  5225. }
  5226. }
  5227. }
  5228. }
  5229. // Set the display of most of the elements in a second loop
  5230. // to avoid the constant reflow
  5231. for ( index = 0; index < length; index++ ) {
  5232. elem = elements[ index ];
  5233. if ( !elem.style ) {
  5234. continue;
  5235. }
  5236. if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
  5237. elem.style.display = show ? values[ index ] || "" : "none";
  5238. }
  5239. }
  5240. return elements;
  5241. }
  5242. jQuery.extend({
  5243. // Add in style property hooks for overriding the default
  5244. // behavior of getting and setting a style property
  5245. cssHooks: {
  5246. opacity: {
  5247. get: function( elem, computed ) {
  5248. if ( computed ) {
  5249. // We should always get a number back from opacity
  5250. var ret = curCSS( elem, "opacity" );
  5251. return ret === "" ? "1" : ret;
  5252. }
  5253. }
  5254. }
  5255. },
  5256. // Don't automatically add "px" to these possibly-unitless properties
  5257. cssNumber: {
  5258. "columnCount": true,
  5259. "fillOpacity": true,
  5260. "fontWeight": true,
  5261. "lineHeight": true,
  5262. "opacity": true,
  5263. "order": true,
  5264. "orphans": true,
  5265. "widows": true,
  5266. "zIndex": true,
  5267. "zoom": true
  5268. },
  5269. // Add in properties whose names you wish to fix before
  5270. // setting or getting the value
  5271. cssProps: {
  5272. // normalize float css property
  5273. "float": "cssFloat"
  5274. },
  5275. // Get and set the style property on a DOM Node
  5276. style: function( elem, name, value, extra ) {
  5277. // Don't set styles on text and comment nodes
  5278. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  5279. return;
  5280. }
  5281. // Make sure that we're working with the right name
  5282. var ret, type, hooks,
  5283. origName = jQuery.camelCase( name ),
  5284. style = elem.style;
  5285. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
  5286. // gets hook for the prefixed version
  5287. // followed by the unprefixed version
  5288. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5289. // Check if we're setting a value
  5290. if ( value !== undefined ) {
  5291. type = typeof value;
  5292. // convert relative number strings (+= or -=) to relative numbers. #7345
  5293. if ( type === "string" && (ret = rrelNum.exec( value )) ) {
  5294. value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
  5295. // Fixes bug #9237
  5296. type = "number";
  5297. }
  5298. // Make sure that null and NaN values aren't set. See: #7116
  5299. if ( value == null || value !== value ) {
  5300. return;
  5301. }
  5302. // If a number was passed in, add 'px' to the (except for certain CSS properties)
  5303. if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
  5304. value += "px";
  5305. }
  5306. // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
  5307. // but it would mean to define eight (for every problematic property) identical functions
  5308. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  5309. style[ name ] = "inherit";
  5310. }
  5311. // If a hook was provided, use that value, otherwise just set the specified value
  5312. if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
  5313. // Support: Chrome, Safari
  5314. // Setting style to blank string required to delete "style: x !important;"
  5315. style[ name ] = "";
  5316. style[ name ] = value;
  5317. }
  5318. } else {
  5319. // If a hook was provided get the non-computed value from there
  5320. if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
  5321. return ret;
  5322. }
  5323. // Otherwise just get the value from the style object
  5324. return style[ name ];
  5325. }
  5326. },
  5327. css: function( elem, name, extra, styles ) {
  5328. var val, num, hooks,
  5329. origName = jQuery.camelCase( name );
  5330. // Make sure that we're working with the right name
  5331. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
  5332. // gets hook for the prefixed version
  5333. // followed by the unprefixed version
  5334. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5335. // If a hook was provided get the computed value from there
  5336. if ( hooks && "get" in hooks ) {
  5337. val = hooks.get( elem, true, extra );
  5338. }
  5339. // Otherwise, if a way to get the computed value exists, use that
  5340. if ( val === undefined ) {
  5341. val = curCSS( elem, name, styles );
  5342. }
  5343. //convert "normal" to computed value
  5344. if ( val === "normal" && name in cssNormalTransform ) {
  5345. val = cssNormalTransform[ name ];
  5346. }
  5347. // Return, converting to number if forced or a qualifier was provided and val looks numeric
  5348. if ( extra === "" || extra ) {
  5349. num = parseFloat( val );
  5350. return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
  5351. }
  5352. return val;
  5353. }
  5354. });
  5355. jQuery.each([ "height", "width" ], function( i, name ) {
  5356. jQuery.cssHooks[ name ] = {
  5357. get: function( elem, computed, extra ) {
  5358. if ( computed ) {
  5359. // certain elements can have dimension info if we invisibly show them
  5360. // however, it must have a current display style that would benefit from this
  5361. return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
  5362. jQuery.swap( elem, cssShow, function() {
  5363. return getWidthOrHeight( elem, name, extra );
  5364. }) :
  5365. getWidthOrHeight( elem, name, extra );
  5366. }
  5367. },
  5368. set: function( elem, value, extra ) {
  5369. var styles = extra && getStyles( elem );
  5370. return setPositiveNumber( elem, value, extra ?
  5371. augmentWidthOrHeight(
  5372. elem,
  5373. name,
  5374. extra,
  5375. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5376. styles
  5377. ) : 0
  5378. );
  5379. }
  5380. };
  5381. });
  5382. // Support: Android 2.3
  5383. jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
  5384. function( elem, computed ) {
  5385. if ( computed ) {
  5386. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5387. // Work around by temporarily setting element display to inline-block
  5388. return jQuery.swap( elem, { "display": "inline-block" },
  5389. curCSS, [ elem, "marginRight" ] );
  5390. }
  5391. }
  5392. );
  5393. // These hooks are used by animate to expand properties
  5394. jQuery.each({
  5395. margin: "",
  5396. padding: "",
  5397. border: "Width"
  5398. }, function( prefix, suffix ) {
  5399. jQuery.cssHooks[ prefix + suffix ] = {
  5400. expand: function( value ) {
  5401. var i = 0,
  5402. expanded = {},
  5403. // assumes a single number if not a string
  5404. parts = typeof value === "string" ? value.split(" ") : [ value ];
  5405. for ( ; i < 4; i++ ) {
  5406. expanded[ prefix + cssExpand[ i ] + suffix ] =
  5407. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  5408. }
  5409. return expanded;
  5410. }
  5411. };
  5412. if ( !rmargin.test( prefix ) ) {
  5413. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  5414. }
  5415. });
  5416. jQuery.fn.extend({
  5417. css: function( name, value ) {
  5418. return access( this, function( elem, name, value ) {
  5419. var styles, len,
  5420. map = {},
  5421. i = 0;
  5422. if ( jQuery.isArray( name ) ) {
  5423. styles = getStyles( elem );
  5424. len = name.length;
  5425. for ( ; i < len; i++ ) {
  5426. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  5427. }
  5428. return map;
  5429. }
  5430. return value !== undefined ?
  5431. jQuery.style( elem, name, value ) :
  5432. jQuery.css( elem, name );
  5433. }, name, value, arguments.length > 1 );
  5434. },
  5435. show: function() {
  5436. return showHide( this, true );
  5437. },
  5438. hide: function() {
  5439. return showHide( this );
  5440. },
  5441. toggle: function( state ) {
  5442. if ( typeof state === "boolean" ) {
  5443. return state ? this.show() : this.hide();
  5444. }
  5445. return this.each(function() {
  5446. if ( isHidden( this ) ) {
  5447. jQuery( this ).show();
  5448. } else {
  5449. jQuery( this ).hide();
  5450. }
  5451. });
  5452. }
  5453. });
  5454. function Tween( elem, options, prop, end, easing ) {
  5455. return new Tween.prototype.init( elem, options, prop, end, easing );
  5456. }
  5457. jQuery.Tween = Tween;
  5458. Tween.prototype = {
  5459. constructor: Tween,
  5460. init: function( elem, options, prop, end, easing, unit ) {
  5461. this.elem = elem;
  5462. this.prop = prop;
  5463. this.easing = easing || "swing";
  5464. this.options = options;
  5465. this.start = this.now = this.cur();
  5466. this.end = end;
  5467. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  5468. },
  5469. cur: function() {
  5470. var hooks = Tween.propHooks[ this.prop ];
  5471. return hooks && hooks.get ?
  5472. hooks.get( this ) :
  5473. Tween.propHooks._default.get( this );
  5474. },
  5475. run: function( percent ) {
  5476. var eased,
  5477. hooks = Tween.propHooks[ this.prop ];
  5478. if ( this.options.duration ) {
  5479. this.pos = eased = jQuery.easing[ this.easing ](
  5480. percent, this.options.duration * percent, 0, 1, this.options.duration
  5481. );
  5482. } else {
  5483. this.pos = eased = percent;
  5484. }
  5485. this.now = ( this.end - this.start ) * eased + this.start;
  5486. if ( this.options.step ) {
  5487. this.options.step.call( this.elem, this.now, this );
  5488. }
  5489. if ( hooks && hooks.set ) {
  5490. hooks.set( this );
  5491. } else {
  5492. Tween.propHooks._default.set( this );
  5493. }
  5494. return this;
  5495. }
  5496. };
  5497. Tween.prototype.init.prototype = Tween.prototype;
  5498. Tween.propHooks = {
  5499. _default: {
  5500. get: function( tween ) {
  5501. var result;
  5502. if ( tween.elem[ tween.prop ] != null &&
  5503. (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
  5504. return tween.elem[ tween.prop ];
  5505. }
  5506. // passing an empty string as a 3rd parameter to .css will automatically
  5507. // attempt a parseFloat and fallback to a string if the parse fails
  5508. // so, simple values such as "10px" are parsed to Float.
  5509. // complex values such as "rotate(1rad)" are returned as is.
  5510. result = jQuery.css( tween.elem, tween.prop, "" );
  5511. // Empty strings, null, undefined and "auto" are converted to 0.
  5512. return !result || result === "auto" ? 0 : result;
  5513. },
  5514. set: function( tween ) {
  5515. // use step hook for back compat - use cssHook if its there - use .style if its
  5516. // available and use plain properties where available
  5517. if ( jQuery.fx.step[ tween.prop ] ) {
  5518. jQuery.fx.step[ tween.prop ]( tween );
  5519. } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
  5520. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  5521. } else {
  5522. tween.elem[ tween.prop ] = tween.now;
  5523. }
  5524. }
  5525. }
  5526. };
  5527. // Support: IE9
  5528. // Panic based approach to setting things on disconnected nodes
  5529. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  5530. set: function( tween ) {
  5531. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  5532. tween.elem[ tween.prop ] = tween.now;
  5533. }
  5534. }
  5535. };
  5536. jQuery.easing = {
  5537. linear: function( p ) {
  5538. return p;
  5539. },
  5540. swing: function( p ) {
  5541. return 0.5 - Math.cos( p * Math.PI ) / 2;
  5542. }
  5543. };
  5544. jQuery.fx = Tween.prototype.init;
  5545. // Back Compat <1.8 extension point
  5546. jQuery.fx.step = {};
  5547. var
  5548. fxNow, timerId,
  5549. rfxtypes = /^(?:toggle|show|hide)$/,
  5550. rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
  5551. rrun = /queueHooks$/,
  5552. animationPrefilters = [ defaultPrefilter ],
  5553. tweeners = {
  5554. "*": [ function( prop, value ) {
  5555. var tween = this.createTween( prop, value ),
  5556. target = tween.cur(),
  5557. parts = rfxnum.exec( value ),
  5558. unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  5559. // Starting value computation is required for potential unit mismatches
  5560. start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
  5561. rfxnum.exec( jQuery.css( tween.elem, prop ) ),
  5562. scale = 1,
  5563. maxIterations = 20;
  5564. if ( start && start[ 3 ] !== unit ) {
  5565. // Trust units reported by jQuery.css
  5566. unit = unit || start[ 3 ];
  5567. // Make sure we update the tween properties later on
  5568. parts = parts || [];
  5569. // Iteratively approximate from a nonzero starting point
  5570. start = +target || 1;
  5571. do {
  5572. // If previous iteration zeroed out, double until we get *something*
  5573. // Use a string for doubling factor so we don't accidentally see scale as unchanged below
  5574. scale = scale || ".5";
  5575. // Adjust and apply
  5576. start = start / scale;
  5577. jQuery.style( tween.elem, prop, start + unit );
  5578. // Update scale, tolerating zero or NaN from tween.cur()
  5579. // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
  5580. } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
  5581. }
  5582. // Update tween properties
  5583. if ( parts ) {
  5584. start = tween.start = +start || +target || 0;
  5585. tween.unit = unit;
  5586. // If a +=/-= token was provided, we're doing a relative animation
  5587. tween.end = parts[ 1 ] ?
  5588. start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
  5589. +parts[ 2 ];
  5590. }
  5591. return tween;
  5592. } ]
  5593. };
  5594. // Animations created synchronously will run synchronously
  5595. function createFxNow() {
  5596. setTimeout(function() {
  5597. fxNow = undefined;
  5598. });
  5599. return ( fxNow = jQuery.now() );
  5600. }
  5601. // Generate parameters to create a standard animation
  5602. function genFx( type, includeWidth ) {
  5603. var which,
  5604. i = 0,
  5605. attrs = { height: type };
  5606. // if we include width, step value is 1 to do all cssExpand values,
  5607. // if we don't include width, step value is 2 to skip over Left and Right
  5608. includeWidth = includeWidth ? 1 : 0;
  5609. for ( ; i < 4 ; i += 2 - includeWidth ) {
  5610. which = cssExpand[ i ];
  5611. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  5612. }
  5613. if ( includeWidth ) {
  5614. attrs.opacity = attrs.width = type;
  5615. }
  5616. return attrs;
  5617. }
  5618. function createTween( value, prop, animation ) {
  5619. var tween,
  5620. collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
  5621. index = 0,
  5622. length = collection.length;
  5623. for ( ; index < length; index++ ) {
  5624. if ( (tween = collection[ index ].call( animation, prop, value )) ) {
  5625. // we're done with this property
  5626. return tween;
  5627. }
  5628. }
  5629. }
  5630. function defaultPrefilter( elem, props, opts ) {
  5631. /* jshint validthis: true */
  5632. var prop, value, toggle, tween, hooks, oldfire, display,
  5633. anim = this,
  5634. orig = {},
  5635. style = elem.style,
  5636. hidden = elem.nodeType && isHidden( elem ),
  5637. dataShow = data_priv.get( elem, "fxshow" );
  5638. // handle queue: false promises
  5639. if ( !opts.queue ) {
  5640. hooks = jQuery._queueHooks( elem, "fx" );
  5641. if ( hooks.unqueued == null ) {
  5642. hooks.unqueued = 0;
  5643. oldfire = hooks.empty.fire;
  5644. hooks.empty.fire = function() {
  5645. if ( !hooks.unqueued ) {
  5646. oldfire();
  5647. }
  5648. };
  5649. }
  5650. hooks.unqueued++;
  5651. anim.always(function() {
  5652. // doing this makes sure that the complete handler will be called
  5653. // before this completes
  5654. anim.always(function() {
  5655. hooks.unqueued--;
  5656. if ( !jQuery.queue( elem, "fx" ).length ) {
  5657. hooks.empty.fire();
  5658. }
  5659. });
  5660. });
  5661. }
  5662. // height/width overflow pass
  5663. if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
  5664. // Make sure that nothing sneaks out
  5665. // Record all 3 overflow attributes because IE9-10 do not
  5666. // change the overflow attribute when overflowX and
  5667. // overflowY are set to the same value
  5668. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  5669. // Set display property to inline-block for height/width
  5670. // animations on inline elements that are having width/height animated
  5671. display = jQuery.css( elem, "display" );
  5672. // Get default display if display is currently "none"
  5673. if ( display === "none" ) {
  5674. display = defaultDisplay( elem.nodeName );
  5675. }
  5676. if ( display === "inline" &&
  5677. jQuery.css( elem, "float" ) === "none" ) {
  5678. style.display = "inline-block";
  5679. }
  5680. }
  5681. if ( opts.overflow ) {
  5682. style.overflow = "hidden";
  5683. anim.always(function() {
  5684. style.overflow = opts.overflow[ 0 ];
  5685. style.overflowX = opts.overflow[ 1 ];
  5686. style.overflowY = opts.overflow[ 2 ];
  5687. });
  5688. }
  5689. // show/hide pass
  5690. for ( prop in props ) {
  5691. value = props[ prop ];
  5692. if ( rfxtypes.exec( value ) ) {
  5693. delete props[ prop ];
  5694. toggle = toggle || value === "toggle";
  5695. if ( value === ( hidden ? "hide" : "show" ) ) {
  5696. // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
  5697. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  5698. hidden = true;
  5699. } else {
  5700. continue;
  5701. }
  5702. }
  5703. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  5704. }
  5705. }
  5706. if ( !jQuery.isEmptyObject( orig ) ) {
  5707. if ( dataShow ) {
  5708. if ( "hidden" in dataShow ) {
  5709. hidden = dataShow.hidden;
  5710. }
  5711. } else {
  5712. dataShow = data_priv.access( elem, "fxshow", {} );
  5713. }
  5714. // store state if its toggle - enables .stop().toggle() to "reverse"
  5715. if ( toggle ) {
  5716. dataShow.hidden = !hidden;
  5717. }
  5718. if ( hidden ) {
  5719. jQuery( elem ).show();
  5720. } else {
  5721. anim.done(function() {
  5722. jQuery( elem ).hide();
  5723. });
  5724. }
  5725. anim.done(function() {
  5726. var prop;
  5727. data_priv.remove( elem, "fxshow" );
  5728. for ( prop in orig ) {
  5729. jQuery.style( elem, prop, orig[ prop ] );
  5730. }
  5731. });
  5732. for ( prop in orig ) {
  5733. tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  5734. if ( !( prop in dataShow ) ) {
  5735. dataShow[ prop ] = tween.start;
  5736. if ( hidden ) {
  5737. tween.end = tween.start;
  5738. tween.start = prop === "width" || prop === "height" ? 1 : 0;
  5739. }
  5740. }
  5741. }
  5742. }
  5743. }
  5744. function propFilter( props, specialEasing ) {
  5745. var index, name, easing, value, hooks;
  5746. // camelCase, specialEasing and expand cssHook pass
  5747. for ( index in props ) {
  5748. name = jQuery.camelCase( index );
  5749. easing = specialEasing[ name ];
  5750. value = props[ index ];
  5751. if ( jQuery.isArray( value ) ) {
  5752. easing = value[ 1 ];
  5753. value = props[ index ] = value[ 0 ];
  5754. }
  5755. if ( index !== name ) {
  5756. props[ name ] = value;
  5757. delete props[ index ];
  5758. }
  5759. hooks = jQuery.cssHooks[ name ];
  5760. if ( hooks && "expand" in hooks ) {
  5761. value = hooks.expand( value );
  5762. delete props[ name ];
  5763. // not quite $.extend, this wont overwrite keys already present.
  5764. // also - reusing 'index' from above because we have the correct "name"
  5765. for ( index in value ) {
  5766. if ( !( index in props ) ) {
  5767. props[ index ] = value[ index ];
  5768. specialEasing[ index ] = easing;
  5769. }
  5770. }
  5771. } else {
  5772. specialEasing[ name ] = easing;
  5773. }
  5774. }
  5775. }
  5776. function Animation( elem, properties, options ) {
  5777. var result,
  5778. stopped,
  5779. index = 0,
  5780. length = animationPrefilters.length,
  5781. deferred = jQuery.Deferred().always( function() {
  5782. // don't match elem in the :animated selector
  5783. delete tick.elem;
  5784. }),
  5785. tick = function() {
  5786. if ( stopped ) {
  5787. return false;
  5788. }
  5789. var currentTime = fxNow || createFxNow(),
  5790. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  5791. // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
  5792. temp = remaining / animation.duration || 0,
  5793. percent = 1 - temp,
  5794. index = 0,
  5795. length = animation.tweens.length;
  5796. for ( ; index < length ; index++ ) {
  5797. animation.tweens[ index ].run( percent );
  5798. }
  5799. deferred.notifyWith( elem, [ animation, percent, remaining ]);
  5800. if ( percent < 1 && length ) {
  5801. return remaining;
  5802. } else {
  5803. deferred.resolveWith( elem, [ animation ] );
  5804. return false;
  5805. }
  5806. },
  5807. animation = deferred.promise({
  5808. elem: elem,
  5809. props: jQuery.extend( {}, properties ),
  5810. opts: jQuery.extend( true, { specialEasing: {} }, options ),
  5811. originalProperties: properties,
  5812. originalOptions: options,
  5813. startTime: fxNow || createFxNow(),
  5814. duration: options.duration,
  5815. tweens: [],
  5816. createTween: function( prop, end ) {
  5817. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  5818. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  5819. animation.tweens.push( tween );
  5820. return tween;
  5821. },
  5822. stop: function( gotoEnd ) {
  5823. var index = 0,
  5824. // if we are going to the end, we want to run all the tweens
  5825. // otherwise we skip this part
  5826. length = gotoEnd ? animation.tweens.length : 0;
  5827. if ( stopped ) {
  5828. return this;
  5829. }
  5830. stopped = true;
  5831. for ( ; index < length ; index++ ) {
  5832. animation.tweens[ index ].run( 1 );
  5833. }
  5834. // resolve when we played the last frame
  5835. // otherwise, reject
  5836. if ( gotoEnd ) {
  5837. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  5838. } else {
  5839. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  5840. }
  5841. return this;
  5842. }
  5843. }),
  5844. props = animation.props;
  5845. propFilter( props, animation.opts.specialEasing );
  5846. for ( ; index < length ; index++ ) {
  5847. result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
  5848. if ( result ) {
  5849. return result;
  5850. }
  5851. }
  5852. jQuery.map( props, createTween, animation );
  5853. if ( jQuery.isFunction( animation.opts.start ) ) {
  5854. animation.opts.start.call( elem, animation );
  5855. }
  5856. jQuery.fx.timer(
  5857. jQuery.extend( tick, {
  5858. elem: elem,
  5859. anim: animation,
  5860. queue: animation.opts.queue
  5861. })
  5862. );
  5863. // attach callbacks from options
  5864. return animation.progress( animation.opts.progress )
  5865. .done( animation.opts.done, animation.opts.complete )
  5866. .fail( animation.opts.fail )
  5867. .always( animation.opts.always );
  5868. }
  5869. jQuery.Animation = jQuery.extend( Animation, {
  5870. tweener: function( props, callback ) {
  5871. if ( jQuery.isFunction( props ) ) {
  5872. callback = props;
  5873. props = [ "*" ];
  5874. } else {
  5875. props = props.split(" ");
  5876. }
  5877. var prop,
  5878. index = 0,
  5879. length = props.length;
  5880. for ( ; index < length ; index++ ) {
  5881. prop = props[ index ];
  5882. tweeners[ prop ] = tweeners[ prop ] || [];
  5883. tweeners[ prop ].unshift( callback );
  5884. }
  5885. },
  5886. prefilter: function( callback, prepend ) {
  5887. if ( prepend ) {
  5888. animationPrefilters.unshift( callback );
  5889. } else {
  5890. animationPrefilters.push( callback );
  5891. }
  5892. }
  5893. });
  5894. jQuery.speed = function( speed, easing, fn ) {
  5895. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  5896. complete: fn || !fn && easing ||
  5897. jQuery.isFunction( speed ) && speed,
  5898. duration: speed,
  5899. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  5900. };
  5901. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  5902. opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
  5903. // normalize opt.queue - true/undefined/null -> "fx"
  5904. if ( opt.queue == null || opt.queue === true ) {
  5905. opt.queue = "fx";
  5906. }
  5907. // Queueing
  5908. opt.old = opt.complete;
  5909. opt.complete = function() {
  5910. if ( jQuery.isFunction( opt.old ) ) {
  5911. opt.old.call( this );
  5912. }
  5913. if ( opt.queue ) {
  5914. jQuery.dequeue( this, opt.queue );
  5915. }
  5916. };
  5917. return opt;
  5918. };
  5919. jQuery.fn.extend({
  5920. fadeTo: function( speed, to, easing, callback ) {
  5921. // show any hidden elements after setting opacity to 0
  5922. return this.filter( isHidden ).css( "opacity", 0 ).show()
  5923. // animate to the value specified
  5924. .end().animate({ opacity: to }, speed, easing, callback );
  5925. },
  5926. animate: function( prop, speed, easing, callback ) {
  5927. var empty = jQuery.isEmptyObject( prop ),
  5928. optall = jQuery.speed( speed, easing, callback ),
  5929. doAnimation = function() {
  5930. // Operate on a copy of prop so per-property easing won't be lost
  5931. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  5932. // Empty animations, or finishing resolves immediately
  5933. if ( empty || data_priv.get( this, "finish" ) ) {
  5934. anim.stop( true );
  5935. }
  5936. };
  5937. doAnimation.finish = doAnimation;
  5938. return empty || optall.queue === false ?
  5939. this.each( doAnimation ) :
  5940. this.queue( optall.queue, doAnimation );
  5941. },
  5942. stop: function( type, clearQueue, gotoEnd ) {
  5943. var stopQueue = function( hooks ) {
  5944. var stop = hooks.stop;
  5945. delete hooks.stop;
  5946. stop( gotoEnd );
  5947. };
  5948. if ( typeof type !== "string" ) {
  5949. gotoEnd = clearQueue;
  5950. clearQueue = type;
  5951. type = undefined;
  5952. }
  5953. if ( clearQueue && type !== false ) {
  5954. this.queue( type || "fx", [] );
  5955. }
  5956. return this.each(function() {
  5957. var dequeue = true,
  5958. index = type != null && type + "queueHooks",
  5959. timers = jQuery.timers,
  5960. data = data_priv.get( this );
  5961. if ( index ) {
  5962. if ( data[ index ] && data[ index ].stop ) {
  5963. stopQueue( data[ index ] );
  5964. }
  5965. } else {
  5966. for ( index in data ) {
  5967. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  5968. stopQueue( data[ index ] );
  5969. }
  5970. }
  5971. }
  5972. for ( index = timers.length; index--; ) {
  5973. if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
  5974. timers[ index ].anim.stop( gotoEnd );
  5975. dequeue = false;
  5976. timers.splice( index, 1 );
  5977. }
  5978. }
  5979. // start the next in the queue if the last step wasn't forced
  5980. // timers currently will call their complete callbacks, which will dequeue
  5981. // but only if they were gotoEnd
  5982. if ( dequeue || !gotoEnd ) {
  5983. jQuery.dequeue( this, type );
  5984. }
  5985. });
  5986. },
  5987. finish: function( type ) {
  5988. if ( type !== false ) {
  5989. type = type || "fx";
  5990. }
  5991. return this.each(function() {
  5992. var index,
  5993. data = data_priv.get( this ),
  5994. queue = data[ type + "queue" ],
  5995. hooks = data[ type + "queueHooks" ],
  5996. timers = jQuery.timers,
  5997. length = queue ? queue.length : 0;
  5998. // enable finishing flag on private data
  5999. data.finish = true;
  6000. // empty the queue first
  6001. jQuery.queue( this, type, [] );
  6002. if ( hooks && hooks.stop ) {
  6003. hooks.stop.call( this, true );
  6004. }
  6005. // look for any active animations, and finish them
  6006. for ( index = timers.length; index--; ) {
  6007. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  6008. timers[ index ].anim.stop( true );
  6009. timers.splice( index, 1 );
  6010. }
  6011. }
  6012. // look for any animations in the old queue and finish them
  6013. for ( index = 0; index < length; index++ ) {
  6014. if ( queue[ index ] && queue[ index ].finish ) {
  6015. queue[ index ].finish.call( this );
  6016. }
  6017. }
  6018. // turn off finishing flag
  6019. delete data.finish;
  6020. });
  6021. }
  6022. });
  6023. jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
  6024. var cssFn = jQuery.fn[ name ];
  6025. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6026. return speed == null || typeof speed === "boolean" ?
  6027. cssFn.apply( this, arguments ) :
  6028. this.animate( genFx( name, true ), speed, easing, callback );
  6029. };
  6030. });
  6031. // Generate shortcuts for custom animations
  6032. jQuery.each({
  6033. slideDown: genFx("show"),
  6034. slideUp: genFx("hide"),
  6035. slideToggle: genFx("toggle"),
  6036. fadeIn: { opacity: "show" },
  6037. fadeOut: { opacity: "hide" },
  6038. fadeToggle: { opacity: "toggle" }
  6039. }, function( name, props ) {
  6040. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6041. return this.animate( props, speed, easing, callback );
  6042. };
  6043. });
  6044. jQuery.timers = [];
  6045. jQuery.fx.tick = function() {
  6046. var timer,
  6047. i = 0,
  6048. timers = jQuery.timers;
  6049. fxNow = jQuery.now();
  6050. for ( ; i < timers.length; i++ ) {
  6051. timer = timers[ i ];
  6052. // Checks the timer has not already been removed
  6053. if ( !timer() && timers[ i ] === timer ) {
  6054. timers.splice( i--, 1 );
  6055. }
  6056. }
  6057. if ( !timers.length ) {
  6058. jQuery.fx.stop();
  6059. }
  6060. fxNow = undefined;
  6061. };
  6062. jQuery.fx.timer = function( timer ) {
  6063. jQuery.timers.push( timer );
  6064. if ( timer() ) {
  6065. jQuery.fx.start();
  6066. } else {
  6067. jQuery.timers.pop();
  6068. }
  6069. };
  6070. jQuery.fx.interval = 13;
  6071. jQuery.fx.start = function() {
  6072. if ( !timerId ) {
  6073. timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
  6074. }
  6075. };
  6076. jQuery.fx.stop = function() {
  6077. clearInterval( timerId );
  6078. timerId = null;
  6079. };
  6080. jQuery.fx.speeds = {
  6081. slow: 600,
  6082. fast: 200,
  6083. // Default speed
  6084. _default: 400
  6085. };
  6086. // Based off of the plugin by Clint Helfers, with permission.
  6087. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  6088. jQuery.fn.delay = function( time, type ) {
  6089. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  6090. type = type || "fx";
  6091. return this.queue( type, function( next, hooks ) {
  6092. var timeout = setTimeout( next, time );
  6093. hooks.stop = function() {
  6094. clearTimeout( timeout );
  6095. };
  6096. });
  6097. };
  6098. (function() {
  6099. var input = document.createElement( "input" ),
  6100. select = document.createElement( "select" ),
  6101. opt = select.appendChild( document.createElement( "option" ) );
  6102. input.type = "checkbox";
  6103. // Support: iOS 5.1, Android 4.x, Android 2.3
  6104. // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
  6105. support.checkOn = input.value !== "";
  6106. // Must access the parent to make an option select properly
  6107. // Support: IE9, IE10
  6108. support.optSelected = opt.selected;
  6109. // Make sure that the options inside disabled selects aren't marked as disabled
  6110. // (WebKit marks them as disabled)
  6111. select.disabled = true;
  6112. support.optDisabled = !opt.disabled;
  6113. // Check if an input maintains its value after becoming a radio
  6114. // Support: IE9, IE10
  6115. input = document.createElement( "input" );
  6116. input.value = "t";
  6117. input.type = "radio";
  6118. support.radioValue = input.value === "t";
  6119. })();
  6120. var nodeHook, boolHook,
  6121. attrHandle = jQuery.expr.attrHandle;
  6122. jQuery.fn.extend({
  6123. attr: function( name, value ) {
  6124. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  6125. },
  6126. removeAttr: function( name ) {
  6127. return this.each(function() {
  6128. jQuery.removeAttr( this, name );
  6129. });
  6130. }
  6131. });
  6132. jQuery.extend({
  6133. attr: function( elem, name, value ) {
  6134. var hooks, ret,
  6135. nType = elem.nodeType;
  6136. // don't get/set attributes on text, comment and attribute nodes
  6137. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6138. return;
  6139. }
  6140. // Fallback to prop when attributes are not supported
  6141. if ( typeof elem.getAttribute === strundefined ) {
  6142. return jQuery.prop( elem, name, value );
  6143. }
  6144. // All attributes are lowercase
  6145. // Grab necessary hook if one is defined
  6146. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6147. name = name.toLowerCase();
  6148. hooks = jQuery.attrHooks[ name ] ||
  6149. ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
  6150. }
  6151. if ( value !== undefined ) {
  6152. if ( value === null ) {
  6153. jQuery.removeAttr( elem, name );
  6154. } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
  6155. return ret;
  6156. } else {
  6157. elem.setAttribute( name, value + "" );
  6158. return value;
  6159. }
  6160. } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
  6161. return ret;
  6162. } else {
  6163. ret = jQuery.find.attr( elem, name );
  6164. // Non-existent attributes return null, we normalize to undefined
  6165. return ret == null ?
  6166. undefined :
  6167. ret;
  6168. }
  6169. },
  6170. removeAttr: function( elem, value ) {
  6171. var name, propName,
  6172. i = 0,
  6173. attrNames = value && value.match( rnotwhite );
  6174. if ( attrNames && elem.nodeType === 1 ) {
  6175. while ( (name = attrNames[i++]) ) {
  6176. propName = jQuery.propFix[ name ] || name;
  6177. // Boolean attributes get special treatment (#10870)
  6178. if ( jQuery.expr.match.bool.test( name ) ) {
  6179. // Set corresponding property to false
  6180. elem[ propName ] = false;
  6181. }
  6182. elem.removeAttribute( name );
  6183. }
  6184. }
  6185. },
  6186. attrHooks: {
  6187. type: {
  6188. set: function( elem, value ) {
  6189. if ( !support.radioValue && value === "radio" &&
  6190. jQuery.nodeName( elem, "input" ) ) {
  6191. // Setting the type on a radio button after the value resets the value in IE6-9
  6192. // Reset value to default in case type is set after value during creation
  6193. var val = elem.value;
  6194. elem.setAttribute( "type", value );
  6195. if ( val ) {
  6196. elem.value = val;
  6197. }
  6198. return value;
  6199. }
  6200. }
  6201. }
  6202. }
  6203. });
  6204. // Hooks for boolean attributes
  6205. boolHook = {
  6206. set: function( elem, value, name ) {
  6207. if ( value === false ) {
  6208. // Remove boolean attributes when set to false
  6209. jQuery.removeAttr( elem, name );
  6210. } else {
  6211. elem.setAttribute( name, name );
  6212. }
  6213. return name;
  6214. }
  6215. };
  6216. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  6217. var getter = attrHandle[ name ] || jQuery.find.attr;
  6218. attrHandle[ name ] = function( elem, name, isXML ) {
  6219. var ret, handle;
  6220. if ( !isXML ) {
  6221. // Avoid an infinite loop by temporarily removing this function from the getter
  6222. handle = attrHandle[ name ];
  6223. attrHandle[ name ] = ret;
  6224. ret = getter( elem, name, isXML ) != null ?
  6225. name.toLowerCase() :
  6226. null;
  6227. attrHandle[ name ] = handle;
  6228. }
  6229. return ret;
  6230. };
  6231. });
  6232. var rfocusable = /^(?:input|select|textarea|button)$/i;
  6233. jQuery.fn.extend({
  6234. prop: function( name, value ) {
  6235. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  6236. },
  6237. removeProp: function( name ) {
  6238. return this.each(function() {
  6239. delete this[ jQuery.propFix[ name ] || name ];
  6240. });
  6241. }
  6242. });
  6243. jQuery.extend({
  6244. propFix: {
  6245. "for": "htmlFor",
  6246. "class": "className"
  6247. },
  6248. prop: function( elem, name, value ) {
  6249. var ret, hooks, notxml,
  6250. nType = elem.nodeType;
  6251. // don't get/set properties on text, comment and attribute nodes
  6252. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6253. return;
  6254. }
  6255. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  6256. if ( notxml ) {
  6257. // Fix name and attach hooks
  6258. name = jQuery.propFix[ name ] || name;
  6259. hooks = jQuery.propHooks[ name ];
  6260. }
  6261. if ( value !== undefined ) {
  6262. return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
  6263. ret :
  6264. ( elem[ name ] = value );
  6265. } else {
  6266. return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
  6267. ret :
  6268. elem[ name ];
  6269. }
  6270. },
  6271. propHooks: {
  6272. tabIndex: {
  6273. get: function( elem ) {
  6274. return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
  6275. elem.tabIndex :
  6276. -1;
  6277. }
  6278. }
  6279. }
  6280. });
  6281. // Support: IE9+
  6282. // Selectedness for an option in an optgroup can be inaccurate
  6283. if ( !support.optSelected ) {
  6284. jQuery.propHooks.selected = {
  6285. get: function( elem ) {
  6286. var parent = elem.parentNode;
  6287. if ( parent && parent.parentNode ) {
  6288. parent.parentNode.selectedIndex;
  6289. }
  6290. return null;
  6291. }
  6292. };
  6293. }
  6294. jQuery.each([
  6295. "tabIndex",
  6296. "readOnly",
  6297. "maxLength",
  6298. "cellSpacing",
  6299. "cellPadding",
  6300. "rowSpan",
  6301. "colSpan",
  6302. "useMap",
  6303. "frameBorder",
  6304. "contentEditable"
  6305. ], function() {
  6306. jQuery.propFix[ this.toLowerCase() ] = this;
  6307. });
  6308. var rclass = /[\t\r\n\f]/g;
  6309. jQuery.fn.extend({
  6310. addClass: function( value ) {
  6311. var classes, elem, cur, clazz, j, finalValue,
  6312. proceed = typeof value === "string" && value,
  6313. i = 0,
  6314. len = this.length;
  6315. if ( jQuery.isFunction( value ) ) {
  6316. return this.each(function( j ) {
  6317. jQuery( this ).addClass( value.call( this, j, this.className ) );
  6318. });
  6319. }
  6320. if ( proceed ) {
  6321. // The disjunction here is for better compressibility (see removeClass)
  6322. classes = ( value || "" ).match( rnotwhite ) || [];
  6323. for ( ; i < len; i++ ) {
  6324. elem = this[ i ];
  6325. cur = elem.nodeType === 1 && ( elem.className ?
  6326. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6327. " "
  6328. );
  6329. if ( cur ) {
  6330. j = 0;
  6331. while ( (clazz = classes[j++]) ) {
  6332. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  6333. cur += clazz + " ";
  6334. }
  6335. }
  6336. // only assign if different to avoid unneeded rendering.
  6337. finalValue = jQuery.trim( cur );
  6338. if ( elem.className !== finalValue ) {
  6339. elem.className = finalValue;
  6340. }
  6341. }
  6342. }
  6343. }
  6344. return this;
  6345. },
  6346. removeClass: function( value ) {
  6347. var classes, elem, cur, clazz, j, finalValue,
  6348. proceed = arguments.length === 0 || typeof value === "string" && value,
  6349. i = 0,
  6350. len = this.length;
  6351. if ( jQuery.isFunction( value ) ) {
  6352. return this.each(function( j ) {
  6353. jQuery( this ).removeClass( value.call( this, j, this.className ) );
  6354. });
  6355. }
  6356. if ( proceed ) {
  6357. classes = ( value || "" ).match( rnotwhite ) || [];
  6358. for ( ; i < len; i++ ) {
  6359. elem = this[ i ];
  6360. // This expression is here for better compressibility (see addClass)
  6361. cur = elem.nodeType === 1 && ( elem.className ?
  6362. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6363. ""
  6364. );
  6365. if ( cur ) {
  6366. j = 0;
  6367. while ( (clazz = classes[j++]) ) {
  6368. // Remove *all* instances
  6369. while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
  6370. cur = cur.replace( " " + clazz + " ", " " );
  6371. }
  6372. }
  6373. // only assign if different to avoid unneeded rendering.
  6374. finalValue = value ? jQuery.trim( cur ) : "";
  6375. if ( elem.className !== finalValue ) {
  6376. elem.className = finalValue;
  6377. }
  6378. }
  6379. }
  6380. }
  6381. return this;
  6382. },
  6383. toggleClass: function( value, stateVal ) {
  6384. var type = typeof value;
  6385. if ( typeof stateVal === "boolean" && type === "string" ) {
  6386. return stateVal ? this.addClass( value ) : this.removeClass( value );
  6387. }
  6388. if ( jQuery.isFunction( value ) ) {
  6389. return this.each(function( i ) {
  6390. jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
  6391. });
  6392. }
  6393. return this.each(function() {
  6394. if ( type === "string" ) {
  6395. // toggle individual class names
  6396. var className,
  6397. i = 0,
  6398. self = jQuery( this ),
  6399. classNames = value.match( rnotwhite ) || [];
  6400. while ( (className = classNames[ i++ ]) ) {
  6401. // check each className given, space separated list
  6402. if ( self.hasClass( className ) ) {
  6403. self.removeClass( className );
  6404. } else {
  6405. self.addClass( className );
  6406. }
  6407. }
  6408. // Toggle whole class name
  6409. } else if ( type === strundefined || type === "boolean" ) {
  6410. if ( this.className ) {
  6411. // store className if set
  6412. data_priv.set( this, "__className__", this.className );
  6413. }
  6414. // If the element has a class name or if we're passed "false",
  6415. // then remove the whole classname (if there was one, the above saved it).
  6416. // Otherwise bring back whatever was previously saved (if anything),
  6417. // falling back to the empty string if nothing was stored.
  6418. this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
  6419. }
  6420. });
  6421. },
  6422. hasClass: function( selector ) {
  6423. var className = " " + selector + " ",
  6424. i = 0,
  6425. l = this.length;
  6426. for ( ; i < l; i++ ) {
  6427. if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
  6428. return true;
  6429. }
  6430. }
  6431. return false;
  6432. }
  6433. });
  6434. var rreturn = /\r/g;
  6435. jQuery.fn.extend({
  6436. val: function( value ) {
  6437. var hooks, ret, isFunction,
  6438. elem = this[0];
  6439. if ( !arguments.length ) {
  6440. if ( elem ) {
  6441. hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  6442. if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
  6443. return ret;
  6444. }
  6445. ret = elem.value;
  6446. return typeof ret === "string" ?
  6447. // handle most common string cases
  6448. ret.replace(rreturn, "") :
  6449. // handle cases where value is null/undef or number
  6450. ret == null ? "" : ret;
  6451. }
  6452. return;
  6453. }
  6454. isFunction = jQuery.isFunction( value );
  6455. return this.each(function( i ) {
  6456. var val;
  6457. if ( this.nodeType !== 1 ) {
  6458. return;
  6459. }
  6460. if ( isFunction ) {
  6461. val = value.call( this, i, jQuery( this ).val() );
  6462. } else {
  6463. val = value;
  6464. }
  6465. // Treat null/undefined as ""; convert numbers to string
  6466. if ( val == null ) {
  6467. val = "";
  6468. } else if ( typeof val === "number" ) {
  6469. val += "";
  6470. } else if ( jQuery.isArray( val ) ) {
  6471. val = jQuery.map( val, function( value ) {
  6472. return value == null ? "" : value + "";
  6473. });
  6474. }
  6475. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  6476. // If set returns undefined, fall back to normal setting
  6477. if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
  6478. this.value = val;
  6479. }
  6480. });
  6481. }
  6482. });
  6483. jQuery.extend({
  6484. valHooks: {
  6485. select: {
  6486. get: function( elem ) {
  6487. var value, option,
  6488. options = elem.options,
  6489. index = elem.selectedIndex,
  6490. one = elem.type === "select-one" || index < 0,
  6491. values = one ? null : [],
  6492. max = one ? index + 1 : options.length,
  6493. i = index < 0 ?
  6494. max :
  6495. one ? index : 0;
  6496. // Loop through all the selected options
  6497. for ( ; i < max; i++ ) {
  6498. option = options[ i ];
  6499. // IE6-9 doesn't update selected after form reset (#2551)
  6500. if ( ( option.selected || i === index ) &&
  6501. // Don't return options that are disabled or in a disabled optgroup
  6502. ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
  6503. ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
  6504. // Get the specific value for the option
  6505. value = jQuery( option ).val();
  6506. // We don't need an array for one selects
  6507. if ( one ) {
  6508. return value;
  6509. }
  6510. // Multi-Selects return an array
  6511. values.push( value );
  6512. }
  6513. }
  6514. return values;
  6515. },
  6516. set: function( elem, value ) {
  6517. var optionSet, option,
  6518. options = elem.options,
  6519. values = jQuery.makeArray( value ),
  6520. i = options.length;
  6521. while ( i-- ) {
  6522. option = options[ i ];
  6523. if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) {
  6524. optionSet = true;
  6525. }
  6526. }
  6527. // force browsers to behave consistently when non-matching value is set
  6528. if ( !optionSet ) {
  6529. elem.selectedIndex = -1;
  6530. }
  6531. return values;
  6532. }
  6533. }
  6534. }
  6535. });
  6536. // Radios and checkboxes getter/setter
  6537. jQuery.each([ "radio", "checkbox" ], function() {
  6538. jQuery.valHooks[ this ] = {
  6539. set: function( elem, value ) {
  6540. if ( jQuery.isArray( value ) ) {
  6541. return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
  6542. }
  6543. }
  6544. };
  6545. if ( !support.checkOn ) {
  6546. jQuery.valHooks[ this ].get = function( elem ) {
  6547. // Support: Webkit
  6548. // "" is returned instead of "on" if a value isn't specified
  6549. return elem.getAttribute("value") === null ? "on" : elem.value;
  6550. };
  6551. }
  6552. });
  6553. // Return jQuery for attributes-only inclusion
  6554. jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
  6555. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  6556. "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
  6557. // Handle event binding
  6558. jQuery.fn[ name ] = function( data, fn ) {
  6559. return arguments.length > 0 ?
  6560. this.on( name, null, data, fn ) :
  6561. this.trigger( name );
  6562. };
  6563. });
  6564. jQuery.fn.extend({
  6565. hover: function( fnOver, fnOut ) {
  6566. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  6567. },
  6568. bind: function( types, data, fn ) {
  6569. return this.on( types, null, data, fn );
  6570. },
  6571. unbind: function( types, fn ) {
  6572. return this.off( types, null, fn );
  6573. },
  6574. delegate: function( selector, types, data, fn ) {
  6575. return this.on( types, selector, data, fn );
  6576. },
  6577. undelegate: function( selector, types, fn ) {
  6578. // ( namespace ) or ( selector, types [, fn] )
  6579. return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
  6580. }
  6581. });
  6582. var nonce = jQuery.now();
  6583. var rquery = (/\?/);
  6584. // Support: Android 2.3
  6585. // Workaround failure to string-cast null input
  6586. jQuery.parseJSON = function( data ) {
  6587. return JSON.parse( data + "" );
  6588. };
  6589. // Cross-browser xml parsing
  6590. jQuery.parseXML = function( data ) {
  6591. var xml, tmp;
  6592. if ( !data || typeof data !== "string" ) {
  6593. return null;
  6594. }
  6595. // Support: IE9
  6596. try {
  6597. tmp = new DOMParser();
  6598. xml = tmp.parseFromString( data, "text/xml" );
  6599. } catch ( e ) {
  6600. xml = undefined;
  6601. }
  6602. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  6603. jQuery.error( "Invalid XML: " + data );
  6604. }
  6605. return xml;
  6606. };
  6607. var
  6608. // Document location
  6609. ajaxLocParts,
  6610. ajaxLocation,
  6611. rhash = /#.*$/,
  6612. rts = /([?&])_=[^&]*/,
  6613. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  6614. // #7653, #8125, #8152: local protocol detection
  6615. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  6616. rnoContent = /^(?:GET|HEAD)$/,
  6617. rprotocol = /^\/\//,
  6618. rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
  6619. /* Prefilters
  6620. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  6621. * 2) These are called:
  6622. * - BEFORE asking for a transport
  6623. * - AFTER param serialization (s.data is a string if s.processData is true)
  6624. * 3) key is the dataType
  6625. * 4) the catchall symbol "*" can be used
  6626. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  6627. */
  6628. prefilters = {},
  6629. /* Transports bindings
  6630. * 1) key is the dataType
  6631. * 2) the catchall symbol "*" can be used
  6632. * 3) selection will start with transport dataType and THEN go to "*" if needed
  6633. */
  6634. transports = {},
  6635. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  6636. allTypes = "*/".concat("*");
  6637. // #8138, IE may throw an exception when accessing
  6638. // a field from window.location if document.domain has been set
  6639. try {
  6640. ajaxLocation = location.href;
  6641. } catch( e ) {
  6642. // Use the href attribute of an A element
  6643. // since IE will modify it given document.location
  6644. ajaxLocation = document.createElement( "a" );
  6645. ajaxLocation.href = "";
  6646. ajaxLocation = ajaxLocation.href;
  6647. }
  6648. // Segment location into parts
  6649. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
  6650. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  6651. function addToPrefiltersOrTransports( structure ) {
  6652. // dataTypeExpression is optional and defaults to "*"
  6653. return function( dataTypeExpression, func ) {
  6654. if ( typeof dataTypeExpression !== "string" ) {
  6655. func = dataTypeExpression;
  6656. dataTypeExpression = "*";
  6657. }
  6658. var dataType,
  6659. i = 0,
  6660. dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
  6661. if ( jQuery.isFunction( func ) ) {
  6662. // For each dataType in the dataTypeExpression
  6663. while ( (dataType = dataTypes[i++]) ) {
  6664. // Prepend if requested
  6665. if ( dataType[0] === "+" ) {
  6666. dataType = dataType.slice( 1 ) || "*";
  6667. (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
  6668. // Otherwise append
  6669. } else {
  6670. (structure[ dataType ] = structure[ dataType ] || []).push( func );
  6671. }
  6672. }
  6673. }
  6674. };
  6675. }
  6676. // Base inspection function for prefilters and transports
  6677. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  6678. var inspected = {},
  6679. seekingTransport = ( structure === transports );
  6680. function inspect( dataType ) {
  6681. var selected;
  6682. inspected[ dataType ] = true;
  6683. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  6684. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  6685. if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  6686. options.dataTypes.unshift( dataTypeOrTransport );
  6687. inspect( dataTypeOrTransport );
  6688. return false;
  6689. } else if ( seekingTransport ) {
  6690. return !( selected = dataTypeOrTransport );
  6691. }
  6692. });
  6693. return selected;
  6694. }
  6695. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  6696. }
  6697. // A special extend for ajax options
  6698. // that takes "flat" options (not to be deep extended)
  6699. // Fixes #9887
  6700. function ajaxExtend( target, src ) {
  6701. var key, deep,
  6702. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  6703. for ( key in src ) {
  6704. if ( src[ key ] !== undefined ) {
  6705. ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
  6706. }
  6707. }
  6708. if ( deep ) {
  6709. jQuery.extend( true, target, deep );
  6710. }
  6711. return target;
  6712. }
  6713. /* Handles responses to an ajax request:
  6714. * - finds the right dataType (mediates between content-type and expected dataType)
  6715. * - returns the corresponding response
  6716. */
  6717. function ajaxHandleResponses( s, jqXHR, responses ) {
  6718. var ct, type, finalDataType, firstDataType,
  6719. contents = s.contents,
  6720. dataTypes = s.dataTypes;
  6721. // Remove auto dataType and get content-type in the process
  6722. while ( dataTypes[ 0 ] === "*" ) {
  6723. dataTypes.shift();
  6724. if ( ct === undefined ) {
  6725. ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
  6726. }
  6727. }
  6728. // Check if we're dealing with a known content-type
  6729. if ( ct ) {
  6730. for ( type in contents ) {
  6731. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  6732. dataTypes.unshift( type );
  6733. break;
  6734. }
  6735. }
  6736. }
  6737. // Check to see if we have a response for the expected dataType
  6738. if ( dataTypes[ 0 ] in responses ) {
  6739. finalDataType = dataTypes[ 0 ];
  6740. } else {
  6741. // Try convertible dataTypes
  6742. for ( type in responses ) {
  6743. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
  6744. finalDataType = type;
  6745. break;
  6746. }
  6747. if ( !firstDataType ) {
  6748. firstDataType = type;
  6749. }
  6750. }
  6751. // Or just use first one
  6752. finalDataType = finalDataType || firstDataType;
  6753. }
  6754. // If we found a dataType
  6755. // We add the dataType to the list if needed
  6756. // and return the corresponding response
  6757. if ( finalDataType ) {
  6758. if ( finalDataType !== dataTypes[ 0 ] ) {
  6759. dataTypes.unshift( finalDataType );
  6760. }
  6761. return responses[ finalDataType ];
  6762. }
  6763. }
  6764. /* Chain conversions given the request and the original response
  6765. * Also sets the responseXXX fields on the jqXHR instance
  6766. */
  6767. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  6768. var conv2, current, conv, tmp, prev,
  6769. converters = {},
  6770. // Work with a copy of dataTypes in case we need to modify it for conversion
  6771. dataTypes = s.dataTypes.slice();
  6772. // Create converters map with lowercased keys
  6773. if ( dataTypes[ 1 ] ) {
  6774. for ( conv in s.converters ) {
  6775. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  6776. }
  6777. }
  6778. current = dataTypes.shift();
  6779. // Convert to each sequential dataType
  6780. while ( current ) {
  6781. if ( s.responseFields[ current ] ) {
  6782. jqXHR[ s.responseFields[ current ] ] = response;
  6783. }
  6784. // Apply the dataFilter if provided
  6785. if ( !prev && isSuccess && s.dataFilter ) {
  6786. response = s.dataFilter( response, s.dataType );
  6787. }
  6788. prev = current;
  6789. current = dataTypes.shift();
  6790. if ( current ) {
  6791. // There's only work to do if current dataType is non-auto
  6792. if ( current === "*" ) {
  6793. current = prev;
  6794. // Convert response if prev dataType is non-auto and differs from current
  6795. } else if ( prev !== "*" && prev !== current ) {
  6796. // Seek a direct converter
  6797. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  6798. // If none found, seek a pair
  6799. if ( !conv ) {
  6800. for ( conv2 in converters ) {
  6801. // If conv2 outputs current
  6802. tmp = conv2.split( " " );
  6803. if ( tmp[ 1 ] === current ) {
  6804. // If prev can be converted to accepted input
  6805. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  6806. converters[ "* " + tmp[ 0 ] ];
  6807. if ( conv ) {
  6808. // Condense equivalence converters
  6809. if ( conv === true ) {
  6810. conv = converters[ conv2 ];
  6811. // Otherwise, insert the intermediate dataType
  6812. } else if ( converters[ conv2 ] !== true ) {
  6813. current = tmp[ 0 ];
  6814. dataTypes.unshift( tmp[ 1 ] );
  6815. }
  6816. break;
  6817. }
  6818. }
  6819. }
  6820. }
  6821. // Apply converter (if not an equivalence)
  6822. if ( conv !== true ) {
  6823. // Unless errors are allowed to bubble, catch and return them
  6824. if ( conv && s[ "throws" ] ) {
  6825. response = conv( response );
  6826. } else {
  6827. try {
  6828. response = conv( response );
  6829. } catch ( e ) {
  6830. return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
  6831. }
  6832. }
  6833. }
  6834. }
  6835. }
  6836. }
  6837. return { state: "success", data: response };
  6838. }
  6839. jQuery.extend({
  6840. // Counter for holding the number of active queries
  6841. active: 0,
  6842. // Last-Modified header cache for next request
  6843. lastModified: {},
  6844. etag: {},
  6845. ajaxSettings: {
  6846. url: ajaxLocation,
  6847. type: "GET",
  6848. isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
  6849. global: true,
  6850. processData: true,
  6851. async: true,
  6852. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  6853. /*
  6854. timeout: 0,
  6855. data: null,
  6856. dataType: null,
  6857. username: null,
  6858. password: null,
  6859. cache: null,
  6860. throws: false,
  6861. traditional: false,
  6862. headers: {},
  6863. */
  6864. accepts: {
  6865. "*": allTypes,
  6866. text: "text/plain",
  6867. html: "text/html",
  6868. xml: "application/xml, text/xml",
  6869. json: "application/json, text/javascript"
  6870. },
  6871. contents: {
  6872. xml: /xml/,
  6873. html: /html/,
  6874. json: /json/
  6875. },
  6876. responseFields: {
  6877. xml: "responseXML",
  6878. text: "responseText",
  6879. json: "responseJSON"
  6880. },
  6881. // Data converters
  6882. // Keys separate source (or catchall "*") and destination types with a single space
  6883. converters: {
  6884. // Convert anything to text
  6885. "* text": String,
  6886. // Text to html (true = no transformation)
  6887. "text html": true,
  6888. // Evaluate text as a json expression
  6889. "text json": jQuery.parseJSON,
  6890. // Parse text as xml
  6891. "text xml": jQuery.parseXML
  6892. },
  6893. // For options that shouldn't be deep extended:
  6894. // you can add your own custom options here if
  6895. // and when you create one that shouldn't be
  6896. // deep extended (see ajaxExtend)
  6897. flatOptions: {
  6898. url: true,
  6899. context: true
  6900. }
  6901. },
  6902. // Creates a full fledged settings object into target
  6903. // with both ajaxSettings and settings fields.
  6904. // If target is omitted, writes into ajaxSettings.
  6905. ajaxSetup: function( target, settings ) {
  6906. return settings ?
  6907. // Building a settings object
  6908. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  6909. // Extending ajaxSettings
  6910. ajaxExtend( jQuery.ajaxSettings, target );
  6911. },
  6912. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  6913. ajaxTransport: addToPrefiltersOrTransports( transports ),
  6914. // Main method
  6915. ajax: function( url, options ) {
  6916. // If url is an object, simulate pre-1.5 signature
  6917. if ( typeof url === "object" ) {
  6918. options = url;
  6919. url = undefined;
  6920. }
  6921. // Force options to be an object
  6922. options = options || {};
  6923. var transport,
  6924. // URL without anti-cache param
  6925. cacheURL,
  6926. // Response headers
  6927. responseHeadersString,
  6928. responseHeaders,
  6929. // timeout handle
  6930. timeoutTimer,
  6931. // Cross-domain detection vars
  6932. parts,
  6933. // To know if global events are to be dispatched
  6934. fireGlobals,
  6935. // Loop variable
  6936. i,
  6937. // Create the final options object
  6938. s = jQuery.ajaxSetup( {}, options ),
  6939. // Callbacks context
  6940. callbackContext = s.context || s,
  6941. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  6942. globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
  6943. jQuery( callbackContext ) :
  6944. jQuery.event,
  6945. // Deferreds
  6946. deferred = jQuery.Deferred(),
  6947. completeDeferred = jQuery.Callbacks("once memory"),
  6948. // Status-dependent callbacks
  6949. statusCode = s.statusCode || {},
  6950. // Headers (they are sent all at once)
  6951. requestHeaders = {},
  6952. requestHeadersNames = {},
  6953. // The jqXHR state
  6954. state = 0,
  6955. // Default abort message
  6956. strAbort = "canceled",
  6957. // Fake xhr
  6958. jqXHR = {
  6959. readyState: 0,
  6960. // Builds headers hashtable if needed
  6961. getResponseHeader: function( key ) {
  6962. var match;
  6963. if ( state === 2 ) {
  6964. if ( !responseHeaders ) {
  6965. responseHeaders = {};
  6966. while ( (match = rheaders.exec( responseHeadersString )) ) {
  6967. responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
  6968. }
  6969. }
  6970. match = responseHeaders[ key.toLowerCase() ];
  6971. }
  6972. return match == null ? null : match;
  6973. },
  6974. // Raw string
  6975. getAllResponseHeaders: function() {
  6976. return state === 2 ? responseHeadersString : null;
  6977. },
  6978. // Caches the header
  6979. setRequestHeader: function( name, value ) {
  6980. var lname = name.toLowerCase();
  6981. if ( !state ) {
  6982. name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
  6983. requestHeaders[ name ] = value;
  6984. }
  6985. return this;
  6986. },
  6987. // Overrides response content-type header
  6988. overrideMimeType: function( type ) {
  6989. if ( !state ) {
  6990. s.mimeType = type;
  6991. }
  6992. return this;
  6993. },
  6994. // Status-dependent callbacks
  6995. statusCode: function( map ) {
  6996. var code;
  6997. if ( map ) {
  6998. if ( state < 2 ) {
  6999. for ( code in map ) {
  7000. // Lazy-add the new callback in a way that preserves old ones
  7001. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  7002. }
  7003. } else {
  7004. // Execute the appropriate callbacks
  7005. jqXHR.always( map[ jqXHR.status ] );
  7006. }
  7007. }
  7008. return this;
  7009. },
  7010. // Cancel the request
  7011. abort: function( statusText ) {
  7012. var finalText = statusText || strAbort;
  7013. if ( transport ) {
  7014. transport.abort( finalText );
  7015. }
  7016. done( 0, finalText );
  7017. return this;
  7018. }
  7019. };
  7020. // Attach deferreds
  7021. deferred.promise( jqXHR ).complete = completeDeferred.add;
  7022. jqXHR.success = jqXHR.done;
  7023. jqXHR.error = jqXHR.fail;
  7024. // Remove hash character (#7531: and string promotion)
  7025. // Add protocol if not provided (prefilters might expect it)
  7026. // Handle falsy url in the settings object (#10093: consistency with old signature)
  7027. // We also use the url parameter if available
  7028. s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
  7029. .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
  7030. // Alias method option to type as per ticket #12004
  7031. s.type = options.method || options.type || s.method || s.type;
  7032. // Extract dataTypes list
  7033. s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
  7034. // A cross-domain request is in order when we have a protocol:host:port mismatch
  7035. if ( s.crossDomain == null ) {
  7036. parts = rurl.exec( s.url.toLowerCase() );
  7037. s.crossDomain = !!( parts &&
  7038. ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
  7039. ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
  7040. ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
  7041. );
  7042. }
  7043. // Convert data if not already a string
  7044. if ( s.data && s.processData && typeof s.data !== "string" ) {
  7045. s.data = jQuery.param( s.data, s.traditional );
  7046. }
  7047. // Apply prefilters
  7048. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  7049. // If request was aborted inside a prefilter, stop there
  7050. if ( state === 2 ) {
  7051. return jqXHR;
  7052. }
  7053. // We can fire global events as of now if asked to
  7054. fireGlobals = s.global;
  7055. // Watch for a new set of requests
  7056. if ( fireGlobals && jQuery.active++ === 0 ) {
  7057. jQuery.event.trigger("ajaxStart");
  7058. }
  7059. // Uppercase the type
  7060. s.type = s.type.toUpperCase();
  7061. // Determine if request has content
  7062. s.hasContent = !rnoContent.test( s.type );
  7063. // Save the URL in case we're toying with the If-Modified-Since
  7064. // and/or If-None-Match header later on
  7065. cacheURL = s.url;
  7066. // More options handling for requests with no content
  7067. if ( !s.hasContent ) {
  7068. // If data is available, append data to url
  7069. if ( s.data ) {
  7070. cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
  7071. // #9682: remove data so that it's not used in an eventual retry
  7072. delete s.data;
  7073. }
  7074. // Add anti-cache in url if needed
  7075. if ( s.cache === false ) {
  7076. s.url = rts.test( cacheURL ) ?
  7077. // If there is already a '_' parameter, set its value
  7078. cacheURL.replace( rts, "$1_=" + nonce++ ) :
  7079. // Otherwise add one to the end
  7080. cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
  7081. }
  7082. }
  7083. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7084. if ( s.ifModified ) {
  7085. if ( jQuery.lastModified[ cacheURL ] ) {
  7086. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  7087. }
  7088. if ( jQuery.etag[ cacheURL ] ) {
  7089. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  7090. }
  7091. }
  7092. // Set the correct header, if data is being sent
  7093. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  7094. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  7095. }
  7096. // Set the Accepts header for the server, depending on the dataType
  7097. jqXHR.setRequestHeader(
  7098. "Accept",
  7099. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
  7100. s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  7101. s.accepts[ "*" ]
  7102. );
  7103. // Check for headers option
  7104. for ( i in s.headers ) {
  7105. jqXHR.setRequestHeader( i, s.headers[ i ] );
  7106. }
  7107. // Allow custom headers/mimetypes and early abort
  7108. if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
  7109. // Abort if not done already and return
  7110. return jqXHR.abort();
  7111. }
  7112. // aborting is no longer a cancellation
  7113. strAbort = "abort";
  7114. // Install callbacks on deferreds
  7115. for ( i in { success: 1, error: 1, complete: 1 } ) {
  7116. jqXHR[ i ]( s[ i ] );
  7117. }
  7118. // Get transport
  7119. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  7120. // If no transport, we auto-abort
  7121. if ( !transport ) {
  7122. done( -1, "No Transport" );
  7123. } else {
  7124. jqXHR.readyState = 1;
  7125. // Send global event
  7126. if ( fireGlobals ) {
  7127. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  7128. }
  7129. // Timeout
  7130. if ( s.async && s.timeout > 0 ) {
  7131. timeoutTimer = setTimeout(function() {
  7132. jqXHR.abort("timeout");
  7133. }, s.timeout );
  7134. }
  7135. try {
  7136. state = 1;
  7137. transport.send( requestHeaders, done );
  7138. } catch ( e ) {
  7139. // Propagate exception as error if not done
  7140. if ( state < 2 ) {
  7141. done( -1, e );
  7142. // Simply rethrow otherwise
  7143. } else {
  7144. throw e;
  7145. }
  7146. }
  7147. }
  7148. // Callback for when everything is done
  7149. function done( status, nativeStatusText, responses, headers ) {
  7150. var isSuccess, success, error, response, modified,
  7151. statusText = nativeStatusText;
  7152. // Called once
  7153. if ( state === 2 ) {
  7154. return;
  7155. }
  7156. // State is "done" now
  7157. state = 2;
  7158. // Clear timeout if it exists
  7159. if ( timeoutTimer ) {
  7160. clearTimeout( timeoutTimer );
  7161. }
  7162. // Dereference transport for early garbage collection
  7163. // (no matter how long the jqXHR object will be used)
  7164. transport = undefined;
  7165. // Cache response headers
  7166. responseHeadersString = headers || "";
  7167. // Set readyState
  7168. jqXHR.readyState = status > 0 ? 4 : 0;
  7169. // Determine if successful
  7170. isSuccess = status >= 200 && status < 300 || status === 304;
  7171. // Get response data
  7172. if ( responses ) {
  7173. response = ajaxHandleResponses( s, jqXHR, responses );
  7174. }
  7175. // Convert no matter what (that way responseXXX fields are always set)
  7176. response = ajaxConvert( s, response, jqXHR, isSuccess );
  7177. // If successful, handle type chaining
  7178. if ( isSuccess ) {
  7179. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7180. if ( s.ifModified ) {
  7181. modified = jqXHR.getResponseHeader("Last-Modified");
  7182. if ( modified ) {
  7183. jQuery.lastModified[ cacheURL ] = modified;
  7184. }
  7185. modified = jqXHR.getResponseHeader("etag");
  7186. if ( modified ) {
  7187. jQuery.etag[ cacheURL ] = modified;
  7188. }
  7189. }
  7190. // if no content
  7191. if ( status === 204 || s.type === "HEAD" ) {
  7192. statusText = "nocontent";
  7193. // if not modified
  7194. } else if ( status === 304 ) {
  7195. statusText = "notmodified";
  7196. // If we have data, let's convert it
  7197. } else {
  7198. statusText = response.state;
  7199. success = response.data;
  7200. error = response.error;
  7201. isSuccess = !error;
  7202. }
  7203. } else {
  7204. // We extract error from statusText
  7205. // then normalize statusText and status for non-aborts
  7206. error = statusText;
  7207. if ( status || !statusText ) {
  7208. statusText = "error";
  7209. if ( status < 0 ) {
  7210. status = 0;
  7211. }
  7212. }
  7213. }
  7214. // Set data for the fake xhr object
  7215. jqXHR.status = status;
  7216. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  7217. // Success/Error
  7218. if ( isSuccess ) {
  7219. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  7220. } else {
  7221. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  7222. }
  7223. // Status-dependent callbacks
  7224. jqXHR.statusCode( statusCode );
  7225. statusCode = undefined;
  7226. if ( fireGlobals ) {
  7227. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  7228. [ jqXHR, s, isSuccess ? success : error ] );
  7229. }
  7230. // Complete
  7231. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  7232. if ( fireGlobals ) {
  7233. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  7234. // Handle the global AJAX counter
  7235. if ( !( --jQuery.active ) ) {
  7236. jQuery.event.trigger("ajaxStop");
  7237. }
  7238. }
  7239. }
  7240. return jqXHR;
  7241. },
  7242. getJSON: function( url, data, callback ) {
  7243. return jQuery.get( url, data, callback, "json" );
  7244. },
  7245. getScript: function( url, callback ) {
  7246. return jQuery.get( url, undefined, callback, "script" );
  7247. }
  7248. });
  7249. jQuery.each( [ "get", "post" ], function( i, method ) {
  7250. jQuery[ method ] = function( url, data, callback, type ) {
  7251. // shift arguments if data argument was omitted
  7252. if ( jQuery.isFunction( data ) ) {
  7253. type = type || callback;
  7254. callback = data;
  7255. data = undefined;
  7256. }
  7257. return jQuery.ajax({
  7258. url: url,
  7259. type: method,
  7260. dataType: type,
  7261. data: data,
  7262. success: callback
  7263. });
  7264. };
  7265. });
  7266. // Attach a bunch of functions for handling common AJAX events
  7267. jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
  7268. jQuery.fn[ type ] = function( fn ) {
  7269. return this.on( type, fn );
  7270. };
  7271. });
  7272. jQuery._evalUrl = function( url ) {
  7273. return jQuery.ajax({
  7274. url: url,
  7275. type: "GET",
  7276. dataType: "script",
  7277. async: false,
  7278. global: false,
  7279. "throws": true
  7280. });
  7281. };
  7282. jQuery.fn.extend({
  7283. wrapAll: function( html ) {
  7284. var wrap;
  7285. if ( jQuery.isFunction( html ) ) {
  7286. return this.each(function( i ) {
  7287. jQuery( this ).wrapAll( html.call(this, i) );
  7288. });
  7289. }
  7290. if ( this[ 0 ] ) {
  7291. // The elements to wrap the target around
  7292. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  7293. if ( this[ 0 ].parentNode ) {
  7294. wrap.insertBefore( this[ 0 ] );
  7295. }
  7296. wrap.map(function() {
  7297. var elem = this;
  7298. while ( elem.firstElementChild ) {
  7299. elem = elem.firstElementChild;
  7300. }
  7301. return elem;
  7302. }).append( this );
  7303. }
  7304. return this;
  7305. },
  7306. wrapInner: function( html ) {
  7307. if ( jQuery.isFunction( html ) ) {
  7308. return this.each(function( i ) {
  7309. jQuery( this ).wrapInner( html.call(this, i) );
  7310. });
  7311. }
  7312. return this.each(function() {
  7313. var self = jQuery( this ),
  7314. contents = self.contents();
  7315. if ( contents.length ) {
  7316. contents.wrapAll( html );
  7317. } else {
  7318. self.append( html );
  7319. }
  7320. });
  7321. },
  7322. wrap: function( html ) {
  7323. var isFunction = jQuery.isFunction( html );
  7324. return this.each(function( i ) {
  7325. jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
  7326. });
  7327. },
  7328. unwrap: function() {
  7329. return this.parent().each(function() {
  7330. if ( !jQuery.nodeName( this, "body" ) ) {
  7331. jQuery( this ).replaceWith( this.childNodes );
  7332. }
  7333. }).end();
  7334. }
  7335. });
  7336. jQuery.expr.filters.hidden = function( elem ) {
  7337. // Support: Opera <= 12.12
  7338. // Opera reports offsetWidths and offsetHeights less than zero on some elements
  7339. return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
  7340. };
  7341. jQuery.expr.filters.visible = function( elem ) {
  7342. return !jQuery.expr.filters.hidden( elem );
  7343. };
  7344. var r20 = /%20/g,
  7345. rbracket = /\[\]$/,
  7346. rCRLF = /\r?\n/g,
  7347. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  7348. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  7349. function buildParams( prefix, obj, traditional, add ) {
  7350. var name;
  7351. if ( jQuery.isArray( obj ) ) {
  7352. // Serialize array item.
  7353. jQuery.each( obj, function( i, v ) {
  7354. if ( traditional || rbracket.test( prefix ) ) {
  7355. // Treat each array item as a scalar.
  7356. add( prefix, v );
  7357. } else {
  7358. // Item is non-scalar (array or object), encode its numeric index.
  7359. buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
  7360. }
  7361. });
  7362. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  7363. // Serialize object item.
  7364. for ( name in obj ) {
  7365. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  7366. }
  7367. } else {
  7368. // Serialize scalar item.
  7369. add( prefix, obj );
  7370. }
  7371. }
  7372. // Serialize an array of form elements or a set of
  7373. // key/values into a query string
  7374. jQuery.param = function( a, traditional ) {
  7375. var prefix,
  7376. s = [],
  7377. add = function( key, value ) {
  7378. // If value is a function, invoke it and return its value
  7379. value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
  7380. s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
  7381. };
  7382. // Set traditional to true for jQuery <= 1.3.2 behavior.
  7383. if ( traditional === undefined ) {
  7384. traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
  7385. }
  7386. // If an array was passed in, assume that it is an array of form elements.
  7387. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  7388. // Serialize the form elements
  7389. jQuery.each( a, function() {
  7390. add( this.name, this.value );
  7391. });
  7392. } else {
  7393. // If traditional, encode the "old" way (the way 1.3.2 or older
  7394. // did it), otherwise encode params recursively.
  7395. for ( prefix in a ) {
  7396. buildParams( prefix, a[ prefix ], traditional, add );
  7397. }
  7398. }
  7399. // Return the resulting serialization
  7400. return s.join( "&" ).replace( r20, "+" );
  7401. };
  7402. jQuery.fn.extend({
  7403. serialize: function() {
  7404. return jQuery.param( this.serializeArray() );
  7405. },
  7406. serializeArray: function() {
  7407. return this.map(function() {
  7408. // Can add propHook for "elements" to filter or add form elements
  7409. var elements = jQuery.prop( this, "elements" );
  7410. return elements ? jQuery.makeArray( elements ) : this;
  7411. })
  7412. .filter(function() {
  7413. var type = this.type;
  7414. // Use .is( ":disabled" ) so that fieldset[disabled] works
  7415. return this.name && !jQuery( this ).is( ":disabled" ) &&
  7416. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  7417. ( this.checked || !rcheckableType.test( type ) );
  7418. })
  7419. .map(function( i, elem ) {
  7420. var val = jQuery( this ).val();
  7421. return val == null ?
  7422. null :
  7423. jQuery.isArray( val ) ?
  7424. jQuery.map( val, function( val ) {
  7425. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7426. }) :
  7427. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7428. }).get();
  7429. }
  7430. });
  7431. jQuery.ajaxSettings.xhr = function() {
  7432. try {
  7433. return new XMLHttpRequest();
  7434. } catch( e ) {}
  7435. };
  7436. var xhrId = 0,
  7437. xhrCallbacks = {},
  7438. xhrSuccessStatus = {
  7439. // file protocol always yields status code 0, assume 200
  7440. 0: 200,
  7441. // Support: IE9
  7442. // #1450: sometimes IE returns 1223 when it should be 204
  7443. 1223: 204
  7444. },
  7445. xhrSupported = jQuery.ajaxSettings.xhr();
  7446. // Support: IE9
  7447. // Open requests must be manually aborted on unload (#5280)
  7448. if ( window.ActiveXObject ) {
  7449. jQuery( window ).on( "unload", function() {
  7450. for ( var key in xhrCallbacks ) {
  7451. xhrCallbacks[ key ]();
  7452. }
  7453. });
  7454. }
  7455. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  7456. support.ajax = xhrSupported = !!xhrSupported;
  7457. jQuery.ajaxTransport(function( options ) {
  7458. var callback;
  7459. // Cross domain only allowed if supported through XMLHttpRequest
  7460. if ( support.cors || xhrSupported && !options.crossDomain ) {
  7461. return {
  7462. send: function( headers, complete ) {
  7463. var i,
  7464. xhr = options.xhr(),
  7465. id = ++xhrId;
  7466. xhr.open( options.type, options.url, options.async, options.username, options.password );
  7467. // Apply custom fields if provided
  7468. if ( options.xhrFields ) {
  7469. for ( i in options.xhrFields ) {
  7470. xhr[ i ] = options.xhrFields[ i ];
  7471. }
  7472. }
  7473. // Override mime type if needed
  7474. if ( options.mimeType && xhr.overrideMimeType ) {
  7475. xhr.overrideMimeType( options.mimeType );
  7476. }
  7477. // X-Requested-With header
  7478. // For cross-domain requests, seeing as conditions for a preflight are
  7479. // akin to a jigsaw puzzle, we simply never set it to be sure.
  7480. // (it can always be set on a per-request basis or even using ajaxSetup)
  7481. // For same-domain requests, won't change header if already provided.
  7482. if ( !options.crossDomain && !headers["X-Requested-With"] ) {
  7483. headers["X-Requested-With"] = "XMLHttpRequest";
  7484. }
  7485. // Set headers
  7486. for ( i in headers ) {
  7487. xhr.setRequestHeader( i, headers[ i ] );
  7488. }
  7489. // Callback
  7490. callback = function( type ) {
  7491. return function() {
  7492. if ( callback ) {
  7493. delete xhrCallbacks[ id ];
  7494. callback = xhr.onload = xhr.onerror = null;
  7495. if ( type === "abort" ) {
  7496. xhr.abort();
  7497. } else if ( type === "error" ) {
  7498. complete(
  7499. // file: protocol always yields status 0; see #8605, #14207
  7500. xhr.status,
  7501. xhr.statusText
  7502. );
  7503. } else {
  7504. complete(
  7505. xhrSuccessStatus[ xhr.status ] || xhr.status,
  7506. xhr.statusText,
  7507. // Support: IE9
  7508. // Accessing binary-data responseText throws an exception
  7509. // (#11426)
  7510. typeof xhr.responseText === "string" ? {
  7511. text: xhr.responseText
  7512. } : undefined,
  7513. xhr.getAllResponseHeaders()
  7514. );
  7515. }
  7516. }
  7517. };
  7518. };
  7519. // Listen to events
  7520. xhr.onload = callback();
  7521. xhr.onerror = callback("error");
  7522. // Create the abort callback
  7523. callback = xhrCallbacks[ id ] = callback("abort");
  7524. // Do send the request
  7525. // This may raise an exception which is actually
  7526. // handled in jQuery.ajax (so no try/catch here)
  7527. xhr.send( options.hasContent && options.data || null );
  7528. },
  7529. abort: function() {
  7530. if ( callback ) {
  7531. callback();
  7532. }
  7533. }
  7534. };
  7535. }
  7536. });
  7537. // Install script dataType
  7538. jQuery.ajaxSetup({
  7539. accepts: {
  7540. script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  7541. },
  7542. contents: {
  7543. script: /(?:java|ecma)script/
  7544. },
  7545. converters: {
  7546. "text script": function( text ) {
  7547. jQuery.globalEval( text );
  7548. return text;
  7549. }
  7550. }
  7551. });
  7552. // Handle cache's special case and crossDomain
  7553. jQuery.ajaxPrefilter( "script", function( s ) {
  7554. if ( s.cache === undefined ) {
  7555. s.cache = false;
  7556. }
  7557. if ( s.crossDomain ) {
  7558. s.type = "GET";
  7559. }
  7560. });
  7561. // Bind script tag hack transport
  7562. jQuery.ajaxTransport( "script", function( s ) {
  7563. // This transport only deals with cross domain requests
  7564. if ( s.crossDomain ) {
  7565. var script, callback;
  7566. return {
  7567. send: function( _, complete ) {
  7568. script = jQuery("<script>").prop({
  7569. async: true,
  7570. charset: s.scriptCharset,
  7571. src: s.url
  7572. }).on(
  7573. "load error",
  7574. callback = function( evt ) {
  7575. script.remove();
  7576. callback = null;
  7577. if ( evt ) {
  7578. complete( evt.type === "error" ? 404 : 200, evt.type );
  7579. }
  7580. }
  7581. );
  7582. document.head.appendChild( script[ 0 ] );
  7583. },
  7584. abort: function() {
  7585. if ( callback ) {
  7586. callback();
  7587. }
  7588. }
  7589. };
  7590. }
  7591. });
  7592. var oldCallbacks = [],
  7593. rjsonp = /(=)\?(?=&|$)|\?\?/;
  7594. // Default jsonp settings
  7595. jQuery.ajaxSetup({
  7596. jsonp: "callback",
  7597. jsonpCallback: function() {
  7598. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  7599. this[ callback ] = true;
  7600. return callback;
  7601. }
  7602. });
  7603. // Detect, normalize options and install callbacks for jsonp requests
  7604. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  7605. var callbackName, overwritten, responseContainer,
  7606. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  7607. "url" :
  7608. typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
  7609. );
  7610. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  7611. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  7612. // Get callback name, remembering preexisting value associated with it
  7613. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  7614. s.jsonpCallback() :
  7615. s.jsonpCallback;
  7616. // Insert callback into url or form data
  7617. if ( jsonProp ) {
  7618. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  7619. } else if ( s.jsonp !== false ) {
  7620. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  7621. }
  7622. // Use data converter to retrieve json after script execution
  7623. s.converters["script json"] = function() {
  7624. if ( !responseContainer ) {
  7625. jQuery.error( callbackName + " was not called" );
  7626. }
  7627. return responseContainer[ 0 ];
  7628. };
  7629. // force json dataType
  7630. s.dataTypes[ 0 ] = "json";
  7631. // Install callback
  7632. overwritten = window[ callbackName ];
  7633. window[ callbackName ] = function() {
  7634. responseContainer = arguments;
  7635. };
  7636. // Clean-up function (fires after converters)
  7637. jqXHR.always(function() {
  7638. // Restore preexisting value
  7639. window[ callbackName ] = overwritten;
  7640. // Save back as free
  7641. if ( s[ callbackName ] ) {
  7642. // make sure that re-using the options doesn't screw things around
  7643. s.jsonpCallback = originalSettings.jsonpCallback;
  7644. // save the callback name for future use
  7645. oldCallbacks.push( callbackName );
  7646. }
  7647. // Call if it was a function and we have a response
  7648. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  7649. overwritten( responseContainer[ 0 ] );
  7650. }
  7651. responseContainer = overwritten = undefined;
  7652. });
  7653. // Delegate to script
  7654. return "script";
  7655. }
  7656. });
  7657. // data: string of html
  7658. // context (optional): If specified, the fragment will be created in this context, defaults to document
  7659. // keepScripts (optional): If true, will include scripts passed in the html string
  7660. jQuery.parseHTML = function( data, context, keepScripts ) {
  7661. if ( !data || typeof data !== "string" ) {
  7662. return null;
  7663. }
  7664. if ( typeof context === "boolean" ) {
  7665. keepScripts = context;
  7666. context = false;
  7667. }
  7668. context = context || document;
  7669. var parsed = rsingleTag.exec( data ),
  7670. scripts = !keepScripts && [];
  7671. // Single tag
  7672. if ( parsed ) {
  7673. return [ context.createElement( parsed[1] ) ];
  7674. }
  7675. parsed = jQuery.buildFragment( [ data ], context, scripts );
  7676. if ( scripts && scripts.length ) {
  7677. jQuery( scripts ).remove();
  7678. }
  7679. return jQuery.merge( [], parsed.childNodes );
  7680. };
  7681. // Keep a copy of the old load method
  7682. var _load = jQuery.fn.load;
  7683. /**
  7684. * Load a url into a page
  7685. */
  7686. jQuery.fn.load = function( url, params, callback ) {
  7687. if ( typeof url !== "string" && _load ) {
  7688. return _load.apply( this, arguments );
  7689. }
  7690. var selector, type, response,
  7691. self = this,
  7692. off = url.indexOf(" ");
  7693. if ( off >= 0 ) {
  7694. selector = url.slice( off );
  7695. url = url.slice( 0, off );
  7696. }
  7697. // If it's a function
  7698. if ( jQuery.isFunction( params ) ) {
  7699. // We assume that it's the callback
  7700. callback = params;
  7701. params = undefined;
  7702. // Otherwise, build a param string
  7703. } else if ( params && typeof params === "object" ) {
  7704. type = "POST";
  7705. }
  7706. // If we have elements to modify, make the request
  7707. if ( self.length > 0 ) {
  7708. jQuery.ajax({
  7709. url: url,
  7710. // if "type" variable is undefined, then "GET" method will be used
  7711. type: type,
  7712. dataType: "html",
  7713. data: params
  7714. }).done(function( responseText ) {
  7715. // Save response for use in complete callback
  7716. response = arguments;
  7717. self.html( selector ?
  7718. // If a selector was specified, locate the right elements in a dummy div
  7719. // Exclude scripts to avoid IE 'Permission Denied' errors
  7720. jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
  7721. // Otherwise use the full result
  7722. responseText );
  7723. }).complete( callback && function( jqXHR, status ) {
  7724. self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
  7725. });
  7726. }
  7727. return this;
  7728. };
  7729. jQuery.expr.filters.animated = function( elem ) {
  7730. return jQuery.grep(jQuery.timers, function( fn ) {
  7731. return elem === fn.elem;
  7732. }).length;
  7733. };
  7734. var docElem = window.document.documentElement;
  7735. /**
  7736. * Gets a window from an element
  7737. */
  7738. function getWindow( elem ) {
  7739. return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
  7740. }
  7741. jQuery.offset = {
  7742. setOffset: function( elem, options, i ) {
  7743. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  7744. position = jQuery.css( elem, "position" ),
  7745. curElem = jQuery( elem ),
  7746. props = {};
  7747. // Set position first, in-case top/left are set even on static elem
  7748. if ( position === "static" ) {
  7749. elem.style.position = "relative";
  7750. }
  7751. curOffset = curElem.offset();
  7752. curCSSTop = jQuery.css( elem, "top" );
  7753. curCSSLeft = jQuery.css( elem, "left" );
  7754. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  7755. ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
  7756. // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
  7757. if ( calculatePosition ) {
  7758. curPosition = curElem.position();
  7759. curTop = curPosition.top;
  7760. curLeft = curPosition.left;
  7761. } else {
  7762. curTop = parseFloat( curCSSTop ) || 0;
  7763. curLeft = parseFloat( curCSSLeft ) || 0;
  7764. }
  7765. if ( jQuery.isFunction( options ) ) {
  7766. options = options.call( elem, i, curOffset );
  7767. }
  7768. if ( options.top != null ) {
  7769. props.top = ( options.top - curOffset.top ) + curTop;
  7770. }
  7771. if ( options.left != null ) {
  7772. props.left = ( options.left - curOffset.left ) + curLeft;
  7773. }
  7774. if ( "using" in options ) {
  7775. options.using.call( elem, props );
  7776. } else {
  7777. curElem.css( props );
  7778. }
  7779. }
  7780. };
  7781. jQuery.fn.extend({
  7782. offset: function( options ) {
  7783. if ( arguments.length ) {
  7784. return options === undefined ?
  7785. this :
  7786. this.each(function( i ) {
  7787. jQuery.offset.setOffset( this, options, i );
  7788. });
  7789. }
  7790. var docElem, win,
  7791. elem = this[ 0 ],
  7792. box = { top: 0, left: 0 },
  7793. doc = elem && elem.ownerDocument;
  7794. if ( !doc ) {
  7795. return;
  7796. }
  7797. docElem = doc.documentElement;
  7798. // Make sure it's not a disconnected DOM node
  7799. if ( !jQuery.contains( docElem, elem ) ) {
  7800. return box;
  7801. }
  7802. // If we don't have gBCR, just use 0,0 rather than error
  7803. // BlackBerry 5, iOS 3 (original iPhone)
  7804. if ( typeof elem.getBoundingClientRect !== strundefined ) {
  7805. box = elem.getBoundingClientRect();
  7806. }
  7807. win = getWindow( doc );
  7808. return {
  7809. top: box.top + win.pageYOffset - docElem.clientTop,
  7810. left: box.left + win.pageXOffset - docElem.clientLeft
  7811. };
  7812. },
  7813. position: function() {
  7814. if ( !this[ 0 ] ) {
  7815. return;
  7816. }
  7817. var offsetParent, offset,
  7818. elem = this[ 0 ],
  7819. parentOffset = { top: 0, left: 0 };
  7820. // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
  7821. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  7822. // We assume that getBoundingClientRect is available when computed position is fixed
  7823. offset = elem.getBoundingClientRect();
  7824. } else {
  7825. // Get *real* offsetParent
  7826. offsetParent = this.offsetParent();
  7827. // Get correct offsets
  7828. offset = this.offset();
  7829. if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
  7830. parentOffset = offsetParent.offset();
  7831. }
  7832. // Add offsetParent borders
  7833. parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
  7834. parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
  7835. }
  7836. // Subtract parent offsets and element margins
  7837. return {
  7838. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  7839. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  7840. };
  7841. },
  7842. offsetParent: function() {
  7843. return this.map(function() {
  7844. var offsetParent = this.offsetParent || docElem;
  7845. while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
  7846. offsetParent = offsetParent.offsetParent;
  7847. }
  7848. return offsetParent || docElem;
  7849. });
  7850. }
  7851. });
  7852. // Create scrollLeft and scrollTop methods
  7853. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  7854. var top = "pageYOffset" === prop;
  7855. jQuery.fn[ method ] = function( val ) {
  7856. return access( this, function( elem, method, val ) {
  7857. var win = getWindow( elem );
  7858. if ( val === undefined ) {
  7859. return win ? win[ prop ] : elem[ method ];
  7860. }
  7861. if ( win ) {
  7862. win.scrollTo(
  7863. !top ? val : window.pageXOffset,
  7864. top ? val : window.pageYOffset
  7865. );
  7866. } else {
  7867. elem[ method ] = val;
  7868. }
  7869. }, method, val, arguments.length, null );
  7870. };
  7871. });
  7872. // Add the top/left cssHooks using jQuery.fn.position
  7873. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  7874. // getComputedStyle returns percent when specified for top/left/bottom/right
  7875. // rather than make the css module depend on the offset module, we just check for it here
  7876. jQuery.each( [ "top", "left" ], function( i, prop ) {
  7877. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  7878. function( elem, computed ) {
  7879. if ( computed ) {
  7880. computed = curCSS( elem, prop );
  7881. // if curCSS returns percentage, fallback to offset
  7882. return rnumnonpx.test( computed ) ?
  7883. jQuery( elem ).position()[ prop ] + "px" :
  7884. computed;
  7885. }
  7886. }
  7887. );
  7888. });
  7889. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  7890. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  7891. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
  7892. // margin is only for outerHeight, outerWidth
  7893. jQuery.fn[ funcName ] = function( margin, value ) {
  7894. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  7895. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  7896. return access( this, function( elem, type, value ) {
  7897. var doc;
  7898. if ( jQuery.isWindow( elem ) ) {
  7899. // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
  7900. // isn't a whole lot we can do. See pull request at this URL for discussion:
  7901. // https://github.com/jquery/jquery/pull/764
  7902. return elem.document.documentElement[ "client" + name ];
  7903. }
  7904. // Get document width or height
  7905. if ( elem.nodeType === 9 ) {
  7906. doc = elem.documentElement;
  7907. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  7908. // whichever is greatest
  7909. return Math.max(
  7910. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  7911. elem.body[ "offset" + name ], doc[ "offset" + name ],
  7912. doc[ "client" + name ]
  7913. );
  7914. }
  7915. return value === undefined ?
  7916. // Get width or height on the element, requesting but not forcing parseFloat
  7917. jQuery.css( elem, type, extra ) :
  7918. // Set width or height on the element
  7919. jQuery.style( elem, type, value, extra );
  7920. }, type, chainable ? margin : undefined, chainable, null );
  7921. };
  7922. });
  7923. });
  7924. // The number of elements contained in the matched element set
  7925. jQuery.fn.size = function() {
  7926. return this.length;
  7927. };
  7928. jQuery.fn.andSelf = jQuery.fn.addBack;
  7929. // Register as a named AMD module, since jQuery can be concatenated with other
  7930. // files that may use define, but not via a proper concatenation script that
  7931. // understands anonymous AMD modules. A named AMD is safest and most robust
  7932. // way to register. Lowercase jquery is used because AMD module names are
  7933. // derived from file names, and jQuery is normally delivered in a lowercase
  7934. // file name. Do this after creating the global so that if an AMD module wants
  7935. // to call noConflict to hide this version of jQuery, it will work.
  7936. if ( typeof define === "function" && define.amd ) {
  7937. define( "jquery", [], function() {
  7938. return jQuery;
  7939. });
  7940. }
  7941. var
  7942. // Map over jQuery in case of overwrite
  7943. _jQuery = window.jQuery,
  7944. // Map over the $ in case of overwrite
  7945. _$ = window.$;
  7946. jQuery.noConflict = function( deep ) {
  7947. if ( window.$ === jQuery ) {
  7948. window.$ = _$;
  7949. }
  7950. if ( deep && window.jQuery === jQuery ) {
  7951. window.jQuery = _jQuery;
  7952. }
  7953. return jQuery;
  7954. };
  7955. // Expose jQuery and $ identifiers, even in
  7956. // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  7957. // and CommonJS for browser emulators (#13566)
  7958. if ( typeof noGlobal === strundefined ) {
  7959. window.jQuery = window.$ = jQuery;
  7960. }
  7961. return jQuery;
  7962. }));
  7963. define("jquery", function(){});
  7964. define('select2/utils',[], function () {
  7965. var Utils = {};
  7966. Utils.Extend = function (ChildClass, SuperClass) {
  7967. var __hasProp = {}.hasOwnProperty;
  7968. function BaseConstructor () {
  7969. this.constructor = ChildClass;
  7970. }
  7971. for (var key in SuperClass) {
  7972. if (__hasProp.call(SuperClass, key)) {
  7973. ChildClass[key] = SuperClass[key];
  7974. }
  7975. }
  7976. BaseConstructor.prototype = SuperClass.prototype;
  7977. ChildClass.prototype = new BaseConstructor();
  7978. ChildClass.__super__ = SuperClass.prototype;
  7979. return ChildClass;
  7980. };
  7981. function getMethods (theClass) {
  7982. var proto = theClass.prototype;
  7983. var methods = [];
  7984. for (var methodName in proto) {
  7985. var m = proto[methodName];
  7986. if (typeof m !== 'function') {
  7987. continue;
  7988. }
  7989. methods.push(methodName);
  7990. }
  7991. return methods;
  7992. }
  7993. Utils.Decorate = function (SuperClass, DecoratorClass) {
  7994. var decoratedMethods = getMethods(DecoratorClass);
  7995. var superMethods = getMethods(SuperClass);
  7996. function DecoratedClass () {
  7997. var unshift = Array.prototype.unshift;
  7998. var argCount = DecoratorClass.prototype.constructor.length;
  7999. var calledConstructor = SuperClass.prototype.constructor;
  8000. if (argCount > 0) {
  8001. unshift.call(arguments, SuperClass.prototype.constructor);
  8002. calledConstructor = DecoratorClass.prototype.constructor;
  8003. }
  8004. calledConstructor.apply(this, arguments);
  8005. }
  8006. DecoratorClass.displayName = SuperClass.displayName;
  8007. function ctr () {
  8008. this.constructor = DecoratedClass;
  8009. }
  8010. DecoratedClass.prototype = new ctr();
  8011. for (var m = 0; m < superMethods.length; m++) {
  8012. var superMethod = superMethods[m];
  8013. DecoratedClass.prototype[superMethod] =
  8014. SuperClass.prototype[superMethod];
  8015. }
  8016. var calledMethod = function (methodName) {
  8017. // Stub out the original method if it's not decorating an actual method
  8018. var originalMethod = function () {};
  8019. if (methodName in DecoratedClass.prototype) {
  8020. originalMethod = DecoratedClass.prototype[methodName];
  8021. }
  8022. var decoratedMethod = DecoratorClass.prototype[methodName];
  8023. return function () {
  8024. var unshift = Array.prototype.unshift;
  8025. unshift.call(arguments, originalMethod);
  8026. return decoratedMethod.apply(this, arguments);
  8027. };
  8028. };
  8029. for (var d = 0; d < decoratedMethods.length; d++) {
  8030. var decoratedMethod = decoratedMethods[d];
  8031. DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
  8032. }
  8033. return DecoratedClass;
  8034. };
  8035. var Observable = function () {
  8036. this.listeners = {};
  8037. };
  8038. Observable.prototype.on = function (event, callback) {
  8039. if (event in this.listeners) {
  8040. this.listeners[event].push(callback);
  8041. } else {
  8042. this.listeners[event] = [callback];
  8043. }
  8044. };
  8045. Observable.prototype.trigger = function (event) {
  8046. var slice = Array.prototype.slice;
  8047. if (event in this.listeners) {
  8048. this.invoke(this.listeners[event], slice.call(arguments, 1));
  8049. }
  8050. if ('*' in this.listeners) {
  8051. this.invoke(this.listeners['*'], arguments);
  8052. }
  8053. };
  8054. Observable.prototype.invoke = function (listeners, params) {
  8055. for (var i = 0, len = listeners.length; i < len; i++) {
  8056. listeners[i].apply(this, params);
  8057. }
  8058. };
  8059. Utils.Observable = Observable;
  8060. return Utils;
  8061. });
  8062. define('select2/data/base',[
  8063. '../utils'
  8064. ], function (Utils) {
  8065. function BaseAdapter ($element, options) {
  8066. BaseAdapter.__super__.constructor.call(this);
  8067. }
  8068. Utils.Extend(BaseAdapter, Utils.Observable);
  8069. BaseAdapter.prototype.current = function (callback) {
  8070. throw new Error('The `current` method must be defined in child classes.');
  8071. };
  8072. BaseAdapter.prototype.query = function (params, callback) {
  8073. throw new Error('The `query` method must be defined in child classes.');
  8074. };
  8075. return BaseAdapter;
  8076. });
  8077. define('select2/data/select',[
  8078. './base',
  8079. '../utils',
  8080. 'jquery'
  8081. ], function (BaseAdapter, Utils, $) {
  8082. function SelectAdapter ($element, options) {
  8083. this.$element = $element;
  8084. SelectAdapter.__super__.constructor.call(this);
  8085. }
  8086. Utils.Extend(SelectAdapter, BaseAdapter);
  8087. SelectAdapter.prototype.current = function (callback) {
  8088. var data = [];
  8089. var self = this;
  8090. this.$element.find(':selected').each(function () {
  8091. var $option = $(this);
  8092. var option = self.item($option);
  8093. data.push(option);
  8094. });
  8095. callback(data);
  8096. };
  8097. SelectAdapter.prototype.select = function (data) {
  8098. var self = this;
  8099. if (this.$element.prop('multiple')) {
  8100. this.current(function (currentData) {
  8101. var val = [];
  8102. data = [data];
  8103. data.push.apply(data, currentData);
  8104. for (var d = 0; d < data.length; d++) {
  8105. id = data[d].id;
  8106. if (val.indexOf(id) === -1) {
  8107. val.push(id);
  8108. }
  8109. }
  8110. self.$element.val(val);
  8111. self.$element.trigger('change');
  8112. });
  8113. } else {
  8114. var val = data.id;
  8115. this.$element.val(val);
  8116. this.$element.trigger('change');
  8117. }
  8118. };
  8119. SelectAdapter.prototype.unselect = function (data) {
  8120. var self = this;
  8121. if (!this.$element.prop('multiple')) {
  8122. return;
  8123. }
  8124. this.current(function (currentData) {
  8125. var val = [];
  8126. for (var d = 0; d < currentData.length; d++) {
  8127. id = currentData[d].id;
  8128. if (id !== data.id && val.indexOf(id) === -1) {
  8129. val.push(id);
  8130. }
  8131. }
  8132. self.$element.val(val);
  8133. self.$element.trigger('change');
  8134. });
  8135. };
  8136. SelectAdapter.prototype.bind = function (container, $container) {
  8137. var self = this;
  8138. container.on('select', function (params) {
  8139. self.select(params.data);
  8140. });
  8141. container.on('unselect', function (params) {
  8142. self.unselect(params.data);
  8143. });
  8144. };
  8145. SelectAdapter.prototype.query = function (params, callback) {
  8146. var data = [];
  8147. var self = this;
  8148. this.$element.find('option').each(function () {
  8149. var $option = $(this);
  8150. var option = self.item($option);
  8151. if (self.matches(params, option)) {
  8152. data.push(option);
  8153. }
  8154. });
  8155. callback(data);
  8156. };
  8157. SelectAdapter.prototype.item = function ($option) {
  8158. var data = $option.data('data');
  8159. // If the data has already be generated, use it
  8160. if (data == null) {
  8161. data = {
  8162. id: $option.val(),
  8163. text: $option.html()
  8164. };
  8165. $option.data('data', data);
  8166. }
  8167. return data;
  8168. };
  8169. SelectAdapter.prototype.matches = function (params, data) {
  8170. if ($.trim(params.term) === '') {
  8171. return true;
  8172. }
  8173. if (data.text.indexOf(params.term) > -1) {
  8174. return true;
  8175. }
  8176. return false;
  8177. };
  8178. return SelectAdapter;
  8179. });
  8180. define('select2/results',[
  8181. './utils'
  8182. ], function (Utils) {
  8183. function Results ($element, options, dataAdapter) {
  8184. this.$element = $element;
  8185. this.data = dataAdapter;
  8186. Results.__super__.constructor.call(this);
  8187. }
  8188. Utils.Extend(Results, Utils.Observable);
  8189. Results.prototype.render = function () {
  8190. var $results = $(
  8191. '<ul class="options"></ul>'
  8192. );
  8193. this.$results = $results;
  8194. return $results;
  8195. };
  8196. Results.prototype.clear = function () {
  8197. this.$results.empty();
  8198. };
  8199. Results.prototype.append = function (data) {
  8200. var $options = [];
  8201. for (var d = 0; d < data.length; d++) {
  8202. var item = data[d];
  8203. var $option = this.option(item);
  8204. $options.push($option);
  8205. }
  8206. this.$results.append($options);
  8207. };
  8208. Results.prototype.setClasses = function () {
  8209. var self = this;
  8210. this.data.current(function (selected) {
  8211. selected = $.map(selected, function (s) { return s.id; });
  8212. self.$results.find('.option.selected').removeClass('selected');
  8213. var $options = self.$results.find('.option');
  8214. $options.each(function () {
  8215. var $option = $(this);
  8216. var item = $option.data('data');
  8217. if (selected.indexOf(item.id) > -1) {
  8218. $option.addClass('selected');
  8219. }
  8220. });
  8221. });
  8222. };
  8223. Results.prototype.option = function (data) {
  8224. var $option = $(
  8225. '<li class="option"></li>'
  8226. );
  8227. $option.html(data.text);
  8228. $option.data('data', data);
  8229. return $option;
  8230. };
  8231. Results.prototype.bind = function (container, $container) {
  8232. var self = this;
  8233. this.on('results:all', function (data) {
  8234. self.clear();
  8235. self.append(data);
  8236. self.setClasses();
  8237. });
  8238. this.on('results:append', function (data) {
  8239. self.append(data);
  8240. self.setClasses();
  8241. });
  8242. this.$results.on('mouseup', '.option', function (evt) {
  8243. var $this = $(this);
  8244. var data = $this.data('data');
  8245. if ($this.hasClass('selected')) {
  8246. self.trigger('unselected', {
  8247. originalEvent: evt,
  8248. data: data
  8249. });
  8250. self.setClasses();
  8251. return;
  8252. }
  8253. self.trigger('selected', {
  8254. originalEvent: evt,
  8255. data: data
  8256. });
  8257. self.setClasses();
  8258. });
  8259. this.$results.on('mouseenter', '.option', function (evt) {
  8260. self.$results.find('.option.highlighted').removeClass('highlighted');
  8261. $(this).addClass('highlighted');
  8262. });
  8263. this.$results.on('mouseleave', '.option', function (evt) {
  8264. $(this).removeClass('highlighted');
  8265. });
  8266. };
  8267. return Results;
  8268. });
  8269. define('select2/dropdown',[
  8270. './utils'
  8271. ], function (Utils) {
  8272. function Dropdown ($element, options) {
  8273. this.$element = $element;
  8274. }
  8275. Utils.Extend(Dropdown, Utils.Observable);
  8276. Dropdown.prototype.render = function () {
  8277. var $dropdown = $(
  8278. '<span class="">' +
  8279. '<span class="results"></span>' +
  8280. '</span>'
  8281. );
  8282. return $dropdown;
  8283. };
  8284. return Dropdown;
  8285. });
  8286. define('select2/selection/single',[
  8287. '../utils'
  8288. ], function (Utils) {
  8289. function SingleSelection ($element, options) {
  8290. this.$element = $element;
  8291. this.options = options;
  8292. SingleSelection.__super__.constructor.call(this);
  8293. }
  8294. Utils.Extend(SingleSelection, Utils.Observable);
  8295. SingleSelection.prototype.render = function () {
  8296. var $selection = $(
  8297. '<span class="single-select">' +
  8298. '<span class="rendered-selection"></span>' +
  8299. '</span>'
  8300. );
  8301. this.$selection = $selection;
  8302. return $selection;
  8303. };
  8304. SingleSelection.prototype.bind = function (container, $container) {
  8305. var self = this;
  8306. this.$selection.on('mousedown', function (evt) {
  8307. // Only respond to left clicks
  8308. if (evt.which !== 1) {
  8309. return;
  8310. }
  8311. self.trigger('toggle', {
  8312. originalEvent: evt
  8313. });
  8314. });
  8315. container.on('selection:update', function (params) {
  8316. self.update(params.data);
  8317. });
  8318. };
  8319. SingleSelection.prototype.clear = function () {
  8320. this.$selection.find('.rendered-selection').empty();
  8321. };
  8322. SingleSelection.prototype.display = function (data) {
  8323. return data.text;
  8324. };
  8325. SingleSelection.prototype.update = function (data) {
  8326. if (data.length === 0) {
  8327. this.clear();
  8328. return;
  8329. }
  8330. var selection = data[0];
  8331. var formatted = this.display(selection);
  8332. this.$selection.find('.rendered-selection').html(formatted);
  8333. };
  8334. return SingleSelection;
  8335. });
  8336. define('select2/selection/multiple',[
  8337. '../utils'
  8338. ], function (Utils) {
  8339. function MultipleSelection ($element, options) {
  8340. this.$element = $element;
  8341. this.options = options;
  8342. MultipleSelection.__super__.constructor.call(this);
  8343. }
  8344. Utils.Extend(MultipleSelection, Utils.Observable);
  8345. MultipleSelection.prototype.render = function () {
  8346. var $selection = $(
  8347. '<span class="multiple-select">' +
  8348. '<ul class="rendered-selection"></ul>' +
  8349. '</span>'
  8350. );
  8351. this.$selection = $selection;
  8352. return $selection;
  8353. };
  8354. MultipleSelection.prototype.bind = function (container, $container) {
  8355. var self = this;
  8356. this.$selection.on('click', function (evt) {
  8357. self.trigger('toggle', {
  8358. originalEvent: evt
  8359. });
  8360. });
  8361. container.on('selection:update', function (params) {
  8362. self.update(params.data);
  8363. });
  8364. };
  8365. MultipleSelection.prototype.clear = function () {
  8366. this.$selection.find('.rendered-selection').empty();
  8367. };
  8368. MultipleSelection.prototype.display = function (data) {
  8369. return data.text;
  8370. };
  8371. MultipleSelection.prototype.update = function (data) {
  8372. this.clear();
  8373. if (data.length === 0) {
  8374. return;
  8375. }
  8376. var $selections = [];
  8377. for (var d = 0; d < data.length; d++) {
  8378. var selection = data[d];
  8379. var formatted = this.display(selection);
  8380. var $selection = $('<ul class="choice"></ul>');
  8381. $selection.text(formatted);
  8382. $selection.data('data', data);
  8383. $selections.push($selection);
  8384. }
  8385. this.$selection.find('.rendered-selection').append($selections);
  8386. };
  8387. return MultipleSelection;
  8388. });
  8389. define('select2/data/array',[
  8390. './select',
  8391. '../utils'
  8392. ], function (SelectAdapter, Utils) {
  8393. function ArrayAdapter ($element, options) {
  8394. this.data = options.options.data;
  8395. ArrayAdapter.__super__.constructor.call(this, $element, options);
  8396. }
  8397. Utils.Extend(ArrayAdapter, SelectAdapter);
  8398. ArrayAdapter.prototype.select = function (data) {
  8399. var self = this;
  8400. this.$element.find('option').each(function () {
  8401. var $option = $(this);
  8402. var option = self.item($option);
  8403. if (option.id == data.id) {
  8404. $option.remove();
  8405. }
  8406. });
  8407. var $option = this.option(data);
  8408. this.$element.append($option);
  8409. ArrayAdapter.__super__.select.call(this, data);
  8410. };
  8411. ArrayAdapter.prototype.option = function (data) {
  8412. var $option = $('<option></option>');
  8413. $option.text(data.text);
  8414. $option.val(data.id);
  8415. $option.data('data', data);
  8416. return $option;
  8417. };
  8418. ArrayAdapter.prototype.query = function (params, callback) {
  8419. var matches = [];
  8420. var self = this;
  8421. $.each(this.data, function () {
  8422. var option = this;
  8423. if (self.matches(params, option)) {
  8424. matches.push(option);
  8425. }
  8426. });
  8427. callback(matches);
  8428. };
  8429. return ArrayAdapter;
  8430. });
  8431. define('select2/data/ajax',[
  8432. './array',
  8433. '../utils',
  8434. 'jquery'
  8435. ], function (ArrayAdapter, Utils, $) {
  8436. function AjaxAdapter ($element, options) {
  8437. this.ajaxOptions = options.options.ajax;
  8438. this.processResults = this.ajaxOptions.processResults ||
  8439. function (results) {
  8440. return results;
  8441. };
  8442. ArrayAdapter.__super__.constructor.call(this, $element, options);
  8443. }
  8444. Utils.Extend(AjaxAdapter, ArrayAdapter);
  8445. AjaxAdapter.prototype.query = function (params, callback) {
  8446. var matches = [];
  8447. var self = this;
  8448. var options = $.extend({
  8449. type: 'GET'
  8450. }, this.ajaxOptions);
  8451. if (typeof options.url === 'function') {
  8452. options.url = options.url(params);
  8453. }
  8454. if (typeof options.data === 'function') {
  8455. options.data = options.data(params);
  8456. }
  8457. var $request = $.ajax(options);
  8458. $request.success(function (data) {
  8459. var results = self.processResults(data);
  8460. callback(results);
  8461. });
  8462. };
  8463. return AjaxAdapter;
  8464. });
  8465. define('select2/options',[
  8466. './data/select',
  8467. './results',
  8468. './dropdown',
  8469. './selection/single',
  8470. './selection/multiple',
  8471. './data/array',
  8472. './data/ajax'
  8473. ], function (SelectData, ResultsList, Dropdown, SingleSelection,
  8474. MultipleSelection) {
  8475. function Options (options) {
  8476. this.options = options;
  8477. this.dataAdapter = options.dataAdapter || SelectData;
  8478. this.resultsAdapter = ResultsList;
  8479. this.dropdownAdapter = options.dropdownAdapter || Dropdown;
  8480. this.selectionAdapter = options.selectionAdapter;
  8481. if (this.selectionAdapter == null) {
  8482. if (this.options.multiple) {
  8483. this.selectionAdapter = MultipleSelection;
  8484. } else {
  8485. this.selectionAdapter = SingleSelection;
  8486. }
  8487. }
  8488. }
  8489. return Options;
  8490. });
  8491. define('select2/core',[
  8492. 'jquery',
  8493. './options',
  8494. './utils'
  8495. ], function ($, Options, Utils) {
  8496. var Select2 = function ($element, options) {
  8497. this.$element = $element;
  8498. options = options || {};
  8499. options.multiple = options.multiple || $element.prop('multiple');
  8500. this.options = new Options(options);
  8501. Select2.__super__.constructor.call(this);
  8502. // Set up containers and adapters
  8503. this.data = new this.options.dataAdapter($element, this.options);
  8504. var $container = this.render();
  8505. this.$container = $container;
  8506. $container.insertAfter(this.$element);
  8507. $container.width($element.width());
  8508. this.selection = new this.options.selectionAdapter($element, this.options);
  8509. var $selectionContainer = $container.find('.selection');
  8510. var $selection = this.selection.render();
  8511. $selectionContainer.append($selection);
  8512. this.dropdown = new this.options.dropdownAdapter($element, this.options);
  8513. var $dropdownContainer = $container.find('.dropdown');
  8514. var $dropdown = this.dropdown.render();
  8515. $dropdownContainer.append($dropdown);
  8516. this.results = new this.options.resultsAdapter(
  8517. $element, this.options, this.data);
  8518. var $resultsContainer = $dropdown.find('.results');
  8519. var $results = this.results.render();
  8520. $resultsContainer.append($results);
  8521. // Bind events
  8522. var self = this;
  8523. this.data.bind(this, $container);
  8524. this.selection.bind(this, $container);
  8525. this.results.bind(this, $container);
  8526. this.$element.on('change', function () {
  8527. self.data.current(function (data) {
  8528. self.trigger('selection:update', {
  8529. data: data
  8530. });
  8531. });
  8532. });
  8533. this.selection.on('toggle', function () {
  8534. self.toggleDropdown();
  8535. });
  8536. this.results.on('selected', function (params) {
  8537. self.trigger('select', params);
  8538. self.trigger('close');
  8539. });
  8540. this.results.on('unselected', function (params) {
  8541. self.trigger('unselect', params);
  8542. self.trigger('close');
  8543. });
  8544. this.on('open', function () {
  8545. $container.addClass('open');
  8546. });
  8547. this.on('close', function () {
  8548. $container.removeClass('open');
  8549. });
  8550. // Set the initial state
  8551. this.data.current(function (initialData) {
  8552. self.trigger('selection:update', {
  8553. data: initialData
  8554. });
  8555. });
  8556. this.data.query({}, function (data) {
  8557. self.results.trigger('results:all', data);
  8558. });
  8559. // Hide the original select
  8560. $element.hide();
  8561. };
  8562. Utils.Extend(Select2, Utils.Observable);
  8563. Select2.prototype.toggleDropdown = function () {
  8564. if (this.$container.hasClass('open')) {
  8565. this.trigger('close');
  8566. } else {
  8567. this.trigger('open');
  8568. }
  8569. };
  8570. Select2.prototype.render = function () {
  8571. var $container = $(
  8572. '<span class="select2 select2-container select2-theme-default">' +
  8573. '<span class="selection"></span>' +
  8574. '<span class="dropdown"></span>' +
  8575. '</span>'
  8576. );
  8577. return $container;
  8578. };
  8579. return Select2;
  8580. });